From 17512d497d7eaf01aefe8140f5010818c0103a95 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Thu, 7 Feb 2019 09:13:18 +0100 Subject: [PATCH 001/292] Disable Docker-based test servers on Windows temporarily The coin agent starts to crash after the docker-compose call. Need to have qt5 dev integrated first, then fix the real issue later. Task-number: QTQAINFRA-2717 Task-number: QTQAINFRA-2750 Change-Id: I255c0c10466cc9413ca41c756ebdb7c049511507 Reviewed-by: Aapo Keskimolo --- tests/auto/testserver.pri | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/testserver.pri b/tests/auto/testserver.pri index 26e7f6ab8a..eb83c6c2cc 100644 --- a/tests/auto/testserver.pri +++ b/tests/auto/testserver.pri @@ -58,9 +58,9 @@ debug_and_release:!build_pass: return() DOCKER_ENABLED = 1 -equals(QMAKE_HOST.os, Darwin) { +equals(QMAKE_HOST.os, Darwin) | equals(QMAKE_HOST.os, Windows) { DOCKER_ENABLED = 0 - message("Not using docker network test server on macOS, see QTQAINFRA-2717 and QTQAINFRA-2750") + message("Not using docker network test server on macOS and Windows, see QTQAINFRA-2717 and QTQAINFRA-2750") } TESTSERVER_VERSION = "" From 90a8de656fe689b6aa856e70e2d22de6630ea855 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 26 Jun 2018 17:12:02 +0200 Subject: [PATCH 002/292] Long live QColorSpace and friends Adds QColorSpace and QColorTransform classes, and parsing of a common subset of ICC profiles found in images, and also parses the ICC profiles in PNG and JPEGs. For backwards compatibility no automatic color handling is done by this patch. [ChangeLog][QtGui] A QColorSpace class has been added, and color spaces are now parsed from PNG and JPEG images. No automatic color space conversion is done however, and applications must request it. Change-Id: Ic09935f84640a716467fa3a9ed1e73c02daf3675 Reviewed-by: Eirik Aavitsland --- .../widgets/imageviewer/imageviewer.cpp | 2 + src/gui/image/qimage.cpp | 134 +++- src/gui/image/qimage.h | 10 +- src/gui/image/qimage_conversions.cpp | 4 +- src/gui/image/qimage_p.h | 4 + src/gui/image/qpnghandler.cpp | 72 +- src/gui/kernel/qguiapplication.cpp | 30 +- src/gui/kernel/qguiapplication_p.h | 11 +- src/gui/painting/painting.pri | 16 +- src/gui/painting/qcolormatrix_p.h | 214 ++++++ src/gui/painting/qcolorspace.cpp | 633 ++++++++++++++++ src/gui/painting/qcolorspace.h | 136 ++++ src/gui/painting/qcolorspace_p.h | 96 +++ src/gui/painting/qcolortransferfunction_p.h | 207 ++++++ src/gui/painting/qcolortransfertable_p.h | 245 +++++++ src/gui/painting/qcolortransform.cpp | 679 ++++++++++++++++++ src/gui/painting/qcolortransform.h | 93 +++ src/gui/painting/qcolortransform_p.h | 89 +++ src/gui/painting/qcolortrc_p.h | 129 ++++ .../{qcolorprofile.cpp => qcolortrclut.cpp} | 49 +- .../{qcolorprofile_p.h => qcolortrclut_p.h} | 72 +- src/gui/painting/qdrawhelper.cpp | 22 +- src/gui/painting/qicc.cpp | 669 +++++++++++++++++ src/gui/painting/qicc_p.h | 70 ++ src/gui/painting/qpainter_p.h | 2 + .../imageformats/jpeg/qjpeghandler.cpp | 14 +- tests/auto/gui/painting/painting.pro | 1 + tests/auto/gui/painting/qcolor/tst_qcolor.cpp | 5 +- .../gui/painting/qcolorspace/qcolorspace.pro | 9 + .../qcolorspace/resources/ProPhoto.jpg | Bin 0 -> 30900 bytes .../qcolorspace/resources/sRGB2014.icc | Bin 0 -> 3024 bytes .../painting/qcolorspace/tst_qcolorspace.cpp | 238 ++++++ 32 files changed, 3863 insertions(+), 92 deletions(-) create mode 100644 src/gui/painting/qcolormatrix_p.h create mode 100644 src/gui/painting/qcolorspace.cpp create mode 100644 src/gui/painting/qcolorspace.h create mode 100644 src/gui/painting/qcolorspace_p.h create mode 100644 src/gui/painting/qcolortransferfunction_p.h create mode 100644 src/gui/painting/qcolortransfertable_p.h create mode 100644 src/gui/painting/qcolortransform.cpp create mode 100644 src/gui/painting/qcolortransform.h create mode 100644 src/gui/painting/qcolortransform_p.h create mode 100644 src/gui/painting/qcolortrc_p.h rename src/gui/painting/{qcolorprofile.cpp => qcolortrclut.cpp} (69%) rename src/gui/painting/{qcolorprofile_p.h => qcolortrclut_p.h} (87%) create mode 100644 src/gui/painting/qicc.cpp create mode 100644 src/gui/painting/qicc_p.h create mode 100644 tests/auto/gui/painting/qcolorspace/qcolorspace.pro create mode 100644 tests/auto/gui/painting/qcolorspace/resources/ProPhoto.jpg create mode 100644 tests/auto/gui/painting/qcolorspace/resources/sRGB2014.icc create mode 100644 tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp diff --git a/examples/widgets/widgets/imageviewer/imageviewer.cpp b/examples/widgets/widgets/imageviewer/imageviewer.cpp index fed551dade..2fc8ff63de 100644 --- a/examples/widgets/widgets/imageviewer/imageviewer.cpp +++ b/examples/widgets/widgets/imageviewer/imageviewer.cpp @@ -106,6 +106,8 @@ bool ImageViewer::loadFile(const QString &fileName) void ImageViewer::setImage(const QImage &newImage) { image = newImage; + if (image.colorSpace().isValid()) + image.convertToColorSpace(QColorSpace::SRgb); imageLabel->setPixmap(QPixmap::fromImage(image)); //! [4] scaleFactor = 1.0; diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 16de045cf0..204729b551 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2018 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -38,8 +38,10 @@ ****************************************************************************/ #include "qimage.h" -#include "qdatastream.h" + #include "qbuffer.h" +#include "qdatastream.h" +#include "qcolortransform.h" #include "qmap.h" #include "qmatrix.h" #include "qtransform.h" @@ -54,6 +56,7 @@ #include #include #include +#include #include #include #include @@ -1098,6 +1101,7 @@ static void copyMetadata(QImageData *dst, const QImageData *src) dst->dpmy = src->dpmy; dst->devicePixelRatio = src->devicePixelRatio; dst->text = src->text; + dst->colorSpace = src->colorSpace; } /*! @@ -4920,6 +4924,132 @@ QTransform QImage::trueMatrix(const QTransform &matrix, int w, int h) return matrix * QTransform().translate(-delta.x(), -delta.y()); } +/*! + \since 5.14 + + Sets the image color space to \a colorSpace without performing any conversions on image data. + + \sa colorSpace() +*/ +void QImage::setColorSpace(const QColorSpace &colorSpace) +{ + if (!d) + return; + if (d->colorSpace == colorSpace) + return; + if (!isDetached()) // Detach only if shared, not for read-only data. + detach(); + d->colorSpace = colorSpace; +} + +/*! + \since 5.14 + + Converts the image to \a colorSpace. + + If the image has no valid color space, the method does nothing. + + \sa convertedToColorSpace(), setColorSpace() +*/ +void QImage::convertToColorSpace(const QColorSpace &colorSpace) +{ + if (!d) + return; + if (!d->colorSpace.isValid()) + return; + if (!colorSpace.isValid()) { + qWarning() << "QImage::convertToColorSpace: Output colorspace is not valid"; + return; + } + detach(); + applyColorTransform(d->colorSpace.transformationToColorSpace(colorSpace)); + d->colorSpace = colorSpace; +} + +/*! + \since 5.14 + + Returns the image converted to \a colorSpace. + + If the image has no valid color space, a null QImage is returned. + + \sa convertToColorSpace() +*/ +QImage QImage::convertedToColorSpace(const QColorSpace &colorSpace) const +{ + if (!d || !d->colorSpace.isValid() || !colorSpace.isValid()) + return QImage(); + QImage image = copy(); + image.convertToColorSpace(colorSpace); + return image; +} + +/*! + \since 5.14 + + Returns the color space of the image if a color space is defined. +*/ +QColorSpace QImage::colorSpace() const +{ + if (!d) + return QColorSpace::Undefined; + return d->colorSpace; +} + +/*! + \since 5.14 + + Applies the color transformation \a transform to all pixels in the image. +*/ +void QImage::applyColorTransform(const QColorTransform &transform) +{ + QImage::Format oldFormat = format(); + if (depth() > 32) { + if (format() != QImage::Format_RGBX64 && format() != QImage::Format_RGBA64 + && format() != QImage::Format_RGBA64_Premultiplied) + *this = std::move(*this).convertToFormat(QImage::Format_RGBA64); + } else if (format() != QImage::Format_ARGB32 && format() != QImage::Format_RGB32 + && format() != QImage::Format_ARGB32_Premultiplied) { + if (hasAlphaChannel()) + *this = std::move(*this).convertToFormat(QImage::Format_ARGB32); + else + *this = std::move(*this).convertToFormat(QImage::Format_RGB32); + } + + QColorTransformPrivate::TransformFlags flags = QColorTransformPrivate::Unpremultiplied; + switch (format()) { + case Format_ARGB32_Premultiplied: + case Format_RGBA64_Premultiplied: + flags = QColorTransformPrivate::Premultiplied; + break; + case Format_RGB32: + case Format_RGBX64: + flags = QColorTransformPrivate::InputOpaque; + break; + case Format_ARGB32: + case Format_RGBA64: + break; + default: + Q_UNREACHABLE(); + } + + if (depth() > 32) { + for (int i = 0; i < height(); ++i) { + QRgba64 *scanline = reinterpret_cast(scanLine(i)); + transform.d_func()->apply(scanline, scanline, width(), flags); + } + } else { + for (int i = 0; i < height(); ++i) { + QRgb *scanline = reinterpret_cast(scanLine(i)); + transform.d_func()->apply(scanline, scanline, width(), flags); + } + } + + if (oldFormat != format()) + *this = std::move(*this).convertToFormat(oldFormat); +} + + bool QImageData::convertInPlace(QImage::Format newFormat, Qt::ImageConversionFlags flags) { if (format == newFormat) diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index 45f571807c..b09e69c839 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -61,9 +61,11 @@ Q_FORWARD_DECLARE_MUTABLE_CG_TYPE(CGImage); QT_BEGIN_NAMESPACE +class QColorSpace; +class QColorTransform; class QIODevice; -class QStringList; class QMatrix; +class QStringList; class QTransform; class QVariant; template class QList; @@ -296,6 +298,12 @@ public: #endif void invertPixels(InvertMode = InvertRgb); + QColorSpace colorSpace() const; + QImage convertedToColorSpace(const QColorSpace &) const; + void convertToColorSpace(const QColorSpace &); + void setColorSpace(const QColorSpace &); + + void applyColorTransform(const QColorTransform &transform); bool load(QIODevice *device, const char* format); bool load(const QString &fileName, const char *format = nullptr); diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index 82ffb8af8b..837ac88470 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -39,7 +39,7 @@ #include #include -#include +#include #include #include #include @@ -100,7 +100,7 @@ const uchar *qt_get_bitflip_array() void qGamma_correct_back_to_linear_cs(QImage *image) { - const QColorProfile *cp = QGuiApplicationPrivate::instance()->colorProfileForA32Text(); + const QColorTrcLut *cp = QGuiApplicationPrivate::instance()->colorProfileForA32Text(); if (!cp) return; // gamma correct the pixels back to linear color space... diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h index de12a313e8..a599fc17c9 100644 --- a/src/gui/image/qimage_p.h +++ b/src/gui/image/qimage_p.h @@ -51,7 +51,9 @@ // We mean it. // +#include #include +#include #include #include @@ -106,6 +108,8 @@ struct Q_GUI_EXPORT QImageData { // internal image data QPaintEngine *paintEngine; + QColorSpace colorSpace; + struct ImageSizeParameters { qsizetype bytesPerLine; qsizetype totalSize; diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index 3655c39326..066261620b 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -42,6 +42,7 @@ #ifndef QT_NO_IMAGEFORMAT_PNG #include +#include #include #include #include @@ -50,6 +51,10 @@ #include // for qt_getImageText +#include +#include +#include + #include #include @@ -96,9 +101,16 @@ public: ReadingEnd, Error }; + // Defines the order of how the various ways of setting colorspace overrides eachother: + enum ColorSpaceState { + Undefined = 0, + GammaChrm = 1, // gAMA+cHRM chunks + Srgb = 2, // sRGB chunk + Icc = 3 // iCCP chunk + }; QPngHandlerPrivate(QPngHandler *qq) - : gamma(0.0), fileGamma(0.0), quality(50), compression(50), png_ptr(0), info_ptr(0), end_info(0), state(Ready), q(qq) + : gamma(0.0), fileGamma(0.0), quality(50), compression(50), colorSpaceState(Undefined), png_ptr(0), info_ptr(0), end_info(0), state(Ready), q(qq) { } float gamma; @@ -108,6 +120,8 @@ public: QString description; QSize scaledSize; QStringList readTexts; + QColorSpace colorSpace; + ColorSpaceState colorSpaceState; png_struct *png_ptr; png_info *info_ptr; @@ -226,11 +240,8 @@ void qpiw_flush_fn(png_structp /* png_ptr */) } static -void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, QSize scaledSize, bool *doScaledRead, float screen_gamma=0.0, float file_gamma=0.0) +void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, QSize scaledSize, bool *doScaledRead) { - if (screen_gamma != 0.0 && file_gamma != 0.0) - png_set_gamma(png_ptr, 1.0f / screen_gamma, file_gamma); - png_uint_32 width; png_uint_32 height; int bit_depth; @@ -585,10 +596,45 @@ bool QPngHandlerPrivate::readPngHeader() readPngTexts(info_ptr); +#ifdef PNG_iCCP_SUPPORTED + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_iCCP)) { + png_charp name = nullptr; + int compressionType = 0; +#if (PNG_LIBPNG_VER < 10500) + png_charp profileData = nullptr; +#else + png_bytep profileData = nullptr; +#endif + png_uint_32 profLen; + png_get_iCCP(png_ptr, info_ptr, &name, &compressionType, &profileData, &profLen); + if (!QIcc::fromIccProfile(QByteArray::fromRawData((const char *)profileData, profLen), &colorSpace)) { + qWarning() << "QPngHandler: Failed to parse ICC profile"; + } else { + colorSpaceState = Icc; + } + } +#endif + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sRGB)) { + int rendering_intent = -1; + png_get_sRGB(png_ptr, info_ptr, &rendering_intent); + // We don't actually care about the rendering_intent, just that it is valid + if (rendering_intent >= 0 && rendering_intent <= 3 && colorSpaceState <= Srgb) { + colorSpace = QColorSpace::SRgb; + colorSpaceState = Srgb; + } + } if (png_get_valid(png_ptr, info_ptr, PNG_INFO_gAMA)) { double file_gamma = 0.0; png_get_gAMA(png_ptr, info_ptr, &file_gamma); fileGamma = file_gamma; + if (fileGamma > 0.0f && colorSpaceState <= GammaChrm) { + QColorSpacePrivate *csPrivate = colorSpace.d_func(); + csPrivate->gamut = QColorSpace::Gamut::SRgb; + csPrivate->transferFunction = QColorSpace::TransferFunction::Gamma; + csPrivate->gamma = fileGamma; + csPrivate->initialize(); + colorSpaceState = GammaChrm; + } } state = ReadHeader; @@ -613,8 +659,19 @@ bool QPngHandlerPrivate::readPngImage(QImage *outImage) return false; } + if (gamma != 0.0 && fileGamma != 0.0) { + // This configuration forces gamma correction and + // thus changes the output colorspace + png_set_gamma(png_ptr, 1.0f / gamma, fileGamma); + QColorSpacePrivate *csPrivate = colorSpace.d_func(); + csPrivate->transferFunction = QColorSpace::TransferFunction::Gamma; + csPrivate->gamma = gamma; + csPrivate->initialize(); + colorSpaceState = GammaChrm; + } + bool doScaledRead = false; - setup_qt(*outImage, png_ptr, info_ptr, scaledSize, &doScaledRead, gamma, fileGamma); + setup_qt(*outImage, png_ptr, info_ptr, scaledSize, &doScaledRead); if (outImage->isNull()) { png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); @@ -683,6 +740,9 @@ bool QPngHandlerPrivate::readPngImage(QImage *outImage) if (scaledSize.isValid() && outImage->size() != scaledSize) *outImage = outImage->scaled(scaledSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + if (colorSpaceState > Undefined && colorSpace.isValid()) + outImage->setColorSpace(colorSpace); + return true; } diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 4a0febc615..6753bf64bc 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -68,7 +68,7 @@ #include #include #include "qsessionmanager.h" -#include +#include #include #include @@ -1643,8 +1643,6 @@ QGuiApplicationPrivate::~QGuiApplicationPrivate() platform_theme = 0; delete platform_integration; platform_integration = 0; - delete m_a8ColorProfile.load(); - delete m_a32ColorProfile.load(); window_list.clear(); screen_list.clear(); @@ -4019,32 +4017,26 @@ void QGuiApplicationPrivate::notifyDragStarted(const QDrag *drag) } #endif -const QColorProfile *QGuiApplicationPrivate::colorProfileForA8Text() +const QColorTrcLut *QGuiApplicationPrivate::colorProfileForA8Text() { #ifdef Q_OS_WIN - QColorProfile *result = m_a8ColorProfile.load(); - if (!result){ - QColorProfile *cs = QColorProfile::fromGamma(2.31); // This is a hard-coded thing for Windows text rendering - if (!m_a8ColorProfile.testAndSetRelease(0, cs)) - delete cs; - result = m_a8ColorProfile.load(); + if (!m_a8ColorProfile){ + QColorTrcLut *cs = QColorTrcLut::fromGamma(2.31); // This is a hard-coded thing for Windows text rendering + m_a8ColorProfile.reset(cs); } - return result; + return m_a8ColorProfile.get(); #else return colorProfileForA32Text(); #endif } -const QColorProfile *QGuiApplicationPrivate::colorProfileForA32Text() +const QColorTrcLut *QGuiApplicationPrivate::colorProfileForA32Text() { - QColorProfile *result = m_a32ColorProfile.load(); - if (!result){ - QColorProfile *cs = QColorProfile::fromGamma(fontSmoothingGamma); - if (!m_a32ColorProfile.testAndSetRelease(0, cs)) - delete cs; - result = m_a32ColorProfile.load(); + if (!m_a32ColorProfile) { + QColorTrcLut *cs = QColorTrcLut::fromGamma(fontSmoothingGamma); + m_a32ColorProfile.reset(cs); } - return result; + return m_a32ColorProfile.get(); } void QGuiApplicationPrivate::_q_updateFocusObject(QObject *object) diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 63646dcd50..61d9661286 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -55,6 +55,7 @@ #include #include +#include #include #include @@ -66,7 +67,7 @@ QT_BEGIN_NAMESPACE -class QColorProfile; +class QColorTrcLut; class QPlatformIntegration; class QPlatformTheme; class QPlatformDragQtResponse; @@ -299,8 +300,8 @@ public: static QInputDeviceManager *inputDeviceManager(); - const QColorProfile *colorProfileForA8Text(); - const QColorProfile *colorProfileForA32Text(); + const QColorTrcLut *colorProfileForA8Text(); + const QColorTrcLut *colorProfileForA32Text(); // hook reimplemented in QApplication to apply the QStyle function on the QIcon virtual QPixmap applyQIconStyleHelper(QIcon::Mode, const QPixmap &basePixmap) const { return basePixmap; } @@ -327,8 +328,8 @@ private: static QGuiApplicationPrivate *self; static QTouchDevice *m_fakeTouchDevice; static int m_fakeMouseSourcePointId; - QAtomicPointer m_a8ColorProfile; - QAtomicPointer m_a32ColorProfile; + QSharedPointer m_a8ColorProfile; + QSharedPointer m_a32ColorProfile; bool ownGlobalShareContext; diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index c3585a4647..0e2dfed9ab 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -8,7 +8,15 @@ HEADERS += \ painting/qbrush.h \ painting/qcolor.h \ painting/qcolor_p.h \ - painting/qcolorprofile_p.h \ + painting/qcolormatrix_p.h \ + painting/qcolorspace.h \ + painting/qcolorspace_p.h \ + painting/qcolortransferfunction_p.h \ + painting/qcolortransfertable_p.h \ + painting/qcolortransform.h \ + painting/qcolortransform_p.h \ + painting/qcolortrc_p.h \ + painting/qcolortrclut_p.h \ painting/qcosmeticstroker_p.h \ painting/qdatabuffer_p.h \ painting/qdrawhelper_p.h \ @@ -17,6 +25,7 @@ HEADERS += \ painting/qemulationpaintengine_p.h \ painting/qfixed_p.h \ painting/qgrayraster_p.h \ + painting/qicc_p.h \ painting/qmatrix.h \ painting/qmemrotate_p.h \ painting/qoutlinemapper_p.h \ @@ -64,12 +73,15 @@ SOURCES += \ painting/qblittable.cpp \ painting/qbrush.cpp \ painting/qcolor.cpp \ - painting/qcolorprofile.cpp \ + painting/qcolorspace.cpp \ + painting/qcolortransform.cpp \ + painting/qcolortrclut.cpp \ painting/qcompositionfunctions.cpp \ painting/qcosmeticstroker.cpp \ painting/qdrawhelper.cpp \ painting/qemulationpaintengine.cpp \ painting/qgrayraster.c \ + painting/qicc.cpp \ painting/qimagescale.cpp \ painting/qmatrix.cpp \ painting/qmemrotate.cpp \ diff --git a/src/gui/painting/qcolormatrix_p.h b/src/gui/painting/qcolormatrix_p.h new file mode 100644 index 0000000000..3d1dca6222 --- /dev/null +++ b/src/gui/painting/qcolormatrix_p.h @@ -0,0 +1,214 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCOLORMATRIX_H +#define QCOLORMATRIX_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +// An abstract 3 value color +class QColorVector +{ +public: + QColorVector() = default; + constexpr QColorVector(float x, float y, float z) : x(x), y(y), z(z), _unused(0.0f) { } + float x; // X, x or red + float y; // Y, y or green + float z; // Z, Y or blue + float _unused; + + friend inline bool operator==(const QColorVector &v1, const QColorVector &v2); + friend inline bool operator!=(const QColorVector &v1, const QColorVector &v2); + + static constexpr QColorVector null() { return QColorVector(0.0f, 0.0f, 0.0f); } + // Common whitepoints on normalized XYZ form: + static constexpr QColorVector D50() { return QColorVector(0.96421f, 1.0f, 0.82519f); } + static constexpr QColorVector D65() { return QColorVector(0.95043f, 1.0f, 1.08890f); } +}; + +inline bool operator==(const QColorVector &v1, const QColorVector &v2) +{ + return (std::abs(v1.x - v2.x) < (1.0f / 2048.0f)) + && (std::abs(v1.y - v2.y) < (1.0f / 2048.0f)) + && (std::abs(v1.z - v2.z) < (1.0f / 2048.0f)); +} + +inline bool operator!=(const QColorVector &v1, const QColorVector &v2) +{ + return !(v1 == v2); +} + + +// A matrix mapping 3 value colors. +// Not using QMatrix because only floats are needed and performance is critical. +class QColorMatrix +{ +public: + // We are storing the matrix transposed as that is more convenient: + QColorVector r; + QColorVector g; + QColorVector b; + + friend inline bool operator==(const QColorMatrix &m1, const QColorMatrix &m2); + friend inline bool operator!=(const QColorMatrix &m1, const QColorMatrix &m2); + + bool isValid() const + { + // A color matrix must be invertible + float det = r.x * (b.z * g.y - g.z * b.y) - + r.y * (b.z * g.x - g.z * b.x) + + r.z * (b.y * g.x - g.y * b.x); + return !qFuzzyIsNull(det); + } + + QColorMatrix inverted() const + { + float det = r.x * (b.z * g.y - g.z * b.y) - + r.y * (b.z * g.x - g.z * b.x) + + r.z * (b.y * g.x - g.y * b.x); + det = 1.0f / det; + QColorMatrix inv; + inv.r.x = (g.y * b.z - b.y * g.z) * det; + inv.r.y = (b.y * r.z - r.y * b.z) * det; + inv.r.z = (r.y * g.z - g.y * r.z) * det; + inv.g.x = (b.x * g.z - g.x * b.z) * det; + inv.g.y = (r.x * b.z - b.x * r.z) * det; + inv.g.z = (g.x * r.z - r.x * g.z) * det; + inv.b.x = (g.x * b.y - b.x * g.y) * det; + inv.b.y = (b.x * r.y - r.x * b.y) * det; + inv.b.z = (r.x * g.y - g.x * r.y) * det; + return inv; + } + QColorMatrix operator*(const QColorMatrix &o) const + { + QColorMatrix comb; + comb.r.x = r.x * o.r.x + g.x * o.r.y + b.x * o.r.z; + comb.g.x = r.x * o.g.x + g.x * o.g.y + b.x * o.g.z; + comb.b.x = r.x * o.b.x + g.x * o.b.y + b.x * o.b.z; + + comb.r.y = r.y * o.r.x + g.y * o.r.y + b.y * o.r.z; + comb.g.y = r.y * o.g.x + g.y * o.g.y + b.y * o.g.z; + comb.b.y = r.y * o.b.x + g.y * o.b.y + b.y * o.b.z; + + comb.r.z = r.z * o.r.x + g.z * o.r.y + b.z * o.r.z; + comb.g.z = r.z * o.g.x + g.z * o.g.y + b.z * o.g.z; + comb.b.z = r.z * o.b.x + g.z * o.b.y + b.z * o.b.z; + return comb; + + } + QColorVector map(const QColorVector &c) const + { + return QColorVector { c.x * r.x + c.y * g.x + c.z * b.x, + c.x * r.y + c.y * g.y + c.z * b.y, + c.x * r.z + c.y * g.z + c.z * b.z }; + } + QColorMatrix transposed() const + { + return QColorMatrix { { r.x, g.x, b.x }, + { r.y, g.y, b.y }, + { r.z, g.z, b.z } }; + } + + static QColorMatrix null() + { + return { QColorVector::null(), QColorVector::null(), QColorVector::null() }; + } + static QColorMatrix identity() + { + return { { 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 1.0f } }; + } + static QColorMatrix toXyzFromSRgb() + { + return QColorMatrix { { 0.4360217452f, 0.2224751115f, 0.0139281144f }, + { 0.3851087987f, 0.7169067264f, 0.0971015394f }, + { 0.1430812478f, 0.0606181994f, 0.7141585946f } }; + } + static QColorMatrix toXyzFromAdobeRgb() + { + return QColorMatrix { { 0.6097189188f, 0.3111021519f, 0.0194766335f }, + { 0.2052682191f, 0.6256770492f, 0.0608891509f }, + { 0.1492247432f, 0.0632209629f, 0.7448224425f } }; + } + static QColorMatrix toXyzFromDciP3D65() + { + return QColorMatrix { { 0.5150973201f, 0.2411795557f, -0.0010491034f }, + { 0.2919696569f, 0.6922441125f, 0.0418830328f }, + { 0.1571449190f, 0.0665764511f, 0.7843542695f } }; + } + static QColorMatrix toXyzFromProPhotoRgb() + { + return QColorMatrix { { 0.7976672649f, 0.2880374491f, 0.0000000000f }, + { 0.1351922452f, 0.7118769884f, 0.0000000000f }, + { 0.0313525312f, 0.0000856627f, 0.8251883388f } }; + } + static QColorMatrix toXyzFromBt2020() + { + return QColorMatrix { { 0.6506130099f, 0.2695676684f, -0.0018652577f }, + { 0.1865101457f, 0.6840794086f, 0.0172256753f }, + { 0.1270887405f, 0.0463530831f, 0.8098278046f } }; + } +}; + +inline bool operator==(const QColorMatrix &m1, const QColorMatrix &m2) +{ + return (m1.r == m2.r) && (m1.g == m2.g) && (m1.b == m2.b); +} + +inline bool operator!=(const QColorMatrix &m1, const QColorMatrix &m2) +{ + return !(m1 == m2); +} + +QT_END_NAMESPACE + +#endif // QCOLORMATRIX_P_H diff --git a/src/gui/painting/qcolorspace.cpp b/src/gui/painting/qcolorspace.cpp new file mode 100644 index 0000000000..24785f7b61 --- /dev/null +++ b/src/gui/painting/qcolorspace.cpp @@ -0,0 +1,633 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qcolorspace.h" +#include "qcolorspace_p.h" + +#include "qcolortransform.h" +#include "qcolormatrix_p.h" +#include "qcolortransferfunction_p.h" +#include "qcolortransform_p.h" +#include "qicc_p.h" + +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +QColorSpacePrivate::QColorSpacePrivate() + : id(QColorSpace::Unknown) + , gamut(QColorSpace::Gamut::Custom) + , transferFunction(QColorSpace::TransferFunction::Custom) + , gamma(0.0f) + , whitePoint(QColorVector::null()) + , toXyz(QColorMatrix::null()) +{ +} + +QColorSpacePrivate::QColorSpacePrivate(QColorSpace::ColorSpaceId colorSpaceId) + : id(colorSpaceId) +{ + switch (colorSpaceId) { + case QColorSpace::Undefined: + gamut = QColorSpace::Gamut::Custom; + transferFunction = QColorSpace::TransferFunction::Custom; + gamma = 0.0f; + description = QStringLiteral("Undefined"); + break; + case QColorSpace::SRgb: + gamut = QColorSpace::Gamut::SRgb; + transferFunction = QColorSpace::TransferFunction::SRgb; + gamma = 2.31f; // ? + description = QStringLiteral("sRGB"); + break; + case QColorSpace::SRgbLinear: + gamut = QColorSpace::Gamut::SRgb; + transferFunction = QColorSpace::TransferFunction::Linear; + gamma = 1.0f; + description = QStringLiteral("Linear sRGB"); + break; + case QColorSpace::AdobeRgb: + gamut = QColorSpace::Gamut::AdobeRgb; + transferFunction = QColorSpace::TransferFunction::Gamma; + gamma = 2.19921875f; // Not quite 2.2, see https://www.adobe.com/digitalimag/pdfs/AdobeRGB1998.pdf + description = QStringLiteral("Adobe RGB"); + break; + case QColorSpace::DisplayP3: + gamut = QColorSpace::Gamut::DciP3D65; + transferFunction = QColorSpace::TransferFunction::SRgb; + gamma = 2.31f; // ? + description = QStringLiteral("Display P3"); + break; + case QColorSpace::ProPhotoRgb: + gamut = QColorSpace::Gamut::ProPhotoRgb; + transferFunction = QColorSpace::TransferFunction::ProPhotoRgb; + gamma = 1.8f; + description = QStringLiteral("ProPhoto RGB"); + break; + case QColorSpace::Bt2020: + gamut = QColorSpace::Gamut::Bt2020; + transferFunction = QColorSpace::TransferFunction::Bt2020; + gamma = 2.1f; // ? + description = QStringLiteral("BT.2020"); + break; + case QColorSpace::Unknown: + qWarning("Can not create an unknown color space"); + Q_FALLTHROUGH(); + default: + Q_UNREACHABLE(); + } + initialize(); +} + +QColorSpacePrivate::QColorSpacePrivate(QColorSpace::Gamut gamut, QColorSpace::TransferFunction fun, float gamma) + : gamut(gamut) + , transferFunction(fun) + , gamma(gamma) +{ + if (!identifyColorSpace()) + id = QColorSpace::Unknown; + initialize(); +} + +bool QColorSpacePrivate::identifyColorSpace() +{ + switch (gamut) { + case QColorSpace::Gamut::SRgb: + if (transferFunction == QColorSpace::TransferFunction::SRgb) { + id = QColorSpace::SRgb; + description = QStringLiteral("sRGB"); + return true; + } + if (transferFunction == QColorSpace::TransferFunction::Linear) { + id = QColorSpace::SRgbLinear; + description = QStringLiteral("Linear sRGB"); + return true; + } + break; + case QColorSpace::Gamut::AdobeRgb: + if (transferFunction == QColorSpace::TransferFunction::Gamma) { + if (qAbs(gamma - 2.19921875f) < (1/1024.0f)) { + id = QColorSpace::AdobeRgb; + description = QStringLiteral("Adobe RGB"); + return true; + } + } + break; + case QColorSpace::Gamut::DciP3D65: + if (transferFunction == QColorSpace::TransferFunction::SRgb) { + id = QColorSpace::DisplayP3; + description = QStringLiteral("Display P3"); + return true; + } + break; + case QColorSpace::Gamut::ProPhotoRgb: + if (transferFunction == QColorSpace::TransferFunction::ProPhotoRgb) { + id = QColorSpace::ProPhotoRgb; + description = QStringLiteral("ProPhoto RGB"); + return true; + } + if (transferFunction == QColorSpace::TransferFunction::Gamma) { + // ProPhoto RGB's curve is effectively gamma 1.8 for 8bit precision. + if (qAbs(gamma - 1.8f) < (1/1024.0f)) { + id = QColorSpace::ProPhotoRgb; + description = QStringLiteral("ProPhoto RGB"); + return true; + } + } + break; + case QColorSpace::Gamut::Bt2020: + if (transferFunction == QColorSpace::TransferFunction::Bt2020) { + id = QColorSpace::Bt2020; + description = QStringLiteral("BT.2020"); + return true; + } + break; + default: + break; + } + return false; +} + +void QColorSpacePrivate::initialize() +{ + setToXyzMatrix(); + setTransferFunction(); +} + +void QColorSpacePrivate::setToXyzMatrix() +{ + switch (gamut) { + case QColorSpace::Gamut::SRgb: + toXyz = QColorMatrix::toXyzFromSRgb(); + whitePoint = QColorVector::D65(); + return; + case QColorSpace::Gamut::AdobeRgb: + toXyz = QColorMatrix::toXyzFromAdobeRgb(); + whitePoint = QColorVector::D65(); + return; + case QColorSpace::Gamut::DciP3D65: + toXyz = QColorMatrix::toXyzFromDciP3D65(); + whitePoint = QColorVector::D65(); + return; + case QColorSpace::Gamut::ProPhotoRgb: + toXyz = QColorMatrix::toXyzFromProPhotoRgb(); + whitePoint = QColorVector::D50(); + return; + case QColorSpace::Gamut::Bt2020: + toXyz = QColorMatrix::toXyzFromBt2020(); + whitePoint = QColorVector::D65(); + return; + case QColorSpace::Gamut::Custom: + toXyz = QColorMatrix::null(); + whitePoint = QColorVector::D50(); + return; + } + Q_UNREACHABLE(); +} + +void QColorSpacePrivate::setTransferFunction() +{ + switch (transferFunction) { + case QColorSpace::TransferFunction::Linear: + trc[0].m_type = QColorTrc::Type::Function; + trc[0].m_fun = QColorTransferFunction(); + break; + case QColorSpace::TransferFunction::Gamma: + trc[0].m_type = QColorTrc::Type::Function; + trc[0].m_fun = QColorTransferFunction::fromGamma(gamma); + break; + case QColorSpace::TransferFunction::SRgb: + trc[0].m_type = QColorTrc::Type::Function; + trc[0].m_fun = QColorTransferFunction::fromSRgb(); + break; + case QColorSpace::TransferFunction::ProPhotoRgb: + trc[0].m_type = QColorTrc::Type::Function; + trc[0].m_fun = QColorTransferFunction::fromProPhotoRgb(); + break; + case QColorSpace::TransferFunction::Bt2020: + trc[0].m_type = QColorTrc::Type::Function; + trc[0].m_fun = QColorTransferFunction::fromBt2020(); + break; + case QColorSpace::TransferFunction::Custom: + break; + default: + Q_UNREACHABLE(); + break; + } + trc[1] = trc[0]; + trc[2] = trc[0]; +} + +QColorTransform QColorSpacePrivate::transformationToColorSpace(const QColorSpacePrivate *out) const +{ + Q_ASSERT(out); + QColorTransform combined; + combined.d_ptr.reset(new QColorTransformPrivate); + combined.d_ptr->colorSpaceIn = this; + combined.d_ptr->colorSpaceOut = out; + combined.d_ptr->colorMatrix = out->toXyz.inverted() * toXyz; + return combined; +} + +/*! + \class QColorSpace + \brief The QColorSpace class provides a color space abstraction. + \since 5.14 + + \ingroup painting + \ingroup appearance + \inmodule QtGui + + Color values can be interpreted in different ways, and based on the interpretation + can live in different spaces. We call this \e {color spaces}. + + QColorSpace provides access to creating several predefined color spaces and + can generate QColorTransforms for converting colors from one color space to + another. + + QColorSpace can also represent color spaces defined by ICC profiles or embedded + in images, that do not otherwise fit the predefined color spaces. + + A color space can generally speaking be conceived as a combination of a transfer + function and a gamut. The gamut defines which colors the color space can represent. + A color space that can represent a wider range of colors is also known as a + wide-gamut color space. The gamut is defined by three primary colors that represent + exactly how red, green, and blue look in this particular color space, and a white + color that represents where and how bright pure white is. + + The transfer function or gamma curve determines how each component in the + color space is encoded. These are used because human perception does not operate + linearly, and the transfer functions try to ensure that colors will seem evenly + spaced to human eyes. +*/ + + +/*! + \enum QColorSpace::ColorSpaceId + + Predefined color spaces. + + \value Undefined An empty, invalid or unsupported color space. + \value Unknown A valid color space that doesn't match any of the predefined color spaces. + \value SRgb The sRGB color space, which Qt operates in by default. It is a close approximation + of how most classic monitors operate, and a mode most software and hardware support. + \l{http://www.color.org/chardata/rgb/srgb.xalter}{ICC registration of sRGB}. + \value SRgbLinear The sRGB color space with linear gamma. Useful for gamma-corrected blending. + \value AdobeRgb The Adobe RGB color space is a classic wide-gamut color space, using a gamma of 2.2. + \l{http://www.color.org/chardata/rgb/adobergb.xalter}{ICC registration of Adobe RGB (1998)} + \value DisplayP3 A color-space using the primaries of DCI-P3, but with the whitepoint and transfer + function of sRGB. Common in modern wide-gamut screens. + \l{http://www.color.org/chardata/rgb/DCIP3.xalter}{ICC registration of DCI-P3} + \value ProPhotoRgb The Pro Photo RGB color space, also known as ROMM RGB is a very wide gamut color space. + \l{http://www.color.org/chardata/rgb/rommrgb.xalter}{ICC registration of ROMM RGB} + \value Bt2020 BT.2020 also known as Rec.2020 is the color space of HDR TVs. + \l{http://www.color.org/chardata/rgb/BT2020.xalter}{ICC registration of BT.2020} +*/ + +/*! + \enum QColorSpace::Gamut + + Predefined gamuts, or sets of primary colors. + + \value Custom The gamut is undefined or does not match any predefined sets. + \value SRgb The sRGB gamut + \value AdobeRgb The Adobe RGB gamut + \value DciP3D65 The DCI-P3 gamut with the D65 whitepoint + \value ProPhotoRgb The ProPhoto RGB gamut with the D50 whitepoint + \value Bt2020 The BT.2020 gamut +*/ + +/*! + \enum QColorSpace::TransferFunction + + Predefined transfer functions or gamma curves. + + \value Custom The custom or null transfer function + \value Linear The linear transfer functions + \value Gamma A transfer function that is a real gamma curve based on the value of gamma() + \value SRgb The sRGB transfer function, composed of linear and gamma parts + \value ProPhotoRgb The ProPhoto RGB transfer function, composed of linear and gamma parts + \value Bt2020 The BT.2020 transfer function, composed of linear and gamma parts +*/ + +/*! + Creates a new colorspace object that represents \a colorSpaceId. + */ +QColorSpace::QColorSpace(QColorSpace::ColorSpaceId colorSpaceId) +{ + static QExplicitlySharedDataPointer predefinedColorspacePrivates[QColorSpace::Bt2020]; + if (colorSpaceId <= QColorSpace::Unknown) { + if (!predefinedColorspacePrivates[0]) + predefinedColorspacePrivates[0] = new QColorSpacePrivate(QColorSpace::Undefined); + d_ptr = predefinedColorspacePrivates[0]; // unknown and undefined both returns the static undefined colorspace. + } else { + if (!predefinedColorspacePrivates[colorSpaceId - 1]) + predefinedColorspacePrivates[colorSpaceId - 1] = new QColorSpacePrivate(colorSpaceId); + d_ptr = predefinedColorspacePrivates[colorSpaceId - 1]; + } + + Q_ASSERT(colorSpaceId == QColorSpace::Undefined || isValid()); +} + +/*! + Creates a custom color space with the gamut \a gamut, using the transfer function \a fun and + optionally \a gamma. + */ +QColorSpace::QColorSpace(QColorSpace::Gamut gamut, QColorSpace::TransferFunction fun, float gamma) + : d_ptr(new QColorSpacePrivate(gamut, fun, gamma)) +{ +} + +/*! + Creates a custom color space with the gamut \a gamut, using a gamma transfer function of + \a gamma. + */ +QColorSpace::QColorSpace(QColorSpace::Gamut gamut, float gamma) + : d_ptr(new QColorSpacePrivate(gamut, TransferFunction::Gamma, gamma)) +{ +} + +QColorSpace::~QColorSpace() +{ +} + +QColorSpace::QColorSpace(QColorSpace &&colorSpace) + : d_ptr(std::move(colorSpace.d_ptr)) +{ +} + +QColorSpace::QColorSpace(const QColorSpace &colorSpace) + : d_ptr(colorSpace.d_ptr) +{ +} + +QColorSpace &QColorSpace::operator=(QColorSpace &&colorSpace) +{ + d_ptr = std::move(colorSpace.d_ptr); + return *this; +} + +QColorSpace &QColorSpace::operator=(const QColorSpace &colorSpace) +{ + d_ptr = colorSpace.d_ptr; + return *this; +} + +/*! + Returns the id of the predefined color space this object + represents or \c Unknown if it doesn't match any of them. +*/ +QColorSpace::ColorSpaceId QColorSpace::colorSpaceId() const noexcept +{ + return d_ptr->id; +} + +/*! + Returns the predefined gamut of the color space + or \c Gamut::Custom if it doesn't match any of them. +*/ +QColorSpace::Gamut QColorSpace::gamut() const noexcept +{ + return d_ptr->gamut; +} + +/*! + Returns the predefined transfer function of the color space + or \c TransferFunction::Custom if it doesn't match any of them. + + \sa gamma() +*/ +QColorSpace::TransferFunction QColorSpace::transferFunction() const noexcept +{ + return d_ptr->transferFunction; +} + +/*! + Returns the gamma value of color spaces with \c TransferFunction::Gamma, + an approximate gamma value for other predefined color spaces, or + 0.0 if no approximate gamma is known. + + \sa transferFunction() +*/ +float QColorSpace::gamma() const noexcept +{ + return d_ptr->gamma; +} + +/*! + Returns an ICC profile representing the color space. + + If the color space was generated from an ICC profile, that profile + is returned, otherwise one is generated. + + \note Even invalid color spaces may return the ICC profile if they + were generated from one, to allow applications to implement wider + support themselves. + + \sa fromIccProfile() +*/ +QByteArray QColorSpace::iccProfile() const +{ + if (!d_ptr->iccProfile.isEmpty()) + return d_ptr->iccProfile; + if (!isValid()) + return QByteArray(); + return QIcc::toIccProfile(*this); +} + +/*! + Creates a QColorSpace from ICC profile \a iccProfile. + + \note Not all ICC profiles are supported. QColorSpace only supports + RGB-XYZ ICC profiles that are three-component matrix-based. + + If the ICC profile is not supported an invalid QColorSpace is returned + where you can still read the original ICC profile using iccProfile(). + + \sa iccProfile() +*/ +QColorSpace QColorSpace::fromIccProfile(const QByteArray &iccProfile) +{ + QColorSpace colorSpace; + if (QIcc::fromIccProfile(iccProfile, &colorSpace)) + return colorSpace; + colorSpace.d_ptr->id = QColorSpace::Undefined; + colorSpace.d_ptr->iccProfile = iccProfile; + return colorSpace; +} + +/*! + Returns \c true if the color space is valid. +*/ +bool QColorSpace::isValid() const noexcept +{ + return d_ptr->id != QColorSpace::Undefined && d_ptr->toXyz.isValid() + && d_ptr->trc[0].isValid() && d_ptr->trc[1].isValid() && d_ptr->trc[2].isValid(); +} + +/*! + \relates QColorSpace + Returns \c true if colorspace \a colorSpace1 is equal to colorspace \a colorSpace2; + otherwise returns \c false +*/ +bool operator==(const QColorSpace &colorSpace1, const QColorSpace &colorSpace2) +{ + if (colorSpace1.d_ptr == colorSpace2.d_ptr) + return true; + + if (colorSpace1.colorSpaceId() == QColorSpace::Undefined && colorSpace2.colorSpaceId() == QColorSpace::Undefined) + return colorSpace1.d_ptr->iccProfile == colorSpace2.d_ptr->iccProfile; + + if (colorSpace1.colorSpaceId() != QColorSpace::Unknown && colorSpace2.colorSpaceId() != QColorSpace::Unknown) + return colorSpace1.colorSpaceId() == colorSpace2.colorSpaceId(); + + if (colorSpace1.gamut() != QColorSpace::Gamut::Custom && colorSpace2.gamut() != QColorSpace::Gamut::Custom) { + if (colorSpace1.gamut() != colorSpace2.gamut()) + return false; + } else { + if (colorSpace1.d_ptr->toXyz != colorSpace2.d_ptr->toXyz) + return false; + } + + if (colorSpace1.transferFunction() != QColorSpace::TransferFunction::Custom && + colorSpace2.transferFunction() != QColorSpace::TransferFunction::Custom) { + if (colorSpace1.transferFunction() != colorSpace2.transferFunction()) + return false; + if (colorSpace1.transferFunction() == QColorSpace::TransferFunction::Gamma) + return colorSpace1.gamma() == colorSpace2.gamma(); + return true; + } + + if (colorSpace1.d_ptr->trc[0] != colorSpace2.d_ptr->trc[0] || + colorSpace1.d_ptr->trc[1] != colorSpace2.d_ptr->trc[1] || + colorSpace1.d_ptr->trc[2] != colorSpace2.d_ptr->trc[2]) + return false; + + return true; +} + +/*! + \fn bool operator!=(const QColorSpace &colorSpace1, const QColorSpace &colorSpace2) + \relates QColorSpace + + Returns \c true if colorspace \a colorspace1 is not equal to colorspace \a colorspace2; + otherwise returns \c false +*/ + +/*! + Generates and returns a color space transformation from this color space to + \a colorspace. +*/ +QColorTransform QColorSpace::transformationToColorSpace(const QColorSpace &colorspace) const +{ + if (!isValid() || !colorspace.isValid()) + return QColorTransform(); + + return d_ptr->transformationToColorSpace(colorspace.d_ptr.constData()); +} + +/*! + \internal +*/ +QColorSpacePrivate *QColorSpace::d_func() +{ + d_ptr.detach(); + return d_ptr.data(); +} + +/*! + \fn const QColorSpacePrivate* QColorSpacePrivate::d_func() const + \internal +*/ + +/***************************************************************************** + QColorSpace stream functions + *****************************************************************************/ +#if !defined(QT_NO_DATASTREAM) +/*! + \fn QDataStream &operator<<(QDataStream &stream, const QColorSpace &colorSpace) + \relates QColorSpace + + Writes the given \a colorSpace to the given \a stream as an ICC profile. + + \sa QColorSpace::iccProfile(), {Serializing Qt Data Types} +*/ + +QDataStream &operator<<(QDataStream &s, const QColorSpace &image) +{ + s << image.iccProfile(); + return s; +} + +/*! + \fn QDataStream &operator>>(QDataStream &stream, QColorSpace &colorSpace) + \relates QColorSpace + + Reads a color space from the given \a stream and stores it in the given + \a colorSpace. + + \sa QColorSpace::fromIccProfile(), {Serializing Qt Data Types} +*/ + +QDataStream &operator>>(QDataStream &s, QColorSpace &colorSpace) +{ + QByteArray iccProfile; + s >> iccProfile; + colorSpace = QColorSpace::fromIccProfile(iccProfile); + return s; +} +#endif // QT_NO_DATASTREAM + +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug dbg, const QColorSpace &colorSpace) +{ + QDebugStateSaver saver(dbg); + dbg.nospace(); + dbg << "QColorSpace("; + dbg << colorSpace.colorSpaceId() << ", " << colorSpace.gamut() << ", " << colorSpace.transferFunction(); + dbg << ", gamma=" << colorSpace.gamma(); + dbg << ')'; + return dbg; +} +#endif + +QT_END_NAMESPACE diff --git a/src/gui/painting/qcolorspace.h b/src/gui/painting/qcolorspace.h new file mode 100644 index 0000000000..923546ec6f --- /dev/null +++ b/src/gui/painting/qcolorspace.h @@ -0,0 +1,136 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCOLORSPACE_H +#define QCOLORSPACE_H + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QColorSpacePrivate; + +class Q_GUI_EXPORT QColorSpace +{ + Q_GADGET +public: + enum ColorSpaceId { + Undefined = 0, + Unknown = 1, + SRgb, + SRgbLinear, + AdobeRgb, + DisplayP3, + ProPhotoRgb, + Bt2020, + }; + Q_ENUM(ColorSpaceId) + enum class Gamut { + Custom = 0, + SRgb, + AdobeRgb, + DciP3D65, + ProPhotoRgb, + Bt2020, + }; + Q_ENUM(Gamut) + enum class TransferFunction { + Custom = 0, + Linear, + Gamma, + SRgb, + ProPhotoRgb, + Bt2020, + }; + Q_ENUM(TransferFunction) + + QColorSpace(ColorSpaceId colorSpaceId = Undefined); + QColorSpace(Gamut gamut, TransferFunction fun, float gamma = 0.0f); + QColorSpace(Gamut gamut, float gamma); + ~QColorSpace(); + + QColorSpace(QColorSpace &&colorSpace); + QColorSpace(const QColorSpace &colorSpace); + QColorSpace &operator=(QColorSpace &&colorSpace); + QColorSpace &operator=(const QColorSpace &colorSpace); + + ColorSpaceId colorSpaceId() const noexcept; + Gamut gamut() const noexcept; + TransferFunction transferFunction() const noexcept; + float gamma() const noexcept; + + bool isValid() const noexcept; + + friend Q_GUI_EXPORT bool operator==(const QColorSpace &colorSpace1, const QColorSpace &colorSpace2); + friend inline bool operator!=(const QColorSpace &colorSpace1, const QColorSpace &colorSpace2); + + static QColorSpace fromIccProfile(const QByteArray &iccProfile); + QByteArray iccProfile() const; + + QColorTransform transformationToColorSpace(const QColorSpace &colorspace) const; + + QColorSpacePrivate *d_func(); + inline const QColorSpacePrivate *d_func() const { return d_ptr.constData(); } + +private: + friend class QColorSpacePrivate; + QExplicitlySharedDataPointer d_ptr; +}; + +bool Q_GUI_EXPORT operator==(const QColorSpace &colorSpace1, const QColorSpace &colorSpace2); +inline bool operator!=(const QColorSpace &colorSpace1, const QColorSpace &colorSpace2) +{ + return !(colorSpace1 == colorSpace2); +} + +// QColorSpace stream functions +#if !defined(QT_NO_DATASTREAM) +Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QColorSpace &); +Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QColorSpace &); +#endif + +#ifndef QT_NO_DEBUG_STREAM +Q_GUI_EXPORT QDebug operator<<(QDebug, const QColorSpace &); +#endif + +QT_END_NAMESPACE + +#endif // QCOLORSPACE_P_H diff --git a/src/gui/painting/qcolorspace_p.h b/src/gui/painting/qcolorspace_p.h new file mode 100644 index 0000000000..91107a9a89 --- /dev/null +++ b/src/gui/painting/qcolorspace_p.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCOLORSPACE_P_H +#define QCOLORSPACE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qcolorspace.h" +#include "qcolormatrix_p.h" +#include "qcolortrc_p.h" +#include "qcolortrclut_p.h" + +#include + +QT_BEGIN_NAMESPACE + +class QColorSpacePrivate : public QSharedData +{ +public: + QColorSpacePrivate(); + QColorSpacePrivate(QColorSpace::ColorSpaceId colorSpaceId); + QColorSpacePrivate(QColorSpace::Gamut gamut, QColorSpace::TransferFunction fun, float gamma); + QColorSpacePrivate(const QColorSpacePrivate &other) = default; + QColorSpacePrivate &operator=(const QColorSpacePrivate &other) = default; + + void initialize(); + void setToXyzMatrix(); + void setTransferFunction(); + bool identifyColorSpace(); + QColorTransform transformationToColorSpace(const QColorSpacePrivate *out) const; + + QColorSpace::ColorSpaceId id; + QColorSpace::Gamut gamut; + QColorSpace::TransferFunction transferFunction; + float gamma; + QColorVector whitePoint; + + QColorTrc trc[3]; + QColorMatrix toXyz; + + QString description; + QByteArray iccProfile; + + mutable QSharedPointer lut[3]; + mutable QAtomicInt lutsGenerated; +}; + +QT_END_NAMESPACE + +#endif // QCOLORSPACE_P_H diff --git a/src/gui/painting/qcolortransferfunction_p.h b/src/gui/painting/qcolortransferfunction_p.h new file mode 100644 index 0000000000..fd7cfa2b2b --- /dev/null +++ b/src/gui/painting/qcolortransferfunction_p.h @@ -0,0 +1,207 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCOLORTRANSFERFUNCTION_P_H +#define QCOLORTRANSFERFUNCTION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +#include + +QT_BEGIN_NAMESPACE + +// Defines a ICC parametric curve type 4 +class Q_GUI_EXPORT QColorTransferFunction +{ +public: + QColorTransferFunction() noexcept + : m_a(1.0f), m_b(0.0f), m_c(1.0f), m_d(0.0f), m_e(0.0f), m_f(0.0f), m_g(1.0f), m_flags(0) + { } + QColorTransferFunction(float a, float b, float c, float d, float e, float f, float g) noexcept + : m_a(a), m_b(b), m_c(c), m_d(d), m_e(e), m_f(f), m_g(g), m_flags(0) + { } + + bool isGamma() const + { + updateHints(); + return m_flags & quint32(Hints::IsGamma); + } + bool isLinear() const + { + updateHints(); + return m_flags & quint32(Hints::IsLinear); + } + bool isSRgb() const + { + updateHints(); + return m_flags & quint32(Hints::IsSRgb); + } + + float apply(float x) const + { + if (x < m_d) + return m_c * x + m_f; + else + return std::pow(m_a * x + m_b, m_g) + m_e; + } + + QColorTransferFunction inverted() const + { + float a, b, c, d, e, f, g; + + d = m_c * m_d + m_f; + + if (!qFuzzyIsNull(m_c)) { + c = 1.0f / m_c; + f = -m_f / m_c; + } else { + c = 0.0f; + f = 0.0f; + } + + if (!qFuzzyIsNull(m_a) && !qFuzzyIsNull(m_g)) { + a = std::pow(1.0f / m_a, m_g); + b = -a * m_e; + e = -m_b / m_a; + g = 1.0f / m_g; + } else { + a = 0.0f; + b = 0.0f; + e = 1.0f; + g = 1.0f; + } + + return QColorTransferFunction(a, b, c, d, e, f, g); + } + + // A few predefined curves: + static QColorTransferFunction fromGamma(float gamma) + { + return QColorTransferFunction(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, gamma); + } + static QColorTransferFunction fromSRgb() + { + return QColorTransferFunction(1.0f / 1.055f, 0.055f / 1.055f, 1.0f / 12.92f, 0.04045f, 0.0f, 0.0f, 2.4f); + } + static QColorTransferFunction fromBt2020() + { + return QColorTransferFunction(1.0f / 1.0993f, 0.0993f / 1.0993f, 1.0f / 4.5f, 0.08145f, 0.0f, 0.0f, 2.2f); + } + static QColorTransferFunction fromProPhotoRgb() + { + return QColorTransferFunction(1.0f, 0.0f, 1.0f / 16.0f, 16.0f / 512.0f, 0.0f, 0.0f, 1.8f); + } + bool matches(const QColorTransferFunction &o) const + { + return paramCompare(m_a, o.m_a) && paramCompare(m_b, o.m_b) + && paramCompare(m_c, o.m_c) && paramCompare(m_d, o.m_d) + && paramCompare(m_e, o.m_e) && paramCompare(m_f, o.m_f) + && paramCompare(m_g, o.m_g); + } + friend inline bool operator==(const QColorTransferFunction &f1, const QColorTransferFunction &f2); + friend inline bool operator!=(const QColorTransferFunction &f1, const QColorTransferFunction &f2); + + float m_a; + float m_b; + float m_c; + float m_d; + float m_e; + float m_f; + float m_g; + +private: + static inline bool paramCompare(float p1, float p2) + { + // Much fuzzier than fuzzy compare. + // It tries match parameters that has been passed through a 8.8 + // fixed point form. + return (qAbs(p1 - p2) <= (1.0f / 512.0f)); + } + + void updateHints() const + { + if (m_flags & quint32(Hints::Calculated)) + return; + // We do not consider the case with m_d = 1.0f linear or simple, + // since it wouldn't be linear for applyExtended(). + bool simple = paramCompare(m_a, 1.0f) && paramCompare(m_b, 0.0f) + && paramCompare(m_d, 0.0f) + && paramCompare(m_e, 0.0f); + if (simple) { + m_flags |= quint32(Hints::IsGamma); + if (qFuzzyCompare(m_g, 1.0f)) + m_flags |= quint32(Hints::IsLinear); + } else { + if (*this == fromSRgb()) + m_flags |= quint32(Hints::IsSRgb); + } + m_flags |= quint32(Hints::Calculated); + } + enum class Hints : quint32 { + Calculated = 1, + IsGamma = 2, + IsLinear = 4, + IsSRgb = 8 + }; + mutable quint32 m_flags; +}; + +inline bool operator==(const QColorTransferFunction &f1, const QColorTransferFunction &f2) +{ + return f1.matches(f2); +} +inline bool operator!=(const QColorTransferFunction &f1, const QColorTransferFunction &f2) +{ + return !f1.matches(f2); +} + +QT_END_NAMESPACE + +#endif // QCOLORTRANSFERFUNCTION_P_H diff --git a/src/gui/painting/qcolortransfertable_p.h b/src/gui/painting/qcolortransfertable_p.h new file mode 100644 index 0000000000..c8b2f7bd92 --- /dev/null +++ b/src/gui/painting/qcolortransfertable_p.h @@ -0,0 +1,245 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCOLORTRANSFERTABLE_P_H +#define QCOLORTRANSFERTABLE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include "qcolortransferfunction_p.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +// Defines either an ICC TRC 'curve' or a lut8/lut16 A or B table +class Q_GUI_EXPORT QColorTransferTable +{ +public: + QColorTransferTable() noexcept + : m_tableSize(0) + { } + QColorTransferTable(uint32_t size, const QVector &table) noexcept + : m_tableSize(size) + , m_table8(table) + { } + QColorTransferTable(uint32_t size, const QVector &table) noexcept + : m_tableSize(size) + , m_table16(table) + { } + + bool isValid() const + { + if (m_tableSize < 2) + return false; + +#if !defined(QT_NO_DEBUG) + // The table must describe an injective curve: + if (!m_table8.isEmpty()) { + uint8_t val = 0; + for (uint i = 0; i < m_tableSize; ++i) { + Q_ASSERT(m_table8[i] >= val); + val = m_table8[i]; + } + } + if (!m_table16.isEmpty()) { + uint16_t val = 0; + for (uint i = 0; i < m_tableSize; ++i) { + Q_ASSERT(m_table16[i] >= val); + val = m_table16[i]; + } + } +#endif + return !m_table8.isEmpty() || !m_table16.isEmpty(); + } + + float apply(float x) const + { + x = std::min(std::max(x, 0.0f), 1.0f); + x *= m_tableSize - 1; + uint32_t lo = (int)std::floor(x); + uint32_t hi = std::min(lo + 1, m_tableSize); + float frac = x - lo; + if (!m_table16.isEmpty()) + return (m_table16[lo] * (1.0f - frac) + m_table16[hi] * frac) * (1.0f/65535.0f); + if (!m_table8.isEmpty()) + return (m_table8[lo] * (1.0f - frac) + m_table8[hi] * frac) * (1.0f/255.0f); + return x; + } + + // Apply inverse, optimized by giving a previous result a value < x. + float applyInverse(float x, float resultLargerThan = 0.0f) const + { + Q_ASSERT(resultLargerThan >= 0.0f && resultLargerThan <= 1.0f); + if (x <= 0.0f) + return 0.0f; + if (x >= 1.0f) + return 1.0f; + if (!m_table16.isEmpty()) { + float v = x * 65535.0f; + uint i = std::floor(resultLargerThan * (m_tableSize - 1)) + 1; + for ( ; i < m_tableSize; ++i) { + if (m_table16[i] > v) + break; + } + if (i >= m_tableSize - 1) + return 1.0f; + float y1 = m_table16[i - 1]; + float y2 = m_table16[i]; + Q_ASSERT(x >= y1 && x < y2); + float fr = (v - y1) / (y2 - y1); + return (i + fr) * (1.0f / (m_tableSize - 1)); + + } + if (!m_table8.isEmpty()) { + float v = x * 255.0f; + uint i = std::floor(resultLargerThan * (m_tableSize - 1)) + 1; + for ( ; i < m_tableSize; ++i) { + if (m_table8[i] > v) + break; + } + if (i >= m_tableSize - 1) + return 1.0f; + float y1 = m_table8[i - 1]; + float y2 = m_table8[i]; + Q_ASSERT(x >= y1 && x < y2); + float fr = (v - y1) / (y2 - y1); + return (i + fr) * (1.0f / (m_tableSize - 1)); + } + return x; + } + + bool asColorTransferFunction(QColorTransferFunction *transferFn) + { + Q_ASSERT(isValid()); + Q_ASSERT(transferFn); + if (!m_table8.isEmpty() && (m_table8[0] != 0 || m_table8[m_tableSize - 1] != 255)) + return false; + if (!m_table16.isEmpty() && (m_table16[0] != 0 || m_table16[m_tableSize - 1] != 65535)) + return false; + if (m_tableSize == 2) { + *transferFn = QColorTransferFunction(); // Linear + return true; + } + // The following heuristics are based on those from Skia: + if (m_tableSize == 26 && !m_table16.isEmpty()) { + // code.facebook.com/posts/411525055626587/under-the-hood-improving-facebook-photos + if (m_table16[6] != 3062) + return false; + if (m_table16[12] != 12824) + return false; + if (m_table16[18] != 31237) + return false; + *transferFn = QColorTransferFunction::fromSRgb(); + return true; + } + if (m_tableSize == 1024 && !m_table16.isEmpty()) { + // HP and Canon sRGB gamma tables: + if (m_table16[257] != 3366) + return false; + if (m_table16[513] != 14116) + return false; + if (m_table16[768] != 34318) + return false; + *transferFn = QColorTransferFunction::fromSRgb(); + return true; + } + if (m_tableSize == 4096 && !m_table16.isEmpty()) { + // Nikon, Epson, and lcms2 sRGB gamma tables: + if (m_table16[515] != 960) + return false; + if (m_table16[1025] != 3342) + return false; + if (m_table16[2051] != 14079) + return false; + *transferFn = QColorTransferFunction::fromSRgb(); + return true; + } + return false; + } + friend inline bool operator!=(const QColorTransferTable &t1, const QColorTransferTable &t2); + friend inline bool operator==(const QColorTransferTable &t1, const QColorTransferTable &t2); + + uint32_t m_tableSize; + QVector m_table8; + QVector m_table16; +}; + +inline bool operator!=(const QColorTransferTable &t1, const QColorTransferTable &t2) +{ + if (t1.m_tableSize != t2.m_tableSize) + return true; + if (t1.m_table8.isEmpty() != t2.m_table8.isEmpty()) + return true; + if (t1.m_table16.isEmpty() != t2.m_table16.isEmpty()) + return true; + if (!t1.m_table8.isEmpty()) { + for (quint32 i = 0; i < t1.m_tableSize; ++i) { + if (t1.m_table8[i] != t2.m_table8[i]) + return true; + } + } + if (!t1.m_table16.isEmpty()) { + for (quint32 i = 0; i < t1.m_tableSize; ++i) { + if (t1.m_table16[i] != t2.m_table16[i]) + return true; + } + } + return false; +} + +inline bool operator==(const QColorTransferTable &t1, const QColorTransferTable &t2) +{ + return !(t1 != t2); +} + +QT_END_NAMESPACE + +#endif // QCOLORTRANSFERTABLE_P_H diff --git a/src/gui/painting/qcolortransform.cpp b/src/gui/painting/qcolortransform.cpp new file mode 100644 index 0000000000..b677c4b36b --- /dev/null +++ b/src/gui/painting/qcolortransform.cpp @@ -0,0 +1,679 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include "qcolortransform.h" +#include "qcolortransform_p.h" + +#include "qcolormatrix_p.h" +#include "qcolorspace_p.h" +#include "qcolortrc_p.h" +#include "qcolortrclut_p.h" + +#include +#include +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +QColorTrcLut *lutFromTrc(const QColorTrc &trc) +{ + if (trc.m_type == QColorTrc::Type::Table) + return QColorTrcLut::fromTransferTable(trc.m_table); + if (trc.m_type == QColorTrc::Type::Function) + return QColorTrcLut::fromTransferFunction(trc.m_fun); + qWarning() << "TRC uninitialized"; + return nullptr; +} + +void QColorTransformPrivate::updateLutsIn() const +{ + if (colorSpaceIn->lutsGenerated.loadAcquire()) + return; + for (int i = 0; i < 3; ++i) { + if (!colorSpaceIn->trc[i].isValid()) + return; + } + + if (colorSpaceIn->trc[0] == colorSpaceIn->trc[1] && colorSpaceIn->trc[0] == colorSpaceIn->trc[2]) { + colorSpaceIn->lut[0].reset(lutFromTrc(colorSpaceIn->trc[0])); + colorSpaceIn->lut[1] = colorSpaceIn->lut[0]; + colorSpaceIn->lut[2] = colorSpaceIn->lut[0]; + } else { + for (int i = 0; i < 3; ++i) + colorSpaceIn->lut[i].reset(lutFromTrc(colorSpaceIn->trc[i])); + } + + colorSpaceIn->lutsGenerated.storeRelease(1); +} + +void QColorTransformPrivate::updateLutsOut() const +{ + if (colorSpaceOut->lutsGenerated.loadAcquire()) + return; + for (int i = 0; i < 3; ++i) { + if (!colorSpaceOut->trc[i].isValid()) + return; + } + + if (colorSpaceOut->trc[0] == colorSpaceOut->trc[1] && colorSpaceOut->trc[0] == colorSpaceOut->trc[2]) { + colorSpaceOut->lut[0].reset(lutFromTrc(colorSpaceOut->trc[0])); + colorSpaceOut->lut[1] = colorSpaceOut->lut[0]; + colorSpaceOut->lut[2] = colorSpaceOut->lut[0]; + } else { + for (int i = 0; i < 3; ++i) + colorSpaceOut->lut[i].reset(lutFromTrc(colorSpaceOut->trc[i])); + } + + colorSpaceOut->lutsGenerated.storeRelease(1); +} + +/*! + \class QColorTransform + \brief The QColorTransform class is a transformation between color spaces. + \since 5.14 + + \ingroup painting + \ingroup appearance + \inmodule QtGui + + QColorTransform is an instantiation of a transformation between color spaces. + It can be applied on color and pixels to convert them from one color space to + another. + + Setting up a QColorTransform takes some preprocessing, so keeping around + QColorTransforms that you need often is recommended, instead of generating + them on the fly. +*/ + + +QColorTransform::~QColorTransform() noexcept +{ +} + +/*! + Applies the color transformation on the QRgb value \a argb. + + The input should be opaque or unpremultiplied. +*/ +QRgb QColorTransform::map(const QRgb &argb) const +{ + if (!d_ptr) + return argb; + Q_D(const QColorTransform); + constexpr float f = 1.0f / 255.0f; + QColorVector c = { qRed(argb) * f, qGreen(argb) * f, qBlue(argb) * f }; + c.x = d->colorSpaceIn->trc[0].apply(c.x); + c.y = d->colorSpaceIn->trc[1].apply(c.y); + c.z = d->colorSpaceIn->trc[2].apply(c.z); + c = d->colorMatrix.map(c); + c.x = std::max(0.0f, std::min(1.0f, c.x)); + c.y = std::max(0.0f, std::min(1.0f, c.y)); + c.z = std::max(0.0f, std::min(1.0f, c.z)); + if (d->colorSpaceOut->lutsGenerated.loadAcquire()) { + c.x = d->colorSpaceOut->lut[0]->fromLinear(c.x); + c.y = d->colorSpaceOut->lut[1]->fromLinear(c.y); + c.z = d->colorSpaceOut->lut[2]->fromLinear(c.z); + } else { + c.x = d->colorSpaceOut->trc[0].applyInverse(c.x); + c.y = d->colorSpaceOut->trc[1].applyInverse(c.y); + c.z = d->colorSpaceOut->trc[2].applyInverse(c.z); + } + + return qRgba(c.x * 255 + 0.5f, c.y * 255 + 0.5f, c.z * 255 + 0.5f, qAlpha(argb)); +} + +/*! + Applies the color transformation on the QRgba64 value \a rgba64. + + The input should be opaque or unpremultiplied. +*/ +QRgba64 QColorTransform::map(const QRgba64 &rgba64) const +{ + if (!d_ptr) + return rgba64; + Q_D(const QColorTransform); + constexpr float f = 1.0f / 65535.0f; + QColorVector c = { rgba64.red() * f, rgba64.green() * f, rgba64.blue() * f }; + c.x = d->colorSpaceIn->trc[0].apply(c.x); + c.y = d->colorSpaceIn->trc[1].apply(c.y); + c.z = d->colorSpaceIn->trc[2].apply(c.z); + c = d->colorMatrix.map(c); + c.x = std::max(0.0f, std::min(1.0f, c.x)); + c.y = std::max(0.0f, std::min(1.0f, c.y)); + c.z = std::max(0.0f, std::min(1.0f, c.z)); + if (d->colorSpaceOut->lutsGenerated.loadAcquire()) { + c.x = d->colorSpaceOut->lut[0]->fromLinear(c.x); + c.y = d->colorSpaceOut->lut[1]->fromLinear(c.y); + c.z = d->colorSpaceOut->lut[2]->fromLinear(c.z); + } else { + c.x = d->colorSpaceOut->trc[0].applyInverse(c.x); + c.y = d->colorSpaceOut->trc[1].applyInverse(c.y); + c.z = d->colorSpaceOut->trc[2].applyInverse(c.z); + } + + return QRgba64::fromRgba64(c.x * 65535, c.y * 65535, c.z * 65535, rgba64.alpha()); +} + +/*! + Applies the color transformation on the QColor value \a color. + +*/ +QColor QColorTransform::map(const QColor &color) const +{ + if (!d_ptr) + return color; + Q_D(const QColorTransform); + QColorVector c = { (float)color.redF(), (float)color.greenF(), (float)color.blueF() }; + c.x = d->colorSpaceIn->trc[0].apply(c.x); + c.y = d->colorSpaceIn->trc[1].apply(c.y); + c.z = d->colorSpaceIn->trc[2].apply(c.z); + c = d->colorMatrix.map(c); + if (d_ptr->colorSpaceOut->lutsGenerated.loadAcquire()) { + c.x = d->colorSpaceOut->lut[0]->fromLinear(c.x); + c.y = d->colorSpaceOut->lut[1]->fromLinear(c.y); + c.z = d->colorSpaceOut->lut[2]->fromLinear(c.z); + } else { + c.x = d->colorSpaceOut->trc[0].applyInverse(c.x); + c.y = d->colorSpaceOut->trc[1].applyInverse(c.y); + c.z = d->colorSpaceOut->trc[2].applyInverse(c.z); + } + QColor out; + out.setRgbF(c.x, c.y, c.z, color.alphaF()); + return out; +} + +// Optimized sub-routines for fast block based conversion: + +static void applyMatrix(QColorVector *buffer, const qsizetype len, const QColorMatrix &colorMatrix) +{ +#if defined(__SSE2__) + const __m128 minV = _mm_set1_ps(0.0f); + const __m128 maxV = _mm_set1_ps(1.0f); + const __m128 xMat = _mm_loadu_ps(&colorMatrix.r.x); + const __m128 yMat = _mm_loadu_ps(&colorMatrix.g.x); + const __m128 zMat = _mm_loadu_ps(&colorMatrix.b.x); + for (qsizetype j = 0; j < len; ++j) { + __m128 c = _mm_loadu_ps(&buffer[j].x); + __m128 cx = _mm_shuffle_ps(c, c, _MM_SHUFFLE(0, 0, 0, 0)); + __m128 cy = _mm_shuffle_ps(c, c, _MM_SHUFFLE(1, 1, 1, 1)); + __m128 cz = _mm_shuffle_ps(c, c, _MM_SHUFFLE(2, 2, 2, 2)); + cx = _mm_mul_ps(cx, xMat); + cy = _mm_mul_ps(cy, yMat); + cz = _mm_mul_ps(cz, zMat); + cx = _mm_add_ps(cx, cy); + cx = _mm_add_ps(cx, cz); + // Clamp: + cx = _mm_min_ps(cx, maxV); + cx = _mm_max_ps(cx, minV); + _mm_storeu_ps(&buffer[j].x, cx); + } +#else + for (int j = 0; j < len; ++j) { + const QColorVector cv = colorMatrix.map(buffer[j]); + buffer[j].x = std::max(0.0f, std::min(1.0f, cv.x)); + buffer[j].y = std::max(0.0f, std::min(1.0f, cv.y)); + buffer[j].z = std::max(0.0f, std::min(1.0f, cv.z)); + } +#endif +} + +template +static void loadPremultiplied(QColorVector *buffer, const T *src, const qsizetype len, const QColorTransformPrivate *d_ptr); +template +static void loadUnpremultiplied(QColorVector *buffer, const T *src, const qsizetype len, const QColorTransformPrivate *d_ptr); + +#if defined(__SSE2__) +// Load to [0-alpha] in 4x32 SIMD +template +static inline void loadP(const T &p, __m128i &v); + +template<> +inline void loadP(const QRgb &p, __m128i &v) +{ + v = _mm_cvtsi32_si128(p); +#if defined(__SSE4_1__) + v = _mm_cvtepu8_epi32(v); +#else + v = _mm_unpacklo_epi8(v, _mm_setzero_si128()); + v = _mm_unpacklo_epi16(v, _mm_setzero_si128()); +#endif +} + +template<> +inline void loadP(const QRgba64 &p, __m128i &v) +{ + v = _mm_loadl_epi64((const __m128i *)&p); +#if defined(__SSE4_1__) + v = _mm_cvtepu16_epi32(v); +#else + v = _mm_unpacklo_epi16(v, _mm_setzero_si128()); +#endif + // Shuffle to ARGB as the template below expects it + v = _mm_shuffle_epi32(v, _MM_SHUFFLE(3, 0, 1, 2)); +} + +template +static void loadPremultiplied(QColorVector *buffer, const T *src, const qsizetype len, const QColorTransformPrivate *d_ptr) +{ + const __m128 v4080 = _mm_set1_ps(4080.f); + const __m128 iFF00 = _mm_set1_ps(1.0f / (255 * 256)); + for (qsizetype i = 0; i < len; ++i) { + __m128i v; + loadP(src[i], v); + __m128 vf = _mm_cvtepi32_ps(v); + // Approximate 1/a: + __m128 va = _mm_shuffle_ps(vf, vf, _MM_SHUFFLE(3, 3, 3, 3)); + __m128 via = _mm_rcp_ps(va); + via = _mm_sub_ps(_mm_add_ps(via, via), _mm_mul_ps(via, _mm_mul_ps(via, va))); + // v * (1/a) + vf = _mm_mul_ps(vf, via); + + // Handle zero alpha + __m128 vAlphaMask = _mm_cmpeq_ps(va, _mm_set1_ps(0.0f)); + vf = _mm_andnot_ps(vAlphaMask, vf); + + // LUT + v = _mm_cvtps_epi32(_mm_mul_ps(vf, v4080)); + const int ridx = _mm_extract_epi16(v, 4); + const int gidx = _mm_extract_epi16(v, 2); + const int bidx = _mm_extract_epi16(v, 0); + v = _mm_insert_epi16(v, d_ptr->colorSpaceIn->lut[0]->m_toLinear[ridx], 0); + v = _mm_insert_epi16(v, d_ptr->colorSpaceIn->lut[1]->m_toLinear[gidx], 2); + v = _mm_insert_epi16(v, d_ptr->colorSpaceIn->lut[2]->m_toLinear[bidx], 4); + vf = _mm_mul_ps(_mm_cvtepi32_ps(v), iFF00); + + _mm_storeu_ps(&buffer[i].x, vf); + } +} + +// Load to [0-4080] in 4x32 SIMD +template +static inline void loadPU(const T &p, __m128i &v); + +template<> +inline void loadPU(const QRgb &p, __m128i &v) +{ + v = _mm_cvtsi32_si128(p); +#if defined(__SSE4_1__) + v = _mm_cvtepu8_epi32(v); +#else + v = _mm_unpacklo_epi8(v, _mm_setzero_si128()); + v = _mm_unpacklo_epi16(v, _mm_setzero_si128()); +#endif + v = _mm_slli_epi32(v, 4); +} + +template<> +inline void loadPU(const QRgba64 &p, __m128i &v) +{ + v = _mm_loadl_epi64((const __m128i *)&p); + v = _mm_sub_epi16(v, _mm_srli_epi16(v, 8)); +#if defined(__SSE4_1__) + v = _mm_cvtepu16_epi32(v); +#else + v = _mm_unpacklo_epi16(v, _mm_setzero_si128()); +#endif + v = _mm_srli_epi32(v, 4); + // Shuffle to ARGB as the template below expects it + v = _mm_shuffle_epi32(v, _MM_SHUFFLE(3, 0, 1, 2)); +} + +template +void loadUnpremultiplied(QColorVector *buffer, const T *src, const qsizetype len, const QColorTransformPrivate *d_ptr) +{ + const __m128 iFF00 = _mm_set1_ps(1.0f / (255 * 256)); + for (qsizetype i = 0; i < len; ++i) { + __m128i v; + loadPU(src[i], v); + const int ridx = _mm_extract_epi16(v, 4); + const int gidx = _mm_extract_epi16(v, 2); + const int bidx = _mm_extract_epi16(v, 0); + v = _mm_insert_epi16(v, d_ptr->colorSpaceIn->lut[0]->m_toLinear[ridx], 0); + v = _mm_insert_epi16(v, d_ptr->colorSpaceIn->lut[1]->m_toLinear[gidx], 2); + v = _mm_insert_epi16(v, d_ptr->colorSpaceIn->lut[2]->m_toLinear[bidx], 4); + __m128 vf = _mm_mul_ps(_mm_cvtepi32_ps(v), iFF00); + _mm_storeu_ps(&buffer[i].x, vf); + } +} + +#else +template<> +void loadPremultiplied(QColorVector *buffer, const QRgb *src, const qsizetype len, const QColorTransformPrivate *d_ptr) +{ + for (qsizetype i = 0; i < len; ++i) { + const uint p = src[i]; + const int a = qAlpha(p); + if (a) { + const float ia = 4080.0f / a; + const int ridx = int(qRed(p) * ia + 0.5f); + const int gidx = int(qGreen(p) * ia + 0.5f); + const int bidx = int(qBlue(p) * ia + 0.5f); + buffer[i].x = d_ptr->colorSpaceIn->lut[0]->m_toLinear[ridx] * (1.0f / (255 * 256)); + buffer[i].y = d_ptr->colorSpaceIn->lut[1]->m_toLinear[gidx] * (1.0f / (255 * 256)); + buffer[i].z = d_ptr->colorSpaceIn->lut[2]->m_toLinear[bidx] * (1.0f / (255 * 256)); + } else { + buffer[i].x = buffer[i].y = buffer[i].z = 0.0f; + } + } +} + +template<> +void loadPremultiplied(QColorVector *buffer, const QRgba64 *src, const qsizetype len, const QColorTransformPrivate *d_ptr) +{ + for (qsizetype i = 0; i < len; ++i) { + const QRgba64 &p = src[i]; + const int a = p.alpha(); + if (a) { + const float ia = 4080.0f / a; + const int ridx = int(p.red() * ia + 0.5f); + const int gidx = int(p.green() * ia + 0.5f); + const int bidx = int(p.blue() * ia + 0.5f); + buffer[i].x = d_ptr->colorSpaceIn->lut[0]->m_toLinear[ridx] * (1.0f / (255 * 256)); + buffer[i].y = d_ptr->colorSpaceIn->lut[1]->m_toLinear[gidx] * (1.0f / (255 * 256)); + buffer[i].z = d_ptr->colorSpaceIn->lut[2]->m_toLinear[bidx] * (1.0f / (255 * 256)); + } else { + buffer[i].x = buffer[i].y = buffer[i].z = 0.0f; + } + } +} + +template<> +void loadUnpremultiplied(QColorVector *buffer, const QRgb *src, const qsizetype len, const QColorTransformPrivate *d_ptr) +{ + for (qsizetype i = 0; i < len; ++i) { + const uint p = src[i]; + buffer[i].x = d_ptr->colorSpaceIn->lut[0]->u8ToLinearF32(qRed(p)); + buffer[i].y = d_ptr->colorSpaceIn->lut[1]->u8ToLinearF32(qGreen(p)); + buffer[i].z = d_ptr->colorSpaceIn->lut[2]->u8ToLinearF32(qBlue(p)); + } +} + +template<> +void loadUnpremultiplied(QColorVector *buffer, const QRgba64 *src, const qsizetype len, const QColorTransformPrivate *d_ptr) +{ + for (qsizetype i = 0; i < len; ++i) { + const QRgba64 &p = src[i]; + buffer[i].x = d_ptr->colorSpaceIn->lut[0]->u16ToLinearF32(p.red()); + buffer[i].y = d_ptr->colorSpaceIn->lut[1]->u16ToLinearF32(p.green()); + buffer[i].z = d_ptr->colorSpaceIn->lut[2]->u16ToLinearF32(p.blue()); + } +} +#endif + +static void storePremultiplied(QRgb *dst, const QRgb *src, const QColorVector *buffer, const qsizetype len, + const QColorTransformPrivate *d_ptr) +{ +#if defined(__SSE2__) + const __m128 v4080 = _mm_set1_ps(4080.f); + const __m128 iFF00 = _mm_set1_ps(1.0f / (255 * 256)); + for (qsizetype i = 0; i < len; ++i) { + const int a = qAlpha(src[i]); + __m128 vf = _mm_loadu_ps(&buffer[i].x); + __m128i v = _mm_cvtps_epi32(_mm_mul_ps(vf, v4080)); + __m128 va = _mm_set1_ps(a); + va = _mm_mul_ps(va, iFF00); + const int ridx = _mm_extract_epi16(v, 0); + const int gidx = _mm_extract_epi16(v, 2); + const int bidx = _mm_extract_epi16(v, 4); + v = _mm_insert_epi16(v, d_ptr->colorSpaceOut->lut[0]->m_fromLinear[ridx], 4); + v = _mm_insert_epi16(v, d_ptr->colorSpaceOut->lut[1]->m_fromLinear[gidx], 2); + v = _mm_insert_epi16(v, d_ptr->colorSpaceOut->lut[2]->m_fromLinear[bidx], 0); + vf = _mm_cvtepi32_ps(v); + vf = _mm_mul_ps(vf, va); + v = _mm_cvtps_epi32(vf); + v = _mm_packs_epi32(v, v); + v = _mm_insert_epi16(v, a, 3); + v = _mm_packus_epi16(v, v); + dst[i] = _mm_cvtsi128_si32(v); + } +#else + for (qsizetype i = 0; i < len; ++i) { + const int a = qAlpha(src[i]); + const float fa = a / (255.0f * 256.0f); + const float r = d_ptr->colorSpaceOut->lut[0]->m_fromLinear[int(buffer[i].x * 4080.0f + 0.5f)]; + const float g = d_ptr->colorSpaceOut->lut[1]->m_fromLinear[int(buffer[i].y * 4080.0f + 0.5f)]; + const float b = d_ptr->colorSpaceOut->lut[2]->m_fromLinear[int(buffer[i].z * 4080.0f + 0.5f)]; + dst[i] = qRgba(r * fa + 0.5f, g * fa + 0.5f, b * fa + 0.5f, a); + } +#endif +} + +static void storeUnpremultiplied(QRgb *dst, const QRgb *src, const QColorVector *buffer, const qsizetype len, + const QColorTransformPrivate *d_ptr) +{ +#if defined(__SSE2__) + const __m128 v4080 = _mm_set1_ps(4080.f); + for (qsizetype i = 0; i < len; ++i) { + const int a = qAlpha(src[i]); + __m128 vf = _mm_loadu_ps(&buffer[i].x); + __m128i v = _mm_cvtps_epi32(_mm_mul_ps(vf, v4080)); + const int ridx = _mm_extract_epi16(v, 0); + const int gidx = _mm_extract_epi16(v, 2); + const int bidx = _mm_extract_epi16(v, 4); + v = _mm_setzero_si128(); + v = _mm_insert_epi16(v, d_ptr->colorSpaceOut->lut[0]->m_fromLinear[ridx], 2); + v = _mm_insert_epi16(v, d_ptr->colorSpaceOut->lut[1]->m_fromLinear[gidx], 1); + v = _mm_insert_epi16(v, d_ptr->colorSpaceOut->lut[2]->m_fromLinear[bidx], 0); + v = _mm_add_epi16(v, _mm_set1_epi16(0x80)); + v = _mm_srli_epi16(v, 8); + v = _mm_insert_epi16(v, a, 3); + v = _mm_packus_epi16(v, v); + dst[i] = _mm_cvtsi128_si32(v); + } +#else + for (qsizetype i = 0; i < len; ++i) { + const int r = d_ptr->colorSpaceOut->lut[0]->u8FromLinearF32(buffer[i].x); + const int g = d_ptr->colorSpaceOut->lut[1]->u8FromLinearF32(buffer[i].y); + const int b = d_ptr->colorSpaceOut->lut[2]->u8FromLinearF32(buffer[i].z); + dst[i] = (src[i] & 0xff000000) | (r << 16) | (g << 8) | (b << 0); + } +#endif +} + +static void storeOpaque(QRgb *dst, const QRgb *src, const QColorVector *buffer, const qsizetype len, + const QColorTransformPrivate *d_ptr) +{ + Q_UNUSED(src); +#if defined(__SSE2__) + const __m128 v4080 = _mm_set1_ps(4080.f); + for (qsizetype i = 0; i < len; ++i) { + __m128 vf = _mm_loadu_ps(&buffer[i].x); + __m128i v = _mm_cvtps_epi32(_mm_mul_ps(vf, v4080)); + const int ridx = _mm_extract_epi16(v, 0); + const int gidx = _mm_extract_epi16(v, 2); + const int bidx = _mm_extract_epi16(v, 4); + v = _mm_setzero_si128(); + v = _mm_insert_epi16(v, d_ptr->colorSpaceOut->lut[0]->m_fromLinear[ridx], 2); + v = _mm_insert_epi16(v, d_ptr->colorSpaceOut->lut[1]->m_fromLinear[gidx], 1); + v = _mm_insert_epi16(v, d_ptr->colorSpaceOut->lut[2]->m_fromLinear[bidx], 0); + v = _mm_add_epi16(v, _mm_set1_epi16(0x80)); + v = _mm_srli_epi16(v, 8); + v = _mm_insert_epi16(v, 255, 3); + v = _mm_packus_epi16(v, v); + dst[i] = _mm_cvtsi128_si32(v); + } +#else + for (qsizetype i = 0; i < len; ++i) { + const int r = d_ptr->colorSpaceOut->lut[0]->u8FromLinearF32(buffer[i].x); + const int g = d_ptr->colorSpaceOut->lut[1]->u8FromLinearF32(buffer[i].y); + const int b = d_ptr->colorSpaceOut->lut[2]->u8FromLinearF32(buffer[i].z); + dst[i] = 0xff000000 | (r << 16) | (g << 8) | (b << 0); + } +#endif +} + +static void storePremultiplied(QRgba64 *dst, const QRgba64 *src, const QColorVector *buffer, const qsizetype len, + const QColorTransformPrivate *d_ptr) +{ + for (qsizetype i = 0; i < len; ++i) { + const int a = src[i].alpha(); + const float fa = a / (255.0f * 256.0f); + const float r = d_ptr->colorSpaceOut->lut[0]->m_fromLinear[int(buffer[i].x * 4080.0f + 0.5f)]; + const float g = d_ptr->colorSpaceOut->lut[1]->m_fromLinear[int(buffer[i].y * 4080.0f + 0.5f)]; + const float b = d_ptr->colorSpaceOut->lut[2]->m_fromLinear[int(buffer[i].z * 4080.0f + 0.5f)]; + dst[i] = qRgba64(r * fa + 0.5f, g * fa + 0.5f, b * fa + 0.5f, a); + } +} + +static void storeUnpremultiplied(QRgba64 *dst, const QRgba64 *src, const QColorVector *buffer, const qsizetype len, + const QColorTransformPrivate *d_ptr) +{ + for (qsizetype i = 0; i < len; ++i) { + const int r = d_ptr->colorSpaceOut->lut[0]->u16FromLinearF32(buffer[i].x); + const int g = d_ptr->colorSpaceOut->lut[1]->u16FromLinearF32(buffer[i].y); + const int b = d_ptr->colorSpaceOut->lut[2]->u16FromLinearF32(buffer[i].z); + dst[i] = qRgba64(r, g, b, src[i].alpha()); + } +} + +static void storeOpaque(QRgba64 *dst, const QRgba64 *src, const QColorVector *buffer, const qsizetype len, + const QColorTransformPrivate *d_ptr) +{ + Q_UNUSED(src); + for (qsizetype i = 0; i < len; ++i) { + const int r = d_ptr->colorSpaceOut->lut[0]->u16FromLinearF32(buffer[i].x); + const int g = d_ptr->colorSpaceOut->lut[1]->u16FromLinearF32(buffer[i].y); + const int b = d_ptr->colorSpaceOut->lut[2]->u16FromLinearF32(buffer[i].z); + dst[i] = qRgba64(r, g, b, 0xFFFF); + } +} + +static constexpr qsizetype WorkBlockSize = 256; + +template +void QColorTransformPrivate::apply(T *dst, const T *src, qsizetype count, TransformFlags flags) const +{ + if (!colorMatrix.isValid()) + return; + + updateLutsIn(); + updateLutsOut(); + + bool doApplyMatrix = (colorMatrix != QColorMatrix::identity()); + + QColorVector buffer[WorkBlockSize]; + qsizetype i = 0; + while (i < count) { + const qsizetype len = qMin(count - i, WorkBlockSize); + if (flags & InputPremultiplied) + loadPremultiplied(buffer, src + i, len, this); + else + loadUnpremultiplied(buffer, src + i, len, this); + + if (doApplyMatrix) + applyMatrix(buffer, len, colorMatrix); + + if (flags & InputOpaque) + storeOpaque(dst + i, src + i, buffer, len, this); + else if (flags & OutputPremultiplied) + storePremultiplied(dst + i, src + i, buffer, len, this); + else + storeUnpremultiplied(dst + i, src + i, buffer, len, this); + + i += len; + } +} + +/*! + \internal + \enum QColorTransformPrivate::TransformFlag + + Defines how the transform is to be applied. + + \value Unpremultiplied The input and output should both be unpremultiplied. + \value InputOpaque The input is guaranteed to be opaque. + \value InputPremultiplied The input is premultiplied. + \value OutputPremultiplied The output should be premultiplied. + \value Premultiplied Both input and output should both be premultiplied. +*/ + +/*! + \internal + Prepares a color transformation for fast application. You do not need to + call this explicitly as it will be called implicitly on the first transforms, but + if you want predictable performance on the first transforms, you can perform it + in advance. + + \sa QColorTransform::map(), apply() +*/ +void QColorTransformPrivate::prepare() +{ + updateLutsIn(); + updateLutsOut(); +} + +/*! + \internal + Applies the color transformation on \a count QRgb pixels starting from + \a src and stores the result in \a dst. + + Thread-safe if prepare() has been called first. + + Assumes unpremultiplied data by default. Set \a flags to change defaults. + + \sa prepare() +*/ +void QColorTransformPrivate::apply(QRgb *dst, const QRgb *src, qsizetype count, TransformFlags flags) const +{ + apply(dst, src, count, flags); +} + +/*! + \internal + Applies the color transformation on \a count QRgba64 pixels starting from + \a src and stores the result in \a dst. + + Thread-safe if prepare() has been called first. + + Assumes unpremultiplied data by default. Set \a flags to change defaults. + + \sa prepare() +*/ +void QColorTransformPrivate::apply(QRgba64 *dst, const QRgba64 *src, qsizetype count, TransformFlags flags) const +{ + apply(dst, src, count, flags); +} + + +QT_END_NAMESPACE diff --git a/src/gui/painting/qcolortransform.h b/src/gui/painting/qcolortransform.h new file mode 100644 index 0000000000..9274387b97 --- /dev/null +++ b/src/gui/painting/qcolortransform.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCOLORTRANSFORM_H +#define QCOLORTRANSFORM_H + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QColor; +class QRgba64; +class QColorSpacePrivate; +class QColorTransformPrivate; + +class Q_GUI_EXPORT QColorTransform +{ +public: + QColorTransform() noexcept : d_ptr(nullptr) { } + ~QColorTransform() noexcept; + QColorTransform(const QColorTransform &colorTransform) noexcept + : d_ptr(colorTransform.d_ptr) + { } + QColorTransform(QColorTransform &&colorTransform) noexcept + : d_ptr(std::move(colorTransform.d_ptr)) + { } + QColorTransform &operator=(const QColorTransform &other) noexcept + { + d_ptr = other.d_ptr; + return *this; + } + QColorTransform &operator=(QColorTransform &&other) noexcept + { + d_ptr = std::move(other.d_ptr); + return *this; + } + + bool isNull() const { return d_ptr.isNull(); } + + QRgb map(const QRgb &argb) const; + QRgba64 map(const QRgba64 &rgba64) const; + QColor map(const QColor &color) const; + +private: + friend class QColorSpace; + friend class QColorSpacePrivate; + friend class QImage; + + Q_DECLARE_PRIVATE(QColorTransform) + QSharedPointer d_ptr; +}; + +QT_END_NAMESPACE + +#endif // QCOLORTRANSFORM_H diff --git a/src/gui/painting/qcolortransform_p.h b/src/gui/painting/qcolortransform_p.h new file mode 100644 index 0000000000..74a1e7fe0a --- /dev/null +++ b/src/gui/painting/qcolortransform_p.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCOLORTRANSFORM_P_H +#define QCOLORTRANSFORM_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qcolormatrix_p.h" +#include "qcolorspace_p.h" + +QT_BEGIN_NAMESPACE + +class QColorTransformPrivate +{ +public: + QColorMatrix colorMatrix; + QExplicitlySharedDataPointer colorSpaceIn; + QExplicitlySharedDataPointer colorSpaceOut; + + void updateLutsIn() const; + void updateLutsOut() const; + bool simpleGammaCorrection() const; + + void prepare(); + enum TransformFlag { + Unpremultiplied = 0, + InputOpaque = 1, + InputPremultiplied = 2, + OutputPremultiplied = 4, + Premultiplied = (InputPremultiplied | OutputPremultiplied) + }; + Q_DECLARE_FLAGS(TransformFlags, TransformFlag) + + void apply(QRgb *dst, const QRgb *src, qsizetype count, TransformFlags flags = Unpremultiplied) const; + void apply(QRgba64 *dst, const QRgba64 *src, qsizetype count, TransformFlags flags = Unpremultiplied) const; + + template + void apply(T *dst, const T *src, qsizetype count, TransformFlags flags) const; +}; + +QT_END_NAMESPACE + +#endif // QCOLORTRANSFORM_P_H diff --git a/src/gui/painting/qcolortrc_p.h b/src/gui/painting/qcolortrc_p.h new file mode 100644 index 0000000000..3a649f3756 --- /dev/null +++ b/src/gui/painting/qcolortrc_p.h @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCOLORTRC_P_H +#define QCOLORTRC_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include "qcolortransferfunction_p.h" +#include "qcolortransfertable_p.h" + +QT_BEGIN_NAMESPACE + + +// Defines an ICC TRC (Tone Reproduction Curve) +class Q_GUI_EXPORT QColorTrc +{ +public: + QColorTrc() noexcept : m_type(Type::Uninitialized) + { } + QColorTrc(const QColorTransferFunction &fun) : m_type(Type::Function), m_fun(fun) + { } + QColorTrc(const QColorTransferTable &table) : m_type(Type::Table), m_table(table) + { } + + enum class Type { + Uninitialized, + Function, + Table + }; + + bool isLinear() const + { + return m_type == Type::Uninitialized || (m_type == Type::Function && m_fun.isLinear()); + } + bool isValid() const + { + return m_type != Type::Uninitialized; + } + float apply(float x) const + { + if (m_type == Type::Table) + return m_table.apply(x); + if (m_type == Type::Function) + return m_fun.apply(x); + return x; + } + + float applyInverse(float x) const + { + if (m_type == Type::Table) + return m_table.applyInverse(x); + if (m_type == Type::Function) + return m_fun.inverted().apply(x); + return x; + } + + friend inline bool operator!=(const QColorTrc &o1, const QColorTrc &o2); + friend inline bool operator==(const QColorTrc &o1, const QColorTrc &o2); + + Type m_type; + QColorTransferFunction m_fun; + QColorTransferTable m_table; +}; + +inline bool operator!=(const QColorTrc &o1, const QColorTrc &o2) +{ + if (o1.m_type != o2.m_type) + return true; + if (o1.m_type == QColorTrc::Type::Function) + return o1.m_fun != o2.m_fun; + if (o1.m_type == QColorTrc::Type::Table) + return o1.m_table != o2.m_table; + return false; +} +inline bool operator==(const QColorTrc &o1, const QColorTrc &o2) +{ + return !(o1 != o2); +} + +QT_END_NAMESPACE + +#endif // QCOLORTRC diff --git a/src/gui/painting/qcolorprofile.cpp b/src/gui/painting/qcolortrclut.cpp similarity index 69% rename from src/gui/painting/qcolorprofile.cpp rename to src/gui/painting/qcolortrclut.cpp index 3b7b0a248b..268d7252b4 100644 --- a/src/gui/painting/qcolorprofile.cpp +++ b/src/gui/painting/qcolortrclut.cpp @@ -37,14 +37,16 @@ ** ****************************************************************************/ -#include "qcolorprofile_p.h" +#include "qcolortrclut_p.h" +#include "qcolortransferfunction_p.h" +#include "qcolortransfertable_p.h" #include QT_BEGIN_NAMESPACE -QColorProfile *QColorProfile::fromGamma(qreal gamma) +QColorTrcLut *QColorTrcLut::fromGamma(qreal gamma) { - QColorProfile *cp = new QColorProfile; + QColorTrcLut *cp = new QColorTrcLut; for (int i = 0; i <= (255 * 16); ++i) { cp->m_toLinear[i] = ushort(qRound(qPow(i / qreal(255 * 16), gamma) * (255 * 256))); @@ -54,31 +56,28 @@ QColorProfile *QColorProfile::fromGamma(qreal gamma) return cp; } -static qreal srgbToLinear(qreal v) +QColorTrcLut *QColorTrcLut::fromTransferFunction(const QColorTransferFunction &fun) { - const qreal a = 0.055; - if (v <= qreal(0.04045)) - return v / qreal(12.92); - else - return qPow((v + a) / (qreal(1) + a), qreal(2.4)); -} - -static qreal linearToSrgb(qreal v) -{ - const qreal a = 0.055; - if (v <= qreal(0.0031308)) - return v * qreal(12.92); - else - return (qreal(1) + a) * qPow(v, qreal(1.0 / 2.4)) - a; -} - -QColorProfile *QColorProfile::fromSRgb() -{ - QColorProfile *cp = new QColorProfile; + QColorTrcLut *cp = new QColorTrcLut; + QColorTransferFunction inv = fun.inverted(); for (int i = 0; i <= (255 * 16); ++i) { - cp->m_toLinear[i] = ushort(qRound(srgbToLinear(i / qreal(255 * 16)) * (255 * 256))); - cp->m_fromLinear[i] = ushort(qRound(linearToSrgb(i / qreal(255 * 16)) * (255 * 256))); + cp->m_toLinear[i] = ushort(qRound(fun.apply(i / qreal(255 * 16)) * (255 * 256))); + cp->m_fromLinear[i] = ushort(qRound(inv.apply(i / qreal(255 * 16)) * (255 * 256))); + } + + return cp; +} + +QColorTrcLut *QColorTrcLut::fromTransferTable(const QColorTransferTable &table) +{ + QColorTrcLut *cp = new QColorTrcLut; + + float minInverse = 0.0f; + for (int i = 0; i <= (255 * 16); ++i) { + cp->m_toLinear[i] = ushort(qBound(0, qRound(table.apply(i / qreal(255 * 16)) * (255 * 256)), 65280)); + minInverse = table.applyInverse(i / qreal(255 * 16), minInverse); + cp->m_fromLinear[i] = ushort(qBound(0, qRound(minInverse * (255 * 256)), 65280)); } return cp; diff --git a/src/gui/painting/qcolorprofile_p.h b/src/gui/painting/qcolortrclut_p.h similarity index 87% rename from src/gui/painting/qcolorprofile_p.h rename to src/gui/painting/qcolortrclut_p.h index 425e9abace..76a6a60803 100644 --- a/src/gui/painting/qcolorprofile_p.h +++ b/src/gui/painting/qcolortrclut_p.h @@ -37,8 +37,8 @@ ** ****************************************************************************/ -#ifndef QCOLORPROFILE_P_H -#define QCOLORPROFILE_P_H +#ifndef QCOLORTRCLUT_P_H +#define QCOLORTRCLUT_P_H // // W A R N I N G @@ -52,21 +52,29 @@ // #include +#include #include #include +#include + #if defined(__SSE2__) #include #elif defined(__ARM_NEON__) || defined(__ARM_NEON) #include #endif + QT_BEGIN_NAMESPACE -class Q_GUI_EXPORT QColorProfile +class QColorTransferFunction; +class QColorTransferTable; + +class Q_GUI_EXPORT QColorTrcLut : public QEnableSharedFromThis { public: - static QColorProfile *fromGamma(qreal gamma); - static QColorProfile *fromSRgb(); + static QColorTrcLut *fromGamma(qreal gamma); + static QColorTrcLut *fromTransferFunction(const QColorTransferFunction &transfn); + static QColorTrcLut *fromTransferTable(const QColorTransferTable &transTable); // The following methods all convert opaque or unpremultiplied colors: @@ -121,6 +129,25 @@ public: return convertWithTable(rgb64, m_toLinear); } + float u8ToLinearF32(int c) const + { + ushort v = m_toLinear[c << 4]; + return v * (1.0f / (255*256)); + } + + float u16ToLinearF32(int c) const + { + c -= (c >> 8); + ushort v = m_toLinear[c >> 4]; + return v * (1.0f / (255*256)); + } + + float toLinear(float f) const + { + ushort v = m_toLinear[(int)(f * (255 * 16) + 0.5f)]; + return v * (1.0f / (255*256)); + } + QRgb fromLinear64(QRgba64 rgb64) const { #if defined(__SSE2__) @@ -176,8 +203,31 @@ public: return convertWithTable(rgb64, m_fromLinear); } + int u8FromLinearF32(float f) const + { + ushort v = m_fromLinear[(int)(f * (255 * 16) + 0.5f)]; + return (v + 0x80) >> 8; + } + int u16FromLinearF32(float f) const + { + ushort v = m_fromLinear[(int)(f * (255 * 16) + 0.5f)]; + return v + (v >> 8); + } + float fromLinear(float f) const + { + ushort v = m_fromLinear[(int)(f * (255 * 16) + 0.5f)]; + return v * (1.0f / (255*256)); + } + + // We translate to 0-65280 (255*256) instead to 0-65535 to make simple + // shifting an accurate conversion. + // We translate from 0-4080 (255*16) for the same speed up, and to keep + // the tables small enough to fit in most inner caches. + ushort m_toLinear[(255 * 16) + 1]; // [0-4080] -> [0-65280] + ushort m_fromLinear[(255 * 16) + 1]; // [0-4080] -> [0-65280] + private: - QColorProfile() { } + QColorTrcLut() { } Q_ALWAYS_INLINE static QRgb convertWithTable(QRgb rgb32, const ushort *table) { @@ -230,16 +280,8 @@ private: return QRgba64::fromRgba64(r, g, b, rgb64.alpha()); #endif } - - // We translate to 0-65280 (255*256) instead to 0-65535 to make simple - // shifting an accurate conversion. - // We translate from 0-4080 (255*16) for the same speed up, and to keep - // the tables small enough to fit in most inner caches. - ushort m_toLinear[(255 * 16) + 1]; // [0-4080] -> [0-65280] - ushort m_fromLinear[(255 * 16) + 1]; // [0-4080] -> [0-65280] - }; QT_END_NAMESPACE -#endif // QCOLORPROFILE_P_H +#endif // QCOLORTRCLUT_P_H diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 2dd18f6dfc..1ed51d26a2 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include #include #include @@ -5523,7 +5523,7 @@ inline static void qt_bitmapblit_quint16(QRasterBuffer *rasterBuffer, map, mapWidth, mapHeight, mapStride); } -static inline void alphamapblend_generic(int coverage, QRgba64 *dest, int x, const QRgba64 &srcLinear, const QRgba64 &src, const QColorProfile *colorProfile) +static inline void alphamapblend_generic(int coverage, QRgba64 *dest, int x, const QRgba64 &srcLinear, const QRgba64 &src, const QColorTrcLut *colorProfile) { if (coverage == 0) { // nothing @@ -5558,7 +5558,7 @@ static void qt_alphamapblit_generic(QRasterBuffer *rasterBuffer, if (color.isTransparent()) return; - const QColorProfile *colorProfile = nullptr; + const QColorTrcLut *colorProfile = nullptr; if (useGammaCorrection) colorProfile = QGuiApplicationPrivate::instance()->colorProfileForA8Text(); @@ -5684,7 +5684,7 @@ void qt_alphamapblit_quint16(QRasterBuffer *rasterBuffer, } } -static inline void rgbBlendPixel(quint32 *dst, int coverage, QRgba64 slinear, const QColorProfile *colorProfile) +static inline void rgbBlendPixel(quint32 *dst, int coverage, QRgba64 slinear, const QColorTrcLut *colorProfile) { // Do a gammacorrected RGB alphablend... const QRgba64 dlinear = colorProfile ? colorProfile->toLinear64(*dst) : QRgba64::fromArgb32(*dst); @@ -5694,7 +5694,7 @@ static inline void rgbBlendPixel(quint32 *dst, int coverage, QRgba64 slinear, co *dst = colorProfile ? colorProfile->fromLinear64(blend) : toArgb32(blend); } -static inline void grayBlendPixel(quint32 *dst, int coverage, QRgba64 srcLinear, const QColorProfile *colorProfile) +static inline void grayBlendPixel(quint32 *dst, int coverage, QRgba64 srcLinear, const QColorTrcLut *colorProfile) { // Do a gammacorrected gray alphablend... const QRgba64 dstLinear = colorProfile ? colorProfile->toLinear64(*dst) : QRgba64::fromArgb32(*dst); @@ -5704,7 +5704,7 @@ static inline void grayBlendPixel(quint32 *dst, int coverage, QRgba64 srcLinear, *dst = colorProfile ? colorProfile->fromLinear64(blend) : toArgb32(blend); } -static inline void alphamapblend_argb32(quint32 *dst, int coverage, QRgba64 srcLinear, quint32 src, const QColorProfile *colorProfile) +static inline void alphamapblend_argb32(quint32 *dst, int coverage, QRgba64 srcLinear, quint32 src, const QColorTrcLut *colorProfile) { if (coverage == 0) { // nothing @@ -5734,7 +5734,7 @@ static void qt_alphamapblit_argb32(QRasterBuffer *rasterBuffer, if (color.isTransparent()) return; - const QColorProfile *colorProfile = nullptr; + const QColorTrcLut *colorProfile = nullptr; if (useGammaCorrection) colorProfile = QGuiApplicationPrivate::instance()->colorProfileForA8Text(); @@ -5830,7 +5830,7 @@ static inline QRgb rgbBlend(QRgb d, QRgb s, uint rgbAlpha) #endif } -static inline void alphargbblend_generic(uint coverage, QRgba64 *dest, int x, const QRgba64 &srcLinear, const QRgba64 &src, const QColorProfile *colorProfile) +static inline void alphargbblend_generic(uint coverage, QRgba64 *dest, int x, const QRgba64 &srcLinear, const QRgba64 &src, const QColorTrcLut *colorProfile) { if (coverage == 0xff000000) { // nothing @@ -5852,7 +5852,7 @@ static inline void alphargbblend_generic(uint coverage, QRgba64 *dest, int x, co } } -static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba64 &srcLinear, quint32 src, const QColorProfile *colorProfile) +static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba64 &srcLinear, quint32 src, const QColorTrcLut *colorProfile) { if (coverage == 0xff000000) { // nothing @@ -5877,7 +5877,7 @@ static void qt_alphargbblit_generic(QRasterBuffer *rasterBuffer, if (color.isTransparent()) return; - const QColorProfile *colorProfile = nullptr; + const QColorTrcLut *colorProfile = nullptr; if (useGammaCorrection) colorProfile = QGuiApplicationPrivate::instance()->colorProfileForA32Text(); @@ -5954,7 +5954,7 @@ static void qt_alphargbblit_argb32(QRasterBuffer *rasterBuffer, const quint32 c = color.toArgb32(); - const QColorProfile *colorProfile = nullptr; + const QColorTrcLut *colorProfile = nullptr; if (useGammaCorrection) colorProfile = QGuiApplicationPrivate::instance()->colorProfileForA32Text(); diff --git a/src/gui/painting/qicc.cpp b/src/gui/painting/qicc.cpp new file mode 100644 index 0000000000..d88b005782 --- /dev/null +++ b/src/gui/painting/qicc.cpp @@ -0,0 +1,669 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qicc_p.h" + +#include +#include +#include +#include +#include + +#include "qcolorspace_p.h" +#include "qcolortrc_p.h" + +QT_BEGIN_NAMESPACE +Q_LOGGING_CATEGORY(lcIcc, "qt.gui.icc") + +struct ICCProfileHeader +{ + quint32_be profileSize; + + quint32_be preferredCmmType; + + quint32_be profileVersion; + quint32_be profileClass; + quint32_be inputColorSpace; + quint32_be pcs; + quint32_be datetime[3]; + quint32_be signature; + quint32_be platformSignature; + quint32_be flags; + quint32_be deviceManufacturer; + quint32_be deviceModel; + quint32_be deviceAttributes[2]; + + quint32_be renderingIntent; + qint32_be illuminantXyz[3]; + + quint32_be creatorSignature; + quint32_be profileId[4]; + + quint32_be reserved[7]; + +// Technically after the header, but easier to include here: + quint32_be tagCount; +}; + +constexpr quint32 IccTag(uchar a, uchar b, uchar c, uchar d) +{ + return (a << 24) | (b << 16) | (c << 8) | d; +} + +enum class ProfileClass : quint32 { + Input = IccTag('s', 'c', 'r', 'n'), + Display = IccTag('m', 'n', 't', 'r'), + // Not supported: + Output = IccTag('p', 'r', 't', 'r'), + ColorSpace = IccTag('s', 'p', 'a', 'c'), +}; + +enum class Tag : quint32 { + acsp = IccTag('a', 'c', 's', 'p'), + RGB_ = IccTag('R', 'G', 'B', ' '), + XYZ_ = IccTag('X', 'Y', 'Z', ' '), + rXYZ = IccTag('r', 'X', 'Y', 'Z'), + gXYZ = IccTag('g', 'X', 'Y', 'Z'), + bXYZ = IccTag('b', 'X', 'Y', 'Z'), + rTRC = IccTag('r', 'T', 'R', 'C'), + gTRC = IccTag('g', 'T', 'R', 'C'), + bTRC = IccTag('b', 'T', 'R', 'C'), + A2B0 = IccTag('A', '2', 'B', '0'), + A2B1 = IccTag('A', '2', 'B', '1'), + B2A0 = IccTag('B', '2', 'A', '0'), + B2A1 = IccTag('B', '2', 'A', '1'), + desc = IccTag('d', 'e', 's', 'c'), + text = IccTag('t', 'e', 'x', 't'), + cprt = IccTag('c', 'p', 'r', 't'), + curv = IccTag('c', 'u', 'r', 'v'), + para = IccTag('p', 'a', 'r', 'a'), + wtpt = IccTag('w', 't', 'p', 't'), + bkpt = IccTag('b', 'k', 'p', 't'), + mft1 = IccTag('m', 'f', 't', '1'), + mft2 = IccTag('m', 'f', 't', '2'), + mAB_ = IccTag('m', 'A', 'B', ' '), + mBA_ = IccTag('m', 'B', 'A', ' '), + chad = IccTag('c', 'h', 'a', 'd'), + sf32 = IccTag('s', 'f', '3', '2'), + + // Apple extensions for ICCv2: + aarg = IccTag('a', 'a', 'r', 'g'), + aagg = IccTag('a', 'a', 'g', 'g'), + aabg = IccTag('a', 'a', 'b', 'g'), +}; + +inline uint qHash(const Tag &key, uint seed = 0) +{ + return qHash(quint32(key), seed); +} + +namespace QIcc { + +struct TagTableEntry +{ + quint32_be signature; + quint32_be offset; + quint32_be size; +}; + +struct GenericTagData { + quint32_be type; + quint32_be null; +}; + +struct XYZTagData : GenericTagData { + qint32_be fixedX; + qint32_be fixedY; + qint32_be fixedZ; +}; + +struct CurvTagData : GenericTagData { + quint32_be valueCount; + quint16_be value[1]; +}; + +struct ParaTagData : GenericTagData { + quint16_be curveType; + quint16_be null2; + quint32_be parameter[1]; +}; + +// For both mAB and mBA +struct mABTagData : GenericTagData { + quint8 inputChannels; + quint8 outputChannels; + quint8 padding[2]; + quint32_be bCurvesOffset; + quint32_be matrixOffset; + quint32_be mCurvesOffset; + quint32_be clutOffset; + quint32_be aCurvesOffset; +}; + +struct Sf32TagData : GenericTagData { + quint32_be value[1]; +}; + +static int toFixedS1516(float x) +{ + return int(x * 65536.0f + 0.5f); +} + +static float fromFixedS1516(int x) +{ + return x * (1.0f / 65536.0f); +} + +QColorVector fromXyzData(const XYZTagData *xyz) +{ + const float x = fromFixedS1516(xyz->fixedX); + const float y = fromFixedS1516(xyz->fixedY); + const float z = fromFixedS1516(xyz->fixedZ); + qCDebug(lcIcc) << "XYZ_ " << x << y << z; + + return QColorVector(x, y, z); +} + +static bool isValidIccProfile(const ICCProfileHeader &header) +{ + if (header.signature != uint(Tag::acsp)) { + qCWarning(lcIcc, "Failed ICC signature test"); + return false; + } + if (header.profileSize < (sizeof(ICCProfileHeader) + header.tagCount * sizeof(TagTableEntry))) { + qCWarning(lcIcc, "Failed basic size sanity"); + return false; + } + + if (header.profileClass != uint(ProfileClass::Input) + && header.profileClass != uint(ProfileClass::Display)) { + qCWarning(lcIcc, "Unsupported ICC profile class %x", quint32(header.profileClass)); + return false; + } + if (header.inputColorSpace != 0x52474220 /* 'RGB '*/) { + qCWarning(lcIcc, "Unsupported ICC input color space %x", quint32(header.inputColorSpace)); + return false; + } + if (header.pcs != 0x58595a20 /* 'XYZ '*/) { + // ### support PCSLAB + qCWarning(lcIcc, "Unsupported ICC profile connection space %x", quint32(header.pcs)); + return false; + } + + QColorVector illuminant; + illuminant.x = fromFixedS1516(header.illuminantXyz[0]); + illuminant.y = fromFixedS1516(header.illuminantXyz[1]); + illuminant.z = fromFixedS1516(header.illuminantXyz[2]); + if (illuminant != QColorVector::D50()) { + qCWarning(lcIcc, "Invalid ICC illuminant"); + return false; + } + + return true; +} + +static int writeColorTrc(QDataStream &stream, const QColorTrc &trc) +{ + if (trc.isLinear()) { + stream << uint(Tag::curv) << uint(0); + stream << uint(0); + return 12; + } + + if (trc.m_type == QColorTrc::Type::Function) { + const QColorTransferFunction &fun = trc.m_fun; + stream << uint(Tag::para) << uint(0); + if (fun.isGamma()) { + stream << ushort(0) << ushort(0); + stream << toFixedS1516(fun.m_g); + return 12 + 4; + } + bool type3 = qFuzzyIsNull(fun.m_e) && qFuzzyIsNull(fun.m_f); + stream << ushort(type3 ? 3 : 4) << ushort(0); + stream << toFixedS1516(fun.m_g); + stream << toFixedS1516(fun.m_a); + stream << toFixedS1516(fun.m_b); + stream << toFixedS1516(fun.m_c); + stream << toFixedS1516(fun.m_d); + if (type3) + return 12 + 5 * 4; + stream << toFixedS1516(fun.m_e); + stream << toFixedS1516(fun.m_f); + return 12 + 7 * 4; + } + + Q_ASSERT(trc.m_type == QColorTrc::Type::Table); + stream << uint(Tag::curv) << uint(0); + stream << uint(trc.m_table.m_tableSize); + if (!trc.m_table.m_table16.isEmpty()) { + for (uint i = 0; i < trc.m_table.m_tableSize; ++i) { + stream << ushort(trc.m_table.m_table16[i]); + } + } else { + for (uint i = 0; i < trc.m_table.m_tableSize; ++i) { + stream << ushort(trc.m_table.m_table8[i] * 257U); + } + } + return 12 + 2 * trc.m_table.m_tableSize; +} + +QByteArray toIccProfile(const QColorSpace &space) +{ + if (!space.isValid()) + return QByteArray(); + + const QColorSpacePrivate *spaceDPtr = space.d_func(); + + constexpr int tagCount = 9; + constexpr uint profileDataOffset = 128 + 4 + 12 * tagCount; + constexpr uint variableTagTableOffsets = 128 + 4 + 12 * 5; + uint currentOffset = 0; + uint rTrcOffset, gTrcOffset, bTrcOffset; + uint rTrcSize, gTrcSize, bTrcSize; + uint descOffset, descSize; + + QBuffer buffer; + buffer.open(QIODevice::WriteOnly); + QDataStream stream(&buffer); + + // Profile header: + stream << uint(0); // Size, we will update this later + stream << uint(0); + stream << uint(0x02400000); // Version 2.4 (note we use 'para' from version 4) + stream << uint(ProfileClass::Display); + stream << uint(Tag::RGB_); + stream << uint(Tag::XYZ_); + stream << uint(0) << uint(0) << uint(0); + stream << uint(Tag::acsp); + stream << uint(0) << uint(0) << uint(0); + stream << uint(0) << uint(0) << uint(0); + stream << uint(1); // Rendering intent + stream << uint(0x0000f6d6); // D50 X + stream << uint(0x00010000); // D50 Y + stream << uint(0x0000d32d); // D50 Z + stream << IccTag('Q','t', QT_VERSION_MAJOR, QT_VERSION_MINOR); + stream << uint(0) << uint(0) << uint(0) << uint(0); + stream << uint(0) << uint(0) << uint(0) << uint(0) << uint(0) << uint(0) << uint(0); + + // Tag table: + stream << uint(tagCount); + stream << uint(Tag::rXYZ) << uint(profileDataOffset + 00) << uint(20); + stream << uint(Tag::gXYZ) << uint(profileDataOffset + 20) << uint(20); + stream << uint(Tag::bXYZ) << uint(profileDataOffset + 40) << uint(20); + stream << uint(Tag::wtpt) << uint(profileDataOffset + 60) << uint(20); + stream << uint(Tag::cprt) << uint(profileDataOffset + 80) << uint(12); + // From here the offset and size will be updated later: + stream << uint(Tag::rTRC) << uint(0) << uint(0); + stream << uint(Tag::gTRC) << uint(0) << uint(0); + stream << uint(Tag::bTRC) << uint(0) << uint(0); + stream << uint(Tag::desc) << uint(0) << uint(0); + // TODO: consider adding 'chad' tag (required in ICC >=4 when we have non-D50 whitepoint) + currentOffset = profileDataOffset; + + // Tag data: + stream << uint(Tag::XYZ_) << uint(0); + stream << toFixedS1516(spaceDPtr->toXyz.r.x); + stream << toFixedS1516(spaceDPtr->toXyz.r.y); + stream << toFixedS1516(spaceDPtr->toXyz.r.z); + stream << uint(Tag::XYZ_) << uint(0); + stream << toFixedS1516(spaceDPtr->toXyz.g.x); + stream << toFixedS1516(spaceDPtr->toXyz.g.y); + stream << toFixedS1516(spaceDPtr->toXyz.g.z); + stream << uint(Tag::XYZ_) << uint(0); + stream << toFixedS1516(spaceDPtr->toXyz.b.x); + stream << toFixedS1516(spaceDPtr->toXyz.b.y); + stream << toFixedS1516(spaceDPtr->toXyz.b.z); + stream << uint(Tag::XYZ_) << uint(0); + stream << toFixedS1516(spaceDPtr->whitePoint.x); + stream << toFixedS1516(spaceDPtr->whitePoint.y); + stream << toFixedS1516(spaceDPtr->whitePoint.z); + stream << uint(Tag::text) << uint(0); + stream << uint(IccTag('N', '/', 'A', '\0')); + currentOffset += 92; + + // From now on the data is variable sized: + rTrcOffset = currentOffset; + rTrcSize = writeColorTrc(stream, spaceDPtr->trc[0]); + currentOffset += rTrcSize; + if (spaceDPtr->trc[0] == spaceDPtr->trc[1]) { + gTrcOffset = rTrcOffset; + gTrcSize = rTrcSize; + } else { + gTrcOffset = currentOffset; + gTrcSize = writeColorTrc(stream, spaceDPtr->trc[1]); + currentOffset += gTrcSize; + } + if (spaceDPtr->trc[0] == spaceDPtr->trc[2]) { + bTrcOffset = rTrcOffset; + bTrcSize = rTrcSize; + } else { + bTrcOffset = currentOffset; + bTrcSize = writeColorTrc(stream, spaceDPtr->trc[2]); + currentOffset += bTrcSize; + } + + descOffset = currentOffset; + QByteArray description = spaceDPtr->description.toUtf8(); + stream << uint(Tag::desc) << uint(0); + stream << uint(description.size() + 1); + stream.writeRawData(description.constData(), description.size() + 1); + stream << uint(0) << uint(0); + stream << ushort(0) << uchar(0); + QByteArray macdesc(67, '\0'); + stream.writeRawData(macdesc.constData(), 67); + descSize = 90 + description.size() + 1; + currentOffset += descSize; + + buffer.close(); + QByteArray iccProfile = buffer.buffer(); + // Now write final size + *(quint32_be *)iccProfile.data() = iccProfile.size(); + // And the final indices and sizes of variable size tags: + *(quint32_be *)(iccProfile.data() + variableTagTableOffsets + 4) = rTrcOffset; + *(quint32_be *)(iccProfile.data() + variableTagTableOffsets + 8) = rTrcSize; + *(quint32_be *)(iccProfile.data() + variableTagTableOffsets + 12 + 4) = gTrcOffset; + *(quint32_be *)(iccProfile.data() + variableTagTableOffsets + 12 + 8) = gTrcSize; + *(quint32_be *)(iccProfile.data() + variableTagTableOffsets + 2 * 12 + 4) = bTrcOffset; + *(quint32_be *)(iccProfile.data() + variableTagTableOffsets + 2 * 12 + 8) = bTrcSize; + *(quint32_be *)(iccProfile.data() + variableTagTableOffsets + 3 * 12 + 4) = descOffset; + *(quint32_be *)(iccProfile.data() + variableTagTableOffsets + 3 * 12 + 8) = descSize; + +#if !defined(QT_NO_DEBUG) || defined(QT_FORCE_ASSERTS) + const ICCProfileHeader *iccHeader = (const ICCProfileHeader *)iccProfile.constData(); + Q_ASSERT(qsizetype(iccHeader->profileSize) == qsizetype(iccProfile.size())); + Q_ASSERT(isValidIccProfile(*iccHeader)); +#endif + + return iccProfile; +} + +bool parseTRC(const GenericTagData *trcData, QColorTrc &gamma) +{ + if (trcData->type == quint32(Tag::curv)) { + const CurvTagData *curv = reinterpret_cast(trcData); + qCDebug(lcIcc) << "curv" << uint(curv->valueCount); + if (curv->valueCount == 0) { + gamma.m_type = QColorTrc::Type::Function; + gamma.m_fun = QColorTransferFunction(); // Linear + } else if (curv->valueCount == 1) { + float g = curv->value[0] * (1.0f / 256.0f); + qCDebug(lcIcc) << g; + gamma.m_type = QColorTrc::Type::Function; + gamma.m_fun = QColorTransferFunction::fromGamma(g); + } else { + QVector tabl; + tabl.resize(curv->valueCount); + for (uint i = 0; i < curv->valueCount; ++i) + tabl[i] = curv->value[i]; + QColorTransferTable table = QColorTransferTable(curv->valueCount, std::move(tabl)); + QColorTransferFunction curve; + if (!table.asColorTransferFunction(&curve)) { + gamma.m_type = QColorTrc::Type::Table; + gamma.m_table = table; + } else { + qCDebug(lcIcc) << "Detected curv table as function"; + gamma.m_type = QColorTrc::Type::Function; + gamma.m_fun = curve; + } + } + return true; + } + if (trcData->type == quint32(Tag::para)) { + const ParaTagData *para = reinterpret_cast(trcData); + qCDebug(lcIcc) << "para" << uint(para->curveType); + switch (para->curveType) { + case 0: { + float g = fromFixedS1516(para->parameter[0]); + qCDebug(lcIcc) << g; + gamma.m_type = QColorTrc::Type::Function; + gamma.m_fun = QColorTransferFunction::fromGamma(g); + break; + } + case 1: { + float g = fromFixedS1516(para->parameter[0]); + float a = fromFixedS1516(para->parameter[1]); + float b = fromFixedS1516(para->parameter[2]); + float d = -b / a; + qCDebug(lcIcc) << g << a << b; + gamma.m_type = QColorTrc::Type::Function; + gamma.m_fun = QColorTransferFunction(a, b, 0.0f, d, 0.0f, 0.0f, g); + break; + } + case 2: { + float g = fromFixedS1516(para->parameter[0]); + float a = fromFixedS1516(para->parameter[1]); + float b = fromFixedS1516(para->parameter[2]); + float c = fromFixedS1516(para->parameter[3]); + float d = -b / a; + qCDebug(lcIcc) << g << a << b << c; + gamma.m_type = QColorTrc::Type::Function; + gamma.m_fun = QColorTransferFunction(a, b, 0.0f, d, c, c, g); + break; + } + case 3: { + float g = fromFixedS1516(para->parameter[0]); + float a = fromFixedS1516(para->parameter[1]); + float b = fromFixedS1516(para->parameter[2]); + float c = fromFixedS1516(para->parameter[3]); + float d = fromFixedS1516(para->parameter[4]); + qCDebug(lcIcc) << g << a << b << c << d; + gamma.m_type = QColorTrc::Type::Function; + gamma.m_fun = QColorTransferFunction(a, b, c, d, 0.0f, 0.0f, g); + break; + } + case 4: { + float g = fromFixedS1516(para->parameter[0]); + float a = fromFixedS1516(para->parameter[1]); + float b = fromFixedS1516(para->parameter[2]); + float c = fromFixedS1516(para->parameter[3]); + float d = fromFixedS1516(para->parameter[4]); + float e = fromFixedS1516(para->parameter[5]); + float f = fromFixedS1516(para->parameter[6]); + qCDebug(lcIcc) << g << a << b << c << d << e << f; + gamma.m_type = QColorTrc::Type::Function; + gamma.m_fun = QColorTransferFunction(a, b, c, d, e, f, g); + break; + } + default: + qCWarning(lcIcc) << "Unknown para type" << uint(para->curveType); + return false; + } + return true; + } + qCWarning(lcIcc) << "Invalid TRC data type"; + return false; +} + +bool fromIccProfile(const QByteArray &data, QColorSpace *colorSpace) +{ + if (data.size() < qsizetype(sizeof(ICCProfileHeader))) { + qCWarning(lcIcc) << "fromIccProfile: failed size sanity 1"; + return false; + } + const ICCProfileHeader *header = (const ICCProfileHeader *)data.constData(); + if (!isValidIccProfile(*header)) { + qCWarning(lcIcc) << "fromIccProfile: failed general sanity check"; + return false; + } + if (qsizetype(header->profileSize) > data.size()) { + qCWarning(lcIcc) << "fromIccProfile: failed size sanity 2"; + return false; + } + + // Read tag index + const TagTableEntry *tagTable = (const TagTableEntry *)(data.constData() + sizeof(ICCProfileHeader)); + const qsizetype offsetToData = sizeof(ICCProfileHeader) + header->tagCount * sizeof(TagTableEntry); + + QHash tagIndex; + for (uint i = 0; i < header->tagCount; ++i) { + // Sanity check tag sizes and offsets: + if (qsizetype(tagTable[i].offset) < offsetToData) { + qCWarning(lcIcc) << "fromIccProfile: failed tag offset sanity 1"; + return false; + } + // Checked separately from (+ size) to handle overflow. + if (tagTable[i].offset > header->profileSize) { + qCWarning(lcIcc) << "fromIccProfile: failed tag offset sanity 2"; + return false; + } + if ((tagTable[i].offset + tagTable[i].size) > header->profileSize) { + qCWarning(lcIcc) << "fromIccProfile: failed tag offset + size sanity"; + return false; + } +// printf("'%4s' %d %d\n", (const char *)&tagTable[i].signature, +// quint32(tagTable[i].offset), +// quint32(tagTable[i].size)); + tagIndex.insert(Tag(quint32(tagTable[i].signature)), tagTable[i].offset); + } + // Check the profile is three-component matrix based (what we currently support): + if (!tagIndex.contains(Tag::rXYZ) || !tagIndex.contains(Tag::gXYZ) || !tagIndex.contains(Tag::bXYZ) || + !tagIndex.contains(Tag::rTRC) || !tagIndex.contains(Tag::gTRC) || !tagIndex.contains(Tag::bTRC) || + !tagIndex.contains(Tag::wtpt)) { + qCWarning(lcIcc) << "fromIccProfile: Unsupported ICC profile - not three component matrix based"; + return false; + } + + // Parse XYZ tags + const XYZTagData *rXyz = (const XYZTagData *)(data.constData() + tagIndex[Tag::rXYZ]); + const XYZTagData *gXyz = (const XYZTagData *)(data.constData() + tagIndex[Tag::gXYZ]); + const XYZTagData *bXyz = (const XYZTagData *)(data.constData() + tagIndex[Tag::bXYZ]); + const XYZTagData *wXyz = (const XYZTagData *)(data.constData() + tagIndex[Tag::wtpt]); + if (rXyz->type != quint32(Tag::XYZ_) || gXyz->type != quint32(Tag::XYZ_) || + wXyz->type != quint32(Tag::XYZ_) || wXyz->type != quint32(Tag::XYZ_)) { + qCWarning(lcIcc) << "fromIccProfile: Bad XYZ data type"; + return false; + } + QColorSpacePrivate *colorspaceDPtr = colorSpace->d_func(); + + colorspaceDPtr->toXyz.r = fromXyzData(rXyz); + colorspaceDPtr->toXyz.g = fromXyzData(gXyz); + colorspaceDPtr->toXyz.b = fromXyzData(bXyz); + QColorVector whitePoint = fromXyzData(wXyz); + colorspaceDPtr->whitePoint = whitePoint; + + colorspaceDPtr->gamut = QColorSpace::Gamut::Custom; + if (colorspaceDPtr->toXyz == QColorMatrix::toXyzFromSRgb()) { + qCDebug(lcIcc) << "fromIccProfile: sRGB gamut detected"; + colorspaceDPtr->gamut = QColorSpace::Gamut::SRgb; + } else if (colorspaceDPtr->toXyz == QColorMatrix::toXyzFromAdobeRgb()) { + qCDebug(lcIcc) << "fromIccProfile: Adobe RGB gamut detected"; + colorspaceDPtr->gamut = QColorSpace::Gamut::AdobeRgb; + } else if (colorspaceDPtr->toXyz == QColorMatrix::toXyzFromDciP3D65()) { + qCDebug(lcIcc) << "fromIccProfile: DCI-P3 D65 gamut detected"; + colorspaceDPtr->gamut = QColorSpace::Gamut::DciP3D65; + } else if (colorspaceDPtr->toXyz == QColorMatrix::toXyzFromBt2020()) { + qCDebug(lcIcc) << "fromIccProfile: BT.2020 gamut detected"; + colorspaceDPtr->gamut = QColorSpace::Gamut::Bt2020; + } + if (colorspaceDPtr->toXyz == QColorMatrix::toXyzFromProPhotoRgb()) { + qCDebug(lcIcc) << "fromIccProfile: ProPhoto RGB gamut detected"; + colorspaceDPtr->gamut = QColorSpace::Gamut::ProPhotoRgb; + } + // Reset the matrix to our canonical values: + if (colorspaceDPtr->gamut != QColorSpace::Gamut::Custom) + colorspaceDPtr->setToXyzMatrix(); + + // Parse TRC tags + const GenericTagData *rTrc; + const GenericTagData *gTrc; + const GenericTagData *bTrc; + if (tagIndex.contains(Tag::aarg) && tagIndex.contains(Tag::aagg) && tagIndex.contains(Tag::aabg)) { + // Apple extension for parametric version of TRCs in ICCv2: + rTrc = (const GenericTagData *)(data.constData() + tagIndex[Tag::aarg]); + gTrc = (const GenericTagData *)(data.constData() + tagIndex[Tag::aagg]); + bTrc = (const GenericTagData *)(data.constData() + tagIndex[Tag::aabg]); + } else { + rTrc = (const GenericTagData *)(data.constData() + tagIndex[Tag::rTRC]); + gTrc = (const GenericTagData *)(data.constData() + tagIndex[Tag::gTRC]); + bTrc = (const GenericTagData *)(data.constData() + tagIndex[Tag::bTRC]); + } + + QColorTrc rCurve; + QColorTrc gCurve; + QColorTrc bCurve; + if (!parseTRC(rTrc, rCurve)) + return false; + if (!parseTRC(gTrc, gCurve)) + return false; + if (!parseTRC(bTrc, bCurve)) + return false; + if (rCurve == gCurve && gCurve == bCurve && rCurve.m_type == QColorTrc::Type::Function) { + if (rCurve.m_fun.isLinear()) { + qCDebug(lcIcc) << "fromIccProfile: Linear gamma detected"; + colorspaceDPtr->trc[0] = QColorTransferFunction(); + colorspaceDPtr->transferFunction = QColorSpace::TransferFunction::Linear; + colorspaceDPtr->gamma = 1.0f; + } else if (rCurve.m_fun.isGamma()) { + qCDebug(lcIcc) << "fromIccProfile: Simple gamma detected"; + colorspaceDPtr->trc[0] = QColorTransferFunction::fromGamma(rCurve.m_fun.m_g); + colorspaceDPtr->transferFunction = QColorSpace::TransferFunction::Gamma; + colorspaceDPtr->gamma = rCurve.m_fun.m_g; + } else if (rCurve.m_fun.isSRgb()) { + qCDebug(lcIcc) << "fromIccProfile: sRGB gamma detected"; + colorspaceDPtr->trc[0] = QColorTransferFunction::fromSRgb(); + colorspaceDPtr->transferFunction = QColorSpace::TransferFunction::SRgb; + } else { + colorspaceDPtr->trc[0] = rCurve; + colorspaceDPtr->transferFunction = QColorSpace::TransferFunction::Custom; + } + + colorspaceDPtr->trc[1] = colorspaceDPtr->trc[0]; + colorspaceDPtr->trc[2] = colorspaceDPtr->trc[0]; + } else { + colorspaceDPtr->trc[0] = rCurve; + colorspaceDPtr->trc[1] = gCurve; + colorspaceDPtr->trc[2] = bCurve; + colorspaceDPtr->transferFunction = QColorSpace::TransferFunction::Custom; + } + + // FIXME: try to parse the description.. + + if (!colorspaceDPtr->identifyColorSpace()) + colorspaceDPtr->id = QColorSpace::Unknown; + else + qCDebug(lcIcc) << "fromIccProfile: Named colorspace detected: " << colorSpace->colorSpaceId(); + + colorspaceDPtr->iccProfile = data; + + return true; +} + +} // namespace QIcc + +QT_END_NAMESPACE diff --git a/src/gui/painting/qicc_p.h b/src/gui/painting/qicc_p.h new file mode 100644 index 0000000000..c3220391f4 --- /dev/null +++ b/src/gui/painting/qicc_p.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QICC_P_H +#define QICC_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class QColorSpace; + +namespace QIcc { + +Q_GUI_EXPORT bool fromIccProfile(const QByteArray &data, QColorSpace *colorSpace); +Q_GUI_EXPORT QByteArray toIccProfile(const QColorSpace &space); + +} + +QT_END_NAMESPACE + +#endif // QICC_P_H diff --git a/src/gui/painting/qpainter_p.h b/src/gui/painting/qpainter_p.h index 930180e9fa..9857a59070 100644 --- a/src/gui/painting/qpainter_p.h +++ b/src/gui/painting/qpainter_p.h @@ -54,6 +54,8 @@ #include #include #include "QtGui/qbrush.h" +#include "QtGui/qcolorspace.h" +#include "QtGui/qcolortransform.h" #include "QtGui/qfont.h" #include "QtGui/qpen.h" #include "QtGui/qregion.h" diff --git a/src/plugins/imageformats/jpeg/qjpeghandler.cpp b/src/plugins/imageformats/jpeg/qjpeghandler.cpp index 54fe857908..9d5ccc8a3d 100644 --- a/src/plugins/imageformats/jpeg/qjpeghandler.cpp +++ b/src/plugins/imageformats/jpeg/qjpeghandler.cpp @@ -40,10 +40,14 @@ #include "qjpeghandler_p.h" #include +#include +#include +#include #include #include #include #include +#include #include #include // for qt_getImageText @@ -725,6 +729,7 @@ public: QRect clipRect; QString description; QStringList readTexts; + QByteArray iccProfile; struct jpeg_decompress_struct info; struct my_jpeg_source_mgr * iod_src; @@ -887,6 +892,7 @@ bool QJpegHandlerPrivate::readJpegHeader(QIODevice *device) if (!setjmp(err.setjmp_buffer)) { jpeg_save_markers(&info, JPEG_COM, 0xFFFF); jpeg_save_markers(&info, JPEG_APP0 + 1, 0xFFFF); // Exif uses APP1 marker + jpeg_save_markers(&info, JPEG_APP0 + 2, 0xFFFF); // ICC uses APP2 marker (void) jpeg_read_header(&info, TRUE); @@ -919,6 +925,10 @@ bool QJpegHandlerPrivate::readJpegHeader(QIODevice *device) readTexts.append(value); } else if (marker->marker == JPEG_APP0 + 1) { exifData.append((const char*)marker->data, marker->data_length); + } else if (marker->marker == JPEG_APP0 + 2) { + if (marker->data_length > 128 + 4 + 14 && strcmp((const char *)marker->data, "ICC_PROFILE") == 0) { + iccProfile.append((const char*)marker->data + 14, marker->data_length - 14); + } } } @@ -954,6 +964,9 @@ bool QJpegHandlerPrivate::read(QImage *image) for (int i = 0; i < readTexts.size()-1; i+=2) image->setText(readTexts.at(i), readTexts.at(i+1)); + if (!iccProfile.isEmpty()) + image->setColorSpace(QColorSpace::fromIccProfile(iccProfile)); + state = ReadingEnd; return true; } @@ -962,7 +975,6 @@ bool QJpegHandlerPrivate::read(QImage *image) } return false; - } Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32_neon(quint32 *dst, const uchar *src, int len); diff --git a/tests/auto/gui/painting/painting.pro b/tests/auto/gui/painting/painting.pro index 831fffab30..26e84c1b15 100644 --- a/tests/auto/gui/painting/painting.pro +++ b/tests/auto/gui/painting/painting.pro @@ -3,6 +3,7 @@ SUBDIRS=\ qpainterpath \ qpainterpathstroker \ qcolor \ + qcolorspace \ qbrush \ qregion \ qpagelayout \ diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp index 72bad03a6a..46a2d73ece 100644 --- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp +++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp @@ -33,7 +33,7 @@ #include #include -#include +#include #include #include @@ -1632,14 +1632,13 @@ void tst_QColor::qcolorprofile_data() QTest::newRow("gamma=1.7") << qreal(1.7) << 2; QTest::newRow("gamma=2.0") << qreal(2.0) << 8; QTest::newRow("gamma=2.31") << qreal(2.31) << 33; - QTest::newRow("SRgb") << qreal(0.0) << 7; } void tst_QColor::qcolorprofile() { QFETCH(qreal, gammaC); QFETCH(int, tolerance); - QColorProfile *cp = (gammaC == 0) ? QColorProfile::fromSRgb(): QColorProfile::fromGamma(gammaC); + QColorTrcLut *cp = QColorTrcLut::fromGamma(gammaC); // Test we are accurate for most values after converting through gamma-correction. int error = 0; diff --git a/tests/auto/gui/painting/qcolorspace/qcolorspace.pro b/tests/auto/gui/painting/qcolorspace/qcolorspace.pro new file mode 100644 index 0000000000..14bd699bf7 --- /dev/null +++ b/tests/auto/gui/painting/qcolorspace/qcolorspace.pro @@ -0,0 +1,9 @@ +CONFIG += testcase +QT += testlib gui-private core-private + +TARGET = tst_qcolorspace +SOURCES += tst_qcolorspace.cpp + +RESOURCES += $$files(resources/*) + +TESTDATA += resources/* diff --git a/tests/auto/gui/painting/qcolorspace/resources/ProPhoto.jpg b/tests/auto/gui/painting/qcolorspace/resources/ProPhoto.jpg new file mode 100644 index 0000000000000000000000000000000000000000..481d35ca8ec02d94537ab16c585ccee339d8d249 GIT binary patch literal 30900 zcmeFZcU%+Q(f}NK5evN|ReB4A9+2KadRIddAe01>&_x9)(mT=w=}46hc160N^r|8q zDGDNrKI*ptEYI_L?|a|x_x<PlZ}WBLn4%>wB_&0uYM>o?)o8|2f(~nf7My=5KaPwllmN1^}2i<)ExF0?lFiO8_Q2OkVY*(7L+-Pom-j zdf*mB{2NU28%$b!Aj>yG{SVVo06qC{G!%z0fj{MM=~TbL)W5+rzroVQ#QXIj2Pz5% z$|C6b7y!!x>GS|BK@b2q2)r)?bx;GY)W8X}xQvn%L`hnP8)$b~StTijKc;m<6F{dm zj)UG&n(beKtRQmW1N%S!KC-S2c90FH3~;|i9Q zkP?>%Y>?Z_i`zvKETI7C0AO)o*#uTZhj0s!ix}__fhg93Q8*K zBLG3u34*3bh)GGv$VdT;APNESAW~W~Iv#0ta(Xiu1+NbSI5fF{l24=V5u^FwJAN5w zY#0?a6Eh1do4_eSAz=|&h@8BFqLQYTwvMizzJZ0Mm9>qnojn|Zba8bK;+?$(X-mbjA)+Gx5v57T6+)wlCR#CRo`2E6IKe z_DilQ5Df_t(0C-Yfb%79jzitmnrec^B|hf`4;?jB>o|K!ICL~N9l9caWX-YH{p5z_ zD-6Y_3VYW2k0Q#WiXRl_pYhg9NWQxZIsfu(LmgrG~D&(6-zuuIhJGQZajcpHg*W!ws>pS>(d*aszl|BF!{jd z-n(4wV{@&>VbMM0`Y@byu-oIqCBJ1)OxnltsU26vDu%ZCYUK^Sv3#E1(X6K3*K5We zuP4TY+Z=t%rxtMis%Ey69&dxnd;(awJfv$bL*0cXh~C<;xXVU4>fgm$?$9vlvV6x_z}~3xLakcXNkOsSdInXTeTU08p6ouxJ{>*tv8qE5qTo#C3W1j$ z*EfFSn6jAVlU*B^n+*#x1>YL^z(d*LCVJc;=$K-$qx4NmkW~i*dx$WXMrGWvrUinv zT1>O<2e@v+FK%RaU5Mj4|4k2CqHB@K{-FTTj(stE&# z!hH#YpXARB7bI@;VJ;6+P;!sX8)vP+*5AQ7h!!yQxf+x#4MO8h{A2-+)yATrR!^-frjM4iE(T(;lhLR)MLpQshz8@z~qsdDb ztDD^^<*xB(ml=%POXj69Z*YzA=CEMlIO86fZL}0)@$+vB%@xYbrecZgI<#~l$|Fbh;QXtW$TjN)v`DM* zQmUV@=!#B^?a1SiTb0t&m)kmwD6KjWZ~T-{&+jkVR)s=lK3N#Xu*CJp_Ybu(pgl^5 zeAP~YqMBezahnA?%t~J7t6qh)ojS%YlP`Lf5gcqW0wLyGy2>6Ejqg%>SdbcJV{L4{ z0=S{OsLrPqzWQ3W-1#L+qfaj15hC4%l-}psZcV>=O^(()m88PtO@YF&mKe_3^MKW2NJb{K%+<;NEwOQrUulF?qX%!hP})1c@p%+^lDGX^E-;~_V5*=eVQp>#Ag1A zEDE@;x}Ck&-~7^G)+(@SNL!IH*Qe)>jNPKKIBVBEbpf=~>KZ$pDA)t7P?K&?^E!{N zSY8KFZKi!{?53c3@f9noN0mWEWC0CG0dl1n-KFv_X%5RsqjBZdBpHcs31i5Bz4xto_$h2?K)haIz6tL5 zs@6rV=_nxcV72lJ?Fye%qxCE6JFR|E1Ke`T!;o7Y<1v#o@!l)un5H$DD| zdWw=S<1HwTvuW7Loedh!Wv&%o-bLK@)#6;hi?G~dmu;AXD^yaHnU__YOdjZ^a)^I@ zlc+f&+qZ_gkr6O>hI*-1{M+qiO?M^3Jg%kqyGlIO7ldGQ>Tlf~ zj$gzF`Cq-%0D&^xx9Ep$&yUsP6Qf#WroNWGS?}Ni-{A6y2+=U_CCL>Yka41UDLMjC zcB?8%Pe1)=%EunpIiAdsV)EQoFG;tQPjLFe6N@-{Tcx|VW*%(jr&=J%t8Dw!ziT4;2}!Vbsiu#6^(~3P`x9D@CZjM4Jak{_TW9 z5yzRQgWKB^D|Wnw7jj8ro(9g_sKjM=w2hSB_F1emTeZ>}TFlVEtyz9-6=#g!<9Ecm zH>mZxhZ~uIQOJA_*BIl{u6mKPn=W$=e_g|ciF_G|dtw!9OOoVce=gmzLn6?2sTRLH z<-mA_m(dw2I$Tpt-=lIY{gL~bDu0t3{xvh=XkU2GQ}5nXa~4%J)*h9PZV2yP&} zNsGR% zy=&eo{@aPyF57;n`tpTSq}RItP4WbZBLmn8d?B^|$~bvrbv1nY-bC9+NL59rbc2n{ znKH$JEkB*syDfCz7Gt^JI^DZp>vmg1o8gMz%k-u7(`T->GNMP)NyuAgK3_Mv21#8( zx%&%b=8ntY*PjML>bzgNO(~6ORcM|-J;9CI7WSg*PccmmcUdJ_UxH?R|!tTWZ7{pjYj&^bN9RTOtV&NYcQH9PLX8CahGTgr8=>VkKOv! zt$eh#e2fmJEdq917QF^itc5099DFFAk13&4pKbEqfTM0FE#LFI_V!EUa+5c+=Y@~U z_b`|3Wu6TPRA?b9PlhGh7KH4>Rs_i z+}1nvR3|vzJ6g?tgkIo8jEl~UfV{fP3d(QvQD^dy-~Cvy)@9}M#a)q)-^bbvXMXj) zMZfbN8fMq?o+$6AJD(RjZtND1IQ#hzjMW^E_1cf$6)kLpv^~=(&5#t{!&x}Y=$xeE z5=qWMXvdp>v2`W2ro9rB(_3iJrA^P1mK3m|)x0LUK;75eI@6v#-NJ`<7Z9Y^>(FQY z$mE$zvOR|1@+80QP;APrpolS8MnB`XP7cZ%5PACS$h9+2547v{24nDCJ>SEui%lic zHZ1Ts>YJ54tV5_%7RR$4m+xtHc?6qBmca__W34-ezM_uHCN)ovd>L+zyLMaY%tbSs z^`%KP?qvf*#?_$F%xKF;j9r|plU6Tm%WkHMz7Dd2gh#MeE1r-ZP%I6}nmJFs;>-Sg zDPCDLqgqavxZ3rck?LTVdxm8;*`t%`NRzH5_*kVcti{V9sQCt8cugR08`ZgBCg_@` zb@IZsf(|6d(mfRjgfd?_q3Vt04nwv<-pkQtGzH_}>Nlp~@^%GouJmyhIc#TINxkCf zrphumf95B0)MYhF<5tJ7%r*J&NBQ5VMr?~c7YWT*cl_|?3#4E?@=;sg%ZcTUyF9FX z!A*{sV_lx$h^srNYUOV9?vYx8-xz&04tz^1%r~AuoyIxD8$)&lv{Pwt^{cd9>J0M& zTLOF56;SRN_)11;uR9z2s^@V{Q@1C+)-N`-g0EkquJkVl%dy8S@8Z&`!b*9xSw2c_ zgd)C4eBf;SaxyQn>FvC>S1!)hyzCkeXXQwI8GVZWW1X~`vwT-N%t;tlT=*8DLYTWD zq7W{pqa0~X5|eU{HtOhCl8^!0R=V?J>&6ee3>IpdlyAL#A$$2))4;1ZgZ7s#1(%Y> zjum_doupVZGsLd_B_IY1tu&`Q-EVa=sMa9A)q1yj;e)O?q)1p##)yK$r8p>x#l7iP z-a=cUO5o+s7V4E5yVG;C$ed6^Sc#w8>Nl@xq;7XpNT2YO_Ssu4F})p@adL_k@)m+Q z+u2!bR_V#a`SR?EE~6FRQ-JHj|uFw5I-kB;{r9^VCaIChgTa-vYiAkKa_P zPlL9nTZGHXHyyPq-Gj4hBTq`#2lkY2Slc-)RU<+*;>MHZPkr4Oxb0&cT&k~c>Nz~$ zm|@Y~fu5c!E@OE%RGRm6y7Yr)2Zl!6PPEw2$D}`VwZtEu-A0xxjrHlUX?=hth|?dy6N^JxkTMa8r@VR66SD^I@Kl#C4BR^j6!FV4vvm9-a9s_ERA*U)S9p z3weArv_l&soq*&XqmRioel2g}YRAwD^*DLvJo=bOcP{CRywS{U*`Yd)F@||Blk5+& zw*J(EIwzev9oSkIuFBu}AUKwV*Zdb;iEQ^ozT+U&LslXa*^0)I}>9A%# zr%L9hBVLr}ODD^HwNL1XlTNz(edlW@MaEpx+14!*vnnf_n~xlWde{dTq+2A{Hia|Z zNrMRM$aMx(fjKijKt`J51s?T=QB;HHjSUrclgKFq$4Xh)hWwIEX^lN`7d2Z~&p>ku zx~nzXm-uc}L~dzrK!&!vSXR1yhXv{)wG;W-BKL}|$!z1SbD3!~J1Hv~I#U$IJnkIT zf1EE0zRCaM@xbDOdR*>^zqdZmm(r?fO0a>D5SHuw%Vq zU^OSZe~DgwVHqEJQ;ofxiWRFk$uZ`b7|07n?9-S=iMB$Q<{P*4{1T2rA=a7eCNgHK zsba(4s`i7!_=x7)HrH}(JgpcdTyVNmQ(c;ckNEZY(@j;IT+Q0zv~;vhIGMPPk&6X)hjfiI3W`%-#6bf!G=d>3b=qTK0 z-y&YfxQ^YUcj8rcrm#5cUmihsWzA7IxIfP*JqMa^*nF$4E<@LjKkJ&>z4I|qtCq#@ zB4);T16c$!C$3)Ugc`f92uL=8##5z3O+VK?!c_bBc%H(@T&VA${5k?<2p*>k7pT;& zcw@qLPP6X=rxK^s5#_eO#-WZ9pqh&zs%|YRZbMp%GertDWu4@P_w=`DDT_FciOLw= zxmVYm!eVEjCuKDbp{-BG-Aw`CNK>JS3naN`A>LG3%*EMuKVsSTu_vp-Tif?28|gZB zoQ97n7EwAjO)D_JK4FY!W4zs4EJfb7vhyV}O{B9U(bIb7q{qCJNQ)vYz7@mkIk z#3rJNDL9~m4eBl4sJkYTP-e|>1bwfPXEfU!<+a(;6}NknT*k5lkJmp{qj)OdT1zXPZlE%N#Z;G z)NmFnzFPNJB-&PvLyB8C{AfYjGsggARVeo9+KLDGi(%4bXU(%YA?_}Tr9>5LFjDJD zZ<(045sa+w@hTspKl;vW-6=0?_U1TG@4$vT&L>#SCDs~>j`KPC^td)_Ri9y2%B!!2 zJ3H0xD>YF{FBd11=lX^cXpef=cMmDLK%NIA=$EwdcYgY8qoDpwk+FyLnQ-&u+HHxV z5>!2V&ZjAJn+VQ+w^tXmldGp*88_%zMIO1e)LJX-pCZ%JjQXPM{(jNkx*odnJa$Yc zbZj|;IOXzyi6L8QN+17PYHqHjgW}C=p&jsxWtukDN*)X;y^G@mF>V=RZ5G4ON+oab zQwq{8OD~S%PZW_X5SNWfxUx>bhTX`8A${JJt`za+Q#rDtew&}>OO&73_$_rgOG$)? zrnKG75H_`v?MCEn!&r{;wNT$cWPf-!xDb&DzPq>3_g5nSD;VLVYNr;tiEPhoVYaCoUv@7bG#kn+(?g}#&+Zjl7`rQ*wu5%o@lKo<2`l;ubvX1R#a{X1ik(mLv?7{91 zuhm_7`?x|;+iV>bA4~jowl|-@i6YHQp7HN8ZYr6imVI*7o1|V^h`R>Wuew)ZsNU9E z$#F4fHn@A@JIJjy!V>)ul6nb+K)+JHyRLOYn_OZkCY4|%2!!H^xr-@rsNBiPq%SVdp zN|_4vZ=(H`@PpkfG_H`5)f3|GAxK%s5WOCiUH3k8PBu}pWyrY z+J?S8`wIM{yUe$V!kE=~N?GSO-RXZRLo28x1QP^4EIvp_%ow}UgT<$N=f9Mn{_0kk zTW(>n%Qy9`weR@xnNKmZ{0@w2_q$5`>|LW|pHUWHV^%NCyl~%*bt(FMXXz_VX=MCPh>Hcz;Z3VC3 zItnAR6%pFY9Mr~|2yfzhiwhg+_QY;D$K@d^f|BhtW&^*(NDNLhm|1Y*={Eh&GLKfV zLF=DbTS8CQ)XzJ%$kjN*lb}Z#YzlN53rEbltkWFYmaet5$hXvTD2k_!%(Y#2!obD& zNfKJ!g=%$5>^xl;aJ@z;MA<{JrpL$_%o9q6VuG{%vfX(oNFaAS=yVhdW5xunQtVHD zp9G#DpA>b&N9C85epuC4w z_4oIe@RyOmU|l7p6%`dFrNEM4usA>=jtfNNVFBW39N!NPT1Xrmi}J>!FlcT9N0>9l z7Z2qH%HOXTfPrfV011bz3HSSqad?EJK5!!o2m%mDf~BMs#HGOEU`0aR4}|jaHa7m5 z^N;%T^7=`Q!)yEfD(8>XILkn9q@+0#hw;V2k=lMpG@kEAVK}@w@|OnwgX{qL&&=MQ zzPR5j>Wf1XlJ*7lM7T%-GVV9`kHQF#>3`A_wC#%W^4_N=Q2wBT`2x-QC+k51?!Y^Bc!@Q7Km^c>ZFOEav@hG$_?r)Vrz<-wF?Thu?uLc4xiS$Hz0SY3} zO8+dx+YN)q;M_3YKePNzQ$NvvD*%w`&*VS6fFLl?)Jj?yxG$kheJv<2kRpLVA(Z5t zA@a`B5Tv*>9O)u1i%^sihe;t7#T8|oT@Z>=5C}wC>PLQkG!73#!;wGoqk#M}a9OYv zOi@8x0S1u~msNzwiz~<>A>v3mX(>e+gp{1TG~`EqQ!EPbL73<7_0ZJTkdcK6OfbxRj zkvf2ea9XGXF##$mDM@LmLo$6Ym@Cr6*UK4+1uzP7(lQ6xjgV--GXCc?`CnLqzNBU4 ze@j5SU48)mHxwTEQ+{a~Ss7Uc1%hk@0u4_fNaBF^8^AyF zXn6V}^?Z?kySISheX%e?Ec%(Oxo`bvuoxGVCqS%D2*KPyBcKs5EaHH4F8E7^#azBGKwz7+*9H_702v8xGKp z9tz4U_b+fpKoiUU19!$3>+OmB7fcV3hg{|Vm=iz}*b?lSpeQY*8!YHo6KMx{V{pD$ zV7vqJ(R1PCvf8bZb?8X z>IipV9G(z+)O~zmKh^m+48h?3jM=Z+pHaquPXb-$pOL0m7|@P?#vLg8&p5y&|BSFh zdU|5~f8q$9Zwy2G0uc=e8Nh2_fMfilZ3!fY&Y_KlITK9nuN^e`@p(B>&LsA1MBz-9J$LuH!$T|EcL8 zia2m`z&(HJ@eB+LgdjW?1=oUMJpkW7)bFqKpJr(RgiFAeifX2B7b3kmkUur7{KCz zSolNGUs!Vt9*F$_hS0SU0>qhLIE#Zox8I%p17+n6bj)tQqTFw}fDQwX0&@N;4THlI z;(;~F6%B-df5tMv*5N<|{@KsSNdVm*p*Wzue~&i6?H^*zzfJlVKJY8gFM_{0!Ji2J z?gf9M_@^8EiRK@E@F$XgIKrPue)ohw;s4^N0Bz zCTk;Hk;X8b$M24Gh%$#EP=wL8C@_CIXu5sGLBINw4Z)KvF=!ya2F#NXp?(_3zP%ry zemdUoE&nI{FR}l`1}Go!qkqBU0Qm<7mPjveU>F1pSb)08D*osT4-_XV4L*t9XBwf{h#PF)`z|N zzhi$u^dHpqfbc)5@d4$5jsCl$|1E_v%-aHwMWS8tZa*9NXNXXgfJjImD8m}%40PGQ z8PmUrGW%oMpN6N7o-?7g_&Ca4?8jsaxfVgxVRi#K~@}iTUkn6K~WYi4nYDFV?|jh8F?3Aih95qhjGFC z!>~wo!jSaGROrl)89n#GOo`hZ=Fh!v^4vnkFgOs#f%(4h4;KDzNW$b)O8Pg$kc9wS z3=R#0(2|5zp#LEv0+=lRCZzYlpa|&wp}cU+{&WY4;C8`cytohC09a!}d0^1uXrv1_ z9&?yT@C`BUeQgmE(MW%8&qJHy{g);G3+4Wh=ub-h&(<9NBc<*S&afCjE;&LN`A>EF zyR-d&DH&Ww9xN{>3l>Kp6cxo~;YeA+x{9p099UivB88Naad81c-5({>1(vAxx0Y}V z?XPM4!zM(fz=X)K@5%%VI52m@$``P(^UD(s?zIlAL5I-Z`wMSMh~Jie{`V!9gFJs~ zy8qN4fYm!CV5s_kU+y6YNLbrb+Fx$5@ZDeH!2a^_eFglH;8)^)0L1+3Ouz8^c{DNJ zf%^ksQ-3t_kGcK_#eO~`6dahb{kfdqa6lIXCv-5s6aI8#)n7Y?R3r~P8^G;Dhb{cK z?E8q{mV|%M0_)5K@aM9%D))bn|7zgB8u+gU{;PriYT&;b`2U{)h^1zfxK@`|4EyV$BW+euZauBP4j!4VMfPvX8;qrZsjo^*c~HmI|YG;MG5#{>HiT#1NX+_fjyoK0JR3H1%ZB!G`WS~!ra=xqbn~Mn%fYAfO!Bf8F+ca(1BvygqH@y zxM7~2-21~;95)t;Ljr492no=EECf!Vqrh71esgmJ3f@lvevW@(xL;|!xgb!p z>fh5S_xCIV?JfSBjO2v2H#}qvq5y<51et=gKAOoh3*f0Q5uRLC5J1i1hw7C6x$IPl92RM8jEy!ZYu zH^>-BLx51gofm*3+~EOg6hJEk|%n~=n`tm+Wz)?`2Y03@deX?&H0)!F`Kf@64XuTN?gYS z)3arU`t~*1(54##@!L_a8E?8M+f~+md94ez4!XV&`1W+__T4+d)(_N&MDHX3yGc7>&Of9)C728Uu@BTJqe_fUQx-=Riz4K~Csjx|5FW3jth z2yL1j^)j>Gbhmo)VLjqzbx^~J{@{cJ52Ids+^H8GulxsA=A$~Iv=U05l~rz+ele7* zExH}uzg6|*Vbe9s$sIlR_$!zvL@j1{g-qkgqke{3@9ad}sr{9OlkSQP+kbXbK5Lsc zcugLAB;IGHq^Okq(edZTu8Zv8jy$dL>WH%B&~WOml?Ir$^&`cCq29(R zrYQrO-r?AhM9A%JbWwOU1$~nd2hH=VG_d8Wz(d^N`{{vY_EP{E&hV4V)-+>;^z|3XhrJ!NTAK@ z^n`*EgaD%Cajs$U*({3Fs}NU@zCae(^EaG!rB8MQJfvAaD9}3g*#~}Bz?8ickyvPl zGW)M&AoBvccb-zM+Lv_GTz^u$x+KF_Lm&1r zQ{Ec3fbQ5$(ZwBq>~?13$w=HxlYzmS*qw;Dx6A8XHsi}vieslSgMMkUxn_gml{fCC z1?p1$1mB4X zydN48^4_#?`L;gdOJ?yn`dHD@*=PQRIf{vaK{r1eSP9WYS38bVCsj`eIq({dAFW1_e_J$%SQ6+&X+ke>HE9S^!3}lMSOY|oI9N=TOV~c^=gKQ;T+#Z zSc1fW;>y-ab6!XJZe3LaF}&Br$|BSJgOc72=_I=>X?z8&>70XN!uFGGgP`!p?b!s= z9Fp|>6ROX9ckBZz7e~&rJoa!-CU=UqZaywIl&~msZ&40Ry8ANJFkGQXzKyQoP5Eqs8=KOphdgY8{u(Hgs8=VTX^4aQ#n{CfKZB80T zCDbMi*4C7rS^?g%86b<>3*r}JT9O4KB=v*_=M5=`=Gw@Q^X0{pO>4;e~qL zD+^aqj~_NLrv<&g73l-+x^wdQIng^ZD>JA-H9?Erpay> z^_>@ZW=EHl1u651Oj_Q2;Y1rD;sN;l8!rigfr=LZA*0wsVaA|n>% zy>BS7Wva~A$XnV+$=!c!zK5tbqu1za3`Z*6UR>VLo@d^asC(d^_#W6x|BJs)b92sw zwvW!#Zg5X6&+VQ~aFZ7+?H%eEEQ8!%_P0zbjf}D{o#aWKKzHJKL$n=X#PpcK%#Q!X5ooBmENo#lFd$UjHHg>BR7DrFDVsj2D3)#fx_Nzl~Oy zf;j{pyW7^6Q%K}#hIrlU@WL9cJ}_B*;bXe~w6#VwhQ}oTgJ45VnLxy2#!34)M)FV_ zfgpt#=?q)O*dO?$7jbke?FH+~eV`iH6i(z$8 z?=)t|h27$S0%eJg?H+yVY=K8C0g@BdUdkTR*}PM8CR^V@x?0g=-v+O)ROrf$E~<7hZ;fk;^<59mXOT0+iS?d$PMqHl=JM1CAVx zN3l70$7Hqj*k|dzO^h{7NVFJ~(xn9_EAJ&BbQ}3^S=n#Q2W)+)S+1tP-jFPdAjC!??iSj5*IDQGemY<7rLr=BjPO! zSQV`(qb~EoTPaj8{U}ex`rlCH7=$& zOHo8a*Ep9$MDAvg$8dXQleLOXMRugBW5(G*>zgXijt1d!V*j+X)j(!^wZFY89&T3rBkFIyJG0cmj&(J%uT&bH#{C6BNTCM6+ATeM%3n0 zI7#iUB2{Fcq69~7R>z6hNa5Blm$O=%@#d=fK&u$~u=sE%CVK~TJX=kZ{LJ|sRAP9F z@;EBTQ!LZQzUr*qUl=2LovlRXkBc<%l6?W=_~xGXTtTVrbw8E7{{$UHP$#{z5y0Uw1OA@)*0$?lCvb3O}vqQ=pJcx~raRr_`Z2VXR+VmBw2=#$kcB&+D#))yKo1p>8V6_y(o6O^DT zuf@zXtk;w}leDRcdik4N>bCfHzFcx&t}vq+7wx+m!OM&z85 ztW;^)2^`mx_@+8%^7?jc1k&@)+=Dt^NHU)4Upym6rIs2d-FzjAUhjrK+7QgVz3L8r-3SEK&_BiT2DJ9X6K>A81i-%xc!CQ}1reJ#n9q(7C5( zw}-%Gx~Ff*sf?P@D?V<@wy>z_r9qwv!_ezG71zqDa0zo*T2n^GHjvw!SRA>-pxYdk znl&$ZG*It`*@WvkzIuaO4M*Mh1Y#54dd)}IUn@~~5K1E2deubv;`Q^U30cfCjKF}JO8ZAd7qP??95f*m z93v8P`mHdUWh^NgV-3mihw1Q z6WhLYvU=u-)91U|paz<3Z=x>&-HHe>7Xc37!%?Kb2aEO(!snN0fsaO! zouKFDRcDX_o5{d@PVaXtK-Z&2^qIlWCcfUbD&32X?`)4nL2b#U*KvOE`Sl2Ujw3$J zh9@fGnQaCUvR`-H&NU^*Z3gM66?RDU-8;p$axwGcTdNB(b+ptepOtp!8&0Lkx((J& z)^g$AMXfgT2O&?=t^4y#HpG1FspGN zW;ZujGLMZFwOYHf40mBrQA@1U&{WJ%6f=06cjF0F}k1<|NEB|%M zj$yL3*z5O*#eFBtrv$1R1R_nbTv2KMWbk@}U8QNfc zM^?b4L7~-^@J0<+KI(z)9$xdwdP#V#E6LE()OwJrj+5Ypofs)guE})qF1>b>Vuzc7 z0txvkae_4wn$>>7OoqwdL8N zBM~xm4$+oo)xkcp&l0R9cPwHlb>T6XqJ*TL9gmP}x}G~LTcKX@b%uyI6sG7=Dlcd5 zu~XmLM<4X<%pqFAIe|wS`E(hapT3%X8Es&G?XyDj1yiSl`?0i%qZg<6;g^z9hrqOs zY`hnZaw8mRD(~C9U3s#z=cqfFvTYT$^+`1O`C`!r${G_=*S`9`)E=^gZ3ROY0e8x@q;;(Y9h_vn-d-QPFejki z17UQDSn{1w)D|m~XYBmsd%2Eg@qAYKnh0GN9ezQs!Lw|aZyMFK7Ti2W&u92oKAZNQ zbT#wx_9{nK(8M^CjapZ;c;CaUq|dAdGZgF5x@LN3c;yR>nfuqaXQFL+!f<2NweTef)Ps?+S(}U76hV9^bzFL716gDv|2jBNO zSh`*TZ*obj@v7OR;=5?&#N?iow$?30h2y6@E3y2IqHLUDUP%ja!RHq0MYQUI#lz_~ z@~OA^<5@kI2kU*tJ>zn=O?tFLimIFKgguNVwP)_@lLE zHHft+#jm;3%ADF`Y1y*pGW4`q>1(;TYx`HAaABADH!{kL`o#}kUrj5XUu2rI`pVRE z%Hgj#tJb45anJa>?|~)Vk|`#;%_kk3cQllA%T1$`C1R%exVlc+>GI5`JQZI7hEb73O-;`M?Z}X0ZJTNlb{4kFJo*J?ipgQOGqpb&NOE(f?eA zQ5OAl=o25dXQ#>~^sQUf^j)~(S?M4aYkB?=zkb$~ke)|Cu8AN$ z@$|{G^|+8&8zv8dr=PC2Q;09g`Y^~jKyL^U&?i&jb!=@6-Dy3%&|JBP^C`ZWoolX5 z&N?(Ke>p}QrH5BZpgmuQ3CH7g6kf3KM`wZglzGJxmx0id@i6?DD9K}v?)y447&+q% zce))b{DMs&*Vy=rgk)B|A&2zI@{#hB>)HzjP42qA;oD%J$wIdj8S!k<1e(;*@?gHj z^BoJ7$n2|4&#$SuKC(xYu-&7k&3BFi!VNa6{>)o}=JP`@-#N(hSVmigH9xOHvW2R| z(?y3(BzkfsrY!`rd>KM z!;iJNA5>90(k}&uB1$g*V0S7-;*1+qqgpL zschcYPLKxZPr;uuzh?Gy#eh>()%9YOCKK4hP+FBjV?GH^fbdM zr8~ivGshT77e#lwzGuXNgHc8G$uL6u2i`By(KBV+v?|$?LsGBOm+NBT|EX|)jL32$<7va*U@}EKfcPIg?DO%SsT-k)w3|<&Y!iO+RoN1 z9?5DMJhk`rY7m=1ma0&Lw$hwX{{!udauym}wp#f5@P6>;?5}Fw(I|oATIe)rwv)M= zuTDssjuhYd1;i-0{A1%?r|1tWMW(!Wg6FI$0ZeCm1&67uGIhIXPFJy3(a{ zJayO32yrQz>@yE(Grm*9Kq!M%Tm=z$l+LiQP2t37V+^|9D51LJb-G;-V!@r?su3~q zN;AxJk&EBl)XNxcwi0yY)U%VXmon@)1?g_T>;0_D+cO*YMUgVMxu@DryOw6CYcb1; zgKy9;bs@tbCFYU)BYeH}?I|g-W?HS%?;tJg__yr1PT}+yawwj0m%=7iyxaIz>eZ`H zV?Ca!#96{ToV36jh${UY0h zO#5nV+Mp?U6I#$zB!Hna?!KL%!)d;nv^^1k*s#BfcPL%olJ!pL<+bIEKDK4=>iVka zb^c#!ops-$Zq(I7Ov={dADFLkg=CXEH6kt)-%*JYYL}MXMnk`-X|1=5*&%OVsx!KN zHd>xfzx>mDq(%7^;HzbV7mYG`n}NtA3oHr%pZp{vAts?DeEJkv3MPDXl1KUk9VtDp zx*0bZ#^)n-T7!XK#ym7ExqysO^KgNHT#a~V5eXcw+gWzNVKXk$ac-O4;j2MwN}>rN zX)Gl0FVz^tUo{y$&}*Y7Hs6qE{?++8qsa7Yni$39TKY*%=L^*f4nlFAYT#~?zKkg> zoXA(U@kY?qch`AogvngD#D*@>BMQuKG}K#@-AQw3y`aQKBRi?vzI4>@+rx!@f3N|`{iu+- zF_Wcnoe7duX<0OE10LBt5)N;Tk8*1ae{*SDJ)OV1ORyzOr8>h|DzK@d_ zf@nTcRi~>a_j2tnA}K7uZz+B58h?t4y}&zmn;L15u$!d`o9a9w7~@O%Ds8Db)1T?> z*o87n+;`B`*vk8Z=Mz3g%JMZ=6|(!0wQ}6_u~CBQyD|S)OSD6*s%gAUjFlhE`3AA?dmywwqyD*cN8mLWc;W*#QrXN zy>{|K8dC9P{J@I)8(exck51O`MmUGei{sZ}6S`eq>~^o$?MRy!CRcPmw{$WqE^Rv5>x`Ti4rpD!SNKL*XzOyJ z*R02=uP-reL^^S7(R!?L#tXUJ8=-?!k4wAvurzVJ8oeaFTSssPO13pc5$Sx?_Ey)a zp7{unuVPzNyaL)Et5NqYaGzmg)xJ>OMa29hr4Cy%_Q^)`;q!-)duLaN$o>*VlIOp% z(eJdRK}n}wl&yYZQMhR=db{9OVzl-Gm-SJTZktl7($}K1H@9zmG%g)RwvC(kf6_|d znQ+?99Fk6BVU~KeP-CnnKekpT%4F+g=g^(fVpgd4ma@@8?7dJ}f$8N6?VjOp528xG zsK<`f7+H|K249yTYgD+%dh7G3#F1y)5$E7-RWFXA9+y}|Reg3eT+UJNUp?u3*?#d!Wjb-ZV z3F%w`rQVIU^4Fj}BdBo|4E^-^B*8@-YirwA6HvJqpSjxmo(T1gQX-7HrzCQ`5j`z| zEq@-QUVm(iaWI^k(hKE3iL0n}c&9KUN3{S_afOYeo6 z6rcJG!}G<_5Xl?w^%vBGFEI2k0YjhR49+wI9!4*x8>P?6v>$X-zKbGj_g)XqQ>y%E z87ms1k*JN?gPpMcbPSr}}*A&N#Ug+WSK_jUbQLFUxi!DD+f zRwnAF;_#`9I+qKH(>5MD_f{K1MyV!uO)KU@O6fB{YSSSf(G8>f(w@6p=8&}{T(WIv z%N`qAp`^7)H;ddE?pKQUt@gD@8y|_=ICnuoP%?XchAD8DTh z)*|_>#$j-@Ga1(w(oMqFEH+L@{rHnJk#=yatIInYB`QWLOOaB2im}+d2@M&3%bZ8q zss`yaT&rdcrySXSPNs-<7sVA#nf%Eb5+Nw-?5ZuDI|K(PU_s`_BcMto-}tN z+oLiRK62tUzh2HelU%wC49y)XrGV=?piqj}mtE4{*1oQdBq!>1ak<`yJ5D|FB$P4D zeWX>@_8p7`b5;aYx5-;l$2R)(MTg_f6O+%>J$r+#ry#wa-%=vC5=HlN&O&APM$FXe zzIHO|>~YO@?c9#3JMuYy6P*A51Zx?T=48>Ia_b~)h!Vu9RilNO*pMjn@TidY>!uY&i5B52*b&9BpRbu&;b4dzR6fPocXf0E=EGKHJqoQKm z$ZiCYPScpQ+z4kPRS`18Oc7jX zvR8|VgZ+jftaOHD6P6Z;4pR7yYGf+lrBU3vt(EzP7J%xv23d}FMa?lQTbHy^Dy_jl z;$+g-a0L&fOs|V9v<+7<8r{Y17wrJnWMVBNYluV3F|=jrSqI@z#OrCLmcU! zRIu3E?hQ{HMy>dJlno`Htd|XxHz@SfL{o8<%fPXOu^xoDjqW)yj7w#Dhf8CGuP2N) zuG*dd0MtvE8e@e$m}%`D%MaX3JkC<0O%>cRSx83g;v0R%!zxHQsseR|;xB^88+8va zeHE5bw^5-X&Y^5MX=Kcdu{NIsb+0e*oJ3+f!w5ff5BEJoni8-0O_or8Nm0Z@6(@Bm zWZu#%n2J)UYCSLptwi>&5Wl7pp$a}w+2w$S!}Lht>kOn&t(mYJmkV9-2nFqTEm$4I z+njfMX!W{*SZt2NFAFGyNEx|c=$gw0j|&b?66=ja)V3=S3y9F6PyGGmT-Tf=?t0b8J0y9MzPm@|Ijo(<9MiVbtmQVEbjO zqdOzf5M_M`q6URxQw(X7GYvGu4OrX&`q+n-Stdi|ByF;;a4TdH5GsiGU3P|C+$RJU z?M&7XgeMU(cV;F?=PiI&6Ck55(u0^=Gt4mPLsXNyevxY%f_P2;A+oDqY zV0HIEU>R}LV4j+maOZPU1n~sZhrFQv@rv z1Q%C7|Jncy0|5X600RI301%HplWpE$=iek>P4E@2s{=+wX$c>%rG{nmw;~&z0tH^f zVXUzrgYPY&?_A`TV3x7wOYaDYYkr0T|EWQvA=+_)5QEGR0oBLVzOf8-UOgijoXJg` zh-6+odvZvL(zZ4CP2DBF-`NU!ZAx70avNS#fxm?R0P0~>2$scKOj?6!Up9jvS zeOez8@CBy>mtqCR!*Ah}t9u0YBFP2K)E~fn1REqY)c7DmKJX~Ua>I6D`LQR6sC)%U zxxTxQ84j%ZBj12HemKvMhZ+1|P8(bAT%GtY!2{dsI@s?efH1*4j|sl+0n01`$RBP0 z03;KVPECFm9TpR4DDA>;ABE~h@T+iL*g}Df8%L%bIdy@P~fI93>o+fNMlQj@C zBUay%#D`ae2M3Y4G%>o5!~yW+x0cj1knj4qlM)h-wpOw@*!n@F;GO)DwHPrG0AYPA zZNo{!;Tw(pA`gH%S%@|S1d+I%J)eTukogV~iVwi}z`69;P5nk%c>>3YOWsWcLDnDU zx46bUoY(qWk~c}0GRUE3Pwi!vT_=Q*rM+GV!x#|^PGdhTc=Yzizu2*SU1Hy7)^QT2 zeix+hYjavtd2B8|{!uV{{?6H&&B*koJBu zYBK2sFJKyCbz_770J3;_dXPN!SB>@?+^<`Gdh?dQai9s%lr=6`H2l}L*!UaSa>Pc!7sT1>eotcEdH(>P z+!^thpHKL<2M@_)JpTYT{-e>Fy2p|~ZZ_O@&tM9|ISN4=j6M$5$I{yH01SBB!C$B%Wn#@1!F<5{MEsz4n;ke7KhDo==yydPl$N|4m_=edtV6;=V z^iDF@vYt)oYzGC4c@6&n@^qY6Sk6bLeZw|h7SXk~_{MbnNaJ(9e$4tTjKzcX>3%x> z%nsgH)w4c7-p>C3&EqV|AFD3A52Sykg!Xx*oHGnh>FmlkUT@?tt1JQ^7Lqb_kAsVM z!T|Ixb3J~r5zHl=pFIqIm$4}&+3X`eKmWu49}xio0RaI40RaI40RaF2000315g{=U zK~Z5Kk)i+E00;pB0RcY{J}hEGVOe5aD^R2EVQH4n;{9eg`PleIrHlr^AW78XKiU5P zme5YqkZ&wzf|9KR)zZA%TCbNIJ6lbN=W>nP4i{-uBn*uFde0N74YkQ*kOeiqp_ zVt0RjZw-g*eo%phu(2j`=6mqxQI1)G25j;@2GPFRgOUP;DP>^pyL*!&>Ov_kCNmx3i5 z1;TR2FJ@keA_=fIPoEqgi+nE4f{p1lZHt1O*tv+j2Tbu**w+AQkTYEbr0< zIS0hN9G9e#k0BlQR}RUyg`w8`7w{(CkioMCLb}L0MdHp$xU{fgvv2c0T=vnYk>r+Q z_CX)BfS;C(a@_2O7Ll0(cfLc>1EGEtqy&^P`x_0qTao$2+xO$795&SB9Uttn$m-k7 z@9l!r5qWm95&YRXpHQ1;_(*X3J}b`8hVwNtT{h01$NFq{Q!?w~F3~p+C^^5v5*7kE**McKci^+b2`SyxH@oW$zY?Z8R>$VC4DNk1(;VaRF~ z8i$r+mk93dvwNO5n0b2mBZJ%Cc-Xk*jH3<*l3n(1cVUN2vLPM3KZd^}-r9IJANL*) z{o4fymTuQc(n-!3-9JfVZngv+xNN^ku@&l+0d0-gw%H;2yJxV3=(LU%A$TyJ>?h@g z|HJ?!5CH%K00II700RL50RR910096IAu&NwVR3@G?nghf!g?j ztjBv5^Olt^6277ht7D@T{84I|Z}-SASE2rfP%ih-o7INX_N;Of|gP0X+ zu?r{Md=9%{1-s^5+4+RGkp@{sgv3gFgoEZYE=DSxUYV#woW-8~#9rvDN`1>6Zlh1` zCdW)guNYlC!Unq|zlw9ION1K;Du{ltZ-fP!!`6e>UZ)t!itbs%u6vjBzUI8KO}vo} zb=AcbFA(i%^&YOym_ccL_?knKhhH!Y;=Okr5uRYF7S9l{IP*T34bO-iLzzXvFR5>& zH1P+=i2AJ_Q>fsq3L0D=QT?z03h|xHL;<;8rTlHEFU00pQ>yP{rVCL|vQw0m)yIO9 z)e`6|;^8ies2fvt)TIKO%7;huEEG}k8#T|k*-MRoaTf(ZmG>%Hz(DQ@;DzYC@e5y5 zcO{GaH;UEb8oPWTbOjzE(Y;iD!1g?!{D9;%Qr=i$AY3E$2UFV=x4O*RT#;7 z{2;0nIb5Gox9aX0iM>w8&r!b$=6Bn^WkV>uVVF;u$0~Z3E#@{8(0XON2#a>Og4^D$ zMER9mGz4;ceUTokVvo7bXrG^Oep97HR|5rSo5=RH;sSYUe27jbpMZAV1hSyRfaOxu z7E&5%mFwpmteb!G)m>1Og>=JtodcbX*r6xsE(yk_K_SY4B*JJUD~3)qf%!! z{{XQpg_mu|my)d;9EKHH?ls)9H326I96sRp<3#>bHytXDJaaSEvA+0A+ULX@6q3a? zTp^|h1h>TrutkF1lGSgPA6|?W*p%1FS2%=H30pr#9dRsFy+%wY6SlYS?$q z%f=Wb?OV)DuxtMgvTjj|5;l)##?of1;NUtSa~=h>5NtZXQUU zE^*h=z!2pk==5UI$Hjl1qv?_%UZ@Q>*NXms}CskwWc4t*?=&%-<^a371VjkPl167)q{gexo20 zp#;25_4O@pQ2LFEe6TQb=OsPF)1*t7h_b|N-O}njAf_=u83Ax(U*deOj~tu~u0 zRW(oAtXl%DjrGJX88r`3f>o=WIYrYuptdB3$1Zq9uLM!Dq;0Z@aFJ)S60(yCP(L4V zGeLe)+LYtsI4eXyVH&}z$2T#z=4XM$cA zfl2=W$d0qGAyCycuM^5B74BM@D;;&Q*dj`LUzmdKVR97(F`~=r1FAxm<+de;n>8L~ zt0KM~MHx#KBN}Z#ZVeoubk3Im@JjxpN0rMHR0Zzm^*VyL)KyAr>2V$(sY-CiAgBVh zej)Z1@xLhX0J`K`13`1K1I#aSt$B%q7lKhHIEbluY5-`k-p5egfpWzST&#*^-ifxh zDX777(s_WnBHum{7QDyw^AWrvc!frYoX29k))OTc`5=)I1-_0JFT(j!P)QfTe+&Vs zd2GpbN{AODaEDd>pmj=%9m{d%v+f;(r2dR4c7-4-tcPXTj4Q+3HuhoLbD9WAvFa$z z%asdtw%jGV!_VcGbGTFG>H(uvnnS+Hqv|1v za-L%SKzaqBM72XrenlX>c^K-Uz<=0MHZc~>YU|F!v(ZWdFwhm-^vmM~a97MS9tF^S z^BY0v9mhT%5(j3E3?(t=z9BnAwPbSI=@>^nwLQk&u^;?VAf>5QKAM8)LgKFcZ@Bt` z)x1Dust++iG>G&I(nJ*HSL9n@s&N{#&jhhr7A&E%F}WenPz_e7f8^F9csVk`0T>v( zjL+sDpu^#dbWPVrb0Ew4K@K0=D_RtfiK#Jxda;VSD}@X#8l&amsJBrh6K>QCExkSn z+T+Z!r6!&FwlmNs2h|NBX7opN)H33fhy8|%w;S;t%jC+)vH>ny8Uk$zrTjy~Q-`)V z3jnp3rYsx9uJH0)M{7{WmOBDfCZ93ln_Q*c#|RCxs&fIn6`^ruWdr7+fIW$9R@vsK zTM0Q30->|N${zhhJ41mV(zdSPMvo4bF``Ml?rB&W9F$VBMwDAwS1ikUdbRzfI|p5CL&Zhv4NPSOtcWr`OyPcacwJxEAw zXfD{SEzsbL%mY)*wJU*TmjvQD9ws-2Z@|?>8W}+XqEFR%oYaD z=#(5?Q+6YQ0X}k8)Gq%3B@_U+)U?~!4u`H)TL9*x?7tvwR_=8Iu8B*4&Vxc%RAxU> zrG$|}VKr~RQqsPXpzLE^QQTV4DQEW;f&f#*zLMJE`y7p*O5nS%Ff~hL1_L=;y2N_4 zAB571&2JHAEhYC62Aw5P(gYayoH%~sIF-W#m~|)yj!=$xu(8Y)Fb18QxO0{ zi)PeA!e}~`ynx<;%mOx(PMK2o)l2s&^ZbRo(WO9!{4sglSFYE)L{&X60r$S4jSa(g{Yz|FQ|vsfp&A$4kB&J1!eK#ZViwT0AOJ!43xFWE@vsmA zU-J%%fN1dyw1l-$;#BaBz;h8ltpK^kOhyY+-_|$=?#fGl-D`SkFJb)`^8R7fgxfg& zetC;~meTo%0N5y1#)3N($x(_|9COX9uzvS%s1oq4Dae)@4f5{n5iL1R&1Ff(^5Kjv zZU8$vFzM2Tcw^9uBMffttB-NyvmMo;YS-}(iD9ZK5VobpQM3@g2gxX^#**_sAOcjV zH$pNSkWF`Y>Rs(X#wNeE_8WC?93CRTTGn$C6evvyn))6aer^z7&SV-Kjlg-@A|+c_ z9^nP;JeA#h`GOZ#$y4PEZgXY{qkb3}Xrjj=_Z5e5Ec;_S4nzJD>7hiM-8T4z(7$eh z*OLM#Es<3<-^=+e2g)gNSV8U?4F;F|M%cPqk3nMnOVF-PqDzqI$E=9AygbK80va4I z+b^A=FBre%<#KKp8BpanaCH;&2b(y)4{XY9a_z`GqQLWOW#xUu@J1ofPnZMTM2zrD j*$9d3q8=b|LY$Vw;YJ=9gwa*_BLHd3+$zKa^FRODaj~Kt literal 0 HcmV?d00001 diff --git a/tests/auto/gui/painting/qcolorspace/resources/sRGB2014.icc b/tests/auto/gui/painting/qcolorspace/resources/sRGB2014.icc new file mode 100644 index 0000000000000000000000000000000000000000..49afbfef10f22a1832590b68369d2f248ea553b9 GIT binary patch literal 3024 zcmb`Jc{r5o8^@pboqe;-klom~#=Z=)?<7n1RL0C;EQ4W?v`H$Qlq6e;oU(N2=!6`p zq_j9fq0&N*O8IqkN}I~>9j@P{b6vkb&vRYx^M3C8x$pP6pZoda{Q^K51jvAqCy}2f z2yl0zhlYjIaZeGKxM&3c7CSY0nf@_DE7pfmuw>n3hyBge}>zEF^|hhw$p<`Vm43NktlHVq|Q#Wc`bi=uVbDr*Q%R@mv7f?y!Y| z^kpAf^uhola$__g2b6(2&;bl!0xW?IZ~(5r3;2RS5C%2@Hi!j@Kmam8HrNI7Kmj-i zj(`eK4eCGxXa=pI9dv;!;5xVs2Ehmz2NPf#yasdN16Y6{2nSIhDkKM~K$?&~WCAfE zJIEDU3k5)7P$U!s@gX6U4ef>spkk;3s(~7yU!e=o73d~31U-Nzp&96J=nIU3$uJF8 zg0)~nm^L%}Fw^fA^LPfRE#29trw!<1r9Va{W&VMZ|1m=9PiRtBq$wZwX0 z!?1DKt=K~BF>DL=GIj_%g`LOYaB?_(oGs25$HJxI@^Iz2Gq_8*VcazC6P|=u!JFXS z@ZoqqJ_lclZ^U=whw(4)3j_&*Cc&EEOW+W;5Q+$OgigX8!ZcxlC`r^N+7bhaal~E3 zGGa6F8u1bF9f?FzBUzFBNj%a{QW@zi=>}<%^qDM0)+0NUBgjJX0rF|`W%2{^I|_xO zMRA~nQ_?60C=HaWlqZx=VpK5$F;6j$*bcEuu{N<`u{YubaZPbY@lE1c;-%u}#P5jD zN)RNpB%CE!65AyzB`!#eNz6-9C5m zB-1K0D)VKP(kjPQ+*SKmHLn_8^-)$q);f{g-OAzz_Y;h`d|sHYg9xK;6_V!z_NlCqM!QnFIH(p9BdWf^4$ z67?SSISmyJAB}8{CXI)h1Wl%9tmaY8KFyC>+FBu6d$roNUTVu~dunHC zH)%i8q3GD_r0CS@+|$MCGIis1kLeET!FuL;v3iwycl2R>3w@scG5w*{nAKLR`KxPJ zk1@y$M@BlMi7{y)W3bjB$DrNdjiH8NxZxqgKEv-u=0*udbw=aHQpR4!ImVsFf1Bu; zuuUpW?wL|d-As3wc9_03(>LRq9XGpgPBr&2-)r7u{>{SDLSWHsF=MG=8EIK%ImV{PDV}wr}Iu9ovod>IbU``xwyOJy9~HW zxdypbxIS@HbBl3na+`BEci-xM*#qO@?QzIs%u~se?b+Zt=Vj@&&8yd&?7iN*!u#1; zy|se1oj$OSm(O9JN9#1#@z=Hc0$)$x!@iIGwEa^2e)q@v`}tS;KMybt$PVaRPhG!x zedGEMflh%%f#X3sLBgP(VDaFH;D+FjAub`sArqm7q1!@lhslTW!aBln;lbgj!sj=* zZaA`GI>J06FJg3~_QuSOH#f;|O4xL9v-oD#=5vvl$dJg!$geD4RxN8j$}_4eYL4y9 zKFWU0ap072X1KQ8V(yD*+vwuxmoc_6hht`9?PE)0XL-)N3f|i|kGSf%kMX|or{fnB zLK0dM@rjX%7x+^Acz$n^a#Ci}P_lklKhhQM>Ze1S!z~VeUx}qcyyv{ZCOXTM)|?=uNAQsBb82-EmewD`>Q@4 z;~X14?r^-hTB*9A`pXI4iTgF~HEp$8wWTMqC(}uM0h$Hl62xH~9T@mugq#Md^!0-Nf$P?!`-4 zm*y`gU!J`Zb7iV$bIqdq~gGTRGoA)2d|5UxvdGp&}4uAE}h0aaC6}(;i zyYQXdyVLK@-uKM=%|H2&_+jB={wKLl^`Dua`@V#Hd9jf375BC5o9?&H@7~`ZEha85 z{-8k&JYAjX7RFW<77P=HG2Mk5%@QW0(M8J6IVmAYD4?%TX0f?+23;gpmIcJWHm~TE zsB!?>_W&UKaK(pgBT{F`Sk`1q_=ApIvi~>1Kja-poFc8Ycg2@f3jlK-0Mx-$UJPB7 zEaT{Co~CjhDoy^Z4|Cv`LizZ;q8ZSF~{&Hxtp1 zNS#T^TLiqA*fhE)KaDHkvqTlK5|(a9AgVDnNsz`9Ca$I)0svP6z_+5s#f6&1#cxP2P~!kx7XBBF2+<<| literal 0 HcmV?d00001 diff --git a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp new file mode 100644 index 0000000000..9bd4b75443 --- /dev/null +++ b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp @@ -0,0 +1,238 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** 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 + +#include +#include +#include + +Q_DECLARE_METATYPE(QColorSpace::ColorSpaceId) +Q_DECLARE_METATYPE(QColorSpace::Gamut) +Q_DECLARE_METATYPE(QColorSpace::TransferFunction) + +class tst_QColorSpace : public QObject +{ + Q_OBJECT + +public: + tst_QColorSpace(); + +private slots: + void namedColorSpaces_data(); + void namedColorSpaces(); + + void toIccProfile_data(); + void toIccProfile(); + + void fromIccProfile(); + + void imageConversion_data(); + void imageConversion(); + + void loadImage(); +}; + +tst_QColorSpace::tst_QColorSpace() +{ } + + +void tst_QColorSpace::namedColorSpaces_data() +{ + QTest::addColumn("colorSpaceId"); + QTest::addColumn("gamutId"); + QTest::addColumn("transferFunctionId"); + + QTest::newRow("sRGB") << QColorSpace::SRgb + << QColorSpace::Gamut::SRgb + << QColorSpace::TransferFunction::SRgb; + QTest::newRow("sRGB Linear") << QColorSpace::SRgbLinear + << QColorSpace::Gamut::SRgb + << QColorSpace::TransferFunction::Linear; + QTest::newRow("Adobe RGB") << QColorSpace::AdobeRgb + << QColorSpace::Gamut::AdobeRgb + << QColorSpace::TransferFunction::Gamma; + QTest::newRow("Display-P3") << QColorSpace::DisplayP3 + << QColorSpace::Gamut::DciP3D65 + << QColorSpace::TransferFunction::SRgb; + QTest::newRow("ProPhoto RGB") << QColorSpace::ProPhotoRgb + << QColorSpace::Gamut::ProPhotoRgb + << QColorSpace::TransferFunction::ProPhotoRgb; + QTest::newRow("BT.2020") << QColorSpace::Bt2020 + << QColorSpace::Gamut::Bt2020 + << QColorSpace::TransferFunction::Bt2020; +} + +void tst_QColorSpace::namedColorSpaces() +{ + QFETCH(QColorSpace::ColorSpaceId, colorSpaceId); + QFETCH(QColorSpace::Gamut, gamutId); + QFETCH(QColorSpace::TransferFunction, transferFunctionId); + + QColorSpace colorSpace = colorSpaceId; + + QVERIFY(colorSpace.isValid()); + + QCOMPARE(colorSpace.colorSpaceId(), colorSpaceId); + QCOMPARE(colorSpace.gamut(), gamutId); + QCOMPARE(colorSpace.transferFunction(), transferFunctionId); +} + + +void tst_QColorSpace::toIccProfile_data() +{ + namedColorSpaces_data(); +} + +void tst_QColorSpace::toIccProfile() +{ + QFETCH(QColorSpace::ColorSpaceId, colorSpaceId); + QFETCH(QColorSpace::Gamut, gamutId); + QFETCH(QColorSpace::TransferFunction, transferFunctionId); + + Q_UNUSED(gamutId); + Q_UNUSED(transferFunctionId); + + QColorSpace colorSpace = colorSpaceId; + QByteArray iccProfile = colorSpace.iccProfile(); + QVERIFY(!iccProfile.isEmpty()); + + QColorSpace colorSpace2 = QColorSpace::fromIccProfile(iccProfile); + QVERIFY(colorSpace2.isValid()); + + QCOMPARE(colorSpace2, colorSpace); + + QByteArray iccProfile2 = colorSpace2.iccProfile(); + QVERIFY(!iccProfile2.isEmpty()); + + QCOMPARE(iccProfile2, iccProfile); +} + +void tst_QColorSpace::fromIccProfile() +{ + // Read the official sRGB ICCv2 profile: + QString prefix = QFINDTESTDATA("resources/"); + QFile file(prefix + "sRGB2014.icc"); + file.open(QIODevice::ReadOnly); + QByteArray iccProfile = file.readAll(); + QColorSpace stdSRgb = QColorSpace::fromIccProfile(iccProfile); + QVERIFY(stdSRgb.isValid()); + + QCOMPARE(stdSRgb.gamut(), QColorSpace::Gamut::SRgb); + QCOMPARE(stdSRgb.transferFunction(), QColorSpace::TransferFunction::SRgb); + QCOMPARE(stdSRgb.colorSpaceId(), QColorSpace::SRgb); + + QCOMPARE(stdSRgb, QColorSpace(QColorSpace::SRgb)); +} + +void tst_QColorSpace::imageConversion_data() +{ + QTest::addColumn("fromColorSpace"); + QTest::addColumn("toColorSpace"); + QTest::addColumn("tolerance"); + + QTest::newRow("sRGB -> Display-P3") << QColorSpace::SRgb << QColorSpace::DisplayP3 << 0; + QTest::newRow("sRGB -> Adobe RGB") << QColorSpace::SRgb << QColorSpace::AdobeRgb << 2; + QTest::newRow("Display-P3 -> sRGB") << QColorSpace::DisplayP3 << QColorSpace::SRgb << 0; + QTest::newRow("Adobe RGB -> sRGB") << QColorSpace::AdobeRgb << QColorSpace::SRgb << 2; + QTest::newRow("Display-P3 -> Adobe RGB") << QColorSpace::DisplayP3 << QColorSpace::AdobeRgb << 2; + QTest::newRow("Display-P3 -> BT.2020") << QColorSpace::DisplayP3 << QColorSpace::Bt2020 << 4; + QTest::newRow("sRGB -> sRGB Linear") << QColorSpace::SRgb << QColorSpace::SRgbLinear << 0; +} + +void tst_QColorSpace::imageConversion() +{ + QFETCH(QColorSpace::ColorSpaceId, fromColorSpace); + QFETCH(QColorSpace::ColorSpaceId, toColorSpace); + QFETCH(int, tolerance); + + QImage testImage(256, 1, QImage::Format_RGB32); + + for (int i = 0; i < 256; ++i) + testImage.setPixel(i, 0, qRgb(i, i, i)); + + testImage.setColorSpace(fromColorSpace); + QCOMPARE(testImage.colorSpace(), QColorSpace(fromColorSpace)); + + testImage.convertToColorSpace(toColorSpace); + QCOMPARE(testImage.colorSpace(), QColorSpace(toColorSpace)); + + int lastRed = 0; + int lastGreen = 0; + int lastBlue = 0; + for (int i = 0; i < 256; ++i) { + QRgb p = testImage.pixel(i, 0); + QVERIFY(qRed(p) >= lastRed); + QVERIFY(qGreen(p) >= lastGreen); + QVERIFY(qBlue(p) >= lastBlue); + lastRed = qRed(p); + lastGreen = qGreen(p); + lastBlue = qBlue(p); + } + + lastRed = 0; + lastGreen = 0; + lastBlue = 0; + testImage.convertToColorSpace(fromColorSpace); + QCOMPARE(testImage.colorSpace(), QColorSpace(fromColorSpace)); + for (int i = 0; i < 256; ++i) { + QRgb p = testImage.pixel(i, 0); + QVERIFY(qAbs(qRed(p) - qGreen(p)) <= tolerance); + QVERIFY(qAbs(qRed(p) - qBlue(p)) <= tolerance); + QVERIFY((lastRed - qRed(p)) <= (tolerance / 2)); + QVERIFY((lastGreen - qGreen(p)) <= (tolerance / 2)); + QVERIFY((lastBlue - qBlue(p)) <= (tolerance / 2)); + lastRed = qRed(p); + lastGreen = qGreen(p); + lastBlue = qBlue(p); + } +} + + +void tst_QColorSpace::loadImage() +{ + QString prefix = QFINDTESTDATA("resources/"); + QImageReader reader(prefix + "ProPhoto.jpg"); + QImage image = reader.read(); + + QVERIFY(!image.isNull()); + QVERIFY(image.colorSpace().isValid()); + QCOMPARE(image.colorSpace().colorSpaceId(), QColorSpace::ProPhotoRgb); + QVERIFY(!image.colorSpace().iccProfile().isEmpty()); + + QColorSpace defaultProPhotoRgb = QColorSpace::ProPhotoRgb; + QVERIFY(!defaultProPhotoRgb.iccProfile().isEmpty()); + + // Test the iccProfile getter returns the ICC profile from the image + // which since we didn't write it, isn't identical to our defaults. + QVERIFY(defaultProPhotoRgb.iccProfile() != image.colorSpace().iccProfile()); +} + +QTEST_MAIN(tst_QColorSpace) +#include "tst_qcolorspace.moc" From 756c64c539952334546c08741066546cc43e104c Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Fri, 21 Dec 2018 12:17:25 +0100 Subject: [PATCH 003/292] qmake.pro: Fix missing headers and add missing line continuation Change-Id: I308cff86f1af2c24eee13ec0531d967a3770ed04 Reviewed-by: Frederik Gladhorn Reviewed-by: Joerg Bornemann --- qmake/qmake.pro | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/qmake/qmake.pro b/qmake/qmake.pro index ebd61751b7..d704fdb6dc 100644 --- a/qmake/qmake.pro +++ b/qmake/qmake.pro @@ -96,7 +96,7 @@ HEADERS += \ bp = $$shadowed(..) INCLUDEPATH += \ $$bp/include $$bp/include/QtCore \ - $$bp/include/QtCore/$$QT_VERSION $$bp/include/QtCore/$$QT_VERSION/QtCore + $$bp/include/QtCore/$$QT_VERSION $$bp/include/QtCore/$$QT_VERSION/QtCore \ $$bp/src/corelib/global VPATH += \ @@ -182,18 +182,17 @@ HEADERS += \ qglobal.h \ qhash.h \ qiodevice.h \ - qjson.h \ + qjson_p.h \ qjsonarray.h \ qjsondocument.h \ qjsonobject.h \ - qjsonparser.h \ + qjsonparser_p.h \ qjsonvalue.h \ - qjsonwriter.h \ + qjsonwriter_p.h \ qlinkedlist.h \ qlist.h \ qlocale.h \ qlocale_tools_p.h \ - qmalloc.h \ qmap.h \ qmetatype.h \ qnumeric.h \ @@ -204,12 +203,12 @@ HEADERS += \ qsystemerror_p.h \ qtemporaryfile.h \ qtextstream.h \ - qutfcodec.h \ + qutfcodec_p.h \ quuid.h \ qvector.h \ qversionnumber.h \ qxmlstream.h \ - qxmlutils.h + qxmlutils_p.h unix { SOURCES += \ From e990d4d27f6ca2044808a91f88c39d2ac1c690e2 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Tue, 29 Jan 2019 10:38:23 +0100 Subject: [PATCH 004/292] corelib: typo fix in .pro-file Consistently use space before line continuation marker. Change-Id: Ib87d45f76b6fd174c78a04335f06b4dbed1bed13 Reviewed-by: Frederik Gladhorn --- src/corelib/kernel/kernel.pri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri index 3f7bf3cd47..789bcb7927 100644 --- a/src/corelib/kernel/kernel.pri +++ b/src/corelib/kernel/kernel.pri @@ -7,7 +7,7 @@ HEADERS += \ kernel/qdeadlinetimer.h \ kernel/qdeadlinetimer_p.h \ kernel/qelapsedtimer.h \ - kernel/qeventloop.h\ + kernel/qeventloop.h \ kernel/qpointer.h \ kernel/qcorecmdlineargs_p.h \ kernel/qcoreapplication.h \ From 1d1e801cba01c88e75e73aa19e07d7588aa9e89b Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Tue, 29 Jan 2019 14:13:41 +0100 Subject: [PATCH 005/292] gui: Fix typo in qmake build system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I170125fb7ed2355b3b322ef287c795f40c37fe6b Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/kernel.pri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 1f137fc46f..9c80f1e2cc 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -21,7 +21,7 @@ HEADERS += \ kernel/qplatforminputcontextplugin_p.h \ kernel/qplatformintegrationfactory_p.h \ kernel/qplatformintegrationplugin.h \ - kernel/qplatformtheme.h\ + kernel/qplatformtheme.h \ kernel/qplatformtheme_p.h \ kernel/qplatformthemefactory_p.h \ kernel/qplatformthemeplugin.h \ From 88a2a746b7ed49f4ac4861bbf8e3a55db691fa43 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 4 Jan 2019 14:55:28 +0100 Subject: [PATCH 006/292] Always return early if no signal is connected And simply emit the signal spy and tracing callbacks in that code path as well. Change-Id: I17f65055c7044caf1be58fac94bb7fe3487f3060 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/kernel/qobject.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index c0c009f254..8a03fe2a86 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -3668,12 +3668,14 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i Q_TRACE(QMetaObject_activate_end_declarative_signal, sender, signal_index); } - if (!sender->d_func()->isSignalConnected(signal_index, /*checkDeclarative =*/ false) - && !qt_signal_spy_callback_set.signal_begin_callback - && !qt_signal_spy_callback_set.signal_end_callback - && !Q_TRACE_ENABLED(QMetaObject_activate_begin_signal) - && !Q_TRACE_ENABLED(QMetaObject_activate_end_signal)) { - // The possible declarative connection is done, and nothing else is connected, so: + if (!sender->d_func()->isSignalConnected(signal_index, /*checkDeclarative =*/ false)) { + // The possible declarative connection is done, and nothing else is connected + if (qt_signal_spy_callback_set.signal_begin_callback != nullptr) + qt_signal_spy_callback_set.signal_begin_callback(sender, signal_index, argv); + Q_TRACE(QMetaObject_activate_begin_signal, sender, signal_index); + Q_TRACE(QMetaObject_activate_end_signal, sender, signal_index); + if (qt_signal_spy_callback_set.signal_end_callback != nullptr) + qt_signal_spy_callback_set.signal_end_callback(sender, signal_index); return; } @@ -3711,13 +3713,6 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i QObjectConnectionListVector *operator->() const { return connectionLists; } }; ConnectionListsRef connectionLists = sender->d_func()->connectionLists; - if (!connectionLists.connectionLists) { - locker.unlock(); - if (qt_signal_spy_callback_set.signal_end_callback != 0) - qt_signal_spy_callback_set.signal_end_callback(sender, signal_index); - Q_TRACE(QMetaObject_activate_end_signal, sender, signal_index); - return; - } const QObjectPrivate::ConnectionList *list; if (signal_index < connectionLists->count()) From a5a859e721e7a1d0c5a3ec6abe2db55d9144bb36 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 3 Jan 2019 16:02:09 +0100 Subject: [PATCH 007/292] Get rid of the connectedSignals bitflags Measurements show that it's just almost as fast to simply query the connectionlist directly and avoid both the memory overhead of the bitfield and the associated bookkeeping. For connected signals, the difference is not relevant at all. With a signal that was never connected, removing the bitfield will cause signal emission to be ~2.5% faster. And if you ever disconnect from a signal, the bitfields might not be accurate and this can cause a major slowdown. Here are some numbers to validate this. All times are measured in ms for 100M signal emissions: without change with change string based connect: 3817 3836 pointer based connect: 4552 4571 not connected: 493 479 disconnected: 2113 559 Change-Id: Ia2c85036afaa7f991b883c8ff812f69cf4580f7e Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: hjk --- src/corelib/global/qhooks.cpp | 2 +- src/corelib/kernel/qobject.cpp | 65 +++++++++---------- src/corelib/kernel/qobject_p.h | 18 +---- .../other/toolsupport/tst_toolsupport.cpp | 4 +- 4 files changed, 35 insertions(+), 54 deletions(-) diff --git a/src/corelib/global/qhooks.cpp b/src/corelib/global/qhooks.cpp index bbddb1cbf1..020dee3710 100644 --- a/src/corelib/global/qhooks.cpp +++ b/src/corelib/global/qhooks.cpp @@ -67,7 +67,7 @@ quintptr Q_CORE_EXPORT qtHookData[] = { // The required sizes and offsets are tested in tests/auto/other/toolsupport. // When this fails and the change was intentional, adjust the test and // adjust this value here. - 16 + 17 }; Q_STATIC_ASSERT(QHooks::LastHookIndex == sizeof(qtHookData) / sizeof(qtHookData[0])); diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 8a03fe2a86..c158cf9452 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -232,7 +232,6 @@ QObjectPrivate::QObjectPrivate(int version) receiveChildEvents = true; postedEvents = 0; extraData = 0; - connectedSignals[0] = connectedSignals[1] = 0; metaObject = 0; isWindow = false; deleteLaterCalled = false; @@ -409,19 +408,12 @@ void QObjectPrivate::addConnection(int signal, Connection *c) *c->prev = c; if (c->next) c->next->prev = &c->next; - - if (signal < 0) { - connectedSignals[0] = connectedSignals[1] = ~0; - } else if (signal < (int)sizeof(connectedSignals) * 8) { - connectedSignals[signal >> 5] |= (1 << (signal & 0x1f)); - } } void QObjectPrivate::cleanConnectionLists() { if (connectionLists->dirty && !connectionLists->inUse) { // remove broken connections - bool allConnected = false; for (int signal = -1; signal < connectionLists->count(); ++signal) { QObjectPrivate::ConnectionList &connectionList = (*connectionLists)[signal]; @@ -433,13 +425,11 @@ void QObjectPrivate::cleanConnectionLists() QObjectPrivate::Connection **prev = &connectionList.first; QObjectPrivate::Connection *c = *prev; - bool connected = false; // whether the signal is still connected somewhere while (c) { if (c->receiver) { last = c; prev = &c->nextConnectionList; c = *prev; - connected = true; } else { QObjectPrivate::Connection *next = c->nextConnectionList; *prev = next; @@ -451,19 +441,40 @@ void QObjectPrivate::cleanConnectionLists() // Correct the connection list's last pointer. // As conectionList.last could equal last, this could be a noop connectionList.last = last; - - if (!allConnected && !connected && signal >= 0 - && size_t(signal) < sizeof(connectedSignals) * 8) { - // This signal is no longer connected - connectedSignals[signal >> 5] &= ~(1 << (signal & 0x1f)); - } else if (signal == -1) { - allConnected = connected; - } } connectionLists->dirty = false; } } +/*! \internal + + Returns \c true if the signal with index \a signal_index from object \a sender is connected. + + \a signal_index must be the index returned by QObjectPrivate::signalIndex; +*/ +bool QObjectPrivate::isSignalConnected(uint signalIndex, bool checkDeclarative) const +{ + if (checkDeclarative && isDeclarativeSignalConnected(signalIndex)) + return true; + + if (!connectionLists) + return false; + + if (connectionLists->allsignals.first) + return true; + + if (signalIndex < uint(connectionLists->count())) { + const QObjectPrivate::Connection *c = connectionLists->at(signalIndex).first; + while (c) { + if (c->receiver) + return true; + c = c->nextConnectionList; + } + } + return false; +} + + /*! \internal */ @@ -2521,21 +2532,7 @@ bool QObject::isSignalConnected(const QMetaMethod &signal) const signalIndex += QMetaObjectPrivate::signalOffset(signal.mobj); QMutexLocker locker(signalSlotLock(this)); - if (d->connectionLists) { - if (signalIndex < sizeof(d->connectedSignals) * 8 && !d->connectionLists->dirty) - return d->isSignalConnected(signalIndex); - - if (signalIndex < uint(d->connectionLists->count())) { - const QObjectPrivate::Connection *c = - d->connectionLists->at(signalIndex).first; - while (c) { - if (c->receiver) - return true; - c = c->nextConnectionList; - } - } - } - return d->isDeclarativeSignalConnected(signalIndex); + return d->isSignalConnected(signalIndex, true); } /*! @@ -3668,7 +3665,7 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i Q_TRACE(QMetaObject_activate_end_declarative_signal, sender, signal_index); } - if (!sender->d_func()->isSignalConnected(signal_index, /*checkDeclarative =*/ false)) { + if (!sender->d_func()->isSignalConnected(signal_index, false)) { // The possible declarative connection is done, and nothing else is connected if (qt_signal_spy_callback_set.signal_begin_callback != nullptr) qt_signal_spy_callback_set.signal_begin_callback(sender, signal_index, argv); diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index a762e6f529..7cc82d4f71 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -201,7 +201,7 @@ public: static const QObjectPrivate *get(const QObject *o) { return o->d_func(); } int signalIndex(const char *signalName, const QMetaObject **meta = nullptr) const; - inline bool isSignalConnected(uint signalIdx, bool checkDeclarative = true) const; + bool isSignalConnected(uint signalIdx, bool checkDeclarative = true) const; inline bool isDeclarativeSignalConnected(uint signalIdx) const; // To allow abitrary objects to call connectNotify()/disconnectNotify() without making @@ -232,7 +232,6 @@ public: Connection *senders; // linked list of connections connected to this object Sender *currentSender; // object currently activating the object - mutable quint32 connectedSignals[2]; union { QObject *currentChildBeingDeleted; // should only be used when QObjectData::isDeletingChildren is set @@ -246,21 +245,6 @@ public: Q_DECLARE_TYPEINFO(QObjectPrivate::ConnectionList, Q_MOVABLE_TYPE); -/*! \internal - - Returns \c true if the signal with index \a signal_index from object \a sender is connected. - Signals with indices above a certain range are always considered connected (see connectedSignals - in QObjectPrivate). - - \a signal_index must be the index returned by QObjectPrivate::signalIndex; -*/ -inline bool QObjectPrivate::isSignalConnected(uint signal_index, bool checkDeclarative) const -{ - return signal_index >= sizeof(connectedSignals) * 8 - || (connectedSignals[signal_index >> 5] & (1 << (signal_index & 0x1f)) - || (checkDeclarative && isDeclarativeSignalConnected(signal_index))); -} - inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const { return declarativeData && QAbstractDeclarativeData::isSignalConnected diff --git a/tests/auto/other/toolsupport/tst_toolsupport.cpp b/tests/auto/other/toolsupport/tst_toolsupport.cpp index f31a755f9e..27bc6ba646 100644 --- a/tests/auto/other/toolsupport/tst_toolsupport.cpp +++ b/tests/auto/other/toolsupport/tst_toolsupport.cpp @@ -126,9 +126,9 @@ void tst_toolsupport::offsets_data() #ifdef Q_PROCESSOR_X86 // x86 32-bit has weird alignment rules. Refer to QtPrivate::AlignOf in // qglobal.h for more details. - data << 168 << 248; + data << 160 << 240; #else - data << 172 << 248; + data << 164 << 240; #endif } #endif From a65752c71bd25bbb66bf33d3a82f7901419c5d95 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 3 Jan 2019 22:57:28 +0100 Subject: [PATCH 008/292] Shave ~5% off from signal emission time Refactor activate(), so that we eliminate almost all checks for signal hooks in the common case. Here are the benchmark numbers showing the improvement for 100M signal emissions without change with change string based connect: 3836 3693 pointer based connect: 4571 4510 not connected: 479 433 disconnected: 559 522 Change-Id: I394e6ea5d5bc96e298e8cc0c763eed78c8041876 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/global/qtrace_p.h | 2 + src/corelib/kernel/qcoreapplication.cpp | 9 --- src/corelib/kernel/qobject.cpp | 102 +++++++++++++++--------- src/corelib/kernel/qobject_p.h | 4 +- src/testlib/qsignaldumper.cpp | 5 +- 5 files changed, 69 insertions(+), 53 deletions(-) diff --git a/src/corelib/global/qtrace_p.h b/src/corelib/global/qtrace_p.h index 3d04a7311d..56d1f9a318 100644 --- a/src/corelib/global/qtrace_p.h +++ b/src/corelib/global/qtrace_p.h @@ -114,10 +114,12 @@ QT_BEGIN_NAMESPACE #if defined(Q_TRACEPOINT) && !defined(QT_BOOTSTRAPPED) +# define Q_HAS_TRACEPOINTS 1 # define Q_TRACE(x, ...) QtPrivate::trace_ ## x(__VA_ARGS__) # define Q_UNCONDITIONAL_TRACE(x, ...) QtPrivate::do_trace_ ## x(__VA_ARGS__) # define Q_TRACE_ENABLED(x) QtPrivate::trace_ ## x ## _enabled() #else +# define Q_HAS_TRACEPOINTS 0 # define Q_TRACE(x, ...) # define Q_UNCONDITIONAL_TRACE(x, ...) # define Q_TRACE_ENABLED(x) false diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index e5098b8415..e6d1d26f3c 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -256,15 +256,6 @@ void QCoreApplicationPrivate::processCommandLineArguments() // Support for introspection -#ifndef QT_NO_QOBJECT -QSignalSpyCallbackSet Q_CORE_EXPORT qt_signal_spy_callback_set = { 0, 0, 0, 0 }; - -void qt_register_signal_spy_callbacks(const QSignalSpyCallbackSet &callback_set) -{ - qt_signal_spy_callback_set = callback_set; -} -#endif - extern "C" void Q_CORE_EXPORT qt_startup_hook() { } diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index c158cf9452..0c81e416da 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -77,6 +77,12 @@ QT_BEGIN_NAMESPACE static int DIRECT_CONNECTION_ONLY = 0; +Q_CORE_EXPORT QBasicAtomicPointer qt_signal_spy_callback_set = Q_BASIC_ATOMIC_INITIALIZER(nullptr); + +void qt_register_signal_spy_callbacks(QSignalSpyCallbackSet *callback_set) +{ + qt_signal_spy_callback_set.store(callback_set); +} QDynamicMetaObjectData::~QDynamicMetaObjectData() { @@ -3638,41 +3644,32 @@ static void queued_activate(QObject *sender, int signal, QObjectPrivate::Connect QCoreApplication::postEvent(c->receiver, ev); } -/*! - \internal - */ -void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_signal_index, - void **argv) +template +void doActivate(QObject *sender, int signal_index, void **argv) { - activate(sender, QMetaObjectPrivate::signalOffset(m), local_signal_index, argv); -} + QObjectPrivate *sp = QObjectPrivate::get(sender); -/*! - \internal - */ -void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_index, void **argv) -{ - int signal_index = signalOffset + local_signal_index; - - if (sender->d_func()->blockSig) + if (sp->blockSig) return; - if (sender->d_func()->isDeclarativeSignalConnected(signal_index) + if (sp->isDeclarativeSignalConnected(signal_index) && QAbstractDeclarativeData::signalEmitted) { Q_TRACE(QMetaObject_activate_begin_declarative_signal, sender, signal_index); - QAbstractDeclarativeData::signalEmitted(sender->d_func()->declarativeData, sender, + QAbstractDeclarativeData::signalEmitted(sp->declarativeData, sender, signal_index, argv); Q_TRACE(QMetaObject_activate_end_declarative_signal, sender, signal_index); } - if (!sender->d_func()->isSignalConnected(signal_index, false)) { + const QSignalSpyCallbackSet *signal_spy_set = callbacks_enabled ? qt_signal_spy_callback_set.load() : nullptr; + + if (!sp->isSignalConnected(signal_index, false)) { // The possible declarative connection is done, and nothing else is connected - if (qt_signal_spy_callback_set.signal_begin_callback != nullptr) - qt_signal_spy_callback_set.signal_begin_callback(sender, signal_index, argv); + if (callbacks_enabled && signal_spy_set->signal_begin_callback != nullptr) + signal_spy_set->signal_begin_callback(sender, signal_index, argv); Q_TRACE(QMetaObject_activate_begin_signal, sender, signal_index); Q_TRACE(QMetaObject_activate_end_signal, sender, signal_index); - if (qt_signal_spy_callback_set.signal_end_callback != nullptr) - qt_signal_spy_callback_set.signal_end_callback(sender, signal_index); + if (callbacks_enabled && signal_spy_set->signal_end_callback != nullptr) + signal_spy_set->signal_end_callback(sender, signal_index); return; } @@ -3680,9 +3677,8 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i if (!argv) argv = empty_argv; - if (qt_signal_spy_callback_set.signal_begin_callback != 0) { - qt_signal_spy_callback_set.signal_begin_callback(sender, signal_index, argv); - } + if (callbacks_enabled && signal_spy_set->signal_begin_callback != nullptr) + signal_spy_set->signal_begin_callback(sender, signal_index, argv); Q_TRACE(QMetaObject_activate_begin_signal, sender, signal_index); { @@ -3709,7 +3705,7 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i QObjectConnectionListVector *operator->() const { return connectionLists; } }; - ConnectionListsRef connectionLists = sender->d_func()->connectionLists; + ConnectionListsRef connectionLists = sp->connectionLists; const QObjectPrivate::ConnectionList *list; if (signal_index < connectionLists->count()) @@ -3731,7 +3727,7 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i continue; QObject * const receiver = c->receiver; - const bool receiverInSameThread = currentThreadId == receiver->d_func()->threadData->threadId.load(); + const bool receiverInSameThread = currentThreadId == QObjectPrivate::get(receiver)->threadData->threadId.load(); // determine if this connection should be sent immediately or // put into the event queue @@ -3780,34 +3776,34 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i locker.relock(); } else if (c->callFunction && c->method_offset <= receiver->metaObject()->methodOffset()) { //we compare the vtable to make sure we are not in the destructor of the object. - const int methodIndex = c->method(); const int method_relative = c->method_relative; const auto callFunction = c->callFunction; locker.unlock(); - if (qt_signal_spy_callback_set.slot_begin_callback != 0) - qt_signal_spy_callback_set.slot_begin_callback(receiver, methodIndex, argv); + const int methodIndex = (Q_HAS_TRACEPOINTS || callbacks_enabled) ? c->method() : 0; + if (callbacks_enabled && signal_spy_set->slot_begin_callback != nullptr) + signal_spy_set->slot_begin_callback(receiver, methodIndex, argv); Q_TRACE(QMetaObject_activate_begin_slot, receiver, methodIndex); callFunction(receiver, QMetaObject::InvokeMetaMethod, method_relative, argv); Q_TRACE(QMetaObject_activate_end_slot, receiver, methodIndex); - if (qt_signal_spy_callback_set.slot_end_callback != 0) - qt_signal_spy_callback_set.slot_end_callback(receiver, methodIndex); + if (callbacks_enabled && signal_spy_set->slot_end_callback != nullptr) + signal_spy_set->slot_end_callback(receiver, methodIndex); locker.relock(); } else { const int method = c->method_relative + c->method_offset; locker.unlock(); - if (qt_signal_spy_callback_set.slot_begin_callback != 0) { - qt_signal_spy_callback_set.slot_begin_callback(receiver, method, argv); + if (callbacks_enabled && signal_spy_set->slot_begin_callback != nullptr) { + signal_spy_set->slot_begin_callback(receiver, method, argv); } Q_TRACE(QMetaObject_activate_begin_slot, receiver, method); - metacall(receiver, QMetaObject::InvokeMetaMethod, method, argv); + QMetaObject::metacall(receiver, QMetaObject::InvokeMetaMethod, method, argv); Q_TRACE(QMetaObject_activate_end_slot, receiver, method); - if (qt_signal_spy_callback_set.slot_end_callback != 0) - qt_signal_spy_callback_set.slot_end_callback(receiver, method); + if (callbacks_enabled && signal_spy_set->slot_end_callback != nullptr) + signal_spy_set->slot_end_callback(receiver, method); locker.relock(); } @@ -3824,11 +3820,39 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i } - if (qt_signal_spy_callback_set.signal_end_callback != 0) - qt_signal_spy_callback_set.signal_end_callback(sender, signal_index); + if (callbacks_enabled && signal_spy_set->signal_end_callback != nullptr) + signal_spy_set->signal_end_callback(sender, signal_index); Q_TRACE(QMetaObject_activate_end_signal, sender, signal_index); + } +/*! + \internal + */ +void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_signal_index, + void **argv) +{ + int signal_index = local_signal_index + QMetaObjectPrivate::signalOffset(m); + + if (Q_UNLIKELY(qt_signal_spy_callback_set.load())) + doActivate(sender, signal_index, argv); + else + doActivate(sender, signal_index, argv); +} + +/*! + \internal + */ +void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_index, void **argv) +{ + int signal_index = signalOffset + local_signal_index; + + if (Q_UNLIKELY(qt_signal_spy_callback_set.load())) + doActivate(sender, signal_index, argv); + else + doActivate(sender, signal_index, argv); + } + /*! \internal signal_index comes from indexOfMethod() diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 7cc82d4f71..a260ed680e 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -79,9 +79,9 @@ struct QSignalSpyCallbackSet EndCallback signal_end_callback, slot_end_callback; }; -void Q_CORE_EXPORT qt_register_signal_spy_callbacks(const QSignalSpyCallbackSet &callback_set); +void Q_CORE_EXPORT qt_register_signal_spy_callbacks(QSignalSpyCallbackSet *callback_set); -extern QSignalSpyCallbackSet Q_CORE_EXPORT qt_signal_spy_callback_set; +extern Q_CORE_EXPORT QBasicAtomicPointer qt_signal_spy_callback_set; enum { QObjectPrivateVersion = QT_VERSION }; diff --git a/src/testlib/qsignaldumper.cpp b/src/testlib/qsignaldumper.cpp index 8305c5d424..b3360b4e6c 100644 --- a/src/testlib/qsignaldumper.cpp +++ b/src/testlib/qsignaldumper.cpp @@ -170,13 +170,12 @@ void QSignalDumper::startDump() { static QSignalSpyCallbackSet set = { QTest::qSignalDumperCallback, QTest::qSignalDumperCallbackSlot, QTest::qSignalDumperCallbackEndSignal, 0 }; - qt_register_signal_spy_callbacks(set); + qt_register_signal_spy_callbacks(&set); } void QSignalDumper::endDump() { - static QSignalSpyCallbackSet nset = { 0, 0, 0 ,0 }; - qt_register_signal_spy_callbacks(nset); + qt_register_signal_spy_callbacks(nullptr); } void QSignalDumper::ignoreClass(const QByteArray &klass) From ab92b9e40025dcf08c14232de762a268201a78b4 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 4 Jan 2019 08:55:40 +0100 Subject: [PATCH 009/292] Simplify the code required for switching the current sender Squeezes another percent of performance out of QMetaObject::activate(). Change-Id: I620b8c578681280efcc9bec50cfb1020d2afc928 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/kernel/qobject.cpp | 55 +++++++--------------------------- src/corelib/kernel/qobject_p.h | 50 ++++++++++++++----------------- 2 files changed, 33 insertions(+), 72 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 0c81e416da..f7983f3251 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -166,39 +166,6 @@ extern "C" Q_CORE_EXPORT void qt_removeObject(QObject *) {} #endif -struct QConnectionSenderSwitcher { - QObject *receiver; - QObjectPrivate::Sender *previousSender; - QObjectPrivate::Sender currentSender; - bool switched; - - inline QConnectionSenderSwitcher() : switched(false) {} - - inline QConnectionSenderSwitcher(QObject *receiver, QObject *sender, int signal_absolute_id) - { - switchSender(receiver, sender, signal_absolute_id); - } - - inline void switchSender(QObject *receiver, QObject *sender, int signal_absolute_id) - { - this->receiver = receiver; - currentSender.sender = sender; - currentSender.signal = signal_absolute_id; - currentSender.ref = 1; - previousSender = QObjectPrivate::setCurrentSender(receiver, ¤tSender); - switched = true; - } - - inline ~QConnectionSenderSwitcher() - { - if (switched) - QObjectPrivate::resetCurrentSender(receiver, ¤tSender, previousSender); - } -private: - Q_DISABLE_COPY(QConnectionSenderSwitcher) -}; - - void (*QAbstractDeclarativeData::destroyed)(QAbstractDeclarativeData *, QObject *) = 0; void (*QAbstractDeclarativeData::destroyed_qml1)(QAbstractDeclarativeData *, QObject *) = 0; void (*QAbstractDeclarativeData::parentChanged)(QAbstractDeclarativeData *, QObject *, QObject *) = 0; @@ -938,10 +905,10 @@ QObject::~QObject() } } - // set ref to zero to indicate that this object has been deleted - if (d->currentSender != 0) - d->currentSender->ref = 0; - d->currentSender = 0; + if (d->currentSender) { + d->currentSender->receiverDeleted(); + d->currentSender = nullptr; + } if (d->connectionLists || d->senders) { QMutex *signalSlotMutex = signalSlotLock(this); @@ -1272,7 +1239,7 @@ bool QObject::event(QEvent *e) { QMetaCallEvent *mce = static_cast(e); - QConnectionSenderSwitcher sw(this, const_cast(mce->sender()), mce->signalId()); + QObjectPrivate::Sender sender(this, const_cast(mce->sender()), mce->signalId()); mce->placeMetaCall(this); break; @@ -1576,9 +1543,10 @@ void QObjectPrivate::setThreadData_helper(QThreadData *currentData, QThreadData } // the current emitting thread shouldn't restore currentSender after calling moveToThread() - if (currentSender) - currentSender->ref = 0; - currentSender = 0; + if (currentSender) { + currentSender->receiverDeleted(); + currentSender = nullptr; + } // set new thread data targetData->ref(); @@ -3755,11 +3723,8 @@ void doActivate(QObject *sender, int signal_index, void **argv) #endif } - QConnectionSenderSwitcher sw; + QObjectPrivate::Sender senderData(receiverInSameThread ? receiver : nullptr, sender, signal_index); - if (receiverInSameThread) { - sw.switchSender(receiver, sender, signal_index); - } if (c->isSlotObject) { c->slotObj->ref(); QScopedPointer obj(c->slotObj); diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index a260ed680e..ab20064c65 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -167,9 +167,31 @@ public: struct Sender { + Sender(QObject *receiver, QObject *sender, int signal) + : receiver(receiver), sender(sender), signal(signal) + { + if (receiver) { + previous = receiver->d_func()->currentSender; + receiver->d_func()->currentSender = this; + } + } + ~Sender() + { + if (receiver) + receiver->d_func()->currentSender = previous; + } + void receiverDeleted() + { + Sender *s = this; + while (s) { + s->receiver = nullptr; + s = s->previous; + } + } + Sender *previous; + QObject *receiver; QObject *sender; int signal; - int ref; }; @@ -189,12 +211,6 @@ public: void addConnection(int signal, Connection *c); void cleanConnectionLists(); - static inline Sender *setCurrentSender(QObject *receiver, - Sender *sender); - static inline void resetCurrentSender(QObject *receiver, - Sender *currentSender, - Sender *previousSender); - static QObjectPrivate *get(QObject *o) { return o->d_func(); } @@ -251,26 +267,6 @@ inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) cons && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index); } -inline QObjectPrivate::Sender *QObjectPrivate::setCurrentSender(QObject *receiver, - Sender *sender) -{ - Sender *previousSender = receiver->d_func()->currentSender; - receiver->d_func()->currentSender = sender; - return previousSender; -} - -inline void QObjectPrivate::resetCurrentSender(QObject *receiver, - Sender *currentSender, - Sender *previousSender) -{ - // ref is set to zero when this object is deleted during the metacall - if (currentSender->ref == 1) - receiver->d_func()->currentSender = previousSender; - // if we've recursed, we need to tell the caller about the objects deletion - if (previousSender) - previousSender->ref = currentSender->ref; -} - inline void QObjectPrivate::connectNotify(const QMetaMethod &signal) { q_ptr->connectNotify(signal); From 5cc6f90910082f35e3f5340493facbc8c175f65f Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 7 Jan 2019 15:05:06 +0100 Subject: [PATCH 010/292] Move all connection related data into one data structure Adn create that data structure on demand on the heap. This reduces the size of QObjectPrivate if there are no connections. If we have connections, it'll use the same amount of allocations and memory as before. Change-Id: I900f6980a2cd8a5f72c3ad18697b5dd49100217d Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/kernel/qobject.cpp | 376 ++++++++---------- src/corelib/kernel/qobject_p.h | 47 ++- .../other/toolsupport/tst_toolsupport.cpp | 4 +- 3 files changed, 215 insertions(+), 212 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index f7983f3251..b8e973a0a3 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -182,7 +182,7 @@ QMetaObject *QObjectData::dynamicMetaObject() const } QObjectPrivate::QObjectPrivate(int version) - : threadData(0), connectionLists(0), senders(0), currentSender(0), currentChildBeingDeleted(0) + : threadData(0), currentChildBeingDeleted(0) { #ifdef QT_BUILD_INTERNAL // Don't check the version parameter in internal builds. @@ -257,59 +257,22 @@ static void computeOffsets(const QMetaObject *metaobject, int *signalOffset, int } } -/* - This vector contains the all connections from an object. - - Each object may have one vector containing the lists of - connections for a given signal. The index in the vector correspond - to the signal index. The signal index is the one returned by - QObjectPrivate::signalIndex (not QMetaObject::indexOfSignal). - Negative index means connections to all signals. - - This vector is protected by the object mutex (signalSlotMutexes()) - - Each Connection is also part of a 'senders' linked list. The mutex - of the receiver must be locked when touching the pointers of this - linked list. -*/ -class QObjectConnectionListVector : public QVector -{ -public: - bool orphaned; //the QObject owner of this vector has been destroyed while the vector was inUse - bool dirty; //some Connection have been disconnected (their receiver is 0) but not removed from the list yet - int inUse; //number of functions that are currently accessing this object or its connections - QObjectPrivate::ConnectionList allsignals; - - QObjectConnectionListVector() - : QVector(), orphaned(false), dirty(false), inUse(0) - { } - - QObjectPrivate::ConnectionList &operator[](int at) - { - if (at < 0) - return allsignals; - return QVector::operator[](at); - } -}; - // Used by QAccessibleWidget bool QObjectPrivate::isSender(const QObject *receiver, const char *signal) const { Q_Q(const QObject); int signal_index = signalIndex(signal); - if (signal_index < 0) + ConnectionData *cd = connections.load(); + if (signal_index < 0 || !cd) return false; QMutexLocker locker(signalSlotLock(q)); - if (connectionLists) { - if (signal_index < connectionLists->count()) { - const QObjectPrivate::Connection *c = - connectionLists->at(signal_index).first; + if (signal_index < cd->signalVector.count()) { + const QObjectPrivate::Connection *c = cd->signalVector.at(signal_index).first; - while (c) { - if (c->receiver == receiver) - return true; - c = c->nextConnectionList; - } + while (c) { + if (c->receiver == receiver) + return true; + c = c->nextConnectionList; } } return false; @@ -321,18 +284,17 @@ QObjectList QObjectPrivate::receiverList(const char *signal) const Q_Q(const QObject); QObjectList returnValue; int signal_index = signalIndex(signal); - if (signal_index < 0) + ConnectionData *cd = connections.load(); + if (signal_index < 0 || !cd) return returnValue; QMutexLocker locker(signalSlotLock(q)); - if (connectionLists) { - if (signal_index < connectionLists->count()) { - const QObjectPrivate::Connection *c = connectionLists->at(signal_index).first; + if (signal_index < cd->signalVector.count()) { + const QObjectPrivate::Connection *c = cd->signalVector.at(signal_index).first; - while (c) { - if (c->receiver) - returnValue << c->receiver; - c = c->nextConnectionList; - } + while (c) { + if (c->receiver) + returnValue << c->receiver; + c = c->nextConnectionList; } } return returnValue; @@ -342,9 +304,12 @@ QObjectList QObjectPrivate::receiverList(const char *signal) const QObjectList QObjectPrivate::senderList() const { QObjectList returnValue; - QMutexLocker locker(signalSlotLock(q_func())); - for (Connection *c = senders; c; c = c->next) - returnValue << c->sender; + ConnectionData *cd = connections.load(); + if (cd) { + QMutexLocker locker(signalSlotLock(q_func())); + for (Connection *c = cd->senders; c; c = c->next) + returnValue << c->sender; + } return returnValue; } @@ -361,12 +326,12 @@ QObjectList QObjectPrivate::senderList() const void QObjectPrivate::addConnection(int signal, Connection *c) { Q_ASSERT(c->sender == q_ptr); - if (!connectionLists) - connectionLists = new QObjectConnectionListVector(); - if (signal >= connectionLists->count()) - connectionLists->resize(signal + 1); + ensureConnectionData(); + ConnectionData *cd = connections.load(); + if (signal >= cd->signalVector.count()) + cd->signalVector.resize(signal + 1); - ConnectionList &connectionList = (*connectionLists)[signal]; + ConnectionList &connectionList = cd->connectionsForSignal(signal); if (connectionList.last) { connectionList.last->nextConnectionList = c; } else { @@ -376,7 +341,10 @@ void QObjectPrivate::addConnection(int signal, Connection *c) cleanConnectionLists(); - c->prev = &(QObjectPrivate::get(c->receiver)->senders); + QObjectPrivate *rd = QObjectPrivate::get(c->receiver); + rd->ensureConnectionData(); + + c->prev = &(rd->connections.load()->senders); c->next = *c->prev; *c->prev = c; if (c->next) @@ -385,11 +353,11 @@ void QObjectPrivate::addConnection(int signal, Connection *c) void QObjectPrivate::cleanConnectionLists() { - if (connectionLists->dirty && !connectionLists->inUse) { + ConnectionData *cd = connections.load(); + if (cd->dirty && !cd->inUse) { // remove broken connections - for (int signal = -1; signal < connectionLists->count(); ++signal) { - QObjectPrivate::ConnectionList &connectionList = - (*connectionLists)[signal]; + for (int signal = -1; signal < cd->signalVector.count(); ++signal) { + ConnectionList &connectionList = cd->connectionsForSignal(signal); // Set to the last entry in the connection list that was *not* // deleted. This is needed to update the list's last pointer @@ -415,7 +383,7 @@ void QObjectPrivate::cleanConnectionLists() // As conectionList.last could equal last, this could be a noop connectionList.last = last; } - connectionLists->dirty = false; + cd->dirty = false; } } @@ -430,14 +398,15 @@ bool QObjectPrivate::isSignalConnected(uint signalIndex, bool checkDeclarative) if (checkDeclarative && isDeclarativeSignalConnected(signalIndex)) return true; - if (!connectionLists) + ConnectionData *cd = connections.load(); + if (!cd) return false; - if (connectionLists->allsignals.first) + if (cd->allsignals.first) return true; - if (signalIndex < uint(connectionLists->count())) { - const QObjectPrivate::Connection *c = connectionLists->at(signalIndex).first; + if (signalIndex < uint(cd->signalVector.count())) { + const QObjectPrivate::Connection *c = cd->signalVector.at(signalIndex).first; while (c) { if (c->receiver) return true; @@ -905,60 +874,51 @@ QObject::~QObject() } } - if (d->currentSender) { - d->currentSender->receiverDeleted(); - d->currentSender = nullptr; - } + QObjectPrivate::ConnectionData *cd = d->connections.load(); + if (cd) { + if (cd->currentSender) { + cd->currentSender->receiverDeleted(); + cd->currentSender = nullptr; + } - if (d->connectionLists || d->senders) { QMutex *signalSlotMutex = signalSlotLock(this); QMutexLocker locker(signalSlotMutex); + ++cd->inUse; // disconnect all receivers - if (d->connectionLists) { - ++d->connectionLists->inUse; - int connectionListsCount = d->connectionLists->count(); - for (int signal = -1; signal < connectionListsCount; ++signal) { - QObjectPrivate::ConnectionList &connectionList = - (*d->connectionLists)[signal]; - - while (QObjectPrivate::Connection *c = connectionList.first) { - if (!c->receiver) { - connectionList.first = c->nextConnectionList; - c->deref(); - continue; - } - - QMutex *m = signalSlotLock(c->receiver); - bool needToUnlock = QOrderedMutexLocker::relock(signalSlotMutex, m); - - if (c->receiver) { - *c->prev = c->next; - if (c->next) c->next->prev = c->prev; - } - c->receiver = 0; - if (needToUnlock) - m->unlock(); + int receiverCount = cd->signalVector.count(); + for (int signal = -1; signal < receiverCount; ++signal) { + QObjectPrivate::ConnectionList &connectionList = cd->connectionsForSignal(signal); + while (QObjectPrivate::Connection *c = connectionList.first) { + if (!c->receiver) { connectionList.first = c->nextConnectionList; - - // The destroy operation must happen outside the lock - if (c->isSlotObject) { - c->isSlotObject = false; - locker.unlock(); - c->slotObj->destroyIfLastRef(); - locker.relock(); - } c->deref(); + continue; } - } - if (!--d->connectionLists->inUse) { - delete d->connectionLists; - } else { - d->connectionLists->orphaned = true; + QMutex *m = signalSlotLock(c->receiver); + bool needToUnlock = QOrderedMutexLocker::relock(signalSlotMutex, m); + + if (c->receiver) { + *c->prev = c->next; + if (c->next) c->next->prev = c->prev; + } + c->receiver = 0; + if (needToUnlock) + m->unlock(); + + connectionList.first = c->nextConnectionList; + + // The destroy operation must happen outside the lock + if (c->isSlotObject) { + c->isSlotObject = false; + locker.unlock(); + c->slotObj->destroyIfLastRef(); + locker.relock(); + } + c->deref(); } - d->connectionLists = 0; } /* Disconnect all senders: @@ -970,8 +930,9 @@ QObject::~QObject() * thread. That's why we set node->prev to &node, that way, if node is destroyed, node will * be updated. */ - QObjectPrivate::Connection *node = d->senders; + QObjectPrivate::Connection *node = cd->senders; while (node) { + Q_ASSERT(node->receiver); QObject *sender = node->sender; // Send disconnectNotify before removing the connection from sender's connection list. // This ensures any eventual destructor of sender will block on getting receiver's lock @@ -988,9 +949,9 @@ QObject::~QObject() continue; } node->receiver = 0; - QObjectConnectionListVector *senderLists = sender->d_func()->connectionLists; - if (senderLists) - senderLists->dirty = true; + QObjectPrivate::ConnectionData *senderData = sender->d_func()->connections; + if (senderData) + senderData->dirty = true; QtPrivate::QSlotObjectBase *slotObj = nullptr; if (node->isSlotObject) { @@ -1010,6 +971,13 @@ QObject::~QObject() locker.relock(); } } + + if (!--cd->inUse) { + delete cd; + } else { + cd->orphaned = true; + } + d->connections.store(nullptr); } if (!d->children.isEmpty()) @@ -1239,6 +1207,10 @@ bool QObject::event(QEvent *e) { QMetaCallEvent *mce = static_cast(e); + if (!d_func()->connections.load()) { + QMutexLocker locker(signalSlotLock(this)); + d_func()->ensureConnectionData(); + } QObjectPrivate::Sender sender(this, const_cast(mce->sender()), mce->signalId()); mce->placeMetaCall(this); @@ -1543,9 +1515,10 @@ void QObjectPrivate::setThreadData_helper(QThreadData *currentData, QThreadData } // the current emitting thread shouldn't restore currentSender after calling moveToThread() - if (currentSender) { - currentSender->receiverDeleted(); - currentSender = nullptr; + ConnectionData *cd = connections.load(); + if (cd && cd->currentSender) { + cd->currentSender->receiverDeleted(); + cd->currentSender = nullptr; } // set new thread data @@ -2354,12 +2327,13 @@ QObject *QObject::sender() const Q_D(const QObject); QMutexLocker locker(signalSlotLock(this)); - if (!d->currentSender) - return 0; + QObjectPrivate::ConnectionData *cd = d->connections.load(); + if (!cd || !cd->currentSender) + return nullptr; - for (QObjectPrivate::Connection *c = d->senders; c; c = c->next) { - if (c->sender == d->currentSender->sender) - return d->currentSender->sender; + for (QObjectPrivate::Connection *c = cd->senders; c; c = c->next) { + if (c->sender == cd->currentSender->sender) + return cd->currentSender->sender; } return 0; @@ -2395,13 +2369,14 @@ int QObject::senderSignalIndex() const Q_D(const QObject); QMutexLocker locker(signalSlotLock(this)); - if (!d->currentSender) + QObjectPrivate::ConnectionData *cd = d->connections.load(); + if (!cd || !cd->currentSender) return -1; - for (QObjectPrivate::Connection *c = d->senders; c; c = c->next) { - if (c->sender == d->currentSender->sender) { + for (QObjectPrivate::Connection *c = cd->senders; c; c = c->next) { + if (c->sender == cd->currentSender->sender) { // Convert from signal range to method range - return QMetaObjectPrivate::signal(c->sender->metaObject(), d->currentSender->signal).methodIndex(); + return QMetaObjectPrivate::signal(c->sender->metaObject(), cd->currentSender->signal).methodIndex(); } } @@ -2433,7 +2408,8 @@ int QObject::receivers(const char *signal) const { Q_D(const QObject); int receivers = 0; - if (signal) { + QObjectPrivate::ConnectionData *cd = d->connections.load(); + if (signal && cd) { QByteArray signal_name = QMetaObject::normalizedSignature(signal); signal = signal_name; #ifndef QT_NO_DEBUG @@ -2458,14 +2434,12 @@ int QObject::receivers(const char *signal) const } QMutexLocker locker(signalSlotLock(this)); - if (d->connectionLists) { - if (signal_index < d->connectionLists->count()) { - const QObjectPrivate::Connection *c = - d->connectionLists->at(signal_index).first; - while (c) { - receivers += c->receiver ? 1 : 0; - c = c->nextConnectionList; - } + if (signal_index < cd->signalVector.count()) { + const QObjectPrivate::Connection *c = + cd->signalVector.at(signal_index).first; + while (c) { + receivers += c->receiver ? 1 : 0; + c = c->nextConnectionList; } } } @@ -3269,23 +3243,21 @@ QObjectPrivate::Connection *QMetaObjectPrivate::connect(const QObject *sender, int method_offset = rmeta ? rmeta->methodOffset() : 0; Q_ASSERT(!rmeta || QMetaObjectPrivate::get(rmeta)->revision >= 6); - QObjectPrivate::StaticMetaCallFunction callFunction = - rmeta ? rmeta->d.static_metacall : 0; + QObjectPrivate::StaticMetaCallFunction callFunction = rmeta ? rmeta->d.static_metacall : nullptr; QOrderedMutexLocker locker(signalSlotLock(sender), signalSlotLock(receiver)); - if (type & Qt::UniqueConnection) { - QObjectConnectionListVector *connectionLists = QObjectPrivate::get(s)->connectionLists; - if (connectionLists && connectionLists->count() > signal_index) { - const QObjectPrivate::Connection *c2 = - (*connectionLists)[signal_index].first; + QObjectPrivate::ConnectionData *scd = QObjectPrivate::get(s)->connections.load(); + if (type & Qt::UniqueConnection && scd) { + if (scd->signalVector.count() > signal_index) { + const QObjectPrivate::Connection *c2 = scd->signalVector.at(signal_index).first; int method_index_absolute = method_index + method_offset; while (c2) { if (!c2->isSlotObject && c2->receiver == receiver && c2->method() == method_index_absolute) - return 0; + return nullptr; c2 = c2->nextConnectionList; } } @@ -3409,37 +3381,35 @@ bool QMetaObjectPrivate::disconnect(const QObject *sender, QMutex *senderMutex = signalSlotLock(sender); QMutexLocker locker(senderMutex); - QObjectConnectionListVector *connectionLists = QObjectPrivate::get(s)->connectionLists; - if (!connectionLists) + QObjectPrivate::ConnectionData *scd = QObjectPrivate::get(s)->connections.load(); + if (!scd) return false; - // prevent incoming connections changing the connectionLists while unlocked - ++connectionLists->inUse; + // prevent incoming connections changing the connections->receivers while unlocked + ++scd->inUse; bool success = false; if (signal_index < 0) { // remove from all connection lists - for (int sig_index = -1; sig_index < connectionLists->count(); ++sig_index) { - QObjectPrivate::Connection *c = - (*connectionLists)[sig_index].first; + for (int sig_index = -1; sig_index < scd->signalVector.count(); ++sig_index) { + QObjectPrivate::Connection *c = scd->connectionsForSignal(sig_index).first; if (disconnectHelper(c, receiver, method_index, slot, senderMutex, disconnectType)) { success = true; - connectionLists->dirty = true; + scd->dirty = true; } } - } else if (signal_index < connectionLists->count()) { - QObjectPrivate::Connection *c = - (*connectionLists)[signal_index].first; + } else if (signal_index < scd->signalVector.count()) { + QObjectPrivate::Connection *c = scd->signalVector.at(signal_index).first; if (disconnectHelper(c, receiver, method_index, slot, senderMutex, disconnectType)) { success = true; - connectionLists->dirty = true; + scd->dirty = true; } } - --connectionLists->inUse; - Q_ASSERT(connectionLists->inUse >= 0); - if (connectionLists->orphaned && !connectionLists->inUse) - delete connectionLists; + --scd->inUse; + Q_ASSERT(scd->inUse >= 0); + if (scd->orphaned && !scd->inUse) + delete scd; locker.unlock(); if (success) { @@ -3651,35 +3621,36 @@ void doActivate(QObject *sender, int signal_index, void **argv) { QMutexLocker locker(signalSlotLock(sender)); - struct ConnectionListsRef { - QObjectConnectionListVector *connectionLists; - ConnectionListsRef(QObjectConnectionListVector *connectionLists) : connectionLists(connectionLists) + struct ConnectionDataRef { + QObjectPrivate::ConnectionData *connections; + ConnectionDataRef(QObjectPrivate::ConnectionData *connections) : connections(connections) { - if (connectionLists) - ++connectionLists->inUse; + if (connections) + ++connections->inUse; } - ~ConnectionListsRef() + ~ConnectionDataRef() { - if (!connectionLists) + if (!connections) return; - --connectionLists->inUse; - Q_ASSERT(connectionLists->inUse >= 0); - if (connectionLists->orphaned) { - if (!connectionLists->inUse) - delete connectionLists; + --connections->inUse; + Q_ASSERT(connections->inUse >= 0); + if (connections->orphaned) { + if (!connections->inUse) + delete connections; } } - QObjectConnectionListVector *operator->() const { return connectionLists; } + QObjectPrivate::ConnectionData *operator->() const { return connections; } }; - ConnectionListsRef connectionLists = sp->connectionLists; + Q_ASSERT(sp->connections.load()); + ConnectionDataRef connections = sp->connections.load(); const QObjectPrivate::ConnectionList *list; - if (signal_index < connectionLists->count()) - list = &connectionLists->at(signal_index); + if (signal_index < connections->signalVector.count()) + list = &connections->signalVector.at(signal_index); else - list = &connectionLists->allsignals; + list = &connections->allsignals; Qt::HANDLE currentThreadId = QThread::currentThreadId(); @@ -3773,15 +3744,15 @@ void doActivate(QObject *sender, int signal_index, void **argv) locker.relock(); } - if (connectionLists->orphaned) + if (connections->orphaned) break; } while (c != last && (c = c->nextConnectionList) != 0); - if (connectionLists->orphaned) + if (connections->orphaned) break; - } while (list != &connectionLists->allsignals && + } while (list != &connections->allsignals && //start over for all signals; - ((list = &connectionLists->allsignals), true)); + ((list = &connections->allsignals), true)); } @@ -3832,7 +3803,7 @@ void QMetaObject::activate(QObject *sender, int signal_index, void **argv) /*! \internal - Returns the signal index used in the internal connectionLists vector. + Returns the signal index used in the internal connections->receivers vector. It is different from QMetaObject::indexOfSignal(): indexOfSignal is the same as indexOfMethod while QObjectPrivate::signalIndex is smaller because it doesn't give index to slots. @@ -4077,14 +4048,14 @@ void QObject::dumpObjectInfo() const // first, look for connections where this object is the sender qDebug(" SIGNALS OUT"); - if (d->connectionLists) { - for (int signal_index = 0; signal_index < d->connectionLists->count(); ++signal_index) { + QObjectPrivate::ConnectionData *cd = d->connections.load(); + if (cd && cd->signalVector.count()) { + for (int signal_index = 0; signal_index < cd->signalVector.count(); ++signal_index) { const QMetaMethod signal = QMetaObjectPrivate::signal(metaObject(), signal_index); qDebug(" signal: %s", signal.methodSignature().constData()); // receivers - const QObjectPrivate::Connection *c = - d->connectionLists->at(signal_index).first; + const QObjectPrivate::Connection *c = cd->signalVector.at(signal_index).first; while (c) { if (!c->receiver) { qDebug(" "); @@ -4112,8 +4083,8 @@ void QObject::dumpObjectInfo() const // now look for connections where this object is the receiver qDebug(" SIGNALS IN"); - if (d->senders) { - for (QObjectPrivate::Connection *s = d->senders; s; s = s->next) { + if (cd && cd->senders) { + for (QObjectPrivate::Connection *s = cd->senders; s; s = s->next) { QByteArray slotName = QByteArrayLiteral(""); if (!s->isSlotObject) { const QMetaMethod slot = metaObject()->method(s->method()); @@ -4848,11 +4819,10 @@ QMetaObject::Connection QObjectPrivate::connectImpl(const QObject *sender, int s QOrderedMutexLocker locker(signalSlotLock(sender), signalSlotLock(receiver)); - if (type & Qt::UniqueConnection && slot) { - QObjectConnectionListVector *connectionLists = QObjectPrivate::get(s)->connectionLists; - if (connectionLists && connectionLists->count() > signal_index) { - const QObjectPrivate::Connection *c2 = - (*connectionLists)[signal_index].first; + if (type & Qt::UniqueConnection && slot && QObjectPrivate::get(s)->connections.load()) { + QObjectPrivate::ConnectionData *connections = QObjectPrivate::get(s)->connections.load(); + if (connections->signalVector.count() > signal_index) { + const QObjectPrivate::Connection *c2 = connections->signalVector.at(signal_index).first; while (c2) { if (c2->receiver == receiver && c2->isSlotObject && c2->slotObj->compare(slot)) { @@ -4909,14 +4879,14 @@ bool QObject::disconnect(const QMetaObject::Connection &connection) { QOrderedMutexLocker locker(senderMutex, receiverMutex); - QObjectConnectionListVector *connectionLists = QObjectPrivate::get(c->sender)->connectionLists; - Q_ASSERT(connectionLists); - connectionLists->dirty = true; + QObjectPrivate::ConnectionData *connections = QObjectPrivate::get(c->sender)->connections.load(); + Q_ASSERT(connections); + connections->dirty = true; *c->prev = c->next; if (c->next) c->next->prev = c->prev; - c->receiver = 0; + c->receiver = nullptr; } // destroy the QSlotObject, if possible @@ -4928,7 +4898,7 @@ bool QObject::disconnect(const QMetaObject::Connection &connection) c->sender->disconnectNotify(QMetaObjectPrivate::signal(c->sender->metaObject(), c->signal_index)); - const_cast(connection).d_ptr = 0; + const_cast(connection).d_ptr = nullptr; c->deref(); // has been removed from the QMetaObject::Connection object return true; diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index ab20064c65..64998797ac 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -171,14 +171,15 @@ public: : receiver(receiver), sender(sender), signal(signal) { if (receiver) { - previous = receiver->d_func()->currentSender; - receiver->d_func()->currentSender = this; + ConnectionData *cd = receiver->d_func()->connections.load(); + previous = cd->currentSender; + cd->currentSender = this; } } ~Sender() { if (receiver) - receiver->d_func()->currentSender = previous; + receiver->d_func()->connections.load()->currentSender = previous; } void receiverDeleted() { @@ -194,6 +195,34 @@ public: int signal; }; + /* + This contains the all connections from and to an object. + + The signalVector contains the lists of connections for a given signal. The index in the vector correspond + to the signal index. The signal index is the one returned by QObjectPrivate::signalIndex (not + QMetaObject::indexOfSignal). allsignals contains a list of special connections that will get invoked on + any signal emission. This is done by connecting to signal index -1. + + This vector is protected by the object mutex (signalSlotLock()) + + Each Connection is also part of a 'senders' linked list. This one contains all connections connected + to a slot in this object. The mutex of the receiver must be locked when touching the pointers of this + linked list. + */ + struct ConnectionData { + bool orphaned = false; //the QObject owner of this vector has been destroyed while the vector was inUse + bool dirty = false; //some Connection have been disconnected (their receiver is 0) but not removed from the list yet + int inUse = 0; //number of functions that are currently accessing this object or its connections + ConnectionList allsignals; + QVector signalVector; + Connection *senders = nullptr; + Sender *currentSender = nullptr; // object currently activating the object + + ConnectionList &connectionsForSignal(int signal) + { + return signal < 0 ? allsignals : signalVector[signal]; + } + }; QObjectPrivate(int version = QObjectPrivateVersion); virtual ~QObjectPrivate(); @@ -240,14 +269,18 @@ public: const int *types, const QMetaObject *senderMetaObject); static QMetaObject::Connection connect(const QObject *sender, int signal_index, QtPrivate::QSlotObjectBase *slotObj, Qt::ConnectionType type); static bool disconnect(const QObject *sender, int signal_index, void **slot); + + void ensureConnectionData() + { + if (connections.load()) + return; + connections.store(new ConnectionData); + } public: ExtraData *extraData; // extra data set by the user QThreadData *threadData; // id of the thread that owns the object - QObjectConnectionListVector *connectionLists; - - Connection *senders; // linked list of connections connected to this object - Sender *currentSender; // object currently activating the object + QAtomicPointer connections; union { QObject *currentChildBeingDeleted; // should only be used when QObjectData::isDeletingChildren is set diff --git a/tests/auto/other/toolsupport/tst_toolsupport.cpp b/tests/auto/other/toolsupport/tst_toolsupport.cpp index 27bc6ba646..8c129adaf3 100644 --- a/tests/auto/other/toolsupport/tst_toolsupport.cpp +++ b/tests/auto/other/toolsupport/tst_toolsupport.cpp @@ -126,9 +126,9 @@ void tst_toolsupport::offsets_data() #ifdef Q_PROCESSOR_X86 // x86 32-bit has weird alignment rules. Refer to QtPrivate::AlignOf in // qglobal.h for more details. - data << 160 << 240; + data << 152 << 224; #else - data << 164 << 240; + data << 156 << 224; #endif } #endif From 0e534bf8b704b8ae24b87a9b1dcb5cd829c9dd2f Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 9 Jan 2019 09:48:59 +0100 Subject: [PATCH 011/292] Replace the ConnectionData::inUse int with a proper refcount The main difference is that QObject itself also holds on reference on the structure. Also rename the orphaned flag to objectDeleted for clarity. Change-Id: Ief9b9ff9c8b9cc3630dcfd29806ed24cd07150e4 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/kernel/qobject.cpp | 78 +++++++++++----------------------- src/corelib/kernel/qobject_p.h | 16 +++++-- 2 files changed, 38 insertions(+), 56 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index b8e973a0a3..c3271b2c35 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -354,7 +354,7 @@ void QObjectPrivate::addConnection(int signal, Connection *c) void QObjectPrivate::cleanConnectionLists() { ConnectionData *cd = connections.load(); - if (cd->dirty && !cd->inUse) { + if (cd->dirty && cd->ref == 1) { // remove broken connections for (int signal = -1; signal < cd->signalVector.count(); ++signal) { ConnectionList &connectionList = cd->connectionsForSignal(signal); @@ -883,7 +883,6 @@ QObject::~QObject() QMutex *signalSlotMutex = signalSlotLock(this); QMutexLocker locker(signalSlotMutex); - ++cd->inUse; // disconnect all receivers int receiverCount = cd->signalVector.count(); @@ -949,7 +948,7 @@ QObject::~QObject() continue; } node->receiver = 0; - QObjectPrivate::ConnectionData *senderData = sender->d_func()->connections; + QObjectPrivate::ConnectionData *senderData = sender->d_func()->connections.load(); if (senderData) senderData->dirty = true; @@ -972,13 +971,11 @@ QObject::~QObject() } } - if (!--cd->inUse) { - delete cd; - } else { - cd->orphaned = true; - } - d->connections.store(nullptr); + cd->objectDeleted = true; } + if (cd && !cd->ref.deref()) + delete cd; + d->connections.store(nullptr); if (!d->children.isEmpty()) d->deleteChildren(); @@ -3385,32 +3382,29 @@ bool QMetaObjectPrivate::disconnect(const QObject *sender, if (!scd) return false; - // prevent incoming connections changing the connections->receivers while unlocked - ++scd->inUse; - bool success = false; - if (signal_index < 0) { - // remove from all connection lists - for (int sig_index = -1; sig_index < scd->signalVector.count(); ++sig_index) { - QObjectPrivate::Connection *c = scd->connectionsForSignal(sig_index).first; + { + // prevent incoming connections changing the connections->receivers while unlocked + QObjectPrivate::ConnectionDataPointer connections(scd); + + if (signal_index < 0) { + // remove from all connection lists + for (int sig_index = -1; sig_index < scd->signalVector.count(); ++sig_index) { + QObjectPrivate::Connection *c = scd->connectionsForSignal(sig_index).first; + if (disconnectHelper(c, receiver, method_index, slot, senderMutex, disconnectType)) { + success = true; + scd->dirty = true; + } + } + } else if (signal_index < scd->signalVector.count()) { + QObjectPrivate::Connection *c = scd->signalVector.at(signal_index).first; if (disconnectHelper(c, receiver, method_index, slot, senderMutex, disconnectType)) { success = true; scd->dirty = true; } } - } else if (signal_index < scd->signalVector.count()) { - QObjectPrivate::Connection *c = scd->signalVector.at(signal_index).first; - if (disconnectHelper(c, receiver, method_index, slot, senderMutex, disconnectType)) { - success = true; - scd->dirty = true; - } } - --scd->inUse; - Q_ASSERT(scd->inUse >= 0); - if (scd->orphaned && !scd->inUse) - delete scd; - locker.unlock(); if (success) { QMetaMethod smethod = QMetaObjectPrivate::signal(smeta, signal_index); @@ -3621,30 +3615,8 @@ void doActivate(QObject *sender, int signal_index, void **argv) { QMutexLocker locker(signalSlotLock(sender)); - struct ConnectionDataRef { - QObjectPrivate::ConnectionData *connections; - ConnectionDataRef(QObjectPrivate::ConnectionData *connections) : connections(connections) - { - if (connections) - ++connections->inUse; - } - ~ConnectionDataRef() - { - if (!connections) - return; - - --connections->inUse; - Q_ASSERT(connections->inUse >= 0); - if (connections->orphaned) { - if (!connections->inUse) - delete connections; - } - } - - QObjectPrivate::ConnectionData *operator->() const { return connections; } - }; - Q_ASSERT(sp->connections.load()); - ConnectionDataRef connections = sp->connections.load(); + Q_ASSERT(sp->connections); + QObjectPrivate::ConnectionDataPointer connections(sp->connections.load()); const QObjectPrivate::ConnectionList *list; if (signal_index < connections->signalVector.count()) @@ -3744,11 +3716,11 @@ void doActivate(QObject *sender, int signal_index, void **argv) locker.relock(); } - if (connections->orphaned) + if (connections->objectDeleted) break; } while (c != last && (c = c->nextConnectionList) != 0); - if (connections->orphaned) + if (connections->objectDeleted) break; } while (list != &connections->allsignals && //start over for all signals; diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 64998797ac..823c7a195a 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -210,9 +210,16 @@ public: linked list. */ struct ConnectionData { - bool orphaned = false; //the QObject owner of this vector has been destroyed while the vector was inUse + bool objectDeleted = false; //the QObject owner of this vector has been destroyed while the vector was inUse + struct Ref { + int _ref = 0; + void ref() { ++_ref; } + int deref() { return --_ref; } + operator int() const { return _ref; } + }; + + Ref ref; bool dirty = false; //some Connection have been disconnected (their receiver is 0) but not removed from the list yet - int inUse = 0; //number of functions that are currently accessing this object or its connections ConnectionList allsignals; QVector signalVector; Connection *senders = nullptr; @@ -274,12 +281,15 @@ public: { if (connections.load()) return; - connections.store(new ConnectionData); + ConnectionData *cd = new ConnectionData; + cd->ref.ref(); + connections.store(cd); } public: ExtraData *extraData; // extra data set by the user QThreadData *threadData; // id of the thread that owns the object + using ConnectionDataPointer = QExplicitlySharedDataPointer; QAtomicPointer connections; union { From aea500d5d76864bb1a3918e338ca6806e1766e41 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 9 Jan 2019 11:00:01 +0100 Subject: [PATCH 012/292] Use QBasicMutex instead of QMutex in the signalSlockLock() Add a simple private QBasicMutexLocker class, and let the QOrderedMutexLocker operate on a QBasicMutex. This allows the compiler to inline more things when handling connections and speeds up activate() a bit more. without change with change string based connect: 3621 3368 pointer based connect: 4341 3919 not connected: 433 437 disconnected: 551 538 Change-Id: If979337891178aaeb0b3340b6d4f68b6f86b0260 Reviewed-by: Qt CI Bot Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/kernel/qmetaobject_p.h | 4 +- src/corelib/kernel/qobject.cpp | 47 ++++++++-------- src/corelib/thread/qorderedmutexlocker_p.h | 62 +++++++++++++++++++--- 3 files changed, 81 insertions(+), 32 deletions(-) diff --git a/src/corelib/kernel/qmetaobject_p.h b/src/corelib/kernel/qmetaobject_p.h index 522bd78e42..5b412b5140 100644 --- a/src/corelib/kernel/qmetaobject_p.h +++ b/src/corelib/kernel/qmetaobject_p.h @@ -54,6 +54,7 @@ #include #include +#include #ifndef QT_NO_QOBJECT #include // For QObjectPrivate::Connection #endif @@ -168,7 +169,6 @@ Q_DECLARE_TYPEINFO(QArgumentType, Q_MOVABLE_TYPE); typedef QVarLengthArray QArgumentTypeArray; class QMetaMethodPrivate; -class QMutex; struct QMetaObjectPrivate { @@ -234,7 +234,7 @@ struct QMetaObjectPrivate DisconnectType = DisconnectAll); static inline bool disconnectHelper(QObjectPrivate::Connection *c, const QObject *receiver, int method_index, void **slot, - QMutex *senderMutex, DisconnectType = DisconnectAll); + QBasicMutex *senderMutex, DisconnectType = DisconnectAll); #endif }; diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index c3271b2c35..3db43ba1c4 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -152,10 +152,9 @@ static QBasicMutex _q_ObjectMutexPool[131]; * \internal * mutex to be locked when accessing the connectionlists or the senders list */ -static inline QMutex *signalSlotLock(const QObject *o) +static inline QBasicMutex *signalSlotLock(const QObject *o) { - return static_cast(&_q_ObjectMutexPool[ - uint(quintptr(o)) % sizeof(_q_ObjectMutexPool)/sizeof(QBasicMutex)]); + return &_q_ObjectMutexPool[uint(quintptr(o)) % sizeof(_q_ObjectMutexPool)/sizeof(QBasicMutex)]; } #if QT_VERSION < 0x60000 @@ -265,7 +264,7 @@ bool QObjectPrivate::isSender(const QObject *receiver, const char *signal) const ConnectionData *cd = connections.load(); if (signal_index < 0 || !cd) return false; - QMutexLocker locker(signalSlotLock(q)); + QBasicMutexLocker locker(signalSlotLock(q)); if (signal_index < cd->signalVector.count()) { const QObjectPrivate::Connection *c = cd->signalVector.at(signal_index).first; @@ -287,7 +286,7 @@ QObjectList QObjectPrivate::receiverList(const char *signal) const ConnectionData *cd = connections.load(); if (signal_index < 0 || !cd) return returnValue; - QMutexLocker locker(signalSlotLock(q)); + QBasicMutexLocker locker(signalSlotLock(q)); if (signal_index < cd->signalVector.count()) { const QObjectPrivate::Connection *c = cd->signalVector.at(signal_index).first; @@ -306,7 +305,7 @@ QObjectList QObjectPrivate::senderList() const QObjectList returnValue; ConnectionData *cd = connections.load(); if (cd) { - QMutexLocker locker(signalSlotLock(q_func())); + QBasicMutexLocker locker(signalSlotLock(q_func())); for (Connection *c = cd->senders; c; c = c->next) returnValue << c->sender; } @@ -881,8 +880,8 @@ QObject::~QObject() cd->currentSender = nullptr; } - QMutex *signalSlotMutex = signalSlotLock(this); - QMutexLocker locker(signalSlotMutex); + QBasicMutex *signalSlotMutex = signalSlotLock(this); + QBasicMutexLocker locker(signalSlotMutex); // disconnect all receivers int receiverCount = cd->signalVector.count(); @@ -896,7 +895,7 @@ QObject::~QObject() continue; } - QMutex *m = signalSlotLock(c->receiver); + QBasicMutex *m = signalSlotLock(c->receiver); bool needToUnlock = QOrderedMutexLocker::relock(signalSlotMutex, m); if (c->receiver) { @@ -937,7 +936,7 @@ QObject::~QObject() // This ensures any eventual destructor of sender will block on getting receiver's lock // and not finish until we release it. sender->disconnectNotify(QMetaObjectPrivate::signal(sender->metaObject(), node->signal_index)); - QMutex *m = signalSlotLock(sender); + QBasicMutex *m = signalSlotLock(sender); node->prev = &node; bool needToUnlock = QOrderedMutexLocker::relock(signalSlotMutex, m); //the node has maybe been removed while the mutex was unlocked in relock? @@ -1205,7 +1204,7 @@ bool QObject::event(QEvent *e) QMetaCallEvent *mce = static_cast(e); if (!d_func()->connections.load()) { - QMutexLocker locker(signalSlotLock(this)); + QBasicMutexLocker locker(signalSlotLock(this)); d_func()->ensureConnectionData(); } QObjectPrivate::Sender sender(this, const_cast(mce->sender()), mce->signalId()); @@ -2323,7 +2322,7 @@ QObject *QObject::sender() const { Q_D(const QObject); - QMutexLocker locker(signalSlotLock(this)); + QBasicMutexLocker locker(signalSlotLock(this)); QObjectPrivate::ConnectionData *cd = d->connections.load(); if (!cd || !cd->currentSender) return nullptr; @@ -2365,7 +2364,7 @@ int QObject::senderSignalIndex() const { Q_D(const QObject); - QMutexLocker locker(signalSlotLock(this)); + QBasicMutexLocker locker(signalSlotLock(this)); QObjectPrivate::ConnectionData *cd = d->connections.load(); if (!cd || !cd->currentSender) return -1; @@ -2430,7 +2429,7 @@ int QObject::receivers(const char *signal) const signal_index); } - QMutexLocker locker(signalSlotLock(this)); + QBasicMutexLocker locker(signalSlotLock(this)); if (signal_index < cd->signalVector.count()) { const QObjectPrivate::Connection *c = cd->signalVector.at(signal_index).first; @@ -2476,7 +2475,7 @@ bool QObject::isSignalConnected(const QMetaMethod &signal) const signalIndex += QMetaObjectPrivate::signalOffset(signal.mobj); - QMutexLocker locker(signalSlotLock(this)); + QBasicMutexLocker locker(signalSlotLock(this)); return d->isSignalConnected(signalIndex, true); } @@ -3318,7 +3317,7 @@ bool QMetaObject::disconnectOne(const QObject *sender, int signal_index, */ bool QMetaObjectPrivate::disconnectHelper(QObjectPrivate::Connection *c, const QObject *receiver, int method_index, void **slot, - QMutex *senderMutex, DisconnectType disconnectType) + QBasicMutex *senderMutex, DisconnectType disconnectType) { bool success = false; while (c) { @@ -3327,7 +3326,7 @@ bool QMetaObjectPrivate::disconnectHelper(QObjectPrivate::Connection *c, && (method_index < 0 || (!c->isSlotObject && c->method() == method_index)) && (slot == 0 || (c->isSlotObject && c->slotObj->compare(slot)))))) { bool needToUnlock = false; - QMutex *receiverMutex = 0; + QBasicMutex *receiverMutex = nullptr; if (c->receiver) { receiverMutex = signalSlotLock(c->receiver); // need to relock this receiver and sender in the correct order @@ -3375,8 +3374,8 @@ bool QMetaObjectPrivate::disconnect(const QObject *sender, QObject *s = const_cast(sender); - QMutex *senderMutex = signalSlotLock(sender); - QMutexLocker locker(senderMutex); + QBasicMutex *senderMutex = signalSlotLock(sender); + QBasicMutexLocker locker(senderMutex); QObjectPrivate::ConnectionData *scd = QObjectPrivate::get(s)->connections.load(); if (!scd) @@ -3523,7 +3522,7 @@ void QMetaObject::connectSlotsByName(QObject *o) \a signal must be in the signal index range (see QObjectPrivate::signalIndex()). */ static void queued_activate(QObject *sender, int signal, QObjectPrivate::Connection *c, void **argv, - QMutexLocker &locker) + QBasicMutexLocker &locker) { const int *argumentTypes = c->argumentTypes.load(); if (!argumentTypes) { @@ -3614,7 +3613,7 @@ void doActivate(QObject *sender, int signal_index, void **argv) Q_TRACE(QMetaObject_activate_begin_signal, sender, signal_index); { - QMutexLocker locker(signalSlotLock(sender)); + QBasicMutexLocker locker(signalSlotLock(sender)); Q_ASSERT(sp->connections); QObjectPrivate::ConnectionDataPointer connections(sp->connections.load()); @@ -4015,7 +4014,7 @@ void QObject::dumpObjectInfo() const objectName().isEmpty() ? "unnamed" : objectName().toLocal8Bit().data()); Q_D(const QObject); - QMutexLocker locker(signalSlotLock(this)); + QBasicMutexLocker locker(signalSlotLock(this)); // first, look for connections where this object is the sender qDebug(" SIGNALS OUT"); @@ -4845,8 +4844,8 @@ bool QObject::disconnect(const QMetaObject::Connection &connection) if (!c || !c->receiver) return false; - QMutex *senderMutex = signalSlotLock(c->sender); - QMutex *receiverMutex = signalSlotLock(c->receiver); + QBasicMutex *senderMutex = signalSlotLock(c->sender); + QBasicMutex *receiverMutex = signalSlotLock(c->receiver); { QOrderedMutexLocker locker(senderMutex, receiverMutex); diff --git a/src/corelib/thread/qorderedmutexlocker_p.h b/src/corelib/thread/qorderedmutexlocker_p.h index ded102d32d..5b2c7ab112 100644 --- a/src/corelib/thread/qorderedmutexlocker_p.h +++ b/src/corelib/thread/qorderedmutexlocker_p.h @@ -58,6 +58,8 @@ QT_BEGIN_NAMESPACE +#if QT_CONFIG(thread) + /* Locks 2 mutexes in a defined order, avoiding a recursive lock if we're trying to lock the same mutex twice. @@ -65,9 +67,9 @@ QT_BEGIN_NAMESPACE class QOrderedMutexLocker { public: - QOrderedMutexLocker(QMutex *m1, QMutex *m2) - : mtx1((m1 == m2) ? m1 : (std::less()(m1, m2) ? m1 : m2)), - mtx2((m1 == m2) ? 0 : (std::less()(m1, m2) ? m2 : m1)), + QOrderedMutexLocker(QBasicMutex *m1, QBasicMutex *m2) + : mtx1((m1 == m2) ? m1 : (std::less()(m1, m2) ? m1 : m2)), + mtx2((m1 == m2) ? 0 : (std::less()(m1, m2) ? m2 : m1)), locked(false) { relock(); @@ -95,12 +97,12 @@ public: } } - static bool relock(QMutex *mtx1, QMutex *mtx2) + static bool relock(QBasicMutex *mtx1, QBasicMutex *mtx2) { // mtx1 is already locked, mtx2 not... do we need to unlock and relock? if (mtx1 == mtx2) return false; - if (std::less()(mtx1, mtx2)) { + if (std::less()(mtx1, mtx2)) { mtx2->lock(); return true; } @@ -113,10 +115,58 @@ public: } private: - QMutex *mtx1, *mtx2; + QBasicMutex *mtx1, *mtx2; bool locked; }; +class QBasicMutexLocker +{ +public: + inline explicit QBasicMutexLocker(QBasicMutex *m) QT_MUTEX_LOCK_NOEXCEPT + : m(m), isLocked(true) + { + m->lock(); + } + inline ~QBasicMutexLocker() { if (isLocked) unlock(); } + + inline void unlock() Q_DECL_NOTHROW + { + isLocked = false; + m->unlock(); + } + + inline void relock() QT_MUTEX_LOCK_NOEXCEPT + { + isLocked = true; + m->lock(); + } + +private: + Q_DISABLE_COPY(QBasicMutexLocker) + + QBasicMutex *m; + bool isLocked; +}; + +#else + +class QOrderedMutexLocker +{ +public: + QOrderedMutexLocker(QBasicMutex *, QBasicMutex *) {} + ~QOrderedMutexLocker() {} + + void relock() {} + void unlock() {} + + static bool relock(QBasicMutex *, QBasicMutex *) {} +}; + +using QBasicMutexLocker = QMutexLocker; + +#endif + + QT_END_NAMESPACE #endif From 484eec96f9b2235780119526faeb6d69536f509c Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sat, 19 Jan 2019 15:32:07 +0100 Subject: [PATCH 013/292] Add a couple of tests in QObject::tst_qobject For destructors of functor connected to signals Change-Id: I3f8b18fee7507f3cb72e36a2f9e6ef7f37dbeea1 Reviewed-by: Lars Knoll --- .../corelib/kernel/qobject/tst_qobject.cpp | 165 ++++++++++++++++++ 1 file changed, 165 insertions(+) diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index 31268c5cf3..b823ca2aab 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -154,6 +154,8 @@ private slots: void mutableFunctor(); void checkArgumentsForNarrowing(); void nullReceiver(); + void functorReferencesConnection(); + void disconnectDisconnects(); }; struct QObjectCreatedOnShutdown @@ -7487,6 +7489,169 @@ void tst_QObject::nullReceiver() QVERIFY(!connect(&o, SIGNAL(destroyed()), nullObj, SLOT(deleteLater()))); } +void tst_QObject::functorReferencesConnection() +{ + countedStructObjectsCount = 0; + QMetaObject::Connection globalCon; + { + GetSenderObject obj; + CountedStruct counted(&obj); + QCOMPARE(countedStructObjectsCount, 1); + auto c = QSharedPointer::create(); + int slotCalled = 0; + *c = connect(&obj, &GetSenderObject::aSignal, &obj, [&slotCalled, c, counted] { + QObject::disconnect(*c); + slotCalled++; + }); + globalCon = *c; // keep a handle to the connection somewhere; + QVERIFY(globalCon); + QCOMPARE(countedStructObjectsCount, 2); + obj.triggerSignal(); + QCOMPARE(slotCalled, 1); + QCOMPARE(countedStructObjectsCount, 1); + QVERIFY(!globalCon); + obj.triggerSignal(); + QCOMPARE(slotCalled, 1); + QCOMPARE(countedStructObjectsCount, 1); + } + QCOMPARE(countedStructObjectsCount, 0); + + { + GetSenderObject obj; + CountedStruct counted(&obj); + QCOMPARE(countedStructObjectsCount, 1); + auto *rec = new QObject; + int slotCalled = 0; + globalCon = connect(&obj, &GetSenderObject::aSignal, rec, [&slotCalled, rec, counted] { + delete rec; + slotCalled++; + }); + QCOMPARE(countedStructObjectsCount, 2); + obj.triggerSignal(); + QCOMPARE(slotCalled, 1); + QCOMPARE(countedStructObjectsCount, 1); + QVERIFY(!globalCon); + obj.triggerSignal(); + QCOMPARE(slotCalled, 1); + QCOMPARE(countedStructObjectsCount, 1); + } + QCOMPARE(countedStructObjectsCount, 0); + { + int slotCalled = 0; + QEventLoop eventLoop; + { + // Sender will be destroyed when the labda goes out of scope lambda, so it will exit the event loop + auto sender = QSharedPointer::create(); + connect(sender.data(), &QObject::destroyed, &eventLoop, &QEventLoop::quit, Qt::QueuedConnection); + globalCon = connect(sender.data(), &GetSenderObject::aSignal, this, [&slotCalled, sender, &globalCon, this] { + ++slotCalled; + // This signal will be connected, but should never be called as the sender will be destroyed before + auto c2 = connect(sender.data(), &GetSenderObject::aSignal, [] { QFAIL("Should not be called"); }); + QVERIFY(c2); + QVERIFY(QObject::disconnect(sender.data(), nullptr, this, nullptr)); + QVERIFY(!globalCon); // this connection has been disconnected + QVERIFY(c2); // sender should not have been deleted yet, only after the emission is done + }); + QMetaObject::invokeMethod(sender.data(), &GetSenderObject::triggerSignal, Qt::QueuedConnection); + QMetaObject::invokeMethod(sender.data(), &GetSenderObject::triggerSignal, Qt::QueuedConnection); + QMetaObject::invokeMethod(sender.data(), &GetSenderObject::triggerSignal, Qt::QueuedConnection); + } + eventLoop.exec(); + QCOMPARE(slotCalled, 1); + } + + { + GetSenderObject obj; + CountedStruct counted(&obj); + QCOMPARE(countedStructObjectsCount, 1); + auto c1 = QSharedPointer::create(); + auto c2 = QSharedPointer::create(); + int slot1Called = 0; + int slot3Called = 0; + *c1 = connect(&obj, &GetSenderObject::aSignal, &obj, [&slot1Called, &slot3Called, &obj, c1, c2, counted] { + auto c3 = connect(&obj, &GetSenderObject::aSignal, [counted, &slot3Called] { + slot3Called++; + }); + // top-level + the one in the 3 others lambdas + QCOMPARE(countedStructObjectsCount, 4); + QObject::disconnect(*c2); + // the one in the c2's lambda is gone + QCOMPARE(countedStructObjectsCount, 3); + slot1Called++; + }); + connect(&obj, &GetSenderObject::aSignal, [] {}); // just a dummy signal to fill the connection list + *c2 = connect(&obj, &GetSenderObject::aSignal, [counted, c2] { QFAIL("should not be called"); }); + QVERIFY(c1 && c2); + QCOMPARE(countedStructObjectsCount, 3); // top-level + c1 + c2 + obj.triggerSignal(); + QCOMPARE(slot1Called, 1); + QCOMPARE(slot3Called, 0); + QCOMPARE(countedStructObjectsCount, 3); // top-level + c1 + c3 + QObject::disconnect(*c1); + QCOMPARE(countedStructObjectsCount, 2); // top-level + c3 + obj.triggerSignal(); + QCOMPARE(slot1Called, 1); + QCOMPARE(slot3Called, 1); + } + { + struct DestroyEmit { + Q_DISABLE_COPY(DestroyEmit); + explicit DestroyEmit(SenderObject *obj) : obj(obj) {} + SenderObject *obj; + ~DestroyEmit() { + obj->emitSignal1(); + } + }; + SenderObject obj; + int slot1Called = 0; + int slot2Called = 0; + int slot3Called = 0; + auto c1 = QSharedPointer::create(); + auto de = QSharedPointer::create(&obj); + *c1 = connect(&obj, &SenderObject::signal1, [&slot1Called, &slot3Called, de, c1, &obj] { + connect(&obj, &SenderObject::signal1, [&slot3Called] { slot3Called++; }); + slot1Called++; + QObject::disconnect(*c1); + }); + de.clear(); + connect(&obj, &SenderObject::signal1, [&slot2Called] { slot2Called++; }); + obj.emitSignal1(); + QCOMPARE(slot1Called, 1); + QCOMPARE(slot2Called, 2); // because also called from ~DestroyEmit + QCOMPARE(slot3Called, 1); + } +} + +void tst_QObject::disconnectDisconnects() +{ + // Test what happens if the destructor of an functor slot also disconnects more slot; + + SenderObject s1; + QScopedPointer receiver(new QObject); + + auto s2 = QSharedPointer::create(); + QPointer s2_tracker = s2.data(); + int count = 0; + connect(&s1, &SenderObject::signal1, [&count] { count++; }); // α + connect(&s1, &SenderObject::signal1, receiver.data(), [s2] { QFAIL("!!"); }); // β + connect(s2.data(), &SenderObject::signal1, receiver.data(), [] { QFAIL("!!"); }); + connect(&s1, &SenderObject::signal2, receiver.data(), [] { QFAIL("!!"); }); + connect(s2.data(), &SenderObject::signal2, receiver.data(), [] { QFAIL("!!"); }); + connect(&s1, &SenderObject::signal1, [&count] { count++; }); // γ + connect(&s1, &SenderObject::signal2, [&count] { count++; }); // δ + s2.clear(); + + QVERIFY(s2_tracker); + receiver + .reset(); // this will delete the receiver which must also delete s2 as β is disconnected + QVERIFY(!s2_tracker); + // test that the data structures are still in order + s1.emitSignal1(); + QCOMPARE(count, 2); // α + γ + s1.emitSignal2(); + QCOMPARE(count, 3); // + δ +} + // Test for QtPrivate::HasQ_OBJECT_Macro Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro::Value); Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro::Value); From b179abc33b7111e889ca45f48f0ddd5c0182fa2e Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 29 Nov 2018 11:01:09 +0100 Subject: [PATCH 014/292] Remove old dead code Nothing references this, not even commented out debug code, and some functions doesn't even have implementations. Change-Id: I344de26a650b1180f0da78eaece5bd5688fdcd95 Reviewed-by: Laszlo Agocs --- src/gui/painting/qpaintengine_raster.cpp | 76 ---------------------- src/gui/painting/qpaintengine_raster_p.h | 20 ------ src/widgets/kernel/qwidgetbackingstore.cpp | 6 -- src/widgets/kernel/qwidgetbackingstore_p.h | 1 - 4 files changed, 103 deletions(-) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 0f5c7756ad..66af6e3de3 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -552,35 +552,6 @@ bool QRasterPaintEngine::end() return true; } -/*! - \internal -*/ -void QRasterPaintEngine::releaseBuffer() -{ - Q_D(QRasterPaintEngine); - d->rasterBuffer.reset(new QRasterBuffer); -} - -/*! - \internal -*/ -QSize QRasterPaintEngine::size() const -{ - Q_D(const QRasterPaintEngine); - return QSize(d->rasterBuffer->width(), d->rasterBuffer->height()); -} - -/*! - \internal -*/ -#ifndef QT_NO_DEBUG -void QRasterPaintEngine::saveBuffer(const QString &s) const -{ - Q_D(const QRasterPaintEngine); - d->rasterBuffer->bufferImage().save(s, "PNG"); -} -#endif - /*! \internal */ @@ -3845,11 +3816,6 @@ QImage::Format QRasterBuffer::prepare(QImage *image) return format; } -void QRasterBuffer::resetBuffer(int val) -{ - memset(m_buffer, val, m_height*bytes_per_line); -} - QClipData::QClipData(int height) { clipSpanHeight = height; @@ -4272,48 +4238,6 @@ static void qt_span_clip(int count, const QSpan *spans, void *userData) } } -#ifndef QT_NO_DEBUG -QImage QRasterBuffer::bufferImage() const -{ - QImage image(m_width, m_height, QImage::Format_ARGB32_Premultiplied); - - for (int y = 0; y < m_height; ++y) { - uint *span = (uint *)const_cast(this)->scanLine(y); - - for (int x=0; xwidth()); - int h = qMin(m_height, target->height()); - - for (int y=0; y(this)->scanLine(y); - QRgb *dest = (QRgb *) target->scanLine(y); - for (int x=0; x=0); Q_ASSERT(yscroll(tlwRect, dx, dy); } -void QWidgetBackingStore::releaseBuffer() -{ - if (store) - store->resize(QSize()); -} - /*! Prepares the window surface to paint a\ toClean region of the \a widget and updates the BeginPaintInfo struct accordingly. diff --git a/src/widgets/kernel/qwidgetbackingstore_p.h b/src/widgets/kernel/qwidgetbackingstore_p.h index 41469a04bb..a1846da44e 100644 --- a/src/widgets/kernel/qwidgetbackingstore_p.h +++ b/src/widgets/kernel/qwidgetbackingstore_p.h @@ -151,7 +151,6 @@ private: void doSync(); bool bltRect(const QRect &rect, int dx, int dy, QWidget *widget); - void releaseBuffer(); void beginPaint(QRegion &toClean, QWidget *widget, QBackingStore *backingStore, BeginPaintInfo *returnInfo, bool toCleanIsInTopLevelCoordinates = true); From e48b85408752725bd9e90f303354bcdd380b3448 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 22 Sep 2017 14:54:39 +0200 Subject: [PATCH 015/292] Simplify freetype rendering Switch to always using FT_Render_Glyph for all glyph types. Change-Id: I9427bbffd30a8d1ca92d7ab9a92df8761f6b89c3 Reviewed-by: Lars Knoll --- .../fontdatabases/freetype/qfontengine_ft.cpp | 326 ++++-------------- 1 file changed, 75 insertions(+), 251 deletions(-) diff --git a/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp b/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp index 381db1ed12..40db7dbac7 100644 --- a/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp +++ b/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp @@ -121,13 +121,12 @@ class QtFreetypeData { public: QtFreetypeData() - : library(0), hasPatentFreeLcdRendering(false) + : library(0) { } ~QtFreetypeData(); FT_Library library; QHash faces; - bool hasPatentFreeLcdRendering; }; QtFreetypeData::~QtFreetypeData() @@ -153,11 +152,6 @@ QtFreetypeData *qt_getFreetypeData() FT_Bool no_darkening = false; FT_Property_Set(freetypeData->library, "cff", "no-stem-darkening", &no_darkening); #endif - // FreeType has since 2.8.1 a patent free alternative to LCD-filtering. - FT_Int amajor, aminor = 0, apatch = 0; - FT_Library_Version(freetypeData->library, &amajor, &aminor, &apatch); - if (QT_VERSION_CHECK(amajor, aminor, apatch) >= QT_VERSION_CHECK(2, 8, 1)) - freetypeData->hasPatentFreeLcdRendering = true; } return freetypeData; } @@ -561,26 +555,7 @@ QFontEngineFT::Glyph::~Glyph() delete [] data; } -struct LcdFilterDummy -{ - static inline void filterPixel(uchar &, uchar &, uchar &) - {} -}; - -struct LcdFilterLegacy -{ - static inline void filterPixel(uchar &red, uchar &green, uchar &blue) - { - uint r = red, g = green, b = blue; - // intra-pixel filter used by the legacy filter (adopted from _ft_lcd_filter_legacy) - red = (r * uint(65538 * 9/13) + g * uint(65538 * 1/6) + b * uint(65538 * 1/13)) / 65536; - green = (r * uint(65538 * 3/13) + g * uint(65538 * 4/6) + b * uint(65538 * 3/13)) / 65536; - blue = (r * uint(65538 * 1/13) + g * uint(65538 * 1/6) + b * uint(65538 * 9/13)) / 65536; - } -}; - -template -static void convertRGBToARGB_helper(const uchar *src, uint *dst, int width, int height, int src_pitch, bool bgr) +static inline void convertRGBToARGB(const uchar *src, uint *dst, int width, int height, int src_pitch, bool bgr) { const int offs = bgr ? -1 : 1; const int w = width * 3; @@ -590,7 +565,6 @@ static void convertRGBToARGB_helper(const uchar *src, uint *dst, int width, int uchar red = src[x + 1 - offs]; uchar green = src[x + 1]; uchar blue = src[x + 1 + offs]; - LcdFilter::filterPixel(red, green, blue); *dd++ = (0xFFU << 24) | (red << 16) | (green << 8) | blue; } dst += width; @@ -598,16 +572,7 @@ static void convertRGBToARGB_helper(const uchar *src, uint *dst, int width, int } } -static inline void convertRGBToARGB(const uchar *src, uint *dst, int width, int height, int src_pitch, bool bgr, bool legacyFilter) -{ - if (!legacyFilter) - convertRGBToARGB_helper(src, dst, width, height, src_pitch, bgr); - else - convertRGBToARGB_helper(src, dst, width, height, src_pitch, bgr); -} - -template -static void convertRGBToARGB_V_helper(const uchar *src, uint *dst, int width, int height, int src_pitch, bool bgr) +static inline void convertRGBToARGB_V(const uchar *src, uint *dst, int width, int height, int src_pitch, bool bgr) { const int offs = bgr ? -src_pitch : src_pitch; while (height--) { @@ -615,54 +580,12 @@ static void convertRGBToARGB_V_helper(const uchar *src, uint *dst, int width, in uchar red = src[x + src_pitch - offs]; uchar green = src[x + src_pitch]; uchar blue = src[x + src_pitch + offs]; - LcdFilter::filterPixel(red, green, blue); *dst++ = (0XFFU << 24) | (red << 16) | (green << 8) | blue; } src += 3*src_pitch; } } -static inline void convertRGBToARGB_V(const uchar *src, uint *dst, int width, int height, int src_pitch, bool bgr, bool legacyFilter) -{ - if (!legacyFilter) - convertRGBToARGB_V_helper(src, dst, width, height, src_pitch, bgr); - else - convertRGBToARGB_V_helper(src, dst, width, height, src_pitch, bgr); -} - -static inline void convertGRAYToARGB(const uchar *src, uint *dst, int width, int height, int src_pitch) -{ - while (height--) { - const uchar *p = src; - const uchar * const e = p + width; - while (p < e) { - uchar gray = *p++; - *dst++ = (0xFFU << 24) | (gray << 16) | (gray << 8) | gray; - } - src += src_pitch; - } -} - -static void convoluteBitmap(const uchar *src, uchar *dst, int width, int height, int pitch) -{ - // convolute the bitmap with a triangle filter to get rid of color fringes - // If we take account for a gamma value of 2, we end up with - // weights of 1, 4, 9, 4, 1. We use an approximation of 1, 3, 8, 3, 1 here, - // as this nicely sums up to 16 :) - int h = height; - while (h--) { - dst[0] = dst[1] = 0; - // - for (int x = 2; x < width - 2; ++x) { - uint sum = src[x-2] + 3*src[x-1] + 8*src[x] + 3*src[x+1] + src[x+2]; - dst[x] = (uchar) (sum >> 4); - } - dst[width - 2] = dst[width - 1] = 0; - src += pitch; - dst += pitch; - } -} - static QFontEngine::SubpixelAntialiasingType subpixelAntialiasingTypeHint() { static int type = -1; @@ -1153,196 +1076,97 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, int glyph_buffer_size = 0; QScopedArrayPointer glyph_buffer; - bool useFreetypeRenderGlyph = false; - if (slot->format == FT_GLYPH_FORMAT_OUTLINE && (hsubpixel || vfactor != 1)) { - err = FT_Library_SetLcdFilter(slot->library, (FT_LcdFilter)lcdFilterType); - // We use FT_Render_Glyph if freetype has support for lcd-filtering - // or is version 2.8.1 or higher and can do without. - if (err == FT_Err_Ok || qt_getFreetypeData()->hasPatentFreeLcdRendering) - useFreetypeRenderGlyph = true; + FT_Render_Mode renderMode = (default_hint_style == HintLight) ? FT_RENDER_MODE_LIGHT : FT_RENDER_MODE_NORMAL; + switch (format) { + case Format_Mono: + renderMode = FT_RENDER_MODE_MONO; + break; + case Format_A32: + Q_ASSERT(hsubpixel || vfactor != 1); + renderMode = hsubpixel ? FT_RENDER_MODE_LCD : FT_RENDER_MODE_LCD_V; + break; + case Format_A8: + case Format_ARGB: + break; + default: + Q_UNREACHABLE(); } - if (useFreetypeRenderGlyph) { - err = FT_Render_Glyph(slot, hsubpixel ? FT_RENDER_MODE_LCD : FT_RENDER_MODE_LCD_V); + FT_Library_SetLcdFilter(slot->library, (FT_LcdFilter)lcdFilterType); - if (err != FT_Err_Ok) - qWarning("render glyph failed err=%x face=%p, glyph=%d", err, face, glyph); + err = FT_Render_Glyph(slot, renderMode); + if (err != FT_Err_Ok) + qWarning("render glyph failed err=%x face=%p, glyph=%d", err, face, glyph); - FT_Library_SetLcdFilter(slot->library, FT_LCD_FILTER_NONE); + FT_Library_SetLcdFilter(slot->library, FT_LCD_FILTER_NONE); - info.height = slot->bitmap.rows / vfactor; - info.width = hsubpixel ? slot->bitmap.width / 3 : slot->bitmap.width; - info.x = slot->bitmap_left; - info.y = slot->bitmap_top; - - glyph_buffer_size = info.width * info.height * 4; - glyph_buffer.reset(new uchar[glyph_buffer_size]); - - if (hsubpixel) - convertRGBToARGB(slot->bitmap.buffer, (uint *)glyph_buffer.data(), info.width, info.height, slot->bitmap.pitch, subpixelType != Subpixel_RGB, false); - else if (vfactor != 1) - convertRGBToARGB_V(slot->bitmap.buffer, (uint *)glyph_buffer.data(), info.width, info.height, slot->bitmap.pitch, subpixelType != Subpixel_VRGB, false); - } else { - int left = slot->metrics.horiBearingX; - int right = slot->metrics.horiBearingX + slot->metrics.width; - int top = slot->metrics.horiBearingY; - int bottom = slot->metrics.horiBearingY - slot->metrics.height; - if (transform && slot->format != FT_GLYPH_FORMAT_BITMAP) - transformBoundingBox(&left, &top, &right, &bottom, &matrix); - left = FLOOR(left); - right = CEIL(right); - bottom = FLOOR(bottom); - top = CEIL(top); - - int hpixels = TRUNC(right - left); - // subpixel position requires one more pixel - if (subPixelPosition > 0 && format != Format_Mono) - hpixels++; - - if (hsubpixel) - hpixels = hpixels*3 + 8; - info.width = hpixels; - info.height = TRUNC(top - bottom); - info.x = TRUNC(left); - info.y = TRUNC(top); - if (hsubpixel) { - info.width /= 3; - info.x -= 1; - } - - // If any of the metrics are too large to fit, don't cache them - if (areMetricsTooLarge(info)) - return 0; + info.height = slot->bitmap.rows; + info.width = slot->bitmap.width; + info.x = slot->bitmap_left; + info.y = slot->bitmap_top; + if (slot->bitmap.pixel_mode == FT_PIXEL_MODE_LCD) + info.width = info.width / 3; + if (slot->bitmap.pixel_mode == FT_PIXEL_MODE_LCD_V) + info.height = info.height / vfactor; int pitch = (format == Format_Mono ? ((info.width + 31) & ~31) >> 3 : (format == Format_A8 ? (info.width + 3) & ~3 : info.width * 4)); - if (glyph_buffer_size < pitch * info.height) { - glyph_buffer_size = pitch * info.height; - glyph_buffer.reset(new uchar[glyph_buffer_size]); - memset(glyph_buffer.data(), 0, glyph_buffer_size); - } - if (slot->format == FT_GLYPH_FORMAT_OUTLINE) { - FT_Bitmap bitmap; - bitmap.rows = info.height*vfactor; - bitmap.width = hpixels; - bitmap.pitch = format == Format_Mono ? (((info.width + 31) & ~31) >> 3) : ((bitmap.width + 3) & ~3); - int bitmap_buffer_size = bitmap.rows * bitmap.pitch; - if (!hsubpixel && vfactor == 1 && format != Format_A32) { - Q_ASSERT(glyph_buffer_size <= bitmap_buffer_size); - bitmap.buffer = glyph_buffer.data(); - } else { - bitmap.buffer = new uchar[bitmap_buffer_size]; - memset(bitmap.buffer, 0, bitmap_buffer_size); - } - bitmap.pixel_mode = format == Format_Mono ? FT_PIXEL_MODE_MONO : FT_PIXEL_MODE_GRAY; - FT_Matrix matrix; - matrix.xx = (hsubpixel ? 3 : 1) << 16; - matrix.yy = vfactor << 16; - matrix.yx = matrix.xy = 0; + glyph_buffer_size = info.height * pitch; + glyph_buffer.reset(new uchar[glyph_buffer_size]); - FT_Outline_Transform(&slot->outline, &matrix); - FT_Outline_Translate (&slot->outline, (hsubpixel ? -3*left +(4<<6) : -left), -bottom*vfactor); - FT_Outline_Get_Bitmap(slot->library, &slot->outline, &bitmap); - if (hsubpixel) { - Q_ASSERT (bitmap.pixel_mode == FT_PIXEL_MODE_GRAY); - Q_ASSERT(antialias); - uchar *convoluted = new uchar[bitmap_buffer_size]; - bool useLegacyLcdFilter = false; - useLegacyLcdFilter = (lcdFilterType == FT_LCD_FILTER_LEGACY); - uchar *buffer = bitmap.buffer; - if (!useLegacyLcdFilter) { - convoluteBitmap(bitmap.buffer, convoluted, bitmap.width, info.height, bitmap.pitch); - buffer = convoluted; - } - convertRGBToARGB(buffer + 1, (uint *)glyph_buffer.data(), info.width, info.height, bitmap.pitch, subpixelType != Subpixel_RGB, useLegacyLcdFilter); - delete [] convoluted; - } else if (vfactor != 1) { - convertRGBToARGB_V(bitmap.buffer, (uint *)glyph_buffer.data(), info.width, info.height, bitmap.pitch, subpixelType != Subpixel_VRGB, true); - } else if (format == Format_A32 && bitmap.pixel_mode == FT_PIXEL_MODE_GRAY) { - convertGRAYToARGB(bitmap.buffer, (uint *)glyph_buffer.data(), info.width, info.height, bitmap.pitch); - } - - if (bitmap.buffer != glyph_buffer.data()) - delete [] bitmap.buffer; - } else if (slot->format == FT_GLYPH_FORMAT_BITMAP) { -#if ((FREETYPE_MAJOR*10000 + FREETYPE_MINOR*100) >= 20500) - Q_ASSERT(slot->bitmap.pixel_mode == FT_PIXEL_MODE_MONO || slot->bitmap.pixel_mode == FT_PIXEL_MODE_BGRA); -#else - Q_ASSERT(slot->bitmap.pixel_mode == FT_PIXEL_MODE_MONO); -#endif + if (slot->bitmap.pixel_mode == FT_PIXEL_MODE_MONO) { + Q_ASSERT(format == Format_Mono); uchar *src = slot->bitmap.buffer; uchar *dst = glyph_buffer.data(); int h = slot->bitmap.rows; - if (format == Format_Mono) { - int bytes = ((info.width + 7) & ~7) >> 3; - while (h--) { - memcpy (dst, src, bytes); - dst += pitch; - src += slot->bitmap.pitch; - } - } else if (slot->bitmap.pixel_mode == FT_PIXEL_MODE_MONO) { - if (hsubpixel) { - while (h--) { - uint *dd = (uint *)dst; - *dd++ = 0; - for (int x = 0; x < static_cast(slot->bitmap.width); x++) { - uint a = ((src[x >> 3] & (0x80 >> (x & 7))) ? 0xffffff : 0x000000); - *dd++ = a; - } - *dd++ = 0; - dst += pitch; - src += slot->bitmap.pitch; - } - } else if (vfactor != 1) { - while (h--) { - uint *dd = (uint *)dst; - for (int x = 0; x < static_cast(slot->bitmap.width); x++) { - uint a = ((src[x >> 3] & (0x80 >> (x & 7))) ? 0xffffff : 0x000000); - *dd++ = a; - } - dst += pitch; - src += slot->bitmap.pitch; - } - } else { - while (h--) { - for (int x = 0; x < static_cast(slot->bitmap.width); x++) { - unsigned char a = ((src[x >> 3] & (0x80 >> (x & 7))) ? 0xff : 0x00); - dst[x] = a; - } - dst += pitch; - src += slot->bitmap.pitch; - } - } + + int bytes = ((info.width + 7) & ~7) >> 3; + while (h--) { + memcpy (dst, src, bytes); + dst += pitch; + src += slot->bitmap.pitch; } -#if ((FREETYPE_MAJOR*10000 + FREETYPE_MINOR*100) >= 20500) - else if (slot->bitmap.pixel_mode == FT_PIXEL_MODE_BGRA) - { - while (h--) { + } else if (slot->bitmap.pixel_mode == 7 /*FT_PIXEL_MODE_BGRA*/) { + Q_ASSERT(format == Format_ARGB); + uchar *src = slot->bitmap.buffer; + uchar *dst = glyph_buffer.data(); + int h = slot->bitmap.rows; + while (h--) { #if Q_BYTE_ORDER == Q_BIG_ENDIAN - const quint32 *srcPixel = (const quint32 *)src; - quint32 *dstPixel = (quint32 *)dst; - for (int x = 0; x < static_cast(slot->bitmap.width); x++, srcPixel++, dstPixel++) { - const quint32 pixel = *srcPixel; - *dstPixel = qbswap(pixel); - } -#else - memcpy(dst, src, slot->bitmap.width * 4); -#endif - dst += slot->bitmap.pitch; - src += slot->bitmap.pitch; + const quint32 *srcPixel = (const quint32 *)src; + quint32 *dstPixel = (quint32 *)dst; + for (int x = 0; x < static_cast(slot->bitmap.width); x++, srcPixel++, dstPixel++) { + const quint32 pixel = *srcPixel; + *dstPixel = qbswap(pixel); } - info.width = info.linearAdvance = info.xOff = slot->bitmap.width; - info.height = slot->bitmap.rows; - info.x = slot->bitmap_left; - info.y = slot->bitmap_top; - } +#else + memcpy(dst, src, slot->bitmap.width * 4); #endif + dst += slot->bitmap.pitch; + src += slot->bitmap.pitch; + } + info.linearAdvance = info.xOff = slot->bitmap.width; + } else if (slot->bitmap.pixel_mode == FT_PIXEL_MODE_GRAY) { + Q_ASSERT(format == Format_A8); + uchar *src = slot->bitmap.buffer; + uchar *dst = glyph_buffer.data(); + int h = slot->bitmap.rows; + int bytes = info.width; + while (h--) { + memcpy (dst, src, bytes); + dst += pitch; + src += slot->bitmap.pitch; + } + } else if (slot->bitmap.pixel_mode == FT_PIXEL_MODE_LCD) { + Q_ASSERT(format == Format_A32); + convertRGBToARGB(slot->bitmap.buffer, (uint *)glyph_buffer.data(), info.width, info.height, slot->bitmap.pitch, subpixelType != Subpixel_RGB); + } else if (slot->bitmap.pixel_mode == FT_PIXEL_MODE_LCD_V) { + Q_ASSERT(format == Format_A32); + convertRGBToARGB_V(slot->bitmap.buffer, (uint *)glyph_buffer.data(), info.width, info.height, slot->bitmap.pitch, subpixelType != Subpixel_VRGB); } else { - qWarning("QFontEngine: Glyph neither outline nor bitmap format=%d", slot->format); + qWarning("QFontEngine: Glyph rendered in unknown pixel_mode=%d", slot->bitmap.pixel_mode); return 0; } - } - if (!g) { g = new Glyph; From 8c73ddd8e3fb43cc22fa111b855ab1f9f5b83405 Mon Sep 17 00:00:00 2001 From: Gerry Boland Date: Wed, 18 Jul 2018 15:28:02 +0100 Subject: [PATCH 016/292] qpa: remove mirclient MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Mir display server is now Wayland compatible, so a dedicated Mir client library is no longer necessary. [ChangeLog][Platform Specific Changes][Mir] The Mir platform plugin has been removed: use the Wayland plugin when connecting to a Mir display server. Change-Id: Ibc77698dd45a1afaf29f0d57b5e5cf7bd91735f5 Reviewed-by: Gatis Paeglis Reviewed-by: Tor Arne Vestbø Reviewed-by: Paul Olav Tvete Reviewed-by: Johan Helsing --- config_help.txt | 1 - src/gui/configure.json | 26 +- .../platforms/mirclient/mirclient.json | 3 - src/plugins/platforms/mirclient/mirclient.pro | 61 -- .../qmirclientappstatecontroller.cpp | 102 -- .../mirclient/qmirclientappstatecontroller.h | 62 -- .../mirclient/qmirclientbackingstore.cpp | 157 --- .../mirclient/qmirclientbackingstore.h | 74 -- .../mirclient/qmirclientclipboard.cpp | 181 ---- .../platforms/mirclient/qmirclientclipboard.h | 92 -- .../platforms/mirclient/qmirclientcursor.cpp | 209 ---- .../platforms/mirclient/qmirclientcursor.h | 64 -- .../mirclient/qmirclientdebugextension.cpp | 79 -- .../mirclient/qmirclientdebugextension.h | 63 -- .../mirclient/qmirclientdesktopwindow.cpp | 50 - .../mirclient/qmirclientdesktopwindow.h | 53 - .../mirclient/qmirclientglcontext.cpp | 132 --- .../platforms/mirclient/qmirclientglcontext.h | 63 -- .../platforms/mirclient/qmirclientinput.cpp | 708 ------------- .../platforms/mirclient/qmirclientinput.h | 86 -- .../mirclient/qmirclientintegration.cpp | 411 -------- .../mirclient/qmirclientintegration.h | 131 --- .../platforms/mirclient/qmirclientlogging.h | 55 - .../mirclient/qmirclientnativeinterface.cpp | 217 ---- .../mirclient/qmirclientnativeinterface.h | 83 -- .../qmirclientorientationchangeevent_p.h | 61 -- .../mirclient/qmirclientplatformservices.cpp | 75 -- .../mirclient/qmirclientplatformservices.h | 57 -- .../platforms/mirclient/qmirclientplugin.cpp | 56 - .../platforms/mirclient/qmirclientplugin.h | 56 - .../platforms/mirclient/qmirclientscreen.cpp | 262 ----- .../platforms/mirclient/qmirclientscreen.h | 106 -- .../mirclient/qmirclientscreenobserver.cpp | 161 --- .../mirclient/qmirclientscreenobserver.h | 78 -- .../platforms/mirclient/qmirclienttheme.cpp | 67 -- .../platforms/mirclient/qmirclienttheme.h | 57 -- .../platforms/mirclient/qmirclientwindow.cpp | 968 ------------------ .../platforms/mirclient/qmirclientwindow.h | 118 --- src/plugins/platforms/platforms.pro | 2 - 39 files changed, 2 insertions(+), 5285 deletions(-) delete mode 100644 src/plugins/platforms/mirclient/mirclient.json delete mode 100644 src/plugins/platforms/mirclient/mirclient.pro delete mode 100644 src/plugins/platforms/mirclient/qmirclientappstatecontroller.cpp delete mode 100644 src/plugins/platforms/mirclient/qmirclientappstatecontroller.h delete mode 100644 src/plugins/platforms/mirclient/qmirclientbackingstore.cpp delete mode 100644 src/plugins/platforms/mirclient/qmirclientbackingstore.h delete mode 100644 src/plugins/platforms/mirclient/qmirclientclipboard.cpp delete mode 100644 src/plugins/platforms/mirclient/qmirclientclipboard.h delete mode 100644 src/plugins/platforms/mirclient/qmirclientcursor.cpp delete mode 100644 src/plugins/platforms/mirclient/qmirclientcursor.h delete mode 100644 src/plugins/platforms/mirclient/qmirclientdebugextension.cpp delete mode 100644 src/plugins/platforms/mirclient/qmirclientdebugextension.h delete mode 100644 src/plugins/platforms/mirclient/qmirclientdesktopwindow.cpp delete mode 100644 src/plugins/platforms/mirclient/qmirclientdesktopwindow.h delete mode 100644 src/plugins/platforms/mirclient/qmirclientglcontext.cpp delete mode 100644 src/plugins/platforms/mirclient/qmirclientglcontext.h delete mode 100644 src/plugins/platforms/mirclient/qmirclientinput.cpp delete mode 100644 src/plugins/platforms/mirclient/qmirclientinput.h delete mode 100644 src/plugins/platforms/mirclient/qmirclientintegration.cpp delete mode 100644 src/plugins/platforms/mirclient/qmirclientintegration.h delete mode 100644 src/plugins/platforms/mirclient/qmirclientlogging.h delete mode 100644 src/plugins/platforms/mirclient/qmirclientnativeinterface.cpp delete mode 100644 src/plugins/platforms/mirclient/qmirclientnativeinterface.h delete mode 100644 src/plugins/platforms/mirclient/qmirclientorientationchangeevent_p.h delete mode 100644 src/plugins/platforms/mirclient/qmirclientplatformservices.cpp delete mode 100644 src/plugins/platforms/mirclient/qmirclientplatformservices.h delete mode 100644 src/plugins/platforms/mirclient/qmirclientplugin.cpp delete mode 100644 src/plugins/platforms/mirclient/qmirclientplugin.h delete mode 100644 src/plugins/platforms/mirclient/qmirclientscreen.cpp delete mode 100644 src/plugins/platforms/mirclient/qmirclientscreen.h delete mode 100644 src/plugins/platforms/mirclient/qmirclientscreenobserver.cpp delete mode 100644 src/plugins/platforms/mirclient/qmirclientscreenobserver.h delete mode 100644 src/plugins/platforms/mirclient/qmirclienttheme.cpp delete mode 100644 src/plugins/platforms/mirclient/qmirclienttheme.h delete mode 100644 src/plugins/platforms/mirclient/qmirclientwindow.cpp delete mode 100644 src/plugins/platforms/mirclient/qmirclientwindow.h diff --git a/config_help.txt b/config_help.txt index 223adf61d7..606f40385e 100644 --- a/config_help.txt +++ b/config_help.txt @@ -295,7 +295,6 @@ Gui, printing, widget options: -gbm ............... Enable backends for GBM [auto] (Linux only) -kms ............... Enable backends for KMS [auto] (Linux only) -linuxfb ........... Enable Linux Framebuffer support [auto] (Linux only) - -mirclient ......... Enable Mir client support [no] (Linux only) -xcb ............... Enable X11 support. Select used xcb-* libraries [system/qt/no] (-qt-xcb still uses system version of libxcb itself) diff --git a/src/gui/configure.json b/src/gui/configure.json index 70d0817791..1a7afb9c38 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -30,7 +30,6 @@ "libjpeg": { "type": "enum", "values": [ "no", "qt", "system" ] }, "libpng": { "type": "enum", "values": [ "no", "qt", "system" ] }, "linuxfb": "boolean", - "mirclient": "boolean", "mtdev": "boolean", "opengl": { "type": "optionalString", "values": [ "no", "yes", "desktop", "es2", "dynamic" ] }, "opengl-es-2": { "type": "void", "name": "opengl", "value": "es2" }, @@ -394,20 +393,6 @@ { "lib": "zlib", "condition": "features.system-zlib" } ] }, - "mirclient": { - "label": "Mir client libraries", - "test": { - "tail": "static void surfaceCreateCallback(MirSurface*, void*) {}", - "main": [ - "u_application_lifecycle_delegate_new();", - "mir_surface_create(0, surfaceCreateCallback, 0);" - ] - }, - "headers": [ "mir_toolkit/mir_client_library.h", "ubuntu/application/lifecycle_delegate.h", "EGL/egl.h" ], - "sources": [ - { "type": "pkgConfig", "args": "egl mirclient ubuntu-platform-api libcontent-hub >= 0.2.0" } - ] - }, "mtdev": { "label": "mtdev", "test": { @@ -1294,13 +1279,6 @@ ], "output": [ "privateFeature" ] }, - "mirclient": { - "label": "Mir client", - "section": "Platform plugins", - "autoDetect": false, - "condition": "libs.mirclient && features.xkbcommon", - "output": [ "privateFeature" ] - }, "mtdev": { "label": "mtdev", "condition": "libs.mtdev", @@ -1827,7 +1805,7 @@ or may depend on your system and XQuartz setup." }, { "type": "warning", - "condition": "features.gui && config.linux && !config.android && !features.xcb && !features.eglfs && !features.directfb && !features.linuxfb && !features.mirclient", + "condition": "features.gui && config.linux && !config.android && !features.xcb && !features.eglfs && !features.directfb && !features.linuxfb", "message": "No QPA platform plugin enabled! This will produce a Qt that cannot run GUI applications. See \"Platform backends\" in the output of --help." @@ -1935,7 +1913,7 @@ QMAKE_LIBDIR_OPENGL[_ES2] and QMAKE_LIBS_OPENGL[_ES2] in the mkspec for your pla "eglfs_openwfd", "eglfs_viv", "eglfs_viv_wl", "eglfs_rcar", "eglfs_egldevice", "eglfs_gbm", "eglfs_vsp2", "eglfs_mali", "eglfs_brcm", "eglfs_x11" ] }, - "linuxfb", "vnc", "mirclient", + "linuxfb", "vnc", { "type": "feature", "condition": "config.integrity", diff --git a/src/plugins/platforms/mirclient/mirclient.json b/src/plugins/platforms/mirclient/mirclient.json deleted file mode 100644 index c31558a2f1..0000000000 --- a/src/plugins/platforms/mirclient/mirclient.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "Keys": [ "mirclient" ] -} diff --git a/src/plugins/platforms/mirclient/mirclient.pro b/src/plugins/platforms/mirclient/mirclient.pro deleted file mode 100644 index d9eb069200..0000000000 --- a/src/plugins/platforms/mirclient/mirclient.pro +++ /dev/null @@ -1,61 +0,0 @@ -TARGET = qmirclient - -QT += \ - core-private gui-private dbus \ - theme_support-private eventdispatcher_support-private \ - fontdatabase_support-private egl_support-private - -qtHaveModule(linuxaccessibility_support-private): \ - QT += linuxaccessibility_support-private - -DEFINES += MESA_EGL_NO_X11_HEADERS -# CONFIG += c++11 # only enables C++0x -QMAKE_CXXFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden -std=c++11 -Werror -Wall -QMAKE_LFLAGS += -std=c++11 -Wl,-no-undefined - -QMAKE_USE_PRIVATE += mirclient - -SOURCES = \ - qmirclientappstatecontroller.cpp \ - qmirclientbackingstore.cpp \ - qmirclientclipboard.cpp \ - qmirclientcursor.cpp \ - qmirclientdebugextension.cpp \ - qmirclientdesktopwindow.cpp \ - qmirclientglcontext.cpp \ - qmirclientinput.cpp \ - qmirclientintegration.cpp \ - qmirclientnativeinterface.cpp \ - qmirclientplatformservices.cpp \ - qmirclientplugin.cpp \ - qmirclientscreen.cpp \ - qmirclientscreenobserver.cpp \ - qmirclienttheme.cpp \ - qmirclientwindow.cpp - -HEADERS = \ - qmirclientappstatecontroller.h \ - qmirclientbackingstore.h \ - qmirclientclipboard.h \ - qmirclientcursor.h \ - qmirclientdebugextension.h \ - qmirclientdesktopwindow.h \ - qmirclientglcontext.h \ - qmirclientinput.h \ - qmirclientintegration.h \ - qmirclientlogging.h \ - qmirclientnativeinterface.h \ - qmirclientorientationchangeevent_p.h \ - qmirclientplatformservices.h \ - qmirclientplugin.h \ - qmirclientscreen.h \ - qmirclientscreenobserver.h \ - qmirclienttheme.h \ - qmirclientwindow.h - -QMAKE_USE_PRIVATE += xkbcommon - -PLUGIN_TYPE = platforms -PLUGIN_CLASS_NAME = MirServerIntegrationPlugin -!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - -load(qt_plugin) diff --git a/src/plugins/platforms/mirclient/qmirclientappstatecontroller.cpp b/src/plugins/platforms/mirclient/qmirclientappstatecontroller.cpp deleted file mode 100644 index 69fc9b7aa7..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientappstatecontroller.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include "qmirclientappstatecontroller.h" - -#include - -/* - * QMirClientAppStateController - updates Qt's QApplication::applicationState property. - * - * Tries to avoid active-inactive-active invocations using a timer. The rapid state - * change can confuse some applications. - */ - -QMirClientAppStateController::QMirClientAppStateController() - : m_suspended(false) - , m_lastActive(true) -{ - m_inactiveTimer.setSingleShot(true); - m_inactiveTimer.setInterval(10); - QObject::connect(&m_inactiveTimer, &QTimer::timeout, []() - { - QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationInactive); - }); -} - -void QMirClientAppStateController::setSuspended() -{ - m_inactiveTimer.stop(); - if (!m_suspended) { - m_suspended = true; - - QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationSuspended); - } -} - -void QMirClientAppStateController::setResumed() -{ - m_inactiveTimer.stop(); - if (m_suspended) { - m_suspended = false; - - if (m_lastActive) { - QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationActive); - } else { - QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationInactive); - } - } -} - -void QMirClientAppStateController::setWindowFocused(bool focused) -{ - if (m_suspended) { - return; - } - - if (focused) { - m_inactiveTimer.stop(); - QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationActive); - } else { - m_inactiveTimer.start(); - } - - m_lastActive = focused; -} diff --git a/src/plugins/platforms/mirclient/qmirclientappstatecontroller.h b/src/plugins/platforms/mirclient/qmirclientappstatecontroller.h deleted file mode 100644 index b3aa0022d9..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientappstatecontroller.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QMIRCLIENTAPPSTATECONTROLLER_H -#define QMIRCLIENTAPPSTATECONTROLLER_H - -#include - -class QMirClientAppStateController -{ -public: - QMirClientAppStateController(); - - void setSuspended(); - void setResumed(); - - void setWindowFocused(bool focused); - -private: - bool m_suspended; - bool m_lastActive; - QTimer m_inactiveTimer; -}; - -#endif // QMIRCLIENTAPPSTATECONTROLLER_H diff --git a/src/plugins/platforms/mirclient/qmirclientbackingstore.cpp b/src/plugins/platforms/mirclient/qmirclientbackingstore.cpp deleted file mode 100644 index 51363619d9..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientbackingstore.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include "qmirclientbackingstore.h" -#include "qmirclientlogging.h" -#include -#include -#include -#include -#include - -QMirClientBackingStore::QMirClientBackingStore(QWindow* window) - : QPlatformBackingStore(window) - , mContext(new QOpenGLContext) - , mTexture(new QOpenGLTexture(QOpenGLTexture::Target2D)) - , mBlitter(new QOpenGLTextureBlitter) -{ - mContext->setFormat(window->requestedFormat()); - mContext->setScreen(window->screen()); - mContext->create(); - - window->setSurfaceType(QSurface::OpenGLSurface); -} - -QMirClientBackingStore::~QMirClientBackingStore() -{ - mContext->makeCurrent(window()); // needed as QOpenGLTexture destructor assumes current context -} - -void QMirClientBackingStore::flush(QWindow* window, const QRegion& region, const QPoint& offset) -{ - Q_UNUSED(region); - Q_UNUSED(offset); - mContext->makeCurrent(window); - glViewport(0, 0, window->width(), window->height()); - - updateTexture(); - - if (!mBlitter->isCreated()) - mBlitter->create(); - - mBlitter->bind(); - mBlitter->blit(mTexture->textureId(), QMatrix4x4(), QOpenGLTextureBlitter::OriginTopLeft); - mBlitter->release(); - - mContext->swapBuffers(window); -} - -void QMirClientBackingStore::updateTexture() -{ - if (mDirty.isNull()) - return; - - if (!mTexture->isCreated()) { - mTexture->setMinificationFilter(QOpenGLTexture::Nearest); - mTexture->setMagnificationFilter(QOpenGLTexture::Nearest); - mTexture->setWrapMode(QOpenGLTexture::ClampToEdge); - mTexture->setData(mImage, QOpenGLTexture::DontGenerateMipMaps); - mTexture->create(); - } - mTexture->bind(); - - QRegion fixed; - QRect imageRect = mImage.rect(); - - for (const QRect &rect : mDirty) { - // intersect with image rect to be sure - QRect r = imageRect & rect; - - // if the rect is wide enough it is cheaper to just extend it instead of doing an image copy - if (r.width() >= imageRect.width() / 2) { - r.setX(0); - r.setWidth(imageRect.width()); - } - - fixed |= r; - } - - for (const QRect &rect : fixed) { - // if the sub-rect is full-width we can pass the image data directly to - // OpenGL instead of copying, since there is no gap between scanlines - if (rect.width() == imageRect.width()) { - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, rect.y(), rect.width(), rect.height(), GL_RGBA, GL_UNSIGNED_BYTE, - mImage.constScanLine(rect.y())); - } else { - glTexSubImage2D(GL_TEXTURE_2D, 0, rect.x(), rect.y(), rect.width(), rect.height(), GL_RGBA, GL_UNSIGNED_BYTE, - mImage.copy(rect).constBits()); - } - } - /* End of code taken from QEGLPlatformBackingStore */ - - mDirty = QRegion(); -} - - -void QMirClientBackingStore::beginPaint(const QRegion& region) -{ - mDirty |= region; -} - -void QMirClientBackingStore::resize(const QSize& size, const QRegion& /*staticContents*/) -{ - mImage = QImage(size, QImage::Format_RGBA8888); - - mContext->makeCurrent(window()); - - if (mTexture->isCreated()) - mTexture->destroy(); -} - -QPaintDevice* QMirClientBackingStore::paintDevice() -{ - return &mImage; -} - -QImage QMirClientBackingStore::toImage() const -{ - // used by QPlatformBackingStore::composeAndFlush - return mImage; -} diff --git a/src/plugins/platforms/mirclient/qmirclientbackingstore.h b/src/plugins/platforms/mirclient/qmirclientbackingstore.h deleted file mode 100644 index 7644c77df2..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientbackingstore.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QMIRCLIENTBACKINGSTORE_H -#define QMIRCLIENTBACKINGSTORE_H - -#include - -class QOpenGLContext; -class QOpenGLTexture; -class QOpenGLTextureBlitter; - -class QMirClientBackingStore : public QPlatformBackingStore -{ -public: - QMirClientBackingStore(QWindow* window); - virtual ~QMirClientBackingStore(); - - // QPlatformBackingStore methods. - void beginPaint(const QRegion&) override; - void flush(QWindow* window, const QRegion& region, const QPoint& offset) override; - void resize(const QSize& size, const QRegion& staticContents) override; - QPaintDevice* paintDevice() override; - QImage toImage() const override; - -protected: - void updateTexture(); - -private: - QScopedPointer mContext; - QScopedPointer mTexture; - QScopedPointer mBlitter; - QImage mImage; - QRegion mDirty; -}; - -#endif // QMIRCLIENTBACKINGSTORE_H diff --git a/src/plugins/platforms/mirclient/qmirclientclipboard.cpp b/src/plugins/platforms/mirclient/qmirclientclipboard.cpp deleted file mode 100644 index b9fc9b3b42..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientclipboard.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include "qmirclientclipboard.h" -#include "qmirclientlogging.h" -#include "qmirclientwindow.h" - -#include -#include -#include -#include -#include - -// content-hub -#include - -// get this cumbersome nested namespace out of the way -using namespace com::ubuntu::content; - -QMirClientClipboard::QMirClientClipboard() - : mMimeData(new QMimeData) - , mContentHub(Hub::Client::instance()) -{ - connect(mContentHub, &Hub::pasteboardChanged, this, [this]() { - if (mClipboardState == QMirClientClipboard::SyncedClipboard) { - mClipboardState = QMirClientClipboard::OutdatedClipboard; - emitChanged(QClipboard::Clipboard); - } - }); - - connect(qGuiApp, &QGuiApplication::applicationStateChanged, - this, &QMirClientClipboard::onApplicationStateChanged); - - requestMimeData(); -} - -QMirClientClipboard::~QMirClientClipboard() -{ - delete mMimeData; -} - -QMimeData* QMirClientClipboard::mimeData(QClipboard::Mode mode) -{ - if (mode != QClipboard::Clipboard) - return nullptr; - - // Blocks dataChanged() signal from being emitted. Makes no sense to emit it from - // inside the data getter. - const QSignalBlocker blocker(this); - - if (mClipboardState == OutdatedClipboard) { - updateMimeData(); - } else if (mClipboardState == SyncingClipboard) { - mPasteReply->waitForFinished(); - } - - return mMimeData; -} - -void QMirClientClipboard::setMimeData(QMimeData* mimeData, QClipboard::Mode mode) -{ - QWindow *focusWindow = QGuiApplication::focusWindow(); - if (focusWindow && mode == QClipboard::Clipboard && mimeData != nullptr) { - QString surfaceId = static_cast(focusWindow->handle())->persistentSurfaceId(); - - QDBusPendingCall reply = mContentHub->createPaste(surfaceId, *mimeData); - - // Don't care whether it succeeded - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - connect(watcher, &QDBusPendingCallWatcher::finished, - watcher, &QObject::deleteLater); - - mMimeData = mimeData; - mClipboardState = SyncedClipboard; - emitChanged(QClipboard::Clipboard); - } -} - -bool QMirClientClipboard::supportsMode(QClipboard::Mode mode) const -{ - return mode == QClipboard::Clipboard; -} - -bool QMirClientClipboard::ownsMode(QClipboard::Mode mode) const -{ - Q_UNUSED(mode); - return false; -} - -void QMirClientClipboard::onApplicationStateChanged(Qt::ApplicationState state) -{ - if (state == Qt::ApplicationActive) { - // Only focused or active applications might be allowed to paste, so we probably - // missed changes in the clipboard while we were hidden, inactive or, more importantly, - // suspended. - requestMimeData(); - } -} - -void QMirClientClipboard::updateMimeData() -{ - if (qGuiApp->applicationState() != Qt::ApplicationActive) { - // Don't even bother asking as content-hub would probably ignore our request (and should). - return; - } - - delete mMimeData; - - QWindow *focusWindow = QGuiApplication::focusWindow(); - if (focusWindow) { - QString surfaceId = static_cast(focusWindow->handle())->persistentSurfaceId(); - mMimeData = mContentHub->latestPaste(surfaceId); - mClipboardState = SyncedClipboard; - emitChanged(QClipboard::Clipboard); - } -} - -void QMirClientClipboard::requestMimeData() -{ - if (qGuiApp->applicationState() != Qt::ApplicationActive) { - // Don't even bother asking as content-hub would probably ignore our request (and should). - return; - } - - QWindow *focusWindow = QGuiApplication::focusWindow(); - if (!focusWindow) { - return; - } - - QString surfaceId = static_cast(focusWindow->handle())->persistentSurfaceId(); - QDBusPendingCall reply = mContentHub->requestLatestPaste(surfaceId); - mClipboardState = SyncingClipboard; - - mPasteReply = new QDBusPendingCallWatcher(reply, this); - connect(mPasteReply, &QDBusPendingCallWatcher::finished, - this, [this]() { - delete mMimeData; - mMimeData = mContentHub->paste(*mPasteReply); - mClipboardState = SyncedClipboard; - mPasteReply->deleteLater(); - mPasteReply = nullptr; - emitChanged(QClipboard::Clipboard); - }); -} diff --git a/src/plugins/platforms/mirclient/qmirclientclipboard.h b/src/plugins/platforms/mirclient/qmirclientclipboard.h deleted file mode 100644 index 09e9bcdf38..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientclipboard.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QMIRCLIENTCLIPBOARD_H -#define QMIRCLIENTCLIPBOARD_H - -#include - -#include -#include - -namespace com { - namespace ubuntu { - namespace content { - class Hub; - } - } -} - -class QDBusPendingCallWatcher; - -class QMirClientClipboard : public QObject, public QPlatformClipboard -{ - Q_OBJECT -public: - QMirClientClipboard(); - virtual ~QMirClientClipboard(); - - // QPlatformClipboard methods. - QMimeData* mimeData(QClipboard::Mode mode = QClipboard::Clipboard) override; - void setMimeData(QMimeData* data, QClipboard::Mode mode = QClipboard::Clipboard) override; - bool supportsMode(QClipboard::Mode mode) const override; - bool ownsMode(QClipboard::Mode mode) const override; - -private Q_SLOTS: - void onApplicationStateChanged(Qt::ApplicationState state); - -private: - void updateMimeData(); - void requestMimeData(); - - QMimeData *mMimeData; - - enum { - OutdatedClipboard, // Our mimeData is outdated, need to fetch latest from ContentHub - SyncingClipboard, // Our mimeData is outdated and we are waiting for ContentHub to reply with the latest paste - SyncedClipboard // Our mimeData is in sync with what ContentHub has - } mClipboardState{OutdatedClipboard}; - - com::ubuntu::content::Hub *mContentHub; - - QDBusPendingCallWatcher *mPasteReply{nullptr}; -}; - -#endif // QMIRCLIENTCLIPBOARD_H diff --git a/src/plugins/platforms/mirclient/qmirclientcursor.cpp b/src/plugins/platforms/mirclient/qmirclientcursor.cpp deleted file mode 100644 index 812cde95c6..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientcursor.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015-2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include "qmirclientcursor.h" - -#include "qmirclientlogging.h" -#include "qmirclientwindow.h" - -#include - -Q_LOGGING_CATEGORY(mirclientCursor, "qt.qpa.mirclient.cursor", QtWarningMsg) - -QMirClientCursor::QMirClientCursor(MirConnection *connection) - : mConnection(connection) -{ - /* - * TODO: Add the missing cursors to Mir (LP: #1388987) - * Those are the ones without a mir_ prefix, which are X11 cursors - * and won't be understood by any shell other than Unity8. - */ - mShapeToCursorName[Qt::ArrowCursor] = mir_arrow_cursor_name; - mShapeToCursorName[Qt::UpArrowCursor] = "up_arrow"; - mShapeToCursorName[Qt::CrossCursor] = mir_crosshair_cursor_name; - mShapeToCursorName[Qt::WaitCursor] = mir_busy_cursor_name; - mShapeToCursorName[Qt::IBeamCursor] = mir_caret_cursor_name; - mShapeToCursorName[Qt::SizeVerCursor] = mir_vertical_resize_cursor_name; - mShapeToCursorName[Qt::SizeHorCursor] = mir_horizontal_resize_cursor_name; - mShapeToCursorName[Qt::SizeBDiagCursor] = mir_diagonal_resize_bottom_to_top_cursor_name; - mShapeToCursorName[Qt::SizeFDiagCursor] = mir_diagonal_resize_top_to_bottom_cursor_name; - mShapeToCursorName[Qt::SizeAllCursor] = mir_omnidirectional_resize_cursor_name; - mShapeToCursorName[Qt::BlankCursor] = mir_disabled_cursor_name; - mShapeToCursorName[Qt::SplitVCursor] = mir_vsplit_resize_cursor_name; - mShapeToCursorName[Qt::SplitHCursor] = mir_hsplit_resize_cursor_name; - mShapeToCursorName[Qt::PointingHandCursor] = mir_pointing_hand_cursor_name; - mShapeToCursorName[Qt::ForbiddenCursor] = "forbidden"; - mShapeToCursorName[Qt::WhatsThisCursor] = "whats_this"; - mShapeToCursorName[Qt::BusyCursor] = "left_ptr_watch"; - mShapeToCursorName[Qt::OpenHandCursor] = mir_open_hand_cursor_name; - mShapeToCursorName[Qt::ClosedHandCursor] = mir_closed_hand_cursor_name; - mShapeToCursorName[Qt::DragCopyCursor] = "dnd-copy"; - mShapeToCursorName[Qt::DragMoveCursor] = "dnd-move"; - mShapeToCursorName[Qt::DragLinkCursor] = "dnd-link"; -} - -namespace { -const char *qtCursorShapeToStr(Qt::CursorShape shape) -{ - switch (shape) { - case Qt::ArrowCursor: - return "Arrow"; - case Qt::UpArrowCursor: - return "UpArrow"; - case Qt::CrossCursor: - return "Cross"; - case Qt::WaitCursor: - return "Wait"; - case Qt::IBeamCursor: - return "IBeam"; - case Qt::SizeVerCursor: - return "SizeVer"; - case Qt::SizeHorCursor: - return "SizeHor"; - case Qt::SizeBDiagCursor: - return "SizeBDiag"; - case Qt::SizeFDiagCursor: - return "SizeFDiag"; - case Qt::SizeAllCursor: - return "SizeAll"; - case Qt::BlankCursor: - return "Blank"; - case Qt::SplitVCursor: - return "SplitV"; - case Qt::SplitHCursor: - return "SplitH"; - case Qt::PointingHandCursor: - return "PointingHand"; - case Qt::ForbiddenCursor: - return "Forbidden"; - case Qt::WhatsThisCursor: - return "WhatsThis"; - case Qt::BusyCursor: - return "Busy"; - case Qt::OpenHandCursor: - return "OpenHand"; - case Qt::ClosedHandCursor: - return "ClosedHand"; - case Qt::DragCopyCursor: - return "DragCopy"; - case Qt::DragMoveCursor: - return "DragMove"; - case Qt::DragLinkCursor: - return "DragLink"; - case Qt::BitmapCursor: - return "Bitmap"; - default: - return "???"; - } -} -} // anonymous namespace - -void QMirClientCursor::changeCursor(QCursor *windowCursor, QWindow *window) -{ - if (!window) { - return; - } - - MirSurface *surface = static_cast(window->handle())->mirSurface(); - - if (!surface) { - return; - } - - - if (windowCursor) { - qCDebug(mirclientCursor, "changeCursor shape=%s, window=%p", qtCursorShapeToStr(windowCursor->shape()), window); - if (!windowCursor->pixmap().isNull()) { - configureMirCursorWithPixmapQCursor(surface, *windowCursor); - } else if (windowCursor->shape() == Qt::BitmapCursor) { - // TODO: Implement bitmap cursor support - applyDefaultCursorConfiguration(surface); - } else { - const auto &cursorName = mShapeToCursorName.value(windowCursor->shape(), QByteArray("left_ptr")); - auto cursorConfiguration = mir_cursor_configuration_from_name(cursorName.data()); - mir_surface_configure_cursor(surface, cursorConfiguration); - mir_cursor_configuration_destroy(cursorConfiguration); - } - } else { - applyDefaultCursorConfiguration(surface); - } - -} - -void QMirClientCursor::configureMirCursorWithPixmapQCursor(MirSurface *surface, QCursor &cursor) -{ - QImage image = cursor.pixmap().toImage(); - - if (image.format() != QImage::Format_ARGB32) { - image = image.convertToFormat(QImage::Format_ARGB32); - } - - MirBufferStream *bufferStream = mir_connection_create_buffer_stream_sync(mConnection, - image.width(), image.height(), mir_pixel_format_argb_8888, mir_buffer_usage_software); - - { - MirGraphicsRegion region; - mir_buffer_stream_get_graphics_region(bufferStream, ®ion); - - char *regionLine = region.vaddr; - Q_ASSERT(image.bytesPerLine() <= region.stride); - for (int i = 0; i < image.height(); ++i) { - memcpy(regionLine, image.scanLine(i), image.bytesPerLine()); - regionLine += region.stride; - } - } - - mir_buffer_stream_swap_buffers_sync(bufferStream); - - { - auto configuration = mir_cursor_configuration_from_buffer_stream(bufferStream, cursor.hotSpot().x(), cursor.hotSpot().y()); - mir_surface_configure_cursor(surface, configuration); - mir_cursor_configuration_destroy(configuration); - } - - mir_buffer_stream_release_sync(bufferStream); -} - -void QMirClientCursor::applyDefaultCursorConfiguration(MirSurface *surface) -{ - auto cursorConfiguration = mir_cursor_configuration_from_name("left_ptr"); - mir_surface_configure_cursor(surface, cursorConfiguration); - mir_cursor_configuration_destroy(cursorConfiguration); -} diff --git a/src/plugins/platforms/mirclient/qmirclientcursor.h b/src/plugins/platforms/mirclient/qmirclientcursor.h deleted file mode 100644 index c5de23b272..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientcursor.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015-2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QMIRCLIENTCURSOR_H -#define QMIRCLIENTCURSOR_H - -#include - -#include -#include - -struct MirConnection; -struct MirSurface; - -class QMirClientCursor : public QPlatformCursor -{ -public: - QMirClientCursor(MirConnection *connection); - void changeCursor(QCursor *windowCursor, QWindow *window) override; -private: - void configureMirCursorWithPixmapQCursor(MirSurface *surface, QCursor &cursor); - void applyDefaultCursorConfiguration(MirSurface *surface); - QMap mShapeToCursorName; - MirConnection *mConnection; -}; - -#endif // QMIRCLIENTCURSOR_H diff --git a/src/plugins/platforms/mirclient/qmirclientdebugextension.cpp b/src/plugins/platforms/mirclient/qmirclientdebugextension.cpp deleted file mode 100644 index 9aa934083d..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientdebugextension.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include "qmirclientdebugextension.h" - -#include "qmirclientlogging.h" - -// mir client debug -#include - -Q_LOGGING_CATEGORY(mirclientDebug, "qt.qpa.mirclient.debug") - -QMirClientDebugExtension::QMirClientDebugExtension() - : m_mirclientDebug(QStringLiteral("mirclient-debug-extension"), 1) - , m_mapper(nullptr) -{ - qCDebug(mirclientDebug) << "NOTICE: Loading mirclient-debug-extension"; - m_mapper = (MapperPrototype) m_mirclientDebug.resolve("mir_debug_surface_coords_to_screen"); - - if (!m_mirclientDebug.isLoaded()) { - qCWarning(mirclientDebug) << "ERROR: mirclient-debug-extension failed to load:" - << m_mirclientDebug.errorString(); - } else if (!m_mapper) { - qCWarning(mirclientDebug) << "ERROR: unable to find required symbols in mirclient-debug-extension:" - << m_mirclientDebug.errorString(); - } -} - -QPoint QMirClientDebugExtension::mapSurfacePointToScreen(MirSurface *surface, const QPoint &point) -{ - if (!m_mapper) { - return point; - } - - QPoint mappedPoint; - bool status = m_mapper(surface, point.x(), point.y(), &mappedPoint.rx(), &mappedPoint.ry()); - if (status) { - return mappedPoint; - } else { - return point; - } -} diff --git a/src/plugins/platforms/mirclient/qmirclientdebugextension.h b/src/plugins/platforms/mirclient/qmirclientdebugextension.h deleted file mode 100644 index 0596561d77..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientdebugextension.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QMIRCLIENTDEBUGEXTENSION_H -#define QMIRCLIENTDEBUGEXTENSION_H - -#include -#include -struct MirSurface; - -typedef bool (*MapperPrototype)(MirSurface* surface, int x, int y, int* screenX, int* screenY); - - -class QMirClientDebugExtension -{ -public: - QMirClientDebugExtension(); - - QPoint mapSurfacePointToScreen(MirSurface *, const QPoint &point); - -private: - QLibrary m_mirclientDebug; - MapperPrototype m_mapper; -}; - -#endif // QMIRCLIENTDEBUGEXTENSION_H diff --git a/src/plugins/platforms/mirclient/qmirclientdesktopwindow.cpp b/src/plugins/platforms/mirclient/qmirclientdesktopwindow.cpp deleted file mode 100644 index 123f805c25..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientdesktopwindow.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include "qmirclientdesktopwindow.h" - -// local -#include "qmirclientlogging.h" - -QMirClientDesktopWindow::QMirClientDesktopWindow(QWindow *window) - : QPlatformWindow(window) -{ - qCDebug(mirclient, "QMirClientDesktopWindow(window=%p)", window); -} diff --git a/src/plugins/platforms/mirclient/qmirclientdesktopwindow.h b/src/plugins/platforms/mirclient/qmirclientdesktopwindow.h deleted file mode 100644 index 3ba54db826..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientdesktopwindow.h +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QMIRCLIENTDESKTOPWINDOW_H -#define QMIRCLIENTDESKTOPWINDOW_H - -#include - -// TODO Implement it. For now it's just an empty, dummy class. -class QMirClientDesktopWindow : public QPlatformWindow -{ -public: - QMirClientDesktopWindow(QWindow*); -}; - -#endif // QMIRCLIENTDESKTOPWINDOW_H diff --git a/src/plugins/platforms/mirclient/qmirclientglcontext.cpp b/src/plugins/platforms/mirclient/qmirclientglcontext.cpp deleted file mode 100644 index fc7d90d5ec..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientglcontext.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include "qmirclientglcontext.h" -#include "qmirclientlogging.h" -#include "qmirclientwindow.h" - -#include -#include -#include -#include - -Q_LOGGING_CATEGORY(mirclientGraphics, "qt.qpa.mirclient.graphics", QtWarningMsg) - -namespace { - -void printEglConfig(EGLDisplay display, EGLConfig config) -{ - Q_ASSERT(display != EGL_NO_DISPLAY); - Q_ASSERT(config != nullptr); - - const char *string = eglQueryString(display, EGL_VENDOR); - qCDebug(mirclientGraphics, "EGL vendor: %s", string); - - string = eglQueryString(display, EGL_VERSION); - qCDebug(mirclientGraphics, "EGL version: %s", string); - - string = eglQueryString(display, EGL_EXTENSIONS); - qCDebug(mirclientGraphics, "EGL extensions: %s", string); - - qCDebug(mirclientGraphics, "EGL configuration attributes:"); - q_printEglConfig(display, config); -} - -} // anonymous namespace - -QMirClientOpenGLContext::QMirClientOpenGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, - EGLDisplay display) - : QEGLPlatformContext(format, share, display, 0) -{ - if (mirclientGraphics().isDebugEnabled()) { - printEglConfig(display, eglConfig()); - } -} - -static bool needsFBOReadBackWorkaround() -{ - static bool set = false; - static bool needsWorkaround = false; - - if (Q_UNLIKELY(!set)) { - const char *rendererString = reinterpret_cast(glGetString(GL_RENDERER)); - needsWorkaround = qstrncmp(rendererString, "Mali-400", 8) == 0 - || qstrncmp(rendererString, "Mali-T7", 7) == 0 - || qstrncmp(rendererString, "PowerVR Rogue G6200", 19) == 0; - set = true; - } - - return needsWorkaround; -} - -bool QMirClientOpenGLContext::makeCurrent(QPlatformSurface* surface) -{ - const bool ret = QEGLPlatformContext::makeCurrent(surface); - - if (Q_LIKELY(ret)) { - QOpenGLContextPrivate *ctx_d = QOpenGLContextPrivate::get(context()); - if (!ctx_d->workaround_brokenFBOReadBack && needsFBOReadBackWorkaround()) { - ctx_d->workaround_brokenFBOReadBack = true; - } - } - return ret; -} - -// Following method used internally in the base class QEGLPlatformContext to access -// the egl surface of a QPlatformSurface/QMirClientWindow -EGLSurface QMirClientOpenGLContext::eglSurfaceForPlatformSurface(QPlatformSurface *surface) -{ - if (surface->surface()->surfaceClass() == QSurface::Window) { - return static_cast(surface)->eglSurface(); - } else { - return static_cast(surface)->pbuffer(); - } -} - -void QMirClientOpenGLContext::swapBuffers(QPlatformSurface* surface) -{ - QEGLPlatformContext::swapBuffers(surface); - - if (surface->surface()->surfaceClass() == QSurface::Window) { - // notify window on swap completion - auto platformWindow = static_cast(surface); - platformWindow->onSwapBuffersDone(); - } -} diff --git a/src/plugins/platforms/mirclient/qmirclientglcontext.h b/src/plugins/platforms/mirclient/qmirclientglcontext.h deleted file mode 100644 index 92331a6fb1..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientglcontext.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QMIRCLIENTGLCONTEXT_H -#define QMIRCLIENTGLCONTEXT_H - -#include -#include - -#include - -class QMirClientOpenGLContext : public QEGLPlatformContext -{ -public: - QMirClientOpenGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, - EGLDisplay display); - - // QEGLPlatformContext methods. - void swapBuffers(QPlatformSurface *surface) final; - bool makeCurrent(QPlatformSurface *surface) final; - -protected: - EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) final; -}; - -#endif // QMIRCLIENTGLCONTEXT_H diff --git a/src/plugins/platforms/mirclient/qmirclientinput.cpp b/src/plugins/platforms/mirclient/qmirclientinput.cpp deleted file mode 100644 index e5319b0435..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientinput.cpp +++ /dev/null @@ -1,708 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014-2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -// Local -#include "qmirclientinput.h" -#include "qmirclientintegration.h" -#include "qmirclientnativeinterface.h" -#include "qmirclientscreen.h" -#include "qmirclientwindow.h" -#include "qmirclientlogging.h" -#include "qmirclientorientationchangeevent_p.h" - -// Qt -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -Q_LOGGING_CATEGORY(mirclientInput, "qt.qpa.mirclient.input", QtWarningMsg) - -namespace -{ - -// XKB Keysyms which do not map directly to Qt types (i.e. Unicode points) -static const uint32_t KeyTable[] = { - XKB_KEY_Escape, Qt::Key_Escape, - XKB_KEY_Tab, Qt::Key_Tab, - XKB_KEY_ISO_Left_Tab, Qt::Key_Backtab, - XKB_KEY_BackSpace, Qt::Key_Backspace, - XKB_KEY_Return, Qt::Key_Return, - XKB_KEY_Insert, Qt::Key_Insert, - XKB_KEY_Delete, Qt::Key_Delete, - XKB_KEY_Clear, Qt::Key_Delete, - XKB_KEY_Pause, Qt::Key_Pause, - XKB_KEY_Print, Qt::Key_Print, - - XKB_KEY_Home, Qt::Key_Home, - XKB_KEY_End, Qt::Key_End, - XKB_KEY_Left, Qt::Key_Left, - XKB_KEY_Up, Qt::Key_Up, - XKB_KEY_Right, Qt::Key_Right, - XKB_KEY_Down, Qt::Key_Down, - XKB_KEY_Prior, Qt::Key_PageUp, - XKB_KEY_Next, Qt::Key_PageDown, - - XKB_KEY_Shift_L, Qt::Key_Shift, - XKB_KEY_Shift_R, Qt::Key_Shift, - XKB_KEY_Shift_Lock, Qt::Key_Shift, - XKB_KEY_Control_L, Qt::Key_Control, - XKB_KEY_Control_R, Qt::Key_Control, - XKB_KEY_Meta_L, Qt::Key_Meta, - XKB_KEY_Meta_R, Qt::Key_Meta, - XKB_KEY_Alt_L, Qt::Key_Alt, - XKB_KEY_Alt_R, Qt::Key_Alt, - XKB_KEY_Caps_Lock, Qt::Key_CapsLock, - XKB_KEY_Num_Lock, Qt::Key_NumLock, - XKB_KEY_Scroll_Lock, Qt::Key_ScrollLock, - XKB_KEY_Super_L, Qt::Key_Super_L, - XKB_KEY_Super_R, Qt::Key_Super_R, - XKB_KEY_Menu, Qt::Key_Menu, - XKB_KEY_Hyper_L, Qt::Key_Hyper_L, - XKB_KEY_Hyper_R, Qt::Key_Hyper_R, - XKB_KEY_Help, Qt::Key_Help, - - XKB_KEY_KP_Space, Qt::Key_Space, - XKB_KEY_KP_Tab, Qt::Key_Tab, - XKB_KEY_KP_Enter, Qt::Key_Enter, - XKB_KEY_KP_Home, Qt::Key_Home, - XKB_KEY_KP_Left, Qt::Key_Left, - XKB_KEY_KP_Up, Qt::Key_Up, - XKB_KEY_KP_Right, Qt::Key_Right, - XKB_KEY_KP_Down, Qt::Key_Down, - XKB_KEY_KP_Prior, Qt::Key_PageUp, - XKB_KEY_KP_Next, Qt::Key_PageDown, - XKB_KEY_KP_End, Qt::Key_End, - XKB_KEY_KP_Begin, Qt::Key_Clear, - XKB_KEY_KP_Insert, Qt::Key_Insert, - XKB_KEY_KP_Delete, Qt::Key_Delete, - XKB_KEY_KP_Equal, Qt::Key_Equal, - XKB_KEY_KP_Multiply, Qt::Key_Asterisk, - XKB_KEY_KP_Add, Qt::Key_Plus, - XKB_KEY_KP_Separator, Qt::Key_Comma, - XKB_KEY_KP_Subtract, Qt::Key_Minus, - XKB_KEY_KP_Decimal, Qt::Key_Period, - XKB_KEY_KP_Divide, Qt::Key_Slash, - - XKB_KEY_ISO_Level3_Shift, Qt::Key_AltGr, - XKB_KEY_Multi_key, Qt::Key_Multi_key, - XKB_KEY_Codeinput, Qt::Key_Codeinput, - XKB_KEY_SingleCandidate, Qt::Key_SingleCandidate, - XKB_KEY_MultipleCandidate, Qt::Key_MultipleCandidate, - XKB_KEY_PreviousCandidate, Qt::Key_PreviousCandidate, - - // dead keys - XKB_KEY_dead_grave, Qt::Key_Dead_Grave, - XKB_KEY_dead_acute, Qt::Key_Dead_Acute, - XKB_KEY_dead_circumflex, Qt::Key_Dead_Circumflex, - XKB_KEY_dead_tilde, Qt::Key_Dead_Tilde, - XKB_KEY_dead_macron, Qt::Key_Dead_Macron, - XKB_KEY_dead_breve, Qt::Key_Dead_Breve, - XKB_KEY_dead_abovedot, Qt::Key_Dead_Abovedot, - XKB_KEY_dead_diaeresis, Qt::Key_Dead_Diaeresis, - XKB_KEY_dead_abovering, Qt::Key_Dead_Abovering, - XKB_KEY_dead_doubleacute, Qt::Key_Dead_Doubleacute, - XKB_KEY_dead_caron, Qt::Key_Dead_Caron, - XKB_KEY_dead_cedilla, Qt::Key_Dead_Cedilla, - XKB_KEY_dead_ogonek, Qt::Key_Dead_Ogonek, - XKB_KEY_dead_iota, Qt::Key_Dead_Iota, - XKB_KEY_dead_voiced_sound, Qt::Key_Dead_Voiced_Sound, - XKB_KEY_dead_semivoiced_sound, Qt::Key_Dead_Semivoiced_Sound, - XKB_KEY_dead_belowdot, Qt::Key_Dead_Belowdot, - XKB_KEY_dead_hook, Qt::Key_Dead_Hook, - XKB_KEY_dead_horn, Qt::Key_Dead_Horn, - XKB_KEY_dead_stroke, Qt::Key_Dead_Stroke, - XKB_KEY_dead_abovecomma, Qt::Key_Dead_Abovecomma, - XKB_KEY_dead_abovereversedcomma, Qt::Key_Dead_Abovereversedcomma, - XKB_KEY_dead_doublegrave, Qt::Key_Dead_Doublegrave, - XKB_KEY_dead_belowring, Qt::Key_Dead_Belowring, - XKB_KEY_dead_belowmacron, Qt::Key_Dead_Belowmacron, - XKB_KEY_dead_belowcircumflex, Qt::Key_Dead_Belowcircumflex, - XKB_KEY_dead_belowtilde, Qt::Key_Dead_Belowtilde, - XKB_KEY_dead_belowbreve, Qt::Key_Dead_Belowbreve, - XKB_KEY_dead_belowdiaeresis, Qt::Key_Dead_Belowdiaeresis, - XKB_KEY_dead_invertedbreve, Qt::Key_Dead_Invertedbreve, - XKB_KEY_dead_belowcomma, Qt::Key_Dead_Belowcomma, - XKB_KEY_dead_currency, Qt::Key_Dead_Currency, - XKB_KEY_dead_a, Qt::Key_Dead_a, - XKB_KEY_dead_A, Qt::Key_Dead_A, - XKB_KEY_dead_e, Qt::Key_Dead_e, - XKB_KEY_dead_E, Qt::Key_Dead_E, - XKB_KEY_dead_i, Qt::Key_Dead_i, - XKB_KEY_dead_I, Qt::Key_Dead_I, - XKB_KEY_dead_o, Qt::Key_Dead_o, - XKB_KEY_dead_O, Qt::Key_Dead_O, - XKB_KEY_dead_u, Qt::Key_Dead_u, - XKB_KEY_dead_U, Qt::Key_Dead_U, - XKB_KEY_dead_small_schwa, Qt::Key_Dead_Small_Schwa, - XKB_KEY_dead_capital_schwa, Qt::Key_Dead_Capital_Schwa, - XKB_KEY_dead_greek, Qt::Key_Dead_Greek, - XKB_KEY_dead_lowline, Qt::Key_Dead_Lowline, - XKB_KEY_dead_aboveverticalline, Qt::Key_Dead_Aboveverticalline, - XKB_KEY_dead_belowverticalline, Qt::Key_Dead_Belowverticalline, - XKB_KEY_dead_longsolidusoverlay, Qt::Key_Dead_Longsolidusoverlay, - - XKB_KEY_Mode_switch, Qt::Key_Mode_switch, - XKB_KEY_script_switch, Qt::Key_Mode_switch, - XKB_KEY_XF86AudioRaiseVolume, Qt::Key_VolumeUp, - XKB_KEY_XF86AudioLowerVolume, Qt::Key_VolumeDown, - XKB_KEY_XF86PowerOff, Qt::Key_PowerOff, - XKB_KEY_XF86PowerDown, Qt::Key_PowerDown, - - 0, 0 -}; - -Qt::WindowState mirSurfaceStateToWindowState(MirSurfaceState state) -{ - switch (state) { - case mir_surface_state_fullscreen: - return Qt::WindowFullScreen; - case mir_surface_state_maximized: - case mir_surface_state_vertmaximized: - case mir_surface_state_horizmaximized: - return Qt::WindowMaximized; - case mir_surface_state_minimized: - return Qt::WindowMinimized; - case mir_surface_state_hidden: - // We should be handling this state separately. - Q_ASSERT(false); - case mir_surface_state_restored: - case mir_surface_state_unknown: - default: - return Qt::WindowNoState; - } -} - -} // namespace - -class UbuntuEvent : public QEvent -{ -public: - UbuntuEvent(QMirClientWindow* window, const MirEvent *event, QEvent::Type type) - : QEvent(type), window(window) { - nativeEvent = mir_event_ref(event); - } - ~UbuntuEvent() - { - mir_event_unref(nativeEvent); - } - - QPointer window; - const MirEvent *nativeEvent; -}; - -QMirClientInput::QMirClientInput(QMirClientClientIntegration* integration) - : QObject(nullptr) - , mIntegration(integration) - , mEventFilterType(static_cast( - integration->nativeInterface())->genericEventFilterType()) - , mEventType(static_cast(QEvent::registerEventType())) - , mLastInputWindow(nullptr) -{ - // Initialize touch device. - mTouchDevice = new QTouchDevice; - mTouchDevice->setType(QTouchDevice::TouchScreen); - mTouchDevice->setCapabilities( - QTouchDevice::Position | QTouchDevice::Area | QTouchDevice::Pressure | - QTouchDevice::NormalizedPosition); - QWindowSystemInterface::registerTouchDevice(mTouchDevice); -} - -QMirClientInput::~QMirClientInput() -{ - // Qt will take care of deleting mTouchDevice. -} - -static const char* nativeEventTypeToStr(MirEventType t) -{ - switch (t) - { - case mir_event_type_key: - return "key"; - case mir_event_type_motion: - return "motion"; - case mir_event_type_surface: - return "surface"; - case mir_event_type_resize: - return "resize"; - case mir_event_type_prompt_session_state_change: - return "prompt_session_state_change"; - case mir_event_type_orientation: - return "orientation"; - case mir_event_type_close_surface: - return "close_surface"; - case mir_event_type_input: - return "input"; - case mir_event_type_keymap: - return "keymap"; - case mir_event_type_input_configuration: - return "input_configuration"; - case mir_event_type_surface_output: - return "surface_output"; - case mir_event_type_input_device_state: - return "input_device_state"; - default: - return "unknown"; - } -} - -void QMirClientInput::customEvent(QEvent* event) -{ - Q_ASSERT(QThread::currentThread() == thread()); - UbuntuEvent* ubuntuEvent = static_cast(event); - const MirEvent *nativeEvent = ubuntuEvent->nativeEvent; - - if ((ubuntuEvent->window == nullptr) || (ubuntuEvent->window->window() == nullptr)) { - qCWarning(mirclient) << "Attempted to deliver an event to a non-existent window, ignoring."; - return; - } - - // Event filtering. - long result; - if (QWindowSystemInterface::handleNativeEvent( - ubuntuEvent->window->window(), mEventFilterType, - const_cast(static_cast(nativeEvent)), &result) == true) { - qCDebug(mirclient, "event filtered out by native interface"); - return; - } - - qCDebug(mirclientInput, "customEvent(type=%s)", nativeEventTypeToStr(mir_event_get_type(nativeEvent))); - - // Event dispatching. - switch (mir_event_get_type(nativeEvent)) - { - case mir_event_type_input: - dispatchInputEvent(ubuntuEvent->window, mir_event_get_input_event(nativeEvent)); - break; - case mir_event_type_resize: - { - auto resizeEvent = mir_event_get_resize_event(nativeEvent); - - // Enable workaround for Screen rotation - auto const targetWindow = ubuntuEvent->window; - if (targetWindow) { - auto const screen = static_cast(targetWindow->screen()); - if (screen) { - screen->handleWindowSurfaceResize( - mir_resize_event_get_width(resizeEvent), - mir_resize_event_get_height(resizeEvent)); - } - - targetWindow->handleSurfaceResized( - mir_resize_event_get_width(resizeEvent), - mir_resize_event_get_height(resizeEvent)); - } - break; - } - case mir_event_type_surface: - handleSurfaceEvent(ubuntuEvent->window, mir_event_get_surface_event(nativeEvent)); - break; - case mir_event_type_surface_output: - handleSurfaceOutputEvent(ubuntuEvent->window, mir_event_get_surface_output_event(nativeEvent)); - break; - case mir_event_type_orientation: - dispatchOrientationEvent(ubuntuEvent->window->window(), mir_event_get_orientation_event(nativeEvent)); - break; - case mir_event_type_close_surface: - QWindowSystemInterface::handleCloseEvent(ubuntuEvent->window->window()); - break; - default: - qCDebug(mirclient, "unhandled event type: %d", static_cast(mir_event_get_type(nativeEvent))); - } -} - -void QMirClientInput::postEvent(QMirClientWindow *platformWindow, const MirEvent *event) -{ - QWindow *window = platformWindow->window(); - - QCoreApplication::postEvent(this, new UbuntuEvent( - platformWindow, event, mEventType)); - - if ((window->flags().testFlag(Qt::WindowTransparentForInput)) && window->parent()) { - QCoreApplication::postEvent(this, new UbuntuEvent( - static_cast(platformWindow->QPlatformWindow::parent()), - event, mEventType)); - } -} - -void QMirClientInput::dispatchInputEvent(QMirClientWindow *window, const MirInputEvent *ev) -{ - switch (mir_input_event_get_type(ev)) - { - case mir_input_event_type_key: - dispatchKeyEvent(window, ev); - break; - case mir_input_event_type_touch: - dispatchTouchEvent(window, ev); - break; - case mir_input_event_type_pointer: - dispatchPointerEvent(window, ev); - break; - default: - break; - } -} - -void QMirClientInput::dispatchTouchEvent(QMirClientWindow *window, const MirInputEvent *ev) -{ - const MirTouchEvent *tev = mir_input_event_get_touch_event(ev); - - // FIXME(loicm) Max pressure is device specific. That one is for the Samsung Galaxy Nexus. That - // needs to be fixed as soon as the compat input lib adds query support. - const float kMaxPressure = 1.28; - const QRect kWindowGeometry = window->geometry(); - QList touchPoints; - - - // TODO: Is it worth setting the Qt::TouchPointStationary ones? Currently they are left - // as Qt::TouchPointMoved - const unsigned int kPointerCount = mir_touch_event_point_count(tev); - touchPoints.reserve(int(kPointerCount)); - for (unsigned int i = 0; i < kPointerCount; ++i) { - QWindowSystemInterface::TouchPoint touchPoint; - - const float kX = mir_touch_event_axis_value(tev, i, mir_touch_axis_x) + kWindowGeometry.x(); - const float kY = mir_touch_event_axis_value(tev, i, mir_touch_axis_y) + kWindowGeometry.y(); // see bug lp:1346633 workaround comments elsewhere - const float kW = mir_touch_event_axis_value(tev, i, mir_touch_axis_touch_major); - const float kH = mir_touch_event_axis_value(tev, i, mir_touch_axis_touch_minor); - const float kP = mir_touch_event_axis_value(tev, i, mir_touch_axis_pressure); - touchPoint.id = mir_touch_event_id(tev, i); - touchPoint.normalPosition = QPointF(kX / kWindowGeometry.width(), kY / kWindowGeometry.height()); - touchPoint.area = QRectF(kX - (kW / 2.0), kY - (kH / 2.0), kW, kH); - touchPoint.pressure = kP / kMaxPressure; - - MirTouchAction touch_action = mir_touch_event_action(tev, i); - switch (touch_action) - { - case mir_touch_action_down: - mLastInputWindow = window; - touchPoint.state = Qt::TouchPointPressed; - break; - case mir_touch_action_up: - touchPoint.state = Qt::TouchPointReleased; - break; - case mir_touch_action_change: - touchPoint.state = Qt::TouchPointMoved; - break; - default: - Q_UNREACHABLE(); - } - - touchPoints.append(touchPoint); - } - - ulong timestamp = mir_input_event_get_event_time(ev) / 1000000; - QWindowSystemInterface::handleTouchEvent(window->window(), timestamp, - mTouchDevice, touchPoints); -} - -static uint32_t translateKeysym(uint32_t sym, const QString &text) { - int code = 0; - - QTextCodec *systemCodec = QTextCodec::codecForLocale(); - if (sym < 128 || (sym < 256 && systemCodec->mibEnum() == 4)) { - // upper-case key, if known - code = isprint((int)sym) ? toupper((int)sym) : 0; - } else if (sym >= XKB_KEY_F1 && sym <= XKB_KEY_F35) { - return Qt::Key_F1 + (int(sym) - XKB_KEY_F1); - } else if (text.length() == 1 && text.unicode()->unicode() > 0x1f - && text.unicode()->unicode() != 0x7f - && !(sym >= XKB_KEY_dead_grave && sym <= XKB_KEY_dead_currency)) { - code = text.unicode()->toUpper().unicode(); - } else { - for (int i = 0; KeyTable[i]; i += 2) - if (sym == KeyTable[i]) - code = KeyTable[i + 1]; - } - - return code; -} - -namespace -{ -Qt::KeyboardModifiers qt_modifiers_from_mir(MirInputEventModifiers modifiers) -{ - Qt::KeyboardModifiers q_modifiers = Qt::NoModifier; - if (modifiers & mir_input_event_modifier_shift) { - q_modifiers |= Qt::ShiftModifier; - } - if (modifiers & mir_input_event_modifier_ctrl) { - q_modifiers |= Qt::ControlModifier; - } - if (modifiers & mir_input_event_modifier_alt_left) { - q_modifiers |= Qt::AltModifier; - } - if (modifiers & mir_input_event_modifier_meta) { - q_modifiers |= Qt::MetaModifier; - } - if (modifiers & mir_input_event_modifier_alt_right) { - q_modifiers |= Qt::GroupSwitchModifier; - } - return q_modifiers; -} -} - -void QMirClientInput::dispatchKeyEvent(QMirClientWindow *window, const MirInputEvent *event) -{ - const MirKeyboardEvent *key_event = mir_input_event_get_keyboard_event(event); - - ulong timestamp = mir_input_event_get_event_time(event) / 1000000; - xkb_keysym_t xk_sym = mir_keyboard_event_key_code(key_event); - quint32 scan_code = mir_keyboard_event_scan_code(key_event); - quint32 native_modifiers = mir_keyboard_event_modifiers(key_event); - - // Key modifier and unicode index mapping. - auto modifiers = qt_modifiers_from_mir(native_modifiers); - - MirKeyboardAction action = mir_keyboard_event_action(key_event); - QEvent::Type keyType = action == mir_keyboard_action_up - ? QEvent::KeyRelease : QEvent::KeyPress; - - if (action == mir_keyboard_action_down) - mLastInputWindow = window; - - QString text; - QVarLengthArray chars(32); - { - int result = xkb_keysym_to_utf8(xk_sym, chars.data(), chars.size()); - - if (result > 0) { - text = QString::fromUtf8(chars.constData()); - } - } - int sym = translateKeysym(xk_sym, text); - - bool is_auto_rep = action == mir_keyboard_action_repeat; - - QPlatformInputContext *context = QGuiApplicationPrivate::platformIntegration()->inputContext(); - if (context) { - QKeyEvent qKeyEvent(keyType, sym, modifiers, scan_code, xk_sym, native_modifiers, text, is_auto_rep); - qKeyEvent.setTimestamp(timestamp); - if (context->filterEvent(&qKeyEvent)) { - qCDebug(mirclient, "key event filtered out by input context"); - return; - } - } - - QWindowSystemInterface::handleExtendedKeyEvent(window->window(), timestamp, keyType, sym, modifiers, scan_code, xk_sym, native_modifiers, text, is_auto_rep); -} - -namespace -{ -Qt::MouseButtons extract_buttons(const MirPointerEvent *pev) -{ - Qt::MouseButtons buttons = Qt::NoButton; - if (mir_pointer_event_button_state(pev, mir_pointer_button_primary)) - buttons |= Qt::LeftButton; - if (mir_pointer_event_button_state(pev, mir_pointer_button_secondary)) - buttons |= Qt::RightButton; - if (mir_pointer_event_button_state(pev, mir_pointer_button_tertiary)) - buttons |= Qt::MiddleButton; - if (mir_pointer_event_button_state(pev, mir_pointer_button_back)) - buttons |= Qt::BackButton; - if (mir_pointer_event_button_state(pev, mir_pointer_button_forward)) - buttons |= Qt::ForwardButton; - - return buttons; -} -} - -void QMirClientInput::dispatchPointerEvent(QMirClientWindow *platformWindow, const MirInputEvent *ev) -{ - const auto window = platformWindow->window(); - const auto timestamp = mir_input_event_get_event_time(ev) / 1000000; - - const auto pev = mir_input_event_get_pointer_event(ev); - const auto action = mir_pointer_event_action(pev); - - const auto modifiers = qt_modifiers_from_mir(mir_pointer_event_modifiers(pev)); - const auto localPoint = QPointF(mir_pointer_event_axis_value(pev, mir_pointer_axis_x), - mir_pointer_event_axis_value(pev, mir_pointer_axis_y)); - - mLastInputWindow = platformWindow; - - switch (action) { - case mir_pointer_action_button_up: - case mir_pointer_action_button_down: - case mir_pointer_action_motion: - { - const float hDelta = mir_pointer_event_axis_value(pev, mir_pointer_axis_hscroll); - const float vDelta = mir_pointer_event_axis_value(pev, mir_pointer_axis_vscroll); - - if (hDelta != 0 || vDelta != 0) { - // QWheelEvent::DefaultDeltasPerStep = 120 but doesn't exist on vivid - const QPoint angleDelta(120 * hDelta, 120 * vDelta); - QWindowSystemInterface::handleWheelEvent(window, timestamp, localPoint, window->position() + localPoint, - QPoint(), angleDelta, modifiers, Qt::ScrollUpdate); - } - auto buttons = extract_buttons(pev); - QWindowSystemInterface::handleMouseEvent(window, timestamp, localPoint, window->position() + localPoint /* Should we omit global point instead? */, - buttons, modifiers); - break; - } - case mir_pointer_action_enter: - QWindowSystemInterface::handleEnterEvent(window, localPoint, window->position() + localPoint); - break; - case mir_pointer_action_leave: - QWindowSystemInterface::handleLeaveEvent(window); - break; - default: - Q_UNREACHABLE(); - } -} - -static const char* nativeOrientationDirectionToStr(MirOrientation orientation) -{ - switch (orientation) { - case mir_orientation_normal: - return "Normal"; - case mir_orientation_left: - return "Left"; - case mir_orientation_inverted: - return "Inverted"; - case mir_orientation_right: - return "Right"; - } - Q_UNREACHABLE(); -} - -void QMirClientInput::dispatchOrientationEvent(QWindow *window, const MirOrientationEvent *event) -{ - MirOrientation mir_orientation = mir_orientation_event_get_direction(event); - qCDebug(mirclientInput, "orientation direction: %s", nativeOrientationDirectionToStr(mir_orientation)); - - if (!window->screen()) { - qCDebug(mirclient, "Window has no associated screen, dropping orientation event"); - return; - } - - OrientationChangeEvent::Orientation orientation; - switch (mir_orientation) { - case mir_orientation_normal: - orientation = OrientationChangeEvent::TopUp; - break; - case mir_orientation_left: - orientation = OrientationChangeEvent::LeftUp; - break; - case mir_orientation_inverted: - orientation = OrientationChangeEvent::TopDown; - break; - case mir_orientation_right: - orientation = OrientationChangeEvent::RightUp; - break; - default: - qCDebug(mirclient, "No such orientation %d", mir_orientation); - return; - } - - // Dispatch orientation event to [Platform]Screen, as that is where Qt reads it. Screen will handle - // notifying Qt of the actual orientation change - done to prevent multiple Windows each creating - // an identical orientation change event and passing it directly to Qt. - // [Platform]Screen can also factor in the native orientation. - QCoreApplication::postEvent(static_cast(window->screen()->handle()), - new OrientationChangeEvent(OrientationChangeEvent::mType, orientation)); -} - -void QMirClientInput::handleSurfaceEvent(const QPointer &window, const MirSurfaceEvent *event) -{ - auto surfaceEventAttribute = mir_surface_event_get_attribute(event); - - switch (surfaceEventAttribute) { - case mir_surface_attrib_focus: { - window->handleSurfaceFocusChanged( - mir_surface_event_get_attribute_value(event) == mir_surface_focused); - break; - } - case mir_surface_attrib_visibility: { - window->handleSurfaceExposeChange( - mir_surface_event_get_attribute_value(event) == mir_surface_visibility_exposed); - break; - } - // Remaining attributes are ones client sets for server, and server should not override them - case mir_surface_attrib_state: { - MirSurfaceState state = static_cast(mir_surface_event_get_attribute_value(event)); - - if (state == mir_surface_state_hidden) { - window->handleSurfaceVisibilityChanged(false); - } else { - // it's visible! - window->handleSurfaceVisibilityChanged(true); - window->handleSurfaceStateChanged(mirSurfaceStateToWindowState(state)); - } - break; - } - case mir_surface_attrib_type: - case mir_surface_attrib_swapinterval: - case mir_surface_attrib_dpi: - case mir_surface_attrib_preferred_orientation: - case mir_surface_attribs: - break; - } -} - -void QMirClientInput::handleSurfaceOutputEvent(const QPointer &window, const MirSurfaceOutputEvent *event) -{ - const uint32_t outputId = mir_surface_output_event_get_output_id(event); - const int dpi = mir_surface_output_event_get_dpi(event); - const MirFormFactor formFactor = mir_surface_output_event_get_form_factor(event); - const float scale = mir_surface_output_event_get_scale(event); - - const auto screenObserver = mIntegration->screenObserver(); - QMirClientScreen *screen = screenObserver->findScreenWithId(outputId); - if (!screen) { - qCWarning(mirclient) << "Mir notified window" << window->window() << "on an unknown screen with id" << outputId; - return; - } - - screenObserver->handleScreenPropertiesChange(screen, dpi, formFactor, scale); - window->handleScreenPropertiesChange(formFactor, scale); - - if (window->screen() != screen) { - QWindowSystemInterface::handleWindowScreenChanged(window->window(), screen->screen()); - } -} diff --git a/src/plugins/platforms/mirclient/qmirclientinput.h b/src/plugins/platforms/mirclient/qmirclientinput.h deleted file mode 100644 index 263cb5e54e..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientinput.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014-2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QMIRCLIENTINPUT_H -#define QMIRCLIENTINPUT_H - -// Qt -#include - -#include - -class QMirClientClientIntegration; -class QMirClientWindow; - -class QMirClientInput : public QObject -{ - Q_OBJECT - -public: - QMirClientInput(QMirClientClientIntegration* integration); - virtual ~QMirClientInput(); - - // QObject methods. - void customEvent(QEvent* event) override; - - void postEvent(QMirClientWindow* window, const MirEvent *event); - QMirClientClientIntegration* integration() const { return mIntegration; } - QMirClientWindow *lastInputWindow() const {return mLastInputWindow; } - -protected: - void dispatchKeyEvent(QMirClientWindow *window, const MirInputEvent *event); - void dispatchPointerEvent(QMirClientWindow *window, const MirInputEvent *event); - void dispatchTouchEvent(QMirClientWindow *window, const MirInputEvent *event); - void dispatchInputEvent(QMirClientWindow *window, const MirInputEvent *event); - - void dispatchOrientationEvent(QWindow* window, const MirOrientationEvent *event); - void handleSurfaceEvent(const QPointer &window, const MirSurfaceEvent *event); - void handleSurfaceOutputEvent(const QPointer &window, const MirSurfaceOutputEvent *event); - -private: - QMirClientClientIntegration* mIntegration; - QTouchDevice* mTouchDevice; - const QByteArray mEventFilterType; - const QEvent::Type mEventType; - - QMirClientWindow *mLastInputWindow; -}; - -#endif // QMIRCLIENTINPUT_H diff --git a/src/plugins/platforms/mirclient/qmirclientintegration.cpp b/src/plugins/platforms/mirclient/qmirclientintegration.cpp deleted file mode 100644 index eef96ee3de..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientintegration.cpp +++ /dev/null @@ -1,411 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014-2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -// Local -#include "qmirclientintegration.h" -#include "qmirclientbackingstore.h" -#include "qmirclientclipboard.h" -#include "qmirclientdebugextension.h" -#include "qmirclientdesktopwindow.h" -#include "qmirclientglcontext.h" -#include "qmirclientinput.h" -#include "qmirclientlogging.h" -#include "qmirclientnativeinterface.h" -#include "qmirclientscreen.h" -#include "qmirclienttheme.h" -#include "qmirclientwindow.h" - -// Qt -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef QT_NO_ACCESSIBILITY -#include -#ifndef QT_NO_ACCESSIBILITY_ATSPI_BRIDGE -#include -#endif -#endif - -#include -#include - -// platform-api -#include -#include -#include - -static void resumedCallback(const UApplicationOptions */*options*/, void* context) -{ - auto integration = static_cast(context); - integration->appStateController()->setResumed(); -} - -static void aboutToStopCallback(UApplicationArchive */*archive*/, void* context) -{ - auto integration = static_cast(context); - auto inputContext = integration->inputContext(); - if (inputContext) { - inputContext->hideInputPanel(); - } else { - qCWarning(mirclient) << "aboutToStopCallback(): no input context"; - } - integration->appStateController()->setSuspended(); -} - -QMirClientClientIntegration::QMirClientClientIntegration(int argc, char **argv) - : QPlatformIntegration() - , mNativeInterface(new QMirClientNativeInterface(this)) - , mFontDb(new QGenericUnixFontDatabase) - , mServices(new QMirClientPlatformServices) - , mAppStateController(new QMirClientAppStateController) - , mScaleFactor(1.0) -{ - { - QStringList args = QCoreApplication::arguments(); - setupOptions(args); - QByteArray sessionName = generateSessionName(args); - setupDescription(sessionName); - } - - // Create new application instance - mInstance = u_application_instance_new_from_description_with_options(mDesc, mOptions); - - if (Q_UNLIKELY(!mInstance)) - qFatal("QMirClientClientIntegration: connection to Mir server failed. Check that a Mir server is\n" - "running, and the correct socket is being used and is accessible. The shell may have\n" - "rejected the incoming connection, so check its log file"); - - mMirConnection = u_application_instance_get_mir_connection(mInstance); - - // Choose the default surface format suited to the Mir platform - QSurfaceFormat defaultFormat; - defaultFormat.setRedBufferSize(8); - defaultFormat.setGreenBufferSize(8); - defaultFormat.setBlueBufferSize(8); - QSurfaceFormat::setDefaultFormat(defaultFormat); - - // Initialize EGL. - mEglNativeDisplay = mir_connection_get_egl_native_display(mMirConnection); - ASSERT((mEglDisplay = eglGetDisplay(mEglNativeDisplay)) != EGL_NO_DISPLAY); - ASSERT(eglInitialize(mEglDisplay, nullptr, nullptr) == EGL_TRUE); - - // Has debug mode been requsted, either with "-testability" switch or QT_LOAD_TESTABILITY env var - bool testability = qEnvironmentVariableIsSet("QT_LOAD_TESTABILITY"); - for (int i=1; !testability && iscreenAdded(screen); }); - connect(mScreenObserver.data(), &QMirClientScreenObserver::screenRemoved, - this, &QMirClientClientIntegration::destroyScreen); - - Q_FOREACH (auto screen, mScreenObserver->screens()) { - screenAdded(screen); - } - - // Initialize input. - mInput = new QMirClientInput(this); - mInputContext = QPlatformInputContextFactory::create(); - - // compute the scale factor - const int defaultGridUnit = 8; - int gridUnit = defaultGridUnit; - QByteArray gridUnitString = qgetenv("GRID_UNIT_PX"); - if (!gridUnitString.isEmpty()) { - bool ok; - gridUnit = gridUnitString.toInt(&ok); - if (!ok) { - gridUnit = defaultGridUnit; - } - } - mScaleFactor = static_cast(gridUnit) / defaultGridUnit; -} - -QMirClientClientIntegration::~QMirClientClientIntegration() -{ - eglTerminate(mEglDisplay); - delete mInput; - delete mInputContext; - delete mServices; -} - -QPlatformServices *QMirClientClientIntegration::services() const -{ - return mServices; -} - -void QMirClientClientIntegration::setupOptions(QStringList &args) -{ - int argc = args.size() + 1; - char **argv = new char*[argc]; - for (int i = 0; i < argc - 1; i++) - argv[i] = qstrdup(args.at(i).toLocal8Bit()); - argv[argc - 1] = nullptr; - - mOptions = u_application_options_new_from_cmd_line(argc - 1, argv); - - for (int i = 0; i < argc; i++) - delete [] argv[i]; - delete [] argv; -} - -void QMirClientClientIntegration::setupDescription(QByteArray &sessionName) -{ - mDesc = u_application_description_new(); - - UApplicationId* id = u_application_id_new_from_stringn(sessionName.data(), sessionName.count()); - u_application_description_set_application_id(mDesc, id); - - UApplicationLifecycleDelegate* delegate = u_application_lifecycle_delegate_new(); - u_application_lifecycle_delegate_set_application_resumed_cb(delegate, &resumedCallback); - u_application_lifecycle_delegate_set_application_about_to_stop_cb(delegate, &aboutToStopCallback); - u_application_lifecycle_delegate_set_context(delegate, this); - u_application_description_set_application_lifecycle_delegate(mDesc, delegate); -} - -QByteArray QMirClientClientIntegration::generateSessionName(QStringList &args) -{ - // Try to come up with some meaningful session name to uniquely identify this session, - // helping with shell debugging - - if (args.count() == 0) { - return QByteArray("QtUbuntu"); - } if (args[0].contains("qmlscene")) { - return generateSessionNameFromQmlFile(args); - } else { - // use the executable name - QFileInfo fileInfo(args[0]); - return fileInfo.fileName().toLocal8Bit(); - } -} - -QByteArray QMirClientClientIntegration::generateSessionNameFromQmlFile(QStringList &args) -{ - Q_FOREACH (QString arg, args) { - if (arg.endsWith(".qml")) { - QFileInfo fileInfo(arg); - return fileInfo.fileName().toLocal8Bit(); - } - } - - // give up - return "qmlscene"; -} - -QPlatformWindow* QMirClientClientIntegration::createPlatformWindow(QWindow* window) const -{ - if (window->type() == Qt::Desktop) { - // Desktop windows should not be backed up by a mir surface as they don't draw anything (nor should). - return new QMirClientDesktopWindow(window); - } else { - return new QMirClientWindow(window, mInput, mNativeInterface, mAppStateController.data(), - mEglDisplay, mMirConnection, mDebugExtension.data()); - } -} - -bool QMirClientClientIntegration::hasCapability(QPlatformIntegration::Capability cap) const -{ - switch (cap) { - case ThreadedOpenGL: - if (qEnvironmentVariableIsEmpty("QTUBUNTU_NO_THREADED_OPENGL")) { - return true; - } else { - qCDebug(mirclient, "disabled threaded OpenGL"); - return false; - } - - case ThreadedPixmaps: - case OpenGL: - case ApplicationState: - case MultipleWindows: - case NonFullScreenWindows: -#if QT_VERSION > QT_VERSION_CHECK(5, 5, 0) - case SwitchableWidgetComposition: -#endif - case RasterGLSurface: // needed for QQuickWidget - return true; - default: - return QPlatformIntegration::hasCapability(cap); - } -} - -QAbstractEventDispatcher *QMirClientClientIntegration::createEventDispatcher() const -{ - return createUnixEventDispatcher(); -} - -QPlatformBackingStore* QMirClientClientIntegration::createPlatformBackingStore(QWindow* window) const -{ - return new QMirClientBackingStore(window); -} - -QPlatformOpenGLContext* QMirClientClientIntegration::createPlatformOpenGLContext( - QOpenGLContext* context) const -{ - QSurfaceFormat format(context->format()); - - auto platformContext = new QMirClientOpenGLContext(format, context->shareHandle(), mEglDisplay); - if (!platformContext->isValid()) { - // Older Intel Atom-based devices only support OpenGL 1.4 compatibility profile but by default - // QML asks for at least OpenGL 2.0. The XCB GLX backend ignores this request and returns a - // 1.4 context, but the XCB EGL backend tries to honor it, and fails. The 1.4 context appears to - // have sufficient capabilities on MESA (i915) to render correctly however. So reduce the default - // requested OpenGL version to 1.0 to ensure EGL will give us a working context (lp:1549455). - static const bool isMesa = QString(eglQueryString(mEglDisplay, EGL_VENDOR)).contains(QStringLiteral("Mesa")); - if (isMesa) { - qCDebug(mirclientGraphics, "Attempting to choose OpenGL 1.4 context which may suit Mesa"); - format.setMajorVersion(1); - format.setMinorVersion(4); - delete platformContext; - platformContext = new QMirClientOpenGLContext(format, context->shareHandle(), mEglDisplay); - } - } - return platformContext; -} - -QStringList QMirClientClientIntegration::themeNames() const -{ - return QStringList(QMirClientTheme::name); -} - -QPlatformTheme* QMirClientClientIntegration::createPlatformTheme(const QString& name) const -{ - Q_UNUSED(name); - return new QMirClientTheme; -} - -QVariant QMirClientClientIntegration::styleHint(StyleHint hint) const -{ - switch (hint) { - case QPlatformIntegration::StartDragDistance: { - // default is 10 pixels (see QPlatformTheme::defaultThemeHint) - return 10.0 * mScaleFactor; - } - case QPlatformIntegration::PasswordMaskDelay: { - // return time in milliseconds - 1 second - return QVariant(1000); - } - default: - break; - } - return QPlatformIntegration::styleHint(hint); -} - -QPlatformClipboard* QMirClientClientIntegration::clipboard() const -{ - static QPlatformClipboard *clipboard = nullptr; - if (!clipboard) { - clipboard = new QMirClientClipboard; - } - return clipboard; -} - -QPlatformNativeInterface* QMirClientClientIntegration::nativeInterface() const -{ - return mNativeInterface; -} - -QPlatformOffscreenSurface *QMirClientClientIntegration::createPlatformOffscreenSurface( - QOffscreenSurface *surface) const -{ - return new QEGLPbuffer(mEglDisplay, surface->requestedFormat(), surface); -} - -void QMirClientClientIntegration::destroyScreen(QMirClientScreen *screen) -{ - // FIXME: on deleting a screen while a Window is on it, Qt will automatically - // move the window to the primaryScreen(). This will trigger a screenChanged - // signal, causing things like QQuickScreenAttached to re-fetch screen properties - // like DPI and physical size. However this is crashing, as Qt is calling virtual - // functions on QPlatformScreen, for reasons unclear. As workaround, move window - // to primaryScreen() before deleting the screen. Might be QTBUG-38650 - - QScreen *primaryScreen = QGuiApplication::primaryScreen(); - if (screen != primaryScreen->handle()) { - uint32_t movedWindowCount = 0; - Q_FOREACH (QWindow *w, QGuiApplication::topLevelWindows()) { - if (w->screen()->handle() == screen) { - QWindowSystemInterface::handleWindowScreenChanged(w, primaryScreen); - ++movedWindowCount; - } - } - if (movedWindowCount > 0) { - QWindowSystemInterface::flushWindowSystemEvents(); - } - } - - qCDebug(mirclient) << "Removing Screen with id" << screen->mirOutputId() << "and geometry" << screen->geometry(); -#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0) - delete screen; -#else - QPlatformIntegration::destroyScreen(screen); -#endif -} - -#ifndef QT_NO_ACCESSIBILITY -QPlatformAccessibility *QMirClientClientIntegration::accessibility() const -{ -#if !defined(QT_NO_ACCESSIBILITY_ATSPI_BRIDGE) - if (!mAccessibility) { - Q_ASSERT_X(QCoreApplication::eventDispatcher(), "QMirClientIntegration", - "Initializing accessibility without event-dispatcher!"); - mAccessibility.reset(new QSpiAccessibleBridge()); - } -#endif - return mAccessibility.data(); -} -#endif diff --git a/src/plugins/platforms/mirclient/qmirclientintegration.h b/src/plugins/platforms/mirclient/qmirclientintegration.h deleted file mode 100644 index 035117f4da..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientintegration.h +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QMIRCLIENTINTEGRATION_H -#define QMIRCLIENTINTEGRATION_H - -#include -#include - -#include "qmirclientappstatecontroller.h" -#include "qmirclientplatformservices.h" -#include "qmirclientscreenobserver.h" - -// platform-api -#include -#include - -#include - -class QMirClientDebugExtension; -class QMirClientInput; -class QMirClientNativeInterface; -class QMirClientScreen; -class MirConnection; - -class QMirClientClientIntegration : public QObject, public QPlatformIntegration -{ - Q_OBJECT - -public: - QMirClientClientIntegration(int argc, char **argv); - virtual ~QMirClientClientIntegration(); - - // QPlatformIntegration methods. - bool hasCapability(QPlatformIntegration::Capability cap) const override; - QAbstractEventDispatcher *createEventDispatcher() const override; - QPlatformNativeInterface* nativeInterface() const override; - QPlatformBackingStore* createPlatformBackingStore(QWindow* window) const override; - QPlatformOpenGLContext* createPlatformOpenGLContext(QOpenGLContext* context) const override; - QPlatformFontDatabase* fontDatabase() const override { return mFontDb; } - QStringList themeNames() const override; - QPlatformTheme* createPlatformTheme(const QString& name) const override; - QVariant styleHint(StyleHint hint) const override; - QPlatformServices *services() const override; - QPlatformWindow* createPlatformWindow(QWindow* window) const override; - QPlatformInputContext* inputContext() const override { return mInputContext; } - QPlatformClipboard* clipboard() const override; - void initialize() override; - QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const override; - QPlatformAccessibility *accessibility() const override; - - // New methods. - MirConnection *mirConnection() const { return mMirConnection; } - EGLDisplay eglDisplay() const { return mEglDisplay; } - EGLNativeDisplayType eglNativeDisplay() const { return mEglNativeDisplay; } - QMirClientAppStateController *appStateController() const { return mAppStateController.data(); } - QMirClientScreenObserver *screenObserver() const { return mScreenObserver.data(); } - QMirClientDebugExtension *debugExtension() const { return mDebugExtension.data(); } - -private Q_SLOTS: - void destroyScreen(QMirClientScreen *screen); - -private: - void setupOptions(QStringList &args); - void setupDescription(QByteArray &sessionName); - static QByteArray generateSessionName(QStringList &args); - static QByteArray generateSessionNameFromQmlFile(QStringList &args); - - QMirClientNativeInterface* mNativeInterface; - QPlatformFontDatabase* mFontDb; - - QMirClientPlatformServices* mServices; - - QMirClientInput* mInput; - QPlatformInputContext* mInputContext; - mutable QScopedPointer mAccessibility; - QScopedPointer mDebugExtension; - QScopedPointer mScreenObserver; - QScopedPointer mAppStateController; - qreal mScaleFactor; - - MirConnection *mMirConnection; - - // Platform API stuff - UApplicationOptions* mOptions; - UApplicationDescription* mDesc; - UApplicationInstance* mInstance; - - // EGL related - EGLDisplay mEglDisplay{EGL_NO_DISPLAY}; - EGLNativeDisplayType mEglNativeDisplay; -}; - -#endif // QMIRCLIENTINTEGRATION_H diff --git a/src/plugins/platforms/mirclient/qmirclientlogging.h b/src/plugins/platforms/mirclient/qmirclientlogging.h deleted file mode 100644 index 4921864ced..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientlogging.h +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QMIRCLIENTLOGGING_H -#define QMIRCLIENTLOGGING_H - -#include - -#define ASSERT(cond) ((!(cond)) ? qt_assert(#cond,__FILE__,__LINE__) : qt_noop()) - -Q_DECLARE_LOGGING_CATEGORY(mirclient) -Q_DECLARE_LOGGING_CATEGORY(mirclientBufferSwap) -Q_DECLARE_LOGGING_CATEGORY(mirclientInput) -Q_DECLARE_LOGGING_CATEGORY(mirclientGraphics) -Q_DECLARE_LOGGING_CATEGORY(mirclientCursor) -Q_DECLARE_LOGGING_CATEGORY(mirclientDebug) - -#endif // QMIRCLIENTLOGGING_H diff --git a/src/plugins/platforms/mirclient/qmirclientnativeinterface.cpp b/src/plugins/platforms/mirclient/qmirclientnativeinterface.cpp deleted file mode 100644 index b85e6fedfa..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientnativeinterface.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -// Local -#include "qmirclientnativeinterface.h" -#include "qmirclientscreen.h" -#include "qmirclientglcontext.h" -#include "qmirclientwindow.h" - -// Qt -#include -#include -#include -#include - -class UbuntuResourceMap : public QMap -{ -public: - UbuntuResourceMap() - : QMap() { - insert("egldisplay", QMirClientNativeInterface::EglDisplay); - insert("eglcontext", QMirClientNativeInterface::EglContext); - insert("nativeorientation", QMirClientNativeInterface::NativeOrientation); - insert("display", QMirClientNativeInterface::Display); - insert("mirconnection", QMirClientNativeInterface::MirConnection); - insert("mirsurface", QMirClientNativeInterface::MirSurface); - insert("scale", QMirClientNativeInterface::Scale); - insert("formfactor", QMirClientNativeInterface::FormFactor); - } -}; - -Q_GLOBAL_STATIC(UbuntuResourceMap, ubuntuResourceMap) - -QMirClientNativeInterface::QMirClientNativeInterface(const QMirClientClientIntegration *integration) - : mIntegration(integration) - , mGenericEventFilterType(QByteArrayLiteral("Event")) - , mNativeOrientation(nullptr) -{ -} - -QMirClientNativeInterface::~QMirClientNativeInterface() -{ - delete mNativeOrientation; - mNativeOrientation = nullptr; -} - -void* QMirClientNativeInterface::nativeResourceForIntegration(const QByteArray &resourceString) -{ - const QByteArray lowerCaseResource = resourceString.toLower(); - - if (!ubuntuResourceMap()->contains(lowerCaseResource)) { - return nullptr; - } - - const ResourceType resourceType = ubuntuResourceMap()->value(lowerCaseResource); - - if (resourceType == QMirClientNativeInterface::MirConnection) { - return mIntegration->mirConnection(); - } else { - return nullptr; - } -} - -void* QMirClientNativeInterface::nativeResourceForContext( - const QByteArray& resourceString, QOpenGLContext* context) -{ - if (!context) - return nullptr; - - const QByteArray kLowerCaseResource = resourceString.toLower(); - - if (!ubuntuResourceMap()->contains(kLowerCaseResource)) - return nullptr; - - const ResourceType kResourceType = ubuntuResourceMap()->value(kLowerCaseResource); - - if (kResourceType == QMirClientNativeInterface::EglContext) - return static_cast(context->handle())->eglContext(); - else - return nullptr; -} - -void* QMirClientNativeInterface::nativeResourceForWindow(const QByteArray& resourceString, QWindow* window) -{ - const QByteArray kLowerCaseResource = resourceString.toLower(); - if (!ubuntuResourceMap()->contains(kLowerCaseResource)) - return NULL; - const ResourceType kResourceType = ubuntuResourceMap()->value(kLowerCaseResource); - - switch (kResourceType) { - case EglDisplay: - return mIntegration->eglDisplay(); - case NativeOrientation: - // Return the device's native screen orientation. - if (window) { - QMirClientScreen *ubuntuScreen = static_cast(window->screen()->handle()); - mNativeOrientation = new Qt::ScreenOrientation(ubuntuScreen->nativeOrientation()); - } else { - QPlatformScreen *platformScreen = QGuiApplication::primaryScreen()->handle(); - mNativeOrientation = new Qt::ScreenOrientation(platformScreen->nativeOrientation()); - } - return mNativeOrientation; - case MirSurface: - if (window) { - auto ubuntuWindow = static_cast(window->handle()); - if (ubuntuWindow) { - return ubuntuWindow->mirSurface(); - } else { - return nullptr; - } - } else { - return nullptr; - } - default: - return nullptr; - } -} - -void* QMirClientNativeInterface::nativeResourceForScreen(const QByteArray& resourceString, QScreen* screen) -{ - const QByteArray kLowerCaseResource = resourceString.toLower(); - if (!ubuntuResourceMap()->contains(kLowerCaseResource)) - return NULL; - const ResourceType kResourceType = ubuntuResourceMap()->value(kLowerCaseResource); - if (!screen) - screen = QGuiApplication::primaryScreen(); - auto ubuntuScreen = static_cast(screen->handle()); - if (kResourceType == QMirClientNativeInterface::Display) { - return mIntegration->eglNativeDisplay(); - // Changes to the following properties are emitted via the QMirClientNativeInterface::screenPropertyChanged - // signal fired by QMirClientScreen. Connect to this signal for these properties updates. - // WARNING: code highly thread unsafe! - } else if (kResourceType == QMirClientNativeInterface::Scale) { - // In application code, read with: - // float scale = *reinterpret_cast(nativeResourceForScreen("scale", screen())); - return &ubuntuScreen->mScale; - } else if (kResourceType == QMirClientNativeInterface::FormFactor) { - return &ubuntuScreen->mFormFactor; - } else - return NULL; -} - -// Changes to these properties are emitted via the QMirClientNativeInterface::windowPropertyChanged -// signal fired by QMirClientWindow. Connect to this signal for these properties updates. -QVariantMap QMirClientNativeInterface::windowProperties(QPlatformWindow *window) const -{ - QVariantMap propertyMap; - auto w = static_cast(window); - if (w) { - propertyMap.insert("scale", w->scale()); - propertyMap.insert("formFactor", w->formFactor()); - } - return propertyMap; -} - -QVariant QMirClientNativeInterface::windowProperty(QPlatformWindow *window, const QString &name) const -{ - auto w = static_cast(window); - if (!w) { - return QVariant(); - } - - if (name == QStringLiteral("scale")) { - return w->scale(); - } else if (name == QStringLiteral("formFactor")) { - return w->formFactor(); - } else { - return QVariant(); - } -} - -QVariant QMirClientNativeInterface::windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const -{ - QVariant returnVal = windowProperty(window, name); - if (!returnVal.isValid()) { - return defaultValue; - } else { - return returnVal; - } -} diff --git a/src/plugins/platforms/mirclient/qmirclientnativeinterface.h b/src/plugins/platforms/mirclient/qmirclientnativeinterface.h deleted file mode 100644 index eb601de301..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientnativeinterface.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QMIRCLIENTNATIVEINTERFACE_H -#define QMIRCLIENTNATIVEINTERFACE_H - -#include - -#include "qmirclientintegration.h" - -class QPlatformScreen; - -class QMirClientNativeInterface : public QPlatformNativeInterface { - Q_OBJECT -public: - enum ResourceType { EglDisplay, EglContext, NativeOrientation, Display, MirConnection, MirSurface, Scale, FormFactor }; - - QMirClientNativeInterface(const QMirClientClientIntegration *integration); - ~QMirClientNativeInterface(); - - // QPlatformNativeInterface methods. - void* nativeResourceForIntegration(const QByteArray &resource) override; - void* nativeResourceForContext(const QByteArray& resourceString, - QOpenGLContext* context) override; - void* nativeResourceForWindow(const QByteArray& resourceString, - QWindow* window) override; - void* nativeResourceForScreen(const QByteArray& resourceString, - QScreen* screen) override; - - QVariantMap windowProperties(QPlatformWindow *window) const override; - QVariant windowProperty(QPlatformWindow *window, const QString &name) const override; - QVariant windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const override; - - // New methods. - const QByteArray& genericEventFilterType() const { return mGenericEventFilterType; } - -Q_SIGNALS: // New signals - void screenPropertyChanged(QPlatformScreen *screen, const QString &propertyName); - -private: - const QMirClientClientIntegration *mIntegration; - const QByteArray mGenericEventFilterType; - Qt::ScreenOrientation* mNativeOrientation; -}; - -#endif // QMIRCLIENTNATIVEINTERFACE_H diff --git a/src/plugins/platforms/mirclient/qmirclientorientationchangeevent_p.h b/src/plugins/platforms/mirclient/qmirclientorientationchangeevent_p.h deleted file mode 100644 index 5abd3262dc..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientorientationchangeevent_p.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QMIRCLIENTORIENTATIONCHANGEEVENT_P_H -#define QMIRCLIENTORIENTATIONCHANGEEVENT_P_H - -#include -#include "qmirclientlogging.h" - -class OrientationChangeEvent : public QEvent { -public: - enum Orientation { TopUp, LeftUp, TopDown, RightUp }; - - OrientationChangeEvent(QEvent::Type type, Orientation orientation) - : QEvent(type) - , mOrientation(orientation) - { - } - - static const QEvent::Type mType; - Orientation mOrientation; -}; - -#endif // QMIRCLIENTORIENTATIONCHANGEEVENT_P_H diff --git a/src/plugins/platforms/mirclient/qmirclientplatformservices.cpp b/src/plugins/platforms/mirclient/qmirclientplatformservices.cpp deleted file mode 100644 index 1ccd57fc28..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientplatformservices.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include "qmirclientplatformservices.h" - -#include - -#include -#include - -bool QMirClientPlatformServices::openUrl(const QUrl &url) -{ - return callDispatcher(url); -} - -bool QMirClientPlatformServices::openDocument(const QUrl &url) -{ - return callDispatcher(url); -} - -bool QMirClientPlatformServices::callDispatcher(const QUrl &url) -{ - UAUrlDispatcherSession* session = ua_url_dispatcher_session(); - if (!session) - return false; - - ua_url_dispatcher_session_open(session, url.toEncoded().constData(), NULL, NULL); - - free(session); - - // We are returning true here because the other option - // is spawning a nested event loop and wait for the - // callback. But there is no guarantee on how fast - // the callback is going to be so we prefer to avoid the - // nested event loop. Long term plan is improve Qt API - // to support an async openUrl - return true; -} diff --git a/src/plugins/platforms/mirclient/qmirclientplatformservices.h b/src/plugins/platforms/mirclient/qmirclientplatformservices.h deleted file mode 100644 index a1cd5758ca..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientplatformservices.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QMIRCLIENTPLATFORMSERVICES_H -#define QMIRCLIENTPLATFORMSERVICES_H - -#include -#include -#include - -class QMirClientPlatformServices : public QPlatformServices { -public: - bool openUrl(const QUrl &url) override; - bool openDocument(const QUrl &url) override; - -private: - bool callDispatcher(const QUrl &url); -}; - -#endif // QMIRCLIENTPLATFORMSERVICES_H diff --git a/src/plugins/platforms/mirclient/qmirclientplugin.cpp b/src/plugins/platforms/mirclient/qmirclientplugin.cpp deleted file mode 100644 index fc44edfe40..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientplugin.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include "qmirclientplugin.h" -#include "qmirclientintegration.h" -#include "qmirclientlogging.h" - -Q_LOGGING_CATEGORY(mirclient, "qt.qpa.mirclient", QtWarningMsg) - -QPlatformIntegration *QMirClientIntegrationPlugin::create(const QString &system, - const QStringList &/*paramList*/, - int &argc, char **argv) -{ - if (system.toLower() == QLatin1String("mirclient")) { - return new QMirClientClientIntegration(argc, argv); - } else { - return 0; - } -} diff --git a/src/plugins/platforms/mirclient/qmirclientplugin.h b/src/plugins/platforms/mirclient/qmirclientplugin.h deleted file mode 100644 index 207d97b5af..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientplugin.h +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QMIRCLIENTPLUGIN_H -#define QMIRCLIENTPLUGIN_H - -#include - -class QMirClientIntegrationPlugin : public QPlatformIntegrationPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "mirclient.json") - -public: - QPlatformIntegration *create(const QString &system, const QStringList ¶mList, - int &argc, char **argv) override; -}; - -#endif // QMIRCLIENTPLUGIN_H diff --git a/src/plugins/platforms/mirclient/qmirclientscreen.cpp b/src/plugins/platforms/mirclient/qmirclientscreen.cpp deleted file mode 100644 index cc8db830aa..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientscreen.cpp +++ /dev/null @@ -1,262 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014-2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -// local -#include "qmirclientscreen.h" -#include "qmirclientlogging.h" -#include "qmirclientorientationchangeevent_p.h" -#include "qmirclientnativeinterface.h" - -#include - -// Qt -#include -#include -#include -#include -#include -#include - -#include - -static const int overrideDevicePixelRatio = qgetenv("QT_DEVICE_PIXEL_RATIO").toInt(); - -static const char *orientationToStr(Qt::ScreenOrientation orientation) { - switch (orientation) { - case Qt::PrimaryOrientation: - return "primary"; - case Qt::PortraitOrientation: - return "portrait"; - case Qt::LandscapeOrientation: - return "landscape"; - case Qt::InvertedPortraitOrientation: - return "inverted portrait"; - case Qt::InvertedLandscapeOrientation: - return "inverted landscape"; - } - Q_UNREACHABLE(); -} - -const QEvent::Type OrientationChangeEvent::mType = - static_cast(QEvent::registerEventType()); - - -QMirClientScreen::QMirClientScreen(const MirOutput *output, MirConnection *connection) - : mDevicePixelRatio(1.0) - , mFormat(QImage::Format_RGB32) - , mDepth(32) - , mDpi{0} - , mFormFactor{mir_form_factor_unknown} - , mScale{1.0} - , mOutputId(0) - , mCursor(connection) -{ - setMirOutput(output); -} - -QMirClientScreen::~QMirClientScreen() -{ -} - -void QMirClientScreen::customEvent(QEvent* event) { - Q_ASSERT(QThread::currentThread() == thread()); - - OrientationChangeEvent* oReadingEvent = static_cast(event); - switch (oReadingEvent->mOrientation) { - case OrientationChangeEvent::LeftUp: { - mCurrentOrientation = (screen()->primaryOrientation() == Qt::LandscapeOrientation) ? - Qt::InvertedPortraitOrientation : Qt::LandscapeOrientation; - break; - } - case OrientationChangeEvent::TopUp: { - mCurrentOrientation = (screen()->primaryOrientation() == Qt::LandscapeOrientation) ? - Qt::LandscapeOrientation : Qt::PortraitOrientation; - break; - } - case OrientationChangeEvent::RightUp: { - mCurrentOrientation = (screen()->primaryOrientation() == Qt::LandscapeOrientation) ? - Qt::PortraitOrientation : Qt::InvertedLandscapeOrientation; - break; - } - case OrientationChangeEvent::TopDown: { - mCurrentOrientation = (screen()->primaryOrientation() == Qt::LandscapeOrientation) ? - Qt::InvertedLandscapeOrientation : Qt::InvertedPortraitOrientation; - break; - } - } - - // Raise the event signal so that client apps know the orientation changed - qCDebug(mirclient, "QMirClientScreen::customEvent - handling orientation change to %s", orientationToStr(mCurrentOrientation)); - QWindowSystemInterface::handleScreenOrientationChange(screen(), mCurrentOrientation); -} - -void QMirClientScreen::handleWindowSurfaceResize(int windowWidth, int windowHeight) -{ - if ((windowWidth > windowHeight && mGeometry.width() < mGeometry.height()) - || (windowWidth < windowHeight && mGeometry.width() > mGeometry.height())) { - - // The window aspect ratio differ's from the screen one. This means that - // unity8 has rotated the window in its scene. - // As there's no way to express window rotation in Qt's API, we have - // Flip QScreen's dimensions so that orientation properties match - // (primaryOrientation particularly). - // FIXME: This assumes a phone scenario. Won't work, or make sense, - // on the desktop - - QRect currGeometry = mGeometry; - mGeometry.setWidth(currGeometry.height()); - mGeometry.setHeight(currGeometry.width()); - - qCDebug(mirclient, "QMirClientScreen::handleWindowSurfaceResize - new screen geometry (w=%d, h=%d)", - mGeometry.width(), mGeometry.height()); - QWindowSystemInterface::handleScreenGeometryChange(screen(), - mGeometry /* newGeometry */, - mGeometry /* newAvailableGeometry */); - - if (mGeometry.width() < mGeometry.height()) { - mCurrentOrientation = Qt::PortraitOrientation; - } else { - mCurrentOrientation = Qt::LandscapeOrientation; - } - qCDebug(mirclient, "QMirClientScreen::handleWindowSurfaceResize - new orientation %s",orientationToStr(mCurrentOrientation)); - QWindowSystemInterface::handleScreenOrientationChange(screen(), mCurrentOrientation); - } -} - -void QMirClientScreen::setMirOutput(const MirOutput *output) -{ - // Physical screen size (in mm) - mPhysicalSize.setWidth(mir_output_get_physical_width_mm(output)); - mPhysicalSize.setHeight(mir_output_get_physical_height_mm(output)); - - // Pixel Format -// mFormat = qImageFormatFromMirPixelFormat(mir_output_get_current_pixel_format(output)); // GERRY: TODO - - // Pixel depth - mDepth = 8 * MIR_BYTES_PER_PIXEL(mir_output_get_current_pixel_format(output)); - - // Mode = Resolution & refresh rate - const MirOutputMode *mode = mir_output_get_current_mode(output); - mNativeGeometry.setX(mir_output_get_position_x(output)); - mNativeGeometry.setY(mir_output_get_position_y(output)); - mNativeGeometry.setWidth(mir_output_mode_get_width(mode)); - mNativeGeometry.setHeight(mir_output_mode_get_height(mode)); - - mRefreshRate = mir_output_mode_get_refresh_rate(mode); - - // UI scale & DPR - mScale = mir_output_get_scale_factor(output); - if (overrideDevicePixelRatio > 0) { - mDevicePixelRatio = overrideDevicePixelRatio; - } else { - mDevicePixelRatio = 1.0; // FIXME - need to determine suitable DPR for the specified scale - } - - mFormFactor = mir_output_get_form_factor(output); - - mOutputId = mir_output_get_id(output); - - mGeometry.setX(mNativeGeometry.x()); - mGeometry.setY(mNativeGeometry.y()); - mGeometry.setWidth(mNativeGeometry.width()); - mGeometry.setHeight(mNativeGeometry.height()); - - // Set the default orientation based on the initial screen dimensions. - mNativeOrientation = (mGeometry.width() >= mGeometry.height()) ? Qt::LandscapeOrientation : Qt::PortraitOrientation; - - // If it's a landscape device (i.e. some tablets), start in landscape, otherwise portrait - mCurrentOrientation = (mNativeOrientation == Qt::LandscapeOrientation) ? Qt::LandscapeOrientation : Qt::PortraitOrientation; -} - -void QMirClientScreen::updateMirOutput(const MirOutput *output) -{ - auto oldRefreshRate = mRefreshRate; - auto oldScale = mScale; - auto oldFormFactor = mFormFactor; - auto oldGeometry = mGeometry; - - setMirOutput(output); - - // Emit change signals in particular order - if (oldGeometry != mGeometry) { - QWindowSystemInterface::handleScreenGeometryChange(screen(), - mGeometry /* newGeometry */, - mGeometry /* newAvailableGeometry */); - } - - if (!qFuzzyCompare(mRefreshRate, oldRefreshRate)) { - QWindowSystemInterface::handleScreenRefreshRateChange(screen(), mRefreshRate); - } - - auto nativeInterface = static_cast(qGuiApp->platformNativeInterface()); - if (!qFuzzyCompare(mScale, oldScale)) { - nativeInterface->screenPropertyChanged(this, QStringLiteral("scale")); - } - if (mFormFactor != oldFormFactor) { - nativeInterface->screenPropertyChanged(this, QStringLiteral("formFactor")); - } -} - -void QMirClientScreen::setAdditionalMirDisplayProperties(float scale, MirFormFactor formFactor, int dpi) -{ - if (mDpi != dpi) { - mDpi = dpi; - QWindowSystemInterface::handleScreenLogicalDotsPerInchChange(screen(), dpi, dpi); - } - - auto nativeInterface = static_cast(qGuiApp->platformNativeInterface()); - if (!qFuzzyCompare(mScale, scale)) { - mScale = scale; - nativeInterface->screenPropertyChanged(this, QStringLiteral("scale")); - } - if (mFormFactor != formFactor) { - mFormFactor = formFactor; - nativeInterface->screenPropertyChanged(this, QStringLiteral("formFactor")); - } -} - -QDpi QMirClientScreen::logicalDpi() const -{ - if (mDpi > 0) { - return QDpi(mDpi, mDpi); - } else { - return QPlatformScreen::logicalDpi(); - } -} diff --git a/src/plugins/platforms/mirclient/qmirclientscreen.h b/src/plugins/platforms/mirclient/qmirclientscreen.h deleted file mode 100644 index b31cba1964..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientscreen.h +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014-2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QMIRCLIENTSCREEN_H -#define QMIRCLIENTSCREEN_H - -#include -#include - -#include // just for MirFormFactor enum - -#include "qmirclientcursor.h" - -struct MirConnection; -struct MirOutput; - -class QMirClientScreen : public QObject, public QPlatformScreen -{ - Q_OBJECT -public: - QMirClientScreen(const MirOutput *output, MirConnection *connection); - virtual ~QMirClientScreen(); - - // QPlatformScreen methods. - QImage::Format format() const override { return mFormat; } - int depth() const override { return mDepth; } - QRect geometry() const override { return mGeometry; } - QRect availableGeometry() const override { return mGeometry; } - QSizeF physicalSize() const override { return mPhysicalSize; } - qreal devicePixelRatio() const override { return mDevicePixelRatio; } - QDpi logicalDpi() const override; - Qt::ScreenOrientation nativeOrientation() const override { return mNativeOrientation; } - Qt::ScreenOrientation orientation() const override { return mNativeOrientation; } - QPlatformCursor *cursor() const override { return const_cast(&mCursor); } - - // Additional Screen properties from Mir - int mirOutputId() const { return mOutputId; } - MirFormFactor formFactor() const { return mFormFactor; } - float scale() const { return mScale; } - - // Internally used methods - void updateMirOutput(const MirOutput *output); - void setAdditionalMirDisplayProperties(float scale, MirFormFactor formFactor, int dpi); - void handleWindowSurfaceResize(int width, int height); - - // QObject methods. - void customEvent(QEvent* event) override; - -private: - void setMirOutput(const MirOutput *output); - - QRect mGeometry, mNativeGeometry; - QSizeF mPhysicalSize; - qreal mDevicePixelRatio; - Qt::ScreenOrientation mNativeOrientation; - Qt::ScreenOrientation mCurrentOrientation; - QImage::Format mFormat; - int mDepth; - int mDpi; - qreal mRefreshRate; - MirFormFactor mFormFactor; - float mScale; - int mOutputId; - QMirClientCursor mCursor; - - friend class QMirClientNativeInterface; -}; - -#endif // QMIRCLIENTSCREEN_H diff --git a/src/plugins/platforms/mirclient/qmirclientscreenobserver.cpp b/src/plugins/platforms/mirclient/qmirclientscreenobserver.cpp deleted file mode 100644 index 792aeca351..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientscreenobserver.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include "qmirclientscreenobserver.h" -#include "qmirclientscreen.h" -#include "qmirclientwindow.h" -#include "qmirclientlogging.h" - -// Qt -#include -#include - -// Mir -#include -#include - -#include - -namespace { - static void displayConfigurationChangedCallback(MirConnection */*connection*/, void* context) - { - ASSERT(context != NULL); - QMirClientScreenObserver *observer = static_cast(context); - QMetaObject::invokeMethod(observer, "update"); - } - - const char *mirFormFactorToStr(MirFormFactor formFactor) - { - switch (formFactor) { - case mir_form_factor_unknown: return "unknown"; - case mir_form_factor_phone: return "phone"; - case mir_form_factor_tablet: return "tablet"; - case mir_form_factor_monitor: return "monitor"; - case mir_form_factor_tv: return "tv"; - case mir_form_factor_projector: return "projector"; - } - Q_UNREACHABLE(); - } -} // anonymous namespace - -QMirClientScreenObserver::QMirClientScreenObserver(MirConnection *mirConnection) - : mMirConnection(mirConnection) -{ - mir_connection_set_display_config_change_callback(mirConnection, ::displayConfigurationChangedCallback, this); - update(); -} - -void QMirClientScreenObserver::update() -{ - // Wrap MirDisplayConfiguration to always delete when out of scope - auto configDeleter = [](MirDisplayConfig *config) { mir_display_config_release(config); }; - using configUp = std::unique_ptr; - configUp displayConfig(mir_connection_create_display_configuration(mMirConnection), configDeleter); - - // Mir only tells us something changed, it is up to us to figure out what. - QList newScreenList; - QList oldScreenList = mScreenList; - mScreenList.clear(); - - for (int i = 0; i < mir_display_config_get_num_outputs(displayConfig.get()); i++) { - const MirOutput *output = mir_display_config_get_output(displayConfig.get(), i); - if (mir_output_is_enabled(output)) { - QMirClientScreen *screen = findScreenWithId(oldScreenList, mir_output_get_id(output)); - if (screen) { // we've already set up this display before - screen->updateMirOutput(output); - oldScreenList.removeAll(screen); - } else { - // new display, so create QMirClientScreen for it - screen = new QMirClientScreen(output, mMirConnection); - newScreenList.append(screen); - qCDebug(mirclient) << "Added Screen with id" << mir_output_get_id(output) - << "and geometry" << screen->geometry(); - } - mScreenList.append(screen); - } - } - - // Announce old & unused Screens, should be deleted by the slot - Q_FOREACH (const auto screen, oldScreenList) { - Q_EMIT screenRemoved(screen); - } - - /* - * Mir's MirDisplayOutput does not include formFactor or scale for some reason, but Qt - * will want that information on creating the QScreen. Only way we get that info is when - * Mir positions a Window on that Screen. See "handleScreenPropertiesChange" method - */ - - // Announce new Screens - Q_FOREACH (const auto screen, newScreenList) { - Q_EMIT screenAdded(screen); - } - - qCDebug(mirclient) << "======================================="; - for (auto screen: mScreenList) { - qCDebug(mirclient) << screen << "- id:" << screen->mirOutputId() - << "geometry:" << screen->geometry() - << "form factor:" << mirFormFactorToStr(screen->formFactor()) - << "scale:" << screen->scale(); - } - qCDebug(mirclient) << "======================================="; -} - -QMirClientScreen *QMirClientScreenObserver::findScreenWithId(int id) -{ - return findScreenWithId(mScreenList, id); -} - -QMirClientScreen *QMirClientScreenObserver::findScreenWithId(const QList &list, int id) -{ - Q_FOREACH (const auto screen, list) { - if (screen->mirOutputId() == id) { - return screen; - } - } - return nullptr; -} - -void QMirClientScreenObserver::handleScreenPropertiesChange(QMirClientScreen *screen, int dpi, - MirFormFactor formFactor, float scale) -{ - screen->setAdditionalMirDisplayProperties(scale, formFactor, dpi); -} - diff --git a/src/plugins/platforms/mirclient/qmirclientscreenobserver.h b/src/plugins/platforms/mirclient/qmirclientscreenobserver.h deleted file mode 100644 index ad927319c1..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientscreenobserver.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QMIRCLIENTSCREENOBSERVER_H -#define QMIRCLIENTSCREENOBSERVER_H - -#include - -#include - -class QMirClientScreen; - -class QMirClientScreenObserver : public QObject -{ - Q_OBJECT - -public: - QMirClientScreenObserver(MirConnection *connection); - - QList screens() const { return mScreenList; } - QMirClientScreen *findScreenWithId(int id); - - void handleScreenPropertiesChange(QMirClientScreen *screen, int dpi, - MirFormFactor formFactor, float scale); - -Q_SIGNALS: - void screenAdded(QMirClientScreen *screen); - void screenRemoved(QMirClientScreen *screen); - -private Q_SLOTS: - void update(); - -private: - QMirClientScreen *findScreenWithId(const QList &list, int id); - void removeScreen(QMirClientScreen *screen); - - MirConnection *mMirConnection; - QList mScreenList; -}; - -#endif // QMIRCLIENTSCREENOBSERVER_H diff --git a/src/plugins/platforms/mirclient/qmirclienttheme.cpp b/src/plugins/platforms/mirclient/qmirclienttheme.cpp deleted file mode 100644 index dcfef7ca67..0000000000 --- a/src/plugins/platforms/mirclient/qmirclienttheme.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include "qmirclienttheme.h" - -#include - -const char *QMirClientTheme::name = "ubuntu"; - -QMirClientTheme::QMirClientTheme() -{ -} - -QMirClientTheme::~QMirClientTheme() -{ -} - -QVariant QMirClientTheme::themeHint(ThemeHint hint) const -{ - if (hint == QPlatformTheme::SystemIconThemeName) { - QByteArray iconTheme = qgetenv("QTUBUNTU_ICON_THEME"); - if (iconTheme.isEmpty()) { - return QVariant(QStringLiteral("ubuntu-mobile")); - } else { - return QVariant(QString(iconTheme)); - } - } else { - return QGenericUnixTheme::themeHint(hint); - } -} diff --git a/src/plugins/platforms/mirclient/qmirclienttheme.h b/src/plugins/platforms/mirclient/qmirclienttheme.h deleted file mode 100644 index 4bab1d0ee0..0000000000 --- a/src/plugins/platforms/mirclient/qmirclienttheme.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QMIRCLIENTTHEME_H -#define QMIRCLIENTTHEME_H - -#include - -class QMirClientTheme : public QGenericUnixTheme -{ -public: - static const char* name; - QMirClientTheme(); - virtual ~QMirClientTheme(); - - // From QPlatformTheme - QVariant themeHint(ThemeHint hint) const override; -}; - -#endif // QMIRCLIENTTHEME_H diff --git a/src/plugins/platforms/mirclient/qmirclientwindow.cpp b/src/plugins/platforms/mirclient/qmirclientwindow.cpp deleted file mode 100644 index decd21516e..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientwindow.cpp +++ /dev/null @@ -1,968 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014-2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -// Local -#include "qmirclientwindow.h" -#include "qmirclientdebugextension.h" -#include "qmirclientnativeinterface.h" -#include "qmirclientinput.h" -#include "qmirclientintegration.h" -#include "qmirclientscreen.h" -#include "qmirclientlogging.h" - -#include -#include - -// Qt -#include -#include -#include -#include -#include - -// Platform API -#include - -#include - -Q_LOGGING_CATEGORY(mirclientBufferSwap, "qt.qpa.mirclient.bufferSwap", QtWarningMsg) - -namespace -{ -const Qt::WindowType LowChromeWindowHint = (Qt::WindowType)0x00800000; - -// FIXME: this used to be defined by platform-api, but it's been removed in v3. Change ubuntu-keyboard to use -// a different enum for window roles. -enum UAUiWindowRole { - U_MAIN_ROLE = 1, - U_DASH_ROLE, - U_INDICATOR_ROLE, - U_NOTIFICATIONS_ROLE, - U_GREETER_ROLE, - U_LAUNCHER_ROLE, - U_ON_SCREEN_KEYBOARD_ROLE, - U_SHUTDOWN_DIALOG_ROLE, -}; - -struct MirSpecDeleter -{ - void operator()(MirSurfaceSpec *spec) { mir_surface_spec_release(spec); } -}; - -using Spec = std::unique_ptr; - -EGLNativeWindowType nativeWindowFor(MirSurface *surf) -{ - auto stream = mir_surface_get_buffer_stream(surf); - return reinterpret_cast(mir_buffer_stream_get_egl_native_window(stream)); -} - -const char *qtWindowStateToStr(Qt::WindowState state) -{ - switch (state) { - case Qt::WindowNoState: - return "NoState"; - case Qt::WindowFullScreen: - return "FullScreen"; - case Qt::WindowMaximized: - return "Maximized"; - case Qt::WindowMinimized: - return "Minimized"; - case Qt::WindowActive: - return "Active"; - } - Q_UNREACHABLE(); -} - -const char *mirSurfaceStateToStr(MirSurfaceState surfaceState) -{ - switch (surfaceState) { - case mir_surface_state_unknown: return "unknown"; - case mir_surface_state_restored: return "restored"; - case mir_surface_state_minimized: return "minimized"; - case mir_surface_state_maximized: return "vertmaximized"; - case mir_surface_state_vertmaximized: return "vertmaximized"; - case mir_surface_state_fullscreen: return "fullscreen"; - case mir_surface_state_horizmaximized: return "horizmaximized"; - case mir_surface_state_hidden: return "hidden"; - case mir_surface_states: Q_UNREACHABLE(); - } - Q_UNREACHABLE(); -} - -const char *mirPixelFormatToStr(MirPixelFormat pixelFormat) -{ - switch (pixelFormat) { - case mir_pixel_format_invalid: return "invalid"; - case mir_pixel_format_abgr_8888: return "ABGR8888"; - case mir_pixel_format_xbgr_8888: return "XBGR8888"; - case mir_pixel_format_argb_8888: return "ARGB8888"; - case mir_pixel_format_xrgb_8888: return "XRGB8888"; - case mir_pixel_format_bgr_888: return "BGR888"; - case mir_pixel_format_rgb_888: return "RGB888"; - case mir_pixel_format_rgb_565: return "RGB565"; - case mir_pixel_format_rgba_5551: return "RGBA5551"; - case mir_pixel_format_rgba_4444: return "RGBA4444"; - case mir_pixel_formats: Q_UNREACHABLE(); - } - Q_UNREACHABLE(); -} - -const char *mirSurfaceTypeToStr(MirSurfaceType type) -{ - switch (type) { - case mir_surface_type_normal: return "Normal"; /**< AKA "regular" */ - case mir_surface_type_utility: return "Utility"; /**< AKA "floating regular" */ - case mir_surface_type_dialog: return "Dialog"; - case mir_surface_type_gloss: return "Gloss"; - case mir_surface_type_freestyle: return "Freestyle"; - case mir_surface_type_menu: return "Menu"; - case mir_surface_type_inputmethod: return "Input Method"; /**< AKA "OSK" or handwriting etc. */ - case mir_surface_type_satellite: return "Satellite"; /**< AKA "toolbox"/"toolbar" */ - case mir_surface_type_tip: return "Tip"; /**< AKA "tooltip" */ - case mir_surface_types: Q_UNREACHABLE(); - } - return ""; -} - -MirSurfaceState qtWindowStateToMirSurfaceState(Qt::WindowState state) -{ - switch (state) { - case Qt::WindowNoState: - case Qt::WindowActive: - return mir_surface_state_restored; - case Qt::WindowFullScreen: - return mir_surface_state_fullscreen; - case Qt::WindowMaximized: - return mir_surface_state_maximized; - case Qt::WindowMinimized: - return mir_surface_state_minimized; - } - return mir_surface_state_unknown; // should never be reached -} - -MirSurfaceType qtWindowTypeToMirSurfaceType(Qt::WindowType type) -{ - switch (type & Qt::WindowType_Mask) { - case Qt::Dialog: - return mir_surface_type_dialog; - case Qt::Sheet: - case Qt::Drawer: - return mir_surface_type_utility; - case Qt::Popup: - case Qt::Tool: - return mir_surface_type_menu; - case Qt::ToolTip: - return mir_surface_type_tip; - case Qt::SplashScreen: - return mir_surface_type_freestyle; - case Qt::Window: - default: - return mir_surface_type_normal; - } -} - -WId makeId() -{ - static int id = 1; - return id++; -} - -UAUiWindowRole roleFor(QWindow *window) -{ - QVariant roleVariant = window->property("role"); - if (!roleVariant.isValid()) - return U_MAIN_ROLE; - - uint role = roleVariant.toUInt(); - if (role < U_MAIN_ROLE || role > U_SHUTDOWN_DIALOG_ROLE) - return U_MAIN_ROLE; - - return static_cast(role); -} - -QMirClientWindow *transientParentFor(QWindow *window) -{ - QWindow *parent = window->transientParent(); - return parent ? static_cast(parent->handle()) : nullptr; -} - -bool requiresParent(const MirSurfaceType type) -{ - switch (type) { - case mir_surface_type_dialog: //FIXME - not quite what the specification dictates, but is what Mir's api dictates - case mir_surface_type_utility: - case mir_surface_type_gloss: - case mir_surface_type_menu: - case mir_surface_type_satellite: - case mir_surface_type_tip: - return true; - default: - return false; - } -} - -bool requiresParent(const Qt::WindowType type) -{ - return requiresParent(qtWindowTypeToMirSurfaceType(type)); -} - -bool isMovable(const Qt::WindowType type) -{ - auto mirType = qtWindowTypeToMirSurfaceType(type); - switch (mirType) { - case mir_surface_type_menu: - case mir_surface_type_tip: - return true; - default: - return false; - } -} - -Spec makeSurfaceSpec(QWindow *window, MirPixelFormat pixelFormat, QMirClientWindow *parentWindowHandle, - MirConnection *connection) -{ - const auto geometry = window->geometry(); - const int width = geometry.width() > 0 ? geometry.width() : 1; - const int height = geometry.height() > 0 ? geometry.height() : 1; - auto type = qtWindowTypeToMirSurfaceType(window->type()); - - if (U_ON_SCREEN_KEYBOARD_ROLE == roleFor(window)) { - type = mir_surface_type_inputmethod; - } - - MirRectangle location{geometry.x(), geometry.y(), 0, 0}; - MirSurface *parent = nullptr; - if (parentWindowHandle) { - parent = parentWindowHandle->mirSurface(); - // Qt uses absolute positioning, but Mir positions surfaces relative to parent. - location.top -= parentWindowHandle->geometry().top(); - location.left -= parentWindowHandle->geometry().left(); - } - - Spec spec; - - switch (type) { - case mir_surface_type_menu: - spec = Spec{mir_connection_create_spec_for_menu(connection, width, height, pixelFormat, parent, - &location, mir_edge_attachment_any)}; - break; - case mir_surface_type_dialog: - spec = Spec{mir_connection_create_spec_for_modal_dialog(connection, width, height, pixelFormat, parent)}; - break; - case mir_surface_type_utility: - spec = Spec{mir_connection_create_spec_for_dialog(connection, width, height, pixelFormat)}; - break; - case mir_surface_type_tip: -#if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 4, 0) - spec = Spec{mir_connection_create_spec_for_tooltip(connection, width, height, pixelFormat, parent, - &location)}; -#else - spec = Spec{mir_connection_create_spec_for_tip(connection, width, height, pixelFormat, parent, - &location, mir_edge_attachment_any)}; -#endif - break; - case mir_surface_type_inputmethod: - spec = Spec{mir_connection_create_spec_for_input_method(connection, width, height, pixelFormat)}; - break; - default: - spec = Spec{mir_connection_create_spec_for_normal_surface(connection, width, height, pixelFormat)}; - break; - } - - qCDebug(mirclient, "makeSurfaceSpec(window=%p): %s spec (type=0x%x, position=(%d, %d)px, size=(%dx%d)px)", - window, mirSurfaceTypeToStr(type), window->type(), location.left, location.top, width, height); - - return std::move(spec); -} - -void setSizingConstraints(MirSurfaceSpec *spec, const QSize& minSize, const QSize& maxSize, const QSize& increment) -{ - mir_surface_spec_set_min_width(spec, minSize.width()); - mir_surface_spec_set_min_height(spec, minSize.height()); - if (maxSize.width() >= minSize.width()) { - mir_surface_spec_set_max_width(spec, maxSize.width()); - } - if (maxSize.height() >= minSize.height()) { - mir_surface_spec_set_max_height(spec, maxSize.height()); - } - if (increment.width() > 0) { - mir_surface_spec_set_width_increment(spec, increment.width()); - } - if (increment.height() > 0) { - mir_surface_spec_set_height_increment(spec, increment.height()); - } -} - -MirSurface *createMirSurface(QWindow *window, int mirOutputId, QMirClientWindow *parentWindowHandle, - MirPixelFormat pixelFormat, MirConnection *connection, - mir_surface_event_callback inputCallback, void *inputContext) -{ - auto spec = makeSurfaceSpec(window, pixelFormat, parentWindowHandle, connection); - - // Install event handler as early as possible - mir_surface_spec_set_event_handler(spec.get(), inputCallback, inputContext); - - const auto title = window->title().toUtf8(); - mir_surface_spec_set_name(spec.get(), title.constData()); - - setSizingConstraints(spec.get(), window->minimumSize(), window->maximumSize(), window->sizeIncrement()); - - if (window->windowState() == Qt::WindowFullScreen) { - mir_surface_spec_set_fullscreen_on_output(spec.get(), mirOutputId); - } - - if (window->flags() & LowChromeWindowHint) { - mir_surface_spec_set_shell_chrome(spec.get(), mir_shell_chrome_low); - } - - if (!window->isVisible()) { - mir_surface_spec_set_state(spec.get(), mir_surface_state_hidden); - } - - auto surface = mir_surface_create_sync(spec.get()); - Q_ASSERT(mir_surface_is_valid(surface)); - return surface; -} - -QMirClientWindow *getParentIfNecessary(QWindow *window, QMirClientInput *input) -{ - QMirClientWindow *parentWindowHandle = nullptr; - if (requiresParent(window->type())) { - parentWindowHandle = transientParentFor(window); - if (parentWindowHandle == nullptr) { - // NOTE: Mir requires this surface have a parent. Try using the last surface to receive input as that will - // most likely be the one that caused this surface to be created - parentWindowHandle = input->lastInputWindow(); - } - } - return parentWindowHandle; -} - -MirPixelFormat disableAlphaBufferIfPossible(MirPixelFormat pixelFormat) -{ - switch (pixelFormat) { - case mir_pixel_format_abgr_8888: - return mir_pixel_format_xbgr_8888; - case mir_pixel_format_argb_8888: - return mir_pixel_format_xrgb_8888; - default: // can do nothing, leave it alone - return pixelFormat; - } -} -} //namespace - - - -class UbuntuSurface -{ -public: - UbuntuSurface(QMirClientWindow *platformWindow, EGLDisplay display, QMirClientInput *input, MirConnection *connection); - ~UbuntuSurface(); - - UbuntuSurface(const UbuntuSurface &) = delete; - UbuntuSurface& operator=(const UbuntuSurface &) = delete; - - void updateGeometry(const QRect &newGeometry); - void updateTitle(const QString& title); - void setSizingConstraints(const QSize& minSize, const QSize& maxSize, const QSize& increment); - - void onSwapBuffersDone(); - void handleSurfaceResized(int width, int height); - int needsRepaint() const; - - MirSurfaceState state() const { return mir_surface_get_state(mMirSurface); } - void setState(MirSurfaceState state); - - MirSurfaceType type() const { return mir_surface_get_type(mMirSurface); } - - void setShellChrome(MirShellChrome shellChrome); - - EGLSurface eglSurface() const { return mEglSurface; } - MirSurface *mirSurface() const { return mMirSurface; } - - void setSurfaceParent(MirSurface*); - bool hasParent() const { return mParented; } - - QSurfaceFormat format() const { return mFormat; } - - bool mNeedsExposeCatchup; - - QString persistentSurfaceId(); - -private: - static void surfaceEventCallback(MirSurface* surface, const MirEvent *event, void* context); - void postEvent(const MirEvent *event); - - QWindow * const mWindow; - QMirClientWindow * const mPlatformWindow; - QMirClientInput * const mInput; - MirConnection * const mConnection; - QMirClientWindow * mParentWindowHandle{nullptr}; - - MirSurface* mMirSurface; - const EGLDisplay mEglDisplay; - EGLSurface mEglSurface; - - bool mNeedsRepaint; - bool mParented; - QSize mBufferSize; - QSurfaceFormat mFormat; - MirPixelFormat mPixelFormat; - - QMutex mTargetSizeMutex; - QSize mTargetSize; - MirShellChrome mShellChrome; - QString mPersistentIdStr; -}; - -UbuntuSurface::UbuntuSurface(QMirClientWindow *platformWindow, EGLDisplay display, QMirClientInput *input, MirConnection *connection) - : mWindow(platformWindow->window()) - , mPlatformWindow(platformWindow) - , mInput(input) - , mConnection(connection) - , mEglDisplay(display) - , mNeedsRepaint(false) - , mParented(mWindow->transientParent() || mWindow->parent()) - , mFormat(mWindow->requestedFormat()) - , mShellChrome(mWindow->flags() & LowChromeWindowHint ? mir_shell_chrome_low : mir_shell_chrome_normal) -{ - // Have Qt choose most suitable EGLConfig for the requested surface format, and update format to reflect it - EGLConfig config = q_configFromGLFormat(display, mFormat, true); - if (config == 0) { - // Older Intel Atom-based devices only support OpenGL 1.4 compatibility profile but by default - // QML asks for at least OpenGL 2.0. The XCB GLX backend ignores this request and returns a - // 1.4 context, but the XCB EGL backend tries to honor it, and fails. The 1.4 context appears to - // have sufficient capabilities on MESA (i915) to render correctly however. So reduce the default - // requested OpenGL version to 1.0 to ensure EGL will give us a working context (lp:1549455). - static const bool isMesa = QString(eglQueryString(display, EGL_VENDOR)).contains(QStringLiteral("Mesa")); - if (isMesa) { - qCDebug(mirclientGraphics, "Attempting to choose OpenGL 1.4 context which may suit Mesa"); - mFormat.setMajorVersion(1); - mFormat.setMinorVersion(4); - config = q_configFromGLFormat(display, mFormat, true); - } - } - if (config == 0) { - qCritical() << "Qt failed to choose a suitable EGLConfig to suit the surface format" << mFormat; - } - - mFormat = q_glFormatFromConfig(display, config, mFormat); - - // Have Mir decide the pixel format most suited to the chosen EGLConfig. This is the only way - // Mir will know what EGLConfig has been chosen - it cannot deduce it from the buffers. - mPixelFormat = mir_connection_get_egl_pixel_format(connection, display, config); - // But the chosen EGLConfig might have an alpha buffer enabled, even if not requested by the client. - // If that's the case, try to edit the chosen pixel format in order to disable the alpha buffer. - // This is an optimization for the compositor, as it can avoid blending this surface. - if (mWindow->requestedFormat().alphaBufferSize() < 0) { - mPixelFormat = disableAlphaBufferIfPossible(mPixelFormat); - } - - const auto outputId = static_cast(mWindow->screen()->handle())->mirOutputId(); - - mParentWindowHandle = getParentIfNecessary(mWindow, input); - - mMirSurface = createMirSurface(mWindow, outputId, mParentWindowHandle, mPixelFormat, connection, surfaceEventCallback, this); - mEglSurface = eglCreateWindowSurface(mEglDisplay, config, nativeWindowFor(mMirSurface), nullptr); - - mNeedsExposeCatchup = mir_surface_get_visibility(mMirSurface) == mir_surface_visibility_occluded; - - // Window manager can give us a final size different from what we asked for - // so let's check what we ended up getting - MirSurfaceParameters parameters; - mir_surface_get_parameters(mMirSurface, ¶meters); - - auto geom = mWindow->geometry(); - geom.setWidth(parameters.width); - geom.setHeight(parameters.height); - - // Assume that the buffer size matches the surface size at creation time - mBufferSize = geom.size(); - QWindowSystemInterface::handleGeometryChange(mWindow, geom); - - qCDebug(mirclient) << "Created surface with geometry:" << geom << "title:" << mWindow->title() - << "role:" << roleFor(mWindow); - qCDebug(mirclientGraphics) - << "Requested format:" << mWindow->requestedFormat() - << "\nActual format:" << mFormat - << "with associated Mir pixel format:" << mirPixelFormatToStr(mPixelFormat); -} - -UbuntuSurface::~UbuntuSurface() -{ - if (mEglSurface != EGL_NO_SURFACE) - eglDestroySurface(mEglDisplay, mEglSurface); - if (mMirSurface) { - mir_surface_release_sync(mMirSurface); - } -} - -void UbuntuSurface::updateGeometry(const QRect &newGeometry) -{ - qCDebug(mirclient,"updateGeometry(window=%p, width=%d, height=%d)", mWindow, - newGeometry.width(), newGeometry.height()); - - Spec spec; - if (isMovable(mWindow->type())) { - spec = Spec{makeSurfaceSpec(mWindow, mPixelFormat, mParentWindowHandle, mConnection)}; - } else { - spec = Spec{mir_connection_create_spec_for_changes(mConnection)}; - mir_surface_spec_set_width(spec.get(), newGeometry.width()); - mir_surface_spec_set_height(spec.get(), newGeometry.height()); - } - mir_surface_apply_spec(mMirSurface, spec.get()); -} - -void UbuntuSurface::updateTitle(const QString& newTitle) -{ - const auto title = newTitle.toUtf8(); - Spec spec{mir_connection_create_spec_for_changes(mConnection)}; - mir_surface_spec_set_name(spec.get(), title.constData()); - mir_surface_apply_spec(mMirSurface, spec.get()); -} - -void UbuntuSurface::setSizingConstraints(const QSize& minSize, const QSize& maxSize, const QSize& increment) -{ - Spec spec{mir_connection_create_spec_for_changes(mConnection)}; - ::setSizingConstraints(spec.get(), minSize, maxSize, increment); - mir_surface_apply_spec(mMirSurface, spec.get()); -} - -void UbuntuSurface::handleSurfaceResized(int width, int height) -{ - QMutexLocker lock(&mTargetSizeMutex); - - // mir's resize event is mainly a signal that we need to redraw our content. We use the - // width/height as identifiers to figure out if this is the latest surface resize event - // that has posted, discarding any old ones. This avoids issuing too many redraw events. - // see TODO in postEvent as the ideal way we should handle this. - // The actual buffer size may or may have not changed at this point, so let the rendering - // thread drive the window geometry updates. - mNeedsRepaint = mTargetSize.width() == width && mTargetSize.height() == height; -} - -int UbuntuSurface::needsRepaint() const -{ - if (mNeedsRepaint) { - if (mTargetSize != mBufferSize) { - //If the buffer hasn't changed yet, we need at least two redraws, - //once to get the new buffer size and propagate the geometry changes - //and the second to redraw the content at the new size - return 2; - } else { - // The buffer size has already been updated so we only need one redraw - // to render at the new size - return 1; - } - } - return 0; -} - -void UbuntuSurface::setState(MirSurfaceState state) -{ - mir_wait_for(mir_surface_set_state(mMirSurface, state)); -} - -void UbuntuSurface::setShellChrome(MirShellChrome chrome) -{ - if (chrome != mShellChrome) { - auto spec = Spec{mir_connection_create_spec_for_changes(mConnection)}; - mir_surface_spec_set_shell_chrome(spec.get(), chrome); - mir_surface_apply_spec(mMirSurface, spec.get()); - - mShellChrome = chrome; - } -} - -void UbuntuSurface::onSwapBuffersDone() -{ - static int sFrameNumber = 0; - ++sFrameNumber; - - EGLint eglSurfaceWidth = -1; - EGLint eglSurfaceHeight = -1; - eglQuerySurface(mEglDisplay, mEglSurface, EGL_WIDTH, &eglSurfaceWidth); - eglQuerySurface(mEglDisplay, mEglSurface, EGL_HEIGHT, &eglSurfaceHeight); - - const bool validSize = eglSurfaceWidth > 0 && eglSurfaceHeight > 0; - - if (validSize && (mBufferSize.width() != eglSurfaceWidth || mBufferSize.height() != eglSurfaceHeight)) { - - qCDebug(mirclientBufferSwap, "onSwapBuffersDone(window=%p) [%d] - size changed (%d, %d) => (%d, %d)", - mWindow, sFrameNumber, mBufferSize.width(), mBufferSize.height(), eglSurfaceWidth, eglSurfaceHeight); - - mBufferSize.rwidth() = eglSurfaceWidth; - mBufferSize.rheight() = eglSurfaceHeight; - - QRect newGeometry = mPlatformWindow->geometry(); - newGeometry.setSize(mBufferSize); - - QWindowSystemInterface::handleGeometryChange(mWindow, newGeometry); - } else { - qCDebug(mirclientBufferSwap, "onSwapBuffersDone(window=%p) [%d] - buffer size (%d,%d)", - mWindow, sFrameNumber, mBufferSize.width(), mBufferSize.height()); - } -} - -void UbuntuSurface::surfaceEventCallback(MirSurface *surface, const MirEvent *event, void* context) -{ - Q_UNUSED(surface); - Q_ASSERT(context != nullptr); - - auto s = static_cast(context); - s->postEvent(event); -} - -void UbuntuSurface::postEvent(const MirEvent *event) -{ - if (mir_event_type_resize == mir_event_get_type(event)) { - // TODO: The current event queue just accumulates all resize events; - // It would be nicer if we could update just one event if that event has not been dispatched. - // As a workaround, we use the width/height as an identifier of this latest event - // so the event handler (handleSurfaceResized) can discard/ignore old ones. - const auto resizeEvent = mir_event_get_resize_event(event); - const auto width = mir_resize_event_get_width(resizeEvent); - const auto height = mir_resize_event_get_height(resizeEvent); - qCDebug(mirclient, "resizeEvent(window=%p, width=%d, height=%d)", mWindow, width, height); - - QMutexLocker lock(&mTargetSizeMutex); - mTargetSize.rwidth() = width; - mTargetSize.rheight() = height; - } - - mInput->postEvent(mPlatformWindow, event); -} - -void UbuntuSurface::setSurfaceParent(MirSurface* parent) -{ - qCDebug(mirclient, "setSurfaceParent(window=%p)", mWindow); - - mParented = true; - Spec spec{mir_connection_create_spec_for_changes(mConnection)}; - mir_surface_spec_set_parent(spec.get(), parent); - mir_surface_apply_spec(mMirSurface, spec.get()); -} - -QString UbuntuSurface::persistentSurfaceId() -{ - if (mPersistentIdStr.isEmpty()) { - MirPersistentId* mirPermaId = mir_surface_request_persistent_id_sync(mMirSurface); - mPersistentIdStr = mir_persistent_id_as_string(mirPermaId); - mir_persistent_id_release(mirPermaId); - } - return mPersistentIdStr; -} - -QMirClientWindow::QMirClientWindow(QWindow *w, QMirClientInput *input, QMirClientNativeInterface *native, - QMirClientAppStateController *appState, EGLDisplay eglDisplay, - MirConnection *mirConnection, QMirClientDebugExtension *debugExt) - : QObject(nullptr) - , QPlatformWindow(w) - , mId(makeId()) - , mWindowState(w->windowState()) - , mWindowFlags(w->flags()) - , mWindowVisible(false) - , mAppStateController(appState) - , mDebugExtention(debugExt) - , mNativeInterface(native) - , mSurface(new UbuntuSurface{this, eglDisplay, input, mirConnection}) - , mScale(1.0) - , mFormFactor(mir_form_factor_unknown) -{ - mWindowExposed = mSurface->mNeedsExposeCatchup == false; - - qCDebug(mirclient, "QMirClientWindow(window=%p, screen=%p, input=%p, surf=%p) with title '%s', role: '%d'", - w, w->screen()->handle(), input, mSurface.get(), qPrintable(window()->title()), roleFor(window())); -} - -QMirClientWindow::~QMirClientWindow() -{ - qCDebug(mirclient, "~QMirClientWindow(window=%p)", this); -} - -void QMirClientWindow::handleSurfaceResized(int width, int height) -{ - QMutexLocker lock(&mMutex); - qCDebug(mirclient, "handleSurfaceResize(window=%p, size=(%dx%d)px", window(), width, height); - - mSurface->handleSurfaceResized(width, height); - - // This resize event could have occurred just after the last buffer swap for this window. - // This means the client may still be holding a buffer with the older size. The first redraw call - // will then render at the old size. After swapping the client now will get a new buffer with the - // updated size but it still needs re-rendering so another redraw may be needed. - // A mir API to drop the currently held buffer would help here, so that we wouldn't have to redraw twice - auto const numRepaints = mSurface->needsRepaint(); - lock.unlock(); - qCDebug(mirclient, "handleSurfaceResize(window=%p) redraw %d times", window(), numRepaints); - for (int i = 0; i < numRepaints; i++) { - qCDebug(mirclient, "handleSurfaceResize(window=%p) repainting size=(%dx%d)dp", window(), geometry().size().width(), geometry().size().height()); - QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size())); - } -} - -void QMirClientWindow::handleSurfaceExposeChange(bool exposed) -{ - QMutexLocker lock(&mMutex); - qCDebug(mirclient, "handleSurfaceExposeChange(window=%p, exposed=%s)", window(), exposed ? "true" : "false"); - - mSurface->mNeedsExposeCatchup = false; - if (mWindowExposed == exposed) return; - mWindowExposed = exposed; - - lock.unlock(); - QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size())); -} - -void QMirClientWindow::handleSurfaceFocusChanged(bool focused) -{ - qCDebug(mirclient, "handleSurfaceFocusChanged(window=%p, focused=%d)", window(), focused); - if (focused) { - mAppStateController->setWindowFocused(true); - QWindowSystemInterface::handleWindowActivated(window(), Qt::ActiveWindowFocusReason); - } else { - mAppStateController->setWindowFocused(false); - } -} - -void QMirClientWindow::handleSurfaceVisibilityChanged(bool visible) -{ - qCDebug(mirclient, "handleSurfaceVisibilityChanged(window=%p, visible=%d)", window(), visible); - - if (mWindowVisible == visible) return; - mWindowVisible = visible; - - QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size())); -} - -void QMirClientWindow::handleSurfaceStateChanged(Qt::WindowState state) -{ - qCDebug(mirclient, "handleSurfaceStateChanged(window=%p, %s)", window(), qtWindowStateToStr(state)); - - if (mWindowState == state) return; - mWindowState = state; - - QWindowSystemInterface::handleWindowStateChanged(window(), state); -} - -void QMirClientWindow::setWindowState(Qt::WindowStates states) -{ - Qt::WindowState state = Qt::WindowNoState; - if (states & Qt::WindowMinimized) - state = Qt::WindowMinimized; - else if (states & Qt::WindowFullScreen) - state = Qt::WindowFullScreen; - else if (states & Qt::WindowMaximized) - state = Qt::WindowMaximized; - - QMutexLocker lock(&mMutex); - qCDebug(mirclient, "setWindowState(window=%p, %s)", this, qtWindowStateToStr(state)); - - if (mWindowState == state) return; - mWindowState = state; - - lock.unlock(); - updateSurfaceState(); -} - -void QMirClientWindow::setWindowFlags(Qt::WindowFlags flags) -{ - QMutexLocker lock(&mMutex); - qCDebug(mirclient, "setWindowFlags(window=%p, 0x%x)", this, (int)flags); - - if (mWindowFlags == flags) return; - mWindowFlags = flags; - - mSurface->setShellChrome(mWindowFlags & LowChromeWindowHint ? mir_shell_chrome_low : mir_shell_chrome_normal); -} - -QRect QMirClientWindow::geometry() const -{ - if (mDebugExtention) { - auto geom = QPlatformWindow::geometry(); - geom.moveTopLeft(mDebugExtention->mapSurfacePointToScreen(mSurface->mirSurface(), QPoint(0,0))); - return geom; - } else { - return QPlatformWindow::geometry(); - } -} - -void QMirClientWindow::setGeometry(const QRect& rect) -{ - QMutexLocker lock(&mMutex); - - if (window()->windowState() == Qt::WindowFullScreen || window()->windowState() == Qt::WindowMaximized) { - qCDebug(mirclient, "setGeometry(window=%p) - not resizing, window is maximized or fullscreen", window()); - return; - } - - qCDebug(mirclient, "setGeometry (window=%p, position=(%d, %d)dp, size=(%dx%d)dp)", - window(), rect.x(), rect.y(), rect.width(), rect.height()); - // Immediately update internal geometry so Qt believes position updated - QRect newPosition(geometry()); - newPosition.moveTo(rect.topLeft()); - QPlatformWindow::setGeometry(newPosition); - - mSurface->updateGeometry(rect); - // Note: don't call handleGeometryChange here, wait to see what Mir replies with. -} - -void QMirClientWindow::setVisible(bool visible) -{ - QMutexLocker lock(&mMutex); - qCDebug(mirclient, "setVisible (window=%p, visible=%s)", window(), visible ? "true" : "false"); - - if (mWindowVisible == visible) return; - mWindowVisible = visible; - - if (visible) { - if (!mSurface->hasParent() && window()->type() == Qt::Dialog) { - // The dialog may have been parented after creation time - // so morph it into a modal dialog - auto parent = transientParentFor(window()); - if (parent) { - mSurface->setSurfaceParent(parent->mirSurface()); - } - } - } - - lock.unlock(); - updateSurfaceState(); - QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size())); -} - -void QMirClientWindow::setWindowTitle(const QString& title) -{ - QMutexLocker lock(&mMutex); - qCDebug(mirclient, "setWindowTitle(window=%p) title=%s)", window(), title.toUtf8().constData()); - mSurface->updateTitle(title); -} - -void QMirClientWindow::propagateSizeHints() -{ - QMutexLocker lock(&mMutex); - const auto win = window(); - qCDebug(mirclient, "propagateSizeHints(window=%p) min(%d,%d), max(%d,%d) increment(%d, %d)", - win, win->minimumSize().width(), win->minimumSize().height(), - win->maximumSize().width(), win->maximumSize().height(), - win->sizeIncrement().width(), win->sizeIncrement().height()); - mSurface->setSizingConstraints(win->minimumSize(), win->maximumSize(), win->sizeIncrement()); -} - -bool QMirClientWindow::isExposed() const -{ - // mNeedsExposeCatchup because we need to render a frame to get the expose surface event from mir. - return mWindowVisible && (mWindowExposed || (mSurface && mSurface->mNeedsExposeCatchup)); -} - -QSurfaceFormat QMirClientWindow::format() const -{ - return mSurface->format(); -} - -QPoint QMirClientWindow::mapToGlobal(const QPoint &pos) const -{ - if (mDebugExtention) { - return mDebugExtention->mapSurfacePointToScreen(mSurface->mirSurface(), pos); - } else { - return pos; - } -} - -void* QMirClientWindow::eglSurface() const -{ - return mSurface->eglSurface(); -} - -MirSurface *QMirClientWindow::mirSurface() const -{ - return mSurface->mirSurface(); -} - -WId QMirClientWindow::winId() const -{ - return mId; -} - -void QMirClientWindow::onSwapBuffersDone() -{ - QMutexLocker lock(&mMutex); - mSurface->onSwapBuffersDone(); - - if (mSurface->mNeedsExposeCatchup) { - mSurface->mNeedsExposeCatchup = false; - mWindowExposed = false; - - lock.unlock(); - QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size())); - } -} - -void QMirClientWindow::handleScreenPropertiesChange(MirFormFactor formFactor, float scale) -{ - // Update the scale & form factor native-interface properties for the windows affected - // as there is no convenient way to emit signals for those custom properties on a QScreen - if (formFactor != mFormFactor) { - mFormFactor = formFactor; - Q_EMIT mNativeInterface->windowPropertyChanged(this, QStringLiteral("formFactor")); - } - - if (!qFuzzyCompare(scale, mScale)) { - mScale = scale; - Q_EMIT mNativeInterface->windowPropertyChanged(this, QStringLiteral("scale")); - } -} - -void QMirClientWindow::updateSurfaceState() -{ - QMutexLocker lock(&mMutex); - MirSurfaceState newState = mWindowVisible ? qtWindowStateToMirSurfaceState(mWindowState) : - mir_surface_state_hidden; - qCDebug(mirclient, "updateSurfaceState (window=%p, surfaceState=%s)", window(), mirSurfaceStateToStr(newState)); - if (newState != mSurface->state()) { - mSurface->setState(newState); - } -} - -QString QMirClientWindow::persistentSurfaceId() -{ - return mSurface->persistentSurfaceId(); -} diff --git a/src/plugins/platforms/mirclient/qmirclientwindow.h b/src/plugins/platforms/mirclient/qmirclientwindow.h deleted file mode 100644 index 6c5695d62f..0000000000 --- a/src/plugins/platforms/mirclient/qmirclientwindow.h +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014-2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QMIRCLIENTWINDOW_H -#define QMIRCLIENTWINDOW_H - -#include -#include -#include - -#include // needed only for MirFormFactor enum - -#include - -#include - -class QMirClientAppStateController; -class QMirClientDebugExtension; -class QMirClientNativeInterface; -class QMirClientInput; -class QMirClientScreen; -class UbuntuSurface; -struct MirSurface; -class MirConnection; - -class QMirClientWindow : public QObject, public QPlatformWindow -{ - Q_OBJECT -public: - QMirClientWindow(QWindow *w, QMirClientInput *input, QMirClientNativeInterface* native, - QMirClientAppStateController *appState, EGLDisplay eglDisplay, - MirConnection *mirConnection, QMirClientDebugExtension *debugExt); - virtual ~QMirClientWindow(); - - // QPlatformWindow methods. - WId winId() const override; - QRect geometry() const override; - void setGeometry(const QRect&) override; - void setWindowState(Qt::WindowStates state) override; - void setWindowFlags(Qt::WindowFlags flags) override; - void setVisible(bool visible) override; - void setWindowTitle(const QString &title) override; - void propagateSizeHints() override; - bool isExposed() const override; - - QPoint mapToGlobal(const QPoint &pos) const override; - QSurfaceFormat format() const override; - - // Additional Window properties exposed by NativeInterface - MirFormFactor formFactor() const { return mFormFactor; } - float scale() const { return mScale; } - - // New methods. - void *eglSurface() const; - MirSurface *mirSurface() const; - void handleSurfaceResized(int width, int height); - void handleSurfaceExposeChange(bool exposed); - void handleSurfaceFocusChanged(bool focused); - void handleSurfaceVisibilityChanged(bool visible); - void handleSurfaceStateChanged(Qt::WindowState state); - void onSwapBuffersDone(); - void handleScreenPropertiesChange(MirFormFactor formFactor, float scale); - QString persistentSurfaceId(); - -private: - void updateSurfaceState(); - mutable QMutex mMutex; - const WId mId; - Qt::WindowState mWindowState; - Qt::WindowFlags mWindowFlags; - bool mWindowVisible; - bool mWindowExposed; - QMirClientAppStateController *mAppStateController; - QMirClientDebugExtension *mDebugExtention; - QMirClientNativeInterface *mNativeInterface; - std::unique_ptr mSurface; - float mScale; - MirFormFactor mFormFactor; -}; - -#endif // QMIRCLIENTWINDOW_H diff --git a/src/plugins/platforms/platforms.pro b/src/plugins/platforms/platforms.pro index acc55adf6f..c4f2b30965 100644 --- a/src/plugins/platforms/platforms.pro +++ b/src/plugins/platforms/platforms.pro @@ -48,6 +48,4 @@ haiku { wasm: SUBDIRS += wasm -qtConfig(mirclient): SUBDIRS += mirclient - qtConfig(integrityfb): SUBDIRS += integrity From e3f16e7a42893447631321b02a2468c3b1fa35fb Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Fri, 1 Feb 2019 13:37:33 +0100 Subject: [PATCH 017/292] Convert tst_qabstractnetwork auto-test to make it work with our new docker-based test server. Change-Id: I76345a2d3d768b8a571f2c85e69f6a21e9a96d7e Reviewed-by: Ryan Chu Reviewed-by: Edward Welbourne --- .../qabstractnetworkcache/qabstractnetworkcache.pro | 2 ++ .../tst_qabstractnetworkcache.cpp | 7 ++++++- .../cgi-bin/httpcachetest_cachecontrol-expire.cgi | 7 +++++++ .../www/cgi-bin/httpcachetest_cachecontrol.cgi | 13 +++++++++++++ .../www/cgi-bin/httpcachetest_cachecontrol200.cgi | 9 +++++++++ .../testdata/www/cgi-bin/httpcachetest_etag200.cgi | 5 +++++ .../testdata/www/cgi-bin/httpcachetest_etag304.cgi | 11 +++++++++++ .../www/cgi-bin/httpcachetest_expires200.cgi | 5 +++++ .../www/cgi-bin/httpcachetest_expires304.cgi | 11 +++++++++++ .../www/cgi-bin/httpcachetest_lastModified200.cgi | 5 +++++ .../www/cgi-bin/httpcachetest_lastModified304.cgi | 11 +++++++++++ 11 files changed, 85 insertions(+), 1 deletion(-) create mode 100755 tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_cachecontrol-expire.cgi create mode 100755 tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_cachecontrol.cgi create mode 100755 tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_cachecontrol200.cgi create mode 100755 tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_etag200.cgi create mode 100755 tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_etag304.cgi create mode 100755 tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_expires200.cgi create mode 100755 tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_expires304.cgi create mode 100755 tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_lastModified200.cgi create mode 100755 tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_lastModified304.cgi diff --git a/tests/auto/network/access/qabstractnetworkcache/qabstractnetworkcache.pro b/tests/auto/network/access/qabstractnetworkcache/qabstractnetworkcache.pro index 1874f001ab..bdd9d4eb7e 100644 --- a/tests/auto/network/access/qabstractnetworkcache/qabstractnetworkcache.pro +++ b/tests/auto/network/access/qabstractnetworkcache/qabstractnetworkcache.pro @@ -5,3 +5,5 @@ SOURCES += tst_qabstractnetworkcache.cpp TESTDATA += tests/* +QT_TEST_SERVER_LIST = apache2 +include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) diff --git a/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp b/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp index 0da42b8b87..92384e85bc 100644 --- a/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp +++ b/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp @@ -39,7 +39,7 @@ #include -#define TESTFILE QLatin1String("http://") + QtNetworkSettings::serverName() + QLatin1String("/qtest/cgi-bin/") +#define TESTFILE QLatin1String("http://") + QtNetworkSettings::httpServerName() + QLatin1String("/qtest/cgi-bin/") class tst_QAbstractNetworkCache : public QObject { @@ -127,8 +127,13 @@ Q_DECLARE_METATYPE(QNetworkRequest::CacheLoadControl) void tst_QAbstractNetworkCache::initTestCase() { +#if defined(QT_TEST_SERVER) + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpServerName(), 80)); +#else if (!QtNetworkSettings::verifyTestNetworkSettings()) QSKIP("No network test server available"); +#endif + #ifndef QT_NO_BEARERMANAGEMENT netConfMan = new QNetworkConfigurationManager(this); networkConfiguration = netConfMan->defaultConfiguration(); diff --git a/tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_cachecontrol-expire.cgi b/tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_cachecontrol-expire.cgi new file mode 100755 index 0000000000..7dc506fc1e --- /dev/null +++ b/tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_cachecontrol-expire.cgi @@ -0,0 +1,7 @@ +#!/bin/bash +# cache control takes precedence over expires +echo "Cache-Control: max-age=-1" +echo "Expires: Mon, 30 Oct 2028 14:19:41 GMT" +echo "Content-type: text/html"; +echo "" +echo "Hello World!" diff --git a/tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_cachecontrol.cgi b/tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_cachecontrol.cgi new file mode 100755 index 0000000000..f2edfc161f --- /dev/null +++ b/tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_cachecontrol.cgi @@ -0,0 +1,13 @@ +#!/bin/bash +if [ ! -z ${HTTP_IF_MODIFIED_SINCE} ] ; then + echo "Status: 304" + echo "" + exit; +fi + +cc=`echo "${QUERY_STRING}" | sed -e s/%20/\ /g` +echo "Cache-Control: $cc" +echo "Last-Modified: Sat, 31 Oct 1981 06:00:00 GMT" +echo "Content-type: text/html"; +echo "" +echo "Hello World!" diff --git a/tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_cachecontrol200.cgi b/tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_cachecontrol200.cgi new file mode 100755 index 0000000000..e44d5ed570 --- /dev/null +++ b/tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_cachecontrol200.cgi @@ -0,0 +1,9 @@ +#!/bin/bash +cc=`echo "${QUERY_STRING}" | sed -e s/%20/\ /g` +echo "Status: 200" +echo "Cache-Control: $cc" +echo "Last-Modified: Sat, 31 Oct 1981 06:00:00 GMT" +echo "Content-type: text/html"; +echo "X-Script: $0" +echo "" +echo "Hello World!" diff --git a/tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_etag200.cgi b/tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_etag200.cgi new file mode 100755 index 0000000000..0966abfdd1 --- /dev/null +++ b/tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_etag200.cgi @@ -0,0 +1,5 @@ +#!/bin/bash +echo "ETag: foo" +echo "Content-type: text/html"; +echo "" +echo "Hello World!" diff --git a/tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_etag304.cgi b/tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_etag304.cgi new file mode 100755 index 0000000000..91a4b922bd --- /dev/null +++ b/tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_etag304.cgi @@ -0,0 +1,11 @@ +#!/bin/bash +if [ ! -z ${HTTP_IF_NONE_MATCH} ] ; then + echo "Status: 304" + echo "" + exit; +fi + +echo "ETag: foo" +echo "Content-type: text/html"; +echo "" +echo "Hello World!" diff --git a/tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_expires200.cgi b/tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_expires200.cgi new file mode 100755 index 0000000000..e18ebc86ad --- /dev/null +++ b/tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_expires200.cgi @@ -0,0 +1,5 @@ +#!/bin/bash +echo "Expires: Sat, 31 Oct 1981 6:00:00 GMT" +echo "Content-type: text/html"; +echo "" +echo "Hello World!" diff --git a/tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_expires304.cgi b/tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_expires304.cgi new file mode 100755 index 0000000000..1c7de1cd77 --- /dev/null +++ b/tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_expires304.cgi @@ -0,0 +1,11 @@ +#!/bin/bash +if [ ${HTTP_IF_MODIFIED_SINCE} == "Mon, 30 Oct 2028 14:19:41 GMT" ] ; then + echo "Status: 304" + echo "" + exit; +fi + +echo "Expires: Mon, 30 Oct 2028 14:19:41 GMT" +echo "Content-type: text/html"; +echo "" +echo "Hello World!" diff --git a/tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_lastModified200.cgi b/tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_lastModified200.cgi new file mode 100755 index 0000000000..5dc219b1e7 --- /dev/null +++ b/tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_lastModified200.cgi @@ -0,0 +1,5 @@ +#!/bin/bash +echo "Last-Modified: Sat, 31 Oct 1981 6:00:00 GMT" +echo "Content-type: text/html"; +echo "" +echo "Hello World!" diff --git a/tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_lastModified304.cgi b/tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_lastModified304.cgi new file mode 100755 index 0000000000..bdf23bed2f --- /dev/null +++ b/tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_lastModified304.cgi @@ -0,0 +1,11 @@ +#!/bin/bash +if [ ${HTTP_IF_MODIFIED_SINCE} == "Sat, 31 Oct 1981 06:00:00 GMT" ] ; then + echo "Status: 304" + echo "" + exit; +fi + +echo "Last-Modified: Sat, 31 Oct 1981 06:00:00 GMT" +echo "Content-type: text/html"; +echo "" +echo "Hello World!" From ece341e2f3ef90204b209012b2099b8e599eee08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 19 Dec 2018 18:14:59 +0100 Subject: [PATCH 018/292] Allow more fine grained control over QFont debug output With verbosity level 0, only the resolved properties are included in the debug output, which is useful when debugging font resolving. With verbosity level 1, the family, size, and weights are included, plus any resolved property that is different from the default value. Verbosity level 2, the QDebug default, has been kept unchanged, except removing quotes and spaces by adding nospace() and qPrintable. Verbosity level 3 includes all properties, regardless of whether or not they have been resolved. Levels 1 and 3 also include the resolve mask, to aid debugging. This gives the following results for a QFont set to 100pt: QFont(100pt) QFont(".SF NS Text", 100pt, Weight::Normal, resolveMask=SizeResolved) QFont(.SF NS Text,100,-1,5,50,0,0,0,0,0) QFont(".SF NS Text", 100pt, StyleHint::AnyStyle, StyleStrategy::PreferDefault, Weight::Normal, StyleNormal, underline=false, overline=false, strikeOut=false, fixedPitch=false, AnyStretch, kerning=true, MixedCase, letterSpacing=0 (PercentageSpacing), PreferDefaultHinting, styleName="", resolveMask=SizeResolved) Change-Id: Ib4aebd7346ef4a2946cc4450c12730cf7844c3bc Reviewed-by: Konstantin Ritt Reviewed-by: Lars Knoll --- src/gui/text/qfont.cpp | 99 +++++++++++++++++++++++++++++++++++++++++- src/gui/text/qfont.h | 6 +++ 2 files changed, 104 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index d879836572..82e03b6df9 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -3161,7 +3161,104 @@ void QFontCache::decreaseCache() #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug stream, const QFont &font) { - return stream << "QFont(" << font.toString() << ')'; + QDebugStateSaver saver(stream); + stream.nospace().noquote(); + stream << "QFont("; + + if (stream.verbosity() == QDebug::DefaultVerbosity) { + stream << font.toString() << ")"; + return stream; + } + + QString fontDescription; + QDebug debug(&fontDescription); + debug.nospace(); + + QFontPrivate priv; + const QFont defaultFont(&priv); + + for (int property = QFont::FamilyResolved; property < QFont::AllPropertiesResolved; property <<= 1) { + const bool resolved = (font.resolve_mask & property) != 0; + if (!resolved && stream.verbosity() == QDebug::MinimumVerbosity) + continue; + + #define QFONT_DEBUG_SKIP_DEFAULT(prop) \ + if ((font.prop() == defaultFont.prop()) && stream.verbosity() == 1) \ + continue; + + QDebugStateSaver saver(debug); + + switch (property) { + case QFont::FamilyResolved: + debug << font.family(); break; + case QFont::SizeResolved: + if (font.pointSizeF() >= 0) + debug << font.pointSizeF() << "pt"; + else if (font.pixelSize() >= 0) + debug << font.pixelSize() << "px"; + else + Q_UNREACHABLE(); + break; + case QFont::StyleHintResolved: + QFONT_DEBUG_SKIP_DEFAULT(styleHint); + debug.verbosity(1) << font.styleHint(); break; + case QFont::StyleStrategyResolved: + QFONT_DEBUG_SKIP_DEFAULT(styleStrategy); + debug.verbosity(1) << font.styleStrategy(); break; + case QFont::WeightResolved: + debug.verbosity(1) << QFont::Weight(font.weight()); break; + case QFont::StyleResolved: + QFONT_DEBUG_SKIP_DEFAULT(style); + debug.verbosity(0) << font.style(); break; + case QFont::UnderlineResolved: + QFONT_DEBUG_SKIP_DEFAULT(underline); + debug << "underline=" << font.underline(); break; + case QFont::OverlineResolved: + QFONT_DEBUG_SKIP_DEFAULT(overline); + debug << "overline=" << font.overline(); break; + case QFont::StrikeOutResolved: + QFONT_DEBUG_SKIP_DEFAULT(strikeOut); + debug << "strikeOut=" << font.strikeOut(); break; + case QFont::FixedPitchResolved: + QFONT_DEBUG_SKIP_DEFAULT(fixedPitch); + debug << "fixedPitch=" << font.fixedPitch(); break; + case QFont::StretchResolved: + QFONT_DEBUG_SKIP_DEFAULT(stretch); + debug.verbosity(0) << QFont::Stretch(font.stretch()); break; + case QFont::KerningResolved: + QFONT_DEBUG_SKIP_DEFAULT(kerning); + debug << "kerning=" << font.kerning(); break; + case QFont::CapitalizationResolved: + QFONT_DEBUG_SKIP_DEFAULT(capitalization); + debug.verbosity(0) << font.capitalization(); break; + case QFont::LetterSpacingResolved: + QFONT_DEBUG_SKIP_DEFAULT(letterSpacing); + debug << "letterSpacing=" << font.letterSpacing(); + debug.verbosity(0) << " (" << font.letterSpacingType() << ")"; + break; + case QFont::HintingPreferenceResolved: + QFONT_DEBUG_SKIP_DEFAULT(hintingPreference); + debug.verbosity(0) << font.hintingPreference(); break; + case QFont::StyleNameResolved: + QFONT_DEBUG_SKIP_DEFAULT(styleName); + debug << "styleName=" << font.styleName(); break; + default: + continue; + }; + + #undef QFONT_DEBUG_SKIP_DEFAULT + + debug << ", "; + } + + if (stream.verbosity() > QDebug::MinimumVerbosity) + debug.verbosity(0) << "resolveMask=" << QFlags(font.resolve_mask); + else + fontDescription.chop(2); // Last ', ' + + stream << fontDescription << ')'; + + return stream; } #endif diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h index e86f06353a..35ef798275 100644 --- a/src/gui/text/qfont.h +++ b/src/gui/text/qfont.h @@ -147,6 +147,7 @@ public: Q_ENUM(SpacingType) enum ResolveProperties { + NoPropertiesResolved = 0x0000, FamilyResolved = 0x0001, SizeResolved = 0x0002, StyleHintResolved = 0x0004, @@ -167,6 +168,7 @@ public: FamiliesResolved = 0x20000, AllPropertiesResolved = 0x3ffff }; + Q_ENUM(ResolveProperties) QFont(); QFont(const QString &family, int pointSize = -1, int weight = -1, bool italic = false); @@ -335,6 +337,10 @@ private: friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QFont &); #endif +#ifndef QT_NO_DEBUG_STREAM + friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QFont &); +#endif + QExplicitlySharedDataPointer d; uint resolve_mask; }; From 9332f8cb723f63761e60b6cf6b12276aa2cc6721 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Thu, 31 Jan 2019 09:30:20 +0100 Subject: [PATCH 019/292] tst_qheaderview: Do not use the deprecated QAbstractItemModel::reset() Still do a begin/end reset model in place, which is probably not the best code but since it's a test and it works it should be enough Change-Id: Iffaf8d69d5be64ef5e1e359e3d90a1e8174fc13b Reviewed-by: David Faure Reviewed-by: Frederik Gladhorn --- .../auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index 9d3770064f..21ff6c4a1b 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -85,7 +85,8 @@ class XResetModel : public QStandardItemModel blockSignals(true); bool r = QStandardItemModel::removeRows(row, count, parent); blockSignals(false); - emit reset(); + beginResetModel(); + endResetModel(); return r; } virtual bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) @@ -93,7 +94,8 @@ class XResetModel : public QStandardItemModel blockSignals(true); bool r = QStandardItemModel::insertRows(row, count, parent); blockSignals(false); - emit reset(); + beginResetModel(); + endResetModel(); return r; } }; From f20adcde3079227b063b747e6bd91f8fd94c4866 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 20 Nov 2018 19:57:25 +0100 Subject: [PATCH 020/292] Dodge qFatal() so as to get coverage results despite it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The silent and blacklisted selftests of testlib end in a qFatal(), to test its messaging is handled correctly. However, this prevents hooks in main() from saving coverage data when we're gathering that. So use a transient signal handler that longjmp()s back to a setjmp() just before the qFatal() to let the test complete normally (but, since qFatal() does something different on MS-Win, don't apply this to it). Note that testlib's internal FatalSignalHandler handles all fatal signals *except* SIGABRT, so this isn't over-riding it. (In any case, this restores the prior signal handler in setjmp()'s catch branch.) Added missing expected_silent.tap test output while checking that this change doesn't affect (the rest of) the test output. Change-Id: I7e460581ad93e26639c066b3229438a66fd299de Reviewed-by: Tor Arne Vestbø --- .../selftests/blacklisted/tst_blacklisted.cpp | 21 +++++++++- .../testlib/selftests/expected_silent.tap | 42 +++++++++++++++++++ .../testlib/selftests/silent/tst_silent.cpp | 21 +++++++++- 3 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 tests/auto/testlib/selftests/expected_silent.tap diff --git a/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp b/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp index 90520385ec..9c08af382a 100644 --- a/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp +++ b/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp @@ -75,6 +75,17 @@ void tst_Blacklisted::xpass() QVERIFY2(true, "This test should XPASS, blacklist ignored for XPASS"); } +#ifndef Q_OS_WIN +#include +#include + +static jmp_buf state; +static void abort_handler(int signal) +{ + longjmp(state, 1); +} +#endif + void tst_Blacklisted::messages() { qWarning("This is a warning that should not appear in silent test output"); @@ -83,7 +94,15 @@ void tst_Blacklisted::messages() qCritical("This is a critical message that should not appear in silent test output"); qInfo("This is an info message that should not appear in silent test output"); QTestLog::info("This is an internal testlib info message that should not appear in silent test output", __FILE__, __LINE__); - qFatal("This is a fatal error message that should still appear in silent test output"); + +#ifndef Q_OS_WIN + // We're testing qFatal, but we don't want to actually std::abort() ! + auto prior = signal(SIGABRT, abort_handler); + if (setjmp(state)) + signal(SIGABRT, prior); + else +#endif + qFatal("This is a fatal error message that should still appear in silent test output"); } QTEST_MAIN(tst_Blacklisted) diff --git a/tests/auto/testlib/selftests/expected_silent.tap b/tests/auto/testlib/selftests/expected_silent.tap new file mode 100644 index 0000000000..c5f7716390 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_silent.tap @@ -0,0 +1,42 @@ +TAP version 13 +# tst_Silent +ok 1 - initTestCase() +ok 2 - pass() +ok 3 - skip() # SKIP This test should skip +not ok 4 - fail() + --- + type: QVERIFY + message: This test should fail + wanted: true (false) + found: false (false) + expected: true (false) + actual: false (false) + at: tst_Silent::fail() (qtbase/tests/auto/testlib/selftests/silent/tst_silent.cpp:60) + file: qtbase/tests/auto/testlib/selftests/silent/tst_silent.cpp + line: 60 + ... +not ok 5 - xfail() # TODO This test should XFAIL + --- + at: tst_Silent::xfail() (qtbase/tests/auto/testlib/selftests/silent/tst_silent.cpp:66) + file: qtbase/tests/auto/testlib/selftests/silent/tst_silent.cpp + line: 66 + ... +ok 6 - xpass() # TODO 'true' returned TRUE unexpectedly. (This test should XPASS) +# This is a warning that should not appear in silent test output +# This is an internal testlib warning that should not appear in silent test output +# This is a debug message that should not appear in silent test output +# This is a critical message that should not appear in silent test output +# This is an info message that should not appear in silent test output +# This is an internal testlib info message that should not appear in silent test output +# This is a fatal error message that should still appear in silent test output +not ok 7 - messages() + --- + # Received a fatal error. + at: tst_Silent::messages() (Unknown file:0) + file: Unknown file + line: 0 + ... +1..7 +# tests 7 +# pass 3 +# fail 3 diff --git a/tests/auto/testlib/selftests/silent/tst_silent.cpp b/tests/auto/testlib/selftests/silent/tst_silent.cpp index 97fbbfd30a..cf3c35dec4 100644 --- a/tests/auto/testlib/selftests/silent/tst_silent.cpp +++ b/tests/auto/testlib/selftests/silent/tst_silent.cpp @@ -72,6 +72,17 @@ void tst_Silent::xpass() QVERIFY2(true, "This test should XPASS"); } +#ifndef Q_OS_WIN +#include +#include + +static jmp_buf state; +static void abort_handler(int signal) +{ + longjmp(state, 1); +} +#endif + void tst_Silent::messages() { qWarning("This is a warning that should not appear in silent test output"); @@ -80,7 +91,15 @@ void tst_Silent::messages() qCritical("This is a critical message that should not appear in silent test output"); qInfo("This is an info message that should not appear in silent test output"); QTestLog::info("This is an internal testlib info message that should not appear in silent test output", __FILE__, __LINE__); - qFatal("This is a fatal error message that should still appear in silent test output"); + +#ifndef Q_OS_WIN + // We're testing qFatal, but we don't want to actually std::abort() ! + auto prior = signal(SIGABRT, abort_handler); + if (setjmp(state)) + signal(SIGABRT, prior); + else +#endif + qFatal("This is a fatal error message that should still appear in silent test output"); } QTEST_MAIN(tst_Silent) From df2b76046de4af7a47fa8303d5f261e3c5d120fe Mon Sep 17 00:00:00 2001 From: Dominik Holland Date: Wed, 7 Nov 2018 10:18:14 +0100 Subject: [PATCH 021/292] eglfs: Add vsync support when using NVIDIA eglstreams Similar to the kms backend a flip event handler can be retrieved using the drmEvent API to implement vsync. For this to work the acquire calls need to be done manuallly and the automatic acquiring needs to be disabled. Change-Id: I670d288ef68eb49846108db2a31993c6167d9313 Reviewed-by: Laszlo Agocs --- .../eglconvenience/qeglstreamconvenience_p.h | 11 ++++ .../qeglfskmsegldeviceintegration.cpp | 50 +++++++++++++++++++ .../qeglfskmsegldeviceintegration.h | 2 + 3 files changed, 63 insertions(+) diff --git a/src/platformsupport/eglconvenience/qeglstreamconvenience_p.h b/src/platformsupport/eglconvenience/qeglstreamconvenience_p.h index c3d3070210..31a79dbc6c 100644 --- a/src/platformsupport/eglconvenience/qeglstreamconvenience_p.h +++ b/src/platformsupport/eglconvenience/qeglstreamconvenience_p.h @@ -131,6 +131,12 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEKHRPROC) (EGLDisplay typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMEROUTPUTEXTPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLOutputLayerEXT layer); #endif +#ifndef EGL_EXT_stream_acquire_mode +#define EGL_EXT_stream_acquire_mode 1 +#define EGL_CONSUMER_AUTO_ACQUIRE_EXT 0x332B +#define EGL_RESOURCE_BUSY_EXT 0x3353 +#endif + #ifndef EGL_EXT_platform_device #define EGL_PLATFORM_DEVICE_EXT 0x313F #endif @@ -156,6 +162,11 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREATTRIBNVPROC) (EGLDi typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEATTRIBNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); #endif +#ifndef EGL_NV_output_drm_flip_event +#define EGL_NV_output_drm_flip_event 1 +#define EGL_DRM_FLIP_EVENT_DATA_NV 0x333E +#endif + QT_BEGIN_NAMESPACE class QEGLStreamConvenience diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp index ab39af6b80..9f4c9f5703 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp @@ -114,14 +114,18 @@ public: : QEglFSWindow(w) , m_integration(integration) , m_egl_stream(EGL_NO_STREAM_KHR) + , m_framePending(false) { } void invalidateSurface() override; void resetSurface() override; + void flip(); + static void pageFlipHandler(int fd, unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec, void *user_data); const QEglFSKmsEglDeviceIntegration *m_integration; EGLStreamKHR m_egl_stream; EGLint m_latency; + bool m_framePending; }; void QEglFSKmsEglDeviceWindow::invalidateSurface() @@ -142,6 +146,9 @@ void QEglFSKmsEglDeviceWindow::resetSurface() streamAttribs[streamAttribCount++] = EGL_STREAM_FIFO_LENGTH_KHR; streamAttribs[streamAttribCount++] = fifoLength; } + + streamAttribs[streamAttribCount++] = EGL_CONSUMER_AUTO_ACQUIRE_EXT; + streamAttribs[streamAttribCount++] = EGL_FALSE; streamAttribs[streamAttribCount++] = EGL_NONE; m_egl_stream = m_integration->m_funcs->create_stream(display, streamAttribs); @@ -239,6 +246,49 @@ void QEglFSKmsEglDeviceWindow::resetSurface() qCDebug(qLcEglfsKmsDebug, "Created stream producer surface %p", m_surface); } +void QEglFSKmsEglDeviceWindow::flip() +{ + EGLDisplay display = screen()->display(); + + EGLAttrib acquire_attribs[3] = { EGL_NONE }; + + acquire_attribs[0] = EGL_DRM_FLIP_EVENT_DATA_NV; + acquire_attribs[1] = (EGLAttrib)this; + acquire_attribs[2] = EGL_NONE; + + if (m_egl_stream != EGL_NO_STREAM_KHR) + if (!m_integration->m_funcs->acquire_stream_attrib_nv(display, m_egl_stream, acquire_attribs)) + qWarning("eglStreamConsumerAcquireAttribNV failed: eglError: %x", eglGetError()); + + m_framePending = true; + + while (m_framePending) { + drmEventContext drmEvent; + memset(&drmEvent, 0, sizeof(drmEvent)); + drmEvent.version = 3; + drmEvent.vblank_handler = nullptr; + drmEvent.page_flip_handler = pageFlipHandler; + drmHandleEvent(m_integration->m_device->fd(), &drmEvent); + } +} + +void QEglFSKmsEglDeviceWindow::pageFlipHandler(int fd, unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec, void *user_data) +{ + Q_UNUSED(fd); + Q_UNUSED(sequence); + Q_UNUSED(tv_sec); + Q_UNUSED(tv_usec); + + QEglFSKmsEglDeviceWindow *window = static_cast(user_data); + window->m_framePending = false; +} + +void QEglFSKmsEglDeviceIntegration::presentBuffer(QPlatformSurface *surface) +{ + QEglFSKmsEglDeviceWindow *eglWindow = static_cast(surface); + eglWindow->flip(); +} + QEglFSWindow *QEglFSKmsEglDeviceIntegration::createWindow(QWindow *window) const { QEglFSKmsEglDeviceWindow *eglWindow = new QEglFSKmsEglDeviceWindow(window, this); diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h index 5819d82ebf..0c64d83b12 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h @@ -62,6 +62,8 @@ public: bool supportsPBuffers() const override; QEglFSWindow *createWindow(QWindow *window) const override; + void presentBuffer(QPlatformSurface *surface); + EGLDeviceEXT eglDevice() const { return m_egl_device; } protected: From dd1a6308719929b0798447244b401376d983cfbf Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sun, 25 Nov 2018 21:58:47 +0100 Subject: [PATCH 022/292] QLineEdit: don't emit editingFinished if nothing was done When a modal dialog is called from a slot connected to the editingFinished signal, the chain of events resulting from the focus returning to this widget will make the editingFinished signal emitted again. This patch uses a new variable to keep track of the fact that there was a modification. Once editingFinished was emitted, that flag is cleared so next time the signal will be emitted again only if a modification was made to the line edit content. [ChangeLog][QtWidget][QLineEdit] Behavior change: now the editingFinished signal is emitted only once after the line edit content was edited. Fixes: QTBUG-40 Change-Id: Ia4760bad8717f1758c3939132c446b4b4c6cd498 Reviewed-by: Friedemann Kleint Reviewed-by: Shawn Rutledge --- src/widgets/widgets/qlineedit.cpp | 12 ++++++++---- src/widgets/widgets/qlineedit_p.cpp | 7 +++++++ src/widgets/widgets/qlineedit_p.h | 4 +++- .../auto/widgets/widgets/qlineedit/tst_qlineedit.cpp | 10 ++++++++++ 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index ad3d372bd3..02aa703289 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -315,7 +315,7 @@ QString QLineEdit::text() const void QLineEdit::setText(const QString& text) { Q_D(QLineEdit); - d->control->setText(text); + d->setText(text); } /*! @@ -1483,8 +1483,11 @@ bool QLineEdit::event(QEvent * e) } else if (e->type() == QEvent::LeaveEditFocus) { d->setCursorVisible(false); d->control->setCursorBlinkEnabled(false); - if (d->control->hasAcceptableInput() || d->control->fixup()) + if (d->edited && (d->control->hasAcceptableInput() + || d->control->fixup())) { emit editingFinished(); + d->edited = false; + } } } #endif @@ -1891,7 +1894,6 @@ void QLineEdit::focusInEvent(QFocusEvent *e) /*!\reimp */ - void QLineEdit::focusOutEvent(QFocusEvent *e) { Q_D(QLineEdit); @@ -1914,8 +1916,10 @@ void QLineEdit::focusOutEvent(QFocusEvent *e) #endif if (reason != Qt::PopupFocusReason || !(QApplication::activePopupWidget() && QApplication::activePopupWidget()->parentWidget() == this)) { - if (hasAcceptableInput() || d->control->fixup()) + if (d->edited && (hasAcceptableInput() || d->control->fixup())) { emit editingFinished(); + d->edited = false; + } } #ifdef QT_KEYPAD_NAVIGATION d->control->setCancelText(QString()); diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index 2a5a0c34dc..21e70db0ac 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -127,6 +127,7 @@ void QLineEditPrivate::_q_handleWindowActivate() void QLineEditPrivate::_q_textEdited(const QString &text) { Q_Q(QLineEdit); + edited = true; emit q->textEdited(text); #if QT_CONFIG(completer) if (control->completer() @@ -272,6 +273,12 @@ void QLineEditPrivate::setCursorVisible(bool visible) q->update(); } +void QLineEditPrivate::setText(const QString& text) +{ + edited = true; + control->setText(text); +} + void QLineEditPrivate::updatePasswordEchoEditing(bool editing) { Q_Q(QLineEdit); diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h index 12a2f1ddfd..dce5bf605a 100644 --- a/src/widgets/widgets/qlineedit_p.h +++ b/src/widgets/widgets/qlineedit_p.h @@ -151,7 +151,7 @@ public: QLineEditPrivate() : control(0), frame(1), contextMenuEnabled(1), cursorVisible(0), - dragEnabled(0), clickCausedFocus(0), hscroll(0), vscroll(0), + dragEnabled(0), clickCausedFocus(0), edited(0), hscroll(0), vscroll(0), alignment(Qt::AlignLeading | Qt::AlignVCenter), leftTextMargin(0), topTextMargin(0), rightTextMargin(0), bottomTextMargin(0), lastTextSize(0), mouseYThreshold(0) @@ -176,6 +176,7 @@ public: bool inSelection(int x) const; QRect cursorRect() const; void setCursorVisible(bool visible); + void setText(const QString& text); void updatePasswordEchoEditing(bool); @@ -202,6 +203,7 @@ public: uint cursorVisible : 1; uint dragEnabled : 1; uint clickCausedFocus : 1; + uint edited : 1; int hscroll; int vscroll; uint alignment; diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 95799905de..7861065de9 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -3613,6 +3613,14 @@ void tst_QLineEdit::task174640_editingFinished() QTRY_VERIFY(le1->hasFocus()); QCOMPARE(editingFinishedSpy.count(), 0); + le2->setFocus(); + QTRY_VERIFY(le2->hasFocus()); + // editingFinished will not be emitted anew because no editing happened + QCOMPARE(editingFinishedSpy.count(), 0); + + le1->setFocus(); + QTRY_VERIFY(le1->hasFocus()); + QTest::keyPress(le1, Qt::Key_Plus); le2->setFocus(); QTRY_VERIFY(le2->hasFocus()); QCOMPARE(editingFinishedSpy.count(), 1); @@ -3632,6 +3640,8 @@ void tst_QLineEdit::task174640_editingFinished() delete testMenu1; QCOMPARE(editingFinishedSpy.count(), 0); QTRY_VERIFY(le1->hasFocus()); + // Ensure le1 has been edited + QTest::keyPress(le1, Qt::Key_Plus); QMenu *testMenu2 = new QMenu(le2); testMenu2->addAction("foo2"); From 568bc974d7d89f8d12bc4877c59e4291fe582e8b Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 11 Feb 2019 12:18:35 +0100 Subject: [PATCH 023/292] Remove eval mode The evaluation mode of Qt hasn't been used since quite some time. Let's just remove the remaining logic from the code base. Change-Id: I61a2c432cbae78bf973f882848b3732e27431351 Reviewed-by: Joerg Bornemann Reviewed-by: Iikka Eklund Reviewed-by: Thiago Macieira --- src/corelib/corelib.pro | 2 - src/corelib/eval.pri | 4 - src/corelib/global/qlibraryinfo.cpp | 5 - src/corelib/kernel/qcoreapplication.cpp | 5 - src/corelib/kernel/qtcore_eval.cpp | 560 ------------------------ src/tools/bootstrap/bootstrap.pro | 2 - src/widgets/kernel/qapplication.cpp | 4 - src/widgets/kernel/qwidget.cpp | 11 - src/widgets/widgets.pro | 2 - 9 files changed, 595 deletions(-) delete mode 100644 src/corelib/eval.pri delete mode 100644 src/corelib/kernel/qtcore_eval.cpp diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro index 181780c475..2323512a30 100644 --- a/src/corelib/corelib.pro +++ b/src/corelib/corelib.pro @@ -67,8 +67,6 @@ integrity { QMAKE_DYNAMIC_LIST_FILE = $$PWD/QtCore.dynlist -contains(DEFINES,QT_EVAL):include(eval.pri) - HOST_BINS = $$[QT_HOST_BINS] host_bins.name = host_bins host_bins.variable = HOST_BINS diff --git a/src/corelib/eval.pri b/src/corelib/eval.pri deleted file mode 100644 index efda56b16a..0000000000 --- a/src/corelib/eval.pri +++ /dev/null @@ -1,4 +0,0 @@ -SOURCES += \ - $$QT_SOURCE_TREE/src/corelib/kernel/qtcore_eval.cpp -INCLUDEPATH += \ - $$QT_BUILD_TREE/src/corelib/global diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 4119012d85..88cc5b0b01 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -717,11 +717,6 @@ void qt_core_boilerplate() QT_PREPEND_NAMESPACE(qDumpCPUFeatures)(); -#ifdef QT_EVAL - extern void qt_core_eval_init(QCoreApplicationPrivate::Type); - qt_core_eval_init(QCoreApplicationPrivate::Tty); -#endif - exit(0); } diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index e6d1d26f3c..7524d2e6c4 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -857,11 +857,6 @@ void QCoreApplicationPrivate::init() eventDispatcherReady(); #endif -#ifdef QT_EVAL - extern void qt_core_eval_init(QCoreApplicationPrivate::Type); - qt_core_eval_init(application_type); -#endif - processCommandLineArguments(); qt_call_pre_routines(); diff --git a/src/corelib/kernel/qtcore_eval.cpp b/src/corelib/kernel/qtcore_eval.cpp deleted file mode 100644 index 5437210699..0000000000 --- a/src/corelib/kernel/qtcore_eval.cpp +++ /dev/null @@ -1,560 +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:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include - -#include "stdio.h" -#include "stdlib.h" - -QT_BEGIN_NAMESPACE - -#include "qconfig_eval.cpp" - -static const char boilerplate_supported_but_time_limited[] = - "\nQt %1 Evaluation License\n" - "Copyright (C) 2016 The Qt Company Ltd.\n" - "This trial version may only be used for evaluation purposes\n" - "and will shut down after 120 minutes.\n" - "Registered to:\n" - " Licensee: %2\n\n" - "The evaluation expires in %4 days\n\n" - "Contact http://www.qt.io/contact-us for pricing and purchasing information.\n"; - -static const char boilerplate_supported[] = - "\nQt %1 Evaluation License\n" - "Copyright (C) 2016 The Qt Company Ltd.\n" - "This trial version may only be used for evaluation purposes\n" - "Registered to:\n" - " Licensee: %2\n\n" - "The evaluation expires in %4 days\n\n" - "Contact http://www.qt.io/contact-us for pricing and purchasing information.\n"; - -static const char boilerplate_expired[] = - "This software is using the trial version of the Qt GUI toolkit.\n" - "The trial period has expired. If you need more time to\n" - "evaluate Qt, or if you have any questions about Qt, contact us\n" - "at: http://www.qt.io/contact-us.\n\n"; - -static const char will_shutdown_1min[] = - "\nThe evaluation of Qt will SHUT DOWN in 1 minute.\n" - "Contact http://www.qt.io/contact-us for pricing and purchasing information.\n"; - -static const char will_shutdown_now[] = - "\nThe evaluation of Qt has now reached its automatic\n" - "timeout and will shut down.\n" - "Contact http://www.qt.io/contact-us for pricing and purchasing information.\n"; - -enum EvaluationStatus { - EvaluationNotSupported = 0, - EvaluationSupportedButTimeLimited, - EvaluationSupported -}; - -static EvaluationStatus qt_eval_is_supported() -{ - const volatile char *const license_key = qt_eval_key_data + 12; - - // fast fail - if (!qt_eval_key_data[0] || !*license_key) - return EvaluationNotSupported; - - // is this an unsupported evaluation? - const volatile char *typecode = license_key; - int field = 2; - for ( ; field && *typecode; ++typecode) - if (*typecode == '-') - --field; - - if (!field && typecode[1] == '4' && typecode[2] == 'M') { - if (typecode[0] == 'Q') - return EvaluationSupportedButTimeLimited; - else if (typecode[0] == 'R' || typecode[0] == 'Z') - return EvaluationSupported; - } - return EvaluationNotSupported; -} - -static int qt_eval_days_left() -{ - const volatile char *const expiry_date = qt_eval_expiry_date + 12; - - QDate today = QDate::currentDate(); - QDate lastday = QDate::fromString( - QString::fromLatin1(const_cast(expiry_date)), Qt::ISODate); - return today.daysTo(lastday); -} - -static bool qt_eval_is_expired() -{ - return qt_eval_days_left() < 0; -} - -static QString qt_eval_string() -{ - const char *msg; - switch (qt_eval_is_supported()) { - case EvaluationSupportedButTimeLimited: - msg = boilerplate_supported_but_time_limited; - break; - case EvaluationSupported: - msg = boilerplate_supported; - break; - default: - return QString(); - } - - return QString::fromLatin1(msg) - .arg(QLatin1String(QT_VERSION_STR)) - .arg(QLibraryInfo::licensee()) - .arg(qt_eval_days_left()); -} - -#define WARN_TIMEOUT 60 * 1000 * 119 -#define KILL_DELAY 60 * 1000 * 1 - -class QCoreFuriCuri : public QObject -{ -public: - - int warn; - int kill; - - QCoreFuriCuri() : QObject(), warn(-1), kill(-1) - { - if (qt_eval_is_supported() == EvaluationSupportedButTimeLimited) { - warn = startTimer(WARN_TIMEOUT); - kill = 0; - } - } - - void timerEvent(QTimerEvent *e) override { - if (e->timerId() == warn) { - killTimer(warn); - fprintf(stderr, "%s\n", will_shutdown_1min); - kill = startTimer(KILL_DELAY); - } else if (e->timerId() == kill) { - fprintf(stderr, "%s\n", will_shutdown_now); - QCoreApplication::instance()->quit(); - } - } -}; - -#if defined(QT_BUILD_CORE_LIB) || defined (QT_BOOTSTRAPPED) - -void qt_core_eval_init(QCoreApplicationPrivate::Type type) -{ - if (type != QCoreApplicationPrivate::Tty) - return; - - if (!qt_eval_is_supported()) - return; - - if (qt_eval_is_expired()) { - fprintf(stderr, "%s\n", boilerplate_expired); - exit(0); - } else { - fprintf(stderr, "%s\n", qPrintable(qt_eval_string())); - Q_UNUSED(new QCoreFuriCuri()); - } -} -#endif - -#ifdef QT_BUILD_WIDGETS_LIB - -QT_BEGIN_INCLUDE_NAMESPACE -#include -#include -#include -#include -#if QT_CONFIG(pushbutton) -#include -#endif -#include -#include -QT_END_INCLUDE_NAMESPACE - - -static const char * const qtlogo_eval_xpm[] = { -/* columns rows colors chars-per-pixel */ -"46 55 174 2", -" c #002E02", -". c #00370D", -"X c #003A0E", -"o c #003710", -"O c #013C13", -"+ c #043E1A", -"@ c #084F0A", -"# c #0B520C", -"$ c #054413", -"% c #0C4C17", -"& c #07421D", -"* c #09451D", -"= c #0D491E", -"- c #125515", -"; c #13541A", -": c #17591B", -"> c #1B5C1D", -", c #1F611F", -"< c #20621E", -"1 c #337B1E", -"2 c #0B4521", -"3 c #0F4923", -"4 c #114B24", -"5 c #154D2A", -"6 c #175323", -"7 c #1C5924", -"8 c #1C532F", -"9 c #1E5432", -"0 c #245936", -"q c #265938", -"w c #295C3B", -"e c #246324", -"r c #266823", -"t c #2A6C24", -"y c #276628", -"u c #2D7026", -"i c #327427", -"p c #367927", -"a c #37782A", -"s c #397C2A", -"d c #2E613E", -"f c #336C37", -"g c #2F6040", -"h c #356545", -"j c #3C6B4E", -"k c #3F6C51", -"l c #406E4F", -"z c #406D52", -"x c #477457", -"c c #497557", -"v c #4B7857", -"b c #517B5E", -"n c #3C8423", -"m c #3E812C", -"M c #53A61D", -"N c #41862C", -"B c #458A2D", -"V c #498F2D", -"C c #479324", -"Z c #489226", -"A c #4D952C", -"S c #478B30", -"D c #488C30", -"F c #4D9232", -"G c #509632", -"H c #549A33", -"J c #589F35", -"K c #56A526", -"L c #57A821", -"P c #5BAA27", -"I c #57A32A", -"U c #5CA72E", -"Y c #5DAB2A", -"T c #5CA336", -"R c #60AD2E", -"E c #63B12D", -"W c #65AF35", -"Q c #62A53F", -"! c #65AE39", -"~ c #66B036", -"^ c #6AB437", -"/ c #67B138", -"( c #6AB339", -") c #6DB838", -"_ c #70BA3C", -"` c #4D8545", -"' c #4E8942", -"] c #548851", -"[ c #6FAF4A", -"{ c #6DB243", -"} c #71B546", -"| c #70B840", -" . c #73B648", -".. c #79BA4E", -"X. c #7CBB53", -"o. c #598266", -"O. c #62886D", -"+. c #6A8F75", -"@. c #6B9173", -"#. c #70937A", -"$. c #799F79", -"%. c #7BAF66", -"&. c #81BD5B", -"*. c #85BF60", -"=. c #85AC7F", -"-. c #8DBA7B", -";. c #87C061", -":. c #8AC364", -">. c #8DC46A", -",. c #90C56E", -"<. c #93C771", -"1. c #96CA73", -"2. c #9ACB7C", -"3. c #9FD07D", -"4. c #779981", -"5. c #7F9F89", -"6. c #809F88", -"7. c #82A18B", -"8. c #86A192", -"9. c #8DA994", -"0. c #8FA998", -"q. c #94AF9B", -"w. c #97B991", -"e. c #97B19E", -"r. c #9DB6A3", -"t. c #A3BCA7", -"y. c #A6BCAB", -"u. c #A9BEB1", -"i. c #9ECD81", -"p. c #A2CF85", -"a. c #A5D284", -"s. c #A6D189", -"d. c #A9D28E", -"f. c #ABD491", -"g. c #B1D797", -"h. c #B1D699", -"j. c #B5D89E", -"k. c #ADC5AC", -"l. c #B1CAAE", -"z. c #B9DAA3", -"x. c #BDDDA8", -"c. c #ADC1B4", -"v. c #B2C6B6", -"b. c #B5C6BC", -"n. c #B6C9BA", -"m. c #BCD1BA", -"M. c #C6E1B4", -"N. c #CDE5BD", -"B. c #C2D2C6", -"V. c #CADEC2", -"C. c #C6D3CC", -"Z. c #C8D7CB", -"A. c #CEDAD2", -"S. c #D2DDD4", -"D. c #D3E9C6", -"F. c #D7EBC9", -"G. c #D9EBCD", -"H. c #DEEED4", -"J. c #D6E0D9", -"K. c #DAE4DC", -"L. c #E0EFD7", -"P. c #E5F2DD", -"I. c #DFE8E0", -"U. c #E4EBE5", -"Y. c #E9EFEA", -"T. c #EDF4EB", -"R. c #F0FAE6", -"E. c #F1F8EC", -"W. c #EDF0F0", -"Q. c #F4F7F3", -"!. c #F6F9F4", -"~. c #F8FAF7", -"^. c #FEFEFE", -"/. c None", -/* pixels */ -"/././././.c h ' Q / W _ &.p././././././././././././././././././././././././././././././././.", -"/././.4 O % Z ~ ~ W ~ W R U R R ( X.>.p././././././././././././././././././././././././././.", -"/./.. * = J _ ~ ~ ~ ~ ~ / / / / W W U P P U W .;.2././././././././././././././././././././.", -"/.= = & a ) W ~ ~ ~ ~ ~ / W / ~ ~ ~ ^ ( ( ^ ~ R R U P Y ~ .;.2././././././././././././././.", -"O.O = = T ^ W ~ ~ ~ ~ ~ ~ W W / W ~ ~ ~ ~ ~ ~ ~ ( ( ( ( ~ W Y Y Y Y W { &.1././././././././.", -"0 = * 7 ~ ~ ~ ~ ~ ~ ~ ~ ~ / / W ~ ~ ~ ~ ~ ~ ~ ~ W W W ~ ~ ~ ~ ( ( ( W W R U P U W { X.1.f./.", -"= = & e ^ W ~ ~ ~ ~ ~ ~ ~ ~ / / ~ ~ ~ ~ ~ ~ ~ ~ W ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ^ ( ( / ~ W R U U Y ", -"= = & e ^ W ~ ~ ~ ~ ~ ~ ~ ~ W W ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ W ( W ~ ~ ~ ^ ^ ( ", -"= = * e ^ W ~ ~ ~ ~ ~ ~ / W / W ! ( / ~ W ^ ( ( ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ W ~ W W ~ ~ ~ ~ ~ ~ ", -"= = & e ^ ! ~ ~ ~ ~ ~ ~ W W ^ _ ~ K Y W W R P Y W ( ~ ~ ~ ~ ~ ~ ~ W / ~ ~ ~ ^ W ~ ~ ~ ~ ~ ~ ", -"= = & e ^ W ~ ~ ~ ~ ~ ~ W ) W 1 ` w.V.L.H.D.z.,.~ Y ^ ~ ~ ~ ~ ~ W ~ ~ ~ ( ~ W W ~ ~ ~ ~ ~ ~ ", -"= = & e ^ W ~ ~ ~ ~ ~ W ) V = 8.~.^.^.^.^.^.^.^.U.<.Y ~ ~ ~ ~ ~ W W ! ~ Y W ^ W ~ ~ ~ ~ ~ ~ ", -"= = & e ^ W ~ ~ ~ ~ W ^ B O u.^.~.^.^.^.^.~.~.^.^.^.h.Y ^ ~ ~ ^ F $ k.R.G.1.Y / ~ ~ ~ ~ ~ ~ ", -"= = & e ^ ~ ~ ~ / W ( J X 7.^.~.^.^.^.^.^.^.^.^.^.^.^.s.Y / W ) a 2 U.^.^.d.U ( ~ ~ ~ ~ ~ ~ ", -"= = & e ^ W / ~ ~ ~ ^ > w ~.^.^.^.^.^.F.%.v c.^.^.^.^.~.X.W ~ ^ > h ^.^.^.d.P ( ~ ~ ~ ~ ~ ~ ", -"= = & e ^ W ~ ~ W ^ H o e.^.^.^.^.^.G.Y E n . y.^.^.^.^.M.Y ( ! $ @.^.~.^.f.U ( / ~ ~ W ~ ~ ", -"= = & e ^ W ~ W ! ) t 4 U.^.^.^.^.^.>.U ( _ , 9 ~.^.^.^.~...^ A y.^.~.^.s.M W Y ~ ~ ~ ~ ~ ", -"= 3 & e ^ W ~ ( ^ ( $ c ^.^.^.^.^.E.) ~ ~ ^ S o n.^.^.^.^.=.- l.v.Y.^.^.^.M.:.:.X.~ ~ ~ ~ ~ ", -"= = & e ^ ! W W ( J X 7.^.^.^.^.^.F.Y ( W ^ T X 6.^.^.~.^.c.. J.^.^.^.^.^.^.^.^.P.~ ~ ~ ~ ~ ", -"= = & r ^ W / W ) B o v.^.~.^.^.^.M.U / ~ ~ ! $ o.^.^.^.^.K.* S.^.^.^.^.^.^.^.^.P.~ ~ ~ ~ ~ ", -"= = & e ^ ! ~ W ) a + S.^.^.^.^.^.z.P ( W ~ ( % z ^.^.^.^.~.f t.U.^.^.^.^.~.^.^.P.~ ~ ~ ~ ~ ", -"* = & e ^ W ~ W ) t 3 Y.^.^.^.^.^.f.P ( ~ ~ ^ ; h ^.^.^.^.^.:.@ j ^.^.^.^.h.{ X.&.~ ~ ~ ~ ~ ", -"3 = & e ^ W ~ ~ ^ e 8 Q.^.^.^.^.^.s.P ~ ~ W ^ > 0 ~.^.^.^.^.1.# z ^.^.^.^.d.L W R ~ ~ ~ ~ ~ ", -"= = & e ^ W ~ ~ ^ > q ~.^.^.^.^.^.p.U ^ ~ W ) e 9 ~.^.^.^.^.3.# k ^.^.^.^.f.Y ( / ~ ~ ~ ~ ~ ", -"= = & e ^ W / W ^ > w ~.^.^.^.^.^.i.Y / ~ W ^ e 8 Q.^.^.^.^.a.# z ^.^.^.^.f.Y / ~ ~ ~ ~ ~ ~ ", -"= = & e ^ W / W ^ > w ^.^.^.^.^.^.2.Y / ~ ~ ) e 8 Q.^.^.^.^.s.# z ^.^.^.^.d.P ( ~ ~ ~ ~ ~ ~ ", -"= = & e ^ W W W ^ > q ^.^.^.^.^.^.p.Y / ~ ~ ^ e 9 Q.^.^.^.^.a.@ z ^.^.^.^.f.U / ~ ~ ~ ~ ~ ~ ", -"= = & e ^ W / W ) 7 9 Q.^.^.^.^.^.a.P / ~ W ) , 9 Q.^.^.^.^.3.# z ^.^.~.^.f.P ^ ~ ~ ~ ~ ~ ~ ", -"= = & e ^ W / W ) r 5 T.^.^.^.^.^.d.Y / ~ W ) > q ~.^.^.^.^.1.# k ^.^.^.^.f.Y ( ~ ~ ~ ~ ~ ~ ", -"= = & e ^ / / W ) i 2 I.^.^.^.^.^.h.P ( ~ W ( > g ^.^.^.^.^.:.# z ^.^.^.^.f.P / ~ ~ ~ ~ ~ ~ ", -"= = & e ( W / W ) m O Z.^.^.^.^.^.x.P / ~ ~ ( ; j ^.^.^.^.~.&.- k ^.^.~.^.f.P / ~ ~ ~ ~ ~ ~ ", -"= = & e ( W / W ) F o y.^.~.^.^.^.N.U ( ~ ~ W $ b ^.^.^.^.R._ - k ^.^.^.^.f.Y ( ~ ~ ~ ~ ~ ~ ", -"= = & e ^ W ~ ~ ^ J X 4.^.^.^.^.^.L.~ ~ W ^ T X #.^.^.^.^.F.~ ; j ^.^.^.^.f.U ( ~ ~ ~ ~ ~ ~ ", -"= = & e ^ ~ ~ ~ / ^ % l ^.^.^.^.^.!. .R ^ ^ G . r.^.~.^.^.j.E : j ^.^.^.^.f.P ) ( ~ ~ ~ ~ ~ ", -"= = & e ^ W ~ ~ W ) u = U.^.^.^.^.^.1.Y ! ) a & K.^.^.^.^.;.~ : j ^.^.~.^.z.M I I / ~ ~ W ~ ", -"= = & e ( W ~ ~ W ( G . q.^.^.^.^.^.D.U ^ ! X o.^.^.^.^.P.~ ^ > g ^.^.^.^.E.-.$.m.X.W ~ ~ ~ ", -"= = & e ^ / ~ ~ ^ ! ( > w ~.^.^.^.^.^.h.T > j T.^.^.~.^.a.Y _ i 3 U.^.^.^.^.^.^.^.X.R ~ ~ ~ ", -"= = & e ^ / ~ ~ W W ^ H . 9.^.~.^.^.^.^.K.C.~.^.^.^.^.H.W W ^ T . q.^.~.^.^.^.^.^.X.R ~ ~ ~ ", -"= = + e ^ W / ~ W W W ) m + B.^.~.^.^.^.^.^.^.^.^.^.E.X.Y ( W ^ B 6 y.^.^.^.E.D.2.( ~ ~ ~ ~ ", -"= = * e ^ ! / ! W ^ W W ) a 4 b.^.^.^.^.^.^.^.^.^.P...Y ( ! W ! ^ W Z [ *.X.{ Y U ~ ~ ~ ~ ~ ", -"= = & e ( W ~ ~ W / W / W ) A < +.A.~.^.^.^.^.!.p.W R ~ ~ ~ ~ ~ W / ) E U W W / ^ ~ ~ ~ ~ ~ ", -"= = & e ^ W ~ ~ / W / / / W ( _ Z X 6.^.^.^.^.E.W ~ ^ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ / ~ ~ ~ ~ ~ ~ ~ ~ ", -"= = & e ^ ~ ~ ~ W W / W ~ ~ ~ ~ ) ; h ^.^.^.^.^.d.M U ~ / ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ W ", -"= = & e ^ W ~ ~ ^ W W / ~ ~ ~ W ) p + S.^.^.^.^.~.M.f. .W ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ .", -"= = & e ^ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ W ( T O +.^.~.^.^.^.^.^.&.Y ( ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ W ( Y 2.", -"= = & e ( W ~ ~ ~ ~ ~ ~ ~ ~ ~ / W ) N + b.^.^.^.^.^.^.&.R ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ W /.", -"= = & e ^ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ W ^ N 7 r.W.^.^.^.!.X.W ~ ~ W ~ W ~ ~ ~ ~ ~ ~ / ( ( K p./.", -"= = & e ( W ~ ~ W ~ ~ ~ ~ ~ ~ ~ ~ ~ W ( W C Q &.:.X.| ~ ~ ~ ~ W ~ / ~ ( / ( ~ W E U P 1././.", -"= = + e ^ / / / ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ W / ) ^ R Y W W ~ ~ ( / ( / W R Y Y U R ( X.,././././.", -"= = * e ( / ~ / ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ W W W ! ( ( ( W W E U P Y W ( X.,.d./././././././././.", -"= = * e ( W ~ ~ ~ ~ W ! ~ W ~ W ~ ( ( / ^ W W U Y P W ( X.,.d./././././././././././././././.", -"8 $ * e ( W ~ ~ ~ ! ( ( ( / ( W R Y Y Y R ( X.>.d./././././././././././././././././././././.", -"/.d . y ^ / / / ( W Y Y P P W ( X.>.d./././././././././././././././././././././././././././.", -"/./.h : ^ R R R W ( X.<.f./././././././././././././././././././././././././././././././././.", -"/././.] _ *.3./././././././././././././././././././././././././././././././././././././././." -}; - -class EvalMessageBox : public QDialog -{ -public: - EvalMessageBox(bool expired) - { - setWindowTitle(QLatin1String(" ")); - - QString str = expired ? QLatin1String(boilerplate_expired) : qt_eval_string(); - str = str.trimmed(); - - QFrame *border = new QFrame(this); - - QLabel *pixmap_label = new QLabel(border); - pixmap_label->setPixmap(QPixmap(qtlogo_eval_xpm)); - pixmap_label->setAlignment(Qt::AlignTop); - - QLabel *text_label = new QLabel(str, border); - - QHBoxLayout *pm_and_text_layout = new QHBoxLayout(); - pm_and_text_layout->addWidget(pixmap_label); - pm_and_text_layout->addWidget(text_label); - - QVBoxLayout *master_layout = new QVBoxLayout(border); - master_layout->addLayout(pm_and_text_layout); - - QVBoxLayout *border_layout = new QVBoxLayout(this); - border_layout->setMargin(0); - border_layout->addWidget(border); - - if (expired) { - QPushButton *cmd = new QPushButton(QLatin1String("OK"), border); - cmd->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - cmd->setDefault(true); - - QHBoxLayout *button_layout = new QHBoxLayout(); - master_layout->addLayout(button_layout); - button_layout->addWidget(cmd); - - connect(cmd, SIGNAL(clicked()), this, SLOT(close())); - } else { - border->setFrameShape(QFrame::WinPanel); - border->setFrameShadow(QFrame::Raised); - setParent(parentWidget(), Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); - QTimer::singleShot(7000, this, SLOT(close())); - setAttribute(Qt::WA_DeleteOnClose); - setAttribute(Qt::WA_QuitOnClose, false); - } - - setFixedSize(sizeHint()); - } -}; - -class QGuiFuriCuri : public QCoreFuriCuri -{ -public: - void timerEvent(QTimerEvent *e) { - if (e->timerId() == warn) { - killTimer(warn); - QMessageBox::information(0, QLatin1String("Automatic Timeout"), QLatin1String(will_shutdown_1min)); - kill = startTimer(KILL_DELAY); - } else if (e->timerId() == kill) { - killTimer(kill); - QMessageBox::information(0, QLatin1String("Automatic Timeout"), QLatin1String(will_shutdown_now)); - qApp->quit(); - } - } -}; - - -void qt_gui_eval_init(QCoreApplicationPrivate::Type type) -{ - Q_UNUSED(type); - - if (!qt_eval_is_supported()) - return; - - if (qt_eval_is_expired()) { - EvalMessageBox box(true); - box.exec(); - ::exit(0); - } else { - Q_UNUSED(new QGuiFuriCuri()); - } -} - -static QString qt_eval_title_prefix() -{ - return QLatin1String("[Qt Evaluation] "); -} - -QString qt_eval_adapt_window_title(const QString &title) -{ - if (!qt_eval_is_supported()) - return title; - return qt_eval_title_prefix() + title; -} - -void qt_eval_init_widget(QWidget *w) -{ - if (!qt_eval_is_supported()) - return; - if (w->isTopLevel() && w->windowTitle().isEmpty() && w->windowType() != Qt::Desktop ) { - w->setWindowTitle(QLatin1String(" ")); - } -} -#endif - -QT_END_NAMESPACE diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro index 83e44ff9a4..3a1a186e8e 100644 --- a/src/tools/bootstrap/bootstrap.pro +++ b/src/tools/bootstrap/bootstrap.pro @@ -19,8 +19,6 @@ DEFINES += \ QT_NO_FOREACH \ QT_NO_CAST_FROM_ASCII -DEFINES -= QT_EVAL - SOURCES += \ ../../corelib/codecs/qlatincodec.cpp \ ../../corelib/codecs/qtextcodec.cpp \ diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 3594b5c902..e189e5ba50 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -575,10 +575,6 @@ void QApplicationPrivate::init() initialize(); eventDispatcher->startingUp(); -#ifdef QT_EVAL - extern void qt_gui_eval_init(QCoreApplicationPrivate::Type); - qt_gui_eval_init(application_type); -#endif #ifndef QT_NO_ACCESSIBILITY // factory for accessible interfaces for widgets shipped with Qt QAccessible::installFactory(&qAccessibleFactory); diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 87cc150530..e1ce731418 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1348,11 +1348,6 @@ void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow) if (!isWindow() && parentWidget() && parentWidget()->testAttribute(Qt::WA_DropSiteRegistered)) setAttribute(Qt::WA_DropSiteRegistered, true); -#ifdef QT_EVAL - extern void qt_eval_init_widget(QWidget *w); - qt_eval_init_widget(this); -#endif - // need to force the resting of the icon after changing parents if (testAttribute(Qt::WA_SetWindowIcon)) d->setWindowIcon_sys(); @@ -6055,13 +6050,7 @@ QString qt_setWindowTitle_helperHelper(const QString &title, const QWidget *widg { Q_ASSERT(widget); -#ifdef QT_EVAL - extern QString qt_eval_adapt_window_title(const QString &title); - QString cap = qt_eval_adapt_window_title(title); -#else QString cap = title; -#endif - if (cap.isEmpty()) return cap; diff --git a/src/widgets/widgets.pro b/src/widgets/widgets.pro index e556cb8b10..6f807e1696 100644 --- a/src/widgets/widgets.pro +++ b/src/widgets/widgets.pro @@ -32,8 +32,6 @@ qtConfig(graphicseffect) { QMAKE_LIBS += $$QMAKE_LIBS_GUI -contains(DEFINES,QT_EVAL):include($$QT_SOURCE_TREE/src/corelib/eval.pri) - QMAKE_DYNAMIC_LIST_FILE = $$PWD/QtWidgets.dynlist # Code coverage with TestCocoon From d99162754f225ca98318e96184e80a57c33fa1ed Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sat, 2 Feb 2019 22:03:42 +0100 Subject: [PATCH 024/292] QStyleSheet/QToolbox: don't overlap text and icon When an icon was specified with a style sheet, the content rect for the toolbox label was not adjusted which results in an overlapping of the text and the icon. Fix it by adjusting the rect used by drawing the label when an icon is specified with a style sheet. Fixes: QTBUG-40871 Change-Id: I088b319e6355d78066d0bc4472882a5d9a599091 Reviewed-by: Frederik Gladhorn Reviewed-by: Vitaly Fanaskov --- src/widgets/styles/qstylesheetstyle.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index e73d019408..c0f0321fce 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -4089,6 +4089,11 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q if (subRule.hasFont) p->setFont(subRule.font); boxCopy.rect = subRule.contentsRect(opt->rect); + if (subRule.hasImage()) { + // the image is already drawn with CE_ToolBoxTabShape, adjust rect here + const int iconExtent = proxy()->pixelMetric(QStyle::PM_SmallIconSize, box, w); + boxCopy.rect.setLeft(boxCopy.rect.left() + iconExtent); + } QWindowsStyle::drawControl(ce, &boxCopy, p , w); if (subRule.hasFont) p->setFont(oldFont); From 57953174549797d1e87543ff7f70571053caf370 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 23 Dec 2018 10:20:47 +0100 Subject: [PATCH 025/292] QFormLayout: honor vertical expanding size policy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QFormLayout did not honor the vertical expanding state for widgets. Therefore e.g. a QTextEdit was not expanded vertically when it was inside a QFormLayout but worked fine inside a QGridLayout. It was honored when a stretch factor was set though. Fix it by not adding a dummy stretch item when one item is expanding. [ChangeLog][QtWidgets][QFormLayout] Honor the vertical expanding state of a widget inside a QFormLayout. Fixes: QTBUG-72676 Change-Id: If4456145918afa5a10435063770cc93bb9315fbe Reviewed-by: Samuel Gaist Reviewed-by: Friedemann Kleint Reviewed-by: Jan Arve Sæther --- src/widgets/kernel/qformlayout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp index bd0ea2598a..9146ba84c8 100644 --- a/src/widgets/kernel/qformlayout.cpp +++ b/src/widgets/kernel/qformlayout.cpp @@ -783,7 +783,7 @@ void QFormLayoutPrivate::setupVerticalLayoutData(int width) vLayouts[vidx].expansive = expanding || (vLayouts[vidx].stretch > 0); vLayouts[vidx].empty = false; - if (vLayouts[vidx].stretch > 0) + if (vLayouts[vidx].expansive) addTopBottomStretch = false; if (vidx > 1) From f4cc23cffbe3005f0a522cac938695e87ecd6407 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Mon, 18 Feb 2019 21:46:33 +0100 Subject: [PATCH 026/292] QPdfWriter: mark obsolete functions as deprecated Mark obsolete functions in QPdfWriter as deprecated so they can be removed with Qt6: - setPageSize(PageSize size) - setPageSizeMM(const QSizeF &size) - setMargins(const Margins &m) Change-Id: Iba88528742e67c09f5dc61aea69d27e26f484c16 Reviewed-by: Friedemann Kleint Reviewed-by: Andy Shaw --- src/gui/painting/qpdfwriter.cpp | 10 ++++++++++ src/gui/painting/qpdfwriter.h | 6 +++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qpdfwriter.cpp b/src/gui/painting/qpdfwriter.cpp index 258939a763..7f18ce42be 100644 --- a/src/gui/painting/qpdfwriter.cpp +++ b/src/gui/painting/qpdfwriter.cpp @@ -379,6 +379,9 @@ int QPdfWriter::resolution() const */ #endif +#if QT_DEPRECATED_SINCE(5, 14) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED /*! \reimp @@ -404,6 +407,8 @@ void QPdfWriter::setPageSizeMM(const QSizeF &size) { setPageSize(QPageSize(size, QPageSize::Millimeter)); } +QT_WARNING_POP +#endif /*! \internal @@ -427,6 +432,9 @@ bool QPdfWriter::newPage() } +#if QT_DEPRECATED_SINCE(5, 14) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED /*! \reimp @@ -438,6 +446,8 @@ void QPdfWriter::setMargins(const Margins &m) { setPageMargins(QMarginsF(m.left, m.top, m.right, m.bottom), QPageLayout::Millimeter); } +QT_WARNING_POP +#endif QT_END_NAMESPACE diff --git a/src/gui/painting/qpdfwriter.h b/src/gui/painting/qpdfwriter.h index b260805b2b..668081e008 100644 --- a/src/gui/painting/qpdfwriter.h +++ b/src/gui/painting/qpdfwriter.h @@ -86,10 +86,14 @@ public: using QPagedPaintDevice::setPageSize; #endif +#if QT_DEPRECATED_SINCE(5, 14) + QT_DEPRECATED_X("Use setPageSize(QPageSize(id)) instead") void setPageSize(PageSize size) override; + QT_DEPRECATED_X("Use setPageSize(QPageSize(size, QPageSize::Millimeter)) instead") void setPageSizeMM(const QSizeF &size) override; - + QT_DEPRECATED_X("Use setPageMargins(QMarginsF(l, t, r, b), QPageLayout::Millimeter) instead") void setMargins(const Margins &m) override; +#endif protected: QPaintEngine *paintEngine() const override; From 6a314669511fe7b36abc8da832c80de32fa567d9 Mon Sep 17 00:00:00 2001 From: Martin Koller Date: Fri, 4 Jan 2019 21:58:51 +0100 Subject: [PATCH 027/292] ensure signal subWindowActivated() triggers even when widget has focus A widget being added to QMdiArea which currently has focus did not trigger the subWindowActivated() signal since the connection to the method _q_processWindowStateChanged, which emits the signal (set up in appendChild()), was just done after the focus was set back again to the added widget. Setting the focus makes the widget active. This patch changes the order: first call appendChild(), then set focus Change-Id: I3aaf1728dc082d1323c7fbd62bfdbd2af87ab2ce Reviewed-by: Richard Moe Gustavsen --- src/widgets/widgets/qmdiarea.cpp | 4 +++- tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp index feea7cd050..0ce561860e 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -1988,9 +1988,11 @@ QMdiSubWindow *QMdiArea::addSubWindow(QWidget *widget, Qt::WindowFlags windowFla Q_ASSERT(child->testAttribute(Qt::WA_DeleteOnClose)); } + d->appendChild(child); + if (childFocus) childFocus->setFocus(); - d->appendChild(child); + return child; } diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp index 67b79e3faf..046899ce05 100644 --- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp @@ -333,6 +333,7 @@ void tst_QMdiArea::subWindowActivated() for ( i = 0; i < count; ++i ) { QWidget *widget = new QWidget(workspace, 0); widget->setAttribute(Qt::WA_DeleteOnClose); + widget->setFocus(); workspace->addSubWindow(widget)->show(); widget->show(); qApp->processEvents(); From f6cf0442df52e8018f724a9234d2ae0267ecba85 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Fri, 1 Feb 2019 14:27:58 +0100 Subject: [PATCH 028/292] Convert tst_qhttpnetworkconnection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit and make it work with our new docker-based test server Change-Id: I98b5b5b1e2cdca46b7f15be72aa1483d9455403d Reviewed-by: Edward Welbourne Reviewed-by: Mårten Nordheim --- .../qhttpnetworkconnection.pro | 4 + .../tst_qhttpnetworkconnection.cpp | 76 +++++++++--------- tests/testserver/apache2/apache2.sh | 3 + .../testdata/www/htdocs/rfcs/.gitattributes | 1 + .../testdata/www/htdocs/rfcs/rfc2616.html | Bin 0 -> 418321 bytes 5 files changed, 48 insertions(+), 36 deletions(-) create mode 100644 tests/testserver/apache2/testdata/www/htdocs/rfcs/.gitattributes create mode 100644 tests/testserver/apache2/testdata/www/htdocs/rfcs/rfc2616.html diff --git a/tests/auto/network/access/qhttpnetworkconnection/qhttpnetworkconnection.pro b/tests/auto/network/access/qhttpnetworkconnection/qhttpnetworkconnection.pro index d32b651b86..69a4a50144 100644 --- a/tests/auto/network/access/qhttpnetworkconnection/qhttpnetworkconnection.pro +++ b/tests/auto/network/access/qhttpnetworkconnection/qhttpnetworkconnection.pro @@ -4,3 +4,7 @@ SOURCES += tst_qhttpnetworkconnection.cpp requires(qtConfig(private_tests)) QT = core-private network-private testlib + +QT_TEST_SERVER_LIST = apache2 +include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) + diff --git a/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp index 84766f5484..0a9320118d 100644 --- a/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp +++ b/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp @@ -50,6 +50,7 @@ private: bool finishedCalled; bool finishedWithErrorCalled; QNetworkReply::NetworkError netErrorCode; + QString (*httpServerName)() = QtNetworkSettings::httpServerName; private Q_SLOTS: void initTestCase(); @@ -101,7 +102,11 @@ private Q_SLOTS: void tst_QHttpNetworkConnection::initTestCase() { +#if defined(QT_TEST_SERVER) + QVERIFY(QtNetworkSettings::verifyConnection(httpServerName(), 80)); +#else QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); +#endif } void tst_QHttpNetworkConnection::options_data() @@ -126,10 +131,9 @@ void tst_QHttpNetworkConnection::head_data() QTest::addColumn("statusString"); QTest::addColumn("contentLength"); - QTest::newRow("success-internal") << "http://" << QtNetworkSettings::serverName() << "/qtest/rfc3252.txt" << ushort(80) << false << 200 << "OK" << 25962; - - QTest::newRow("failure-path") << "http://" << QtNetworkSettings::serverName() << "/t" << ushort(80) << false << 404 << "Not Found" << -1; - QTest::newRow("failure-protocol") << "" << QtNetworkSettings::serverName() << "/qtest/rfc3252.txt" << ushort(80) << false << 400 << "Bad Request" << -1; + QTest::newRow("success-internal") << "http://" << httpServerName() << "/qtest/rfc3252.txt" << ushort(80) << false << 200 << "OK" << 25962; + QTest::newRow("failure-path") << "http://" << httpServerName() << "/t" << ushort(80) << false << 404 << "Not Found" << -1; + QTest::newRow("failure-protocol") << "" << httpServerName() << "/qtest/rfc3252.txt" << ushort(80) << false << 400 << "Bad Request" << -1; } void tst_QHttpNetworkConnection::head() @@ -175,10 +179,10 @@ void tst_QHttpNetworkConnection::get_data() QTest::addColumn("contentLength"); QTest::addColumn("downloadSize"); - QTest::newRow("success-internal") << "http://" << QtNetworkSettings::serverName() << "/qtest/rfc3252.txt" << ushort(80) << false << 200 << "OK" << 25962 << 25962; + QTest::newRow("success-internal") << "http://" << httpServerName() << "/qtest/rfc3252.txt" << ushort(80) << false << 200 << "OK" << 25962 << 25962; - QTest::newRow("failure-path") << "http://" << QtNetworkSettings::serverName() << "/t" << ushort(80) << false << 404 << "Not Found" << -1 << -1; - QTest::newRow("failure-protocol") << "" << QtNetworkSettings::serverName() << "/qtest/rfc3252.txt" << ushort(80) << false << 400 << "Bad Request" << -1 << -1; + QTest::newRow("failure-path") << "http://" << httpServerName() << "/t" << ushort(80) << false << 404 << "Not Found" << -1 << -1; + QTest::newRow("failure-protocol") << "" << httpServerName() << "/qtest/rfc3252.txt" << ushort(80) << false << 400 << "Bad Request" << -1 << -1; } void tst_QHttpNetworkConnection::get() @@ -244,8 +248,8 @@ void tst_QHttpNetworkConnection::put_data() QTest::addColumn("data"); QTest::addColumn("succeed"); - QTest::newRow("success-internal") << "http://" << QtNetworkSettings::serverName() << "/dav/file1.txt" << ushort(80) << false << "Hello World\nEnd of file\n"<("contentLength"); QTest::addColumn("downloadSize"); - QTest::newRow("success-internal") << "http://" << QtNetworkSettings::serverName() << "/qtest/cgi-bin/echo.cgi" << ushort(80) << false << "7 bytes" << 200 << "OK" << 7 << 7; - QTest::newRow("failure-internal") << "http://" << QtNetworkSettings::serverName() << "/t" << ushort(80) << false << "Hello World" << 404 << "Not Found" << -1 << -1; + QTest::newRow("success-internal") << "http://" << httpServerName() << "/qtest/cgi-bin/echo.cgi" << ushort(80) << false << "7 bytes" << 200 << "OK" << 7 << 7; + QTest::newRow("failure-internal") << "http://" << httpServerName() << "/t" << ushort(80) << false << "Hello World" << 404 << "Not Found" << -1 << -1; } void tst_QHttpNetworkConnection::post() @@ -449,11 +453,11 @@ void tst_QHttpNetworkConnection::get401_data() QTest::addColumn("password"); QTest::addColumn("statusCode"); - QTest::newRow("no-credentials") << "http://" << QtNetworkSettings::serverName() << "/qtest/rfcs-auth/index.html" << ushort(80) << false << false << "" << ""<<401; - QTest::newRow("invalid-credentials") << "http://" << QtNetworkSettings::serverName() << "/qtest/rfcs-auth/index.html" << ushort(80) << false << true << "test" << "test"<<401; - QTest::newRow("valid-credentials") << "http://" << QtNetworkSettings::serverName() << "/qtest/rfcs-auth/index.html" << ushort(80) << false << true << "httptest" << "httptest"<<200; - QTest::newRow("digest-authentication-invalid") << "http://" << QtNetworkSettings::serverName() << "/qtest/auth-digest/index.html" << ushort(80) << false << true << "wrong" << "wrong"<<401; - QTest::newRow("digest-authentication-valid") << "http://" << QtNetworkSettings::serverName() << "/qtest/auth-digest/index.html" << ushort(80) << false << true << "httptest" << "httptest"<<200; + QTest::newRow("no-credentials") << "http://" << httpServerName() << "/qtest/rfcs-auth/index.html" << ushort(80) << false << false << "" << ""<<401; + QTest::newRow("invalid-credentials") << "http://" << httpServerName() << "/qtest/rfcs-auth/index.html" << ushort(80) << false << true << "test" << "test"<<401; + QTest::newRow("valid-credentials") << "http://" << httpServerName() << "/qtest/rfcs-auth/index.html" << ushort(80) << false << true << "httptest" << "httptest"<<200; + QTest::newRow("digest-authentication-invalid") << "http://" << httpServerName() << "/qtest/auth-digest/index.html" << ushort(80) << false << true << "wrong" << "wrong"<<401; + QTest::newRow("digest-authentication-valid") << "http://" << httpServerName() << "/qtest/auth-digest/index.html" << ushort(80) << false << true << "httptest" << "httptest"<<200; } void tst_QHttpNetworkConnection::get401() @@ -508,9 +512,9 @@ void tst_QHttpNetworkConnection::compression_data() QTest::addColumn("autoCompress"); QTest::addColumn("contentCoding"); - QTest::newRow("success-autogzip-temp") << "http://" << QtNetworkSettings::serverName() << "/qtest/rfcs/rfc2616.html" << ushort(80) << false << 200 << "OK" << -1 << 418321 << true << ""; - QTest::newRow("success-nogzip-temp") << "http://" << QtNetworkSettings::serverName() << "/qtest/rfcs/rfc2616.html" << ushort(80) << false << 200 << "OK" << 418321 << 418321 << false << "identity"; - QTest::newRow("success-manualgzip-temp") << "http://" << QtNetworkSettings::serverName() << "/qtest/deflate/rfc2616.html" << ushort(80) << false << 200 << "OK" << 119124 << 119124 << false << "gzip"; + QTest::newRow("success-autogzip-temp") << "http://" << httpServerName() << "/qtest/rfcs/rfc2616.html" << ushort(80) << false << 200 << "OK" << -1 << 418321 << true << ""; + QTest::newRow("success-nogzip-temp") << "http://" << httpServerName() << "/qtest/rfcs/rfc2616.html" << ushort(80) << false << 200 << "OK" << 418321 << 418321 << false << "identity"; + QTest::newRow("success-manualgzip-temp") << "http://" << httpServerName() << "/qtest/deflate/rfc2616.html" << ushort(80) << false << 200 << "OK" << 119124 << 119124 << false << "gzip"; } @@ -586,9 +590,9 @@ void tst_QHttpNetworkConnection::ignoresslerror_data() // fluke's certificate is signed by a non-standard authority. // Since we don't introduce that CA into the SSL verification chain, // connecting should fail. - QTest::newRow("success-init") << "https://" << QtNetworkSettings::serverName() << "/" << ushort(443) << true << true << false << 200; - QTest::newRow("success-fromSignal") << "https://" << QtNetworkSettings::serverName() << "/" << ushort(443) << true << false << true << 200; - QTest::newRow("failure") << "https://" << QtNetworkSettings::serverName() << "/" << ushort(443) << true << false << false << 100; + QTest::newRow("success-init") << "https://" << httpServerName() << "/" << ushort(443) << true << true << false << 200; + QTest::newRow("success-fromSignal") << "https://" << httpServerName() << "/" << ushort(443) << true << false << true << 200; + QTest::newRow("failure") << "https://" << httpServerName() << "/" << ushort(443) << true << false << false << 100; } void tst_QHttpNetworkConnection::ignoresslerror() @@ -635,7 +639,7 @@ void tst_QHttpNetworkConnection::nossl_data() QTest::addColumn("encrypt"); QTest::addColumn("networkError"); - QTest::newRow("protocol-error") << "https://" << QtNetworkSettings::serverName() << "/" << ushort(443) << true < requests; QList replies; @@ -705,7 +709,7 @@ void tst_QHttpNetworkConnection::getMultiple() // depending on what you use the results will vary. // for the "real" results, use a URL that has "internet latency" for you. Then (6 connections, pipelining) will win. // for LAN latency, you will possibly get that (1 connection, no pipelining) is the fastest - QHttpNetworkRequest *request = new QHttpNetworkRequest("http://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt"); + QHttpNetworkRequest *request = new QHttpNetworkRequest("http://" + httpServerName() + "/qtest/rfc3252.txt"); if (pipeliningAllowed) request->setPipeliningAllowed(true); requests.append(request); @@ -723,7 +727,7 @@ void tst_QHttpNetworkConnection::getMultipleWithPipeliningAndMultiplePriorities( quint16 requestCount = 100; // use 2 connections. - QHttpNetworkConnection connection(2, QtNetworkSettings::serverName()); + QHttpNetworkConnection connection(2, httpServerName()); QList requests; QList replies; @@ -731,9 +735,9 @@ void tst_QHttpNetworkConnection::getMultipleWithPipeliningAndMultiplePriorities( for (int i = 0; i < requestCount; i++) { QHttpNetworkRequest *request = 0; if (i % 3) - request = new QHttpNetworkRequest("http://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt", QHttpNetworkRequest::Get); + request = new QHttpNetworkRequest("http://" + httpServerName() + "/qtest/rfc3252.txt", QHttpNetworkRequest::Get); else - request = new QHttpNetworkRequest("http://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt", QHttpNetworkRequest::Head); + request = new QHttpNetworkRequest("http://" + httpServerName() + "/qtest/rfc3252.txt", QHttpNetworkRequest::Head); if (i % 2 || i % 3) request->setPipeliningAllowed(true); @@ -800,9 +804,9 @@ void tst_QHttpNetworkConnection::getMultipleWithPriorities() { quint16 requestCount = 100; // use 2 connections. - QHttpNetworkConnection connection(2, QtNetworkSettings::serverName()); + QHttpNetworkConnection connection(2, httpServerName()); GetMultipleWithPrioritiesReceiver receiver(requestCount); - QUrl url("http://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt"); + QUrl url("http://" + httpServerName() + "/qtest/rfc3252.txt"); QList requests; QList replies; @@ -854,10 +858,10 @@ void tst_QHttpNetworkConnection::getEmptyWithPipelining() { quint16 requestCount = 50; // use 2 connections. - QHttpNetworkConnection connection(2, QtNetworkSettings::serverName()); + QHttpNetworkConnection connection(2, httpServerName()); GetEmptyWithPipeliningReceiver receiver(requestCount); - QUrl url("http://" + QtNetworkSettings::serverName() + "/cgi-bin/echo.cgi"); // a get on this = getting an empty file + QUrl url("http://" + httpServerName() + "/cgi-bin/echo.cgi"); // a get on this = getting an empty file QList requests; QList replies; @@ -901,8 +905,8 @@ void tst_QHttpNetworkConnection::getAndEverythingShouldBePipelined() { quint16 requestCount = 100; // use 1 connection. - QHttpNetworkConnection connection(1, QtNetworkSettings::serverName()); - QUrl url("http://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt"); + QHttpNetworkConnection connection(1, httpServerName()); + QUrl url("http://" + httpServerName() + "/qtest/rfc3252.txt"); QList requests; QList replies; @@ -937,8 +941,8 @@ void tst_QHttpNetworkConnection::getAndThenDeleteObject_data() void tst_QHttpNetworkConnection::getAndThenDeleteObject() { // yes, this will leak if the testcase fails. I don't care. It must not fail then :P - QHttpNetworkConnection *connection = new QHttpNetworkConnection(QtNetworkSettings::serverName()); - QHttpNetworkRequest request("http://" + QtNetworkSettings::serverName() + "/qtest/bigfile"); + QHttpNetworkConnection *connection = new QHttpNetworkConnection(httpServerName()); + QHttpNetworkRequest request("http://" + httpServerName() + "/qtest/bigfile"); QHttpNetworkReply *reply = connection->sendRequest(request); reply->setDownstreamLimited(true); diff --git a/tests/testserver/apache2/apache2.sh b/tests/testserver/apache2/apache2.sh index 4b0c74e2c4..d5075c7096 100755 --- a/tests/testserver/apache2/apache2.sh +++ b/tests/testserver/apache2/apache2.sh @@ -73,5 +73,8 @@ touch -d "2007-05-22 12:04:57 GMT" /home/$USER/www/htdocs/fluke.gif # Create 10MB file for use by tst_Q*::downloadBigFile and interruption tests: su $USER -c "/bin/dd if=/dev/zero of=~/www/htdocs/mediumfile bs=1 count=0 seek=10000000" +# Emulate test server's hierarchy: +su $USER -c "ln -s ~/www/htdocs/rfcs/rfc2616.html ~/www/htdocs/deflate/" + # enable service with installed configurations service apache2 restart diff --git a/tests/testserver/apache2/testdata/www/htdocs/rfcs/.gitattributes b/tests/testserver/apache2/testdata/www/htdocs/rfcs/.gitattributes new file mode 100644 index 0000000000..1d09ee726e --- /dev/null +++ b/tests/testserver/apache2/testdata/www/htdocs/rfcs/.gitattributes @@ -0,0 +1 @@ +rfc2616.html binary diff --git a/tests/testserver/apache2/testdata/www/htdocs/rfcs/rfc2616.html b/tests/testserver/apache2/testdata/www/htdocs/rfcs/rfc2616.html new file mode 100644 index 0000000000000000000000000000000000000000..0e3282fb8d3e5567338e63c19fe298b578522db9 GIT binary patch literal 418321 zcmd44Yj<2na;E#e*XsYUr+V29YKTh#;7t;H4g``CeMpKXLCZ6;mZty|fUY_>N$ZkG9aXXo|maAo-IYQXs8 zAL4)Co{Y~%&2)4!emvM8FZSk>)3eEJI%xK0)3fpP?D3$EcH=PyfBEAdx^QQ^i`nt` zY`o}0U0=KZ(2vHb&GBe@cs@D=k$)P!AH6jy!$PxK6w0ZgH@i{o1OT})1%Y>!N=+O$>YI)U;OvMzYUtR(fn|H z#&iF^%ZR`7o7r^lc(V5^zxptl?$17~%udJCr9XcP&Y$o8`StAd{FHysX0zkn(fsjr zcK3L;Hxioqd2u#6J74H05IN5WnCa|TPcI&S953$9$BW6|M!UyjfBG=lKRbGS|KZx* zqw(bM=n zOBg;EqSNu2D6;x?=gI1`|M`6NyY1J_)_m`1@_xLCL3nk4^8VsDKR4fwf|&+KXJ@Bh zudW_UV6EeiD`#51mFY~Zu~;2g5}!}^$G?5MI{HiV`widI%i|GII z{8v45V~d9#+7QH}c{80Yjz;?!vHW4spyT;yJNE7Ae9UvN#%CX9^Iw~v_-isfY`&k* z&QF^g{du#}Je!P<_j&D)e|R(g>-l(b)*Q^{O=K1{nWIF!iAAT$b znwK%kpMSUe#6PVx-;dAEJ}&(c> z>Q5WnNZH@@2ZUbE4$qJOUO0_t3Qm6?oF7=Q`NzfC$6x#qx_Wa`AVu z;eXD0HO)VrPsh#h(W6Il*e_yqL$6=2B9b_y&Fr8#JDMz-m*bOJLfp~k;!ih=)A8Qq z0DIkxrcL#uaA#AX&n(cVCAN_6IXens)u&}#&Zl?*cLB1G%W6HvAd|)3`C=hYUcX~seae-ogWZz}zRG0xyhQ^_ zo>-e~NBM^(`&3G}MzfaIxyI?WegYgYgKt9D6ONs^W2tyWlbb3nc<5@2skKd0& zYnCaRKrC8Ja=d?+u<-bJgcHvj@5gtWBSoDjEX1gpOj$xaI99}HEKqvm6V~wgna64l zaaQM(y}P3J*_e1?akr@heK?xz9W{Gkv^#Fj7vufP5GSMQN1T$yuM58VID>5_5P(OF zoDopS0@!mPj1~@N8WZdplZOGiCDYmlVd1M6hhRx&nw3t zi$oaI?pW`^AWjO*lV?yQM(GHG?T*J&0GOt`&>HmcOpf=Lf12#`BXPpv@oX1Sy12v> zL|ll!M}j8PJ*%m;6}TAQN;ML!)$ETC@H7^NUDiBlieQ73WE)flB~LL3%@Is`e#%Us z+3fQHfnqC11NbqW@JeotV}YMHHh!@@?kMgSp|&H@!O|F^A(TM`=d=CuNI9(B{?CJe zv?5r|>+|{PY%#t)6unU(tpiBj9&xBOV{>b84-=;iAnhQtlPPik;m6wpS}Bk=f%N11 z@f_Z4enbrf2j2p*;kt3s+|Y@B9VTNv-owQ<3KEa+Lv7$Bk4{cT^D7Y^ZU!V%eCzyB zG=itTd-d$f$3KB%g(R%L!&BO8-khVWZVP8+Wq8jxiQcb^v3xyZ5@f>A5ud=};#b4q zf(_5kQu{AJkmbAhB;yQL-BS@Mu#x#b1UEdetnp;lLT)c!IOKiB%rXX z-RD04a|=hL(PzoH5nAQmiukF}{L9uZAjz_T%_(_{+tWJcw-H(;EDMx;MA&KI3eqTbUO|**blY?ZMTA>D+9I_<02irmlI%O>U1*GagGM&CW@Z1bt$Ly>Rsdy6o&a5{>YYL}` z%g{q4UX*7VuB|mo!eKH!AK%fok#f{sBKLmoKr+R*k0)Zx@5V=?_Y)AA9OOc>7GrXe zB;Uw}Z6A|=S#;Q!0q%t_CO_GC`eF-)JuR;=>A7Af0|MAt^Tal-tbuaYzBlE!bPj|iyioo3q z?fb}5_ruezCtnQeUTC^U_Uc~$`1Z?@s*vOxyngrPfL88>etP6s@yXK{Pj{Yv;r#A} zetNVbo3Qg{Yx_$9tyD;om+c>4y?VO+g)_XD8BL$jVlq^05%&dNHo`|j&`(ax=JE?>9 zwR>`>$%l!nZUd|fNv<^87!5gOHeKvv+yYh$2^0K=4AeXv#Af5R40S*39kYvs^alJC zxg+*dwvT4)ZQg{zMW+rV@zVzU^pd^b{RXdv-8m?Q^}Y$=?}u$MPI56e;HPJ^bDW%; zyxo1K3rYO60YAMRkDDLyR<7QA=)T?k`F>a_<0O9CFh89!!+qu0Z-H7DlK5!@exmd* zJ=gA-pZocK*gNASe%gSamflUZ-+JeEq!J`Yc!nhdv$6Jo#3N3RNw_gR%vpCeHHz6(jb*=)j`@1~pyyT6+-=d;;-m)cr(a4YVg|Dg*>yvgjO>?kF@tC@#(f(t{KhnFZ8JRy>$3(1h2L zzY9sO50D;KUecD(?EHp2)rF*#G>{(292`)6aYGO}`5q+gFmD3y``H&{{q9%Kfb_4J zd~-OY6wBGsTQTNJ50Vt{Ch!Qs_Sl<>8l7h&D#Wj)bGxoRNMiEM;YOwS)6BllW~B6~ z;{PPe->*IfvlEkV4mS&=Wu+r`1cn;qPeL(2bs>q#H-YzVx;Q^Y*~w#RcXU1jtA~@A ze3MfgnUMre>7EN#;_AC3AtVGtAFZ35@X&&`HC#hPfm|r0C5vmGUzTOG3Gs#uMEQX zcsH}ft6$1Wr><~@4`RM4_>j$wEYgI~W~y=itKi81e?d<#CeQYtGCst0v%MT~h5 z<=ZO|FfUa;?P1aXP#{U6NZ~FP%>`ZAfByPU1(MdS_`9zpl57O%qq%y_U>l?Q2CD1Y(PCRs*BlrX+3D|^z5*J*6RDRM0747n~-Uodobt z;q@pj9+1ojPpA9KXR~E0giZG!W~a-$AD542r$~1cEnkOJ7m~O@bUJYk!|u-KUhjbI zLb6SmA$PJbpT(gA#6Lc&l6TKGfrB~;>AR1V*4dB#6m?p7kE*;N!Nm+0??NtlZu5U0 zS_=us{w)P?ye&&2dgVt;%?%(`X~D5~B7|cbb6jbTRp9?>f~EK%!#td4#8J`}H_M)u6UFOgHq{B5pKtB;}V(_qb!r=w~etx-n zunQ#Vrf!vj%JFWsy~rj+;N;S*$bo!D5A_gfKXf2Lrhv43`wC3}4%bqvIFpr-p2C(Y z)4UaO9Y|0rA=NUy7WdEpG+awv;L@ywbPEO0jxbzHU9c%@E?1@f?sh*7*HVHvwTb5x z*cZa;KtdPfrbZr8x-Cwr3pQ8K1(ua%g=bf9{(lPga4qEyNVY9M9gTd%$3Slw1ABns zTFRXuNrVmQC1E+|THYdps8A}r4ENJ=I2=}Ki4Ep(dE)d*9(o&RJ%7g!u5n1aJi}qy zVBsVwE^4Kt@T4{0jE`sJ5t4*gVK*G6rzuGCG+)h@qjXqR_fKL6hNCl|qIG;X%(DbT zL2|s25ne3c({fnpDlGcYhr`O5*5ja`l|nZ_qX%l3X9>WGtRZBIt*zzTtAk;lB@iU* z@q~1HbhFP~SNMeFQrsP}tq&P?$NkjL!>p1QB*_bq@WsbpfY>nW$OTFA0;JmuolzZT9l0P$UV!v&8qw5v z|5o!GW*xa8iOc&T?x*N-@w*PB4RQI4TkE(2ahP@F;Ittwe>wVXnf=KRZUj*ty3xPG zto{}xaXF=xhbN=ka}z#m2aA`9@K_-yoE%e$*p{{E+p~z z7cvuA4YRggbc#T~xorfT>(PfKnkQOs#+?2hx4R7E-vgp=ehP07W_Zt%GaNpkna)p8GE* zNIU7kaZ1ZQ*qa_1I;e(ccdJ75q*I0D_ztX8Mn0RO13Hy-H=*1x>xYLr5G0eZwM(&) zs=reLU(61>Fs~KIblX^oubay zBTlZp8l7D4Iu5fs8l0Hh6RNe}p3Y|Eo^I^}53{BjNX)Hz1tsAtbZ!W`0|~J!(FWTk zG)9Q>kR;e=S*imGvAeKCO)aWVuq$IP?4HwcFt_F|FWxZgteG8RCtDsZZwTpgGxoE{ zqG*c(=9p>vZ;ky+n62xIBTY0My@ANMSZ* zfa%Y1OCW|eELFcUn~{K8{JGiM-=7ni-3sEc)K&*1Su+%X+|5O|1 zbjolL5FLnJbu$6+LZ{D7{4xM`AR%{GLMq3iS9jT3nCsN;m1G>2ib3a}c4&CYv(&$} z{dKN5G; z7^=oB{3UQOPrrQr^6B!Iw4E?47JMj3(%Xo?PFiVu6Ro&Cn#TEc_kX-jWt%WPNYdLK zNQjzK4@4VkBKb);nqOuxg_HDlui*=@ii)b1Ay(${-#tijDcXwh%=LBLuuo#ugXC~k z$-UBq2Aqn$t6tr8;D)6(OtX{xzjUKvNr4XsXEyAGnp1sx8@>aHxgqmb)@Zh8(b(v7 zbZ+U@g=Bsz6z&><_VG{rG%VFq&V;%{-`OO0SvhHOgnk`!7K~G5$*tES*@YB1QIjI+ zKF|)UWQ>N%Yu8b^i{h|UDuGk-IE@4QXjOREoX87!!&0dvNapb_PPdTqtGgd{k-p~V zf`JoW?rnP$3S0$jnAJq<^84KPq-}PlgMK&PqZ_K4=#PIG_T<#RVcqgfX(}uo6#uW( z{LHHQHchsyb|>v|CThZvI+*EFlPwycP39!*iZ(?@XtcYA;D&kHKS9URSIgYDw({t1 z^MOwz+I49sxoy9u0*d+QLo^>d!*Z#CxB-pSRWTZO74x`Kg@YztH1%_DFYnacm_dh+ zdS*x;qdnLCU+y;90x%l4>6GYc>7S(I{-qOIns`ui8#KIhJ<3Ed0CK%-v5qIdMjyZO zv^v<)p(x4@PUwB!B{hxhsOJ_KHlat|o@w$YO^(dfQSl=C#gp?$imc)eML&QA2Tzq* zqVwGkl)ke%cPqWB3aK(LM3JjS@)v_GOdlUhgX zn6Uvt8+oqGE8JG~up84;j-}V4p0>xgfm=?6-&H-q`^o%_7AuBwMCMnm`e+E4T0YvB?Fs92*)3n%|y{_%TPK_)&hKvj}>)*&dFkYOwaAw-A&EEVH~i*O_LD< z*-@EIw5%^otvW$=Vp&}`4)>gBo(qxOVNx4>jL{v~a3JHp`fSnWY}}~1Xfp$kIYAs1 zHFS_1oknF2lyf&YG}H~d)T&Kf z=Gd~xB-$s&beRV+sd@-r?wg#=yvg zdhmQ`Hy`OgX;oAdE&8Hq-)IVV8@tdHhGV%^T-K<&zTRQcbtVp` zLJrkX(Lvi$mLq|OyBbD{mc=ua(`crrm((ON+8;-|McPcN6(V3#GWTgVI-yn+4&ZSs zL1ca|>y2E>;y_;T|XNtCWp(BrT8&H5V8 zO9JW4=;J0K3gD65)>ztTdI{$nR8T>^GWm)Pa5FXS8aZCzUK`OP?LsSD*`lg5lSROz$ z_OC5FD_7>^IqQ#REk`r5pXJ+^wBP)BDC_d-m4DQ7KJ!lx`RV)Fsm}NPy#7m=PdUp! zZ9RX>J8QqxS%ijk`&_UJwH^kECYtUQ*!Dv;HlwJdXFbcZGrxLLzg=#}Yzn^!;j=QmIP`Q7t3PoL=bZ-3Z&@uL0^ zPZ%}6`SIP0d`3UDZ*Twj^5xT4PXfTpt^b+5I0te3f9u6S+$Sm+P;DG6?hMYwjE(0s zFtuKngP^|jyTP?Lb`jRugYQPFe9R7>o0a>v=v!KjgoHYT6=hm&q$Uc$X$e8C_yLS; zE?V%|;(!jR(h74cK+ggVVNrmb`h6i`$uAhdFe)nW$z{wemNC4e zcKQHbHKHNKsLosDW3gJ-p`#{Z9dzivI+~>WWK}ZY{*<p=`XYh?l@d@NQ2ua~q zGSKzdq(-rOBA><3fG%N~EHk(Uzm9L{+Tkp#A#1q&G2U2Im zxZCC<_@u|x>`mr-=Wrz_QYn|3ERKXh=62-VKqR(ZPC~wbB;_ey=~%xjaY!e(Ah5$L zp_bH(ThzFWzWre}_>o!X2|@$c9OH5X12OzUc2@0u`F=(^8~Wg5$B7l8wTPadB@RG2 zEXaB*!LwQYX23YCAm<>h@SdF)z1mW(&@qjAnFDfUq>HW3DfR-7&Vct?FyW40hLdjk zX8_&r0CIQK3JA9~Zf|gmkiDc?AWWFgf?1TZku@#`p@2_&yHgpSMA#R|(TSWo6VRyy z)PDE~qO)t^TARV6C(cM7ha&@^ey`|7vou~gT&YjhYn2EQj4{ll6dC=pxtGFRUZy4+ zb?jc|i#t++@3qm!fMI!MhYL|OtFw>gJ@HxB%PjGuoMdLHbv_+^bh(^4tgK~reD@S$ zRjfAyxL8Ac>EgYMff`5&s-^-{7Chp`LD=pB|j;LxU8QD z@g(%=<>I@}XQy)wc!580ddJfOCS*o0Rd4>Y(=PA!XDHod^2@fe&T1N8rTwDuu zGqH{^KJ?+n3Fkf-a;16dz}23~;#zTspJe1DYt8=#Tci7Dt_ye<8?6!)J>V}jl|Prc zC>dcB9)UO$#WRo-<0vo^A$7JlW!pkGu2f?^%1~RyrXjb?wKaU?3EH&8Rfdix_;J}y z&@OdH<RFddaIgtAd5RV% z-?Q{#yt|BQb7lgLozHe>XNx;t`OuJ#gB8i>O1O%lc)Y!A1ufA@R`jW&XyFuv*QJQm zuWn2$!5vfxp{bcCLXVI9&Q!wObJ%H+A`t0`djgn~R8|tu z9;gQ#&v6vb=e{F=hheIgBg4nCgQehG>=PGt$jwT)-jJ>^;lJ@sdaGhpBaR zQcDCRiCu4zK%$kPb2=n+y1AS(GpObWbac$!GNb@MOcpkEB9vCcij!u2GEWlMs4tE0 zDhDvcZ&-zlLA}mr=cLe%;fdPQX}7eV!_i`LnR?(tGaRUbjZ~8)xiDY4uf0*rv*O;w z5m=cZNWD;HksshmXiav(&aGB58Zi~|Gx7x}Oy`gc@=s*b3oj&iod<#tx%4@DEPY>! zukb@pM!vzSh@}W1k{shH@}HM2U`QT9gx^HkhB1*ojm9pp5*n}(6((>G(}GEq=ty&d zk;fmG-6}9B99T?rfrEXGI8BO&KFc9v4hq9GSK2!&Om0KP0>v{HGj`ZLr>_asP{#}} z1sG>(BT5H&fio}`FfSS}1|&pgemS^RURAcvAcqVj)tGRBR74jd`l^!;d9)(Y$(*jI zH0rl9VZ92F;&oO$8!jW8N_R~cpGGpX+tm*eZCWI&Vv&I@T1j(MDy><}NPdw$W-W73 zJ332%T2Y&)S4xc@@2DX4O3@RgOG?a9;^7I+w@bXvSq77EB3gLsmdt(?%YNbOLSnndKs)Vzm<2-wQTy>~CCf$pp2|7>-e(SN16uxz0 z@SD4iZUXR#9rK=-wEg zV^LPwiXc)ZA4DRiRWRwPt7@r}J6QChoxU+G^7j(pz7CPsqzsJ`oD>FY2qk*?Plm6X z)K5P(2~reWsNjOsr!|{oFnm(!`G!!Nv>u6c2URYmC~#s+q3(~YP;^DStCw}l5wWTj zzi^D~QtZ$$YiLT|pt3_+r>o*@Qrx;(NQ{!usspJDcnT)PTd|>JnY+=i-Int9o-W3+ z_KyfaezkRYfrLxo;7KET(xBT~RR{v{_tY9SE~r8|YYVBaw^gT1G&WW#?_)9p+QdK^ zRxOo5G_WA7#v!ta#B4#rtIMc5XQo7%uE&aA^@2vqSAKHcVGtPl9{BKRN52}c7+&@s zBz?-Ppkar<>LV)yb8f}6BBM(@G)4*GclqF}XGNIB`H8zh$c7!9%Ybvk6IOuI=Z+_v zjO`R3d9-LiE9q+;i;Vx^4dW{1;HA&c1skH06a+M5EO&ttGSTPWV45NZl?nx#1C!W+ zlq6LmAL`HqXpSkwY1xTT*Yv9yDv^gcEO%^nd%6#$B5sX+38zAqVmxI| zB(ltLhso%(g5j`smq6L*Nv&BxSS5%2c=gcgxKevMLt(MciW@1-ha^vne0ensagp*l zLnzTzI&KtPk7~=4Ymmk8T=+&|Jy%^{7)eSQe6E;#nYO1aOI7xT3Jxg8@{CBsN9o>C zZ{0*81BmUtJufY`vm1D(vPG&@BIOB-3#%3ldwYW9(KU^-`(L zpcIWf=dSWBmAY6=)qF7C_H`Lw1VaOj$w60$G_os$zcWyTJuPR(;O`& z7E-{pE-4*MvSi>+L8*9@AEXo_MVG+!DVQTwHcShlq^i}lsVK4nC{qmn$d6^d@A4~Kp!Vy!f$JqX(6s>;>h$Ek))sgHQ9VLGW+PPw z6uY)S3p$f2MOV}PRc7cP3ZUold!tgmgA=Gl5*+bHSwg9l$|96q9<`UrqG1X`UpIps z3Yi+?#WafAx$x9Z$xLSyFZ2DNCWAD{py2Uo2yL93dzYJ+uSu*sm~GS;tfS>DGiz(g zkT`#>ghslY%J}iD$yF$kgh^Kv%_1@(EZQV#!7_c7+uYTu7BOeo%`!wOCsgrDI*W+G zsHx?2g`#qzN+De$U}S2A99xUw9e4JIJYG|?H`;eG97zjG1;5HL0G*|3)_V+}5v}~o z;v~nKLj=1W+PL)P5i0nJWowiBqC+wQ(agoEn#XuQOr!*qD@pmAz9tFj7Nn@e7u{Wx zKorq#mtEM&xtX5l~E;;isyCK0X51eeU;lJ_}7t{=q6cRYRIY>PE?zL z)E*J7OaquGHWtV|d}E+`i(H$=EE57t;;+LZOYcK@7Mf_aTOp(%YwM2j*YA6}yjl9O z?(?83^rwgtb%)5$@-=_{@$l>$qpnxpZC&-;`zu~;eylI?-aj6neRIV_`cCcwF-y z4@a72P8)P(X!3q%@wf8}-9*&a4lue|bMa<|t~DDgC1*+iLyA`_7*}q}CC*`}^@~Kw z%A93KS;<$DPcz!}K6R+J5cT=^1LqwLhjJ8TS6LZ*rmf_MtaXMIKVVTTrx4Q^mGwVs zEkcp#-d?`m1tlruOirZp=UD8b?1X9Noj?a7@*lHTD0w<#30wEw)wM9SF?R4(&Q zJ|PwV0WafDLp`u&R1 z$OX60cl4(huA@Um&7SHMI~95%ZWWVc3Wgg+vLKu+jX#Dhv>_Pe{V+jLdpvNU{l&!? z$yL=rtKW0y$o1LO^dbRKTqJv?>jtz}4(@v+@C}i=!nn<%(Q9f_S(nJlceg9sA;YB* z%F{7Sy+AQ}Tfls7+7L?}9_`Ku%(@UTw#$~Lnt1hOy)7ZD$dubbQW+~%Ve0r%=z5&# zLJiM;op(u@tNfY~<9RDl>Me`aYL*LgNkEPs)n-~P2w|^fqKYA|)6k))o-mTHdnRw^ zw~>k{VFgbuP488jSO=pBNK4+6S%PG4%)&}=$!Z2f9W`4OITQ%h)O&B6_oCLo!JbnI z8NnGHrtbJmYG(`YEy0!eK|9<|!I!Y0H$zx%!pBJxJjzw6fbAPOQj?=#k5ln1x)z;i@U)n~+UV`Yr}CJ~>!7q8!cf z^g3eiK<~$9NiG_iL_}-7L$84$m0V4v50$QU-Wv~!7q-fhhBhw5OPpHOcPo|KEZ6^` zay$RKUgfq_H8oOYyb}K)zeUqkYZoas(@69WZEDM2xTQ*{Y?0i`8X_fox?^SRF2i?v zt=)Q_cJoEtaR-s0PiD+J4~pbQ0#%r|;Yn#%y!wb6$koa9obPisL68?`YSIN9p%&Tb zRYla8oUmd_okTh#6@|5dAR3P=Eo6KmTJbPEXDs3Y{1KnD$6M8QIeDHaJRuXvwn7{x z3iZo`_G#uhqdwPgIw#S7n$5}V{3L9C8t+;frTaf}PbEHS*?*x51J4+W)KbugI28B}LdVp9&$4yEx#5lQ1v-> z(glIXdnXc!3VmKJ^ox~xNM}9TfWju&Jfm+kD<)4Mp=W~16V(G4zvrABd~L=mce zh1_~&0w#dHCk3PDc#aW~_?VjkSssP>Hy)}kwMB_fsyo4yo@3!@-wxBCjrrV}V+83! z<^&6=^#W^stc;mD+KgRPJDDW$k#!mx+u6oGJ|U*6s!yhJJzHk*ri~*r1?A9}ut~*Q z9(92U4SqBleA}-mYE^IIw?-L^vNe_bp;jZv;+VtuLx(3U&+-n9Yfh|nJ;H0Z_Lp$VZDr*v{hiidKqZGfjs06Wo05qH^HAvT>V?&T|S_=`2EQn7^ zi8CD_BQvv3M};^`h(_5~>j-jbdRz+Z`#fd#Jyi-PBhdZhA9Tmz*121zz^dQ9dX_ZZ zQd*!yeOgsy99h^>BT?a}2&JRWm zPRU=5XFLmBVe^qDUCSnVVe=)Z`&xK82&)t_@T|17*~`%mv<>np?#ab9 zS(GaZ8Z$4*fpeXCI)!n#DDD1Eo)3kiJpF=42SKYl2A4d|U`swnj!&>wn(Z+mFc`#9 zpQyTkdkY}G!R(Ibkz6f#mA9|&HZOj9t22yuo9#C*p51MpJpcYVAGTh+{()F-e6~j{ zs#I$MvImp}h}UYHoc$1&lIG?^r1G9RSm{WmJ;seEJC+gk&&Tp%@f zEpP!NzSWaj5D{pZ+WXQ3tQcxxGi-i0R_o=(ry+D*-tsodF2c4n_+7jwuUYknaziPx zgQT3x;Yj93*8lecXF3~%)JE|)yV$UoiV(}_OEJ9uUaxzEb@br=&|id&aGeUXV~Mo2 zryQ{Z#>|@M&SV4;ka6ee9K;4o`hBx>z>R3X!$))SZ2aO5!X%Ln@jjdVO6skg1!Mb6 zkCbWXO?^)BGdPjLzbjMuN|PvW>_GV{Va?#Hfp~>NV6g)1trw++i*zXNKcxae%D?q} zn1RAC85P7DoTLJ#68^9B(}{jcNIJAy4`Snqhrd>z4}H!#8q94$v4V)?dNyH#KNIAN zn)=)KVl!C%-n8UvhQyYa_EM-!i8I+CYAGIkWl}S8MD^{t*nH0#!d;;2!xzPwNOY0kR(Old?;8&;C>y#l)8SdwBb zIF61_k49uvi6kqVS9SKMt|YLfi$i0Vvl;x!mE+c^Dl6`I4~R%K6bN<8kZgrnC^g zA2lMi{i-aKt(4mkxdI86=Dvr8^R89}5%v{Bx05ViPzjYTJ#)9YOCd_A(>smX3vVFK z;l{8A3#+GNgQ_S{$~fjIZKq{FkE6d*akyloV!5&GiJmEn_?uye4J!YLgrGz4QgRKX-PT>+d zvX}NMsKgdK#evSWw1p9{B?eTjY5f1IJgrfLHvYJ{F{>RE2)!Aq}C{_1v!26eaG@n50&NmR&7zh06R#`~QI( zj~qn@jivBw@VWkqOGy*<(C3H^+*amPVf5b>KW1#V*vAe=RW%iFMk z{w+G9jF;UNC8~SXm=6zH`cFuBOQnEmhr1K96UF}(!JMQgMNEx?wB`t#A&XuB!7Bql zH6Tz#2QlHOA!X6kT|}jG)n8UDStpP#WdW3)rD56N>ypjy+zsUo%#6bHlVXcDLKK_B zp6C(B!nqBsE#@n@B>UQwXgmWQSk+-)RkM*3Yu>$G-g>+J{5kTXO3-S2C4j~Rrc3*( z&~NM2+vm-{ZmeuB4<9|ePY0M`?Jk0fZ+_g~;hL=a=do>{Sn1*NE>1ylhb4MS-S+k- zwtv`qQ{QZw_T3i65@I$>*;rwXEefu9xYGml?sfPZ3G50$HNwNMB{4g123v!bmBIgV zAY4|edGX`t;K&#`Qmk-Bg7ddNoE{WStRVP%8KMpuj#Q<>6{v@IHCWR)kNV?m@4TpQ z^1~G`+eXgVt1E=819xBa&s_>{3?n!2^|~ z(OdejFXZ_g{xMc@LM{n1{Hw1X3y{qsIN6#hSauHXwNEQHZIiQm6YbjN^Kw^@+#-jA@gH? z0cBEIRvLDDS*UDZQD!=%C{yV-C#XwH5OWoVyxmJqKOu5aCiLzY)0CS$RMR=91<_m9 zVEchBH6={-ywa-R*>TLfQL2!@(7{=`q~60XW#4G{Mf3JGzzl=JAbPNUiomCU#Y+75+#yMQLNhkOqB}J>kJpRwh;{H7S>ikF@}@vYkJVo1e8b zzcfQ)1BU&b3|T`k;2Fq>?L7V0oro@A31+%0;@LEK?M??^|NdsNJEq? z+Iar<$7Lh*@Zr5j%R|iHI-Trvgx@7xBm-)<-3= zJ^0VVwxySr!V_xOq}BUjjq?-$)}d|J&^}#$($-h&=(5UTQa#{Sh#w2+1Q&#cYGRev zPm)D99;OC-4DIcqkD3rl18P^fBzVclEBAn^(h&_Hd#MFGWyK8VME!1Xa|%Lj7n2TE zW%<_gsu^X0Gje9Bl4kjVbjLn2c0vN1Y=s-})ur!vTg-K#FqOwHsn`NbRQ%!TzZPQZ z-^X$)kcYu{{(IYhKk?sB{r9t)o$bD+pLuEIM|S=9p8wwW-(&xMpug=aq@-~X=*PNC zl@#xad4$(QQCg?)0ObFIty2FR%Erq5Ucqt19+g^;Q9820n!BCH4yQ}6wa$OfJ#2q% zNUYP6iAstQ!rQ3(2knXIhyUkO>qH`iN8-V+{qw)+@9G+O9u?#E2VPqB<3IavQiS~G zfB5gmpBnG~_>upszf;>L2W&^UTkTzm>m;f!uaS}LaYl4P$&CO^gHe^J)W}(xen++l zGj_6rH0<_;Ew&3B6XJ%r93X7y$Ey{$awum&o>X1bV;Mr%49g zX;&tmO$fz#6eC*Cz=-s*^~~Wd#l5`SQ>dLZXzr(gylR0VP&MNc)Hqcq6&V3H5nx%X zOTJ}IGzhO=d@c-^TCOCK_t*U^W_zdeNX_Uq`DmGJYhTJ-b=0kLd}o?Ftb8)a zY847QKL18SQzkfzE4s5@u8PO2r)h|gZTqaSx8ZsACn-Xg#T8pbeM?tI=ks1#=EKq> zuF@Tnq77X(5>*MWN$gljIUd*D@D`tcQF~}51&o@1g>uu1S#O+-{$n=R{8vN`nkmPp zK_iZ?EVk2o~PWt5pY~5|GH$VR?h*tXDRwl=G+&$`N%4#KGoPW8^|XetRB=0-@UKLslDZR;@ zOMQRNus1&gD$A`I)!x*7{F6AEcJ^wjQX?wqN(4D6T1eH2 zJGA<$AqW`l%@y5lQKGVj53UN%^y~}Qx3f1GEYM{NuyomQzU94i4FtOqA~(!p)+GJj zQtfhc=b4+!y3R8nvls6DU&Pq(z4k$2Rvk1SMd4#n6I#^dIg3d46e&dW(t2lRR)w^?SZgf(r*TK5{6$zR%oy?z~Sk7eXq#ChA?R$ zYabgMYo1(fNISjlq^K$( z%=Jptc-b>CB=@m;_2Z803~YN=NWO(*(cUx^lNMVG;Vjyc16eEF%Ho?k=~)G?y@g|a z+y3^I?se-2lT@yRA!3xGqSz?+KkQ~*PUeyeXz^4Q2w-x%u7>G3SGZ+Uf@SD$BV_Ag zEY~IO&DzV(EP{*igpvjRFmUxGE-2Q@BKj zjwkLoO$}h^N*#U3{e*&hUq zn!-rpEicQW;kWW0=C0IHoxwu3-@^7%HXR*Zgt~Y#L6$m9wH@9><4t1})&nLIKEHh| zJ?n#^B&vFVZwoh>WvKD)cmX+Hwb!i2p^JCY`Ea(8f>c7)e2pxFoSo2LMx)?fq#YQl zry&)^R&37lB6isiLU}QE?Dk_mdbR*bpswHz-BGd>BuI5e+TTPsL>uGwfK>59%JM(q z+70_{1jyX{i%xDiG7b@H_*6TTm8_G;}#r$P(XNWY(^{8tLZ^ zT?n88e*2<%NI^=Wc7O~8fE5XaQ4T#;m3*FerFIFJ4oZ=%q^B2*$0!eqiumdkw=3k6 zPI{2-EFRKZas^T}$_Rs5IDx>cgGyNkY_qKF*Li!ILy@w3m~WCH%$`j0vnJE` zGj4C8G79NRihEcf@mx1U-R}Np7It?+KR_xIqm;9PPms}fjE>izx_$$ydo&K)>L3`1 z`0$YKMl@g_M{}*<*Sb4ZZXujX3`2i|DcnC_AT>{BQPpcm&&xqxb$4x_c~cIocfQYC zKagM2IfNpfhk;-NcKMaI6GR2Tpr}ro3dGlCswB6)AVjL~m5LhUiV%a*H6fTp^0e%h zvtU-eh%S~@b&-p(zc=`}>Y@a7N{!M>t+W1`5#G&N%qEysT(N)M5iFulcqJ zW9|$mG7~jmCBHV=TV9qA5vTdhMe0#LjN)r(`_|pxyQ_q1_B?WgUa=#F2ENo)*O{I)Q>w+7E zk5R2d^ubQ9)F~(4l^;^hm7CW_$G&;Q+a;z=D((z;MMR}^<=chd%%V}~5l%o!{4lFd z_Y0CshQysQrD?vHqJ}MD{Rf|1ao;SfDMhp@ z^P~%9$%aVq2CUVx+rp^KSQnj?RpbkO$LH#Gy&dsD@$e>t&_HJm>qj!R2xTc#+?{(AdVfPAA)shjx zPmfdA9x!O!0N3gnR!7JMNrLYYyf|0Ce(xTZjlwB16W!D2+Lz@lX7s+nr?XpV+<8?= z31?Bv+$2t1_@$_V$8d`#hEUa*1E_*!P2uVn|1Ql( zj#59fxiDB|%Ro}t{M-!q>?3Ty@S%vLe$O5PTta2%FVrl1AY5Oe%<4mHN8hh?6AMl5g1|89llZm=8m=px=DRKD;N~<0-K|O z)$K7P%q)~<@7;GiDW)2|pE1G6+_^-x_F%Hq++2S@T3hStZ$5_pUf-1dejZ01HH(Tl zL=67!b({e|3JE9$P-kusjH?fDfwYaJ$j=ioAM?vmmsk;?w`96R8plSh*kv3fC}uXB z?o8BVV*sbmKEh~pf+XR^Iouf+rqR05u2SCbqy&<(jy^vW-`g`MauyF8EHf%$SH@_@ zqx>>dNM!4-9ZuAXw`y$BNtS9X(?;V}wXk75wXMv=e8PFU6qTRUh{gE|7pbfM(Fz~D zwNp$|I@LVMHg5DuDN-=oY0j5iBxd9HxMa(Ow7R$*@5W_oYQ*Os%1|I6zSKnIc&3x8 zk;#ye%+)tQi|tKZ=tVgvhK5|mY*=V4K3B@O)Rr36B#kUd6k z9R&`Cw$CkV2QcYoTUeK~HN6)P2Ynhq$49&|2vT^V$-08mpQX|^>8#lIS*<55woCmR z_(R*eX`z#fu(1{bPsqxPZFjpi=hMaLfZcbOgh&aPAU9S7>z{BMKDZu2`#|OtBSJW>1cx5_U z{fCY1t$$cw`{B*gXBJsawG3)miK70S$p{P=A*AS9yH&-q^$Crn@2cTp4GjZ7o<8;tmIB6ytL@^gT2Kn ze+`H08(m||$1d}L^S-X3T)V#v+RGP_z75Xzx<>usJ==5=0}64uRBrCKG&aShvPEfEWN(xI8ZGd6PR2{_C&Th4pX^96_~z?aby)*en$DowH<7b2 zrO<*jBVMn935Z11fplKwh-!u>zftj@0gwBcyPn9FCp_Q(lm%;ken=n#ful40U-RWECumw-plnDE-wy&W^T@7de z-M{D5=JbQMZC}#)r;)KT0!wIq*hTE4gDKTnjSQbyB=6%ioi!x)2xBamZJs+d7+e*y zq#*llXS-S2p1F_~)b=~MXN_61Ul!l8A0NJ(;e^VQ2VZzS6PVtdIh+jQ)Oe zFs*U~O6tY}ByE{LngGK0OH|Ay1Rpmae#H%Fbc7WOiR*{@!Ar}(198OdhrE6=Q1-)k zd~wY6>&NWQT`&99M0KP4+Gf^*h&KF*sl?B`mxr=>5yM6d$qyG^$VbaR-vEJKd_OGH zQ~I&5tvCO4KE=&@*mhL#VC&`0I@n;DUf%|wp8|tQ%kp&o>*1FD^m2c=Wrkb6IM_yc z{c$^=r83FiDQ;wb!zh$#4;_yPBx)eZA|cHJyo>56biH#7MU#L6v#?+|1V2 zzV?4a=j$6^-+RP=l?<_-IReSOm$RvBdUwvFw)>~?e#?Ia5&uhtFbydD@U!{E|Gpia z#lPp%_NBsZekn#^!ex*}`I&*}t)fpAw=0I5*XJ3tyvnfW^ZLPlbqgdIAVD$wKaFC7 z&&E;C{&F-oE?cMb_N9v>zf6Q-1wZ^x=g0BV`Qi01y&aR)g-So}1yykK{rSmwkC)0U z!|dDUX@|J>4zz;D3|ugT#W9hY)+zn=GBb=6O5U4jI0&|Up>SniP zzTZY*UQklPFLAM-q1+Lm`MVe|A;)h^i34Bwi()djC1 z4_e^gaDQmzZ8d_S*o?^l*P0KUpqdtJ7mgep^B|k%dB|jS%HcSY+SIfTbB)lMiF%@*J*u9rMnx_L*GRwV%7{ za&8=d>4!LSjq-LlFfMEH&p>65-@}} zY&tAp53)T{#!R@eLmk(&!^L%-(Fw5vF^rOmqs53Sr?Ovws&F~%=>=l~ZlQ-SuN^)( zx}ImvcvfN8@%T5LA7pp3y(2Z4p?we5usYDP@q^Bwt*@=GXTx&Zi5^WS(gL`aY_7AA zQNYxhA^z!w+pK;4L4QhG2IH-zuM%6L1gZ?y*_$KixtNPbQfN)Z(xADF zX)vPpqTO>NzZY_yq>f1VeCriQ0n6e_$)d<&ItHXBnw@np9|-2-0GXP+cI*yvMawMZ z>gTiwnCr^6IOi3NW)HCP{(R*PoO=zxNE*e_|+G|ZZT0bD%`w*id^ ztlBRb;+CULqXch2jw%_u5aL3`Zf*ue@dA*dkYs#b zw#HR96*szxL*kZD;6H!5^Q;}jc=z0$pEn*xSF4{lvxfsFlsxmxNn9i>3Ypx-ueuAQ zq1H%G9Gp>R8n=mc58#eeCx*ioPYu4Dt3+m60^?8MaCsoGn@c;f!&vK z_&KL`h=yCNgzxv3vL+RJ(3{TnhgKB_95-RD;M!74=@Uj75hKDmva!HA;0PdS7j8%> z*a1a)Hjnu#EYF3ElIObN8ZsQ!SC(IX5nUy*iI~*`DIhUWollXEcT@ByMUljx$0!3O ze3~eQkXV??CE2$>;R;UR?TbXEJ9b=%sJwwK#wbYG#gL8)!h1_FfgG*;_ zggI(L8*64&?0&QUf? z#gT6V8L^ig)sN088cNA4swctF3%IdzuW&m5YE!QG)ye-XzANt{XUR~JqC#WUZM^88 z9S*+yEAtO3%tN|r6Q4he0-Yno*vcFUf|@z#B&KC8#|qs~wG?e8CTYs7J@t~Ens#mi zgtCz4hYjSVGL{`a^?Q_+wgX^P+*UY^eM&NA9`bd}*bKJ*ZP8Nv^lbSlTF@L* z%QJ?XD;w^+;yLG9U;W&W1}(iX4l7jp3rl#7ufdc!CZeG}ViF4k3Ub>gYCRKvlgiC7 z3Nx!*mgh}kaYK7VGtcXz^&DTDZ#fI5OMHs9sa{l4c?UG>Hq=(R8}yaC2rlSRjLuPE zVY4J-2w6Ip@`MMXP&v7yx18Yv6rblgZ6-OxUO226RWC3VEGCPgboSEiE|qZa@Nbh- z8ojns90DwTNsDy^DLDU;-ZlKhoG!FNxp}_x(YdP5Yx17?2lKu7Uk@JKv6P~&H`W_NrypUy&02#v|FSwak(VO%Q zzx45o+%6K_xEH$u3ZHutY-&KL2n1IyyD}aby|Uk+QXvit)V+MT2acb}bZOwj*{lW` zB!0(gt{nR;S|Hxu*IBj|Uy$^YzW(x8>kiO_mRZ7Y1QW z+J%(RBXwwReUohNm)cj-`Cy`yZ=?#q>pjLDY5|G227f!AkT*>JEsim|^ET4a-GxOu zvIcKs_zM;V)^E=yRHw?TBeobMRy4RyV<};7Rb5f2&hy*`r(tJj7@USFv26rZ3~Qer zpyM98OXX{t4=10hlWT1X%`M8+aC-x*1tYD!m?=|`0@gPJ;zjr}4QSs=wLqR0;Rw5< zSgbn9uj0g|f#mxa%~uO3-Y-1xDth#H?QvIu7pBB_3DvEmPRu(!97A18uv3qFzpO;+oiyQvN(dwyVz+D&>EGu>B{n3gKdj$9_) z47=U)T+6Q!?5^u7C&w$P>0aT+8n-^HfuF+xg<@k0g~EyT$r+{fI%gMqeyt&e&lio# zm;l?qN*B{EdrHr8#8Fjv!P%-;MEB&Ccp^#GZ8K5CH`07Q;h24$h(G#-GJ(KU@5T(q z^D=wr7M2ogLBJLMtscxIbtqy~sD6iQLf)O|EU+)kEG2Rgt`!S^u`#lDbUx)mcx_SC zr?THbo_y&6s9yz$bW+umSN&(&h_-a!dR=1NObSiaR6BMQ#55dyigvlH!L;g$QLE22 zL<=znEPp?4Uv=YuziyK2i3+wnp8r;#IzPvt7arncnO1GX5=XN-zIdh8Wj?)$Gk(qM zsi$_H_8e(lvk`UV^2Q(89WPOch`E!Z)Vk$eH@x@uW?s?3993rQs&ckj3V@u9*iQ8z z8S52pvphslq=Z@?)4uR>#`PuRQTdCkYxMQ+urEqJ1lPGn)Q}z5ayNt?L{_poKQAiR zFDuLzaf4~Gm#XMhs_V65UG{SU+wMGh#$ZymJX_hOD+kQ6YMq3VUP&^=Eio+}d(ojl zn}!}04Hvg7d#XAx7LGMEEqXEvw2Wn=6~u>D=irZpb0+Cdlk+ zZy^?HIwWZ@MZza+KF=H@7` zj&2^fC#xss+HcuJT+GfsLSNY$pUAOxOG)>bikw|2{*Z8Cd5`|pWHXA9L4W3D+|Q>S ze^VrPgdT;}PUHCc5PV*mz(d{+Gw5hDlA(7rvi5aQ$e9f&>r@gFt|n@HDRiz?U7QCT z#ayRIDP4XM4;tor<3`Ot(#fbxqR6+$WJIH)*~OawInipNQ?Wat7ytfnwIix^`WSyM z3gVPs@g0diQ@?p_^}WbbBGaP#$ad+s#Q|>LYT_IF_Qg*&qyp9t6r#zu`_y!=bnaMX zue&!-IAUt>M9O)Y)3uJ`l^B#0b}2!KyiWWhmnEkbeuts}9J-6R5(@XO|7u$!70mOr z-o3RUhnA<+ksI$rJ`u^6I%ztdMOVXC%&J;b!u28w))^pMQp5qqwFM@!7nmIy`xVtV zrJvVHw4~=zBL@;b$d#l_B4*K%hfqXNYfv094_PRqJuL6dpgQz6FBvrZ|L!4ULMkb! z)8~uH-*mddiBMW07*Ov-@U*G-8!!NQ0^KR^7M&99bPT)p)$w#1GG{o6z&{ezXZ1Up zCsHzkBF`Fyi?JxkyZl*4B_rKYR;81Xgvs{Ej!JJz!HG6qE1~WZoD%2v%9?rm$&*U9 zV)b}IdDKG3A_($&a*>w5n{i>E+@7yYIRnu5m;T6x(i@GXz5bab+w~8qS8MWt1~9mG zq{s1#Wv|rF`Jr_?e{mbo>wz1ZO7_?V@;C`Oes7@qjmkDS&r;#E6Z7->dWrtlcR0-$ zZ(hcrzI)*Ts2JXG{r$4Hv^f{aagg?xDB0#0wW;l4$T;!%MPIf5;`J_S51Q$q-*loK*2sWVm}?rnIdOp{glX zkqJ$%P$OkouwvUul3UzbjuiS@BbLw`$e|Ftl%@#uh=@-56N(5*x)L$lozyK|O_Cw1 zph^xB;41 zqX2H2knt?k3g3%La~fo!GLs1D@O5 z2&wflA;3A*L}$^t>?lg(OYM)~UYurP#CXxW1vA-Cf~SafXu0v|8;lX=!(Z(h-N@z? z7crvoO!0IycNroP(P}05q#1T%f%|DwLn8$DEvgqgv0Y5=`D_%HJcyKg)Cna{_U956 zo@evCWj1zsMAnYiw=VP3<-3+Dl%h0YA#ueG>3 z0L@gZCC}u8dOBr)&eoYWvTU_;zGR<+EGi`7aj&8kJ_1H{1|FSHtaToudgp;N`dXOn z@cE(+r33>8f<7Ly$0dI}_Fiic)aa`VJE_vd#rM^6)Ph8^g6L>~WSdXHg2YW< zxprYXKBR@MnW?OU%)K|qm;Ho3;&Z6bLC5(yS?8ax%IxV;{?ymv<3)$1K!|UP!;(bo zIXRK_Ly6+N}FM< z&|QKU=GDnOkJG(nvZ?4tvc2>KLGat=ASf%pjrR}-?<3miH7e2MYJZF3D6|;KZ=~s@ zuXIqjsPZ^n{$PZB*IH|p8O}~a*=P`GuaJ14&X`7(Xs^TjuY(@tAYDo}FxAAU** zwQ78^8(e&z<-RU$&Eln2L0dhyH>{>{N%bLi)Dm`huG<|7!DMJ7Y zZ6T|DJR-e>$J7qiCbd<(5Ecdtk_x_-D|ioIZe&*=TH2J!zm$Rs5zaK7HcQ%#sn$$X zb#FeA(;gHmG1~6!x*T&8oN?34oMI@v-N5NsfDRXAa17?(7we%xwWvgOtrl zTml#LuE7MjP z&T7{e8qropjN2U-7PJJk%WH;VQB?!rEhyt)jLMmcu)fxI$VX9yJ-CvDN>Slt0G+xI zMrh}uS+%szq+N5s*@sf6f`-94hjk36^K9 zo@FD?ciCPzJJ)_!5F0v+s{y7&hu9sMCYrK_^c4x(_$mQ5py@_g&U5tRZLL|{E2WEX zc6GTnWtihd4gA$*sh?(MIh}C<7YkP1pU%C2i0ayUN@HS!=qWKBVXb+b)II;`wN}+t zL`ykJ(Kb8G5GUT{-QA62@Ua_XWP-1(f2_tKwU*Q}Vy8E1_KD?MmSygNO#t`Pnw zN@+st-h|;vSVdW3mbC{eO@Z7w@tZ39%YwPKx~?~?*EKm=yPYl|9q)tnasxW5^To7^ zLs4T{;|0kGJx*flUdDI5dCB(J1iGH}f+z1ECV_Luu5)m2P?lKCuFdN9R?$bfI2j22yt&3^ssuM;)~POS5jH8k96&226td(dXex--S@C2# zUVBMZ*d2kR;ezq8d~YZpXF~IOzB+J_Ls-`V=;&n)uSHqT%VXuTa1KM| zMVjR0DaM^|qO?yA%*SbZ256^&-jU7dGQ3n-sg)|aEa*d0hSAzd6;>;{`T4Y5?~$h4 zw>B{6&O5!4P^)z_UM3Q4(_D0cjyjEaBn|{g|qmg_tWP6%p!IE%gcJBK$BEFCTh4z*&B}YB> zRAv7NwsoeZZ0UB=Bi@2W|K=_8hEmTOfy5{d{B>Z&y}<6iY_me3aDl@_N7kN1%?>eCG99?RxL~*Vyh|<_ao1m7<)L~HX^ORXCN#;N7dp0V`-9n z6_5TGAY3?B@LY)yV61ju|9r})NIG;Kw3?MEeBOQE=D>nyZZ1jZj(>}H(GiRj^~I{q z1zAgFMRWocKdXxRs{AzXj;8delE%k;Y6+^3B8~08coBePd(ZW`KAR*6kr7#(lU`QF zQQu=(lq8m7QNY5Cn%6(R-6?_Snbr~(YVWN%+0P6lzM`7ZVXFlgEb!LmaX3^@UHGEBm23Mnwko>a0hK(O zFKA}s(uJ8JG9rtPiI&U=TDf?vS=Cnx78;aixpC!^o=8>5o(fGkssOCC>m(`4xAXEcX3 zOTW&cM3s^(esGzXrcOoZ|8E`sY4?!-Z1pd6a>vzJ0uen$yp1S(;uUHg2<&(UjX z4|=GOwKixm4EFwfL2k;G1Y3w6Ob$u;dVe$&6E3(XRFm)7vA{rl`aO(|1>u0}AYr<$ zX8LQ8L+VCjx|37k_o@P@nJ&YrOu0YSEkHp8q$`R^_oFE`r*kDC^le>hUcgM} z_>|4gsGbtuVwXC9dp4r?MY&@|C^-~?E$b81Euc7HK@LDt$ENaCV`9DK^SZVqAE7W7 z@#vgdgV-jIC||L4+ExpCSGO4sVizi~`>IYCpPZ5?(}sGW3UU~xlEi^9am^{s;tj^S zz@lDWptZ?i%?yZ5W50FzMVY%4_ja&-#8~y4u-k=0c6c{(0~Wa43URv5qxJ`6VKtaF zB0iRKuST$Sac|-CJhpo#jerk6{L%*V*vKlNS7cGTQ^0bbR zgD1pD*X-|Vt?kTtyHyIZ%q(7&*zQaHa;1Q_d7Pk*SXD=ZSDJK4^65zGbSWhX8c&zs zz4bqPv%O!ZV-|2iaV6z!zmADVe_KAC94;&EHBCcDXbZ{;s%a^iJtBM56IxR@jkv$@ zs71NkLec~?8Tw#U5F(!=N!>!)7~a1R8=aGf)_sBdY)CIb9>a+v6-PAVOp5O6bhYRz z8`0Ua6QhtAhw{4OU8~_&dD3vQ(nP*Q01D4HYMJm&I*?FuaiDd@6^SUfVe{0j2)e2* zf1_brM_*o-?H??+MlAyu)|l)LTZ}%M5X~`$;Zyi!mPBKv zgY$F;UMsn1gHh=Jhyv{A2g@(rwZD9;q`>-SeDjI~$W>q8kIHQW0>B#t6(6KzBn5y{ zl3v6foA=f=v5^j8kLV}`<+FI5HL}MiRtTanMHH1%8#bf#*`tRyQ}V3pVCnzb`HN5!oNfDQwYKSNA4S3RE^JQO+Tv6nJ1sCqyPkt`J#?PHkd(tU zm0KWcd(D){IM6*%d~-6|iWR6;E$~V#OFKPn zF$YTBxWhC^`Q$Q+N}aM_WiBgw82A!muhAa&up;6pmQFn4&t;X2&E@7}GJn~ctrhI8 z>}b{XCe#ckNP1liqiRpq6|$Eb zlW^Wjf=7-{tgR?aT^3hzi!EjccQoTfIWI}fnM2iD#@sR3tcxp;V+-B`+p{x31A+?( z7ErHWtu9-i=W`;;fkqn(H1MU*XlWF zJny^-WJmm|<#ymX>nOuEUUkFI-~Rxa7%n6ak0utNr$YnOnPJ@5!D{W<)JWo z6sW`0>|^%?VI;yX4kTUMW>=%?$GnzF<|wO^*r^fL@p#`n7nBatZ^n+$OKc2*kO+cJ zroPi3dz+MY=QEw{dmUYn4F*-#>?cILtAqiLG3qD7f?(Rf(9h+!JlC&D))H!{K^!4@n#r->Ff5?06RzMEKCwpGof`$@~ z65?CzabA1dK_mxY4W0G3-&GV%vm^z0I`aOH$G1MJdsytMeFyJE6_b!D=%u5fU+K^Z zT4q^$l6QS6cL2%|rzh2@BBfcQO&X5QAiiA;>|AvYgJiDDkg`4}&7CSV4rPOBu~U+q zJ{wc4b@^p`>cdcac*JIJb%az8+1aGdMfIBJ+En&<+?lQ6`l-u*eYI3T=D^1BQ*Y>j zPksM$56Py@%62dcJSqb_+X@%I_053(lyiF?NkDI~iPKrfxX(b|pEA~QqeP|;Q@JSU zaS&=Wwcbk$ZQjLg$=dW&WK^Ul21kjJCtx2=H_0(-x-MvIhMBato~3;9IGMP*uw)>+ z?UT!a9^WmhTjb1t#-=c)TfyCwUoR@dnm(ftX&wjNvJ-10&PLvQDe4N(L-rX_p){*>*Xm?YkoVrDzn;{0uPAB5 z_*Gq<+RhG`Qh0JjDMeNcmD`i@g+qB+UUCn(MbUF5SgAVq2Ok#drExEaO2mQX)KyIT zcsU=cifvOzgN=0}aOsJAbTLyq=+MoVzK#>e#Q_el@IDQ)d)xlo6` z`G}ub$~OYxbo9=Vg%@TBu#?KMI8`T$8ylM>+och_7uRZMhbzH-`Zmkk0+04M8Y9EO zKkN{ubli)k-ZYvEt#jw}l=u2_>8$ll%m~P!9%cndHE#1mrI5m#4R$MJz3doD)hXL+ zC@cUJj#(ylD{V57r$f9KKlH7qkBWj`7-vE#bwkP#F6;&FLVdjvf;|!6{$uJpI=lEj3grw}6L_)(4QE zkR1EXvPT3mPKAW!?j;ZY@$jtNDp-Y~PNW;3{P=(weBa2VD z^P;m)OUhvHJRGOpD9sXm;$9hT7W&clOh{WCs0kGD45DfBbzdd&Z?}Z7(!5n0@oT1# z;_rz>pT)M*CU{MCDS&aRsR5bLieyneTM!9?q*%xg6$MnK5T{o9Or!XN_>A3=V~kO) zVXbP#V3KmRq^BTaP%&-=In#2-rZ}2C%v8^Ig}R9pfFQW)SSo7((9`U2D}hjxkiB$x9bkcIqyB@LCwodid4QCb5Xd0QIfiZ$t(& zRU9i4SCZ>aa?NObHcNM8>F2WTg5w{Bp1Q)pf(>O<=Ft2cJKTR-GPK1V zRg)l+&)e&6(`P5wty>VJMZ8tl8lmo>N=xt@8C`=JwA1~%i?vFhCv5zQzPhpMlY(MM zNfgc-U|HjYCF^5jr-Yq6FzDAM3}}RunIH6|0k!iNBwGv0q;JO8f~Qq9pmu7`wO6Mc zvhy4^T@|Gr-WL7%!tYj@?C#?h>QWwWKg25%?09yh8^4hQovSUrs3Dnhu^`=I6`fLO zf#iX!4r_UPGEU{Df4Wiq)9)x^>xg?&KH9S^nJGWI03hAumS3}mU3{XlsXE&f9+lAH zBKGe?5J`*w+!4%Jk?zo*Z77z`hD8^&1;urcm;1+*l#8J_qoP(>h(&c=#8^URC!_Yy zv=uWT_8>Z~#biUf7-QKx==lXb();tfjeqAcUeRuoHznwOcNv|o?Y)F*%@b?ylXWPw zLy<7M@^~B>4mTiaVX<;ee68f;^=$m-R#Z|&@SkuhfYOk8W;t=zt&H-tbg4uj%(|az z<(E7c#OUyS8atX#Fe&qhx*2S*LTx;qJ2$mPvs3d@bw*TH zw%dX}s1Uw(bwnezD!)NC9ktb!H)vF7EHpDK5^0!Rff3RO^;r^WOqjV$&vPL>5*sFv zZ_4SkLiRw=kSapOGcM-2bq&QWeFU>Ysql1f=(ZRy@+&xkDg(#s+{dR5w=?mumWMH) zb(CzG2QeA%F#`2?TqvbFr}9jY*;vF9R*h>TL% z*kF{O!MI83wW~<4G|~>N2RmGq>C=F6DfiZsLT>QHgNPlx%2b8C{aH|Qpo0z>gA0$Y z8lna;9#_KqDZR@@_2ETc3#G!dT4`>%z!V7+N*>3E2leS{MU=#lOKxt1FMOT zMsBZDh^jzays;VC1(jNZ>2a=8s}hT7k`U32Mk}T-aM*l-Py>TE(6nE?;B;Uyix@$4 z?LXg$ za`%x@J(Nx;ldLG$sMDm_y=ZCyLJHROTuNR$Clu3hbG4>I}h7y*n6CB#8brB7ZY4NlcnRPc^r|c zU2UHSyP*6vvtUyU4}vfYOMNX>_PEKSQ$T5RC#V=igs%9 zB=16g!gs$3z2bG5f5p8CC+t0xRZB;FiG3rA>MaG?kgX_WlQWV&tA&HoI0A!WmP$qw zRa(^MNZ+fiOBz1Fcp|}uyEJY>ZMZce(?+naUbkGHS2RPrchf6B)P@d9P}~&)-p`MX zr&)%>VC5!9Sm_eGN{*d%ZO+Z{?pAGO>c;O7!3Xkk4=`=q=pyG~_;xUUptNPP0nr~$ zI6po;%Km>l#v|Ly5rY`Y9SbDtUTbG3PTrot3~rOr0qNq3cQIVQS?kHGMb%ROa<4@a z-#b|;8Ida5TeJP3hR*8_E0?L)E1hi3GLJIPYKUuCdA_GHB5Tr6>IaMZR&>={3QU3C z{pX!%^*|nM zqPUUC1Y!VD z)G)V=ZPlAzSR{0YdE&i-8+91FrX33*u9<0MRi*X}qbQe1p~YnHp&*~D#U0TH{=ph38aAtH%6+#o0df=$l%3%tP8+emB&-q zFT^ZJ?J%t&#TJ_T#i}W#nZFa&OKy`IU1AzR!|9QdeDRA0=G8*Ki-wEgI7+czn7!?s zmuW=vg)vm|q`ao?Dn&}kj5cCvMOL5Tcm?ko$aMg0m6nKHV>N$LsJmf-;nh}oZoIAV z7B`~(cSW_v#oG~s^DzlMX&O6CkG2nO6VOou(%Slk%jqr+8Iar^!|yF*(q@G9)GKNn z1>zLbi>>J@L39?hISY2p9cDqzNzpE7pWWLbZ-*9u)t|Z0K;3r#6t&}Tv;s7bVI9S~ zz4n)k03ZF6I%w&0%2`V(g_iRzU_pa1gOutJ5~V1M9Z`PjaF2pewx&szun9fs9WEr= z-MpV^Lb*Z8mf`iy$i?f<=@ty*QUWl5i7V)e&t-NOrJ;XhCKmnOyV9+UmC+OR&mUWV z0s+LA{zCmU{NH~QPo}LJ{;YqU0PNkp9s-k0ju-F7f6frTxE{g}jIMgK-U4HSaIk+p z1bkW#%H4o5K{&i&6`Njh!kQt(p_`4*tZ0q;@vY8oZ6U=B;f7WGg_G7>|Cu4&yPgg| ztuJhlH=xWAn4Vx5DPq+d6G|eAn$e>{$5r-ca768d)8RC|YmP{&hN1W#n}tFvOr(wU_PuIr%T2(Q z&OWPB0qMW@hEy7Bq9rv=juM+x7-Ln&I`SEAjByT!;3J`h>B&rGnBhz;r4EzQ^GTTQ z0=2V)Bu*oOYtJ}itc_T1t!Rur7`0U`G`VrnOgQmq=T8#dUeWY({l_0}-CFKW{?q|r zJFW+SoF=tvX9{!&KzG@V0Op;&?Z&^`qr#-M?0NtnFjDyPR^kcC#ZqC&G})vn%WFM;ScB$azGO z<(MkdG-#nBVvHR!_4pj}DH3BY5gtMMECJ&;PeDx4B}0XB&{vQJ6~(&)Xc`sP->QtS zZl>>?Kwt5_`bi7oKjjqf{)MnpXVhaiOiXu=N7CKj7aDYK(I6*kEfoEC`7EuQXlHi>`h%>3n@ z8w}3QpC2A=yekOf`_~G?zpZwZcHIVGeE-nYTw=(7^S)+^eCYjarCIO)xb^i3{}>gt z{rg`({Py9|!%YlE{6D_||Dz}OA8dJj`u+`$&(4GIA3uKhU~>)Q_iu3CY@Nl&G?fSE z<}#N*^zOdK+U}A;yT_YN^jt7+CczmZ*t@0Iq~)^{_`bru$z1ouFh1w!F-Hqf9GcMy zC|sj%Onef^xMYgnkwc`YYV<%W-YLFm(n0$i3K$APAb&o&CzuI)+ zAD+kt@I&z7>QRkgVBku@J>WJhnblyAdLS%H?JX^`Fm(i-cx)MP!guMqj5c93ZU{d% z;Saj}k>TFwr%YOq&GUc#zvTK}>tE~E>tQ7?asN1dtIBTlb&No@IsGEhux`U>y9I{^ z$8fC>4*liNM&=Dyw`I~vJCSSXrx{y39a3zUoy*v0oGp4p5FXKT^MpMEF{A*wa#WI% zW74`|K;H|-iNtH=pW7u&+-YCrRTZ&5cxUx}Hu~jJ_PmNgx33zy)NI<`)gM}#Z6N7L ze=`L*K6&{6{P^g}!>^^+B0MTu@MDDiZxldk%l#E+&V!V{U|ol$FEot~e+RRO&dr&XSYJ0>!wlODp}=tOA-PY!HR zD=tIhxEhSgr{t&C9@%$#&UA6AshZa($#_2AC=#j8)b)A!S#e){Rtqu0kjT%7+4CGTZZp0e(M7ehKK7@ zN#Knf^7sXV2}$UUNptH;0~dj>LKf|z@(mG@=RMx+#~b+}4OiA8#>0Ck%?J&p-pW!SoyVQzZ z6%MZXX5ZpUgyj_(H2M_G`g66bw#Z4eQ_3iFKLqpNVL3Ge*zp>PLf7MSnn~*^`^%5e*Cb;%<4N zoRw#GSeL3DN4qMUH6kgWGEKyh2wx|tO&t8X1YVT*YSq7xBDn~Xeu2ixs$aN z9goVmn1QTTPV?$jk{ptY%S0^#&EI+hBq*I;Xg4^=2N;ukjBKRWaEdgu&j)!^WnP@0 zzndgs$@Nkw$$I%A$p_Y>>v;a24C!x~DO*8h0k4{bqk1d6cm6MY&HthQw?nNe$}xuX z*Ta1#E%&9BJb7LHdZCfgMT=-A&s-l`gTUSSOdJ*p@l~?7x6S#O`S5C3$*kYnoEnp1 z4V7j=4u&b*L%2{1>VC)#&JI3%noVQ=`1>OmLSwmPhFO0}ucxZ}crAbScU$>nKp=bz z_CS7tk~35hVSPdJH4!Igo(`PE3hy~)^s4s?D~@9kB4>$o?=Zr2rW+>6wqq*SJJ0XuFLW_4;%#10FK@DMD<4#0$CEeJSr7WJo;gp16KHjil*d)ORrzc$fK zW6A(1igN6jw(y0xzUQ5!!+D_nm|=>pK&vo{Q8@)EPx_+j)(|zFBcJDEVY|&}r3H!! z@$TQN;&lNUw{_SuQ}G^Q#u4OsQhKk&4vx&)QRuSjJn9Ob7UAS=*&N;SjddfweMB(m z>#T~1P^%YHdB}K4Ek_Z*wL}fLStV-QHkEo}f)h0F$<*kPzDFSm3)E=oj5m!#A_(Tz z$?D)7&Q))GI@{gE6MnrGm8^6FN!n)R7ipRQ6H)iZ?TTOOQe*Og;*)S}^#U%fB5e5) zL63}krB(`Z>#(?iF0Jd!x59MVJi`gC{GlnaAkHl@-8TdUPt13DW2!2IUeZltnw*{&iLd zwYPzvs=>msAXnujL2q$$!Wh+>ijpCY3lT~nLs7m|=|RKMfY8Y^AZ^u(^X3<;eHnRU zE>h57;}`N^NBDSQ!~-wb%n@FZ2>s`7mOs(Wl3R6q#c6FIXW^(&dQuH+_Wt|6-)*$9 z$a7%xXSR9EPF47*UO@&Aif6@xuaB?D5iqrh`%jMVyt+d$U|lpF9h2U+--{@kYL)>H z?qCKDY-b6GI$tCWL6>YBTLMR$kH7RO^srIz% zy@>agBVr039e=G)y_%t?US=0vH1J&b<^9jq%a@stFzZ1S`zg*8K-j{8iP`W^F>vN9QQr`x-e4m+BLP<=C1-{SvA**`C+gd8Fcz=+D8fjttopk8r)Dfc<4DO!;AH=(-QV?Xm|ML;`~j$H2vQh!VP5nCu!tu z|I83>pko`JxP&r8fRJXe2?! zYBL;%m;J9Zgd6HeK=|>j4$O?}m?7N25#OzU+x;fI{>urC3Bth*a`l7Sba%I~<_zHm zwvKM)>FeQWs4@6zlLX+kp+80L$i_q%t>7gmO6UhIt9-7av%i+&d81fQJg|%tDvAA#T zFuF{Z!aaMb<=!X}6%G==2$q@)*>ZO?q?ePwU{e=9kyxWJ2sZi0aWq!^sr_%~9Kwq0 zblK|f?rl+POAw{FF)0sMcwCz?9F#0?~Sm1Ix@dpUls8czG` z_CUp6Z(m;!zeQtK%x|bmxfcB|M&rXhFnGhiqyOb;pUXxKP?1?{aiQfUe|?}Dyc=TH zOk~~t!5Fs|mn~1N{()zIaIhaQQM$U8KyGXDc9lgCxvL5>k=CsKaY`{FV3KyBkHbz`fQ9cG3uZ z%o#lCL#Y5=Az_SaBl!du*|-{7X{ceb0eSd?n6BU&j*lqJ4 zJ!h`B!@kliM#ymag;;?DZ3aY~dhTen-3~aJeelNmM6=h-}MV0Zz99E`_w zo<)lf0XM)(CZNK0SDXj^ihLF{s`JPE@k#3QN`qR|k@G95d*oX;n;$i9Fu@koE? zbx}gocVO;c36t_F6!R5&G$#2(e$-ktPbx9BC&Mz}yd_&Ye&Il0c)~DA-Z$Xg)i+lc zER1Yp{Nc?NL{rgZt@*Pp>!IWISWB5V^j%zOr*kTK z!2#?MrGow$kYKGZsj$s!xMwOko?MOK(^P6&S+HKd?ZnC3$YZBOdKr2UT-(Kz$s!Q?8pM z@8`dUlwE|T3q5}6DMCEZ7*=&ieDEM`|B|4~owv2~OO2=fhS z{qm*w1a1}YmqjW`g^Ht8@}K|McTXhV*}KbaCPS+kYLBEP%mD`=22mu?ll()k+}>TT zGFd*pk4WJ0#Qk@K05*!@2*rzfbAR(g6c)c)egDrRMt*SP6Z?1g!~1 zB|`gm4!FajiPqxrgU!bezoPVTR$&XQBdtDYiVXx0H(}fpj5?gN@xr~$7e14ei{nIT ze5Q?eKHGff^RHGvs2Lr;-~QIYCXt!j{Z(GPO4jee>vNhqmV0xsxvNyzc+I0^e&FEy z`V16D(KI(4Y!aWF0KQ_52AXcMpo6;`l;`GHIEPyE_fl^g&u>tfTN6cP#xrEJzVXTi zojF|om9LD4Eq@Eq>nwS2_wyxEe?3E3Ie!=3Ey~agU$?M(w^i**Nx{l=uGo_(0SWF(yF+* zc8L7lM)%^zhc-Bx2G96VNUQp9x|PyCp$-l=H;J?sWblb#r5Y4)WUIloH2Go^=PxCI z5zQS@57{k^+WF(~?w6ad?cKFvU);hNdvHck;h_UJ1_Ph3zFl8v9D0%>H)3xKqwK*c`M!%Z z*T1}lYxX3YXT9iFs4>@1L{y>`h(6l#O-Td8RjbNV4>sj>4gChu{`RWwfEvH25}GF*6D7p7#STUo69S$; z`{m^P>XKd(U)rXv0wGDAu??z^5~v+)()R%y*ly&@*+zHnHepGFSMOrR!QhjlJA(^bt_dmkY8Df)>5y}+8dDGB928q&)a z!8>sP;<*po+HUmIU{i-!Zi6ya3XS`}#-dG6*HQ(%wpxONbsw|2?Vkz2wZ#$u_+qmy z5GDY7Uz!eE9s|O+)hW98d4h0oZ6Oi}b_N~5r8Agonjsu?8?*S5Jk2Mxj#9gF4Pg9v zhH-5H4hXWe@W{qLGlXjka6tHrf{rc!Ob`waZ=fa3-&^P~h3td_timu#6emfG8UJ-^ z%NA1U&i_S+w?9;Q%3_6=Gu4Uy-qKS7o?!lm)t)}j3kuslG{e!=V-_Unh$kuJ4rvOT zN|lMnY0Pq;E*UHI#f9cqnFJUbPiR$IYD$0OrTF+8R7{Cz=lIGp^As|w(-4* zNAQiL;OZ66^uT+l5sGTCDRkU1H1^?_Rgs>XK)23&Y@b`$GZ)X%9Tth!cYm`!j0Mkm zSZ-o-7CUD83uvUe{e4!ezl2i$1h-0)IOT0AWBWP=9K~AnU+EY`lWCx4?aNv0x=?bP z&3fqlSkNaj;G#O_u$#(mD01mBCiNn+#NJX?%PeRNaT<5%I&}4H?bOs7)A;~l6v$IH zAUrSNEOFpZ{iK|>DsP#{@;5 zsUk{@?QS&LOxkeo+G1#ju+e2RL%6n_IY5Z0ysu`4fMw}FjsG@4SQ@z*!nHcRL-_9N zdn4$DPT#xM$ae@E%@s2a*IM}wLBaWi#0=qv-6Y1Qq%pcE31@<^f5UEmOR;FTQhy^7 zGlXkB4NB7*MB<~)q16X}VEGdaoccHAI-fm~(prGwNwuM$TypKYm>z}FI`n1@m;R%< z1t$=JtIDIC^NnHuZ!?#kXBRyPC_T`j6a$oqQ(VpCzmy7kbw<%letNS4sWG>jFe8+Z zH|HiVL0I=YB;#YKHXReNy@_?{I7ifS+^AnCs;JDD68+OWM1RzTZH7MDUbD;4`@N4M zjO1v+&`51Eb|_gRSBE?rd2e4GkGHGzOqw^UNh4ucXHT6;Bh5N}Y(*wc5&Y&v zBFC~GwP-LdwT_d5ZA(eY5$k?nw0(U!O(fME-CI>+_EscN9!fOPI{$i?O z+)f}BV{?;zwq*{7Cgxula-_9S&RNw&cCDo3CS;K$BG)n_715=E29Pe!Ucc9AaUbkq zGaCQUPj`Gel#xrEjnh|*&Whqqvr)I&UxdW1l~;6I_Zyko^|&#t(@o)S^dX_Kc!keI zoTu-#l>!rny&%+T#sT{gvPX)?yFaL*=R=i=bQ?g?Qo7xW)n+)Vk0{AN$WHi=G?~P8 z{GJ`r173#8%jj}xQf(Z`ku~hHd5=N5Bz%IW9qO9+Jey;KIp)JQtkv65BrkDv!#)|g z@qSD7;k0p)Gi#;RD&I2jEMl45Bd>&B5M@JxUWlItzOxIaE_yFltP~TgY7#?x9*$Om zF#6&UzCLo#-?WA?ZyQi|TjkOZ-7Bw18*Q+Gn4FOReFQnz3? zOu7isB6RFSOQeOo%k4-ht4@S!TOMsJElw12ZONI>AcchX6$HTzCDL5vw8#vaiaSH9 z@>5@My&E?r#c3}rLAM1_?-;FXc+;nO$AU)KE?TqtPfPu0bnQ3kL zg1&^s!4_E_WrT#eqrvE(Z5Wka=S2zuw6$l`{})mNITDXz>;L(Ge1USLj;fGKc5U-l z{eE@9G}cOl|8Q}lttG|PUt`}3C_w@C0y9f3V0lcH9Hj}N>m8plqUCk${>x)cY4oi? zKR)@^XV}%QP*QMuPDTF>_RpP{?qa8TCx3 zUO89CTt|mj#wSie4Q+4Mj^|`t;v6>qA*;$pC05Q|Z|J1cCH9uU&0YqPpYu`XwT@B^d)nPsBZXidW>X7tb z_dnO=SpLhv=jNq>YZLA;Ce(9S--%5IE4#b;6Egw{)y11;zZ{Irm`+k4^QmkS;}3rL zaiueDaxg9#Y&?|G;ff3VYMnq4ARX-Cs8H}2ZwBx1FKn{T{(n;E=r4!1t#?<5-6_AZ zc2^%R^PY+~$8XL_*jc@bFhZ<+cH1g8$|P~L@{CR%PB-DX%kej!^7@QY(T)dqLjoJC zCr4%)CEtE~@|IbOs2fSFF6t`95MF}6_d`5m8fI8>op4q1VD2q4lwa2|@!T8F+z&~I zaZ$P_XZ50r_zJ>^(9*Hom<6C||d#+KKx;Vb>XluJZtO?qpHPBi1oA5V` zMyD(u0wx7c0$HvX>b%fINO#^`zDAo)7=&;thxg0*DIHJV6pm*-KXwCSRfl|@udyxH zA1q3_6}d_ug9$l67WEQNJ8!0CW{W%7d8ixF*r&dbm=&^G&I!rvlx7RPQ4==fRaBlr z@aVB-0O(8l!qB6Gz-kH>sWi3NallWxD)dOjlIN!?U%7OjYhKl{pq5-I`|7q)b*FmVu*XW zHwLGk)4OsTG>a*1ULYwa6L+02lq=HN1q}&@X&cKYe|C(&BsYZp#GNvAf@`|I!R!N2 zchcnW^_Gu@C9~WdzT=RVP2w!dtGOxc22{{E3;FtN@>XnPyEPObcPP%CmUc?(t<}U< z*JcgYXaH^kez2&v``%26cms4KQw% zqxE-g5pcm!H1)Rjz$%R-VNr5>(0%azYk%7!^qmF$a}i!cu`qe4B}qkextKbxJ6Zr% z5OJJsK@K9Z+p2ApYuW>|-dS+kxHxx2lo9{gw)a?GMJMN`rONX0B zvSE_?;C3r6U9eLD0yn0m)7un%F2L%jqU&P37670wXTRU8DkY%X2aDHjR}3s#pdvc3 z@}#5z^S2KV{O`a$H%xplK5x(A|GS966(#*1sABK5$YEfvp@7VE5nxo-UPD}+*EeR> z(j;!HPHjPiMv7Bq3}?>5O$5u6=u;nF$I%q_aqOtRih<2R6*}y~oIjLC^CG0$jEWk( z__KjqRW%!3a8Lw@Ac5_>b|n-#Ww1o)Lo`n4&b47>2)|g1cgu_EM9&Ljw3Jk0R$ZyZ z`WF)+fsnzI!y3Hq70qX7id~wN)+Q#ArI*@D+xADMi4kPFN`+2*XUw8|0oe`uFMh3Q z-tu;lb2T~;<&R_RzLbkCr-=o+TLN)3#_TfZ!Bp;u3|^#bQhc5Jle0h4{JHF>Z@fpZ z8-@n2)!X7+r&S~(p`>tVJ)}-n%%qRGQhjv>lIt&>E%|FNOt#^Q1nH?bLjGR1EWo4- z&!c)U(`bkT++12a-ZaiZw$eYXl%KJA6dK(%3ddW-H_*YhSOS~*66nHVDG%vv0Z>DQ zXAn@|osjf=(D`Ue$Fq>ChK!XkV`6u=jNB3IsZZ0}8qHRree70Wrw=PlO3)~0BzBA} zP+Abj{9^lQ1QqO~xJTSFeUQYuHzUWQrYK6=-B~?UdSt6g%2JD!qALlq9*wz-5mCX< zwaWX`Cu7=wdE8@*Z?-o1WQhY4o_Y>|akQ^L&tcN% zS1uBzhR~`a%i5g6f5z|Jy??3$SLM-H!0g;Y|@l)FLipqM#z@Ll{^`BQ)}%XM#br!Gc6`dtcaAYOF}7!141&6e{(5= z8(i7kzNkh^shtma$;ItaDK6&Zy%g5}VT9?6s+$XAl*CYn8VXE7V)O?3 zf?LQVYm%pnteC8Y^jW3%yhdO#1q+P^MZz9AorynAfJ`k>eWak^nyc}7!R1EO5Q8*} zd}P_FN{2hq9a>htWQH(k$YHfzkz))hH>7=9H0C#_Cqy8m?j461!>=lHNE$EgpRrAk z&suxZB`vnWfOUhI1m!V5tGX_wRrvb_if$k)2 z_vdtQcX+0JKMNJ@Lg>`+keg>Mvc*J&OeAYXbU`Ra6sqV><4Q@&H_{;h=bW*o@z(3{ zXa%K7Ffn{YGR{%V%HPdpLxKITl##OVKX=b&u3geO1%PY5FY(}E?1EKYH zm#-yXd}px9*@{s{^72H%HwUXNqir2B;i3LW&{hr{8OPM&W2i|?hYScV5{T+WD)Eejy$Y@tRkm%zv7oL0trz|y?U#dWd9G3ComZXt;vVTp;-W; zxW`|QSC8e|h^-nOaC$lo@^pFnQd$vV^N}m{udWbrl{=$E5&7dVAVeKx?wKu%dkAAi z^1(}z-H2>hTmS&8Wa~nPKKq~TcD=D;*T;Wax&0o|yZvL&P>ePuUZ%Ig@QsXB<} zVIE&RQ{A(KYLn)q{=PeBt}MY8m_W5^XtCysVIfardPnX~dGYs$thZt_a5%oWT|(RP z5tZhP)|_NrX71~gK?!kSFCte#K|Y=q;b|zU-eNh)HHF0&+wZh9gorCaj~zF(MVNyOZfs!nG~!6jA-YoWk_&0->jMJFBw)1DTDgVj|O+( z+3IIwD?f>ssmlXMRdq`VnD2fY&0P`lZB(g@Qg`V(yO!WGQuRj&mfvTD30G$$BAQon zJ5TVXAc|Rs4o0E2cs#dyN*2Ws6xwGbXT}DDgd8?!)&e5iP+72M(~=m@H1K?xI?=;` z(4Lhm!j}wUO^FA6Q~{@%0JZNqCZ=h^G8it9&KixDR9^{tlA_2YoqlU9Srv&9OmY}j zMW;aWm?<7^IO`d|!3u=9J$#XcQ0STp8@1f}BPvkJkFr=h_`)OjxBLnplyjZ;;#jwo z1Z{Y1q@Vmou4_@SE2p5Km~nFYDt!FOG#hTA&)1xI?N9pBcZ9{?l;;sVTRp2Jj{6!GA|nMoS@j ztynP;1N$CR_AGoG^7pY{zWUxP!kak?^9@7%H#Lote5u z0*B>agqLSMNQhV`Swt0ft)7boRw7NnLe zb%st>2#t`37PcD@xo*W&@{x5=zQburf|IkiO1`RP`i=7}6X-QEN`pw{?ll*~T+{(g z^y``7rp%T*ve>Z>NDnSnQhLum2V$P6rIR@0)&U90P=FuK6(KCZby6v{TiR(W#-y6O z5=|m}P8m22p904)9jQ@u%?5zjtJUL-Ukw5_g?Hm%Og@V55m|v$UbwQ{C5eBwh1MM# zwCj>H20;ludma7wP$$p0A!XbK{i%5+WF$V)Vtgb^zi5;R^%toN6X=>P7j0TKGLBhA z145*en(I9r!j})8&1U6=r^b^D!-|FhADVZ-A9eA-S2ER|JUU8(Zhdxgsw2%_-``u6 zkgJ;^sFNddRhNpeBar?d#-rF@(hK^{o8W#}xjedNwy7jLfUS;e%BmS4I(e?&&osgF zHg;S}f6OL7TE`kS(<;Vc0f|Mb$FPhgNV<>Z&B?zC6*VTP%~n=JxnY?&!s+#UcIoo+ z{JB!nbsp=iBctpSGh0*uZ`x(SJwZF@?Sn*WtWaa-(Dd7An6j98Op(gMZcZ!x0-}*W z&|6`py&9~UIvJx*QWl0^wuq?q`?>WLN?9vmp5s{T4a=~%;&$73 zyRkBl$aROXEPH!hH=}9}3O``UoE_QO80jPgIYf1xr2^Wp7MK)yRHM=f$9q_ATc-4E z@`UoAy_cuevgM;>V5;ixxZn!hfsh4sP9}`{Qx5l1h32QFe3K*i0IvNOh1kEf)!1*9 zq^~yN7KB_NtK+P#| zZeh`8U@?z!O=2?G9|y-B(6mWIdWS8YS_L@Zqeo|?2KvC(@rIsCrQuHnA3)w#Q2Cxm zvX7!a+%bv(QgYtLhUDHGgQjXLchIL?HK*7+CcQDQgk+*Js+kJihwn!|)jaf0Aj(PEu!A zI<~l`@^&^c7Uks#Pq9X7no1pgAo!e?@{#5_gK`f^CHr)dtW+{87> zRDMWNei?Clg>)Y|ix&n%Jw)+XlkMN>{hBz}(^j!LQW8R%c%})cn_LYctrC2>@Y|5KEaaYMVSZ8cLJ!FaYVs*y!uz)UFCDE-u+#O9r+k5fA^X|*i%My&_<3toEAeQ z!dj+nmVOA<8w}GPSpYIWzFsiSSq&5dYF~YK`nVh~OKDR_Z>B$SK}#NVL!E)2Iz+*> zr!hv;N}dQ|fz}~o`MPu*XqfaaHF`>qZUylJ1qq!Kdr8fTDdz7Fm#c16^&H zRrugCQ7Az;dDOLKwwt&q8nmF@J-!7MNZln{25ti`9nECbHgk2**N18dctakDLLW0m zo^bp7t^Ggz;W6L7wo;0h?e@*#TVfj-VB4tFLM(9j(7ijWpGfIdLQ`r-ak)!ewdJ8u z`)-Eo!;?c6tS$SNCEoePOb?vUpit8-pyg-I9nn6v_=wTV`w;TH)=`66r8RB*us#Pa zUR-mahqZm~FE#yTeVeYzz^HuJ(yTzIg(-u_3+JolA&9`){I}eT*j?aKhd_xsjN3$# zf&-?FmeVrDM{qLYdx0_udf_pW?LcIu+y)4Xh$}P#o{8f1TC`NRd#$o}scmJYFuIi- z6TDsOcBc-COuz*qg-UxQbfEAbshN{Y!x6U!NT-?_MCQ{^7OEm%x%k54%Ni5@b>x+G zKr!(<;#2Jc249k1y*y&uX0V`eJ8==$E^uz$Z986q(@X-B=cLh)5Zc?;M=}*)p2>hB z4kF5e7z$@))ekO=G*+V;a>AJ(+KD{~O2y4!L%0Ns73!$%n%3oO?vftUn7FwFbdZ;; z!fVQkVQxr37@@ZO1QO8cXX5PZtSYOy zcPT7r--ZhEZ$kL+kUvfl+TFA|L75(i>O66B=gg3<@KALYPOM35_zCCC*G`Mrbi5%3 z)Qkhz%K4_YRgdV))Ab6z12jeG{LH~6=_i#|Vi*GQ*2Zd7c%)0+OQiql;r*}MDTEJ!Z%WR@{N&V703`m6kyb`uSR{ z80xD~)eo-OXFcY410z zQh~|`nGjOZ?47+EcGQC?@}VGiNei3!$x6Z*^ip2G^E65@ls;f_0C?GL8 z^Jx?IqbK(tJRA*cv^cYJ4Y&|vrSik2WM59sw8ic%Z$xV@TO0L`&n7fNIAn=r_^~V` zJhEVZDJKlKf24*EMVUk$G9&TTG>E%8)$Z+B7DG9x_*#&g($4Oy`KG{?_-#@+cL>*$1(vek=8)PSD>c0q1^TfG|RE4DuvCz zD5!!)^@TgP=kf3XqJE7`;?y?`f%5dC5Q#Cds%Jp;@cs=x1GH0ho^g7fQ4AWNW`1XN z;VJ}$EL$-CKr=&#+PqAOPZ5;rndnJdxu*EJ@a~iLz_|rWYCeH7U#t@c8wKH{)v%8#4P7MhPsE1I0_9$B2{^<{ z{L;+nnG6ilq3bPI`mJFRu32UPCgD_1Qw*|EMv}{;2GRT>4!C8#j_Aud@*tm;f`m-pZEAt8>C32R z`p*k-*586Yi{ng|zl<%x&^gBjDf_a_iY;PulzigwBf6HKyMdPTHZMc-qTN$q7yB&P z9`-s&wG`?sy_>LEe)mF4$C)MNcyyIZj)@9Z*UOM5%SAc;r8cM7@IDje?rO_?cA|Wp zp6w<0ikm!KV@c<=L_ILG-p5@@HyDLe@n_ihPH>ityQ+qQ=k`|3tqa5|*LPpBBkbRz zh`>pk-2^S%iIy|SE?gOn;%>M0g{Roo7%D_=(;1OQ#&C9kbJ@H zbI?_(uxfw1%}qJ#nH>Ao(2qSs&qJ6$FstW5VLG z6PG=x1B-p{V*!=qo5&^Al*Ea_Lq@4RViVAKX4wgD&Z)|m|6{kZt_HJnH%5mdEJw)Z zbW?q5jybWi=wau?;VZI2=?A7-%hF%^Z>50jd5}2u{Nj8ht54Rw%}WB8dWU_Mq(0+7 z1`aiTiMKe)BlQfVQz1~y38jdg)ap-W%Ig#VLvCuorV|DoH4zcbv{sYG{K(v1Y>zB&j1lO!|vxhJ^3DiH^4f zUX?pN^Mg?cd!Jx)ykzZbD|B||-h^*e`X%QUh(QPcT4{y!=Hl>YdVfl6K?$YNMjdl2 zQ3H`Tih1&EPdIZvuJ8e8d5fWOT{m0>+kDMr-G$oBQxvQ6Z^}Wt7zIZqpT@97k8ceo zCwTVRbW@l`&|!&U$9U_7z^~Ia?T8e;6rLW5v3CHp0%ryG+=TzCi&1xA!?r8xHb7{RlV1>)9c+ii;F6SUf{U!_Vj1!cD2# zbZ)ve!=sn&dV*d1NT0xSyFZ>)q?ms+96hVE<$i=itjG1AI63_G#Mc>)W>s$H0x<(h z_DOCO!7(rc)kPg0UBXj$1yC(|K3J-U4B`37#q+B-Ds@3?OiE3p&uDA>=!lRHwnEo{ zF_WyA+9m8Yo8y`YD}f0n%83`U zz4Dy=zFDTpMJMKJ@1R)a={VwyyFpR)0s+;pD8$o(oB3cnn>0r=-uTq;u#D z3B^CFClsu0&7 z(&(iDGG#&;$mxT0snfj!#<;d19S7JmY*VFic~V3lKULOuhBoY{Fl0-UPYJ`kI6yZ_ z_U?w|I{F<-Wscmx<_sf?bnTc)2GS8-ff~m{kmMCwzE?vXIe$mD$Gm+NC2i?X{Fo7kChWN?V*c?Gbju3m& ze+%(yqDN&xb6d$~8KGaRq*;MzZ z79M-Q>NEZbHdwdB1>2h0xi9bBb5(7SZ=WmZs<)!ClAlI~shuhN5t-w=})HiVE1=8+%_xtk6SX>zP9mq(b?UaK&g7itVm`V79w{ZCWnexo20W zr^oz2?;7FPCwLscUcRDn=j|t&kKl8*+>!7uBo06;c?%3C;HqRrBs?fexh~A?%lV5= z%Evc7-Ca-0x9BBQX${a-Re|3ie;x1+vGMmr9>NS|-1PD;`L`FwE1mD@n-6vQl%vRa zTK!JY5rk-8W|nR@loUJFD!s68piKuS9D{x_3* z?3g#ZK!MTZ4i&&=x5e;=-HJw7jW z7pL5X z_EA@I+{{;#9&~gr0rQvrh3;_d-`!&{K)ih$*@y$0@P*_g5sPh}uricbc-N8P7=%G4 zlyWE{E|*fR4T915#=6~SYd{$?%`Lt7-%RjM$$XO7CrtJ)t%1_EBCaipT-bI-M_-;6 z-AO*|;sX_ic4gL>OrouSn0N4vVH`tNs_blh1^VFb!RnSgTA%W`-97~-zPqAqRP^C` zSNIdcp_xetj{&t*MmC|_2QO09+Q&n6IoIl(yuCqIi0!a|$^SkCCX3dJb?z6t3dUkr zYs9c7wj^zTpIh#?m`@xnFJ8qF61`%Ao znDt_MLW8b^*u`Jc=5aL5sBD^Xg7zY-d9aLxZaW|&|*1b zW3~%oOv=IR8rmb@%`{Uhccj`x?-t7Ph0;wWu1}~4bFC6D&^T8pv#MB#8R1K##Kx2>tdgXH4Heij4DTHqY?(=18{W3i zP-57iv=XqJW*)jBlD3om*XED*#gG;q!kukn&XrjOSx`+PjKx`u>4jIIhC$#TX`W~V zuGr#Z;S}Ev5X)(lF*)l8=>Dj7d z8Iu0!@3nyYo@~%#$n~fmJbp1KRB0_W+j;a#DXmlrxevbMUb(OG@xmV1)`%@eS!`ZG zh?j&K9AijmG>a_aGm>iJZk>04Ph8w?8{ri>t_cMaQ4HS;V+%$f*^h7pmiU}6XpkY7 zaLR!k4b($#^(#!Y5ZeM#Q2I6(Pj(@elAHi0kW5b(5M^<=dsSL1vbqC3f-%ya3=tm< zPG%&iAOwRoU1Q$!kQlq-kzX!7YqEs07yKcx&87kbBOUo@8W(OYjm{W1oEdwx*=wx+ z!RYnmAx}C|=ceW{P9iyzMK>BUcb> zi=9n)3N+a&K9eT6K#1^ZWMzd07J(M1Q^P`(EurW|`DzD}&+lkhhV3ZHF^*5Yd0j&P zxLi9)5W@k@v*;74GMMI(rjPO}3w@;dyqxlqodS21(ukDEm+aF^0>3zSoyID&E={x@ zi+Ln+7Xj9XANNfjzGM)aluc+|^)mx5!i#8<_NHOEiW}Ufv;(56%%ymN6rZ#jE>3xU zf`-B}HHK`t7xP%83=G7V3p)Sn9_kU!GCEmLe2K?_WE`Klr%_M?U$$A1b9RDN&tpi7 z*1Yf<(npw_fFf*b$Y}mb_!`{5romo=kGIZ#U=c)NfZdbKHEsnx=_@nWf2a@p1co zFYkPwUE)LHA=<{TccLeXH9G4T^AC z;*`HaF}7uhDdW4%S?S*KNf?XvNDqzAj9J>e4Ebf8OVF=a;r`uyI-NaqPmWpw%LI;S zTO0qLc9J*_qVeyU9oo#T1Tw?><2%7Y)Gt%eVogm!CFUYeAYHobKb3>{<()59ZlWLb zMKslKCdE(AeqsIsDvt&b?gfD%qftz99CvtYVBp*6g4c=Iatg~u$ecn*b4*X!h#T@* zZ%*=8dY|5>N=xvbFR1a!+wg^3e<6HQlAWs89bR~->&~dfq1%zc-uBopNi*vK)Ry=r zFP?Gp5P$0KB}6iYd~<9_@w%$HDqDmYKA3KG5o#k}wRc+`2(d9Eg?e}u?Zuni8t=Fq z5Po)V!sGXUTS?_}rFrAQV0Ud$DD#o{M{2Ftka^s6{(rR|@TYCK zBha|+KVsAK*Kwm}G`7;O&6YNtyq;m(hjg+yy*T`M#r<*}ibiDU)NT(FhC>|UG4ni9 z9c#(-F7{em`*Z?>fRVOqv=UqD;$}o6#q8y1C|1!YMRJKq9ylrXD3$NnKJ72CIeE<0I!v{xA8?lb5Q&h%B&O`8W z>L_2oo^P78P&wNf8%eW>p&V+S7h_KuDL}x5e~lRo34mXG-*7a!uAV;q))3;4GFN{+ zJp5ZEkN588v|EUQ&uh2PmuI40W$w2^FTh3ke>GW(n?)iutwXXGj8t$^29ib7TRRR*zgbMP zu&^K~)c8?(a&vLnVlMHRVd@CC-3SVB>xq<&Lh_5_S68a5w(S}{;rd>4fZ`OdR#!DF z34M%tPNqnKzq9(WpZVQ}NH#m02$2YkZ5Jy%K~l3j=q}Ye*)xEPcX*ybRmL_|qR5V}%%iJAx^~=oPU(FEsapa7 z_m#Al!6Ys(7+%4&a4JFMRbw753ouQ0YNnbp8%TLBUC$>DAzYy0-_I2B;11V=#&4d4 zH_r>q<%H|5_CXJhh+*5FrCGb%v_NyH(hnie#Rh&%k}WI1i7LS z&8k4tkqBED^K(s?vJ*7&hS8{Y#;BQA@Wo#4hj&+ziOPo~oqW;ta9kzC`if zKn_?PCTJ~u=(FR>`NctI)!?E9u1-*)%U%Np|ZaIn=nT+`;N8}%GGsvAd@&>(?LOa?cdzv)q#F z9mIY5gAkl7C}mr5dND(=BHI;Ht;6V>L7jJii@QegK6zoeC?}=UV<-?fB1*(7hhOEh zWWL(&Tvn}O!v19AE@LgY+q%IASPUuAPSh7lcZ&XnSGjsvj=&hHur;nWeU`d@@e8RF z3V533%`#q8QhaglDganKWJV~|Asd;Yl#I9`aRJYC^C*g#E}oAojR89>Akrmpx~sef zCbr+5WDspV?bywPwO6C-Nq{c|A&FDh@(&4O*xA@Xm3iv;Q!(`Z>S<4E?EfzJrzx)D z+$NrkORFztkq| zxVT(3E_X;y+IQ|3Q9o{QL*IAA`o)o>@2gvzd4fjzjuY#>}>$_H;I< zxPL;$#b$%a4&!YYPRp%Mfn~R{!K@i$iimH>8?^XOg%g7jV|BM!EnSNxpGY*K`WU?DJY>P=iqwN;+}`*ymY9#>$r}M04Ue0)AnMY~e^S+g1NJ zdUT*wLefq5UW;6LuNE^^2mb=?lr$Et!;2E6R)EO6%uK0c@+>PK$_;8HiRIJ*Vb^i` zXnF#8B4v@461o9a-%<>0B@`;fZEDMyMT zKOg&Igkrz)wA&&xTzd)I`mkJCKpmFtcF|!+N~vV;;nCU_A~L-rHGt#BXV&F!i=@@s zJSC`dH!zwRXEw(Sj`tuvwA{a3<>}^>5(SP@LE)Tn{)21So8TUR^8Tul-Zx2Z*$RId zE^)^G>{Xmf6~_H<&1nwO&)%Yso|H`qvkHI4zvy|DN7Sl{m_G~iDRw8#2i>q*IQo?R zJq3zQ#jkX7jNfgG2OM}SplDcBSViA(YSu$1!^<28WFS$DpO;u)95W0!j0q>)ojO4x z@%=1RDK^vnioMq3Ru1QWPg)dx1XV=d&M#RlSI*ii)Yul>Q8fmyneg<8sHUzg0>A90 z^9s=}$)r63Z^4=OWGJC085kXMe8Fisd@b`8_j5gey^GXAVJKEl*`45XcF-=a$OS5m z$*Z&^Qx2Csr*M^0k%z62&dkzw&EjbQH6}V7)8>%_O<5TO=|lDk13o^)6Czu3dehnI zRJ4we3{W-|X^9dJ^&CG5yBwMlTWegTJ~P*@iBt|Eg?iinygp1i)CAUf4pgDDwq`k4 zKUO6TD?5~#3yDOrIRIhSX8XGM9l{?6E6xD!-oJv%92cVSMQv^cvkoI zTk4G3L470#$H8k^l!dI^S9u(KAd+5*F?cffDl7t7xpdeUp+HYp%H*Bq4x%+&E<}xn zol=IRpZO{Cx$G;@9_Qx`C{b9_R@0$fLe_=`ekqA0p0J;OZONC`8o2>t0;fa8Yy8b( zHW=E_TtGJ#O;^MrmR|XXfvO9z^Upp0b_oAeMtoqF)E3H8G{#Gt8s46!__lPL6FRVI zHLsl+nUF$zr4cZM;{8>VQTxMj7|2(x;E=X0FdNKk5*L)yqlQa3;F_0t%*YBFBp$H| z%SkAgWevu)K{QYug3jeApH5w`9fnM6X;OBtA@g+X(t2>2RM{@zkH0@^=ZMhOFU~nX zt8eQnVPl!Hgmw)4eD75x@Md)<m*x);2x)h^#5M?VVr(rI6|fZPVU#9h(xB~nmDO} zy)gf}4HJ>F_T>l&V(~^Hdx+YE;-hxtXJFHJuSqFr6Hn>33)|lk7%eo2;^~m>=-IB( zISXsLuVN*swztqW-X~mZI3;IQQ6r~O=xPLv_k+u~ zDU-Ybs&hgm2D*OyoE@X3UrkaNmEW;vvSxZ^IDtC2+IU4Gb_YBi~LR+5h~uDP0Tl2}ihjI9*muWvhfxXYvf-pruPNEo54?}3wY;Isv2-z^JyM#}) zX`eoOkErXdkb6VQjgL4qfQfVK&w-z(iNwj=*30Nd_>hDN&~%Au)=n&OVTjUr6&Yne z25cgvGq2!Ds{RXMBU~BoNB;i7(ZeH@J8QX&aWN1{k9wz#P3CK?_-gz3VR!X44r*#9 z|F=U=)X%3_jau}#*<@8kh00lk-(fy;#ztnUe-ad;jiuIBYTl>ylC7ps$GIbp*p4TX z%+SK-FARcc7>x5=>}mAxM!##F{6&M<;0qf}QyoBVOwmMDSal$2^Ao*H6i7j|#juCw zx^`+4f4+_6D50?iLop)UhRuC6+%KK2`R;r0{qS=e&A}c1znsO>K9@!lb7nv#Xrca~ zyXN$zyJJpF+#-Xp1y@743E$PP$LpV?H$yls`ZLP5eh?XTMhCkqSXWSsB2j!t?oA!_ zSqwFtXtBtEPOPd2WD3jkYYY6I`kF#0wh0|4x|afoza;fLk-a`ISCVln zZD;R_Z~o8$o=}_uRJ?WY`zshPuP(IX>Br(=9_wOMh04Z8d7Bn^4L%b>&mmmi4&XE00Z+@0IB8}mX?oIqQ*|9$I+lx~Y;`zW zF@&Z@Ng)?Xb4SFLu8@2Rc3rgwPxgswbm{_~yJkibO!L2yzf4a?;6v zt>yroN`3e1xo+ydpqZVy)QS{r&jv`vHW-J;^iqD+HE0#eDy*%1Z%*K(EI_s@B9dkn z->iQ-d2{8dR4)}t3?JfTLb4mxpI_)XQn;! z-Z8wtWmbaM-4NINhVj@BC}$l|⁣I0Vg3IyguiqFHEsNDK^QiL6;-NkK$td`takNhL1kg7Z(uhj6HjG?s>2X(hxxp zF5JGG52IjA)-2`$=iGIpBN;artEIiOGuLxs!eYE1_=9o|gK7idBXt5Z=c@8x@6cco zsuB8EouSw#PbUx@>zbyuIl3siFfE&jy3pMIC_+-Dtj(&2qU{e>JPf8s9$x=M2b1CX z>kn5v3@LDv=xnKaSlRR;x6%C0w)yX+Tn%PR+2d>O9El9G^4WeRzan*_O zn+INFN2PcxZKYz>m{nr2y45app3y<}^ey=O+QpwO^DkNylI=W`6~z30?MZpM z24WxckAsBJPe)t@$C&!{Z2I)!s%wdjWQH=RxXlz!SbU#(&*rX-ZlHY2=b1FtQTslK zws8*aW+l}+$;fnh^a|pq3=Ml62iZ&*@f4dC3%??HEQOcnFRk3FGbl7)3aMz38c(F2 z+$Wv9!oohV&B_Y^X^Z@Mg_&~C<;=cyM@6Hasvb$fUB9=)XFAv;%`>(cCa<&5gwfVg zNR~klR#T3U#B~jcb@L`1-W;|x$o9}aX1}m9M^I#w&`CM6U#%J}(k-|tbVQ;a6$~{m z`iNIhI{bv}i;z;4lMt#jbyAREf>BwdRHHIeloH+zGp9(XR7-OF)uhkzlD@1JMX7ut zvN|IDlZY}02sjgo9suSS{4jUrNc<{SzV)R)rDQ+KH+4gqeTFOh2v(v(0&BQo@6 z(IoPu)UxqOz|%)UqQSRElG&1_1@l_Ayhc;ZkhUssP2~3-711Bg-t$kmOFyX%ay!P6 zZk>)AJFnHa-p+ZKZQS&( zhn>QFFs3BrlG7SXpm3QXnBmx7lu#UjOi|>$HSB+4!QcNc!LNO9g8$L?)9-zGc<;{Z zcW+L2{`-?}9<21A|LxQDe|OOM(Le~mzZih%KMf?DpFC4yZ5AOUJddW2>1#bMLXZZ< zm$oH+&yrThKNUXLOdz)eSqNBv(@I?#^>{2oAVN;vrzZ^~)#)*t^lBo5w8dQF7?o=X0Dnzv8IRvy)d>sc}^R3A<5{en!E_A%_mpZNrX4JAhojsFQ@s z>ni!sc+o>06PG5noLvs=pmw+YnjHWt0x>J`aU%4ph|+G_{a@x z9eZO>Fn!wi)quSHV@XLi##8=;S)aemX?kV??rQnJkc6gF@Hw}4s#8g}4r15z6S=~3OI**r+^p3%8DdBrWMY9UIRZ2&EXEN<+Mhx4*R#yf> zZ;(;rX^y*(vzu;$9I><{7a((~pf#>R&t+FGupDYggRqD$-}m@WwP-MVByWvM5znAF zT_6Q?LxA2L)I|}}A)O~UArMB)VmPvERos0vLf@Xtm}5;U(p_^g9{-8k518i!!O~-27UE-7FL}_YPKCx%kY-fI?7+uV zDODqDhq;`wt2uKplGKJ%#-KQMPJVG`ukRk*c6$E&=a|r8mBX{T35tuBkKZe2Nj1>7 ze&@LZ5_djaTiUre7u%zUxk^)6Lm?*bSJKm#*!r<6J*}|#R(AW>@t;hJ1ZDsF_qrK> zQ{!luF*l7;ys|!1)UN^z+zO`NET>FWpQ!CY>UN{ym9_p?)sZ`ZsG*uvCG{15rg&Q! zVFEu~N;DLzKR1>W(QCf&E2~j+m5fbde_FL|b?fBL@tusvwxcyy4Wo)_AdNqpHn{1- zi?X31@cg#YVcOu2C>wUV%FP@UR0VsgHda5Wv|;Z-Dm#zt^~$>c814Yw#o=~Z54E*Q z1(Ru%ugja(6?BDG8RoaJ~%qY~h}*xKEiM5>ztez7_n zI#`bNU%2<%rjV%JDVwsjGalc{pLzwsTbW@UtvYX9X>&W0?_s(_n)&%LIT0Tp2^pvZ ztcx1DA!#?KaIHCa-LFYTaw^RyP)^r`SiL-KKrwaqlB`K;P&qOn!3SuzrEnmJq^Gx8 zTdO9yNpc9v*HN$M{6M zGw&n$+Pc>9mpBNrDkJl1i#!3-fO;RhzYuCCe&-Mr%h$#+A1ww7Kso!NYHf*S0Mc;! z`s=KPGABfRS(XXB07+i7(?>ZKUB>q8N|SygMbX!;b~tA*Nvxebja9>Lu#l$o>4B;0k416r~Lep*(1aw^9{OE zL$bl63fXcBqTQxqq=-x^%8H!JPe1+S^JDqWakcV>+fN^Ai{cOI10Oh)U__Vq9pge7 zrCENp|7lqUe}AHme40)c!zf$iPADYtiZg9e2={aSA&O&CXJ~Ueyz>RK=JK}2;rry8 z#V~_%n89(>)uU*+rq%2og#-wnC}sY(hlCdJ+LA;G2iKW0DFekZ((de84sjSh(Iitl z+cqZY8ZnF8p&M~k4`DS%CMF`)Tis`koyT9NaL?nl;2fNs3_5d$W^xiL=#)6l_poro z>iR7k)mTy?Ax`16UX(ca+H`8W;}%I#Kb3FvVtTRQ1tUH+$b-CgjoL$|B~&IW-9@@e zErP=ZXPX{qZ%QPmoE!r`%;=7v*Y+kmqYA%5M94m4`{*$LI6vj(GS^g-JU z%-haUnz0;R_0H9kcfiLeY7tTo!HZVSQej+B_}0rF;Fb3%orH=D`E!s1oOJX`3bVkY z5K`bg-$GOrxYUFyabZ+2ekyVWk6u0F4rY7*bU~Fw>PSzF9$D;8^>~FUK4cW&tv{0wzCAi*#UyQgQGE>D4MrY~wPoBN z<=zt;cqu{Gg!x9&=!#g0@da(l03mFXy=Q?aX~I| zLJgKA?aj+Fl}-)t{@_q*Kz6uh32PnMSgLVxXktMdb_Q5=*NoRX3S zS!2e!#z$wpq(GRdjx3*P-<*mo#hmjBj9PgFlkKnhB0jQ`rQkUKBr2x{NyAgS+-dMR zH25qQ?|FdYlVSb!LJgW9@GsrO>a#`Xt(goVs1bKL2&3(T6@?CtM31k7DXoRSZ}bP7 zq611W7uLsD-;vjfU?PTDBvtHCt8Z#lc3vp2{!i_3?h+E3aAPeJ9BNE93N^>Z2aNwc zz0T&Vp+z{AOFr0l+YY@>5P8JnHQ zI%@SKBVzOX^S;oauE8{wGR)#cCw+XQGYs?Cx!_jv4uzZHah{)r38P$WCSHp0wj9wL?jQ8W9Zbe2aQ-wH6gp73a+iS(O|dJvsk~ zIH#jSMt@xsbU3N-VG7sapDDSaxKo+BQ}~Mz8LYcofHQh{mr2@qkAx6a_10Qy}tk{|=auIXria>UrVY@1jvsY1071U`dPpMgw@v)muc((4m5~+~+ z-np#Q1v05GopQEK9E{_UYqLr->-ut6|Jt-}tT~mH?*Pb%yd1RSGhN)8KGPV~lyF%6 z_~XydU!9RU@(0r0u6Dvih8+N#M=$VxYp7Y%uxaAsTT5CusM}{5JPa=@CVCnT@m9UZSz&bto znbB;bJMH3EngpQ@h-1(E5e?O^3EOh_(aFmyAIi|U1$7v;Dpa(MNtO5ofWZ}&e2$h` zhsBb%Bzm}A#Q?>j8l(3{Gh%U=((9%*l%Cv+)h)!ch9l_=t#wyMr_n1EG=t1WO0rW+ zH9{=6vQ|6*jY-s#Lj4E+H|PBNy~cHqF28H!)0=wWFVf_rd= zUGD9U^Q7*~W@iy*gV7?;6bMgqlJc{<7^3X12-*Q;=u&rRw!oJ2tRHvuDP-LX&r5K~ zeV}_(B^P6h#7{C7)VYR8+K04h2qQsRr5Oz*lMc;8)j}M-R$N_!?10_eDW8AhOCAA< z>=}~2%+h*-p)GD})+DYl%#2CPDH;;k_QXlhw02yycB6~E$~v`^4$Sfx9NcvTQsRU0 z{cGmepi%H~w2F7@OW*SH>+v(=qrus**cuv36j|`eOW#eVhjI7vj>x9!`BZC}D&)dT8D(EMLt+l>Mxj5R|l z-yvBtI_|zWevzYz;R)`&K~0n15C%HPY<`#4F8In|OGKQ1>ggtq3o{E*>bC?)N5u8e zBtDdKFqNE=dt`KqVR|JR-eNA*&q`Qao9pSQ;CAf1Laui>TH^)r`p?J5Z@qVhBh>9k zP=R>&+Pxk)6D!|3C{=e!diy1NZE-OO4HCysm9+s4TtqID=*?5iS8 zl8FBryKD^!B^*p1&T;-e(1SGi9%*o-po#uBYi?BUnQ+H}{nu6!P^T&T^ zBgBw1+}VbyvPkhzj(02$G$itH<50TQttlQ*%oo>#yGt3cmc@aTng7ako^vnZF}PM1 z>l_>e=Mce$NLN5aJ8Kn<%$9v~YI%=B!k)%w#AZE=V$9L`Ig>yxREjg^M~y-fgt2yj zDnR(fO2w$pjy-11-^{-mM*27sBtcd^D=|y4;TP2!qzWX9>FwqR%-M#MPb(C2P1zq} z2eMQx2_0#d+huC;l*-n8!H@>hnjmso^I%M4OpvN*ecOCqC>qVJ%+}&m%ljCmaNiB% z)9!-RhVL}Ow)zais|!s7KPey~ImAYMgMJ0rXxKu^18ie%p-(1y|Ioc3+&&RgNAm|# zptk!44nU2Pb}!tX8+OlY%}RPn)H*|*CMsei2S-Z>+cK(tc8!L0s-D&fCP5!xD7e-UDU2O**N`e_-vYKu{Cd};OLjx6dzZ6c!aw$EURV3{9Yk5LG=k#qX2{ecL%&Pv81d8S{wuue z7-af5p9Q5!G0XN362Q-)V~0giV%Ynv7R&=NvFI@$c?vx)U!F)`_jo7ts=mh+?PL2#%^j^V1i$i@tNkV)I{hJwu;ehuNWzv6Vti0A{wx5 zt3e~$GjvPE={lUEOmvWUQlw-!&C5|k_dvtmI8b|0Nus75&(N%KrMV$(TSs0Rq?viU z#?}QvaPxJj>`(fK&MW5Cih7o~UjCQ-z(lZv@Pcct4!&Q(&vBY3jE~W&wa$)B%rzO- z85ad%C4Q0{;m~&4K3T?`ifnHZ$G_H6+v>0;Nsvi|MJ8rlQ;LFI86{6U?)PIWTS)Pd zOAxb2wYUq%aCDyLGqR5kLmPv(GZd8!*f!Kqp_{{K1JcO-L14%|?|rUQ?0m~Lqt%9w z7jbU<*jzleC0;6$O-tX3|33FdPMJKUHwu&zFsC-8T4@d#3(ry*YVsz(+%A+V!Brqj z%vC3B83eCOe{Cm|3yag2-!&;x+i(@wyWQ8M_XCF_&OL4^^3km5^}N@5J)cxwY2YeF zQG`&wXTWJ@>8Tf-DSfxvxwq4OifaAz_j^SyzU-xvfr!vh4zL#J4p5mK2!WuktMX|O zm|J+*)saCn{*Hc8DO5vB6qan>&cTR@@MmOW*n1hU|GE95KZ4NjZu#^|lo7EXN+i)F zMd1OA1a0SzHN}#}B(pWSN9*7{S_dB?JQoU~pAPJ>X&_zH(xYf12z1pinCre&YiSq!8Qs*7=%>>6 z&WHq8Z#idoyna)f2NYF7^x-ABGw&3Agu|7&#JIJ_^edt^{13tZ!2Beqp1NJNy=<&Q zLZ3Dx8e}ruA|_+9!3e!oL%f0(46W=eoDa^SgG(p8nxh~!XNmEAhHN4=9CLtmDgVa* zKX!XB`Pv<5WUDaoC}KzSj+6|@{w!(DH8pjjHz!pic{p2hKawNJn%Y##Fbk>?zKxNa z;gO~qe*sfls`x_2D52Vn%|yQ3Yj}iRjWl=o1(NEi7+B#?cRE>`}q7ttbCa(pI5M+wM z`a&e9%ol7=wS_mvy9eVPme8y=i-+-nj}xA99#e>Ne^lBt9v_mR@^M>_lHxGOXI_=6 zte>pD(f@q=_5B}i%K(~(B3-h+`i)Cim;_t`={HwjKYr>fXEhi!(=dt+Eve?AQBJp) zLsA6WK5Mr{VA0oF_x$4Wt3ZX@$xhGTqe!JrJfjx#V$SA;+MA3j)P&9w#8Td5FeOAk z{~5*Na;OGkbY=e;58jJP^IymqD|ZPVq<=G1+td?{(^Bs{NF7p@?a$I?E@6YT?-Vqm zC;)%O?z_@%Fr=kUk9Ym;E5|}pB=_b-f$C61*BS)8j11zNNnf$o-!(@&=0)c4JqGSa`_kn1>7|`uDhD{DQ&T9z$#88zMVn-UHZF9?^$Y@$=3z zb$sub`aAgEB#!xy-q->PKtM#h>Va?EpJ7byPmf;PK)%?OY#z76WH2*s>la)b9h~ce z03#2n5h?`UX>?7LhvNd#_>ta+xFZq*vEE>k{R%)=kNYUtWRdSQ+0%SdJmAoQd%M|_ z#?q}aEx%q5D3XXUuiP*B3O;EQfA%)Nz9PZoB0v4fYXWKPy#}&d;$g{?=>LTc#O0X` zl;p}UuawF$sXF!KH_vCM1g+1~wJY4~IORp*FM%Exoa13&X~ZqTtB4k?=n^712}z`q z4f?8%B1b1i>=2v=kM`oKU|3#}WaIToY{>|tVi6d~Kyae9@X>{(RLhWQ`C#)Hxz5Nq!j{zyhv%p9JM>A~+^&q7}aYw2Nu$3>atm;jWza zYJE&;Q?#a^2X^57w#RacJx#dS#E{CfSFFVUi^X*4A!(E@$wR)2cn}ZKl!g#$Fek>P5&HLpQd`Li=sd(5~o! zot%RHC?V~uEBX>IBhvsn$M2rk>h6!jRnka!uS=kOsY1D~Oq==_QY!KshTRIdk#5tw zVUCLW(Gtj4kJNHx;;U^!Bf^aNmhFdaPgD}-@zywV5-MKukE7zCbvLI*OF-NuTYngE ztB`s8q^UVP;}0Qxug|H{Vs!-1Ww3ET(xv*wLO5aC#0Hzs{CjiWoz?dwJ+nNFt!#X;sV3*R|bBDch8j@LJ17%tC6@1sh^JCbuhbMvIfO zW8^SG=PA%hPR5ML72)2E_kUa+-+6V1GGqv4$WF=tS0Jj~!3cE(w92t=QjvnRw7@m= zvr-4SsG|%~bS{n*4&}q7Lnu#`1%>B0@d$;iOnxEI!<(kjtr%tfo1xoIqDqqoy&dQgdkSkhLEvsd_Qg@<@bd$lPYwIXSAF`dc z_&A6tbC9YeyH{9j^nGLaqmCa2{S`-5E_d{!K&4B#c5$!eMWf}oG3_mKuTqAI&ia@0 zlW4c&l+hWzEKCFBqdM!2ve5C+rEFEg*cf<8i3O{D#m&{2Vzo_LGHZc4GdhSi(H%Z( zBve8O@)mSMiZnu}i4d#s)`@=jX7en`+*7fP*WvNj57$81c(Wj@;y*g&Vbf(Fg6P3q5>Y@F7C?s%w*6bXt86-v8(U5g2X0k zbTY3lIi`L(Py_5JmvarU%8iY6(lNfy#S6vS5>{aJmTU+CF{YoHJE!4D0vmuc^R~9b2rRzxDGdl}f4053gTpGCH48tvpZywEByKImUZMf!hsHvFikswk z=4~8Vwch~Z!BuV{7N?m1!Pa<-ll0c;YV+ROqrvE%^B=mC;n6-lII7O3P3l zaG{2#J&c0^_WLuX$EM$Pb=3%?wBPj5Vb;Na1gqWqKFU6RMF^LB}gh z%g)C%JnY}#UTE3sLy}XWef5%RTe}}4UA0!EjX(!W=N{oCxxz0aHFyOEL)uOqzh;;1 zTMDn_kqg)8oo1VCh2dxo)iLOt5bN5E`r+dv^zvV{kjbmD(}YT4cU{+^KF0!s=j4s! zZ7U3}#RpgE>9pf9`wb?ZLc~brfk+Q#k{^xp=2bLu5oI>QNo3^UXV$oUr$}nl$K@Lm zD~`C`5k-6d@Xq1k2LX_LGK|2i`Pp1iE_N!(*>tmi!YjTuO3)z7@^zCLwz%K^u9Sfk zPA0tBw=BxC6W++$0=ou7q+XG@{%DvP7H8fvBo`jf~8KpH!Wv!8#B2%KT}1DT)7aU9&H{1x(aG zVD?UDvV8q^8m3crixfLdU}Qi;z3~M%cfTT!@5%xht-L?p3L=zbPoV@#hL9$Qy}gz0 z())gE#%-e7v#T;X6aRgbi{ExXs!-Bb{;1<445*K`?^?zO_141=CpB8U6nhpP=IwAq zn=e0c)sU*kcy|A8JQtbn@MKO*7S7Gnejr-HIAsMRQya8WlFZ)?dz<^fxNJ-=X^YZW z_@{XK%+GFa=P6Z7>jTmOSJX)>vSJ*>t9HcmS|Y1;Pb#ko(&zw78>vQQ2{cCN9GXcB zf0>clt)9J(fti?MJAzE~1IJPNzmd2cK zuOx<%fG+Q0HXS))#DaBX))av31vQcAnoMDg10h^i`mEXNDo>*I-Nh`ZiY^Rc0M9`J zl4U}=?qp+U*gyPL^_|(KrE?MEpobikoS+hk<`l&$!anJ~wOijUE?f)OQ|E|1ej^+S zRg>cC+o8xhJ5ASW^x#49Xd1uVvtF4(#bv>Y-OpSPnq5+;l{evxDpeZ7uz{x6AmU!{ z-ad^AM?HbHB~d^AI=n8{(5c3jG84br^`E{f;fTE+E!_YoC!tqv45&`YOaEF=$04jV z&4yG19zNcD+=34f6GXBZ+a)!6erC{GtO&|7<`~JA9;mPnZP91q7*ZNhI|z=%vlrL{ zZCxx!l?<9a&4TtU$z?E`-io5RXU9~xUY2(H2xRz0s#IOj?Oi}q)M&G*1eLO%C=s@0RCW}iXE$BW#lpld8 zld9{fl^eFOOOLm~44SPdZIbuOxe}woX!F<6j9OAt8o>RFlVjVp(6y@V#w_s1>aPh+hXv7_8T=qpQTb0@}Xdk@SZs90UT z=e)}s3Ru{R%!?#LTU0U+kol_7!xTdmwbPsKRn|gRdd*dTzUdPYQZ#2*Z=Mkp@;*MV z8p|ZnsC8X$f+}n?p2~2UD-ru&k12EUe=BcvXZ5FkCIKF8(2#GFo1DdO82RV!3b0|0 zRBJ?C&f1ER3&-#xh9XgTLoQ0v*wuZ_$kTXd&EXMt3|8lr6D8Rd&C6osqIo^|@G-7vD#$qEnB>W3glsOEbBa8|L$)lDRRun*u-;(&1oM} z8$7f5w*IO&4Fwwac%{RL9W|st6J~z{cZCxd7QZo^0hM3Z)4h>Rv2K&77`M1QKqb;Y z!g!J+%%9)iA=stptOUr;DCE3pN9yg>1suxV2SZP_E<@gTJ9Tj8sXF*Nl7-SUNb&2* z3ql$xeh{*BbOcsAZW@el8=1jr`q1~uZ6t3z8GzfD8}=F@h&rp1gw)x!Ip_{lxVpP? zM;mbp&;O6RH|?$SNb-E&Utqq&0UOgJdrXx!yIeMm3tFY>6530RO}7VV)GbgFMX^nh zYA#+1{o&{L|HqQ~Jm*lB@9nuS#^^3dsq3qqvD*d~P;@>0okO1WAGc3BO4D2Mf|DOqP;|9+Cs5lHT(S4EnYx z^uUC6zNaLgOA=H8x)7M}NGRW>bRLw@@I|sf=lgI1l^R3gN0%TcbUHDO&f^9=rzO*6 z4~Umv?B$oijLBW@(J+(|TWPAJ&&K6Isd~6t{x^qlOcrZaTy+ZK_PQk2__J#pZ;qoI zc-i%S#0oe&_Ns$wtqQsJ!&}IPt5Uw>2%jjbDf1t|*i^v<)?2tTc{XF2aR21K=R&ld zM-Uf<8>t6T@GUFZ{bHdw>|EhcMhltE$<^CDlzz4K00dRhffFE&UdG~+fh(nnzm&Op z$$b#U>;^^KJGTxhKHlamAED_IngC0ja%{s1KQq6UDq&8ck57`fzhzbPzm8`?TmBWK zvI~sVO{*4p&HZt8)AB(d$K}PDS#~F5mtp`TvgdC{C*)7k?yG07s9yLeC4LhsWtx(L z`IeH?eYF3Yebc#xrQGq&6Wx`YpWy7IcHw)FR#ue}?#?4+a(?8$V&dHB3hS4IrjRr;(^>rou`Ke>&SdiD&wb7lM357BtSqLeBcUuW< z5)p+E(JBLtC*WxYRi~a6PEJ$kN=}Wh4rWv(hO`U!InI7zQi9%sMa@s12nvg8lk#;L z*R!E#G%|S}z+m94`e0gB_mIQG`{@^Sb3DI3CmEfBeSpUH&ysO{hbg$zZbuhyLPLu| z;*G60`_~uyT)$rB@0oYnZm>;JG8~?*reeT~d`03RNXg>%1x(S*HDB2wxclJ;@#jZj zIJ6U*Hf3EPY?ku)3CGK#HlNxo@e#p2jU6kC22Q4E>HV!7}+c5AGhfHg*G= za9n7YI(8@?o})Y2`T`r~g47N7I-pC%cO~gfzX`?y_Ed?{(?FjN&5I5MZ&+dPCD2Id zx`4j7(}j8(;W)wDk(vrTMP^#jG7)zJr2|Yv?J}ki16=_DPybpQ2tdqN&H8RJg!Mgy4mXlW`U^6S{xVl8c*JSRL!n= zetP-*<~2FC7(FAROPD7>DyQ+9q9Xv^rA*<PqjXG|g?FR!j4di!(%d++>W-(=s59qi{-@E`F{(EIw# z1V^9tM(fk5EylM#h25t5mUwGA=qPl94KBjGb3N4LEM`6D$ENg3&m9aqBmch1yXcvt zhh6v&?4mjFj-Hj^U)(>`G^nI-b+D(%X3JRczfuHZEENoH&RueERj`&C4hdXMgQZsP zJJDJ&lD*H=Ad{t)MkMkPGXPl0GKrc~+E{F0yd;Fi3-L;wZ_bgs>(?~0tEoKE^_2nu zktWpL1gA!GYl;G15~AZ9)=AjZ1}XAxioVhq-#Ny-4MO(^7ZHMUBCaC^bsHjD)fA{j`Uxztt)CE)VzS*LhuNe=?*L!_6H%RVqQ%r#e3o!Xt&e7UgK!z!-HITQ`ReP# zy8b3?+8QDJO|rV3Q~_N_MZI_ZMi-o}v4~Pjb}CM<^ZB=Mm#`S&AowPMN{>NguF<>^ zYK~XZ3D*fthaYfzwc7U4CbwwHNT=b>aj{jZgQIjnRBWh(Z}<>e$Gm1o=Rv_J|K@u{ zN?km_C?*u2FL*FGi1SWfjLY&0CSieS?pv9KJ0c3AMEZrWNm-xrH#QGMu=Hc(zTkYJ zVDfIMB`pJku_^Ba5>c7LIYY&Iz(kWHhbo_Ca|)Y9BOS8(k|V68h19sA7%5y_=!!v< z+K=4Xv&>b@$V$UUwxP(KIffAuFtY21g&{FA@mO+6e4@oeY#d>v*22k(WK<@AuB zMkF;>Hw*O!L@r(sA}tAObogLx;ug8+qo!BgCD2Jk52b%+^pi~qkjV`sqT{^G1sDv;ZBdSNnZ&FcbzS;KjuNXa;^^M;b?;-OiaRR8tTs1s$nfpJ zVg^vxC9_SKyNrCg1U0-moHOG+;k=ENiLhCKzPq{qKmVsWF$h=O5oKwey?un(tqZkE zt0bVwr%pNc>q3{hzMA$c>9_!wd|Qn9;4NhFZN_E4k?au{v_1J#4uJoe2&EEE;}fo< zBCBqvkh(3bQC4@9IaP6<;0`(_lrvg9>})$SSDc<<7^+o z0)wK#q9aHG-*LZ{MZ`>nhB;h3@S5(6A4gs$6G`_%rNZQLJ>%q*#cBCLxfJst?y2XE zx3QKf6ocWQJ7aCu^Z;b_#?vX!@$Q6WvKx*h^bH~^`Mhx9fP{PFg*z>wab5hfm4~C& z7~WES7`nBQRd-p2d^@D`Wt?n|9<+EeqK}u@ZODT``Vngx4gO&pVpV-%U4I-TwUA&2;Qd^GK%#EQ?5fu za@L$gpT4g+*;iQ6K`>d>OB6iHRy~JRr&p^)y1U&hAgu^hTJeXWi=&y`k8=4kwu&go z_(k+su|SYg#fk0G>_H_PQq(l!qSp|+aD^+wM3mxtkzzZ4JAs-}4MnG6 z&a|a^!ZV~YB=QSBKe{4;SQLd!*L|c;4d&G`kBnl3pJywe9HOYt9%Bb0@%m+T z&Xm)3$cc;sp>8K-YmE=1#gb4}*@hm_giYw$Q=A`{T99Y(O;yZoakMEqL#aF!LfDkm zHp)%(wD4lnpW?#R4yp`S%mbl9wrW~3g*<(?*s0Qy6X-xDj?0Hq>wF)jGjZT!vC019 zBuNJ2I+eLwTgCacjgPKdzCm@r|o@nm2`1jBhH9g$8B?fr(L0QOKW zc8nFTLB>HNgW!0%=@MC5rzbHxoyl5Vn-yFYmN+$TJ}GvLFB*^%iWLqR&=|DW$@!fb z;;Az_)gpwnQ<41RBX5?UNGEnIo>8n%kHhQj?&EIhb0%Y|1#rAOlJ84@!#mr1 zee^Tg7a}^1bKUGk|KDC`OvF-e#j)cC2|rZ6qt{=23-&eFp=N{JE$}=mQqc1!q}3cw<6ZwshBt4L5s_E&qm* zO5hXdkw^B~!;kLW^F1!bvdS{MeAU5G&St8i3HZVWRN}|ZQl{6%TQyv9cLWs>_8E3{+A-Oh5*F6E{m}^$6AIb)eKm2q9m8(9(l}hW9I4 zm8K(o)aR#*Q^^FhF8k-hN-S9*R6!qYo!=Yu%?p&YoF;*J`ebVPq|MV@%QiQb_`XGaXwDUFDM8TuQ8V&R< zo>CMKF-Fl?)Q6Uqp^0gd#FpkRW7KcE?6#DVtbsdlR76$O=j0@+i^ZjKLsCo_DI0z& zGREieYJ$=6Qs0m<3ASBB2}dYx0;4a_E>4KOekM^V-LEG>0T0uh!c$BAhGRuT7hZ8D z3D~=$exvjfk8M4!CRe_AS0>xmFct{h_Z%YR)T5W1q$FBw%mI~6X5e{8HH>3xTc?H?!q3F4^pAdcCk!z0MvundR1MBm-Ci!7LqfFRq^{%DA zu`eoz?fZ-+Dy6|}>uA8J*YPwhm~!HZraa#gtG zwh<{!X`|&Fy}7uUhWkeQQR%ToWhwfOZ%Klh5I&$HhGP@w89d@$?xH%CiIDHC6O-YA zy@zHZPAQ4g*`)V*b@B3=2*QVf<8c}K&^%k*#xFxPJLs5XkICWeW!CXn;T`++Hj2nfu=PMr1)vdswd-+dy~~)P^`)@x$DWk zvWZ0|P$dSd(1`I$6(q-pZ!U1JIf;_m>cCyf(sLL>`9F;2DqiK=Y*TG6f=pKP4hk z+@kv;N@4**On`+6*(^dw=%rr~e8OCLQ!JivKo%feb`G*4p-(itX!*&LHt3{u8r!Lp z(sv>PX1?boCCp2~@Boa}5srU1%Fw3uUfggak*o zkc71#wW6SveK7fu_{fCBp(~I6IXQn}#kVuQWLA@n173~T9OU4194OckW0MYGvbMfi zR#j|_o}d_tYBomo*xP8k^k<>^yTw!MFunsL=@#UqhL#V|k>ha?2jEgLq&R7smex1elZ5PeA{vJ_-yLCPPs^m)h@63z}2@I^b@mW0a^i>hh7kkmQ8Cto~mu3H^ZGx zl{UgqTYE#=g2Krvv%``LK$5x2BF)j!(2FLMMXJbmBez#7(oYL&gXY9Zz~(9(3tZ8f zboDY-@7C}R81E@qaWXWU(p!szL8mGy)uyj3oqk2{^SAce zKar8L{0&{Ip5Bhym2{6w*Zd_yY~@0R`iML>`TLY)QLs!+%exe~I8*W4_@Qqf#TStw z-e|GCup^#%s)>d;CD&YFaRlnlrD9U^uJvmnD6xns1Qhh)JW_{?f-}{hhh_S7T+5;L z>|M9S-Gp07ezQfmr`iWj5q+D}W$TW79^fVXxr$AbzmPsaq{bHJ)?U0cTMBZSULoe% z&_o0CQN(KPO-N1kO~O<#UGAEdZ+v;fOmYSk*9nbM2vUKGl6ZvO&DswlOics+_bYQ@ z557P#?N{HT$t&1)*3kvJA>b(b>;5A70eQ_gO!tWUck=`22nMmf0- zhEi_BpLC=eS_)?Y)Ku%(;iVHG!Xe5gSB`QQoq9iLUHh7Dj9~aSFw0~vt{6DU3;$OS zz68xcc#4V0LFM@1er~A2RIs;0(z#O^vJRiC4&E?Uq(j(1E03b$bL&>Sp$}EzAksTi z@-{Cl8H~Is)kw9DQntz!q;<^}7RiiNz;LycRW)Y$4MURX3xB26^lSaw-*Zy&?DQqC z>hX~8hMJ-rajrq=aaXNN#=vN$u|&y%qYC<%yS6TJrXOX8U;VI3K5v0!ifT(7aJ=s- zA6}MO4i_C9DSyzx0dt~;VWJ^qR6mtpP=D}GE^^4|ZuX>&vzJZg{U*>)ZOkiXQd{BL z;rUQBT0Xu}o0bXO;})B4R+gZdo)UxLcWBA#=&`sMsNW1{LIV5Lp83!StvV*cyd#WTB|M3A2F7V$G0*iYCO zF-wB2h-Ju@afDe%H$yp=KT0K(iG%lwbwiiAd!jt1IKK}xAui$w>@^%EB1bcT4y2En z)?Xt%8m^X||%^3 z!OlnjUa(21TPcQkDQYk=B5&@NoDh=NVzqH*M`l962S7V$mUVjZZR$ga;ZF4xoCOCL z`yh+T?*TN*WWq2ApLmhpFI0>`$56GtsiAV5FVgT+&k~Y8QS4LS4Ozi-)FezUdouSi z`_K(zf!_x_4yl{69MFma_{qH*i#Q74XNGJzbwyY!^to^G9!I&wdR}h9b|Obh%(=n; zD(8(`u)X?0%Zk!Wz>Ma6{zz>c6a5(}tjH8!PX!qsF+gtlfr?A3!H}{Zq}8C%kRbw` zNHS`kEIoMEikxDkg~`fush7C`-UQAV|4mBBUa6?PI0djZ7%~9?n&Z_~qO3ax6vkp; z=5%pG-|tWGH=H`%+9NZp^kT6b-{KZi)8A+-r&!utf&i78Q;N~3h>qKT0O>1u9jDX^ z|D^I7*hpJ(ex5K6ZPz5VJ*44Mla0)191KWACrYnsUl#^5CF5p*&6SQ2uY}pj{x*tV zTCk~`mo|=H{Eg`47=&K@O$Yy(f{HsjzWv3~H944~6Kp1xJu(2bkE-44O>!DUh85A> zZW|D3!Lzdns#@Dw7Km%W^+cEDWTSbdLw?~MG@Wt_K0{w*;e?BlpXb;J$dY2UAC8{p zF3^sT2bd;~H|-gEsr$mN5Fkb2xp^~c%S1n1|D^exBK1%u%CV>>o}KMHDmyz6GPCu0 zLs}k08GTK!&^sNZ^~)~H`euqj%*#7VakugKMVPzrKs>xQD$2#URF(U=Op>lYiBnsU ziyp!0ac|gs7T;FlBR1Ig01r6yP$|A;D`xaYtSvh}QWXS*u{(y=UqS%WsFs%$Z0Bp5 zh9j#NM{T5j@!sRAIm*c0Uw5M#FpZ~si;br8w(B~ z$E8kgrPu#c9dJ9vq8#8Gmatbi`cX8-&ac)R(S}^vHI$Hk0zL3#;k-^MOr2p26PnK@qph zzqXu>jku3sInBL8$&`R@a&muWbxZm&A__Ziwt{zKy=*6GhCDNUda+Z+3yaqvEZ(43(O`v`_*%4fA3tu3?jkY4JDO6PzqQWD{_20HF@0mXQXN7$a=9-(cFNM_<9 zdTS$J_6UW;%AumLYdAk??xvmApw2aIlX&)7r*vQX*K<{;MLSFVddFSy)_QBtcMRX zx}Kf6bEk4;?jOHBf#(YnR@m$om%F9WTV>ybzT|(@Amnht-I1Bx(QZ_<+nu%(>tup2 zvIeLl0iEP7^DUK=v)5UPy2wHP_Uzqu{xA}zU^52K5@Aj|RUGczXeIcchVwfTdpKOU z&>>}(4sAoT9U)h6yyP8mQv0_uIzFb`vpPFs>#fK>FuHn&=>Ex8>1Rihig-<`a2p)^ zm=HDM?W0JBdX`#gK(@|xh}Lf#x8VbNZ&6@sMt!V6czp{*q#CTYPP6@iVIi|p*)CwI zu&bdAdErMb)KvjfD5n%ceJRyv9+MBLS1!Fdyg(Qw8yJo4sRZ2R{?Vx9>iLWI? znx5%oKpu;Dep*~4Ep@VM`CnUi!4?Z2A(8mX?@20YP?x`D#e7q^M2{eh;OJ`eG5s%2UT>WtTQ-qdb=cbg#)WL@KRmr{*UrRr-j*fUWpPwIRv*3of4gl-8RJr=q zRmA=rqZG$377^c)Kv0}#uX&KQ;_dp0nQ^H2G>%c5;xkcl7Ex%yk|xJy*4ZfS?;hO9 zu!Lams8VF#+!0DSuZM-!6F49cR%(g?|ENA-L%L7#5YkI+6s|bWYWCHpIilB$bdh;H z-#mCk@k7s1!P_pNwF4tF48aqQG*3JC^F_~7egvP3Qm=ir53y_KB8&d z?jB!*3Js?lYwzFtueGy7=sR(?==lzsUc_ZWQYPvx^T(6y6@~tGdi6KUKO%o;ha&jL z6J|(EuBIbh+pZ5cf8<3RKOGOb@GY$mf^z@jLTCzXC1ci<#hc*lqY8_*RqG&yL*J$x z?;%$4!xU8#MX#%w=kThW{`dI7*g~2ve+;7ehA10#kvx5{bX2Nr-GMW*j0YVz@TRhq zlsM9(<_!Mk1R-ck?Dr=>sfgJ~>T6ThNxt*ZS#WM(ibTtI(DZ(9CT%!KD?&A#bSv|d zJyRs)t-XAvl3*GvK+?SWwuD@NuYo0now+@Jl^d1ZGbtf>dZ=xuku6QW*lcV>hKSv3 zXZG-z5cGJqf35L8eB$?ma$=#^_ETfZkvbR6Rw;Y1e(^AzFqyR!vh3B5MUMkeS;FVw-D9 zM3FQMNv22A04uTf_!cdl9~p`mPt9J;^6rSJoNC2f?E52cM8r_?$#ShO7wTJj>~>UY zX54SUBwrSZ&bH?lZ=}|8Qrea<76V{AAZ!@O!AToufwpNb%P8?osVROp#qS_9{NB!H z@O`}OL2*m-tzqjompl}$TR3Gas|PRgP>TIHl4^#u@BG!*hj?|WB-=-~ic&330@neI zugUqleE zzFoe8A!U(LN0gqUZ!K?gbXazp1Xx?c$@65uAmI?5Xs)~xAuKmFeub{(4IRQt>vw$f zGj@so>tW{SC-DHeC_dZTyzWbtIL8O;p+xOEir@6L`F<)Y1KP_0M42Up+(5x3i0;o{ zjE@(xz1W1TUhfQ*kj1gpx;xghGKQ7$BwVINSH4+-H%3-gQu?QHeaSL3GJf4em9Ofc zZJ~ukDt9z#E&6hpqW7Y!w}*W42by{sM$fL6${f%1NCn5pSXHqDMyDcy$YOkg3FVpv zX4SM8hmo2Lua7>nVBb|!ySG?YSSo%&ZF6Lf$|0XZs(}CDsw9@DLF-gcuS3SdSAbSO z9KXrbXdhNcNoU2=JK)|XwvZSZ_Q)HMP=i^Q-T=>JIX{HSnkZ1pMnsYum~oH(nFxdh zvjaJ^rMHtNBhHDS?1EdYO8Sir;q-uYvZJG$(ycnMlsrB`NF(_aBqV=)|L8>KGAvjX zlKQs>+ZNFdiuu-B7NGPGA6@H0E0F|iMbs^=L@LerhX}uj4mTe*YDk^3@J6;nYc`f{ z#QKW1CWx-5ipJQk^H2eh9&f_0wJ{O`6e{zj5?&1?T(E`8C@M>!YfD550&R7NuWs<@ z5&e9hHz&KiRh|u|X%r;T&=ff*4N1<^4tYi8Rz}EROuss@r}4^)p1J_qPB!8q8)wKQ zrsujr&i=!8NNLM$WMrqo&Ro|YD(1s$rS%n_FC)+nU!9F%WT<;5*)-Bu!HK>3ni{GC zLp+BNXTX}VJ{GJ+xw>SuBu5#mQAu#JI7=zhx!T7%I?MasG6kH?Jx2@4WCkM0ajrM&3s-8 zI2QWspbXVY6QqXBFc~wF_C0;r1`=BE^E|);!YS0~VHGN4o$YHSQ+X^u!zcT?D9B*i z7AGw+&D0G9nZzNi?Yz%aJcUt+zWO9IWv*v$duE=pkPw5R&k&D^FyxkFj^Eg`32ohU zf0cAp=AeRTG2k*KnHpzNPvk7P`3v2+myc$}EV$n+DPV;AxMB#FOKHrfyVM&F8_!PxSj@!s_asI&Z~ng%IH?-KH@BF7iC}e9gt1BV;P?BMt7&yi8_e^z=&I z!OE7pBpktL?4KHV<#2p=#-+b-aUdJvx8I6}Y##HOM5${SI@z-JY621|iS+iv*VZO4 z&f=~;8pI{g7kow7>dFWw1F?;U=5e6mI0ol`Xf-KliyHg5br<#|A7U{Gs+LDDE`A2C z_3oUH>Od)6u^pQzH8D;Qod60utC-vl;*k*@WpHi0$Y^KFm?SfCcDDoJ=>R&<|G>)u zkM2Hr6n}hVwWk5*j|Nvgq&5AB8w6(%V|5IL+8vo8Zm7fYcYFkzKR zKk9Ie2Vu?EFrt!p*xmCVD(F&VzC1yFMLg@>Cs9pH51$b#%sjK#(<>RL{HSfDOdw1Z z+s9h%1S2adHwo>x6B37!@5ADGDUT(r<_(B}b|8fmf{4&!&we| z0D?-3chlq#A`;hjI%I=XLyfCI%GeCLN~YrwI{yirgJKm@D`C*ncInHGvs%rul0zuY zAPtxg9U#Mw@gz`>`0CRSV!kCSTyPeG)as)BjO(9H5wOf#aqw^sTo$%;qVKmk#=$V)nT%xH>8LNB{Tu3>hxGVH?P!`=`wCwW z;;0xbB_{ka^&AS4{EXB4g{KEEl%wzf=-8v`z;b)jdcMPj<2SZb1U=a7;T14zav5j0cTl4fnFlqjL6PO zT0|$Dw;0!K_hI!>SsJf5zLTF%?M;$c}y>)m-hd0CahgizPf@fqvJr$^5^>?WPIM+XqU+=^22b` zinWklFESkuG+JwXV(VT?EhkEw%ah$D)||e#Dj|Js6P7C%?;Nsy)AS`p6jyGoc}11( zTr5M3`}>kBL^76xpQU7sbTH{DW4-JQ;{nNIUT`d2sBS`ihGb%_hb#wMAq$4X?~pMN zh^pN5mE=j<2vAhw%u1&2+&YxQCz{$l_U)r5H7Brz$tRK(SJdQKDA*ryB8uYZEJ7QY zn}^HfT~Ej4`UPJJdx`fbSfRY^ph_S3JNlrvX)roEzNM3^1L5a^sE_miXEb$1KACYS z_1rBQ5sJT7*+)3zc%4KXZf|SPob1P9{2Yih8y_EA#b{2Kwb~BbfkSxnSQZoIMw(<= zEolXrzRe7%;xFC)b*P8X{X$LhXWOxmPkp%^l7m&gA?&`D`p7Hv!CHHku;LyBr@Ny$ z@^3z*1=7{5BOanP>jo1ZzKpBGvCUwl81Er2?nmHas`(brPWV(kEEt0WP`YT9xVK+C z(>^AdRtwYMTN6nLB%$C^P^&W&8)8ovF(kBb;@}rg1xV{42vgvdz-VhONE=5d;fkMqxGXgKCBV2aJ(e8D)@BAzG3?R zT5V?ACDUQmMHWWeO-ULY&XMA&ETz&XdBkQY~;79jD zA*52$+vnGtlN%<5p--mbU8s3Kr_ClnPz3O@GWA}^2$fC=?hntrf`%*_4En~kXa@m6 zR83W{RT$3rkmy3o$!KRlQ!3dx_uv+3NGP29>wUK*K31(A4n%NN=^DzQ`y2|CC_5fz z`)T&#{TMW~_d7l&MR0vVM)(!=-%`y_6+fk4J<_yU)KN58{yE236$*!m))JCY<6T8t zr{dH1-#$bvpoYECKC2}7uy1T2sHgoB!?^xpD4BoU0c!Xns16;fYhG~%`4|=RoM8Xj z=|L(Bw8~NdMjzlZ%1IBLV+Oo49dSlcV2=do6eE1Fv2!U8-{?gCXNP0RAs9{dKGKC5 zAIFD{_JBh7(6yl6>`XF-S>%Hr6vfRO}<+-ef$lIam~HQm-#50NmfX|S7G+oeZyu#<7Y zQXwXdTo zDj~X<^kqR9bXg2xIubAY~s}zGaCBnGuy);|5{JI!`P3 z&ylD?KMD`_vunP9xRO>t zC~pB2?Fz<_&m^~)M!B8hdy!=F6bm+~DpkHGFzz~zOdEPanKV1(<$;|7#`kL@jZ1bY zw5~?GBX$jF%!su=L|#uG-YB~9_QN!93o|xXA0xTSDTSLKJq_kEyLh_9#neN5x-N@W zVF3>@=~S2uAtzULMp!%`2$1JxxyP=_v~? z33s8e+c-05%%&qu8S(DbWYP_U>6+A&3Crl%y=NRdKmAHYkuUXwzQYMM_xV*M6L%^C z`*3gBz`!|tf|^!0wvb9&FH?_%Y8>LcjRC0Btoa7SmS+9`jQ&uZI5aj|{LlJ8vXR=y z(0iza@NdL_osam$ZFTlCP~&cv47)ebDb1s&B#G1%(M1Mc{xGIn_pibhOF5h}bTMa` z$9{aQq4yX3C@1W;gQjszC%uKkZ9JQ%S}uWCYN?Xu9Z+uNSofP@rZP2b80BcnGz}0# z=A@YH;YPH?W`@Q%Yh8YDn`P8od?J=#@$!cY&}p1Bq089A=09JZw|MUG0x~9oiPuc9 zC?Z7%r$gl`qwG6SPHhIP?q{eMU*xC>vr#KbEz!+N6Q09=`<1P=A|q!Y?whi;wy#Foo}0g=Zs(&E zCut#M<7W!(|LI35;kfMxawI|+pSP3G19vcq{_L2KBOzvk-f{-n?V@6J)}KZ&T+7%= z$^bGMfw>@g8!6EY;o%(OQ${>-1})+7Q-)X|`w-XJ9RxapFZqzlla%~=$p<|f^7$a0% zAw}^38c`@4Qth036D#jb3w*~)A_WRO|=xpMw5CoYMQ(( zLDMheflYbMp@-uNxEkL`eY@)dEy4@gYRb!yW3qt3bH%W_-`{;#ao%2JF@{?U<;%~_ z=TLa7`pp=4ii{5;+XA5Rs5V|+hS>&sUSohanYuk-CSP$o}Z<1RVv zel%!dxbW!@Dtj)*&-*$QlzB`oaI!ItA^W{255(Ml4@D|4MJ1~8>)ZS3PIQ4-A@yXE z!qWSSSBXcFLOQyi^t_EGrXi-S7$#Jt_*9)q`D9|P*IjDZZZ8?_v$x0gPG2RTW|k8k zMTE>8_I&Nja`LBZ`W5LRNYQY<-J4f6-=k;lWFJ~~O62H;%FsM7 zj=2h}+cT0l6_>J3w$$53t^lJ{5OHcdy2BkR9h>mu5kRFHXfKIE4=V664-;yaX4cja ztqu_0EYVq%ppwjspN{u4W9FYQ6uz%7Hp6FQF0LyF@*-mapB}^t^I?NjNuxIueC*(O ziHnyAJFCbF&T^ChlsnHXPHO4Zj#4d(+hi0pwV;*V$3WF}D_mhRm|R1kn8%^LV!iZ^ z;`;Ly&jM#3k^H7OaC6$~yamN}zEU2fg1u<|+el}~=6w5sjqK^)L(0Rz6we+E;Ndue zRH~c#+8u}c;2t9&AKZJW|M^JQ@A&7#d-vK>Vuk7KVBhc+EwQ`Yrhe17>;->f=F%P zvHB3tuNPq@8nyb^!rVZc&7Hr{h0Mi8!^m%WEfzjjcapE}AkkdDG+y(A2`N~ew2?5+6q!YcQ2T6M+GDGhR) z+s}jJw6+9LhwxN7Vs>vMN0V}b!bbhX{iHc?YthV%(rf_o45J>X=%Nioj0|PSj-RZn!*-xz z8slXvJSR*k2MpO&xn03sU(cL#OMWgp99Bb^@sO}2E<7eaTDGm7lA9P2cBXEG+%D3T zPm=PgIGpM#`lQ~fy{9c`-LuCf@I-h*yS&|isfww$jgqyPOO{ae)iJRWgb|VLBWu=6K)MPQ~wbaSZ=UO(^Q*XT?y z#eR`bB>?nKK4#L18*Pl_%klmPcbny*B*QCt0Vk+TA*-gBfR5+K3HE1nGi0c~D#>mq zAk>L2Kp;k(==X}eypsp8)hSaz2#I>OpO!cbJayJH1!EWSUc1C@9>KFXF1>f^$ldvX}k&ymrtdudgU}h?ZgLu)LSB!a~}A{|rOT z)YNox^>mKTP?VL6FbrHCaQZtYD(L3xd>Fty<-+ukV`yDBat?{G;lpsnclqN*X$3uF zzdIuqZ~dQ-kKgPcoRN&Ft?Y09Vr3`G&+*zb+VwlwD!hX6%flzr-wEe+(VkuKF_K(Fkes$Qc56IaE8ZoGAkm2`P8~ z|9PPgzSaDQ9&v#nf%O0g16*G`zo1+k0nZgvy0`)u{>5}W_@dQKE;T3^*eN=Kq(#zQ z-a)C&fvIir$vl@>?w5K8Q3-8h?pE6^05u|*2 zxW!uXmvN%WB2v+dvwaJv)YDL29JL*zy~JJ2r!qIniiABb&knPT0gN|wSSziXSSbzR zg5<>uL-7qgS-*3vFmp!z;*jpDW(;`(I|PK&TW%ce2REanbbZthV1>vl%X@H51aqUPW00$|T0-!F}eb99q9as)!Xys?uNkf4}YbJ0&wKqJTC?aNjvWeW#wsjEz96yc+ZT`AGbIm8G!Eh4VxcdN&ri6x;C@@_3j%3~d0hA|PQ@o$p~ zdnIpNQOb6?x3!lDe56cBNBebBk=rgU7jw13{}rD)7v?}w3)H6^^}+7xsvD2QSExrl zt+?W85O>ZEpslxYotGvqjM_>biC56MlrOs-8!3stI>b0v79)3lqGER<8Wzgd#Keqx zx#u1kM zgp4{4nfR%|n07!P=;M*|uh2SwsEXTfrOpR2`^v#)GBiHMA*<|AbGIWeMdeHy_Dty1 zrX%^lh70G#?55c!$-pK2QvIQm@o#n3z@iQ^E& z-n9{_DQmxHZnLmxB;a`J|=W;aA=no2W0 zWlz%qjRk7S)4X~mU()3?m~&mp$8aK` zgSFy?#X6U#fP_}`!_y#3>P&RYX8j!$UXjUbZ)2?sgqLA;KxIkrZJ-A7wxg@Uv6RGH zWXW(A@;>K~N~%?}kT)eKCGliD>g>&Z<&I&uo5-)IRyNUop5i0xCM`M)s}Vrzzs&24 zcn-Ik)gfd8;~@*y6>+o$X}fB=l~0r=ibE44g+bK1y4O=+aDz3dN5_2Z;?U%{L`hB5 z$O1J9g*m?z%+9Xz0VQpl8$4GRS&}n}CQn+UD{diGp))A4aajZkK95UgL z=}ud#xGVt`?FvZgIg3J=vdJI&oKA?SmsGBFsxAf9%FBx^oNJdRb$N_xrilD<^=rnF z*oCb7-Bodv;FVXG0noB@E#oncqB|8_^jp*|aTzr9# zZE>zwYPQx;O1(^8+nEyRu}>$eTlDKY$yM14ZoM&BFh*6TrMBt|tsfV1Q;HQks=pf( zp3`h{Hbae6OMbRz>r-=WbfuXG-Y{P1vTEsF`Bw%p`B?Uu>a)X>>KWL=3RU4gQSGmD zI|(TJwIkr-4(B4o{v1?xn-b6r%RQM%7*;bL!!{O!ZmOl@;oSXKmmaXhmPw~++QWcc!xk1k(FQ5d5Yt+XgUcxd;!Grt3tPH|Xzj^{7xYyi zE`{inw8+&hd14*DrwqC#pqAWi?sTCKUPLs zU*9%E938&^qXde#>HV`6us}!h!iR?WFtb&lY$5dw74>mL3|=a%rwUdnjE`Il69QjR z)L?Hy_nX!G1mB4y>LyT(w*P{%T*OUs)M3E*o?`tDJMTZZdtW%IY!ZC{5%y-+f+N>@ z^^K`>&}4QiPI$C=81^%CS(mI;(t~S>hy)FgZx1yeg#5jJbgcN2Uw#xn35gQx-aXd zK3xoRj62g2cJS@$yL+u!a<5fYq8ZM}^#CfTa6*rVd^&Gld?-t+0Zb9~PKRtD(*et1 zwr@3`7~+KDtR~RdWKhP8YdFYUwD)ABwikHAdwX>NxyvS^QwXA3sF~E?3e>j`50dF7 z_cu{9+yCyHr(QJ;jf|Ksd}kN?P+OGoBzG}p7{FWS6J?8mMCZA6qS-Vx!1+!D_AA1_ ziHo7F@ev@!xn(D-YeMCj%pz8C0lFW2%=TJGMzvwT3pu)!`Ld zuQ|bA%Ja~tt**{p=tQhUMKmFY5vj5gjA?`dTeWk_7a#){IxV?&7u*abVnlt>2~jpA ze7i96QB&m}40EePrJo_sG7DbqN#}mGA1SfQON`@4wGzs1l&B_F8 zcfR=kTbdZr|BBrZKe?g6tsyS#Tyunm04xKB&%gSU_4DsoCTzFXSx9PTY1d+|iB3je zZb=A~qpddM{;hL|-cfXiSIRdeRQwHrDy#UQ4)Oea?bd z^ZH}bm|+jm*y5BGq!hwQuIwQM^Ys#8X}_YFCoPcXrq-28M&Vw)j8PWF!6E5J2k*YP zTd&D`i_?n5)eDN~6zv+{Of|)J-nL*l>ikx&_>`n0qZmfo2!lsWS4Yyxa zI8fwV%a{ko^$qvALWdrX$f0rW^=kn7!7dz?6ZIlPo+jARK$+6s7B-qNSb6iJUf$}0 zk0i(phSZZc-gZVBCgNB#YUHBX`SLQ-;=Hqo0p+`#>>{g>QE8GndKNQc1ce`ub#A47 zWHXad-CFAB8Cq^E$SyYzFm zsg&_ZD5<$Bz8`T6F*#keG9@c_sUn327e& z5$^9d-$uW(zNBuL{O9Ajv++;%YL1AR?fG{zxW1E};7(Ap^HK9fvV0*eYSF}!h-SDB z^&-+FiM;88l0kbptLaO|gILGsFu0nB(5;hVlGhXc@1wE|1%Y!QcbgN$A2Y>VZ$?^| zv;1?Xn*Qw1rV|w^#&C?xB9|2|Vz&qhCjKfek2Y`RBQK~*>IM?zD@@qpH0MFNUP{py zo>)+)CIg*i_0o1hOxZ^AC1(*p!6zSYo?Kokt-?2+svbaOsGML1_|XZw`8>yWbVo#- zmk(;hT2+ho^J1TNm8L^wWxy~MPCHY7Pk0Tn_yf`b_=HX{V-8wWmg)AzG4qKAS zqx3g5vP!T6Q!8>_3qx9cB1D)+rGyQk(7n6)%PNBttpRo`+`>v1#-a++uCw7pidCg;}fbje8E z6V>s-UtuX1k(C)Ts&mEHSfp}(4y55bqG80X#q<-Yic9PSBXkS~IH zPDX?2AQWDgK9`=8WGcLX0Q7>ASI8_ah{PCG|xT?$;dk!Xd4*u7Ymis#`rQ2mVuQstf!-trnPji7v&8;QPVXk4&RTP4v!Xn z()lI@_NxLe*xUX$#|rAnPZ?z*YJ>*gee=cDhDSK^wKzG&+IYAVd;j-dm~b7>+28bd zt<|*KfH8{*Gf(!GeN4FXU?kCZc{~=V>DEtJfpPfk)k!)WMlhCZs0RwCSbUQIthQ-q zgTjz{z6zQVVB35=XCoA^8l}k$y`6q&_A+Y}qQb;*#s^M=?+ph_w2N2gy!0RL^30f> zV~FU4{f@*wx4)joOM>BRxL~&V&ShG=1AkOEnp){n9UP(ugXtyT)#6+tn}-8)!avT< zM}o%|S9w)E4&x1^E)CNc9f1yNYko*Zdujco(-l8)OjHroxh>bxfSl&TT=EgvE}umd z`B_u5X1aHc6XZF&)00=+GsOQnJ*NxS@C;@z?hZ4iUmwfq^SDblIALlC)}xdFlTGlS+5d4D2i}fXLwqUzNrPo5Xy$R4_%mQCMZ)VC_R{es`?5s)I9M2j1Q z_Q+@?SFCe<$K?+?RuDnG6fO}R;o_bjOJ+!PaBi9ud65^a+Q>^G$DHHfP^E8B0=Gqu zbLk_Axk%aj_JcXBMAy!7w&teP!E?K4mbxvo+DRdudJ@794W-@7ELKJ3j>lod{BflX zjUhiye{-Z0D>Z!w4=k#I*D-twG8W=6`=T8Em+uZ!SGk1z$0uJr(d8Jg;h+5FYYoKr zzu}jyD2gT-)owWq=_pUTxW3jKeM$@sg7`pm{Vk9W2ax^o2~M$gCini9T}56g)7}O$ zv}Zb;n8zq4OKe184=t8M8p};&EeSZNvy=XNLl(*TKuc#ye3+IZAE7`swHOIT-C%uS z@lG==cp#t1k}}>tX9HLxMKHv){O`G7e!PG9DlqwSFuA{@K)VpKOoftx!DnwLxN~kd zw?!ziU1(%KWSov;XYhUk2{LVvGSGm*Mb#~{lpNk!S?I0OAA6PtC`5D0hxGOAzj6{v z9ppK59k6fmW-+kTuQNC3NXKm@;%HXfAp^2~%LV}ap&XAG>#Tt@6(bJzFJ@l$Yk?{tlLPltNE{|pJ`4ISt*u%XS%uE zgRn;)$Y%)-5lWYfw^(0gGl{4xj)OJ9E@V_!$Sayon9oDA$NHB^R3NfQx8%$T}*@ z2Wmal07}^I(!mLH=x$7{ zkD-zuuV)K6Cqv@nk5EocM4yY9*Cvy|t!gk?eB< zr{kAL)XeNEtwQ2kT2P- z%HSnL@xHOsnDlI|(S}U`o1&UBR&hJp|K;fk-D4rzG4<5SA~FRDt#|a|;`xnqb@wP8 zveyz9zK0%=LD3VS)-;$8XV6UdEwb2{ct5JP%DObRmSu*|iBsBX!hK6wgqZvnS^zaz zkR>*QJ$N6juk&dda@u;61N}~w%xeQk%V>Eo(7cBLI-l-92dVasaEp{LDi_+bY=Uoq z0|jELbR>rzh)nDPX@Z2=yX4?rdW{$)TB2Lt5eVD7-@vAFCa|L zU~~Y&!6smQ@jz%b&M0FJ&d8nB3Oq?r#C1-kM+%0T@kN*ZRY{E#VRXIyczO~EmfqT( z@B^#h z2quK|XH3c2yCAUMS4gzy4540WvIdCcCo-3F5NO0ZjRbGJ zS`kKDmQ-cQH}Sx#qA4K)54oxpyZ7G${y#Q% z{A$Q%?{^?V|6c2!ZB!PYrJGOZ_O{Qzw|SrSKiyNdo>oNF!Ups>5XP?p#5FZNaUKnJ|H`D;>5Ow6QO zX0Gz8hW3w-bV;2LT;Y~tsS^?eZ{i&CjTHwOZjGr2=T*cuv0(#uuWKR6z7Hk8Cgrdv zx^XD0&jsrRRYx{apH=X!1lQmK)t@p6F@ZOPrnQt3{BMEM0D$L?3DFY%u~9Ei?Fnjk z3qJNP8b%Qi5_EGqesOkD9es98D&I!WrcpAh!)$CUA~RtS>9Yvlbt?hK&e-eiFD`v} z!_n-xgrdwJVHhRocyh|=tOaeBM9@q#hp$3tf%e_a|A=+{-k7=_I4k^beXwmF+DCuS zvG&kz(k)U-xq}zSCzs^m!G0+fd-6F~FQ{Z2&wJA2_s5-xhbqvD z9Nt&@(>YWI2L1QX?$;qAui@BzN9+nJ+ehFgV89pc)~o}BKCf`}N@)!ln?AtunJ5X9 z3WtUM6dcJA$x`%n-MO<*n7*XU4b>NMbZDOj8&?9nS-|M*6esq2YeQ+*4qB*!B+ifM-LqD*c!|q2uVF0gy@`~xusvE@EtO61%qp_r4Sf+vIbqcmo zJOSU}&>g9PXR;EpE<^fmUYuV1?)^{UqI=2=#lN|mbox9$ogoyYv+Kv{$y{Oy_nyib zmeVzTDazh*CpaCW=3g3b+lt7%a6F>dGm6mDr1Y4{i_7rwz5nWJ)qcHfl=|T=R?MIX z2N_`-n^?F|(%4|7#Gx}x7-SXwz?VtrGV|#V7)m-wp%X0p6F=gNu?ooi$|{B=24H8} zQ}|i(eB_y$5{}8EBPTo@A=C~|0C-L^w#NJkOtkxhaV|eyiph;li^UlkP%ijL^DKnG zSZ8Eji!~0SaS;{vjM@}Mu;dd6wu4plbocK_o}8Wsw~#;dk6vBBo?j(KWc8na_4EFV zA5Y`cALplk-Y>@bm*dN4=v(582o>uQ`!$>OA{+(>C@cUXqvj2Z48eyA#U}yksX2V2 z>$gr^B>_z;ei>i_F8F5AN(qZRR7_}Ry%RuvH}El43?|YE&8J@u4W+@Qc815zYuQw{ zj+RF{YqSm~SHF}L1#kMRFf;)XT^g}-D?_JKvN(R^SBcMKk9^g8_w~f~gE3-du$1Y5 zm~=$Sel4ec-o_H|=gFE621|VE$$OuXO2_-m?>e`q0~^;+#%fc^ZgZc;4jqVK79ejy zti@QG{$>C0Vg8V%^cntpgzwoaAF}A+4O~I{8)^5Y9WI{76~;6zX&oS#g#mCHdwt1R z1elCtBO(lGZMZ@C_IzH^Rv_&*_GiRG{uh1B;odp$3pI^5)tdLFzj22n!sH`o|${snI+lF+|Y(BX4D)(!7y!-o& zQ-7*|TYvd%bMNl&m!Gq6)$i+1eeU5zCx=?U`?oj8C-sT?Q=epO`OjXts8AmRzk7Ed z-TJwQi_d{!eKP#5gV{&yq+67VV3=g8a^3RA_w4inKB+68aSd6ud4YDmE1Bs^XFwfPAQNI1 zxym*#v=u%`+qM6gc#1tI(Ikq&*7XY%kYnh#<__BJ?i;QnOaplMOT*fw?>(mtoV5u% zYCk`6kKqJJJHPQpaNI`0TO_fXRsZtkF^TUh)fzb>YvrS}=s2ngvMY?_XLEIl%B9^7 zuaK|xx@FxN88R-XgkE`i6Bd2NNl0||nDYago8&r5)%MG#bNnmfc9x;Yy))ZzpCrQ_ zN510D|A;&Q5%hLMKGF?3*NBt#o#bEFLHdzeCFt`8;X}U?Rr>t0oUA3KvC5w#%94?pwC*CIB>GdpW_zA~zvH$VM zAO2w!KhiyNMP`*mQ0oh1rdHWn3zC!4PLqBTc8wY{BF@JvQoEV#{Djr{pGv4vt`|`V`*T$k4 z`lLV!#T+j5MzXj$_KX=tH5Hrib4xAZm3Oh&rzkaa%`#GW%K`?}ZsmVktgzyz*qC<{ z$DSccMsjjp6A|~#jTzBl5=4ZZ;R6ZmYr3Yz`vSgb?-NjQro&z&WDp1Cp0^Q1Gp1QZ zk|i&FVkRDz!deaFoa{vXX1AdLF2l}GRcA%x1~KgXdzUQlM(0o%Dz?BK8jA+HG#n4@ z^dTN(XUjS|LuL&|RH>a5TgfL#+Bb$HsoRs4Q{NhlzOv&#Y2QNWcBPwNtPeJv&!o8* z8!H8#n(0Y6mQE?Eod&h3_-S_BR{Quw0jSg#S?`m-pGNzo7F>U>ceVb-W_aRTzbe?_ zcg70*{r=tYe&yD8ghhM?l}dP`LU0G7_Kb702Ni-dfQY@K069C76l)SKM3`uAiom_8 zq5Ar8?L17$JILrO^b;X5DQFvU%j!f}&iT__zr3oMp~-Af4`p4hetG@uLhZ7XRaugjq>n0_=!sOiL5QP%OK(NfmEO<6t7&CJ4Ne>I=}ofx z&_`9%6jtZ8_9rKG3OTbjH345?wiO4eJN@s+mls8Q*daU?vKA9gxJZW_`(AN4#fYU~ zi)+t#LX|%njXL-Vok|)g!Ghj;>9pxQZfhrFaW>J_I6-PuB&@hI_`Wlo@Tcp0coF`X zb0^A~On_F0RkaIod9ShFZVA%_W+&n`!kQ)y&D6@nirb+J_!FSx9DKjB<*7vw;@cF! zq1M`>J1O=GE;XN9JRReDOMe$~trS@?YS1U!U_1aP}r7^y9+I1%(OLlJK&M~%g|9nn z99m7;j1|szJ)E}yC1Xa8#_ni7qsrOTCA&?}W}6S!BXSCi4vnG<^)2`JDGuF_G>p*}%?pNkc723XXpd8?|LCuJz< zkKkfDQAkB4x)1E_EE7E$fOEnmB?t=kT!t`|tWQmPWqmlGY+f9ZO*r2_c_v5XE@h|V zbN{V!wvpbJht+H((mYF#Jut)xS3#|tSFu^i4DkD-Y=UVyz8e`;`5r~;I051Ojq zx=5e*bMU$$IIO#fuhJV=-){a^*hntQM#3{JFc!4tCLE0>xWWfCI>z8k3?MjBIg^o+ zcG7L27cL!JC^$-fMo!SKlMVoIMV|;S^5{*Xd?zk4;>}PHC@GttHI?8;0|lTsNN!mv zO0iC1)fv8MEGHc%6N<%890LQ>03L|EW^r=(3 zr}xSd^fmB#wRvIUYZJlIRw<~KaIxj(8;iWh@vE35KQ7@0Z&mfZw>VO>dFZr5VJFnO ziP^XpJ!l=V7S}vQGx+{BMoGR54K%(6p);yCXG!c*L2$2h_QYjdKK5bGW!|!#5D?(W zjqwm0waeeoxO4j4N+Wu;1llCm(iT3BA#_-K53141yT5vVE4hNy*jP{ zBL*Mc=QTo#9(iJVwZ{YT;3)SIf3vUFgOtA~W`FFcR$SQ)}nH93~OKtRhqr0?39Y&q)gXrB++p z?q4!@NMT=mY!76STV32nM*oD8|6X+lHY1fjA+y-dbc|Cs(P%cWBc+}oUyvd`nJzJd z3I!f=^wRgJ+zt>V6#+tq*t5w6MlX-ZGM{S1XN}jSDZoQ6g-+SRwm`U}<5dK|gs_Oq zxN&pCeXuMNFUC*7o-cHxobnV%bcKpYRA?1C8N*B(0Nxp6D);OKk+EU>dIJLO0O0|^ zT_=D>RfAnYT3<9T7pF>%Dy*#CpX7l)dJrsZEHe=T1!7k>C)Uo$Q5sM;O(V5>3=Hg; ztiT8Z{Cf~ADDDVr3f6!Yix82=hvn{lBhLXs)YlGS)0F@C6~`P^hh^k3tXvR66@!A& z1!iT)Q)9}Z{Dqn;H1v}ZF9dFm7HS1_ayW{8tolkWKYj_2 z`~P4x_9;KQKubpPxccGv%GdJ)4KkXt2$5RRG_CYTdk=~PLVMQ!weEt3pWv&LLmyO@ zb6oMF0M#g)d=ufZ!`_&SMH_)`hG?{QtzGLh3X&pCqgr21wu@1k1C=ZBEn*iCZlGVB z!N|JgCMQxv33=Te(Dm?IHuWuH794l3%P z1`*BwKb~gRDOI-=t9}uKti)X2Rg$XM|D(-82ivS;rf2WFSsim4qeh{g4%%_rDts%X zk6v?Q+;O%q_{CtKBzyEN>N!nOc%D8%?K#t7AX5j9YOz3*I?!a76f^V$-eO%^3XtfM z7_ma#IZQ8Le2VO;Q(YCFluLvVuepq9$MLxoA<+p$G~{Nq@Kz z{U~{yCa*2 z-Q4y}G%K4?lKXoNj=bPq>srgQ>&pgF$y}N#-(j}i%k)PGB6 z6D^Cm_8I)$T*3{R!5K|sNiW^3)m$)qQWR3YFA%Dr?wYYVj`CE^wkU9My`^Gq-DwA@ z5cAQR2E`PUPx!3Oe~JO?!s3taeYm;vrPq)%7$npimZk6}nXvGho?&nG*AU@<2nd7p zSq#@1;j^r*x4!s^rgwbck#`?#7QOMY^HN6fARyIN9k?tUt1*o7TZ{pI`6`eR3qd zarX7Q19|+6!s=+qyNT|}9cM1?k|&OeEt^=7RyiS|R(oobM^MUcqQbTI&cvWrz! z*XP7_DC%>=V!_8P&I>Ln<@WJL&tLPadV#zEFS=swka8Vc<$bw2nxBw1y6IGo6~N9(3YNWC(?;^v3-@qkXQB$b}7tC6NZZ z$MO2Jn5h|ca|=GwQXALq3rYz>dSD9xp&P=|;Sy**Owf}uzcf7=-U6e1M-DmE(M<%= z9ml!y#Chlw)A^C)D=@*4M`z4GjE|KxAVJz=V!P-v5H*$?x7Rc8B$Vg#8SPrpck>lm z;EAoVo_eA5yX?(6*Mz{(u@+EagAHZCGd~frwj~@Ot@>aE(%7g%C zLI6D>V2aE{j!6bYBM+jP_LIV1$e?b*s40I6yH$!h5^yn5((;c64fuDQdlQMp+66~T zO*rW&uW%{k(gl;36nig3P_dBa6vQ320z~#;#@6EVqtatgeq0s8?7RY7h9IZEDgEdX z3I*rtm-FWgw^CJ+StVx|j4kU4yU@@16=aTai&u-$T4}H&fWJ$w?xxAN3?N-6PP$n_cCea$r@)Vr(;~xC`T+_9`7&23VNSj zPYx*kZp38*IGuH_ub=+Pgyspq|GnIl%ruac!_U=Y3@J*_{L&VRJ=#lo2i8fWJu%F* zqu<0jrs0BNCP-_?L6n{NZ#s`??t9C5yt#Qslln@iCsCeOmHvvtd1x<05L2+wO*@2F z5eGTTKg77U{l_YAT%2VbatPv&rEKfxnLs&Px*o^?I)pSor4EZfl>%%ADU2V}tFc}1 zDPh6XGQy|vaq2K7y<@xyKh{%kP{q5;bNO8}1GeP!Ji>^vOt0K>r{qCYA0l~LF;H+% z+}1vNfe(jQCwB`6jY@-1X@!$ZqZtyDkXf&d(wtVO#;#lC0IH{T%^}$(V2%Z{p&Xr^ zz&OO{T$VC%XE;h+;?X8#KLTWXp6RNHJf8<)FeIw;B%yWKGDV@{+J29cvJtX>F?}bb zh=b!?;&zLd8~R~lR-)T96x|+_w2V}`oZc>2toUXMU*f}V&l;cp3%AE#AAN%3ylxpK@=C zO7Q7RPSjCJPNJA9S5YDvK}%DV*14(_=Eup7r@>*ROiti5yc3H*RW;4Q1i6rSOJtI< zOs|F2Xbd6;Tz=*AP?mj)rd><3vk;3Pg+qP+AAAV=4YcwSs~_W!$4^RkPG1O9&;R~M ze#ZC|_081JK<8XaC$K^Byr@yQKd{k_BD@Uzarp)IA zbH`s-%dEJ@75-}uJx=N$&#ph+`^S^(Pbqadj^6jQlJVoeu8(d7Z?N&Z0(?7u@4(gU zc?Dy|*zdp%+b~uP@%o08#PCXYa>N!MOP<)XoBOLkR(n~&cn2Zf-pj+Kc$L3?yL5?- zR(LF7ybFJC!)O*?fBiFzh@J@#p8550Q5i9}LRRITv7wP7P(4$z>VkuNI*V)ZrpMyj zB#xaEleelo37$%M8<^Mf&hAF69<}ssAdLd1`L@+@WNkZHF78Hz|E6{08Qw@=v8ew- zWk(4Wc^?=@eF|KnOz6LdL$t$%!?d>3Sy^1o*R)1@<}1*j4u_^&d%UT9;Y{A6}t+QhpDds5=Sikte%{7$cBP3l+VCVAMT&7A9!#_J|~|u zX@VlG90esDdw7lv7q43DVTviku)p~RvdxdJc)qF}QZK2#EWZo|FioWN(cm@W!}%8f zvu@RhE|o=a)c(h2bIUpc2{ha1hz(-ddC5_MA*}6X=V5}2MU`X{JB*Cv0*x=Zz9ARS zuY^=ulAe09ebY$K=8*q=h-AzKx5G}cYgjllAWF@Ny&2(kar9zFA`iePDs42ABwIW2 zRnF(|f8R6x#W!B69RSlnB#>NR!xsxeJt-UA;xC3!pcIoE{9$`JjLUZ&^eVi6u}qrm z&*u@ltt{l-Hgl4xAE6Ll^ArjBNGEtCyD=g-A|~Zu6LTwy2uDXw@9`pPF6B6htMMUV)F5Te3Z2>z zq{eQIB9D(kGl??GYXl|B;qw$*JdF{5-bDtHjZLNtypL{r_P^*y?}|=Aik9?q{6)vP z2&?)9k_ZGjgChEeZr>=5c2uel7MMAQOA<{l|M-H-A}6aZ#rEUrj-M(C)1{{DYr9() zI@43Dl~!9K!w;P{nAcQ&svd5%ICfnOGEDSaWT?dxqjK%DCh*&F z*y7NPti`!q5-_eV%<$v(eTVc&H_zw>)pdV2RG!KVd_Oturaca>)C0nIf&952@|q zW@npt6;ah>#{kucTyTOc%_$IdK_iKIJ)})(5oBwklb9MJNQ2=i?$vfH3I zY+{RFp>gFA#mum%r`rrl&!d09ruvLVF=OPfevQiA?8*WB8#+gypUXH)mq4zea#@N7 zjMaZ-PS#*boGiRLV8RX2@CHTE#B>zv7kYEHpwwM56eRaOpZ~yc-|Hhr>&2*5RC{E! zCWI<<0;`EPwI<3jHDKt?H2-GF9LQ~JT@oz8(+>)llwy~VijO1 z3s6u0hIk27Yf0>SZP2H3rE1l@RB~Ja`t>D8aNxD#`&w+GO`%|?@YpkfR6AjH8?EN2 zj!MDJbIy0THFDKw4+kr{wNcGpW=2oM?R9pW}QGO7)1P+V#sptP)&Z-RrfW>0dZ-DX^>W+Q*@_h4(YIQ zkwo_+rM0*sqtXnjK#wwjycBgu`>vwcqZGI1lBlEe!e(5n|A2Iel!o5w1)45!AqjNK z^rJhG2a+2;o34W78}v)YPrr6_x2f+kU*H-QrULNe&6%z-WTEL8X1#jBdlGNtsK~ZC zG=I3+neT}1rYGYO*e~ntowSPL#wi_Ay_SSAGAX=rQ&yz=KJXoNqT!7i$Lw_+T^e2w z21&1C*~!C5MmJfXQIL&S(`cYGoKfK(uGRpWdEZ%m$Tch>jKrkj2)+8WIdjJg)bL>x zTkWo;p&9RD1wsN;@Z|}F2TUGA-PQHz5lI;RZgJC4U*zY;23MX-xlw#&dLAN*VR(Vx znBjVpeC{DIf3|N94!-0gi#4`3^r&)36QW!yb1ql88Za>y^EONq^HU7S*z9E;jOi_V|{2@Y`0zZn==s?{NPMVgw!@SRkRsX!LD=fC+6Dcq~H0mOpm+UP% z_Nre^EKqqACvjHrBFSMm9GQ+}wH~MDzysRU#?mM7o#eGoZAi)M=xAvxl&6yypdANX zWR|<+i@|!_cJTr;?xX>+{Yw9Cbguh|vA zb?fQiLpGYvIS{j-w+~IQdRQjtpu;QD#-niYP3&&;m&!i!BXpMclV5o(RJt180Gg{b zJ1lF?c0~udqox;Jj#8(q7j?GsHA0IoP#bL-!RqN;FY%aTE#F$nhHun@T$jFT7U@m4 zl6i4Cea6V5ize|4L?RDC2Q4!;O}K=aK(u$$oDh6FCw?;)J6I>Ig16KoEzmODHm3mo zQH?ZebP`n4S@Bp9NzSek&o8-ejq#5zQu#%q4|PB1ndD(XO+n&{&lGx;@xzv@TTM1O z2kGTIAekGM8q$=#ruPGac+ga^ zsSuk(#ElB)!MSh{zilXJD|J%)>Hxk^ydYm*hQ(U(to!cXmO$(T(yBvJtOMBF^M~Ns zX?qb_p3I;zT%N6{G)q-RWyK1`jbC-^*lUfKnz{P}Z(Uw99yu;}q673~nyAo)!<8bg zGxD`~=M2n|+b*0E*el&-%1U!tYD#(C^8Glivi+Dmv3x0TLrP(dXL1D+*LN}z9!V9O z3Zap!j3qt0fa-P5Q{*<-V+TW%O1eb(@APAgjGQB}mIhk{B+%P07h;VIhC8(71!-q4 zvNS$hOV<&84e-lx{5pIWucq>F@c5;o!hvQ%X>6A{^*Re?Lqzvief~d*3fp&=g}X!u^N^A5yQ3YPD+XVb__*lSll(-rDP<-y%G=>cP< zX8t~OWquSQAcS>R_Eth`Ms-O{viug|8~Hg7yav4r%0S7>4>_Dw3BKj{mUt)@g4OX- zM_tPhDu5J^Z;{k1R@jhy?dZl?R#K|`BVGLO^QF~v?jfE4u6GpKjQZ^T`#eeiO<&51 z9I?OBz0e1VduCx4_{;6rEvDrn-2vw9ajXn+QPwQ%o9nPdis74aDbWf_U`cVMan?~e zslB)FcU%l;vSTKrvWZf?LE5oQyqK!+ck8Z+;rR30#=JKSV>mk?>P>el;GZym{yvWi z*mcS)QloL#OEgnp(*YA~D-CDm;d8nEDLGzKlVss|*bJVj*LB#KAqk10Go8OoW-1Ky zElX(@8O-0&5uDBc-^{gK?cy7E`c$V*Rj0n~=W^%Xp6oW478Ord2*VTeB&cKIOkL$6 zo4N~p)0ylSrk!;kz$w}3RdgJGG$|Z>IW+%%{$~>8S5o6&4ixi4Q)ySmv z4Qa+9E~P`$#W#753-|} zqn??p#rJdDSxRY7NKR{D#6h}-y`PyI`Zcpd9eVgzYKe^RRs$w? zLufeC@Epf<_{yrdhT45BaR^85ab_!$w3CxsZs_7nbn-?B2T04;*ZPVk+O9K6LGEo8 z2iGqeofHz?maU2Xp}+Rl7iTnwR2?aWjyh)XtaZ0iwGjNML@M8V5?>Z-W1Fs-6o^t? z-dg528(`#rCJu^1UWkYjHKU@~`7t~6W$M2ThMEs|A?Ag~ZG_E$fUARB~jQMt1DSWZ}@19Xe8?9UU13M;r2!-L9@hGvmZD zMon{lY@lUIiS=uqcWYwyqlJPYm~mTGhx{H-)Mg>)yI+^w8L=%EuFEg~XVAIg_>u34s_H`g`p(LoX42m=tF0p10o;^IxAB2RZ47tmN@5{VL< z@f)tD;{a?Oc}hkdYg`G?&;}|AerAxyyFdvvEER;Ogb6X3yWMHr^3VFolXjl)on*{& z(IE=c9!CN^_3;!jY4`|AI%Z}`gc^JBGfO82hFjeq?~m24!U>?2o6DPVsZ;XMA1i^V zrin@I8PfveLs5a3wG{|ZR9-mrc~3qq>;Mn4G54_mm1!*jlBD{+1qfnokmJfKZrp!O zA(@HPzm%AA$cxE4V=(4eGq!wWfGWgrbmS>Dh!K@ic*LuppAKsx73H)BH)dS+G!MY*I0!``;rgu^}U=sr2n$~%wVL+=?-3zmCjH_z|U!k z&ZS`wIVFWq`jyE{Ugc=>;2uHJ*Z(}tTdFJWJFqH9M~)phb5*eA;sz$Y;}15kE`FjD z5{s<;ZIi4333nUnY{!XxfOmrmY6yyY8M7$ptJ(al!Ps9xeK*sOx;C{(U5AcUc;St_ z{LQ)j7H1ZAK^cp4?u#PX!n6KwQvg($Y;RRl@O6Ww;&2Xjvpmte8z%=n9i-u?*+JoF zWGoe`CAn`sx1n%hE2V^1CQ&rpc2%&t*EJFe52x490$Zob)TWU+7>6RM982yL_>Sw0 z1qF35_n3qO!;VPn*nh;l(4I@+O9ZlL|CJVaMIEyzL{~pae(5uP(oO$FSTAc z(4bnIsaV=yUJz^LHrBzJJHfZgqXlSL_Ay-?hh~*CHEcSN>6#~{GO8YssQO7+#|R_Y zz_CB@R5Q*w;zR9I@y@tjLck{;C^)rNa^{C(@PDG*u2!K#jvDn{@6Jq}zjF4-7GK=- zvtz7aJ>sN6)SXqai>4@pC89Vy2X$?vq@3qVHcrSQC1xa7MxYs99&uHx#s^8Y^_pU z6^Xlo6B(;^H8yu5A{D>0e7>Sb<08V9#YXgM+__V-y}(S)beA0*V{ZvSh@gAu;MY{2 zM1}>)zEIc*I|?pNlLni*wK1T1_fgPqA@tZ1Y@59>@^?l8yu@X`11FK>XuW=6vKX(8Fuv^$<^!Ql)w>|9?mBBOOn8p90M_lEGf4!6&2 zR%>`AGRiD{T^f?KRL(B!geLzvqWQB+L^Af79oM}i5jaEqkIduo=9Jd{nWk*KkxFzjwE zS>~z~4y66oQSVjRXxh0WQ@aw8v5yF&nf9$aWMk;=OJTl zZqC%fS0{u@AlruC7_GOX6-By5EkZ1NLw57{`Hhoubn>6`?s_X{yX}!VVzBd=>Cqy2 zee?rOF)C=>Twl=C4;yEqNpf7M{CKJcZO(nmAVQ#ql^}AsOuCN~tK6KYwqgf`=Bkb?P5ZB$P)AJT3M6y`18#SG z6vkb|VB^4Yd%kc~#2h368iYjaVoXK-_<7!Ut(BR3pCgRB<`PrWQ-#hsJNL?!>wZhQ zPPQ})C+@uhfi)KM6jU06Y(BvCv!ksp>8;U^Famvwn7 zdVzvdHuU%^YV)yK3j%S1IuUIJYxC_)OC2euy5ACDFQ3&k<(jXJ7UFU#+L)lC&R+(-%j;;beRgcxd3so&y%vH? zr;`I@e>C`_sDlG|r)_cisXTcvUzxC-y}AoPn+ME)zf|yn(U@7bmzD)?nx&+^tQSA6 zqMf|UV%5{+LcYZH7vO`UlvfOVSAH3g{s6%lAv&%8)6q zqwAb*+h*7gkf{4080=CNHB_v;EeXPAe`F?^TMI(=dL$SiQ|@KChJoB7f#h%}RwqT9Q5yCgJbE&!!d_&g1~!@|cHhsUjGwvA8)LT4UsaF5RU{ z>h-G}Ac6^cYz6?+?ld+vP!iPx84KVjYo>aH~Ar+q%28E42}h=+NFe2d)-r&WY5e ztO1qe**<~$^-xguO(51XHhkn7wnonZiLAq7EZ%&_5XBmGotwK|3k5bU^Le=q`l)r} zV^P$SvCLgG-OI%K;}mp#d_|HWr#G8UH&$G;OV3duv=h8g#}1|ZUSjNOF@XJP^@U3%1y6jCb`?dXX6ISfss1Q`6!$B5z+ItV9VNsLg9*e*=- zO`R%#j1YI)VJ-$dNgXNt9si~qt~-4AC$1GtHqcpaE+~1$Mv&=du6VaRVsb-7 z2nIj|TF|1+ApzhMMwU4&Q?k=?rM-1%w+s0V8DgzP<4cl;++M9NArHNYMUo09c#RZ20&&8oR+*NOGRFR^WV=24Zi}WL{oqo&vn_dK; z(Ydi)y!rTEd?s^QEe9XEq1)cU&Y6`Rrm-9`-5P`&^yWmxWQRU)=^T$Ql1CIOt4i?O zGDM>SSAh~xhuGB{+b{H}{0j?Z+%RyTH%99l$?=)1V5|#0HM2Q@k~oja+;-WWK~yQG zrHW{w?ZU{4AzmUP-l#JQ(XOy~hyy)R_W$n}af2+ZCOz}hnn+BXLw72#bjUj?0&U@R8+>8#1IOtAIQpIMTEcFN`ff>*W+kY!vIDHBjGN4D(- zw|BZdJ$b93ASW#UbbO6e(9k#+^dzhrYw~BJyC>7Yt5Oml1kN2P5Wh8d>@~b(4q+lI zaP2VK#6T)M1ft0gk$<32?@ZSzokl*Tf>0}m+r-NJJetsiFpXf`Fv>$Qa-3pPsM_Ei zzz6-q8v8b#*KCfFBva;AcWw!jVUPuQVXAa9)2d!GGbB}gGCjTsMhgU!NExmJ!t;&} zp67UE-pZ;}VJ(@=3!rfHB)8FmQ?rdEn^bJ1PuhBYvDBchs>{Nb8u!mNSsfcS-1b%n znYuzuH3mrOIsP;MMiX-VlSFTe%+@x%U9f?05kC9Nri`8Q*`xNYxeKnk$RrLtnC_<{ zvny~|NFgrVZ5G-)2Q)|;k3vL}t5s6gt89e&z^MoG7)99?d=NC;(}|EX)|=)efUr*&pj8jyWYiHwqP-zg=4a~81a#dp)zwpp~!`U6&S|<%y4(PE0X4RltZ*4Rfiai*4gG)0mb^AlZf5MtPJFvRn z8YdadEF2EcSqVv0YDGfV?mt6r>RwuTH-i~gI&>Nb81-WV=V7du-+`i`Mz?~7Gs!zS zb46MdOo)hip3DsLjL>GGBU`f7#UB1U!4s84LjnJ+PCb`TEbedZ1n0*Vy;#;#B}8{> zgOO%73R;gsJBNvbVey!bTIGrQ+Xp;{3iM$lIaq?+e2~H!LR0lwCcC1CM>&Ua8v01+ zD2@TESV+egW&eIr3;6U$0N{ZesP;2NlNSo{1SFmvBfBE>yHxq)IB%3vUPedZ@V9Km zlvD%iN=n(CkdMKE0{d$eEmi8w-cSYxjfg-;V@beDm_WBy*P|pMJR+6U8|6wrX&R(> z#+2ffb{=fq<2FVSuypT^FeQT8d_qo1FG$ip0QUJ;6-OFhEt0}Og~5dOnK|z_IIgtgR5TItY+>Z{mu@)M%6$`tq+RFSbV%XqfPGF##9C;AVNm8pFitg_ zQ+YZekUfMGz;y`cBvjc<+J=%^u&{nq@ehQW&x*|mJdd}Le+6|2tM=sL<{LxqxN>nC z&#WG;E~TnH6e*OYk!L`$_dp=|W9V5Qa`=v=yrSpas-vWn0(k0RO)s(mh@~Mk7!m6L zdboJ~w-aho`~wl=6bO->14kG58N`-}#}Ivv6md{N;>49I*{&^2y@-0O&7WR8B|upB zT||m~ARnzCMM*|ENX|o}%F!FPmB^3mE1J02ce}qv=BSxf^T0H1NwIIwjpPv6ZYz$Y zgpWMdY9L=huZWlUeCM0*Aq2U?2@%k|rR-3FJ5#iKMQfmr_KqWS@?H~y$cIMHC!ZP~ z)%CX+`;8UoLP|1kSqC#A{xnWt1}^7@&Z|Lby2@ro=@d)!DHr8w zr7$XW=rt_az5sK0H2r>0VY=QrBPYpmF=4UD=j_FrG4%c*21K%!d{EpPbQgnPg_LjXP*mr`V1I~** z*UHRxDp_K(M%MZikdITNFhnG>GD0Vi5uqJr&r^&Bl|SlYe4MrA*<2>;0&lcmGu(?l z)ZCefAEDhG{U`xHDxe^zFd|bLa|#)lk1UQ)RWz~N)GYXJ-Mgb6YZ!=ZvWfo2Mse93UVgAIEC$@hXr% z<4rCEU--BzwMNMm3Lla+%&(C+_;Ks7(sE3}q!qUkz9ioy*b{DpFv4!I2|3rk8^mNp zY;^{Wwdko9^CB5gY4JH;5TRefTcKTw!F*_nu?8!&SA}zLa!(-VYf4v{Awq^U7$bsK z_%F)+u0&e>t_@m9$)vs3`57@YM0j6KFxJtnS81j*}@ z+Z&||AuOsnfp2+6k?ke+9D-5D((l)3V7B`mvdBDb;I;fu}9 z3=@~Fa7r<-LN1bBgh(|GtXzPIBuaVhb?Lwrq-tR{fD_f_FV-rq?qP{CFS!vQ>D!Bh z8cN3rq+`%3&bw&CC>GBjA3QmLR2_aw8QbhhC_VT+3Exe(sRaM>x4H@2D zkhaPO0~2)94Hm!h4c*p)yn-y@{^|1YI){mF3q^jV$A3lYuaZN(>6l7ZCq;d;y&Drm!!# zXnsiN|CkXbRvru=dW!U1O%aHQaoZB>jGOTeQM28Ck5kYaW!iY2V1fO8s}2jCM9rY- zh@S^i`A5IjPBpI0C~&yAVbr;a7J;>S=&n;??YpPnJyErs4A#uo422DTkJqtCNpUHN zHgacol*VAH=c&)j(Mr1}5#x9onHz;Syh^VgvBUqQHJsujv7!@_BF!ji{+K;RIqQi=#X3cxA(XlD<*`EH zvc8yJ8@v(@e|i!H3mA6hvrYoyuNM4` zJXP9E)Tf_FKzgAdLN`tXj+7c|YSs(byq(oXoZ!MMEa{pIFVug^SYp4*0<__yFyv6- z;I)MXn6nopuGoG&A6OQN3F6O1lYy!89rA01v8KkW$FP`xBEAdfqx8tqt z3J6w`PG|i7lyXW3_6kE~B6>rq+mQ3TtWwFgJE-Z`?J9mW^=chxnW;tDUTF{5rTKTJv0wpj5T~Jo>pe{oUPTDm2@(l+D3#}0R3k!ngX+l>_Ht9bVHy{ZCBq<3 zt`;NCjDkp^+`o!2P0mt)ypZO3b_xgv6zfnk^xbK{^%KMMtjKTnwg#u2$|~Yr5fNUa zfF{K)@uyA@U-;7rtEdF=p@M)2W{d$_ufsj`_lmM{Oh;H7n3BVdxkRubCyL$l31{r( zWT{`^e#nAp->0yAF~nmBwNniPN$iEG_V!dih|?c_I#9jo56_tm(hebCtT4DE(qEDO&NY8r}ODLeVE8?vG9MPV2T*T*BfuH zuHHYqbB7j-<5#C2w^YG?x^;Gb=i=4jrT%N@{=NOJH&^dYH~#g-w~rV4^Iz^P|8?=p z?%rRqCjy(0x88en@|p(F;@V&i+ao2VhKP%-0_3{FBU!gQq-#st>Xcq{r8D(QZ;lV& zE^dAI^l=Mi4eN8=l?=6qIS_(hiI?2~Dyb&ZCCexK*!{>0rH;-s9hOWgiBSU5Z5mR^ zqLQ0{&I2tghK(9S>OGh2?d911*3%k7(8TuVgE0Kx9o?mVN2v2ltv~u_en^*~O61?$ z7j}1c@4LEsz&WggPq_F;k5$*N4kTYRt{1JduBvOzUI0We2`BTH_mj=p5O=lLJ24mI zGRD(gJp}sSX;t$olcf=9L{{8M9SWcTnaG7X)a(poa(FJ2k*$(fS4YCwV|>~|HfI#i z;>^SQgKr7Cz?wnxp-I8JWqTXgG$UChn$+Q+S&kWR7$A9?aFX44u|oq&5GJ%VZ;^co zCTJnHWH$rim2AlY@8qcHrQo@Y%&nqWX90Mcv)xh+k|zUgv7*v_?%5L&x@k!Q_%MR= zvrTzF2~W+GRO|j#<-SGx1o%hgZ_`6YU$yXMWr$Tti7X>4Uu?{*gs(+c?&elNGj>fMs+02C2?flT;H}APi+Q=JgfE! zO-RTt0MIjez$5;x$}x<{Fp^V^<1~f_(WS)ZVcZuJCV5);nM7uL){CS^+{#&AU^WX9 z@?AknBvQiD>**A~SJe$dqe^mSkr--p?Zp;1iAuu))lth=i?APm4^3HfyJsnP^ z;qlh%E#^`4Z%8D(3PQZ_L_%2Nl+z0#ut?JiRBcf;n** zt#oquD4%=(rYx2NJN8oaZs{b<0XM|8bZSucIi5HIULI)In{A5$DtWb#dEzG*K#DoU zbepnHC(RMcyDQxwbQuFWEiV%y0!%eN8|{kQ?T-U@q7fi^l4(0rl$UrM+~2-Qv7;Nb z;5`DY1(LbEo4jpFuTtwuqTjHh!WL4!lL}VxhcE!$d!3YQ)0b9+u5oh`Z?J`y=)Z4< zp$o{yS~CYy26@Qo1C1i4Zpm*oPKLv82&+N~jpIezZrkZZJhPHrG1XclS%-XC1FcnV zf}ae~i((X-r=^WOkPLWh*X8kxXW#Y?XPD+lqj91Hz|aK~Nn%NXj?yc5?V%-EUsWjP z4k<@S>}zC0j8Lbru*&AcHMh)wab-}K%sf4QMTa3lDQs=+O|g>(f#K0Q@#f+bG<2A9 zc;y6B`~w-x5h-KaMI<^9kXN!!KXhRe;=xO^kY$rj>+BzwOeJ;7xaM?-f>@Bk)gx!q z1QNOi2zYY~Y(yfu8=T`t5OE<$TeT32*EYi4BHAbiN-RClm?WmTyUTx`l-(5WEW*B) z(F+`#qsH6M+#YJ8@iPjZ6@u+7&yFl5A%!(`EqkRFDPouX6M1sZN}6?qhH{c{eQ@t% zH~^jwmhG9QK^&%Wp$MiQtsp5q1C|H15*<=Ru6au+Vre(f?i7w)r*Hyaendxv1}vvJ zNHKz5?5xwG=t_SjO*2#)wL2_OvR^de-vJ`@%NqRW+42(Idpn6QZik#KBuORKiH(Wj z5zQ`>O5IQ^tz|>mo5SE(y&muU{LF1H0Q8PZw=SABo zpuj?ehYe!HKG0m9(y+;5BuvF$B6OJM27Se|9|NlcC@do3Mq5Z4Al`8q7K?yI%{goq z0x5LsR5Sd)N8!XEF{axa6D(dU+^i(1%?qJmQy?cEbZV<#>Qnh^I(N?$W#5x$;|Di= zpHE(HY9EUqL+j=vH~f#^6wqM_zBh=AjXU(X-0(pE_!cCumW#vV%H;fgvGJ#k7G2aY z*Dn7xmtrczx#@2)r4}2T8ze-BPkIf1f8W}F`IQaWIY9l9uNOO$RM!D?ktCOiiD{1N zoSEj8j7T*#i!jY+CZUO>awXHkL%vr3XG+USabme2@2&6ZWP_tqN_?l1$Rk`L38 zc6>`Ov-^B!!#nUCED&l+L8c32{wqL-*!+M#Dkrl!TwHe`q1;dC(uc2^Ru|z*V5zB} zsOTT2-n&bYHKIA5GSqY0u^x7?wis0AfPWPhkbfZ3$By(06{q&1j9$|vs(|hIO`8sG zg0UD9oy1S$TsjoRoR0#$HS86FFTS1w9(Vqj3cX|_&KAC&-kUHZVgJgr==xO@^Fv#+ z5(Lsxkdi$UE-)OqFb94T(_w;iu=}Hk(Po(f8~l*GrNN$V-OK1S!bs}jK1ub#OKv`x z45yf)YlQXdJzJUx869D?fygAW$2z@zRKTr_YqFs6EtMJIkc_x|d-A z&CGbNo}Cx!QVVi`g#tTs%m*zhg=FQGeF4d@NVWbU8F&1ww=W?lPWJZ`JoHTm9!^dvpK6gFAY@>$i9i>7iSVZhVq2HXp2c_K_5M z48JLp=XYSxN{pXE6aXS0pmB05p{l4O+DBADwb22*Ui^f}AD zB{G{d#(LIYQ8BB%O&_)l8GmC`=kK^EmbaOeQaPye?sWOyPMjyxV%EK3%$l029AZdW zfPEP>&cm1KGbKwU$!-R>g;oq%-5uy>k(ZAzy%2`fhafImuj;avppKb`7FCBgb`=T1 zcXqaR82);1k*rj5u=bE1XwtCM{(gV{>tg4@gS(6Edk=T-KHS}3{M&a2?YGZl zNqmQ|gep5)_t5^syZ0Y%-=91*LBhk_$L`Md4y66%_U_Id{r7HrNBunT@^G98wG3At`X3{$_Oyz=lT>t-tl@|iO(&YzA+vY%s4*HSVySRe zm9qp_w~xKhP}5~UCm0ruRmHCSlM6yrjIF?!L`J-OLy_P#wY?JNHYT~0%WoVo4LS=o z?u;MZ+uE~bpytGJr2Yx5#;uuakk}(9<%5+CG^^Si`TqHV!hQBU+N|E#+8U@M>=(Tx z3uY1B$l1dRgcV}TD!5UGjfZ3tf|)t{XWg8E(HRV@OtCk>5us&STEZ|6aE+&RU^$Y* zUME^K#)BP>qt3X8bC#EHjkKa8uVKBDi zp8cw6xkc1UNRtthhzgP(U)IOeM?*aja)r{oNWQw@${>9%9oCRep>Hd^psFK{Kp;1w zasiMhJ!Ez$Ev|6&r+~)Qr!pr>&U26_ksK&P?S;tC@TDITg#Yc$KssdC6w_&GB0hNf zDk>QaemyejNdF@992)C)+0DFkvGXOd$YkdX$5E49{FmoHJ^O|&dW@aW({Nl}D60mp*U|Y6JO83LsnQKV zXynUw78p_AJBeJ0#b8xrqJ*G|D1xw1_SBQ!~04Yi*hqkKYN-%4Uey5{tkUI2u){LkS(U&cTB1M_n@c^zV?W&I} z_A{ZCa@NBT8}tuk192OSF=k|83JQZIo99H?b;^;ON_D-Go*Ld^I{jZzo$K9A()0Qx z^YdzGa<^!rlb|~4nZs4D5~dP81H$-atGDowewhZ@*rWrf2*Z~s z{GCP}_kH*CKo!1ZH{uwl6Nv+BW>tUC12gC_8ekR|bRkq64>_)E1c%mFvg2UL+RTL6LCui5k6aZcD$1453fW6J~P2JB-Cr{%I1Vif_-T>@0b=&%T%DR}g(1ZLIl@5| z$q3sDIRaC}rgV72j`rG)66BT*cg-#qKE<7Hk=bytssU4E^c#49AZA*-y%f_=Wi~Oj zS9(suue5$nA}7LD*lVdSR%uSaCk_i>WpY9pqNT9JsQ2#~*1$DRV0KL~1@zwY5tO7@(&3qrzPg21h0GEE}Q^Jv_LbMTIZCMw-|>WQ%my8?tKai zWnz6iJAA_pE$Ry*9BXib3NuzxL*iY2VjfZoMDq)aupeiMSiUzx;bFP0o+Sj6r<38F zB)~Y_Y8H20h804{GgDwuxC%eTo0H1VU{`Q<=9SxI zlqRbnRE_%8jwkO;5p#TgVRtXT)kJqCj|@sjnWWo0?hysY+4hLSj^YJAQ~fHZT_X5M zOM8L$$}chVIs}+sFWE};qx}}G#7U57)hQfZdxC@C7L#hcOxaC3i$*`~QY>XM%6ba( z#@tad@v-E(vni?UQx83-4$HVqV?x)YriE5oZHjYxL{5Ypc_9;>(N3H9BHxiv0dOtT zK%UE`5UAr-6pki(l?o|Vb_}ZQUg1a?h??|LV;Df|TJbWLB*G`sFDm`ju32M$(4vT{ zi}a!S4R_8Q2WK&akXt(ZP$Y?=^c6AgnIV$it?y<6VmJ(%r)x+G4}BEg zgT<4B)@U!GqCeYfrnY}t1!4J@x(`f*4d8bqOVF$Dcvhg_vP)_%+L*#74<5=aNs z%M88#tCl%7zbx*YpYU_<$2M%BKeieHjZ7U%B-`!wO|apN{vLMq&+QgenntX^ga%(1@d0+Q9ex zC*K@@e7yhcx$29?6nP=B*MOsvhACK{80Q(6fJb}e(dJ=DlQ0Bg;bEGD zy_$5@g0GS+#z#wd?(ckQaBjsLL(+YVOT)#54OXirI&VnHGj=kP*usKTg* z^hACUDMbV!qB)E~w42beGOfZ``eL#F+izYZa^yv#2a>N-!>Xl3Vm)=)GIl~rz(MHW zIMtBIEo%2F`qT246i=WioRkdzZcU6A>0fc;49!eV#RQPHD2yhjUL0)<4n!S4n~hJ- zsXUIM-f$|5Pn<|0=CRT{ArPUF;r)%8!V}vhvMKy{GPE*J*Jr^}L5UvTK9(Hom`8pN z9w`Sm*PN{Ag{EvefYZ^@YGx0lv4Y5(!y#+z&G~z3o;LX()x4sZ9qbP8$r(@?rXTGx z`kgKG3?Y9CWui%}`_*IiD#@G^6xP9IxcS}jF}a2|MnfnH_!EqY)W*1DM8EcfSHti= zdLxb|p(qX^$DjtUjEm^8_I(}ocjmxT&90UA04lbvJ@bzpne6mCnfhQ3U3#M$Uw&`r z3tWbOk~j};s>O%Nf6R#7&GezRD3>rygb4PCCnDH0u&5N;j<6w@cdF6s1gA2caIm`h zdnEEsL?JzRvlZqhPBNnaQh0gIx8&`oa&sl3Wck@u<~rj8%=9+j+W{;ywo_{`OQ|8?+?f1h3LK9wW(H9g{P5cL2}$IQO$@uKCKf!;Jfev zJbkJV`CsVA14(2=KA)6fa*7trBTYUzu39=aC@8o8$!VtQ{Ou~h8*dhmZFZQ z*M!FT?6D}lM(U1*VmeM;BIr|K9S!#FBgdyE^ZwQYOlCR698Ld`$|WwyYM7I2oe3e; z$u>DvSv&4xM$H0vayUCvJB<1 zPv~f)IROU*C6*U&M-;M5Jrit1{)1wSxtpv2kVw_**47QUaU~T{^HYTIZxqo;NobhK zUyHBxT@RH)T_fuaeVsyf<}pg<*w>_#Zc*uwiP=Vfxo8=$oZ%;^ zUO%jOh(W1`h*R^xgJ_0!4kYdR<4wl;pKA0tQa_>-+Sr?GE`|$bNiBkF(r8r=&7Q8TSXA27+q6avucVgB zXs3J#L=~M=n~Xm-dSJn7G5{4D0^sHOZ{cfmYM(91*QOU2zdZP>WX1J+QJ=lz&tC8o ziNQf7_!tnZs05ur=!4uuxsziqaQ^7SzC%5Ab^h?f@ymBEi2wgS>}{Q2yx#cN`6tRx zwv$KrOz34EP+{7vE+?xRG>NgA&g{~9#8A-YkxaN(zL!Rao-sM;uawlttLrn}@eLyL z*yUigh%+4Tl{jQbAzq?_Y$TbchDe*b?1DkG5EnMSCj*?H1*OjWq*~q z?-okFUIs*T#u72r`n(n1R%isvJZxI8#Mg=_B^QW@HO}UJPlGW~i#d)TZE0!ukHb8T5Lhu@>KM(mC@ga$+lTQ*raLo?*I~()!f37Y?MRG6d3Jj^y&8exXAW3Tf7ZcG!<5q&f+<}HsQ0u4 zdYN7fEdZMv5&W7Ata1~?b4*qT2Ssy@615WeYXVG{PsDLcOZVtz;~a)A>Jy(VIs**HJ_*i4NO z3>kY_9KU-HC#KW&C{A}4QbarUyNVHx-dGtFRU<<12LKhmQ=kpnA53Oz3WTY=ya6_^ z6LKTG!Z4_cN{bk0`z(>>kSD>eywt1Y>ShdmS#h$~29#B)^=E2ZUqpH-qFE8c1AdBi z6)=ab+G_J%M_7)jbc{5ZkVfBIar+Rbx?K2DR%E|#6HyC`4maFo_7 zXr>4g_L>gbS55VInwT@_q57z(aH@+Cm@)-2@>WJ0yY!9JIdGGcJ8~=K@^mQn@DV8* zr-~uTJNc!ufUk65$a<~^)$nHTd{sX+eIpZ%011XOA_r~j<-{6lZfNVJ$6RSy9GxE7 zU|c07?x{U69Wam184oEd+t0JGCaZ@BYj7G;M!wxzJc)9LAvfDbj#V&$YDp^o4$2N~ zGuVL_Tx!OWEOq`VO7Rth$LiX3U0e82AS^F9jm*?2l+zFQt#H@On|sGi*Re6GvM*I{ zfd)}HNpP1f)b8xlNz(L%qbX-Cl)8nlCOt5lh9dzV;9+^h5*iE=22cjXfy>B|;Qt`= zO2^{q0RU`o-$e$HfM`2IO!( zze5e)a!dH%7i3y}O3FI74sk@O-jfUGYkZ6b!@8`0I{#h8Sm%}4EfyY>0|#Z4U1y6L ze@98W_8cv)(86S; zChsLFvG1zBBYiMqAq5t!kq#OR%{S|RReBk|Uvm89vzdJVcnQpAgdVUDnDIkz@9 zZ5k_$@`4~ZMMU)bSfU@4dA3kkWWre!NJ8WU)Z?#x*y}I~9@Pv}gczF%W)E~m5!1LK z`9PmSoE-=+l$s=)JNCI0)!&^G-?{G}37kexJ@HO%BBj zEK-Vx6-_E8kAn>B)GKkM)bepRmjYVh;@Hk^L>D9|*&W#k&D&QGMt`H%IaS>bOyIel zs@WZmKtCMUtEcM%OdhZ5dPYMGu^%F_jhhV{pHt1)NscHJzzV+HH87I} zhrI~U$#*5VKF<{PF{C*xC#Fnc+Og*jT+QUx5l6uf4wwZn{o`Jz%ULH?DioAmrfkse zkNCYzS0{~QF|W{!k{0O+twrHPH0JT}VsCqYaZ3-?%fFE5%^5Dkwa0C-qCwdk>A}S$ z%EV*YW>Y+-kv948bMm>8nBnK0i~}N8Px0a6N2SGgA1s~|L5%F~gNOTj(?*|1w!u=o zXeXZ}u`~su?KH?P5gWF0y za*|ku|9%t+%ka5*9@khRTV{lpuoX-Ux!jM)W5zj6Kmp~o%a;vXBQxK0sw>;AWmsMt z53}+=vBz5Ha4k41vLy+v+M@ug766c$@au4;xto?x$bu3c-{*Lpz*8;J#Ymw{bXvn1 ztXCz&{*QXW{p^5Qt${#vb5D6m#Ne92Kpb#ZyA9Q(QRj+;hVzZO*}H41bVoc)Nr1K0 z>w&ERVudi=1A#ZJ;DDOuFi0|;+DSDhI@HlcyHM{-K==$@MMEJ~I0`?{tTX5_xih7>F z9t2r#r|0Dpt3?Q#oH+4@y`1jufRe1c&e}<9bYuiw$mmoqUcrVekyNEhdIa~|F0nhZ! zm}zmn9`gr!BOawx>K78)$iEX>Goeh8$r)N#0xD`zd5sCd4tO0Zy6U8hx-mdU(mzWVs)P-!Grr7ATFvCadVWdKJ& zu8JgM-X{LgA=l1RNaDFJUT2USmz$Swk3VcWD$N@Um1Pu+udFSFxnGB_YkisB-svt- zDW&a}-LgyV4q5`&I(bBmMErZ*4b8=r{$bb-{RrdKh*mZOpb*)QFVD?l8V51@{aTlw zde}@GXUA8}ZH-}z9JcI^Gjh|3ssoUnHkFZEW>-!H82zUSi%z70x2YqTI8qMocOUAf zvv)VI@Q1yqdm@qUstvoDd|njxdES!~3Em7wa-;MABZ-6_CH&u;N$4n>oS?i4s`J5O@*$CZEU>NNvH?Jr$rnW)dw&5$$oP#|zoF9P$L@QB7&C zZL%exyDEv?LFdtVXx-aop;viH%OMI)rWVYkFWb*=h)p4yKb2U3n0_az;P=*BiXmaq zDQTJY>C~3w zuFwKXR@ok0QeDD1$r*$b@nLs5;KNA@`sZi zszF@|2dtsr0g)lyjo+xiS;+^j2&sy7LTI>e#wGh$8-uE(ka($LPrR}DI(=;~lTMD2 z2}M+9D0&E*Coihp&j8b;C&+6gE3_<~6`XCi)#H#1ot`xnF0=sDp3GW0l;6t(eNL{*kY>Nv?Q%f>Sgy)TR5n!@S(8yK#+W5!R;&SJv5WbJNYa?C z3NCkY#kbM>k`GxUI8#clTzxo(Hb`6XU#;;de*Qe*-p8u@; z%i4u+FL=k0yWy|(*_-j{Kc2$rPfz6&2N(xR{F#sh@>OInx$(ct{rFOEaNsUI55#ke zcF6xFnxZ~_;=tASCrdQ4_y`U)iABCuo-cu`OUh5Y2TX;S>7k^#`b=#`)FNU|twNk) z?P9G6>Y52_WuUALFh=TO^m1%2+;YZu#3qW^k_1J{o>#oM6eq^^))!RBeNb4)f*fGI zQ1he~VGWJOQ|>}2o5Za{#fP)&MIsNtlBnY)H*?ygVv;|KK4xu~{lgbgz-1#Lk(E*P z*q2XXk})~}t#zP9S}usvL8iyex*NobF0M8YPc9CxPbgm1X~f&TaMNZ_!v~@&7d&v% zB{c~*|M%3kb$SXHWo}hD^(16MHd@6rP10J&S$S`%^JGn-5ar-qE5%&`wbBc!evDm+Qe~mYKgBE@ z5abP013`dPzAD0*ef8EgnR=X2Tv5TDlM3ZEz`RWA@KhobI5(66LYGF&iYJm6A^ znw92-Qu}w+6GlqYIT@XUDyQqfq(N9CYT8pdo4|)h^en~?GZQOSO_4_)Z<3};*23#b z?_!?GR9g`~1IlKgrlsqW`{VWG*kK zfvWkpe=J;OT&+p=w=JhY!rBKL5&8(GRkRR6S^>F0IVc}M^SXW3}NLzDo#zV+5 z=3o1Ysc?|wdM_7wlqzM zh0L6Vz{w{Or%Lf{qzQhre#TxW3GI??Eipf+1M9hYF1Oc_{U3Z|Q9 zCjfp9;jf#jFkN@eoLz?O?sHGZy;zNzVWLhNQCHq(g&$P9-M zS1~l(7e^n}r^axB-b_TM3o~-^60PqFUgdwMw|X)LTOqUlMq*5e&d5*MYoYj=5FSVF zWg}7t{VdhGVu01>cGfuR1W&L_`q5Cee<^KmMvK8>P zSWv4Tb~;w0eHCxP8ljNjb?+H{G#~KLN2a57Z@2s+Qnp&RnPG7FfhPiNnpnaR|~@%IRTRepMJ^UL-~*gmjw*Lf_NS zBRyVrwCTbpPH_X>%YJ--)cY-NT|rd}-oc}KCSoj^6TMe;h9PMD0>lAHPL*QNUNcNb z79ie>0fg>r{$|v;e52!wg4wjtMRV|t%K;T9L>e~F44TQ?z?wIR+NmLK3k^14>=6N1}b-lMX zD}|B~`$}@?#m&3+Bd7(pqYmL2+}3>JP`~tdNuPKkH}1m5?n{)tWxS#3<%Cc=71* zlYYm`gRT2tVB;Pwp8s(0^!fKcj^FHl!6HiCI}>_JFPby#-bH|gb2o0 zhzE3Q6Ukl?6$x&ORdmho$=OTQNu`~d%0dtK5d19jFWIu>B5m4;iTZdYE$TX_-b;Y= z=U7A3M6Sg9U{%F46)png)AMs(F$NG`=H1EBrk@*`d4hH`^Y}?H^y-DJ<8M+o3T)=+ z95VL*)W(lmM^bzVh!8?dm{BlmhGwZcNmSM-pDOyIK6&2JYCw? zB0lJW?~4F(b-zA&L$EC;L^2!%oA+9?VY;!FV%)Z~^+-6W7yIdXe8`NMg3RpvEL$?BiE924Ngf=0jC~V4LmjT+4G6Z4r!h^Nv=#^eu zcV#iEpd2D)?J$~^Y3sFw4b&Z2iVVo)9U);e?ig5rW}-Wr@CI5^x%gWjU&e3!3K9E%N-DOVP##wrr)0l*Ft4ng1c+6(6RI`={8~W_#Xeq94z{u#`MIk5Ozfgc=ak z=)D;~ZBI5@$}jZfXU(2&gP?z|Bz?WF<6UH!0ZHh=ia&HvicUoc4T(;?TGZ35Ob)h? zD2aP@-n7{?xWdWALO38$f20zfDWo7cCy0KCVhPlmWM3|cv<~lRKubff*O8ENr%K&X zfD#GO)%NQb^;7Xp*xpvFL(o(@voHuLK9`MT3*{xFB)l(I++Wp{Es={?NjGSl%2(Hg zH$SLY%!bk^bh1ufO*KIRUZ=1K40ur35^iyiK5_|*xP_cgA=~D92_|k8V2ELgfFD+P z%aWC6W;3f0lr^@htH1eat6%sv7K$%;2v@~}pEEiQq#%5jN$Oy7EX#C(^W#qJA=H1qH@??fEAF)s_=2fZ1xaST!B-})*S{f%^D-Im#(8I zmdF>1BejbLWgrV$)+%lDej`-7E`w4PMSm3YFhkzB_Yz_eR}n+VU)a-~UcY_Ze8i9| zmT-W0qA%xPa(1!8)OjdAO18F%BsJ|#+gRM+X0*3owisR}7y3okTMh{|=UWF4+RLOm zN-r9fd8#WeGw@ZOe26#A?8@!v4VMrV>2eHAF9cvzJJHU;@r3YBPLsR@)fm0v3tKV* zjygoeLIyfmgEgzIRb-a>Yv2yp6>)h^A=46P5CesWC|c$YH*jp|8E;~W#D|MN6FWMz zoc`wIwJIkc#Tdrv?=}{{?CB-x0Ety<3IsS;ntnOq=xJH~@H&0b zni)B)v+PNeU7xbx`{ywlASMJx_~hvP19h#~!wfrxJ%XW`JK5?=FnAs9t!dkFLfLqB zj9H89$!MiQhb$Kh5&jYlP_8J!lNuy_2YOaDeL@iT_vgD6xmAp*=1}Wq0~dh2Bi4*m z&#p5tptvABo}wt=;>1$@=c^3N@1WD9C4Sr=C<`;;Z;mVvB-7Vv-`38i3<-1SCL13~ zbY$fr)%BIg7mv5sFbJUy+n1~HB*v2k0trGJQHQV=r$j32Lnd{Jhz`-fxn)F(Ygdj1 zBB{$61n6{m@DCytaf41my&6cb;+dSurNy(**&Q|mC7pT>sg?xt$b!!;r^G1)w{{2m z+$QYG=7OQ|sfxIU)A_%~(2EI2i{;y4%-Okp@p=4wrZ5ZBG$YOuBp#WDV`c_xtmW*~ z`uvcf3?G*uD)ka|wOb3@-tCfXt*lUx`tj_B+2*!ilTA~$~l&R&?oMuiCGV5^ue4&L9Kzj{?TNqrWgNneWc@D)U{p;xDn#7o+GhGkf@ z^rId!6k1LM=LNswpO!VD3-p{909}rlwQ3Vdb6DO+{3Wn&g{%m;`PG#IZ>*$%Wm&^d zBlfxuT-ZD#DE4N`N0`JutEOSRUSWn{Z-uvdzuu6E!h_VbM}O`O^)KaE`4TC_deugN z!xM*0B-F}DZK5g3&FhFn17&pshg+C(h~(OJ=g@f_pITk*{F+KDIV2`a@9HqLJZ`J7H z$V*#L=yF(u{RAO?a(M&v^883sGmXd=T>LX1VVoYmIoF(DfSS;mW(lRLRnn)WnHDX@ z6e~+3appBCPSGh12v^W3jdUiIa1-ui(}i-0g&V{Y79!FnzYN6rg~KC>&bb_UR8I|O zEnzRZttfN}f1P8zBLVa~CMRPm&R0bRZ`wW+*n%2dP#xmH3)#(;rQL!LA+jt>zK`S3 zi$U=4PHLiq^9NwebgGv}owS2b1&e5zz!IWJ3udNuSi6u=C%}tPav$*(8aJDlCp-ts zX7B;Ch7?w5N#rCqV>&glQ-r@=SQ1qnKJ^}UPn@N z4N`(%#)q{v#2F^aIN>qL-~O7O?H zl8{gs3NycQcy-!6Q%;{WhE(&Fe$r8OIao?5)o&5RxQ+?&6VBj4ZzS1~EBLmzzZj}A zHZ!=TX&BsBpA2?O@8VHe2$zfP&HV=tP?}OdQp8_83+LqBWwGEl-J*+Svoq$V zb@_br!E9v%D~T15e4W3UuN=wFn-+eMPfdZIFTKgH#&w@-4kfbrYd=1IbAZeX<4Dn? zX4Yi9$;bjr_5;|@gAqU5w>NjjrG8ZE3q5yAu>N$RE>@8v`hwffF%3%UMeUNp6xPul zk+V%KrYDvAo}5*GVnFG=?d{w5ws(a7wcmd^eqYYoZZ>_q2;Bv=$y(*P*;6kte}RPlZ5FMZwib z218%GupmhIGW1Y^wu&VVVZ?ZaboTYdnatAANyr|0aqEn7wSl+dEvRMxBSJM6K?DCL zZJ>eM7~-rE_rb>!5mOj~kV3TQ%o9JMGTN9c4^$*NiBLMJ2DbA@LTsYV=f-H&Y;A(m3SBC?PHZy=n5!%WG}ZJ!{BHrZW|4fXtRZLy zf@e;2R*4$#gc}CctJ6zVwe|XmX7ELC^AE9MqL0VhgzAi`+_Rhu4x76VVz|CMe?1ka zJ)C0*vv3~5?whthfo|C&D+FErEfI{cP^;8wBPEAkj@|l*-gD`r@9F9@QC-RFFFL0( zQ0FM48chKnF1edTF{_$9;2Hcg&D57D6*cfp8(CQR2ISA$`-HVMNPuCp$qxO6!F|cg zLq}(o@@BWb&W=Wm-n$@+rmwR4{7Pd)uJE1uZz=qWh6g2bv#-Dh0kZ$V8JK>djSfeX zT{4EQF0R$*HKfRvuU=KD>*`30zDhg1IV^2?Sb`V4B5lxaw0uem$yor6XF~2(u?MMI z_Y96SjVFWwZ?XodmL`6CGRkzyI6Y%udOQNxAlVf!Z_Ll7m@L|`864q5yNQh(le;o- zDSC{@lOR0MPD%RU3Nc*CVSt5=rd4zyI{IQ^+`zdhlT-L9@#tpPG7y~!3aonf`Hp4; z@-Dk_&PM3$jFvR_F0aZt)?0X4zTbUpQEv&$`+4PdBjsWz#;b66lS-BTL*+rTEZJ8y zm26Wm^d8!j!XjO2=T#0^I6wJ?WZGW~O~0R6sl<9D_e-pW)TEgBB?aEEPH@bH`?~S! z7AZxKM~MT;JcVStf$0(87hz4i99z-qc3H(OJ-Ly^Q5U*2^Hh%QYfpXlBJoytBrr%IO zg$JMnT?Ei-YY}E~@F~)d#*C{-QWe~YU@Kard!&%ebS)*X4ri|&Y^fwBBC&h5@~3=9>L-Bgwn|l<;+fLZ zZ=@klhguO)4VoYC(dcbIg}$`ba9DB9!bLmX3<2}6Zj+YoZtrQti?6IQ zKtG)=f5mRoy>GqtL3~uj3?4&NNXDpn0zW>hea_Er08l4V!``yVCy*_Q-;6A+PMkT6;9<#0 z#~spa;_|v;ZzS3f`M&=!LH5ZSpa@{vDU((<w#uS zMX!eCr-X;hg{7ik1~jBXTlygv9G=`>P}u)XTp;~mvAg&1?gRcWdK^=740QT%v9nul zHkONy2yRnQF5et_2mon71gX0^!E4;`M)vpN8C}sbP<(uF6R}4gUt&*zL^BbRD=%U6 zwl2?KU15V{ayO%s;Y*cw0pWWba2QV`CB(UV9i2TWb=$?5JU+TspVK+9Xbu>xyJ}#s zIuxh`^aWL3qADPY{Ge3!YJ*dCZn_^L3it?GUBATO(%KZH9DvCD%j@LZv?*Qi1c5_X zxCyLfdW~x$YcUvCYHId!FJ%8WjFeF~B+B!ENkwhMCqZpHf4WuBpcrz4jn396g?RYk z;_;Ig-{0BW+6L&C+#+{pcWdX%Jm?hHCDBA2Q8xkPG9V>z-Y}UK3nQyUf|P8O&bQKq zvK@j*hUT8?4Jk9_a5RCFxOBMRi}->-oM+js-P{Z^>x(uL`>i4B16Izr`!{1xN4E8C2tJ>U~%wdVD^J2FnZLzO)bdQLT<0R)nB)`!)A^l z_G=LK>`sN1Mn0~FujCb%2+>6YW;~)HeC9hp6`k{=US#!gY(8Qg++VKkIb+Wj-&~(b z!&Lku;gC@o_zyLrZWpj2SD_?5Mwwju#YQfBsoUXQMMFMz_f99c zx^1jTt71QQ?hR?NEIz!ElJ~amjdaZ63_{@GNeBS)=L{yo*FJk~{gOZFpCK^%rvAR* z=QxU&I6Rvj_+JvVO@npG?VV*-hP2bQG!cN&k*z^inJUhjC~HbZOw^lYe()bUKwO$Q zzo8_z*c~Kc$03!)LV1e(6S5Kqhf^Tcs*^D0+x7!#kqyI^qW&JZE!CjAX5gcmkGW*J z)xV@SG+U(vb_(3NQXj4IgC`GFK#wjC6G;cgXNE2Rts@d~6J*F=e)S(;Z*Se5^5%pm z?RNJFs!!kqZFl7BE1~u*!vs*hueuvUa2MVxHLs8YrxzwGe7aP>V%2fRYrRZL;yMZ> z@6I;kKnQ6n*e-hIB*yNED64S*HEUoBaV-vu0fI49f?(OHHIIuGLx99R$^09>4as7d zmU^uL8{*EKzh`<5=MeWJa@kPG3}$*2TMREc{jmHvz7I)aSEe1-qS4&IWPli!Kw!5R zp-Ih<_!5i5I-kQJW~-EOO>Ul_4XdbcC$2Zb0=FCcYYg#hCU^gQp6LffY72qI%vC2S6R^tywpB52o3uvqD)28v?@ z-o>PP0XIw;MVuk&rkCCgD-OzT(dY_6hYctGVr^*D5#8|28|@FTDV@@d zTD`b47k?=frt&P%Kym`-5FV{J@EQ-9PHZj)rdLH~LMo7U{Y$Q#;qlq^$1 z-?{vRa>7jr!RTGwvhe+c*ja|miT-ZY18|~g^Z-EGLIh{(W%mpe7>DCe&E~xqU(U8vNEQVr=yvz>-|2k) zlNHUTY`xsrqg54GQLXO9)Pmy9p%c{X)gu;R>!b)kN7lC-~+$59-5v<=uJBFaKgsO0$&}-ts3rjUk z-tRcwAOSG$>@XuXsoSzYFUe*5MrK_lo%5_mZ=g}|oLuW{ze}2!05CZ5LfYC*R-DmW zsAJWy`~7B7aT|w&nVJv@5tb`aE|1XM+kYp1NngwDcqjU(iPCjjoI@gC~ zSL93J%%<=x>g*PJ4D0;Vh@i=exFUNu!J1K3FqTI!H3A~Kg}`drDOwfO3!Fp&`asd6 zOlB&Rx-K9XvRJ13;0!AqjS0k2X)tI+qcIqqhEI4W5%w4oP-t{O5lxWQhSOl$cM>+| zry{j9=%^g(UE7!-abaq|#>t3jIQOOs@ncd}{J6XL>HX`A7d5_{HQ!dCS6hjg~L2CK1>~blJH1JLkv^vd^2Q4{g$F7 z7)?U~hTe}o6SF>Iaq(U~_LF z5>jnVqmN~sg~b}6^`RtUzXCx2=0C(Z@{{60mQuVn+2UJ_p^AFvM|v!uc^LGtyS05A zJrxx`d$$))Up&5ZPbTP#gGYCM+o@`@@nk3ahwhwvbbM5|*TigF5{Hh}AtLExIyi-#vOaA4D(U(^*iHV%Fh$CRl`=v<9TZXoCx@#38jx4YWG$Z5_Gy@IKn|mF zsGuUl+)8J_w-M-Iu9&YG%E@lnkA*5xt_E&}CN=6KL7Dv4+*HpagW!$6 zppE=9lyZ-Ei-W;&WO=cPoD)98UOBf&lEk!&Hz z8wr0NdkTgXE(Yz7GO z5i?PB2Xqy#syCn=RdC20ALu^a5(P3PElWOHXA}bEMpU>qMBw4_{qm(Q!gGli&rR?c zgw>TugL;(MJ-Il8OK%HLJ{_@`KFUWOGn#rgJVw3x*|fp~zezR3aiLbg<7B3{Zj?eE zZG}?kBKC+K2zR2O;DhM>^D@PwGPTHA)KVpSN7+~Q(r1&1U--G<$?MRpE!0+f_*9tE zI~YOi>A-oIvNptFOk$N@qJ&WyxWBv8b%YrcccIJFvS7Sfq*k}`Xf*6cp(~yKNcGZP zmLhq9t&(FR97(4*?x`l1j@I4UJEV)ZclBTBGS=AJzRQ`nOny86z9SZ$7*0Ti)gHE$ z0{a6Q$>Uvk3c-fmGrcs$tbX^3S+qQgP5qauFKPZtw+9r~&*fW}uJG+$mBz`tn4GuI zZ0?TvHwK~R5G?zxN_Y9$$u5XrVE4s9pez{xTGtW}fderR4yh%I?6NSetNXt9Vvg7aCB>GFC*|2SaL|ljr|rlBkUXG3t`|B)H3{+|qu~xrch3 zgRMO*emyzIMxZ;NY=sa(PqGGNf?*uFbMoHRxi3(HUhjlfZlS_O0H|w9lqI-_b@11jDi{FJ{@%9RrpI*uTw8Q9RHtD`5(OCxk1zjlX+i9X zoy%14&Su&D#J`aPDGt>HY4_^zQX-6H2img{1CshVsvA=$@9Ttg2e5F+X$++g0TFgX zciX~c3nzCzo=E3D136acdaZq^iGcd$&*0{Qjdw2|Bh|G71wmpOIFlKKWQ> z33u5>D^Ym4C;MGIv%mOv?h{UHUfiNTZww+z!5f)*-EX^zY!R2HIhG54#0X>poY^4nvS4q+zcI(ywg*!&|!$d3HzqR!urM@ zJ--Vl99ZLuF0bFxp=LaVh*z)=t!?~i!xPkHIyDTF?QrdGD$0iH9@{CyBhRd}>y)pE_NtwIQ4c>A3K+Ma!8Y#e&h;B*mJEWUZ9+l$YbJMsEl zo(`fKc7`?_D8|vOAaR`xPa;pCVK~7JEvmy@q`obY89~_O8h{AjK{76s(I?0(tgNUf z7=TJvwnsoHuhtZCC6*K%`h666Z;FfmgGic=Xaln`YY5cToi&404h;{t#C>lwb!?DC zkw;V)dWa!Zt#fYyw8p^HBSbez1~Yp(q8F*-E`hv;@z4$Ogi=rA!DpRIr$mT^>NZV8 zYFrrtD(zp>NU}RJO!^_dPmcjyXy`u~N|~)87N9BvxIBH062E%$F85|=h`C)Zo`3)B z|MxnnmDWk(tj6$4c;UHp8Z5rK;8Q&PC`F5FTGf^r2C_Lr8^|Gur&$+h>kh;2onjB# zc%e0C4nkjXvTy2C4*+&NuE>2U zBqpcV7EkCF?wv#E;RB#?|z1|9imY12gwuz9?UL=fg2KzDsPpM^w z{mGj(sWsXxJF55xejACMZLwLQT{NSE$6B668J)O{QcuV-@E*cz&@Y3^tf=7l(g0!ZkB?3Zd3n<7=;?Hn{B#HrZ0@H~ zJb)lNe|^r4z33hNcH>2iUOK|HG(~2P?_ZXSH>A9{kn*33NY(X)A(cw#B`9E4f+OEIxF{RHy=bBH^Dz z^ire0)9abp&pMOv>?iS~+zF9Lh(}2;qEfA}Kk+&r2b|;qd8+vJ>jh@U$+E)Sw{(i0 zcFpkHd}I3rI{BrXk|^n85&qMD&>s1kAJ!jXt8Coa;F0#(7~5rq_PKb6OyZY z{R60|y`W&_)W@5T+Q$W9+I)HRUZ>U&$BjI|T^Lc^7>9R^J9WoiKbeN}XA3>5x{RjZqi&U=IvLB5{s%dJ%w8M@4`k zS&y}auMp_yw;~Jrc2Ismj92MZaoPx602FTa7X_)Qf{m`EHipS;BPbHpysE}>H=pfs z#cA>ctW?ur5E3RHA4FcVJ!C*O4ERMIw|O1W97WQRGxhcp`ZdERr6GR|Cvbc(>ao$9 zn5@T^g6sQXVHE}}#Q@@lMqBT2GlH~;JoRI^;VuO))Ct~yehaHq?o`%QX6{Nw(sV!< zSrB`+I#OAXVe{>|H6f9qPGiChx-=osrHU+z3F_}LgO6xo4I7z*xvZsjN*E@c`7jC? zExUMs{gR{3HE|%Ra8mMY3)Izu{1Zy21kyVbh1CiYFd;ofHE<_O>id~VgRJ`SVe91Z za_jn#ixQ8nyWvErwCo5;xB1u3xJRle z-z%`9>guY3{2?tvkwh~YP3}bA!5BK0Q|Qe+Wo65>`T*G(q-?^$66R)K=K~~MT06PX zluiS$(V7m~NHRwQM7D|xowYD{f2}wKx)8=5gg`|?D(DV{yr*TxC98RJZ@&KvpytR-MpRe8?H)eKYx z%iK&77mq{GFV%qrQ}fvFEb}9B^@1Pu!9@oO*3#B%D{S9uj%gsM_3|w`@n{> zu$Z+iqj?74nxRW z(GS)w{Eh;LziHvga*qb-Uz8<}uFy8rN(Dl)d>JTl^KiF|2V4_mQgIkyJX-LE;+GS` zDFitM>Br^QryIC1yz#zsf!z-&tc5$!5wRra`Ilntn z`SRzY0k|qK!nR!_CV-9##Te@7g$h>uHMrGHrxI}7ny#W5EUdQzp>Dtk=!i&AB!}d$ zX$y)NO8&R;t1>!fJF$80?wC{&oDEfUBn3I%V@fXLW}x z!&Tek{aw6xZ#r0Yc=aFf_g3K1DAUNU>U(``Ad-H|C7p`;`|8aeeTG~`y^86=4iGK25POrY&_%E-ozOoe)z3J_){*X07)!^9gF8T7a{)PZ;kt+x(R51v%Qa_h*+fZ5++`1j6kg8g zJ-p=5s;ZN4e;{kjIjJ66HeZ{4lG5K?GweHp-XU+;xK6@HU%N5TsDz}fEh{+C1KOn*k`Y-j(k zMRikJ#Obv?Un)e9+T{v=RQ6WN!Q0qJzJAIWjT@*k{M@AzvQ=WSKDX+@q~&9G#x4&0+04f@nxwMsbz^Z8d1K$CQ8y+G}c=p$VEvQ`xxb17<9_5T%o= zTCy}k_v{o3iM0bO*S@SHa?qGwCz2yF)Z_Is0BK`=PG`vH#?c0cM`Q%<+gqn*v;}= z_quV}UMLr0M8d~=%A%SY?ic2e1($wedk49yvkCb{g$D&@X^?P=_T#-$)Mj{RAcDh+ zD@77%4SabyoIS!pzD})FZt=SJ6E{fN`609%=;aL|!P5Zv%k!U}eUnb8q2ULpzc~KHsi?W?y3!p!ZeJoXW0*ky=jMhw2viKWU?}9wn7LL4NlXM)& z;gZ9IY;qM%dh$6a5tptavM90IprIZ(SSZ$g@L1J zxx_nF2{q_$ZcRSe^T$PC24IVV~Nj~|VzHLqz=jNhu&S{w;$4KIwE zqI0)1D-YhG+gtplqzszq{Ym7@KY?NsoAg*0PX>#*@WN~4&?(xA@E+GVoV?<`axzro z*!#uqKBmaEQg3O(6}FKl@R>*sP$?W!9?UU-W-y(ML zr#GD5+TEq;yt2V~3q+r9)tkJt1W*r%^BrdhHELkmXA*5aWZ1@1euL8YI*#_v3C$*> zkb*U%mHPWj3x+pDomhp@wClrJ5tS}W>0RPF@smSTNfkLnXl#k# zYs~jy9$L8qftkKDY{sGFFF52bL+o;>-DA-u`Fsm>*xip?1eEK6u#&-V`#8N@n+4ei zeT1Mml|_q>F<4PvCwHi?WaPa0X!^1tY>9`xgRPgZQmyPaY9n;=m=|vlhEbb8RH?C zdGXP%o%hK6F*%Bif2N942i6@E)U`_P$qaEtAlOU&fY~&7CSC-o_EzS*g*~)0KueF3 zdK%(RaM_uW++?}%|D$+a=tIQ*%yn6MX{2d!dQivVu(AX?Pz<2vn-eI3mte`hqI@ST z_hD#(j;T;1z{O(95kfX3q1=ZBiba7g}TdEzpP(xXKcPK)$4chmFJx4KV0()yiErIu>j# z)S<3$z;V|(ep%FIC8mLYU`st2&i-H24r<{Lbyz!98B<>^ecpG#JohK6iWJVs=q|7IpYt+77HdcffPq@e#W)lt`ZKrd>$R%VIKk%iGMSZOm1=hiC?2u$agtfXjbDr6@vQI;^TDTr_zH2|Y-HMYJ4 zm1CurBO@KBavY-1ab#gq?u>;*~@U`?RV$<5;}qx zNk7zJ-(qFk2UMJBBf<=l*Mbg}$E#oMF0odZih#k=hd^bs}=wk&4&dqpGa+ocp? zv{GQ}OKnMtU|NOwreshXPHZ3Cs2$L6HVWmT5JsLx+uPRSiP{5OL3vY`;}UJ|S0LU7 zYY^rPL#aHo);`4GuM(+cJ)`Y)SA(N51|{r+2<)`X9tKjcxEl{-1j_X@DF!77(#2{1 z(<|yhGnFH18#I0yFt*>&*jDHK#;ws;$H3SuYu^_`+Es^24gq;Q9Zvo|fmP1l9FR@F zqb~G$#YmN!2#yKp;kDj<)GWsG!-VuyJk4vd*bK+RD^?&v3&nw|-BU#!sS(n6w*ZfL zfS>|d%OD|m*~2EJU(&1Xx&Z=n1-T_~2pDmFodYKFWq2gbZ^_wN(mQ0L^zqzOz9MFg zY0@laLoE|Fz0tA`13VZiFe5uF5$4S)Fej;lpz)D&EMBR|aG;L@SA6^vY?D>j?Op%{ zZ1x=bP2oCzvv>cClw@8$)s`4m9+|QVHo!RyC)G=@%XIM0GXQ;9Z3c;C%VCtE>{3K= zGv7PCY1;e55CunMM^4Y_%~r+_Mfa1G>lIghP@)56`ixzdIBZ_lNZ9iRQC3|zI|>Um zs;LnVMt*3D@DF276V|F2pJ9(NrU-{zfp=zD8Mk?bN(-j{SY3jnJtk!i!^_k*@PE!U zm?$;7hGn`CMmT$$p$}69)v-v8aYt;ytnFpObA~HpTfV!^Ts?azULmn6jFeNCOY}^n zPfZ}1y8xh=HJjd%j(n@4UT5F=x0fiY3l7r@93S|WpH)RHTYGtd+a-Y>T|-gd8YJLV zk~MNVjE>4rn9S(}I{kP@*HnJQC8w67YS}F+a~~o$b!T#3!8LboV3~qf!c6Sr=LZ}Y z%RDxu%@UD}t0?$#t`l?bk}S8>c5TUd9K+sBOlgc(Zqb6r-UXH2N-<4L=}_Y&PZg#K zB$usTz$tttGYPU0J8>CKd2Sq@g@j*QkCi#4P3Q-8<7HH&fo+|dPsU#$Eig+B?;96lm(n8UTmtiUE_u!k+>c}#M8_*b7khBv4%GQle z25hOQ;d7Hijx`f6^s7lIoih-;teX}he4XAPW-5a;6pQ1GgyRsLK|0DOp)H+KStYD= z%kJ0nQ+l78&_F)PqQs@+?Wkyne`B@zv&{;XSV()xnDj}r^>Yk8?*RnV*{(+vM#9iC zBe5$IzI+=iH4>X?7i_sJ4gaa-Z(3Vxd8J?mNmu}rEy7hr?$)72*&WT^31JD(D#>uq z@g(oG;uu9RCRR>^&QYKOD%2QpJPf!XpZ_4XLmUnm@PsSQ&WZO2TWu0NXHb+~ zwPoB0lN_3+)>_(%C1ohPll$RK5k|1l>bE=u3E%cA-RsD})8r}h45O+b(4U*iv(j#)-3;X(>lJ;N^ ze(!Z$!Kj@^$S>VxMYm`M6VdIrm=T;`&TkV}EE=nwL=Y)F=At zIfEU+i5b>s=yh1&`0UpcI;a#YlHQlD6EL37$iI1mne6xsOZBiU2rDVw2-1aOyO$Yp z4rT=ePAH@dd0A8n<{(Xjk>oiQTOmn(uxeH{qVVw*t;YhqQeRhzq(CS6W$c=!=y|jH zCtsbM5?VEeCd}Xfy(sh}n@W|Ld5V9do=p}0X~Ivo7M8pi6VgP2DI$+ppsdOAGInBk z+HO4K@?+UbO7zEO1`WI-CaqPl9J~@(JUJU=F80Ch;!#|FwfHk*M2;5E&zLcScOx z$ThVi>QSv0H1*2MIKLzdE~C;WQq;i_$s5JJmt<7nn5PQb#>)8%M*t98sxm? zWh_9Q1C&jqS`x?*g)hPezC}1RU*)IopZ>So)U`>R;5{yWMnvGd*c>$^;X`I2A^Z^= zaKFN0V{40Rvm9d7;VP#?_X-vQ@06$^am(3znLve7QWR+)BL-fU4#{FtRr73#V61X* z2aG7eVekVhk@+#I5I9^E{MiT+S)gAkSWF^D4`Ukm*8+9 zk6VEja26xKbygP}$)x8IHk>C&c(0VMS7=JgA6*5|LR`1Uo^2bXr-~d0!^bKw7L+ z!SNIgcAb;0%}Xsk&)%J9>wJKXSjSd)pWNp|W@l(NSp27OI+2NH zXX=RfzynaVi*im**%32b`b_2*2VB7^w*yqQ!Wz9#dyd>yIL*A(iBp zYpVwb&!~-474yOQ;u%t0H^pm1W(F@p284JZZ%8C()L9RH z49Udx-xBf$7({rt!|tJjzH=z~CQvgv-B-is)?nd$RoGx01$~(3ufU^_?{~@0ttP6? zkhOdrs3l3znKdVkLv+}FX%Oex1fz)wd28IQ6NHjEMWiYDB=^;;I6&j(7r*T8|JA^G zjmWlY2zfRWv5+t)`VTP^$A%p3(l*J%O=pxfrTh77KCoj29Xfh@4l#6t?M(U$-KZ z{l&AaWU2_30h#F&*?(;)LKr0NQjXSSHqHx3Yb{9<3njfI>5sgO!6#1^oEbst{zN>` zy)N`Bb`S6zdjm}>;xTfb6O7`*_Dxv%)(YkD=euP^_6%suHju7ReNvXPTrL^9JOev# zm6iVz7y~4N8*yuj%3`9K#aP7^kj9b4SN0QdOCyAD;zzB=NiL96CZG#-o6>L`?zSy` za{^ChJx_!fQ;&akQ|r$C?R!I0tNx6p*1fy1n5>-+61xYHy~+yOEZh!&c!T7MWUS|1 z@(;GCx~qhd=*=b!>_XsEAq1qm4dXtS3RFa(1Yt6%vywI$DkJ-yPy+;#ByIv!kZ71W z5Qb9@f+YS!BU>12kP?r4z>9E5TGUPN>G`3v80zF!#NOq3U0-CHPkAYqq9q>m9R zA^XDEdU}LYmS$EG+LPb#_JoqrZ8Bcu?Ela9&b2A7V@uP2Wlzn;s7D19cd(@~LP){_ z!~j0-(~dLUB`%^YMA2L<;hFij^QogF=0ivH=Xu_DW#-Ne$QI+{i0O!-`&d-5cjn5K z>%La5%n{boi~@4EEi9UDCrUg~)HWoN>O&f87A(r> zKv}67O|CSEGU7Z=>kl^n;BJ~%Un%JK4>Bi4{0`!-Fe~_fC7s`4L&mvxFS8w{TCY7_ z6pg;B_NMss^6;#3>rCvp`?I4+AWYjRB)~-QnM43bUWks2Z-x7Vcr%Dr1;{#4|q$|!<-b^i%t~fT$N+OXW=ax4im$YLefJt zg)D{ve@%%4s39_oZEbMW3~Iu>eCyGSw65V336T)HxMqM@lIfOeZGExr8o~wK^du3` zx-%&RV}e9X?ikdFU8;V7Ae3V7tU%lyJekh!7dp`LlvxlBq}o@g5%;|Fs)LRZ%C##Y zPQZai<{jaDuW`CNQ#qZ?*XqQBlPgoZ=|rG<2UNFdo(EgR5L$v0^n1lslq_%dCKg#OVT^g1slCSybPE<;U z_Ep+`VlSku$8deYpxi!|?5QftaTso8NyQ;a3g;=r#u$)E-y*9dS7bt2CS_JOLF!!NVU^;L~IeIO3pUmt0ztfq59)WqPii4866F+BilC^M4OiZ|82H_DX9Ta(_R39lyYDX-z`n|;| zq9}{UHelNfU9?~+!Ce?2O&q|*@FNVF67$rSoX43C3T7>Z{FOkAreZ`1C{a_3 z51(M*sF}lMt(}w6zt2!VQJ);ND>ei`AHy1Raq0Pq3(K%;Iss4hwZG&Jdcxm`Z7)4- zdZ~AJc^e0Hi~P--){*U56gzVso1qh6X=?Gn+oPK?Tdw8NvLanR%m?v{e4~7%KiyU! zLjn=8$RD0_7>nQ)%h@9UBT!dU+7TYw329l3OHl60D^qx&pN?F%i{$?RK`P{*Y<7_b z!;5qzf;c)Mctie--l+7IH3WE+2f2rtGty-umXvEiEg?7!r%0^w3^(Fa!K=j%uiZEt zCVIC0!Z>qiW^@o(%2_Oh5=dk47(w3W&I#loZ9G_-oIQ8>$q;RLUx0n`d5NI6K$XY;A0XDA+zBm8xr2f6?4@Q7$w49Ts3h|Hc#X9paMEak?+>L5wdxUj3`szKt0$_Bm#Ig z&3(ou<}4fHAsx09)rGRjsu6z?*Uc7fU-qv%NqLM)9N4A|pJ2qfG;o`g27QP7G{d2u zmI$b1qT2QJ`&z9dK_18$FS8VfS)7O%NUgMpzOgj5&=iT8IipD#rXlh6+ie4Wt&7Qysv z{8n6k#;@OvPpBe5*t|!+f5-XYzCIj`lehHpg3^u0%?`J+o>C^aMQjDZJ^avr2KUi5 z@YV1=IAZY45t?oFV$^KX#!+c%gX1M_9juMVT#Pr5Q=&aLtCr!>wg-ay*j#4#S3UeJvo7qGx$18n(xF*7=_}Gj`QI4wC|^ITr=mFaoQ*3lyyn3ZN>o6{ zogb6inrN3J@hM`fhn{f`@(i2rKL1)e}DKzmOPef!v{ocJu5S z?IPvV{n=7)paR|2kfWHtjK+Abhmg*=em3;L7KNgT{Po8zoqSxQttPQ54vKbuUZOb2 zYL6hFGQlpX?z3j?mmBKLE{2`Qn`f%g+TpBlZo{MDff*UUI>`lMBzo!>zJri2(6HS% z0?O|wH34Ue4^}^W2ji=&W=H3pLPY9ss~Q$%Ayeq~&zp~M)h-gGz;Chg>ge#4O}+i} z<~1Emo88ebzqA3Wm$;#1bS_RuC;9G?@>+n3T*7&)Nb2>NNnedmuY{>vKc0SXcseF; zS72H_J^I88=RAMsgV1Zu9|bXmnUVzdJsGBVI#sac4`tkhPO*a!h+C>_)W=Q~zs7oGe29w0>Ww;7WpY zk8>LZBoq5jXU%Jp>bEzK>K8=sI&a_;wc8<79gXw`!QERwLY4Sq8*6QN!|kADqD1+V z&1*>iio8|z6KbW|lZiLHu3oWX*&J@F1cM-4^_vNPaKat9{Idwmf6)iNzX{D)i;18y#;c@eQd=CcAk{)ffrjuEocfb}^K^ zXp3rGcp4>wNN8mv&qABi|W`8&OT(F=Gy;r2++&jyTW}oTK*3CXS3g*ASWH< zw9?|TngeMwbYD*Z?;rtmwv)<_KVvt@C%~i{H#dC9-U7QRzI=%Val`Fq*2i(ss-gE7 z^@Ooc%Qe+3P^Bx9jw za~V~~$Ltg*;jyEnrqYJOaz~lnVtYM85{tJjvqGs@S(Pw+j2x51-yD8a@AWF6+ogwW zZekqC$|nMeaK~a5{@+DJKchqYA(#z~;r3>C=ka*R9hvpAZ-o1vvg=dy<(rB_#S|~% zAD25E_IYI0S86m^mDlGigd*Y74_FEuq3Q1t%;yH!$X#pWz8k%}9DWSqesy$qF$%Hx z;)1~7&HGM>^ow1!ndyb4I%~>DXH9Jw##Cf5a#qUt(b6~x8`ipUqMV?d5*Lpk)KU?N z%ci3Z4KFJGSrMM1P|D|v+C7L$S4YPwL%)ayPNzrF!~Xk^gTJuR+1SF+o_yT&_J>sU zB~Y3T=O76s6sfeC`gUJ(;|o`{c^pZ+!Q#TgW4j9{&0u+XJ`0B*XPD#cJsim$nKS}; z!5kRtLmB)0#-~jr6=l&7E+0hJXmNxOANF;c<|f3H=6F77DtQKF*(Suo?`g-2H~4aV zPRLd9gYfqzbU{0&Wc0fzux3srR^?cMEX`6YsaTTVe#8pDc+&@Svz>|sK5Ek|jLa5{ z%>D%<^g{h%`kO~^(>_b>eSfB6UkYN`rc}F{kL4r$L5ue;uIb?*Q%1 zX3y6+pB6r4uf3WcT};6sGAZ@Sj|8HqWM*>uK|8m!(AhaY2AJFMUk0-!=Y>09LeskP z(4u@da7&aYi4b{f-WRl0qqqQ%Vh)7*TxRm zgm^0eZgOFF9QNc6iOJy&qOL_F}1S z(p7lGzo^w~JIV|0RaX=PsfmMfFv^PRaj%*9c`!LoYqEX%C-^komQCr(2W9i2b}E(` zfF+Z|I2F%Km;D)_9&6S%Nhu_NO?6vd5_p1$kdqG+J<}ZtxilRTvRz=7?XCP7pif^B zcoNLuP3S}DINAby9SSnJ>+FBzSij#}-(KHu$FAt+i#c*I-BojZ3<9rY`qE;HK~&vq z+5wKy?r3cRyMt@R{ZOaq^`^I-PN8w}!)4ngD)0C$ZPzR>E<$@pZ!bt)O1v$#tj}c^ zkfAeQuOX_QW7QL%muZ}B$fZ#s#aguNb73t4ElV$aONBq$=gpkkoS9$UTie)Z#EK8u z^UvJZ(Mm_o^R;@XS|R#z`-n8*W4YtPBznA6>OF~ybO8K?PAPp)_X#pQ*bT4tw>EF1 zaFp};?N#J05vF+F1UA-BqawJB412JOEZH?Yw^i6)NaAO;s*`Z zfoe;wpBuMy-sNICR|3PyGXA)kliHMr?8;yszCXG8aN2vS`-k=M7ECp+s$D_nv`~3l zh#l+_N*R^C+LcHRHhIC@K2t*w@PUREeFx- zF00DQVCDh4GFY7M;DC>}aL|HQ8Jjccg+0tOqHk!0dr7mE(zjJ|yXSWV>bB0$JZKLW zXX~4Aus3}Z4!ZSTdvgZq{{3EXv208w#MX#hk<@|T_sA{vo5lV!#iO~X4iD(8DbiI> zOAfT)Z&b%ID!EJGEbH{u?Y)iWZ)Ydx`jT8I96odTT`k3CknQSQf$->RuIz!zX>}K zt0e!1u$XKxEi!!l!3wZT)XV19kKdcQ_dUq4yvOhNy*PXCix^+!MSkbSrQ0*k-TUHP z^&-FD_u_ndacb=b)lZp1S!?y~{Qd7P}3Qd-M$0ujEE6(l{+cf#C(cav<|!9{gF-^Zkjx!hmnj;cSzJzHG=; zzP~fa@-)h)vI{D=X9lhL{D>OQ1HwLvFZ5pi9S4APvQqpjm!%uAln*W~GB-JUcb<7@ zcZ=$Zj%PK4y8P48*?aZn#Hrfhurc=szs2kd<2L74)=<|9&`mbI4Ii8m%PJGwau6Ix zeC>vb@k@woB8QTNlq%i#o^LmMQSSD*`FXOLVaLx2w9U--XXh&u0*ME+Dhku=aUa}? z4lpagsCvA-LR_`;A<;FN2ofTUk}AQ>&0Xn3>;ah0Qv9g-Y8kF0>^l_cqlpM#DRbtNu@3bS!iO`I)_z68 zhLd+^X}4b^G>07LLXG_Le#l<0;+))2O(xg4yW1q(OoBvI*>PPlNQ7nOjuqwmh%bF{ z@zj+jo}&5Q<&@UiS8#NBVXCuoZtyeKKJ%>BsM`&z4cb64mAaW-pUy)xY)tL$_LrCX za|;OGi5#wnjC6WW&6S`f47Exei!JcDzTaD$sx{Q!fzJ?g@{aP7(G_G}Ihf0m=f?Su zGuTpF2x4T8f`7$1@HtAhK85uDlsJ?wa9y9T-8uNHzIj3vnzsQ=-zGR+Bz(+?4jrXB zoje;)T^t`=>OX_o={o$Nk2Z+fC}-;(&tRZ+1tc7SEgNk0IaX+1gGs zzyP|PDvrIXaz8#M(Fd@uznSvpO_sfPS1+ zFk^VCn-?5m(N{93GL;e!#sw}->5adx&}5|XaWSE<|8wXJ4v zO{LUst@}(3-N5bbz*h@&o&P2Ky76cQvPQn+bnV@6Sm~2T+mrX9OJ5(vXR{!@jd#xQ z(aUQmFELmw^x(JocA3)X2m_b%vcliCX-ee?nyHuF3=g#@bZ=8JHQ#<} z3o&&HQ6@gpK%tD}dsFdyNzu6(d$FAs{a%!Wx0>?JRG)}?cZy@Z?*jPsvjcJ}x&}jn zIaPVv>RWxs;6A?kJe4QmUgbtq$_&8n`sYEJeXNw)`qjr^4%Jo0eej;VW3J38bKbGA zI;9&qzDad(>MDvMx2u?imNW}-!^17<5V87lUY?%m5IY|O+$t{BhVso z)0rMjAw>QW66nfSk-BdHuU*p?xQSO##hOge>4)KUc4n@_l{0ezC^zfm^knNV&!MS( zI^*}`^gk!~Uy$Tn(GrU@xJI)NWDl3mpwQMo4dr8ZWb6a>W3Hp*r{|KAzdy%9vx&;i zB{)!wT!ZpjaW!ZD{#c7Q8Ds4(TdqGy=-%H>qmG7zbw60Lb4E7#D>A#jic5BZr&j6U zzRI$rimXct7PBx{2MSg8Ute#I17ZI)*imKXc8 zb29{rzu#L;)4v#gT510CpqW^nTYl6m&5+Gl9L#%ybtMR^_?0Bn)p+GNLHaE!YLXk! z6eZ|Az3*GmdYb0DA<3U)#CdR}CFcXm5fupYk}%Zh`h)+vwXsjS!aY~jpHL24iJ;av zn4g=6jSo)9&W+!37KE;|sgKIq@Wb1S(cwGHt*zB&dS)<-gt=$gsES8~TbG)pg{7Ha zTlP=yzWq2m$-&&-)ADP*z*KdQg=zmL7KwLG%BKy+wQKU0id+0dpw;wM~Cl84%AB;crp5FPYT3l38W`91L z=CQaTCEVP&M*EliPViVHK{D8!OD3xFI~<|ZE0=Y>l_jpeEfEY~%-yJ3tLfDcQm>t&GQHby_9h){s-KPl z4u-x^k29@4@=IQZuEsiKMnxx^N!BmaTF~t3+Q~L9eaKsgxp@_ z7p&-fbne~@iV<)!Lj5Q{VBh@a67k$=LgmGblvDjM`ow+10Y-JS&+$uIL9h&pX565{ z2MRV;w^y4V2b}Ls1S1o^b^YCLbH!%8{*!jev*~j@$gLCJ@-x(TdR8I-@>GhJa@K`9 z3)<}93B_aFLDH7>z40xh)I8jN%8E^eZyzq-bqfL0Um{#7TIl~N1@_uDL!!?_JBN4R z*Bau-H>6_pD}D_2=oJ{Py?i()4r`>@+~FbhbIotZzvX73Xw7SeA?8c$-6X@t3YfR! zL)GTzSJR?m4GF(NE_gz{MBAKOxzLB8ZdfMZYe&hW=|lgX zBXI}t?FoZ+3hIVMB(|eVKq#5io)=Zvl{aN7 zh*?3LLfjD)|JwN?*c{CT*}0t)3G+gB<#p`9NUiLrqXGTGSIjA%$H=LA+qN(2w=2CA zY~t&ZBO26-l;30-jEb37XIGpPT~J9XPQ9gejA=+5CbjSbW!+kr@kK_hnNZ=Ent7zP z+`Zx+3>}f$P$kvav%QpYg> z6$nT?*#~S*jUhMlEDQ4pX}kND#L4=QVP$ct`D_K{+ZxyrHT_SGzj|e;3P-)HJogd0 z_dS5(DHF6<`N;J&Nz0@2)R9i7PYt4Vv+kEv^Yub4va7<=5AxY{k++@dWO!uS@gOvb zIy+R+bkV5Uev3Up6{QDc|A5MDYvl%h9>phOg{r=Q%qtZkR+Lkze*REU-~rl4?~%AQ zq3J<>b~F7Ku#>rv!7ZbH)@0}y7KOJUzyD`+)(dt%-Q|#*D2TP(K1b}e)8#HNnL-lm zs~^<9YcQ`eZWnts(+evz^D8rR&C9K*^WUVwN`DJI4P_kO_rl!D{L;$wQh6a0m>6KC z-Mxy!zb>@$WdGI1-rw)-?`~|r{QJH2oz-2+UG|cc==VSKSGKh~Nu`#j&JW{6Xnw*R zy+ZdKb(fu=p6)L%FHbE^Pfw>=CMPFl-Gpi7hxx`B`UB>t9(uaJcs~U6Pf{Z!gYawf ztIjqP?KS~`%e>{Fg$tMbXTb0mVY1Ke9{I4> z(cppfqzAIMR+`~6LS=U5mG84A8`KUea3X
    1Y3qCJ|9NW~NyKuEaMa&$|C1Q{bC zgkI4xhHY^F@>@Gw@20o}ATw^9tc)oxBX_KK>Bsbo7%+u@HtE6!Q{4em=;vIFXh}d( zmFU3D+HSqJf-ZnIA|)3rL2VdTJATSZ2<$)2<>6RRx(PsZN}iI#r}SG56eS_jjxM?5 z4(-uh)l!>EP+3&0na%`3A;5X`N!zQ$r-N1EDo-u3sfhzRp&E*%C|f>)EaCE0JCfJo z(F0_yfZM#&!50xsIR!u~bG3&@mwD=0HR|&~!XgJ(=yjf@NUNuGB}c@{I#L7B^9Jf| zC?TQ+;!KQ}6iVbTaXD4n{}pE``Wsm6>DltKPQlxcsFY?~>{mLfYd*KXEEkV)Ma?yu z$GBu~zgPh-%~xseKA#kwHT*`4HEUG2L%(PesKOVGI$XzWXV@%_JIW=QM`w0*P1eS- z`y6krl#aQcSr)M8j2#u>FJ&VwL(*AUkNORItaA_KnKMSpKS;RHzGHEbhd9nQ_ zj7|^ot8GfO+f= z;MLW0No+#X*_dG_x`Kgv+Exhp#&Ga1J}K?WThI+}@Qw+M#reK$FTuL@40#}B#!ig2 zb}W`8KH5>-Fc8aC8Vam&uKAq)Y_>Z1mH||JVfZmD=BOXmZM4G6CE1uzEDi&#OUf8< zc<+nZ>odpun><<)HpR@qHl>#~Oy{a%)rr-KT zAhoYs*QZyb?A&)>s*d}*98P^NAHm&59UMfXAj@E_Ie5N~G(c=n159$p7OIiAy0`e% z(g8ius6erx;}o$vcEQuARaA!VYsZr>D)aXu)w8Rq%rz$wgvAl3do{cFFD^Pc=2Y47 zk^8z!zoD8GLcw|TrbnM8kCW{v-Aeb?B=);E-JB`otRgXAj;QMsxzGxkbs+2QEC3*0 zf_~IZv~on)bZX$>R_nlsGpl9cS!gosQuZizjcO>#8jnKTyQ9PL2gwGJgDiUZ_zWzx zW_`S?Hn72xE%S#8(G@s?-_2yIQ7T>iRSouWsMMFPET)iZ$dPl*V9w%W})MbIDZOni)AEAyM z$19T3&n0*!oA1-@@zwiz&1!mFtokx_k_(zF4HC9Y@Dprm?I?^u^Tl!XW)`?6fGdk@ zSnu~rHc4hw6lyq8(^MgFiLVq(F70rUvZRr)qa{>oXt~P>PVzum3DU_;o(TF}wMM*S zHY>aNEBsUG{0=1n<&!Ag%y{lKy_H@w_?zb&FDYW`aT{y;JrSL8m-m^ZB(@(Us0{#z zlv23Ky=51;%oNuWq1ThYE_+s+=9jsCIHY~su(}f=@Hpai5r3hzP7y${6UZs770wso zQrJG`hyb?M3nX<~*zetUsbuE{Y^-M6zNm3&xX{rz5qrq?P*UQ!{s|^&54dK8| z$%~RXf)?f*Dtn!P&%O4W-j&*uRQfC^x;9p%GYgeWK4>lXMhBBHO_Bn^<3x{TK}xKE zu>@B!hYWyY44iEr(k~F4D{x@F%EI1`bSqG+q}O(3X!Cd7-$V9U*wX8Xwme7)LCB6$ zd5A557#Fui!eMPUG`Bx6S}kOwyrhN6;!LIj7?oy=WjPsE_)459%1Jr7E@~5OKUiT? zf5O9A&;W(xHkY!nswBQbjT>;lBGS>SYGbQX*EvGrx#dea2G@eF5FFebW{%;vf#YEm z>HiFUI{kNkOWIl%KK&^Sh>Qnp-BW%(OK9HIh>~WP`(x_U7={Bk&YpJKbRG@dZ59y zNU2aai!vc^zOXP!^7~+jDP^XWVdzYmW5t1(&YW4Dl!MLHMH~p^6xx6&v!aNQt5}JN zF`e6c8}c0mx}TD$h)qn~d&k4I@N&>Qllb)+0iIyK+kZ2ptS0vqhr+rWYO6kCxlxDG z{WC1!AxbbXNil<*ILtc)mN9(QH`n)S8t$a-TCJm^%7OqW>A4u;guS;A&3lSCcdkq3S_EPRo zw$6n!8^d$*s4vD`*_%4-pCV$$I%H5n9VPDHa1+#5=~AB-pKFFcA^_ zZmlmb>Z>53+YogyhH7O%tyRRT1AC|!k~fhUrGsx9c4|F8R}9{Dn(Uouasgqpz4!n| zVK#G9{7G%<32n)vCpaVqi=a;0nhf^768f>p9>uYADFf=Qb+S?~I^b{hf_kPrDRv%wGkMQQNO2Q zdSA0eN%CAi`A;;m;Iq_YKZ3q$H$m|v9e~4CH()~y@Mzw5YhyD|S!TDkZ0uh-$tw{stI*`ZDFqW2nvf0^GL-a z)=gmSZVDb|hpJGUHkN3Y!H5t>)>g?Mv+658*{|?Vab01~T2UXuS#^q7ng%foP@6*x#2OWBb<9p`OPMTXq4HWyKD-nfEVUjz~cSLs4y@qix zH#x_(a(6v^hr279_a@=DCCO9VI*(FGO9`{+PD_@U&FBj9?t0m>RefVMFDYr6oY|pw zaB_Y2{^$?^m$^Nqx+?2o0kOg`SU>Vbi(QD>0nMIY9$g=f1+mgCRcE2@%@Mz9@jmf%Rx7fQ^jZ`zF{N8u!o6r z4t9SJWRsx$lnO*7dl*t=&LG3Q9_TYGFnR?D&*>_~6e$}0VrfVb#nr)NeLtnAHv0=4 zv=>4*0W5RPi7{OV!EGooZ|4?z`PdX^Wyi6g0bzM`fuSG4HrC>B1HwnXk+GjB(^x{F z;>Tv+*h|wZLon!67uWKXG~Rq&W%eSady=gFV)IFz#;cRcx$(FW_r- ZxlgJ|-`K z+sWCwB8D4^F7!o;XS3Pz%e~CPsNREHXINlv8&6i|@>p)(dY334<^I*^MpO1xrp zrptK^jrZQQPH(x7isYfVl)v(Z%6skwPX>ST_Y~9jI5}u3JQ8Vw6gu8O3!f0;NJn`i z|IOo=xH_*M9?@O+#(Q+E%3QQ*l(IQU7{tmFJrS^#N7ZgqP4E# zi$w>mlZ(rp3)Yf@QFSEpw(gH;q!m>{mZW=Iiu(beS;pITidp1qcw1oygl5VIQ0~1= zb{aMIiINN)=XtV7_rRGpXTS0j>Qy9*_o$owQG(W2{FSYg2kYITiA_4JCiF&#hG>S` zOvp4(mjq$slzahJfU2|`3n%rm5k{v;tHM#Q+j^Fxej!zalMtSwF|XHcB*%%v%G<10i}~}#NdHXRD3CtiIkT3b?vw6@>|=hiF8Az( zlP|`ib^87PsfG#X_irX}d3(B9BoD8G_zz7Oc^;(xn;mB6_jRf#Vwzs_Km2yTSZ)2Q z@%xn9zVp7veqyX^+hVRe1L&!CCEB9)VJ6RCu;M4ZRAJkXa@zJSL46x0@>Tc1Ry~!# z^FtndB3@vP$=!@;gdR_|s*IZ3M>zi1PJhn^t;EgB#@g2f1y6d%THK^^8x=bdMm*w< zbvz%Dw5o9+-Q-nmzu8CjO58-%#Aq2-Y}kYP{r$^DQE!wcQpJ^xJu+4 z!CYxuMULBh$O02dc(j`k!^F+)Qi7thQ!3jvX$B*-WNZs)VkO$b<{u6$Qv^#YN~F5<6-fjeCTphIt?Ht^ zs~&86lKvcI!vVMM@~1nevl{z4kp?8(r=%MVb*Uceyl|r+ELYp5CkvOG{Wb5cDe6Y= z%+MJ)=$BF3_zdKm(w#ZTkRnr;(z+jpKVinFeKrCu@f9D+si|%lZ55br=t>!Wn6-Y1>IGuZ1b|=4EHapFw4uNPZ|TGylE-5S!n(O!%@J-fN#g!zf9GT@p7K zEJQMO;a(>X7wnD;t)tOg(x&DQT2=k{8|~=w*f4lEzVva z9i8`A6)-g#(>7}r1izCDB2k)4)8OoTDhm)ux+I;qa`B>^BP^ZSuyiD_WL-L|kP5!? zHWq~_W=;7k5@sJLMEu2-esS1eff@@6^KgyO!J6gRgp!WNbaT7gu`hx?1e4Xb#K_(rNyl}t8#Xmx3k zYj`oVg{rP`A9UC%F&LA!=Xu%Ks7Rn8e}ci|Ku=*-dFQi?widL}MjYKobu+Fg0Z|Zy z#lBT6O(AcO<7~dEV?)No*%7);slFT1RcJMkxJF14A+`QA{d=};FTR8h8? zUMJ2gr%>93JZ@ZQnv``;7z-_@L++dHoMiH7sV$(&b3`AM^rWL^pbWzy+U>OCD~9f( z5QYRGDr0?NJ&FD>4#D?`(@XOFeVU@RC^IgMCnmxh#;8;>NFz!SBL@O&Wm_Dv$1HIC zPHt$yuj?@jhlBUL2{Zs7b zupHo}O$?%!2-P4M*+C-UcNgQ2STCuzS`dKCU`KsuTYqGckqZ?fexcf~sKddLAcj<~!h$3Mf*>_ru2kC^Su;fs%RYd6#RF=*#wqpzLsU%Z$ z54l?gc5J0*@M251Eyu>`h0hAbka1aT*d|&{!!RqGE0re^kcCMxq|(6r8RoUzyl1Sv zB)ZiHt34gUswz7}N)T^2F)yDK^qsOb3Abgt4Et z;#7I!9b3PM(4AIKqp`A{&TfV*fcunD#9s5IuF$f~W=KVRWn-{JEQ?Kk4@G^(Mt~(U zc*fN|0FWDN;jZnA>fMr6#Xu*rNvQ0Ga*ub|{@I~~{0NU)7DfOl$Bf<{!TXp}lU+bM zLBTIyk7jV~YP#E1ddCc_0|>(dd0>i}x1bLURQ7q2pwiX06~lByT^4-SUqRm5xx$j- z#*9Usu}%@(Z1%NQT!>l5rZz96NN|fN^z5sv%CGRwv=ozL1K|>}x-dY_j(n(8B2$$c zl0S&uSbVzEk&6%=Q;q4m;}i|-S1K^uEteKIEZD6o4+e|Fh8$s3FIx`9ay|}0v+NqI zA^{LxwIVW|2XGIqP`7zF%L5BN?3ewFM_l z=mn>;H4lXQ>rTq(tM$l5Wsz$=y8}&MC_{K5;}?me4Hp3>SP0;=UVI_ zDwP!Tu6Y=*BaXFF&RT@jXJvr+O*@>qIa_Q=s0?zl>hfzjniy@7r)McT4D=hu! zM@3l@CDq5!R5ImD9W{grOMG$E`7=o>x;5jBNh?^TPnq?l|N8cuRwM&vOYn38v08H>^xopLTW{46)p zYMyWJm9MEhnaIWY&@bV|a_)9*cU_nK2o-oXLl+q$WRms9m)yv5HGC(*h;q3K-gfYH ze0{;w$+wFRCdqp5&NhS7m<1z*uY64ZnUZKJF6fR0CFRm_5?7>N!h?(RLPbRjP1J_z z)|{k#5fLy6uAZG0BD@w$oD&mWwIX2@1IeV(F0zvGTM7P>$!HxzH!;Amv#8CMb~f>I z^TrP&_N~p+M!lL&iX0DdBPF8GQU!qO6EYr3fkY~`(He5BEeaB_WM#C=@l%~Qqr{On zG=N1$*`VXmCy6aG5^5(B`;$s~+LAFaW56fCg`Jur_;S%t`>chtYzjrXz3r#!M&XJF zW_t8>-V`u#%^PXR-L_P zp@5acPt2d^`>)qTUP)>HX~+R<7iRoI!`ddXXgT3#B=$BC+A^{}Dl{V9ODyE8p!X)yt$WbY$ymr^g)R%Na0Wfb9%JlsrGAZ?J5hL)pQ06Q`|JwyXJMhbJZBqF$n zKaUaeax%ypz`~%DSdI9Q$O3PBw($Gm%jBztrpC=L(<%y==Y>qO$Wu5j2u-?W4Pra$ zOD?JvKNa1?4AS-~dGd90$qfmgNCkRQ$--N(9?JD#2|3EAd0HTJszaOvEZiQ#f0v`U zK)+4SX6Qsp9YAQEHT=|9JAg=N5xK~6SUZP(gs90ezHCEDb1Fo73kThKpb%MeM4ztH zHl>JB_D&|Oe@VJ9Ln<WXV zN}?mmrT4@pi9B>9`3cU&YewIeORed3?iL) zAS(lpgB=wXovgPZ$j6}VtOgjcyN=lsv`Tv@P>`_@w2p^Kgl5GAx>qcU62w0 z$#Soy+YtoOK*_Lr?dk}V>f%*N>}agAz?i*!W)vb$*gC+YAvQ|T+ZJA}4ft~cClhei z4^^a*Zb0^F#Pz-6DT4h|oQVsc=O|y(=@%+6az9Z&WRc_<9MuCHwm4*O8}y_C;J^~4 z#$E~+GeVW12qu4<%3C34<8*z;&moW3M6z?42HT>qJTAG37^(L>D^}V=~Me& zwURmAOF@><^&JwE+-TF!&IKeuo(H_yAav0|#;bD&_4U3E26$pz7gfx}2 zB^VD5$iE|xf;q@BA5?ySeB8I9#<6s@nGRCd-JZD)BNfY%$!8g) z%k!k*O3-L0k$&sb=hPK|i}~yyZ$`bn18G%Z2J01X6<6MVQC6L61Om^nxh2MMBV@Sd z%s3Zu1Ole#DrTt$(h|~@*H$3hsbbaar4{4(havavaCbE`s7wamP_7cZPYNmLf>Z=- z11OS71Q6=FlDi84T{Z`1Y^7#LFPR5nr6yQ_aN$vtU@#&|7nRVrz|+c!*mmoqo$vPr zR1SOM_(LIbaHW7ekj*_YAq39;CNge2*`TP^Od%i2QLv=eTUq&V;!?eC)xk^lvFsNQ zj|j6D&z7J@_%_au0Chgo6{P6QyJH3^MxCAWs0auLS00@0J{Zvk@G%Yj-Z2)R*?E&s zdQzjp7^AbF)q*VyR>d=92A?&)FCi{bNLLP(>GDiCz$yjARB?PJ4evFjM<|<$AZuc? zI2kyhLxLh8YB;HFVLpbYqVpmhk#cIJC~<2)U`<#qNRb7P4eoLyJP!6Jnk2nN6&#O9 zh7%EI!_doyC@R5HIOInzD`m)aWED@@P?IPz4M3uA=_7T4^gpC2wbW0$O?BCN+Sicb zLG!j*#s|EumW7AcPCD27>ya|w4X;@wdN8HJ6B1B_cLFp*R>zr5x^}WKyQ3ofXR?(l zvz=JL&g%Z!tH;ge#`bG&vDwzY@&iom?nIUSwcN55DxyjtrTB|o!m?n2lH^N9iH$g$ zL0N~U$b_QfUmiTT|GCk+y&Z`5JZOH=@y41&;X`>28705AVh_|=bsO%>C~VC-xjcUjoV2x4Gt-#D zhez2K+(FFa=%IUUGVD+}u}2#-&X-sAqj!qZt72JfY(HQBTdT_%?BeEydIznI&u=ai zuXDp!XX=x^+5Tl>?U8pQ8{?Fa9k?HyiYAwdE6ccOb~VZ+HjjPCXhY>~goCq>VtHT* zbDA7~>|EG4vX_XibD3)5gJT?2*Tdmu8TsbgWIp1FaERWm{$P0Q1G`Py2N+G(cb4>| zvXw8zN@sIZ)R(_eSVWnRNL)SX3)LH>3=71M*i&^yK!scvS(Oq!0jXjkn#U=AY2V@F ziE2lrLfkkM=_Em~Fep~7do)O}%iK@3Fr*H76A@Eg>VvdMML=vQImzLoN%GMtG==UdL%DnwX>autSr$j-1Tz~!lXB%y#4`q=ETb)FV{`Rz z8Ie*{-AllTeqTqhB8%(+;xL~G#Dr(NLb+38K-vyYuvtHnkCS~8L@jg3AsC){m~~2| zAU<<%5{?eWGZ1Pqx$u`16X8RPgaTP=_f{iuyR`=-R z+tcYPX??)mf3@ChZ11n{Zm;h*dvDgbIQh@b>h|;QAJ(^DZfviwtA)Q8wZFRex_R+t zcWu3SzOlEqxw^5n*Q{=Ca>3i~?&|jb#`+%jW&iEY?)u(d^Jcf%*xK3LSbxqPlG|&W z-#^d8Ji}z%#yi{G;AX~k=6u7{f6jya85mag4aoO<>&=@N2`1*-dxhCt&cDDwCK$)Fx&Ykha^6>zUU+t}Oy0f78sV}D!F zGaDz(xV2z^W9|FR)!k<2``w*4d+Xkt)wYkL1Y_E+7nDAWBQnoOL#&hEVq;4)3(#-t z#wQJnc!JF#N`rKpP(0r^QwU8izx?JL5kzp{N$-GZ39~%?M&-e1r%c{YdfyFy9)`-| zum4Ur3SitFO!Q_J1`EAMlxj~+HU0k6Z>HkSr(a@TBn2>eesca_7>vrfCmxP61j-e! zp7j3yEdacyUj)@|ql5QPdLNO$ArPxbWWlN(GJ+t?WW-7Pe5))n4+(xWlo!O`jId3Xp6&q4-T*EiRv`tRxJz7c+tK>l&)4el>3bh_7pyOjo;k_Zc8=fDOy#+y$bs=1I7 znMkbl55t2?jLggPl}5M0txQdQ{P=Ma&-a%}h-QlZgBO>$yi|X{_h>uWEkw?y5LArNE4;rWLWFMvi>A0=Fn=OG!Gr-XG0n;=DDvqH7q8& zczt}VNIfhvx~g_&_3RoucB`3Km>SIg5nD4evv_woqjy-r&GneOd5G#Bj)_aj+UNgA zW{-2cA(h6(cgMqvllj57C*v!1&yr{>8=^lo6N^(bX8ON2S9j-9fxLpOVJ5G7a^(~Y9F*`AsnZ3*OKR9BFyIax*Sp2Rz63@%9!qkd$mr8di zU=Q_$Bk*#4U%};9>#NwQSa|!7tJSQn4Nnh0B2u`~JdxI4TfZzU-(~tAxGf5uM!Ff{ zB<-R=ql9eB#I&sYZuqI0n4OyWV}$GU{9Ro!y86lv9K4AKH2j5*t&*q`p&%F+=>yQJ zHj8gA3VC1Na4Vh^^dCgu^D}oLeWN7%jH=Zravr*@8r@v#^?#eBr5axCZ*5k@kV$)a zYW5G2|BJJC*MYuC4*ezO+X+U-6>i=2*@)F#Q){Cr4bcR`E{LKm;MI|)nV6gULkMFq zzc_bCvSSe4jIV9Z=nkQao3I_i=2YYr8i9oI1Hw@znV{=Sh_GvUdUXOjN|`r`N-C89 zB!6GMDI9K)nKzjFLj?SQpF68c!9WCsqJa>4Td}sF#7c>}IC#_kalV;2S9Q;f>e?LZ zQ9XLKtev4^R_~h~I@n6KEd4>Y>tJ^N?q0pSx?Wnu09v?O8h`zMJUai&bpNbr4v(9+ zCqEzm^#0`doesJ#93A}p?x)j}lb^0nej1G_fj_>wIT|%TllXc+`P1o7*io$RNx!KU z_S1V-GZ1%33;(r6*bfesW2qrdS2FP z)rY)^;jcNLr&6oW&FF{#^Kb69}LhL3?6L{3_KVt-6;L8sfjQWMp4S}Xh{aW}h$KjBKd>z4*sp`S0^7d4cCE~fK{|9qX3TXfU literal 0 HcmV?d00001 From ae9be1a63d7b579fb5bb8b4bf903f1a3efe7168f Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 10 Jan 2019 13:54:11 +0100 Subject: [PATCH 029/292] moc: Parse namespaces from other files We can parse the namespaces in order to find the enums in them and populate the related metaobjects of the current file's classes. The symbol clashes are avoided by only generating metaobjects for namespaces defined in the same file. Fixes: QTBUG-71966 Fixes: QTBUG-72069 Change-Id: Ibdf21c3f9dae48d95b0952b3e220b4c29e30ecb8 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/tools/moc/moc.cpp | 33 ++++++++++++++++---------------- src/tools/moc/moc.h | 1 + tests/auto/tools/moc/tst_moc.cpp | 13 +++++++++++++ 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 5d777ece2e..c82a6d71ae 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -565,6 +565,7 @@ void Moc::parse() } else if (!test(SEMIC)) { NamespaceDef def; def.classname = nsName; + def.doGenerate = currentFilenames.size() <= 1; next(LBRACE); def.begin = index - 1; @@ -572,25 +573,22 @@ void Moc::parse() def.end = index; index = def.begin + 1; - const bool parseNamespace = currentFilenames.size() <= 1; - if (parseNamespace) { - for (int i = namespaceList.size() - 1; i >= 0; --i) { - if (inNamespace(&namespaceList.at(i))) { - def.qualified.prepend(namespaceList.at(i).classname + "::"); - } - } - for (const QByteArray &ns : nested) { - NamespaceDef parentNs; - parentNs.classname = ns; - parentNs.qualified = def.qualified; - def.qualified += ns + "::"; - parentNs.begin = def.begin; - parentNs.end = def.end; - namespaceList += parentNs; + for (int i = namespaceList.size() - 1; i >= 0; --i) { + if (inNamespace(&namespaceList.at(i))) { + def.qualified.prepend(namespaceList.at(i).classname + "::"); } } + for (const QByteArray &ns : nested) { + NamespaceDef parentNs; + parentNs.classname = ns; + parentNs.qualified = def.qualified; + def.qualified += ns + "::"; + parentNs.begin = def.begin; + parentNs.end = def.end; + namespaceList += parentNs; + } - while (parseNamespace && inNamespace(&def) && hasNext()) { + while (inNamespace(&def) && hasNext()) { switch (next()) { case NAMESPACE: if (test(IDENTIFIER)) { @@ -915,7 +913,8 @@ void Moc::parse() } else { knownGadgets.insert(def.classname, def.qualified); knownGadgets.insert(def.qualified, def.qualified); - classList += def; + if (n.doGenerate) + classList += def; } } } diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h index d6482f4e44..54f935a8da 100644 --- a/src/tools/moc/moc.h +++ b/src/tools/moc/moc.h @@ -188,6 +188,7 @@ Q_DECLARE_TYPEINFO(ClassDef::Interface, Q_MOVABLE_TYPE); struct NamespaceDef : BaseDef { bool hasQNamespace = false; + bool doGenerate = false; }; Q_DECLARE_TYPEINFO(NamespaceDef, Q_MOVABLE_TYPE); diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 74ddfd5620..0acc90fd11 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -3847,6 +3847,14 @@ static void checkEnum(const QMetaEnum &enumerator, const QByteArray &name, const } } +class EnumFromNamespaceClass : public QObject +{ + Q_OBJECT + Q_PROPERTY(FooNamespace::Enum1 prop READ prop CONSTANT) +public: + FooNamespace::Enum1 prop() { return FooNamespace::Enum1::Key2; } +}; + void tst_Moc::testQNamespace() { QCOMPARE(TestQNamespace::staticMetaObject.enumeratorCount(), 4); @@ -3874,6 +3882,11 @@ void tst_Moc::testQNamespace() QCOMPARE(FooNamespace::staticMetaObject.enumeratorCount(), 1); QCOMPARE(FooNamespace::FooNestedNamespace::staticMetaObject.enumeratorCount(), 2); QCOMPARE(FooNamespace::FooNestedNamespace::FooMoreNestedNamespace::staticMetaObject.enumeratorCount(), 1); + + EnumFromNamespaceClass obj; + const QVariant prop = obj.property("prop"); + QCOMPARE(prop.type(), QMetaType::Int); + QCOMPARE(prop.toInt(), int(FooNamespace::Enum1::Key2)); } void tst_Moc::cxx17Namespaces() From 783953f09dcfe9c58dc991394535ba07dabe2560 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 23 Jan 2019 16:31:35 +0100 Subject: [PATCH 030/292] Add conversion to and from long and ulong This implements conversion parity with QString, which can convert to and from long and unsigned long. The implementation simply forwards to existing long long overloads or uses the existing helpers, so just as for the conversion to/from int or short, no additional test cases were added. Change-Id: I37ef06d9ce4d80d98bd72720353996bac723e09c Fixes: QTBUG-782 Reviewed-by: Volker Hilsheimer --- src/corelib/tools/qlocale.cpp | 126 +++++++++++++++++++++++++++++++++ src/corelib/tools/qlocale.h | 12 ++++ src/corelib/tools/qlocale.qdoc | 24 +++++++ 3 files changed, 162 insertions(+) diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index b3fb079342..ebb6c97975 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -1332,6 +1332,48 @@ uint QLocale::toUInt(const QString &s, bool *ok) const return toIntegral_helper(d, s, ok); } +/*! + Returns the long int represented by the localized string \a s. + + If the conversion fails the function returns 0. + + If \a ok is not \c nullptr, failure is reported by setting *\a{ok} + to \c false, and success by setting *\a{ok} to \c true. + + This function ignores leading and trailing whitespace. + + \sa toInt(), toULong(), toDouble(), toString() + + \since 5.13 + */ + + +long QLocale::toLong(const QString &s, bool *ok) const +{ + return toIntegral_helper(d, s, ok); +} + +/*! + Returns the unsigned long int represented by the localized + string \a s. + + If the conversion fails the function returns 0. + + If \a ok is not \c nullptr, failure is reported by setting *\a{ok} + to \c false, and success by setting *\a{ok} to \c true. + + This function ignores leading and trailing whitespace. + + \sa toLong(), toInt(), toDouble(), toString() + + \since 5.13 +*/ + +ulong QLocale::toULong(const QString &s, bool *ok) const +{ + return toIntegral_helper(d, s, ok); +} + /*! Returns the long long int represented by the localized string \a s. @@ -1499,6 +1541,48 @@ uint QLocale::toUInt(const QStringRef &s, bool *ok) const return toIntegral_helper(d, s, ok); } +/*! + Returns the long int represented by the localized string \a s. + + If the conversion fails the function returns 0. + + If \a ok is not \c nullptr, failure is reported by setting *\a{ok} + to \c false, and success by setting *\a{ok} to \c true. + + This function ignores leading and trailing whitespace. + + \sa toInt(), toULong(), toDouble(), toString() + + \since 5.13 + */ + + +long QLocale::toLong(const QStringRef &s, bool *ok) const +{ + return toIntegral_helper(d, s, ok); +} + +/*! + Returns the unsigned long int represented by the localized + string \a s. + + If the conversion fails the function returns 0. + + If \a ok is not \c nullptr, failure is reported by setting *\a{ok} + to \c false, and success by setting *\a{ok} to \c true. + + This function ignores leading and trailing whitespace. + + \sa toLong(), toInt(), toDouble(), toString() + + \since 5.13 + */ + +ulong QLocale::toULong(const QStringRef &s, bool *ok) const +{ + return toIntegral_helper(d, s, ok); +} + /*! Returns the long long int represented by the localized string \a s. @@ -1675,6 +1759,48 @@ uint QLocale::toUInt(QStringView s, bool *ok) const return toIntegral_helper(d, s, ok); } +/*! + Returns the long int represented by the localized string \a s. + + If the conversion fails the function returns 0. + + If \a ok is not \c nullptr, failure is reported by setting *\a{ok} + to \c false, and success by setting *\a{ok} to \c true. + + This function ignores leading and trailing whitespace. + + \sa toInt(), toULong(), toDouble(), toString() + + \since 5.13 + */ + + +long QLocale::toLong(QStringView s, bool *ok) const +{ + return toIntegral_helper(d, s, ok); +} + +/*! + Returns the unsigned long int represented by the localized + string \a s. + + If the conversion fails the function returns 0. + + If \a ok is not \c nullptr, failure is reported by setting *\a{ok} + to \c false, and success by setting *\a{ok} to \c true. + + This function ignores leading and trailing whitespace. + + \sa toLong(), toInt(), toDouble(), toString() + + \since 5.13 + */ + +ulong QLocale::toULong(QStringView s, bool *ok) const +{ + return toIntegral_helper(d, s, ok); +} + /*! Returns the long long int represented by the localized string \a s. diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h index 1fbd96c6d5..2b4f131552 100644 --- a/src/corelib/tools/qlocale.h +++ b/src/corelib/tools/qlocale.h @@ -961,6 +961,8 @@ public: ushort toUShort(const QString &s, bool *ok = nullptr) const; int toInt(const QString &s, bool *ok = nullptr) const; uint toUInt(const QString &s, bool *ok = nullptr) const; + long toLong(const QString &s, bool *ok = nullptr) const; + ulong toULong(const QString &s, bool *ok = nullptr) const; qlonglong toLongLong(const QString &s, bool *ok = nullptr) const; qulonglong toULongLong(const QString &s, bool *ok = nullptr) const; float toFloat(const QString &s, bool *ok = nullptr) const; @@ -970,6 +972,8 @@ public: ushort toUShort(const QStringRef &s, bool *ok = nullptr) const; int toInt(const QStringRef &s, bool *ok = nullptr) const; uint toUInt(const QStringRef &s, bool *ok = nullptr) const; + long toLong(const QStringRef &s, bool *ok = nullptr) const; + ulong toULong(const QStringRef &s, bool *ok = nullptr) const; qlonglong toLongLong(const QStringRef &s, bool *ok = nullptr) const; qulonglong toULongLong(const QStringRef &s, bool *ok = nullptr) const; float toFloat(const QStringRef &s, bool *ok = nullptr) const; @@ -980,6 +984,8 @@ public: ushort toUShort(QStringView s, bool *ok = nullptr) const; int toInt(QStringView s, bool *ok = nullptr) const; uint toUInt(QStringView s, bool *ok = nullptr) const; + long toLong(QStringView s, bool *ok = nullptr) const; + ulong toULong(QStringView s, bool *ok = nullptr) const; qlonglong toLongLong(QStringView s, bool *ok = nullptr) const; qulonglong toULongLong(QStringView s, bool *ok = nullptr) const; float toFloat(QStringView s, bool *ok = nullptr) const; @@ -987,6 +993,8 @@ public: QString toString(qlonglong i) const; QString toString(qulonglong i) const; + inline QString toString(long i) const; + inline QString toString(ulong i) const; inline QString toString(short i) const; inline QString toString(ushort i) const; inline QString toString(int i) const; @@ -1107,6 +1115,10 @@ private: Q_DECLARE_SHARED(QLocale) Q_DECLARE_OPERATORS_FOR_FLAGS(QLocale::NumberOptions) +inline QString QLocale::toString(long i) const + { return toString(qlonglong(i)); } +inline QString QLocale::toString(ulong i) const + { return toString(qulonglong(i)); } inline QString QLocale::toString(short i) const { return toString(qlonglong(i)); } inline QString QLocale::toString(ushort i) const diff --git a/src/corelib/tools/qlocale.qdoc b/src/corelib/tools/qlocale.qdoc index b852c10b8d..91b0ab6442 100644 --- a/src/corelib/tools/qlocale.qdoc +++ b/src/corelib/tools/qlocale.qdoc @@ -1163,6 +1163,30 @@ currency string. */ +/*! +\fn QString QLocale::toString(long i) const + +\overload + +\sa toLong() +*/ + +/*! +\fn QString QLocale::toString(ulong i) const + +\overload + +\sa toULong() +*/ + +/*! +\fn QString QLocale::toString(ushort i) const + +\overload + +\sa toUShort() +*/ + /*! \fn QString QLocale::toString(short i) const From 46589056c399191e1afe0b2ddb1e2f0570fa8ddc Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 12 Feb 2019 12:45:50 +0100 Subject: [PATCH 031/292] QObject: count declarative receivers also if there are no C++ ones Change-Id: If998cdd5eeb8a3ae85cd540cc9c1fd0c051e1d4b Fixes: QTBUG-73753 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/kernel/qobject.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 257575e141..7b9689f1cf 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -2404,8 +2404,7 @@ int QObject::receivers(const char *signal) const { Q_D(const QObject); int receivers = 0; - QObjectPrivate::ConnectionData *cd = d->connections.load(); - if (signal && cd) { + if (signal) { QByteArray signal_name = QMetaObject::normalizedSignature(signal); signal = signal_name; #ifndef QT_NO_DEBUG @@ -2429,8 +2428,9 @@ int QObject::receivers(const char *signal) const signal_index); } + QObjectPrivate::ConnectionData *cd = d->connections.load(); QBasicMutexLocker locker(signalSlotLock(this)); - if (signal_index < cd->signalVector.count()) { + if (cd && signal_index < cd->signalVector.count()) { const QObjectPrivate::Connection *c = cd->signalVector.at(signal_index).first; while (c) { From 0f431712fbcb3775d85891a97ccb080d0da581e0 Mon Sep 17 00:00:00 2001 From: Mikhail Svetkin Date: Fri, 4 Jan 2019 16:26:19 +0100 Subject: [PATCH 032/292] qtlite: Add a new option -no-pcre pcre only used by QRegularExpression. Change-Id: I704bdb46ed8956f875e1f5fcc0fa2e06122fd87e Reviewed-by: Lars Knoll --- config_help.txt | 2 +- src/corelib/configure.json | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/config_help.txt b/config_help.txt index 18f66c7931..77a333c89a 100644 --- a/config_help.txt +++ b/config_help.txt @@ -241,7 +241,7 @@ Core options: -inotify ............. Enable inotify support -iconv ............... Enable iconv(3) support [posix/sun/gnu/no] (Unix only) -icu ................. Enable ICU support [auto] - -pcre ................ Select used libpcre2 [system/qt] + -pcre ................ Select used libpcre2 [system/qt/no] -pps ................. Enable PPS support [auto] (QNX only) -zlib ................ Select used zlib [system/qt] diff --git a/src/corelib/configure.json b/src/corelib/configure.json index 948aa0829b..81768507f6 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -11,7 +11,7 @@ "icu": "boolean", "inotify": "boolean", "journald": "boolean", - "pcre": { "type": "enum", "values": [ "qt", "system" ] }, + "pcre": { "type": "enum", "values": [ "no", "qt", "system" ] }, "posix-ipc": { "type": "boolean", "name": "ipc_posix" }, "pps": { "type": "boolean", "name": "qqnx_pps" }, "slog2": "boolean", @@ -662,15 +662,18 @@ "condition": "features.textcodec", "output": [ "publicFeature", "feature" ] }, + "pcre2": { + "label": "PCRE2", + "disable": "input.pcre == 'no' || input.pcre == 'system'", + "enable": "input.pcre == 'qt'", + "output": [ "privateConfig" ] + }, "system-pcre2": { - "label": "Using system PCRE2", - "disable": "input.pcre == 'qt'", + "label": " Using system PCRE2", + "disable": "input.pcre == 'no' || input.pcre == 'qt'", "enable": "input.pcre == 'system'", "condition": "libs.pcre2", - "output": [ - "privateFeature", - { "type": "privateConfig", "negative": true, "name": "pcre2" } - ] + "output": [ "privateFeature" ] }, "poll_ppoll": { "label": "Native ppoll()", @@ -749,6 +752,7 @@ "label": "QRegularExpression", "purpose": "Provides an API to Perl-compatible regular expressions.", "section": "Kernel", + "condition": "features.system-pcre2 || features.pcre2", "output": [ "publicFeature", "feature" ] }, "sharedmemory": { @@ -1048,6 +1052,7 @@ Please apply the patch corresponding to your Standard Library vendor, found in "args": "qqnx_pps", "condition": "config.qnx" }, + "pcre2", "system-pcre2" ] } From 2be7746e0922fa404da567fd0bc0cbc00c6215cb Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 30 Jan 2019 14:11:07 +0100 Subject: [PATCH 033/292] Fix a typo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit in a comment. Change-Id: I10252b2e732636993daba6b72ed86116691f2030 Reviewed-by: Mårten Nordheim Reviewed-by: Jesus Fernandez --- src/network/ssl/qsslsocket_openssl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index c48cd42360..6a8269b521 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -476,7 +476,8 @@ bool QSslSocketBackendPrivate::initSslContext() { Q_Q(QSslSocket); - // If no external context was set (e.g. bei QHttpNetworkConnection) we will create a default context + // If no external context was set (e.g. by QHttpNetworkConnection) we will + // create a default context if (!sslContextPointer) { // create a deep copy of our configuration QSslConfigurationPrivate *configurationCopy = new QSslConfigurationPrivate(configuration); From 656ce9fa9dd1a5cb268f8e3225b2ed65c05365db Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sat, 9 Feb 2019 11:14:37 +0100 Subject: [PATCH 034/292] QGraphicsItemAnimation: add transformAt() an deprecate matrixAt() Replace QGraphicsItemAnimation::matrixAt(qreal) with transformAt(qreal) to avoid the usage of QMatrix which is deprecated. Change-Id: Iafcdf8b9b2fbffffa61417601a3ae4272d0176c6 Reviewed-by: Allan Sandfeld Jensen --- src/widgets/doc/snippets/timeline/main.cpp | 4 +-- .../graphicsview/qgraphicsitemanimation.cpp | 33 ++++++++++++++----- .../graphicsview/qgraphicsitemanimation.h | 5 +++ .../tst_qgraphicsitemanimation.cpp | 6 ++-- 4 files changed, 34 insertions(+), 14 deletions(-) diff --git a/src/widgets/doc/snippets/timeline/main.cpp b/src/widgets/doc/snippets/timeline/main.cpp index 74aa749254..4dfa2400d0 100644 --- a/src/widgets/doc/snippets/timeline/main.cpp +++ b/src/widgets/doc/snippets/timeline/main.cpp @@ -48,7 +48,7 @@ ** ****************************************************************************/ -#include +#include #include int main(int argv, char *args[]) @@ -68,7 +68,7 @@ int main(int argv, char *args[]) for (int i = 0; i < 200; ++i) animation->setPosAt(i / 200.0, QPointF(i, i)); - QGraphicsScene *scene = new QGraphicsScene(); + QGraphicsScene *scene = new QGraphicsScene; scene->setSceneRect(0, 0, 250, 250); scene->addItem(ball); diff --git a/src/widgets/graphicsview/qgraphicsitemanimation.cpp b/src/widgets/graphicsview/qgraphicsitemanimation.cpp index 78b91d5c39..ad77e2f260 100644 --- a/src/widgets/graphicsview/qgraphicsitemanimation.cpp +++ b/src/widgets/graphicsview/qgraphicsitemanimation.cpp @@ -115,7 +115,7 @@ public: QGraphicsItem *item; QPointF startPos; - QMatrix startMatrix; + QTransform startTransform; qreal step; @@ -294,23 +294,38 @@ QList > QGraphicsItemAnimation::posList() const return list; } +#if QT_DEPRECATED_SINCE(5, 14) /*! Returns the matrix used to transform the item at the specified \a step value. + + \obsolete Use transformAt() instead */ QMatrix QGraphicsItemAnimation::matrixAt(qreal step) const { check_step_valid(step, "matrixAt"); + return transformAt(step).toAffine(); +} +#endif - QMatrix matrix; +/*! + Returns the transform used for the item at the specified \a step value. + + \since 5.14 +*/ +QTransform QGraphicsItemAnimation::transformAt(qreal step) const +{ + check_step_valid(step, "transformAt"); + + QTransform transform; if (!d->rotation.isEmpty()) - matrix.rotate(rotationAt(step)); + transform.rotate(rotationAt(step)); if (!d->verticalScale.isEmpty()) - matrix.scale(horizontalScaleAt(step), verticalScaleAt(step)); + transform.scale(horizontalScaleAt(step), verticalScaleAt(step)); if (!d->verticalShear.isEmpty()) - matrix.shear(horizontalShearAt(step), verticalShearAt(step)); + transform.shear(horizontalShearAt(step), verticalShearAt(step)); if (!d->xTranslation.isEmpty()) - matrix.translate(xTranslationAt(step), yTranslationAt(step)); - return matrix; + transform.translate(xTranslationAt(step), yTranslationAt(step)); + return transform; } /*! @@ -542,7 +557,7 @@ void QGraphicsItemAnimation::setStep(qreal step) || !d->horizontalShear.isEmpty() || !d->xTranslation.isEmpty() || !d->yTranslation.isEmpty()) { - d->item->setMatrix(d->startMatrix * matrixAt(step)); + d->item->setTransform(d->startTransform * transformAt(step)); } } @@ -562,7 +577,7 @@ void QGraphicsItemAnimation::reset() if (!d->item) return; d->startPos = d->item->pos(); - d->startMatrix = d->item->matrix(); + d->startTransform = d->item->transform(); } #endif diff --git a/src/widgets/graphicsview/qgraphicsitemanimation.h b/src/widgets/graphicsview/qgraphicsitemanimation.h index f983bd8026..3051fb2e2b 100644 --- a/src/widgets/graphicsview/qgraphicsitemanimation.h +++ b/src/widgets/graphicsview/qgraphicsitemanimation.h @@ -51,6 +51,7 @@ class QGraphicsItem; class QMatrix; class QPointF; class QTimeLine; +class QTransform; template struct QPair; class QGraphicsItemAnimationPrivate; @@ -71,7 +72,11 @@ public: QList > posList() const; void setPosAt(qreal step, const QPointF &pos); +#if QT_DEPRECATED_SINCE(5, 14) + QT_DEPRECATED_X("Use transformAt() instead") QMatrix matrixAt(qreal step) const; +#endif + QTransform transformAt(qreal step) const; qreal rotationAt(qreal step) const; QList > rotationList() const; diff --git a/tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp b/tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp index dfb2752ee0..ed79904ed8 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp @@ -54,9 +54,9 @@ void tst_QGraphicsItemAnimation::construction() QCOMPARE(animation.posAt(0), QPointF()); QCOMPARE(animation.posAt(0.5), QPointF()); QCOMPARE(animation.posAt(1), QPointF()); - QCOMPARE(animation.matrixAt(0), QMatrix()); - QCOMPARE(animation.matrixAt(0.5), QMatrix()); - QCOMPARE(animation.matrixAt(1), QMatrix()); + QCOMPARE(animation.transformAt(0), QTransform()); + QCOMPARE(animation.transformAt(0.5), QTransform()); + QCOMPARE(animation.transformAt(1), QTransform()); QCOMPARE(animation.rotationAt(0), qreal(0.0)); QCOMPARE(animation.rotationAt(0.5), qreal(0.0)); QCOMPARE(animation.rotationAt(1), qreal(0.0)); From bdf1c4f671c706832cea84269e91995e85eb9f07 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Tue, 5 Feb 2019 20:30:43 +0100 Subject: [PATCH 035/292] QComboBox: add two new signals textHighlighted() and textActivated() To avoid overloaded signals for highlighted() and activated() add two new signals textHighlighted()/textActivated() and deprecate the old QString overloads. [ChangeLog][QtWidgets][QComboBox] Two new signals textHighlighted() and textActivated() were added to replace highlighted()/activated() QString overloads Change-Id: I62df7e606b335b5c756315a800654d7d0de442bd Reviewed-by: Shawn Rutledge --- src/widgets/widgets/qcombobox.cpp | 6 ++++++ src/widgets/widgets/qcombobox.h | 12 +++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 1ad43fffb4..aa520e37a2 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -1364,7 +1364,10 @@ void QComboBoxPrivate::emitActivated(const QModelIndex &index) return; QString text(itemText(index)); emit q->activated(index.row()); + emit q->textActivated(text); +#if QT_DEPRECATED_SINCE(5, 15) emit q->activated(text); +#endif } void QComboBoxPrivate::_q_emitHighlighted(const QModelIndex &index) @@ -1374,7 +1377,10 @@ void QComboBoxPrivate::_q_emitHighlighted(const QModelIndex &index) return; QString text(itemText(index)); emit q->highlighted(index.row()); + emit q->textHighlighted(text); +#if QT_DEPRECATED_SINCE(5, 15) emit q->highlighted(text); +#endif } void QComboBoxPrivate::_q_emitCurrentIndexChanged(const QModelIndex &index) diff --git a/src/widgets/widgets/qcombobox.h b/src/widgets/widgets/qcombobox.h index 64fbebb3c5..6a87a675a4 100644 --- a/src/widgets/widgets/qcombobox.h +++ b/src/widgets/widgets/qcombobox.h @@ -220,15 +220,21 @@ public Q_SLOTS: Q_SIGNALS: void editTextChanged(const QString &); void activated(int index); - void activated(const QString &); + void textActivated(const QString &); void highlighted(int index); - void highlighted(const QString &); + void textHighlighted(const QString &); void currentIndexChanged(int index); + void currentTextChanged(const QString &); #if QT_DEPRECATED_SINCE(5, 13) QT_DEPRECATED_X("Use currentTextChanged() instead") void currentIndexChanged(const QString &); #endif - void currentTextChanged(const QString &); +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X("Use textActivated() instead") + void activated(const QString &); + QT_DEPRECATED_X("Use textHighlighted() instead") + void highlighted(const QString &); +#endif protected: void focusInEvent(QFocusEvent *e) override; From 36c2ceca955940e306abb966d1c768895ccf1014 Mon Sep 17 00:00:00 2001 From: Kari Oikarinen Date: Mon, 25 Feb 2019 09:37:31 +0200 Subject: [PATCH 036/292] Bump version Change-Id: I5561df4b90b02d88bb2fc7b52d74487e71efce7d --- .qmake.conf | 2 +- src/corelib/serialization/qdatastream.cpp | 1 + src/corelib/serialization/qdatastream.h | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.qmake.conf b/.qmake.conf index c92e38c48f..08e1a4723c 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -4,4 +4,4 @@ CONFIG += warning_clean QT_SOURCE_TREE = $$PWD QT_BUILD_TREE = $$shadowed($$PWD) -MODULE_VERSION = 5.13.0 +MODULE_VERSION = 5.14.0 diff --git a/src/corelib/serialization/qdatastream.cpp b/src/corelib/serialization/qdatastream.cpp index ead6ed5083..3ea518907b 100644 --- a/src/corelib/serialization/qdatastream.cpp +++ b/src/corelib/serialization/qdatastream.cpp @@ -561,6 +561,7 @@ void QDataStream::setByteOrder(ByteOrder bo) \value Qt_5_11 Same as Qt_5_6 \value Qt_5_12 Version 18 (Qt 5.12) \value Qt_5_13 Version 19 (Qt 5.13) + \value Qt_5_14 Same as Qt_5_13 \omitvalue Qt_DefaultCompiledVersion \sa setVersion(), version() diff --git a/src/corelib/serialization/qdatastream.h b/src/corelib/serialization/qdatastream.h index 81134f74b0..6e358df02e 100644 --- a/src/corelib/serialization/qdatastream.h +++ b/src/corelib/serialization/qdatastream.h @@ -100,10 +100,11 @@ public: Qt_5_11 = Qt_5_10, Qt_5_12 = 18, Qt_5_13 = 19, -#if QT_VERSION >= 0x050e00 + Qt_5_14 = Qt_5_13, +#if QT_VERSION >= 0x050f00 #error Add the datastream version for this Qt version and update Qt_DefaultCompiledVersion #endif - Qt_DefaultCompiledVersion = Qt_5_13 + Qt_DefaultCompiledVersion = Qt_5_14 }; enum ByteOrder { From 93b7b0ec76572427291d8e2eef9a10eb499417a9 Mon Sep 17 00:00:00 2001 From: Sandro Mani Date: Thu, 12 Jul 2018 10:27:36 +0200 Subject: [PATCH 037/292] Add support for SPNEGO/Negotiate authentication MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds support for single-sign-on SPNEGO/Negotiate authentication to QAuthenticator, using SSPI on Windows and GSSAPI on other platforms (if KRB5 GSSAPI is available). [ChangeLog][QtNetwork][QAuthenticator] Add support for SPNEGO/Negotiate Task-number: QTBUG-4117 Change-Id: Ie246b887db3fd6201b7ed30b023feca292cd6530 Reviewed-by: Mårten Nordheim --- src/network/access/qhttpnetworkconnection.cpp | 13 +- src/network/access/qhttpnetworkreply.cpp | 3 + src/network/configure.json | 26 +- src/network/kernel/kernel.pri | 2 + src/network/kernel/qauthenticator.cpp | 416 ++++++++++++------ src/network/kernel/qauthenticator_p.h | 17 +- src/network/socket/qhttpsocketengine.cpp | 2 +- .../qauthenticator/tst_qauthenticator.cpp | 8 +- 8 files changed, 327 insertions(+), 160 deletions(-) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 681d84fee8..ee1e3cfb8f 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -398,11 +398,12 @@ void QHttpNetworkConnectionPrivate::copyCredentials(int fromChannel, QAuthentica { Q_ASSERT(auth); - // NTLM is a multi phase authentication. Copying credentials between authenticators would mess things up. + // NTLM and Negotiate do multi-phase authentication. + // Copying credentialsbetween authenticators would mess things up. if (fromChannel >= 0) { - if (!isProxy && channels[fromChannel].authMethod == QAuthenticatorPrivate::Ntlm) - return; - if (isProxy && channels[fromChannel].proxyAuthMethod == QAuthenticatorPrivate::Ntlm) + const QHttpNetworkConnectionChannel &channel = channels[fromChannel]; + const QAuthenticatorPrivate::Method method = isProxy ? channel.proxyAuthMethod : channel.authMethod; + if (method == QAuthenticatorPrivate::Ntlm || method == QAuthenticatorPrivate::Negotiate) return; } @@ -592,7 +593,7 @@ void QHttpNetworkConnectionPrivate::createAuthorization(QAbstractSocket *socket, if ((channels[i].authMethod != QAuthenticatorPrivate::Ntlm && request.headerField("Authorization").isEmpty()) || channels[i].lastStatus == 401) { QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(channels[i].authenticator); if (priv && priv->method != QAuthenticatorPrivate::None) { - QByteArray response = priv->calculateResponse(request.methodName(), request.uri(false)); + QByteArray response = priv->calculateResponse(request.methodName(), request.uri(false), request.url().host()); request.setHeaderField("Authorization", response); channels[i].authenticationCredentialsSent = true; } @@ -604,7 +605,7 @@ void QHttpNetworkConnectionPrivate::createAuthorization(QAbstractSocket *socket, if (!(channels[i].proxyAuthMethod == QAuthenticatorPrivate::Ntlm && channels[i].lastStatus != 407)) { QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(channels[i].proxyAuthenticator); if (priv && priv->method != QAuthenticatorPrivate::None) { - QByteArray response = priv->calculateResponse(request.methodName(), request.uri(false)); + QByteArray response = priv->calculateResponse(request.methodName(), request.uri(false), networkProxy.hostName()); request.setHeaderField("Proxy-Authorization", response); channels[i].proxyCredentialsSent = true; } diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp index c9c3172304..a8b635c45a 100644 --- a/src/network/access/qhttpnetworkreply.cpp +++ b/src/network/access/qhttpnetworkreply.cpp @@ -444,6 +444,9 @@ QAuthenticatorPrivate::Method QHttpNetworkReplyPrivate::authenticationMethod(boo } else if (method < QAuthenticatorPrivate::DigestMd5 && line.startsWith("digest")) { method = QAuthenticatorPrivate::DigestMd5; + } else if (method < QAuthenticatorPrivate::Negotiate + && line.startsWith("negotiate")) { + method = QAuthenticatorPrivate::Negotiate; } } return method; diff --git a/src/network/configure.json b/src/network/configure.json index e6c87b550b..aaedc05ea4 100644 --- a/src/network/configure.json +++ b/src/network/configure.json @@ -199,6 +199,15 @@ ] }, "use": "openssl" + }, + "gssapi": { + "label": "KRB5 GSSAPI support", + "type": "compile", + "test": { + "include": [ "gssapi/gssapi.h" ], + "main": ["gss_ctx_id_t ctx;"], + "qmake": "LIBS += -lgssapi_krb5" + } } }, @@ -374,6 +383,20 @@ "purpose": "Provides API for DNS lookups.", "section": "Networking", "output": [ "publicFeature" ] + }, + "gssapi": { + "label": "GSSAPI", + "purpose": "Enable SPNEGO authentication through GSSAPI", + "section": "Networking", + "condition": "!config.win32 && tests.gssapi", + "output": [ "publicFeature", "feature" ] + }, + "sspi": { + "label": "SSPI", + "purpose": "Enable NTLM/SPNEGO authentication through SSPI", + "section": "Networking", + "condition": "config.win32 && !config.winrt", + "output": [ "publicFeature", "feature" ] } }, @@ -433,7 +456,8 @@ For example: "dtls", "ocsp", "sctp", - "system-proxies" + "system-proxies", + "gssapi" ] } ] diff --git a/src/network/kernel/kernel.pri b/src/network/kernel/kernel.pri index 11b80d59d5..f7269e5070 100644 --- a/src/network/kernel/kernel.pri +++ b/src/network/kernel/kernel.pri @@ -68,6 +68,8 @@ mac { !uikit: LIBS_PRIVATE += -framework CoreServices -framework SystemConfiguration } +qtConfig(gssapi): LIBS_PRIVATE += -lgssapi_krb5 + uikit:HEADERS += kernel/qnetworkinterface_uikit_p.h osx:SOURCES += kernel/qnetworkproxy_mac.cpp else:win32:!winrt: SOURCES += kernel/qnetworkproxy_win.cpp diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index 47ce9ab0c6..3ca8806c2b 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -54,20 +54,29 @@ #include #include #include -#ifndef Q_OS_WINRT +#endif + +#if QT_CONFIG(sspi) // SSPI #define SECURITY_WIN32 1 #include -#endif +#elif QT_CONFIG(gssapi) // GSSAPI +#include #endif QT_BEGIN_NAMESPACE static QByteArray qNtlmPhase1(); static QByteArray qNtlmPhase3(QAuthenticatorPrivate *ctx, const QByteArray& phase2data); -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) -static QByteArray qNtlmPhase1_SSPI(QAuthenticatorPrivate *ctx); -static QByteArray qNtlmPhase3_SSPI(QAuthenticatorPrivate *ctx, const QByteArray& phase2data); -#endif +#if QT_CONFIG(sspi) // SSPI +static QByteArray qSspiStartup(QAuthenticatorPrivate *ctx, QAuthenticatorPrivate::Method method, + const QString& host); +static QByteArray qSspiContinue(QAuthenticatorPrivate *ctx, QAuthenticatorPrivate::Method method, + const QString& host, const QByteArray& challenge = QByteArray()); +#elif QT_CONFIG(gssapi) // GSSAPI +static QByteArray qGssapiStartup(QAuthenticatorPrivate *ctx, const QString& host); +static QByteArray qGssapiContinue(QAuthenticatorPrivate *ctx, + const QByteArray& challenge = QByteArray()); +#endif // gssapi /*! \class QAuthenticator @@ -90,6 +99,7 @@ static QByteArray qNtlmPhase3_SSPI(QAuthenticatorPrivate *ctx, const QByteArray& \li Basic \li NTLM version 2 \li Digest-MD5 + \li SPNEGO/Negotiate \endlist \target qauthenticator-options @@ -133,6 +143,10 @@ static QByteArray qNtlmPhase3_SSPI(QAuthenticatorPrivate *ctx, const QByteArray& The Digest-MD5 authentication mechanism supports no outgoing options. + \section2 SPNEGO/Negotiate + + This authentication mechanism currently supports no incoming or outgoing options. + \sa QSslSocket */ @@ -187,7 +201,7 @@ QAuthenticator &QAuthenticator::operator=(const QAuthenticator &other) d->options = other.d->options; } else if (d->phase == QAuthenticatorPrivate::Start) { delete d; - d = 0; + d = nullptr; } return *this; } @@ -339,21 +353,25 @@ bool QAuthenticator::isNull() const return !d; } -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) -class QNtlmWindowsHandles +#if QT_CONFIG(sspi) // SSPI +class QSSPIWindowsHandles { public: CredHandle credHandle; CtxtHandle ctxHandle; }; -#endif +#elif QT_CONFIG(gssapi) // GSSAPI +class QGssApiHandles +{ +public: + gss_ctx_id_t gssCtx = nullptr; + gss_name_t targetName; +}; +#endif // gssapi QAuthenticatorPrivate::QAuthenticatorPrivate() : method(None) - #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) - , ntlmWindowsHandles(0) - #endif , hasFailed(false) , phase(Start) , nonceCount(0) @@ -363,13 +381,7 @@ QAuthenticatorPrivate::QAuthenticatorPrivate() nonceCount = 0; } -QAuthenticatorPrivate::~QAuthenticatorPrivate() -{ -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) - if (ntlmWindowsHandles) - delete ntlmWindowsHandles; -#endif -} +QAuthenticatorPrivate::~QAuthenticatorPrivate() = default; void QAuthenticatorPrivate::updateCredentials() { @@ -424,6 +436,9 @@ void QAuthenticatorPrivate::parseHttpResponse(const QList( reinterpret_cast(GetProcAddress(securityDLLHandle, "InitSecurityInterfaceW"))); - if (pInitSecurityInterface != NULL) + if (pInitSecurityInterface != nullptr) pSecurityFunctionTable = pInitSecurityInterface(); } } - if (pSecurityFunctionTable == NULL) + if (pSecurityFunctionTable == nullptr) return false; return true; } -// Phase 1: -static QByteArray qNtlmPhase1_SSPI(QAuthenticatorPrivate *ctx) +static QByteArray qSspiStartup(QAuthenticatorPrivate *ctx, QAuthenticatorPrivate::Method method, + const QString& host) { - QByteArray result; + if (!q_SSPI_library_load()) + return QByteArray(); - if (!q_NTLM_SSPI_library_load()) - return result; + TimeStamp expiry; // For Windows 9x compatibility of SSPI calls - // 1. The client obtains a representation of the credential set - // for the user via the SSPI AcquireCredentialsHandle function. - if (!ctx->ntlmWindowsHandles) - ctx->ntlmWindowsHandles = new QNtlmWindowsHandles; - memset(&ctx->ntlmWindowsHandles->credHandle, 0, sizeof(CredHandle)); - TimeStamp tsDummy; + if (!ctx->sspiWindowsHandles) + ctx->sspiWindowsHandles.reset(new QSSPIWindowsHandles); + memset(&ctx->sspiWindowsHandles->credHandle, 0, sizeof(CredHandle)); + + // Acquire our credentials handle SECURITY_STATUS secStatus = pSecurityFunctionTable->AcquireCredentialsHandle( - NULL, (SEC_WCHAR*)L"NTLM", SECPKG_CRED_OUTBOUND, NULL, NULL, - NULL, NULL, &ctx->ntlmWindowsHandles->credHandle, &tsDummy); + nullptr, + (SEC_WCHAR*)(method == QAuthenticatorPrivate::Negotiate ? L"Negotiate" : L"NTLM"), + SECPKG_CRED_OUTBOUND, nullptr, nullptr, nullptr, nullptr, + &ctx->sspiWindowsHandles->credHandle, &expiry + ); if (secStatus != SEC_E_OK) { - delete ctx->ntlmWindowsHandles; - ctx->ntlmWindowsHandles = 0; - return result; + ctx->sspiWindowsHandles.reset(nullptr); + return QByteArray(); } - // 2. The client calls the SSPI InitializeSecurityContext function - // to obtain an authentication request token (in our case, a Type 1 message). - // The client sends this token to the server. - SecBufferDesc desc; - SecBuffer buf; - desc.ulVersion = SECBUFFER_VERSION; - desc.cBuffers = 1; - desc.pBuffers = &buf; - buf.cbBuffer = 0; - buf.BufferType = SECBUFFER_TOKEN; - buf.pvBuffer = NULL; - ULONG attrs; - - secStatus = pSecurityFunctionTable->InitializeSecurityContext(&ctx->ntlmWindowsHandles->credHandle, NULL, - const_cast(L"") /* host */, - ISC_REQ_ALLOCATE_MEMORY, - 0, SECURITY_NETWORK_DREP, - NULL, 0, - &ctx->ntlmWindowsHandles->ctxHandle, &desc, - &attrs, &tsDummy); - if (secStatus == SEC_I_COMPLETE_AND_CONTINUE || - secStatus == SEC_I_CONTINUE_NEEDED) { - pSecurityFunctionTable->CompleteAuthToken(&ctx->ntlmWindowsHandles->ctxHandle, &desc); - } else if (secStatus != SEC_E_OK) { - if ((const char*)buf.pvBuffer) - pSecurityFunctionTable->FreeContextBuffer(buf.pvBuffer); - pSecurityFunctionTable->FreeCredentialsHandle(&ctx->ntlmWindowsHandles->credHandle); - delete ctx->ntlmWindowsHandles; - ctx->ntlmWindowsHandles = 0; - return result; - } - - result = QByteArray((const char*)buf.pvBuffer, buf.cbBuffer); - pSecurityFunctionTable->FreeContextBuffer(buf.pvBuffer); - return result; + return qSspiContinue(ctx, method, host); } -// Phase 2: -// 3. The server receives the token from the client, and uses it as input to the -// AcceptSecurityContext SSPI function. This creates a local security context on -// the server to represent the client, and yields an authentication response token -// (the Type 2 message), which is sent to the client. - -// Phase 3: -static QByteArray qNtlmPhase3_SSPI(QAuthenticatorPrivate *ctx, const QByteArray& phase2data) +static QByteArray qSspiContinue(QAuthenticatorPrivate *ctx, QAuthenticatorPrivate::Method method, + const QString &host, const QByteArray &challenge) { - // 4. The client receives the response token from the server and calls - // InitializeSecurityContext again, passing the server's token as input. - // This provides us with another authentication request token (the Type 3 message). - // The return value indicates that the security context was successfully initialized; - // the token is sent to the server. - QByteArray result; + SecBuffer challengeBuf; + SecBuffer responseBuf; + SecBufferDesc challengeDesc; + SecBufferDesc responseDesc; + unsigned long attrs; + TimeStamp expiry; // For Windows 9x compatibility of SSPI calls - if (pSecurityFunctionTable == NULL) - return result; - - SecBuffer type_2, type_3; - SecBufferDesc type_2_desc, type_3_desc; - ULONG attrs; - TimeStamp tsDummy; // For Windows 9x compatibility of SPPI calls - - type_2_desc.ulVersion = type_3_desc.ulVersion = SECBUFFER_VERSION; - type_2_desc.cBuffers = type_3_desc.cBuffers = 1; - type_2_desc.pBuffers = &type_2; - type_3_desc.pBuffers = &type_3; - - type_2.BufferType = SECBUFFER_TOKEN; - type_2.pvBuffer = (PVOID)phase2data.data(); - type_2.cbBuffer = phase2data.length(); - type_3.BufferType = SECBUFFER_TOKEN; - type_3.pvBuffer = 0; - type_3.cbBuffer = 0; - - SECURITY_STATUS secStatus = pSecurityFunctionTable->InitializeSecurityContext(&ctx->ntlmWindowsHandles->credHandle, - &ctx->ntlmWindowsHandles->ctxHandle, - const_cast(L"") /* host */, - ISC_REQ_ALLOCATE_MEMORY, - 0, SECURITY_NETWORK_DREP, &type_2_desc, - 0, &ctx->ntlmWindowsHandles->ctxHandle, &type_3_desc, - &attrs, &tsDummy); - - if (secStatus == SEC_E_OK && ((const char*)type_3.pvBuffer)) { - result = QByteArray((const char*)type_3.pvBuffer, type_3.cbBuffer); - pSecurityFunctionTable->FreeContextBuffer(type_3.pvBuffer); + if (!challenge.isEmpty()) + { + // Setup the challenge "input" security buffer + challengeDesc.ulVersion = SECBUFFER_VERSION; + challengeDesc.cBuffers = 1; + challengeDesc.pBuffers = &challengeBuf; + challengeBuf.BufferType = SECBUFFER_TOKEN; + challengeBuf.pvBuffer = (PVOID)(challenge.data()); + challengeBuf.cbBuffer = challenge.length(); } - pSecurityFunctionTable->FreeCredentialsHandle(&ctx->ntlmWindowsHandles->credHandle); - pSecurityFunctionTable->DeleteSecurityContext(&ctx->ntlmWindowsHandles->ctxHandle); - delete ctx->ntlmWindowsHandles; - ctx->ntlmWindowsHandles = 0; + // Setup the response "output" security buffer + responseDesc.ulVersion = SECBUFFER_VERSION; + responseDesc.cBuffers = 1; + responseDesc.pBuffers = &responseBuf; + responseBuf.BufferType = SECBUFFER_TOKEN; + responseBuf.pvBuffer = nullptr; + responseBuf.cbBuffer = 0; + + // Calculate target (SPN for Negotiate, empty for NTLM) + std::wstring targetNameW = (method == QAuthenticatorPrivate::Negotiate + ? QLatin1String("HTTP/") + host : QString()).toStdWString(); + + // Generate our challenge-response message + SECURITY_STATUS secStatus = pSecurityFunctionTable->InitializeSecurityContext( + &ctx->sspiWindowsHandles->credHandle, + !challenge.isEmpty() ? &ctx->sspiWindowsHandles->ctxHandle : nullptr, + const_cast(targetNameW.data()), + ISC_REQ_ALLOCATE_MEMORY, + 0, SECURITY_NATIVE_DREP, + !challenge.isEmpty() ? &challengeDesc : nullptr, + 0, &ctx->sspiWindowsHandles->ctxHandle, + &responseDesc, &attrs, + &expiry + ); + + if (secStatus == SEC_I_COMPLETE_NEEDED || secStatus == SEC_I_COMPLETE_AND_CONTINUE) { + secStatus = pSecurityFunctionTable->CompleteAuthToken(&ctx->sspiWindowsHandles->ctxHandle, + &responseDesc); + } + + if (secStatus != SEC_I_COMPLETE_AND_CONTINUE && secStatus != SEC_I_CONTINUE_NEEDED) { + pSecurityFunctionTable->FreeCredentialsHandle(&ctx->sspiWindowsHandles->credHandle); + pSecurityFunctionTable->DeleteSecurityContext(&ctx->sspiWindowsHandles->ctxHandle); + ctx->sspiWindowsHandles.reset(nullptr); + } + + result = QByteArray((const char*)responseBuf.pvBuffer, responseBuf.cbBuffer); + pSecurityFunctionTable->FreeContextBuffer(responseBuf.pvBuffer); return result; } -#endif // Q_OS_WIN && !Q_OS_WINRT + +// ---------------------------- End of SSPI code --------------------------------------- + +#elif QT_CONFIG(gssapi) // GSSAPI + +// ---------------------------- GSSAPI code ---------------------------------------------- +// See postgres src/interfaces/libpq/fe-auth.c + +// Fetch all errors of a specific type +static void q_GSSAPI_error_int(const char *message, OM_uint32 stat, int type) +{ + OM_uint32 minStat, msgCtx = 0; + gss_buffer_desc msg; + + do { + gss_display_status(&minStat, stat, type, GSS_C_NO_OID, &msgCtx, &msg); + qDebug() << message << ": " << reinterpret_cast(msg.value); + gss_release_buffer(&minStat, &msg); + } while (msgCtx); +} + +// GSSAPI errors contain two parts; extract both +static void q_GSSAPI_error(const char *message, OM_uint32 majStat, OM_uint32 minStat) +{ + // Fetch major error codes + q_GSSAPI_error_int(message, majStat, GSS_C_GSS_CODE); + + // Add the minor codes as well + q_GSSAPI_error_int(message, minStat, GSS_C_MECH_CODE); +} + +// Send initial GSS authentication token +static QByteArray qGssapiStartup(QAuthenticatorPrivate *ctx, const QString &host) +{ + OM_uint32 majStat, minStat; + + if (!ctx->gssApiHandles) + ctx->gssApiHandles.reset(new QGssApiHandles); + + // Convert target name to internal form + QByteArray serviceName = QStringLiteral("HTTPS@%1").arg(host).toLocal8Bit(); + gss_buffer_desc nameDesc = {static_cast(serviceName.size()), serviceName.data()}; + + majStat = gss_import_name(&minStat, &nameDesc, + GSS_C_NT_HOSTBASED_SERVICE, &ctx->gssApiHandles->targetName); + + if (majStat != GSS_S_COMPLETE) { + q_GSSAPI_error("gss_import_name error", majStat, minStat); + ctx->gssApiHandles.reset(nullptr); + return QByteArray(); + } + + // Call qGssapiContinue with GSS_C_NO_CONTEXT to get initial packet + ctx->gssApiHandles->gssCtx = GSS_C_NO_CONTEXT; + return qGssapiContinue(ctx); +} + +// Continue GSS authentication with next token as needed +static QByteArray qGssapiContinue(QAuthenticatorPrivate *ctx, const QByteArray& challenge) +{ + OM_uint32 majStat, minStat, ignored; + QByteArray result; + gss_buffer_desc inBuf = {0, nullptr}; // GSS input token + gss_buffer_desc outBuf; // GSS output token + + if (!challenge.isEmpty()) { + inBuf.value = const_cast(challenge.data()); + inBuf.length = challenge.length(); + } + + majStat = gss_init_sec_context(&minStat, + GSS_C_NO_CREDENTIAL, + &ctx->gssApiHandles->gssCtx, + ctx->gssApiHandles->targetName, + GSS_C_NO_OID, + GSS_C_MUTUAL_FLAG, + 0, + GSS_C_NO_CHANNEL_BINDINGS, + challenge.isEmpty() ? GSS_C_NO_BUFFER : &inBuf, + nullptr, + &outBuf, + nullptr, + nullptr); + + if (outBuf.length != 0) + result = QByteArray(reinterpret_cast(outBuf.value), outBuf.length); + gss_release_buffer(&ignored, &outBuf); + + if (majStat != GSS_S_COMPLETE && majStat != GSS_S_CONTINUE_NEEDED) { + q_GSSAPI_error("gss_init_sec_context error", majStat, minStat); + gss_release_name(&ignored, &ctx->gssApiHandles->targetName); + if (ctx->gssApiHandles->gssCtx) + gss_delete_sec_context(&ignored, &ctx->gssApiHandles->gssCtx, GSS_C_NO_BUFFER); + ctx->gssApiHandles.reset(nullptr); + } + + if (majStat == GSS_S_COMPLETE) { + gss_release_name(&ignored, &ctx->gssApiHandles->targetName); + ctx->gssApiHandles.reset(nullptr); + } + + return result; +} + +// ---------------------------- End of GSSAPI code ---------------------------------------------- + +#endif // gssapi QT_END_NAMESPACE diff --git a/src/network/kernel/qauthenticator_p.h b/src/network/kernel/qauthenticator_p.h index 265cb7afe2..e201d22650 100644 --- a/src/network/kernel/qauthenticator_p.h +++ b/src/network/kernel/qauthenticator_p.h @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include @@ -61,14 +62,16 @@ QT_BEGIN_NAMESPACE class QHttpResponseHeader; -#ifdef Q_OS_WIN -class QNtlmWindowsHandles; +#if QT_CONFIG(sspi) // SSPI +class QSSPIWindowsHandles; +#elif QT_CONFIG(gssapi) // GSSAPI +class QGssApiHandles; #endif class Q_AUTOTEST_EXPORT QAuthenticatorPrivate { public: - enum Method { None, Basic, Ntlm, DigestMd5 }; + enum Method { None, Basic, Ntlm, DigestMd5, Negotiate }; QAuthenticatorPrivate(); ~QAuthenticatorPrivate(); @@ -79,8 +82,10 @@ public: Method method; QString realm; QByteArray challenge; -#ifdef Q_OS_WIN - QNtlmWindowsHandles *ntlmWindowsHandles; +#if QT_CONFIG(sspi) // SSPI + QScopedPointer sspiWindowsHandles; +#elif QT_CONFIG(gssapi) // GSSAPI + QScopedPointer gssApiHandles; #endif bool hasFailed; //credentials have been tried but rejected by server. @@ -100,7 +105,7 @@ public: QString workstation; QString userDomain; - QByteArray calculateResponse(const QByteArray &method, const QByteArray &path); + QByteArray calculateResponse(const QByteArray &method, const QByteArray &path, const QString& host); inline static QAuthenticatorPrivate *getPrivate(QAuthenticator &auth) { return auth.d; } inline static const QAuthenticatorPrivate *getPrivate(const QAuthenticator &auth) { return auth.d; } diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp index 49ea17f9f8..6cae29193d 100644 --- a/src/network/socket/qhttpsocketengine.cpp +++ b/src/network/socket/qhttpsocketengine.cpp @@ -524,7 +524,7 @@ void QHttpSocketEngine::slotSocketConnected() //qDebug() << "slotSocketConnected: priv=" << priv << (priv ? (int)priv->method : -1); if (priv && priv->method != QAuthenticatorPrivate::None) { d->credentialsSent = true; - data += "Proxy-Authorization: " + priv->calculateResponse(method, path); + data += "Proxy-Authorization: " + priv->calculateResponse(method, path, d->proxy.hostName()); data += "\r\n"; } data += "\r\n"; diff --git a/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp b/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp index 55053842dc..8cef351554 100644 --- a/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp +++ b/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp @@ -93,7 +93,7 @@ void tst_QAuthenticator::basicAuth() QCOMPARE(priv->phase, QAuthenticatorPrivate::Start); - QCOMPARE(priv->calculateResponse("GET", "/").constData(), QByteArray("Basic " + expectedReply).constData()); + QCOMPARE(priv->calculateResponse("GET", "/", "").constData(), QByteArray("Basic " + expectedReply).constData()); } void tst_QAuthenticator::ntlmAuth_data() @@ -133,9 +133,9 @@ void tst_QAuthenticator::ntlmAuth() headers << qMakePair("WWW-Authenticate", "NTLM"); priv->parseHttpResponse(headers, /*isProxy = */ false); if (sso) - QVERIFY(priv->calculateResponse("GET", "/").startsWith("NTLM ")); + QVERIFY(priv->calculateResponse("GET", "/", "").startsWith("NTLM ")); else - QCOMPARE(priv->calculateResponse("GET", "/").constData(), "NTLM TlRMTVNTUAABAAAABYIIAAAAAAAAAAAAAAAAAAAAAAA="); + QCOMPARE(priv->calculateResponse("GET", "/", "").constData(), "NTLM TlRMTVNTUAABAAAABYIIAAAAAAAAAAAAAAAAAAAAAAA="); // NTLM phase 2: challenge headers.clear(); @@ -146,7 +146,7 @@ void tst_QAuthenticator::ntlmAuth() QEXPECT_FAIL("with-realm-sso", "NTLM authentication code doesn't extract the realm", Continue); QCOMPARE(auth.realm(), realm); - QVERIFY(priv->calculateResponse("GET", "/").startsWith("NTLM ")); + QVERIFY(priv->calculateResponse("GET", "/", "").startsWith("NTLM ")); } void tst_QAuthenticator::equalityOperators() From 2f4c6582363d3fd2ece331913c4baedd6dae1061 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 15 Feb 2019 15:04:29 +0100 Subject: [PATCH 038/292] Mark QEglFSKmsEglDeviceIntegration::presentBuffer as override clang complains; this makes it build Change-Id: I874c51ea4500edcf3f0bb9c79f0ef0f36309d579 Reviewed-by: Laszlo Agocs --- .../eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h index 0c64d83b12..a5697ec831 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h @@ -62,7 +62,7 @@ public: bool supportsPBuffers() const override; QEglFSWindow *createWindow(QWindow *window) const override; - void presentBuffer(QPlatformSurface *surface); + void presentBuffer(QPlatformSurface *surface) override; EGLDeviceEXT eglDevice() const { return m_egl_device; } From c93670c5a03cecbca9bb43aff65ceea3a401c7b1 Mon Sep 17 00:00:00 2001 From: JiDe Zhang Date: Tue, 6 Nov 2018 15:29:03 +0800 Subject: [PATCH 039/292] QGenericUnixTheme: use QStandardPaths get the xdg data path The corresponding interface is already provided in QStandardPaths. We should use QStandardPaths::GenericDataLocation instead of the environment variable XDG_DATA_DIRS. Change-Id: I0e89e8c86d629585ec7d9a12989f24335aa6e3ba Reviewed-by: Anton Kudryavtsev Reviewed-by: Dmitry Shachnev Reviewed-by: Friedemann Kleint Reviewed-by: David Faure --- .../themes/genericunix/qgenericunixthemes.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp index 1003812767..7b3f9b624a 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp @@ -172,15 +172,9 @@ QStringList QGenericUnixTheme::xdgIconThemePaths() if (homeIconDir.isDir()) paths.prepend(homeIconDir.absoluteFilePath()); - QString xdgDirString = QFile::decodeName(qgetenv("XDG_DATA_DIRS")); - if (xdgDirString.isEmpty()) - xdgDirString = QLatin1String("/usr/local/share/:/usr/share/"); - const auto xdgDirs = xdgDirString.splitRef(QLatin1Char(':')); - for (const QStringRef &xdgDir : xdgDirs) { - const QFileInfo xdgIconsDir(xdgDir + QLatin1String("/icons")); - if (xdgIconsDir.isDir()) - paths.append(xdgIconsDir.absoluteFilePath()); - } + paths.append(QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, + QStringLiteral("icons"), + QStandardPaths::LocateDirectory)); return paths; } From ac7f46dd9114051756f56571b9cb3bda002314a1 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Mon, 5 Nov 2018 17:07:03 +0200 Subject: [PATCH 040/292] Unix: QPageSetupDialog: Use print device default paper size When invoking QPageSetupDialog from QPrintPreviewDialog, don't construct a new QPageSetupDialog every time the pageSetup action is triggered, instead reuse the dialog if it's already been created. This way setPrinter is called only once. This matches how QPrintDialog invokes QPageSetupDialog. Set the default print device paper size in initPageSizes() instead of setPrinter(). Change-Id: Ic82e6dd47ee00ecdd942c5ba59dbf09fb18ef218 Reviewed-by: Frederik Gladhorn Reviewed-by: Andy Shaw --- .../dialogs/qpagesetupdialog_unix.cpp | 26 ++++++++++++------- .../dialogs/qprintpreviewdialog.cpp | 12 ++++++--- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp index d9b4a84aa9..1d8af9dbf0 100644 --- a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp +++ b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp @@ -361,13 +361,21 @@ void QPageSetupWidget::initPageSizes() QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get(); if (ps) { QPrintDevice printDevice = ps->createPrintDevice(m_printerName); + const QPageSize defaultSize = printDevice.defaultPageSize(); const auto pageSizes = printDevice.supportedPageSizes(); for (const QPageSize &pageSize : pageSizes) m_ui.pageSizeCombo->addItem(pageSize.name(), QVariant::fromValue(pageSize)); - if (m_ui.pageSizeCombo->count() > 0 && printDevice.supportsCustomPageSizes()) { - m_ui.pageSizeCombo->addItem(tr("Custom")); - m_realCustomPageSizeIndex = m_ui.pageSizeCombo->count() - 1; + if (m_ui.pageSizeCombo->count() > 0) { + if (printDevice.supportsCustomPageSizes()) { + m_ui.pageSizeCombo->addItem(tr("Custom")); + m_realCustomPageSizeIndex = m_ui.pageSizeCombo->count() - 1; + } m_blockSignals = false; + + // If the defaultSize is index 0, setCurrentIndex won't emit the currentIndexChanged + // signal; workaround the issue by initially setting the currentIndex to -1 + m_ui.pageSizeCombo->setCurrentIndex(-1); + m_ui.pageSizeCombo->setCurrentIndex(m_ui.pageSizeCombo->findData(QVariant::fromValue(defaultSize))); return; } } @@ -403,12 +411,6 @@ void QPageSetupWidget::setPrinter(QPrinter *printer, QPrintDevice *printDevice, // Initialize the layout to the current QPrinter layout m_pageLayout = m_printer->pageLayout(); - if (printDevice) { - const QPageSize pageSize = printDevice->defaultPageSize(); - const QMarginsF printable = printDevice->printableMargins(pageSize, m_pageLayout.orientation(), m_printer->resolution()); - m_pageLayout.setPageSize(pageSize, qt_convertMargins(printable, QPageLayout::Point, m_pageLayout.units())); - } - // Assume if margins are Points then is by default, so set to locale default units if (m_pageLayout.units() == QPageLayout::Point) { if (QLocale().measurementSystem() == QLocale::MetricSystem) @@ -735,8 +737,12 @@ int QPageSetupDialog::exec() Q_D(QPageSetupDialog); int ret = QDialog::exec(); - if (ret == Accepted) + if (ret == Accepted) { static_cast (d)->widget->setupPrinter(); + static_cast (d)->widget->updateSavedValues(); + } else { + static_cast (d)->widget->revertToSavedValues(); + } return ret; } diff --git a/src/printsupport/dialogs/qprintpreviewdialog.cpp b/src/printsupport/dialogs/qprintpreviewdialog.cpp index e6b665f82c..258741c35c 100644 --- a/src/printsupport/dialogs/qprintpreviewdialog.cpp +++ b/src/printsupport/dialogs/qprintpreviewdialog.cpp @@ -152,8 +152,8 @@ class QPrintPreviewDialogPrivate : public QDialogPrivate Q_DECLARE_PUBLIC(QPrintPreviewDialog) public: QPrintPreviewDialogPrivate() - : printDialog(nullptr), ownPrinter(false), - initialized(false) {} + : printDialog(nullptr), pageSetupDialog(nullptr), + ownPrinter(false), initialized(false) {} // private slots void _q_fit(QAction *action); @@ -178,6 +178,7 @@ public: void updateZoomFactor(); QPrintDialog *printDialog; + QPageSetupDialog *pageSetupDialog; QPrintPreviewWidget *preview; QPrinter *printer; bool ownPrinter; @@ -602,8 +603,10 @@ void QPrintPreviewDialogPrivate::_q_pageSetup() { Q_Q(QPrintPreviewDialog); - QPageSetupDialog pageSetup(printer, q); - if (pageSetup.exec() == QDialog::Accepted) { + if (!pageSetupDialog) + pageSetupDialog = new QPageSetupDialog(printer, q); + + if (pageSetupDialog->exec() == QDialog::Accepted) { // update possible orientation changes if (preview->orientation() == QPrinter::Portrait) { portraitAction->setChecked(true); @@ -713,6 +716,7 @@ QPrintPreviewDialog::~QPrintPreviewDialog() if (d->ownPrinter) delete d->printer; delete d->printDialog; + delete d->pageSetupDialog; } /*! From d15b02ff291e3124d9bb8ac3b06b704c292f52ab Mon Sep 17 00:00:00 2001 From: Paul Lemire Date: Wed, 20 Feb 2019 09:54:07 +0100 Subject: [PATCH 041/292] QOpenGLTexture::setData add overloads to allow specifying sub images All current setData implementation only allow to specify a full size sub image for a given mip level. In some cases, we might only want to update a small region on an image, in which cases being able to specify the x, y, z offsets as well as the dimensions is required. Change-Id: I880cfcc67a814733e8ab880aa8766c87b7bc7e45 Reviewed-by: Giuseppe D'Angelo --- src/gui/opengl/qopengltexture.cpp | 234 ++++++++++++++++++++++++++++++ src/gui/opengl/qopengltexture.h | 26 ++++ src/gui/opengl/qopengltexture_p.h | 4 + 3 files changed, 264 insertions(+) diff --git a/src/gui/opengl/qopengltexture.cpp b/src/gui/opengl/qopengltexture.cpp index 5b7956d31e..f25988585e 100644 --- a/src/gui/opengl/qopengltexture.cpp +++ b/src/gui/opengl/qopengltexture.cpp @@ -1467,6 +1467,122 @@ void QOpenGLTexturePrivate::setData(int mipLevel, int layer, int layerCount, QOp } } +void QOpenGLTexturePrivate::setData(int xOffset, int yOffset, int zOffset, int width, int height, int depth, + int mipLevel, int layer, int layerCount, QOpenGLTexture::CubeMapFace cubeFace, + QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, + const void *data, const QOpenGLPixelTransferOptions * const options) +{ + switch (target) { + case QOpenGLTexture::Target1D: + Q_UNUSED(layer); + Q_UNUSED(cubeFace); + Q_UNUSED(layerCount); + Q_UNUSED(yOffset); + Q_UNUSED(zOffset); + Q_UNUSED(height); + Q_UNUSED(depth); + texFuncs->glTextureSubImage1D(textureId, target, bindingTarget, mipLevel, + xOffset, width, + sourceFormat, sourceType, data, options); + break; + + case QOpenGLTexture::Target1DArray: + Q_UNUSED(cubeFace); + Q_UNUSED(yOffset); + Q_UNUSED(zOffset); + Q_UNUSED(height); + Q_UNUSED(depth); + texFuncs->glTextureSubImage2D(textureId, target, bindingTarget, mipLevel, + xOffset, layer, + width, + layerCount, + sourceFormat, sourceType, data, options); + break; + + case QOpenGLTexture::Target2D: + Q_UNUSED(layer); + Q_UNUSED(cubeFace); + Q_UNUSED(layerCount); + Q_UNUSED(zOffset); + Q_UNUSED(depth); + texFuncs->glTextureSubImage2D(textureId, target, bindingTarget, mipLevel, + xOffset, yOffset, + width, height, + sourceFormat, sourceType, data, options); + break; + + case QOpenGLTexture::Target2DArray: + Q_UNUSED(cubeFace); + Q_UNUSED(zOffset); + Q_UNUSED(depth); + texFuncs->glTextureSubImage3D(textureId, target, bindingTarget, mipLevel, + xOffset, yOffset, layer, + width, height, layerCount, + sourceFormat, sourceType, data, options); + break; + + case QOpenGLTexture::Target3D: + Q_UNUSED(cubeFace); + Q_UNUSED(layerCount); + texFuncs->glTextureSubImage3D(textureId, target, bindingTarget, mipLevel, + xOffset, yOffset, zOffset, + width, height, depth, + sourceFormat, sourceType, data, options); + break; + + case QOpenGLTexture::TargetCubeMap: + Q_UNUSED(layer); + Q_UNUSED(layerCount); + Q_UNUSED(zOffset); + Q_UNUSED(depth); + texFuncs->glTextureSubImage2D(textureId, cubeFace, bindingTarget, mipLevel, + xOffset, yOffset, + width, height, + sourceFormat, sourceType, data, options); + break; + + case QOpenGLTexture::TargetCubeMapArray: { + Q_UNUSED(zOffset); + Q_UNUSED(depth); + int faceIndex = cubeFace - QOpenGLTexture::CubeMapPositiveX; + int layerFace = 6 * layer + faceIndex; + texFuncs->glTextureSubImage3D(textureId, target, bindingTarget, mipLevel, + xOffset, yOffset, layerFace, + width, height, + layerCount, + sourceFormat, sourceType, data, options); + break; + } + + case QOpenGLTexture::TargetRectangle: + Q_UNUSED(mipLevel); + Q_UNUSED(layer); + Q_UNUSED(cubeFace); + Q_UNUSED(layerCount); + Q_UNUSED(zOffset); + Q_UNUSED(depth); + texFuncs->glTextureSubImage2D(textureId, target, bindingTarget, 0, + xOffset, yOffset, + width, height, + sourceFormat, sourceType, data, options); + break; + + case QOpenGLTexture::Target2DMultisample: + case QOpenGLTexture::Target2DMultisampleArray: + case QOpenGLTexture::TargetBuffer: + // We don't upload pixel data for these targets + qWarning("QOpenGLTexture::setData(): Texture target does not support pixel data upload"); + break; + } + + // If requested perform automatic mip map generation + if (mipLevel == 0 && autoGenerateMipMaps && mipLevels > 1) { + Q_Q(QOpenGLTexture); + q->generateMipMaps(); + } +} + + void QOpenGLTexturePrivate::setCompressedData(int mipLevel, int layer, int layerCount, QOpenGLTexture::CubeMapFace cubeFace, int dataSize, const void *data, @@ -3380,6 +3496,124 @@ void QOpenGLTexture::setData(PixelFormat sourceFormat, PixelType sourceType, d->setData(0, 0, 1, QOpenGLTexture::CubeMapPositiveX, sourceFormat, sourceType, data, options); } +/*! + \since 5.14 + \overload + + This overload is to be used to update a part of the texture. Parameters \a + xOffset, \a yOffset, \a zOffset specify the texel offsets within the + texture. Parameters \a width, \a height and \a depth specify the dimensions + of the sub image. + + The structure of the pixel data pointed to by \a data is specified by \a + sourceFormat and \a sourceType. The pixel data upload can optionally be + controlled by \a options. +*/ +void QOpenGLTexture::setData(int xOffset, int yOffset, int zOffset, + int width, int height, int depth, + PixelFormat sourceFormat, PixelType sourceType, + const void *data, const QOpenGLPixelTransferOptions * const options) +{ + Q_D(QOpenGLTexture); + Q_ASSERT(d->textureId); + d->setData(xOffset, yOffset, zOffset, + width, height, depth, + 0, 0, 1, + QOpenGLTexture::CubeMapPositiveX, sourceFormat, + sourceType, data, options); +} + +/*! + \since 5.14 + \overload + + This overload is to be used to update a part of the texture. Parameters \a + xOffset, \a yOffset, \a zOffset specify the texel offsets within the + texture. Parameters \a width, \a height and \a depth specify the dimensions + of the sub image. The mip map level and layerof the sub image we want to + update are specified with \a mipLevel and \a layer. + + The structure of the pixel data pointed to by \a data is specified by \a + sourceFormat and \a sourceType. The pixel data upload can optionally be + controlled by \a options. +*/ +void QOpenGLTexture::setData(int xOffset, int yOffset, int zOffset, + int width, int height, int depth, + int mipLevel, int layer, + PixelFormat sourceFormat, PixelType sourceType, + const void *data, const QOpenGLPixelTransferOptions * const options) +{ + Q_D(QOpenGLTexture); + Q_ASSERT(d->textureId); + d->setData(xOffset, yOffset, zOffset, + width, height, depth, + mipLevel, layer, 1, + QOpenGLTexture::CubeMapPositiveX, sourceFormat, + sourceType, data, options); +} + +/*! + \since 5.14 + \overload + + This overload is to be used to update a part of the texture. Parameters \a + xOffset, \a yOffset, \a zOffset specify the texel offsets within the + texture. Parameters \a width, \a height and \a depth specify the dimensions + of the sub image.The mip map level, layer and cube map face of the sub + image we want to update are specified with \a mipLevel, \a layer and \a + face. + + The structure of the pixel data pointed to by \a data is specified by \a + sourceFormat and \a sourceType. The pixel data upload can optionally be + controlled by \a options. +*/ +void QOpenGLTexture::setData(int xOffset, int yOffset, int zOffset, + int width, int height, int depth, + int mipLevel, int layer, + CubeMapFace face, + PixelFormat sourceFormat, PixelType sourceType, + const void *data, const QOpenGLPixelTransferOptions * const options) +{ + Q_D(QOpenGLTexture); + Q_ASSERT(d->textureId); + d->setData(xOffset, yOffset, zOffset, + width, height, depth, + mipLevel, layer, 1, + face, sourceFormat, + sourceType, data, options); +} + +/*! + \since 5.14 + \overload + + This overload is to be used to update a part of the texture. Parameters \a + xOffset, \a yOffset, \a zOffset specify the texel offsets within the + texture. Parameters \a width, \a height and \a depth specify the dimensions + of the sub image.The mip map level, starting layer, cube map face and + number of layers of the sub image we want to update are specified with \a + mipLevel, \a layer, \a face and \a layerCount. + + The structure of the pixel data pointed to by \a data is specified by \a + sourceFormat and \a sourceType. The pixel data upload can optionally be + controlled by \a options. +*/ +void QOpenGLTexture::setData(int xOffset, int yOffset, int zOffset, + int width, int height, int depth, + int mipLevel, int layer, + CubeMapFace face, int layerCount, + PixelFormat sourceFormat, PixelType sourceType, + const void *data, const QOpenGLPixelTransferOptions * const options) +{ + Q_D(QOpenGLTexture); + Q_ASSERT(d->textureId); + d->setData(xOffset, yOffset, zOffset, + width, height, depth, + mipLevel, layer, layerCount, + face, sourceFormat, + sourceType, data, options); +} + #if QT_DEPRECATED_SINCE(5, 3) /*! \obsolete diff --git a/src/gui/opengl/qopengltexture.h b/src/gui/opengl/qopengltexture.h index c0c5283374..7d984babc8 100644 --- a/src/gui/opengl/qopengltexture.h +++ b/src/gui/opengl/qopengltexture.h @@ -485,6 +485,32 @@ public: void setData(PixelFormat sourceFormat, PixelType sourceType, const void *data, const QOpenGLPixelTransferOptions * const options = nullptr); + void setData(int xOffset, int yOffset, int zOffset, + int width, int height, int depth, + PixelFormat sourceFormat, PixelType sourceType, + const void *data, const QOpenGLPixelTransferOptions * const options = nullptr); + void setData(int xOffset, int yOffset, int zOffset, + int width, int height, int depth, int mipLevel, + PixelFormat sourceFormat, PixelType sourceType, + const void *data, const QOpenGLPixelTransferOptions * const options = nullptr); + void setData(int xOffset, int yOffset, int zOffset, + int width, int height, int depth, + int mipLevel, int layer, + PixelFormat sourceFormat, PixelType sourceType, + const void *data, const QOpenGLPixelTransferOptions * const options = nullptr); + void setData(int xOffset, int yOffset, int zOffset, + int width, int height, int depth, + int mipLevel, int layer, + CubeMapFace cubeFace, + PixelFormat sourceFormat, PixelType sourceType, + const void *data, const QOpenGLPixelTransferOptions * const options = nullptr); + void setData(int xOffset, int yOffset, int zOffset, + int width, int height, int depth, + int mipLevel, int layer, + CubeMapFace cubeFace, int layerCount, + PixelFormat sourceFormat, PixelType sourceType, + const void *data, const QOpenGLPixelTransferOptions * const options = nullptr); + // Compressed data upload // ### Qt 6: remove the non-const void * overloads #if QT_DEPRECATED_SINCE(5, 3) diff --git a/src/gui/opengl/qopengltexture_p.h b/src/gui/opengl/qopengltexture_p.h index f7694f77bc..9f3457ad0a 100644 --- a/src/gui/opengl/qopengltexture_p.h +++ b/src/gui/opengl/qopengltexture_p.h @@ -101,6 +101,10 @@ public: void setData(int mipLevel, int layer, int layerCount, QOpenGLTexture::CubeMapFace cubeFace, QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, const void *data, const QOpenGLPixelTransferOptions * const options); + void setData(int xOffset, int yOffset, int zOffset, int width, int height, int depth, + int mipLevel, int layer, int layerCount, QOpenGLTexture::CubeMapFace cubeFace, + QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, + const void *data, const QOpenGLPixelTransferOptions * const options); void setCompressedData(int mipLevel, int layer, int layerCount, QOpenGLTexture::CubeMapFace cubeFace, int dataSize, const void *data, const QOpenGLPixelTransferOptions * const options); From 2ec47d6cb53066b052c13d088e249a44f8a04c79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 26 Feb 2019 12:57:00 +0100 Subject: [PATCH 042/292] Fix crash in QTest's signal dumper It Q_ASSERTs that argv is not a nullptr, so it would fail when an unconnected signal with 0 arguments was emitted. Change-Id: I5dd810fbeea5b6b511eff4705efdaa6a55739604 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qobject.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 1382015d76..63bb386107 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -3593,6 +3593,10 @@ void doActivate(QObject *sender, int signal_index, void **argv) const QSignalSpyCallbackSet *signal_spy_set = callbacks_enabled ? qt_signal_spy_callback_set.load() : nullptr; + void *empty_argv[] = { nullptr }; + if (!argv) + argv = empty_argv; + if (!sp->isSignalConnected(signal_index, false)) { // The possible declarative connection is done, and nothing else is connected if (callbacks_enabled && signal_spy_set->signal_begin_callback != nullptr) @@ -3604,10 +3608,6 @@ void doActivate(QObject *sender, int signal_index, void **argv) return; } - void *empty_argv[] = { nullptr }; - if (!argv) - argv = empty_argv; - if (callbacks_enabled && signal_spy_set->signal_begin_callback != nullptr) signal_spy_set->signal_begin_callback(sender, signal_index, argv); Q_TRACE(QMetaObject_activate_begin_signal, sender, signal_index); From 1844f011f67a767d163d16d5338ad24ade7eb0c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Thu, 7 Feb 2019 13:23:36 +0100 Subject: [PATCH 043/292] Convert the QSocks5SocketEngine test to use Docker Change-Id: I5d223758471a72c93ad57d250001c1de51a208cd Reviewed-by: Timur Pocheptsov --- tests/auto/network-settings.h | 24 ++++++++++- .../qsocks5socketengine.pro | 6 +++ .../tst_qsocks5socketengine.cpp | 42 +++++++++++-------- tests/testserver/cyrus/cyrus.sh | 34 +++++++++++++++ tests/testserver/docker-compose.yml | 12 ++++++ 5 files changed, 98 insertions(+), 20 deletions(-) create mode 100755 tests/testserver/cyrus/cyrus.sh diff --git a/tests/auto/network-settings.h b/tests/auto/network-settings.h index f162c3ae9f..092830a51a 100644 --- a/tests/auto/network-settings.h +++ b/tests/auto/network-settings.h @@ -72,15 +72,20 @@ public: } #ifdef QT_NETWORK_LIB - static QHostAddress serverIP() + static QHostAddress getServerIpImpl(const QString &serverName) { - const QHostInfo info = QHostInfo::fromName(serverName()); + const QHostInfo info = QHostInfo::fromName(serverName); if (info.error()) { QTest::qFail(qPrintable(info.errorString()), __FILE__, __LINE__); return QHostAddress(); } return info.addresses().constFirst(); } + + static QHostAddress serverIP() + { + return getServerIpImpl(serverName()); + } #endif static bool compareReplyIMAP(QByteArray const& actual) @@ -214,4 +219,19 @@ public: return serverName(); #endif } + static QString imapServerName() + { +#ifdef QT_TEST_SERVER_NAME + return QString("cyrus.") % serverDomainName(); +#else + return serverName(); +#endif + } + +#ifdef QT_NETWORK_LIB + static QHostAddress imapServerIp() + { + return getServerIpImpl(imapServerName()); + } +#endif }; diff --git a/tests/auto/network/socket/qsocks5socketengine/qsocks5socketengine.pro b/tests/auto/network/socket/qsocks5socketengine/qsocks5socketengine.pro index 71ceafa133..ca9e44873c 100644 --- a/tests/auto/network/socket/qsocks5socketengine/qsocks5socketengine.pro +++ b/tests/auto/network/socket/qsocks5socketengine/qsocks5socketengine.pro @@ -11,3 +11,9 @@ MOC_DIR=tmp QT = core-private network-private testlib requires(qtConfig(private_tests)) + +# Only on Linux until cyrus has been added to docker-compose-for-{windows,macOS}.yml and tested +linux { + QT_TEST_SERVER_LIST = danted apache2 cyrus + include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) +} diff --git a/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp b/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp index 1212ea20e5..464054f8a6 100644 --- a/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp +++ b/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp @@ -137,7 +137,13 @@ private slots: void tst_QSocks5SocketEngine::initTestCase() { +#ifdef QT_TEST_SERVER + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::socksProxyServerName(), 1080)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpServerName(), 80)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::imapServerName(), 143)); +#else QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); +#endif } //--------------------------------------------------------------------------- @@ -293,13 +299,13 @@ void tst_QSocks5SocketEngine::simpleConnectToIMAP() QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); - socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080)); + socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1080)); - QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143)); + QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::imapServerIp(), 143)); QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState); QVERIFY(socketDevice.waitForWrite()); QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState); - QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::serverIP()); + QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::imapServerIp()); // Wait for the greeting QVERIFY(socketDevice.waitForRead()); @@ -347,10 +353,10 @@ void tst_QSocks5SocketEngine::simpleErrorsAndStates() // Initialize device QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); - socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080)); + socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1080)); QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); - QVERIFY(!socketDevice.connectToHost(QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first(), 8088)); + QVERIFY(!socketDevice.connectToHost(QHostInfo::fromName(QtNetworkSettings::socksProxyServerName()).addresses().first(), 8088)); QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState); if (socketDevice.waitForWrite(15000)) { QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState || @@ -433,7 +439,7 @@ void tst_QSocks5SocketEngine::serverTest() // Initialize a Tcp socket QVERIFY(server.initialize(QAbstractSocket::TcpSocket)); - QNetworkProxy proxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080); + QNetworkProxy proxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1080); server.setProxy(proxy); @@ -510,7 +516,7 @@ void tst_QSocks5SocketEngine::udpTest() QVERIFY(udpSocket.initialize(QAbstractSocket::UdpSocket)); QVERIFY(udpSocket.isValid()); - QNetworkProxy proxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080); + QNetworkProxy proxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1080); udpSocket.setProxy(proxy); @@ -564,7 +570,7 @@ void tst_QSocks5SocketEngine::tcpSocketBlockingTest() QTcpSocket socket; // Connect - socket.connectToHost(QtNetworkSettings::serverName(), 143); + socket.connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket.waitForConnected()); QCOMPARE(socket.state(), QTcpSocket::ConnectedState); @@ -635,7 +641,7 @@ void tst_QSocks5SocketEngine::tcpSocketNonBlockingTest() }); // Connect - socket.connectToHost(QtNetworkSettings::serverName(), 143); + socket.connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket.state() == QTcpSocket::HostLookupState || socket.state() == QTcpSocket::ConnectingState); @@ -754,13 +760,13 @@ void tst_QSocks5SocketEngine::downloadBigFile() << " (" << stopWatch.elapsed() << "ms)"; }); - socket.connectToHost(QtNetworkSettings::serverName(), 80); + socket.connectToHost(QtNetworkSettings::httpServerName(), 80); QTestEventLoop::instance().enterLoop(30); if (QTestEventLoop::instance().timeout()) QFAIL("Network operation timed out"); - QByteArray hostName = QtNetworkSettings::serverName().toLatin1(); + QByteArray hostName = QtNetworkSettings::httpServerName().toLatin1(); QCOMPARE(socket.state(), QAbstractSocket::ConnectedState); QVERIFY(socket.write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0); QVERIFY(socket.write("HOST: ") > 0); @@ -791,13 +797,13 @@ void tst_QSocks5SocketEngine::passwordAuth() QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); - socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080, "qsockstest", "password")); + socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1080, "qsockstest", "password")); // Connect to imap.trolltech.com's IP - QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143)); + QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::imapServerIp(), 143)); QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState); QVERIFY(socketDevice.waitForWrite()); - if (!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143)) { + if (!socketDevice.connectToHost(QtNetworkSettings::imapServerIp(), 143)) { qDebug("%d, %s", socketDevice.error(), socketDevice.errorString().toLatin1().constData()); } QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState); @@ -857,19 +863,19 @@ void tst_QSocks5SocketEngine::passwordAuth2() QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); - socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1081)); + socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1081)); socketDevice.setReceiver(this); - QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143)); + QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::imapServerIp(), 143)); QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState); while (socketDevice.state() == QAbstractSocket::ConnectingState) { QVERIFY(socketDevice.waitForWrite()); - socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143); + socketDevice.connectToHost(QtNetworkSettings::imapServerIp(), 143); } if (socketDevice.state() != QAbstractSocket::ConnectedState) qDebug("%d, %s", socketDevice.error(), socketDevice.errorString().toLatin1().constData()); QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState); - QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::serverIP()); + QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::imapServerIp()); // Wait for the greeting QVERIFY(socketDevice.waitForRead()); diff --git a/tests/testserver/cyrus/cyrus.sh b/tests/testserver/cyrus/cyrus.sh new file mode 100755 index 0000000000..bd09acffc8 --- /dev/null +++ b/tests/testserver/cyrus/cyrus.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +############################################################################# +## +## Copyright (C) 2019 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the test suite of the Qt Toolkit. +## +## $QT_BEGIN_LICENSE:GPL$ +## 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 or (at your option) any later version +## approved by the KDE Free Qt Foundation. The licenses are as published by +## the Free Software Foundation and appearing in the file LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +set -ex + +service cyrus-imapd start diff --git a/tests/testserver/docker-compose.yml b/tests/testserver/docker-compose.yml index be65e5a26a..fe39a49cca 100644 --- a/tests/testserver/docker-compose.yml +++ b/tests/testserver/docker-compose.yml @@ -76,8 +76,20 @@ services: - apache2:apache2.${TEST_DOMAIN} - vsftpd:vsftpd.${TEST_DOMAIN} - ftp-proxy:ftp-proxy.${TEST_DOMAIN} + - cyrus:cyrus.${TEST_DOMAIN} volumes: - ./common:/common:ro - ./danted:/service:ro entrypoint: common/startup.sh command: service/danted.sh + + cyrus: + image: qt-test-server-cyrus:c8d72754abc0e501afd624ce838e4df35505abc9 + container_name: qt-test-server-cyrus + domainname: ${TEST_DOMAIN} + hostname: cyrus + volumes: + - ./common:/common:ro + - ./cyrus:/service:ro + entrypoint: common/startup.sh + command: service/cyrus.sh From a247d08faef289dcaab2c7132189e3cf051d27fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 12 Feb 2019 17:05:51 +0100 Subject: [PATCH 044/292] Port tst_qtcpsocket to the docker server The iptables container launches with extra capabilities to actually be able to make changes to the tables. Change-Id: I892fd18853ce882709e21791e6c88217e5029d53 Reviewed-by: Timur Pocheptsov --- tests/auto/network-settings.h | 48 +++++ .../network/socket/qtcpsocket/test/test.pro | 6 + .../socket/qtcpsocket/tst_qtcpsocket.cpp | 174 ++++++++++-------- tests/testserver/docker-compose.yml | 17 ++ tests/testserver/iptables/iptables.sh | 34 ++++ 5 files changed, 206 insertions(+), 73 deletions(-) create mode 100755 tests/testserver/iptables/iptables.sh diff --git a/tests/auto/network-settings.h b/tests/auto/network-settings.h index 092830a51a..bf632c9846 100644 --- a/tests/auto/network-settings.h +++ b/tests/auto/network-settings.h @@ -228,10 +228,58 @@ public: #endif } + static QString echoServerName() + { +#ifdef QT_TEST_SERVER_NAME + return QString("echo.") % serverDomainName(); +#else + return serverName(); +#endif + } + + static QString firewallServerName() + { +#ifdef QT_TEST_SERVER_NAME + return QString("iptables.") % serverDomainName(); +#else + return serverName(); +#endif + } + #ifdef QT_NETWORK_LIB static QHostAddress imapServerIp() { return getServerIpImpl(imapServerName()); } + + static QHostAddress httpServerIp() + { + return getServerIpImpl(httpServerName()); + } + + static QHostAddress httpProxyServerIp() + { + return getServerIpImpl(httpProxyServerName()); + } + + static QHostAddress socksProxyServerIp() + { + return getServerIpImpl(socksProxyServerName()); + } + + static QHostAddress ftpProxyServerIp() + { + return getServerIpImpl(ftpProxyServerName()); + } + + static QHostAddress ftpServerIp() + { + return getServerIpImpl(ftpServerName()); + } + + static QHostAddress firewallServerIp() + { + return getServerIpImpl(firewallServerName()); + } #endif }; diff --git a/tests/auto/network/socket/qtcpsocket/test/test.pro b/tests/auto/network/socket/qtcpsocket/test/test.pro index 337e75b372..29d9414b03 100644 --- a/tests/auto/network/socket/qtcpsocket/test/test.pro +++ b/tests/auto/network/socket/qtcpsocket/test/test.pro @@ -15,3 +15,9 @@ win32 { } else { DESTDIR = ../ } + +# Only on Linux until cyrus has been added to docker-compose-for-{windows,macOS}.yml and tested +linux { + QT_TEST_SERVER_LIST = danted squid apache2 ftp-proxy vsftpd iptables cyrus + include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) +} diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp index c473230246..abe9845213 100644 --- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp @@ -317,7 +317,7 @@ tst_QTcpSocket::tst_QTcpSocket() connect(earlyConstructedSockets->endPoints[1], SIGNAL(bytesWritten(qint64)), this, SLOT(earlySocketBytesSent(qint64))); earlyConstructedSockets->endPoints[1]->write("hello work"); - firstFailInfo.setAddresses(QList() << QHostAddress("224.0.0.0") << QtNetworkSettings::serverIP()); + firstFailInfo.setAddresses(QList() << QHostAddress("224.0.0.0") << QtNetworkSettings::httpServerIp()); } void tst_QTcpSocket::initTestCase_data() @@ -326,7 +326,6 @@ void tst_QTcpSocket::initTestCase_data() QTest::addColumn("proxyType"); QTest::addColumn("ssl"); - qDebug() << QtNetworkSettings::serverName(); QTest::newRow("WithoutProxy") << false << 0 << false; //QTest::newRow("WithSocks5Proxy") << true << int(Socks5Proxy) << false; ### temporarily disabled, QTBUG-38385 //QTest::newRow("WithSocks5ProxyAuth") << true << int(Socks5Proxy | AuthBasic) << false; ### temporarily disabled, QTBUG-38385 @@ -352,7 +351,17 @@ void tst_QTcpSocket::initTestCase_data() void tst_QTcpSocket::initTestCase() { +#ifdef QT_TEST_SERVER + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpServerName(), 80)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3128)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::imapServerName(), 143)); + //QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::firewallServerName(), 1357)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::socksProxyServerName(), 1080)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::ftpServerName(), 21)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::ftpProxyServerName(), 2121)); +#else QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); +#endif } void tst_QTcpSocket::init() @@ -361,30 +370,33 @@ void tst_QTcpSocket::init() if (setProxy) { #ifndef QT_NO_NETWORKPROXY QFETCH_GLOBAL(int, proxyType); - QList addresses = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses(); - QVERIFY2(addresses.count() > 0, "failed to get ip address for test server"); - QString fluke = addresses.first().toString(); + QList socks5Addresses = QHostInfo::fromName(QtNetworkSettings::socksProxyServerName()).addresses(); + QList httpProxyAddresses = QHostInfo::fromName(QtNetworkSettings::httpProxyServerName()).addresses(); + QVERIFY2(socks5Addresses.count() > 0, "failed to get ip address for SOCKS5 proxy server"); + QVERIFY2(httpProxyAddresses.count() > 0, "failed to get ip address for HTTP proxy server"); + QString socks5Address = socks5Addresses.first().toString(); + QString httpProxyAddress = httpProxyAddresses.first().toString(); QNetworkProxy proxy; switch (proxyType) { case Socks5Proxy: - proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, fluke, 1080); + proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, socks5Address, 1080); break; case Socks5Proxy | AuthBasic: - proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, fluke, 1081); + proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, socks5Address, 1081); break; case HttpProxy | NoAuth: - proxy = QNetworkProxy(QNetworkProxy::HttpProxy, fluke, 3128); + proxy = QNetworkProxy(QNetworkProxy::HttpProxy, httpProxyAddress, 3128); break; case HttpProxy | AuthBasic: - proxy = QNetworkProxy(QNetworkProxy::HttpProxy, fluke, 3129); + proxy = QNetworkProxy(QNetworkProxy::HttpProxy, httpProxyAddress, 3129); break; case HttpProxy | AuthNtlm: - proxy = QNetworkProxy(QNetworkProxy::HttpProxy, fluke, 3130); + proxy = QNetworkProxy(QNetworkProxy::HttpProxy, httpProxyAddress, 3130); break; } QNetworkProxy::setApplicationProxy(proxy); @@ -644,8 +656,8 @@ void tst_QTcpSocket::bind() void tst_QTcpSocket::bindThenResolveHost_data() { QTest::addColumn("hostName"); - QTest::newRow("ip-literal") << QtNetworkSettings::serverIP().toString(); - QTest::newRow("name") << QtNetworkSettings::serverName(); + QTest::newRow("ip-literal") << QtNetworkSettings::httpServerIp().toString(); + QTest::newRow("name") << QtNetworkSettings::httpServerName(); QTest::newRow("first-fail") << firstFailName; } @@ -715,7 +727,7 @@ void tst_QTcpSocket::setSocketDescriptor() #ifdef Q_OS_WIN // need the dummy to ensure winsock is started QTcpSocket *dummy = newSocket(); - dummy->connectToHost(QtNetworkSettings::serverName(), 143); + dummy->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(dummy->waitForConnected()); SOCKET sock = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); @@ -737,7 +749,7 @@ void tst_QTcpSocket::setSocketDescriptor() QCOMPARE(socket->socketDescriptor(), (qintptr)sock); qt_qhostinfo_clear_cache(); //avoid the HostLookupState being skipped due to address being in cache from previous test. - socket->connectToHost(QtNetworkSettings::serverName(), 80); + socket->connectToHost(QtNetworkSettings::httpServerName(), 80); QCOMPARE(socket->state(), QTcpSocket::HostLookupState); QCOMPARE(socket->socketDescriptor(), (qintptr)sock); QVERIFY(socket->waitForConnected(10000)); @@ -758,7 +770,7 @@ void tst_QTcpSocket::socketDescriptor() QTcpSocket *socket = newSocket(); QCOMPARE(socket->socketDescriptor(), (qintptr)-1); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket->state() == QAbstractSocket::HostLookupState || socket->state() == QAbstractSocket::ConnectingState); QVERIFY(socket->waitForConnected(10000)); @@ -775,7 +787,7 @@ void tst_QTcpSocket::blockingIMAP() QTcpSocket *socket = newSocket(); // Connect - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket->waitForConnected(10000)); QCOMPARE(socket->state(), QTcpSocket::ConnectedState); QVERIFY(socket->isValid()); @@ -852,6 +864,14 @@ void tst_QTcpSocket::hostNotFound() socket->connectToHost("nosuchserver.qt-project.org", 80); QVERIFY(!socket->waitForConnected()); QCOMPARE(socket->state(), QTcpSocket::UnconnectedState); +#ifdef QT_TEST_SERVER + QFETCH_GLOBAL(bool, setProxy); + if (setProxy) { + QEXPECT_FAIL("", "QTBUG-73953: The version of Squid in the docker container behaves " + "differently to the one in the network testing server, returning 503 " + "when we expect 404", Continue); + } +#endif QCOMPARE(int(socket->error()), int(QTcpSocket::HostNotFoundError)); delete socket; @@ -861,8 +881,8 @@ void tst_QTcpSocket::hostNotFound() void tst_QTcpSocket::timeoutConnect_data() { QTest::addColumn("address"); - QTest::newRow("host") << QtNetworkSettings::serverName(); - QTest::newRow("ip") << QtNetworkSettings::serverIP().toString(); + QTest::newRow("host") << QtNetworkSettings::firewallServerName(); + QTest::newRow("ip") << QtNetworkSettings::firewallServerIp().toString(); } void tst_QTcpSocket::timeoutConnect() @@ -910,7 +930,7 @@ void tst_QTcpSocket::nonBlockingIMAP() nonBlockingIMAP_socket = socket; // Connect - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket->state() == QTcpSocket::HostLookupState || socket->state() == QTcpSocket::ConnectingState); @@ -1036,7 +1056,7 @@ void tst_QTcpSocket::delayedClose() connect(socket, SIGNAL(connected()), SLOT(nonBlockingIMAP_connected())); connect(socket, SIGNAL(disconnected()), SLOT(exitLoopSlot())); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); enterLoop(30); if (timeout()) @@ -1082,7 +1102,7 @@ QByteArray tst_QTcpSocket::expectedReplyIMAP() void tst_QTcpSocket::fetchExpectedReplyIMAP() { QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY2(socket->waitForConnected(10000), qPrintable(socket->errorString())); QVERIFY2(socket->state() == QTcpSocket::ConnectedState, qPrintable(socket->errorString())); @@ -1101,7 +1121,7 @@ void tst_QTcpSocket::fetchExpectedReplyIMAP() void tst_QTcpSocket::partialRead() { QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket->waitForConnected(10000)); QCOMPARE(socket->state(), QTcpSocket::ConnectedState); char buf[512]; @@ -1125,7 +1145,7 @@ void tst_QTcpSocket::partialRead() void tst_QTcpSocket::unget() { QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket->waitForConnected(10000)); QCOMPARE(socket->state(), QTcpSocket::ConnectedState); char buf[512]; @@ -1162,7 +1182,7 @@ void tst_QTcpSocket::readRegularFile_readyRead() void tst_QTcpSocket::readAllAfterClose() { QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); connect(socket, SIGNAL(readyRead()), SLOT(readRegularFile_readyRead())); enterLoop(10); if (timeout()) @@ -1202,7 +1222,7 @@ void tst_QTcpSocket::openCloseOpenClose() QCOMPARE(socket->state(), QTcpSocket::UnconnectedState); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket->waitForConnected(10000)); socket->close(); } @@ -1225,7 +1245,7 @@ void tst_QTcpSocket::connectDisconnectConnectDisconnect() QCOMPARE(int(socket->peerPort()), 0); QCOMPARE(socket->peerAddress(), QHostAddress()); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket->waitForReadyRead(10000)); QCOMPARE(QString::fromLatin1(socket->read(4)), QString("* OK")); @@ -1429,7 +1449,7 @@ void tst_QTcpSocket::disconnectWhileLookingUp() // just connect and disconnect, then make sure nothing weird happened QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 21); + socket->connectToHost(QtNetworkSettings::ftpServerName(), 21); // check that connect is in progress QVERIFY(socket->state() != QAbstractSocket::UnconnectedState); @@ -1477,7 +1497,7 @@ void tst_QTcpSocket::downloadBigFile() connect(tmpSocket, SIGNAL(readyRead()), SLOT(downloadBigFileSlot())); connect(tmpSocket, SIGNAL(disconnected()), SLOT(exitLoopSlot())); - tmpSocket->connectToHost(QtNetworkSettings::serverName(), 80); + tmpSocket->connectToHost(QtNetworkSettings::httpServerName(), 80); enterLoop(30); if (timeout()) { @@ -1486,7 +1506,7 @@ void tst_QTcpSocket::downloadBigFile() QFAIL("Network operation timed out"); } - QByteArray hostName = QtNetworkSettings::serverName().toLatin1(); + QByteArray hostName = QtNetworkSettings::httpServerName().toLatin1(); QCOMPARE(tmpSocket->state(), QAbstractSocket::ConnectedState); QVERIFY(tmpSocket->write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0); QVERIFY(tmpSocket->write("HOST: ") > 0); @@ -1552,7 +1572,7 @@ void tst_QTcpSocket::downloadBigFileSlot() void tst_QTcpSocket::readLine() { QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket->waitForConnected(5000)); while (!socket->canReadLine()) @@ -1601,7 +1621,7 @@ void tst_QTcpSocket::readLine() void tst_QTcpSocket::readLineString() { QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket->waitForReadyRead(10000)); QByteArray arr = socket->readLine(); @@ -1614,7 +1634,7 @@ void tst_QTcpSocket::readLineString() void tst_QTcpSocket::readChunks() { QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket->waitForConnected(10000)); QVERIFY(socket->waitForReadyRead(5000)); @@ -1634,7 +1654,7 @@ void tst_QTcpSocket::readChunks() void tst_QTcpSocket::waitForBytesWritten() { QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 80); + socket->connectToHost(QtNetworkSettings::httpServerName(), 80); QVERIFY(socket->waitForConnected(10000)); socket->write("GET / HTTP/1.0\r\n\r\n"); @@ -1652,7 +1672,7 @@ void tst_QTcpSocket::waitForBytesWrittenMinusOne() QSKIP("QTBUG-24451 - indefinite wait may hang"); #endif QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 80); + socket->connectToHost(QtNetworkSettings::httpServerName(), 80); QVERIFY(socket->waitForConnected(10000)); socket->write("GET / HTTP/1.0\r\n\r\n"); @@ -1667,7 +1687,7 @@ void tst_QTcpSocket::waitForBytesWrittenMinusOne() void tst_QTcpSocket::waitForReadyRead() { QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 80); + socket->connectToHost(QtNetworkSettings::httpServerName(), 80); socket->write("GET / HTTP/1.0\r\n\r\n"); QVERIFY(socket->waitForReadyRead(5000)); delete socket; @@ -1680,7 +1700,7 @@ void tst_QTcpSocket::waitForReadyReadMinusOne() QSKIP("QTBUG-24451 - indefinite wait may hang"); #endif QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 80); + socket->connectToHost(QtNetworkSettings::httpServerName(), 80); socket->write("GET / HTTP/1.0\r\n\r\n"); QVERIFY(socket->waitForReadyRead(-1)); delete socket; @@ -1693,7 +1713,7 @@ void tst_QTcpSocket::flush() socket->flush(); connect(socket, SIGNAL(connected()), SLOT(exitLoopSlot())); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); enterLoop(60); QVERIFY(socket->isOpen()); @@ -1710,7 +1730,7 @@ void tst_QTcpSocket::flush() void tst_QTcpSocket::synchronousApi() { QTcpSocket *ftpSocket = newSocket(); - ftpSocket->connectToHost(QtNetworkSettings::serverName(), 21); + ftpSocket->connectToHost(QtNetworkSettings::ftpServerName(), 21); ftpSocket->write("QUIT\r\n"); QVERIFY(ftpSocket->waitForDisconnected(10000)); QVERIFY(ftpSocket->bytesAvailable() > 0); @@ -1757,10 +1777,10 @@ void tst_QTcpSocket::recursiveReadyRead() QSignalSpy spy(testSocket, SIGNAL(readyRead())); - testSocket->connectToHost(QtNetworkSettings::serverName(), 143); + testSocket->connectToHost(QtNetworkSettings::imapServerName(), 143); enterLoop(30); QVERIFY2(!timeout(), - "Timed out when connecting to QtNetworkSettings::serverName()."); + "Timed out when connecting to QtNetworkSettings::imapServerName()."); enterLoop(30); QVERIFY2(!timeout(), @@ -1794,7 +1814,7 @@ void tst_QTcpSocket::recursiveReadyReadSlot() void tst_QTcpSocket::atEnd() { QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 21); + socket->connectToHost(QtNetworkSettings::ftpServerName(), 21); QVERIFY(socket->waitForReadyRead(15000)); QTextStream stream(socket); @@ -1802,9 +1822,15 @@ void tst_QTcpSocket::atEnd() QString greeting = stream.readLine(); QVERIFY(stream.atEnd()); +#ifdef QT_TEST_SERVER + // Test server must use some vsFTPd 3.x.x version + QVERIFY2(greeting.length() == sizeof("220 (vsFTPd 3.x.x)")-1, qPrintable(greeting)); + QVERIFY2(greeting.startsWith("220 (vsFTPd 3."), qPrintable(greeting)); +#else // Test server must use some vsFTPd 2.x.x version QVERIFY2(greeting.length() == sizeof("220 (vsFTPd 2.x.x)")-1, qPrintable(greeting)); QVERIFY2(greeting.startsWith("220 (vsFTPd 2."), qPrintable(greeting)); +#endif QVERIFY2(greeting.endsWith(QLatin1Char(')')), qPrintable(greeting)); delete socket; @@ -1835,7 +1861,7 @@ protected: connect(socket, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), Qt::DirectConnection); - socket->connectToHost(QtNetworkSettings::serverName(), 21); + socket->connectToHost(QtNetworkSettings::ftpServerName(), 21); socket->write("QUIT\r\n"); exec(); @@ -1909,7 +1935,7 @@ void tst_QTcpSocket::waitForReadyReadInASlot() tmpSocket = socket; connect(socket, SIGNAL(connected()), this, SLOT(waitForReadyReadInASlotSlot())); - socket->connectToHost(QtNetworkSettings::serverName(), 80); + socket->connectToHost(QtNetworkSettings::httpServerName(), 80); socket->write("GET / HTTP/1.0\r\n\r\n"); enterLoop(30); @@ -2073,7 +2099,7 @@ void tst_QTcpSocket::waitForConnectedInHostLookupSlot() timer.start(15000); connect(tmpSocket, SIGNAL(hostFound()), this, SLOT(hostLookupSlot())); - tmpSocket->connectToHost(QtNetworkSettings::serverName(), 143); + tmpSocket->connectToHost(QtNetworkSettings::imapServerName(), 143); // only execute the loop if not already connected if (tmpSocket->state() != QAbstractSocket::ConnectedState) @@ -2128,7 +2154,7 @@ public slots: inline void doIt() { attemptedToConnect = true; - sock->connectToHost(QtNetworkSettings::serverName(), 80); + sock->connectToHost(QtNetworkSettings::httpServerName(), 80); #if defined(Q_OS_MAC) pthread_yield_np(); @@ -2179,7 +2205,7 @@ void tst_QTcpSocket::readyReadSignalsAfterWaitForReadyRead() QSignalSpy readyReadSpy(socket, SIGNAL(readyRead())); // Connect - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); // Wait for the read QVERIFY(socket->waitForReadyRead(10000)); @@ -2315,7 +2341,7 @@ void tst_QTcpSocket::localAddressEmptyOnBSD() void tst_QTcpSocket::zeroAndMinusOneReturns() { QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 80); + socket->connectToHost(QtNetworkSettings::httpServerName(), 80); socket->write("GET / HTTP/1.0\r\nConnection: keep-alive\r\n\r\n"); QVERIFY(socket->waitForReadyRead(15000)); @@ -2376,7 +2402,7 @@ void tst_QTcpSocket::connectionRefused() connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), &QTestEventLoop::instance(), SLOT(exitLoop())); - socket->connectToHost(QtNetworkSettings::serverName(), 144); + socket->connectToHost(QtNetworkSettings::httpServerName(), 144); enterLoop(10); disconnect(socket, SIGNAL(error(QAbstractSocket::SocketError)), @@ -2523,7 +2549,7 @@ void tst_QTcpSocket::moveToThread0() { // Case 1: Moved after connecting, before waiting for connection. QTcpSocket *socket = newSocket();; - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); socket->moveToThread(0); QVERIFY(socket->waitForConnected(5000)); socket->write("XXX LOGOUT\r\n"); @@ -2535,7 +2561,7 @@ void tst_QTcpSocket::moveToThread0() // Case 2: Moved before connecting QTcpSocket *socket = newSocket(); socket->moveToThread(0); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket->waitForConnected(5000)); socket->write("XXX LOGOUT\r\n"); QVERIFY(socket->waitForBytesWritten(5000)); @@ -2545,7 +2571,7 @@ void tst_QTcpSocket::moveToThread0() { // Case 3: Moved after writing, while waiting for bytes to be written. QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket->waitForConnected(5000)); socket->write("XXX LOGOUT\r\n"); socket->moveToThread(0); @@ -2556,7 +2582,7 @@ void tst_QTcpSocket::moveToThread0() { // Case 4: Moved after writing, while waiting for response. QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket->waitForConnected(5000)); socket->write("XXX LOGOUT\r\n"); QVERIFY(socket->waitForBytesWritten(5000)); @@ -2687,7 +2713,7 @@ void tst_QTcpSocket::taskQtBug5799ConnectionErrorWaitForConnected() // use waitForConnected, e.g. this should use a synchronous select() on the OS level QTcpSocket socket; - socket.connectToHost(QtNetworkSettings::serverName(), 12346); + socket.connectToHost(QtNetworkSettings::httpServerName(), 12346); QTime timer; timer.start(); socket.waitForConnected(10000); @@ -2707,7 +2733,7 @@ void tst_QTcpSocket::taskQtBug5799ConnectionErrorEventLoop() // This testcase uses an event loop QTcpSocket socket; connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), &QTestEventLoop::instance(), SLOT(exitLoop())); - socket.connectToHost(QtNetworkSettings::serverName(), 12346); + socket.connectToHost(QtNetworkSettings::httpServerName(), 12346); QTestEventLoop::instance().enterLoop(10); QVERIFY2(!QTestEventLoop::instance().timeout(), "Connection to closed port timed out instead of refusing, something is wrong"); @@ -2720,7 +2746,7 @@ void tst_QTcpSocket::taskQtBug7054TimeoutErrorResetting() { QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 443); + socket->connectToHost(QtNetworkSettings::httpServerName(), 443); QVERIFY(socket->waitForConnected(5*1000)); QCOMPARE(socket->error(), QAbstractSocket::UnknownSocketError); @@ -2749,10 +2775,12 @@ void tst_QTcpSocket::invalidProxy_data() QTest::addColumn("failsAtConnect"); QTest::addColumn("expectedError"); - QString fluke = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first().toString(); - QTest::newRow("ftp-proxy") << int(QNetworkProxy::FtpCachingProxy) << fluke << 21 << true + const QString ftpAddress = QtNetworkSettings::ftpServerIp().toString(); + const QString httpProxyAddress = QtNetworkSettings::httpProxyServerIp().toString(); + const QString socksProxyAddress = QtNetworkSettings::socksProxyServerIp().toString(); + QTest::newRow("ftp-proxy") << int(QNetworkProxy::FtpCachingProxy) << ftpAddress << 21 << true << int(QAbstractSocket::UnsupportedSocketOperationError); - QTest::newRow("http-caching-proxy") << int(QNetworkProxy::HttpCachingProxy) << fluke << 3128 << true + QTest::newRow("http-caching-proxy") << int(QNetworkProxy::HttpCachingProxy) << httpProxyAddress << 3128 << true << int(QAbstractSocket::UnsupportedSocketOperationError); QTest::newRow("no-such-host-socks5") << int(QNetworkProxy::Socks5Proxy) << "this-host-will-never-exist.qt-project.org" << 1080 << false @@ -2760,9 +2788,9 @@ void tst_QTcpSocket::invalidProxy_data() QTest::newRow("no-such-host-http") << int(QNetworkProxy::HttpProxy) << "this-host-will-never-exist.qt-project.org" << 3128 << false << int(QAbstractSocket::ProxyNotFoundError); - QTest::newRow("http-on-socks5") << int(QNetworkProxy::HttpProxy) << fluke << 1080 << false + QTest::newRow("http-on-socks5") << int(QNetworkProxy::HttpProxy) << socksProxyAddress << 1080 << false << int(QAbstractSocket::ProxyConnectionClosedError); - QTest::newRow("socks5-on-http") << int(QNetworkProxy::Socks5Proxy) << fluke << 3128 << false + QTest::newRow("socks5-on-http") << int(QNetworkProxy::Socks5Proxy) << httpProxyAddress << 3128 << false << int(QAbstractSocket::SocketTimeoutError); } @@ -2781,7 +2809,7 @@ void tst_QTcpSocket::invalidProxy() QTcpSocket *socket = newSocket(); socket->setProxy(proxy); - socket->connectToHost(QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first().toString(), 80); + socket->connectToHost(QtNetworkSettings::httpServerIp().toString(), 80); if (failsAtConnect) { QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState); @@ -2833,48 +2861,48 @@ void tst_QTcpSocket::proxyFactory_data() // tests that do connect - proxyList << QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3129); + proxyList << QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::httpProxyServerName(), 3129); QTest::newRow("http") << proxyList << proxyList.at(0) << false << int(QAbstractSocket::UnknownSocketError); proxyList.clear(); - proxyList << QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1081); + proxyList << QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1081); QTest::newRow("socks5") << proxyList << proxyList.at(0) << false << int(QAbstractSocket::UnknownSocketError); proxyList.clear(); - proxyList << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::serverName(), 3129) - << QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1081); + proxyList << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::httpProxyServerName(), 3129) + << QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1081); QTest::newRow("cachinghttp+socks5") << proxyList << proxyList.at(1) << false << int(QAbstractSocket::UnknownSocketError); proxyList.clear(); - proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::serverName(), 2121) - << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::serverName(), 3129) - << QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1081); + proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::ftpProxyServerName(), 2121) + << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::httpProxyServerName(), 3129) + << QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1081); QTest::newRow("ftp+cachinghttp+socks5") << proxyList << proxyList.at(2) << false << int(QAbstractSocket::UnknownSocketError); // tests that fail to connect proxyList.clear(); - proxyList << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::serverName(), 3129); + proxyList << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::httpProxyServerName(), 3129); QTest::newRow("cachinghttp") << proxyList << QNetworkProxy() << true << int(QAbstractSocket::UnsupportedSocketOperationError); proxyList.clear(); - proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::serverName(), 2121); + proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::ftpProxyServerName(), 2121); QTest::newRow("ftp") << proxyList << QNetworkProxy() << true << int(QAbstractSocket::UnsupportedSocketOperationError); proxyList.clear(); - proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::serverName(), 2121) - << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::serverName(), 3129); + proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::ftpProxyServerName(), 2121) + << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::httpProxyServerName(), 3129); QTest::newRow("ftp+cachinghttp") << proxyList << QNetworkProxy() << true << int(QAbstractSocket::UnsupportedSocketOperationError); @@ -2895,7 +2923,7 @@ void tst_QTcpSocket::proxyFactory() QNetworkProxyFactory::setApplicationProxyFactory(factory); QTcpSocket *socket = newSocket(); - QString host = QtNetworkSettings::serverName(); + QString host = QtNetworkSettings::httpServerName(); socket->connectToHost(host, 80); // Verify that the factory was called properly diff --git a/tests/testserver/docker-compose.yml b/tests/testserver/docker-compose.yml index fe39a49cca..4286c88211 100644 --- a/tests/testserver/docker-compose.yml +++ b/tests/testserver/docker-compose.yml @@ -31,6 +31,9 @@ services: - apache2 external_links: - apache2:apache2.${TEST_DOMAIN} + - cyrus:cyrus.${TEST_DOMAIN} + - iptables:iptables.${TEST_DOMAIN} + - vsftpd:vsftpd.${TEST_DOMAIN} volumes: - ./common:/common:ro - ./squid:/service:ro @@ -93,3 +96,17 @@ services: - ./cyrus:/service:ro entrypoint: common/startup.sh command: service/cyrus.sh + + iptables: + image: qt-test-server-iptables:cb7a8bd6d28602085a88c8ced7d67e28e75781e2 + container_name: qt-test-server-iptables + domainname: ${TEST_DOMAIN} + hostname: iptables + volumes: + - ./common:/common:ro + - ./iptables:/service:ro + entrypoint: common/startup.sh + command: service/iptables.sh + cap_add: + - NET_ADMIN + - NET_RAW diff --git a/tests/testserver/iptables/iptables.sh b/tests/testserver/iptables/iptables.sh new file mode 100755 index 0000000000..9a48686d8b --- /dev/null +++ b/tests/testserver/iptables/iptables.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +############################################################################# +## +## Copyright (C) 2019 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the test suite of the Qt Toolkit. +## +## $QT_BEGIN_LICENSE:GPL$ +## 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 or (at your option) any later version +## approved by the KDE Free Qt Foundation. The licenses are as published by +## the Free Software Foundation and appearing in the file LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +set -ex + +iptables -A INPUT -p tcp --destination-port 1357 -j DROP From c47ec42f02196f387c28ab1a5ac70a23ec642a63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Thu, 21 Feb 2019 15:16:37 +0100 Subject: [PATCH 045/292] Convert tst_qtcpserver to use docker Change-Id: Id456fa8ea6ab4f23b6b83c5f6388e96443ccf9e0 Reviewed-by: Edward Welbourne Reviewed-by: Timur Pocheptsov --- .../network/socket/qtcpserver/test/test.pro | 6 +++ .../socket/qtcpserver/tst_qtcpserver.cpp | 43 +++++++++++-------- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/tests/auto/network/socket/qtcpserver/test/test.pro b/tests/auto/network/socket/qtcpserver/test/test.pro index 4491523383..ac4ed9a989 100644 --- a/tests/auto/network/socket/qtcpserver/test/test.pro +++ b/tests/auto/network/socket/qtcpserver/test/test.pro @@ -16,3 +16,9 @@ win32 { QT = core network testlib MOC_DIR=tmp + +# Only on Linux until cyrus has been added to docker-compose-for-{windows,macOS}.yml and tested +linux { + QT_TEST_SERVER_LIST = danted cyrus squid ftp-proxy + include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) +} diff --git a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp index 161d94d642..22ac9aa076 100644 --- a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp +++ b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp @@ -160,8 +160,15 @@ void tst_QTcpServer::initTestCase_data() void tst_QTcpServer::initTestCase() { +#ifdef QT_TEST_SERVER + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::socksProxyServerName(), 1080)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3128)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::ftpProxyServerName(), 2121)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::imapServerName(), 143)); +#else if (!QtNetworkSettings::verifyTestNetworkSettings()) QSKIP("No network test server available"); +#endif #ifndef QT_NO_BEARERMANAGEMENT QNetworkConfigurationManager man; networkSession = new QNetworkSession(man.defaultConfiguration(), this); @@ -177,7 +184,7 @@ void tst_QTcpServer::init() #ifndef QT_NO_NETWORKPROXY QFETCH_GLOBAL(int, proxyType); if (proxyType == QNetworkProxy::Socks5Proxy) { - QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080)); + QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1080)); } #else // !QT_NO_NETWORKPROXY QSKIP("No proxy support"); @@ -513,7 +520,7 @@ void tst_QTcpServer::waitForConnectionTest() } QTcpSocket findLocalIpSocket; - findLocalIpSocket.connectToHost(QtNetworkSettings::serverName(), 143); + findLocalIpSocket.connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(findLocalIpSocket.waitForConnected(5000)); QTcpServer server; @@ -668,16 +675,18 @@ void tst_QTcpServer::invalidProxy_data() QTest::addColumn("port"); QTest::addColumn("expectedError"); - QString fluke = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first().toString(); - QTest::newRow("ftp-proxy") << int(QNetworkProxy::FtpCachingProxy) << fluke << 143 + const QString imapIp = QtNetworkSettings::imapServerIp().toString(); + const QString httpProxyIp = QtNetworkSettings::httpProxyServerIp().toString(); + const QString socksIp = QtNetworkSettings::socksProxyServerIp().toString(); + QTest::newRow("ftp-proxy") << int(QNetworkProxy::FtpCachingProxy) << imapIp << 143 << int(QAbstractSocket::UnsupportedSocketOperationError); - QTest::newRow("http-proxy") << int(QNetworkProxy::HttpProxy) << fluke << 3128 + QTest::newRow("http-proxy") << int(QNetworkProxy::HttpProxy) << httpProxyIp << 3128 << int(QAbstractSocket::UnsupportedSocketOperationError); QTest::newRow("no-such-host") << int(QNetworkProxy::Socks5Proxy) << "invalid.test.qt-project.org" << 1080 << int(QAbstractSocket::ProxyNotFoundError); - QTest::newRow("socks5-on-http") << int(QNetworkProxy::Socks5Proxy) << fluke << 3128 + QTest::newRow("socks5-on-http") << int(QNetworkProxy::Socks5Proxy) << httpProxyIp << 3128 << int(QAbstractSocket::SocketTimeoutError); } @@ -740,48 +749,48 @@ void tst_QTcpServer::proxyFactory_data() // tests that do get to listen - proxyList << QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080); + proxyList << QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1080); QTest::newRow("socks5") << proxyList << proxyList.at(0) << false << int(QAbstractSocket::UnknownSocketError); proxyList.clear(); - proxyList << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::serverName(), 3128) - << QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080); + proxyList << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::httpProxyServerName(), 3128) + << QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1080); QTest::newRow("cachinghttp+socks5") << proxyList << proxyList.at(1) << false << int(QAbstractSocket::UnknownSocketError); proxyList.clear(); - proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::serverName(), 2121) - << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::serverName(), 3128) - << QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080); + proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::ftpProxyServerName(), 2121) + << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::httpProxyServerName(), 3128) + << QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1080); QTest::newRow("ftp+cachinghttp+socks5") << proxyList << proxyList.at(2) << false << int(QAbstractSocket::UnknownSocketError); // tests that fail to listen proxyList.clear(); - proxyList << QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3128); + proxyList << QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::httpProxyServerName(), 3128); QTest::newRow("http") << proxyList << proxyList.at(0) << true << int(QAbstractSocket::UnsupportedSocketOperationError); proxyList.clear(); - proxyList << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::serverName(), 3128); + proxyList << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::httpProxyServerName(), 3128); QTest::newRow("cachinghttp") << proxyList << QNetworkProxy() << true << int(QAbstractSocket::UnsupportedSocketOperationError); proxyList.clear(); - proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::serverName(), 2121); + proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::ftpProxyServerName(), 2121); QTest::newRow("ftp") << proxyList << QNetworkProxy() << true << int(QAbstractSocket::UnsupportedSocketOperationError); proxyList.clear(); - proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::serverName(), 2121) - << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::serverName(), 3128); + proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::ftpProxyServerName(), 2121) + << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::httpProxyServerName(), 3128); QTest::newRow("ftp+cachinghttp") << proxyList << QNetworkProxy() << true << int(QAbstractSocket::UnsupportedSocketOperationError); From 703ca2606f0ec5fd91c0bd5caea9cbb94d07cd6b Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 27 Feb 2019 13:48:46 +0100 Subject: [PATCH 046/292] Convert tst_qsslsocket_*_static/member auto-tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To work with docker test server. Change-Id: I50a1c7b632748d7648dafd70356aa849614e4e12 Reviewed-by: Mårten Nordheim Reviewed-by: Edward Welbourne --- ...qsslsocket_onDemandCertificates_member.pro | 6 +++++ ...qsslsocket_onDemandCertificates_member.cpp | 21 +++++++++++++----- ...qsslsocket_onDemandCertificates_static.pro | 6 +++++ ...qsslsocket_onDemandCertificates_static.cpp | 22 ++++++++++++++----- 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro index 05755ff606..3e3ebeb358 100644 --- a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro +++ b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro @@ -17,3 +17,9 @@ win32 { DEFINES += SRCDIR=\\\"$$PWD/\\\" requires(qtConfig(private_tests)) + +# DOCKERTODO: linux, docker is disabled on macOS/Windows. +linux { + QT_TEST_SERVER_LIST = squid danted + include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) +} diff --git a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp index 25c2701f69..4199c0f465 100644 --- a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp +++ b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp @@ -102,7 +102,15 @@ void tst_QSslSocket_onDemandCertificates_member::initTestCase_data() void tst_QSslSocket_onDemandCertificates_member::initTestCase() { +#ifdef QT_TEST_SERVER + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::socksProxyServerName(), 1080)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::socksProxyServerName(), 1081)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3128)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3129)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3130)); +#else QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); +#endif // QT_TEST_SERVER } void tst_QSslSocket_onDemandCertificates_member::init() @@ -110,28 +118,29 @@ void tst_QSslSocket_onDemandCertificates_member::init() QFETCH_GLOBAL(bool, setProxy); if (setProxy) { QFETCH_GLOBAL(int, proxyType); - QString testServer = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first().toString(); + const auto socksAddr = QtNetworkSettings::socksProxyServerIp().toString(); + const auto squidAddr = QtNetworkSettings::httpProxyServerIp().toString(); QNetworkProxy proxy; switch (proxyType) { case Socks5Proxy: - proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, testServer, 1080); + proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, socksAddr, 1080); break; case Socks5Proxy | AuthBasic: - proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, testServer, 1081); + proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, socksAddr, 1081); break; case HttpProxy | NoAuth: - proxy = QNetworkProxy(QNetworkProxy::HttpProxy, testServer, 3128); + proxy = QNetworkProxy(QNetworkProxy::HttpProxy, squidAddr, 3128); break; case HttpProxy | AuthBasic: - proxy = QNetworkProxy(QNetworkProxy::HttpProxy, testServer, 3129); + proxy = QNetworkProxy(QNetworkProxy::HttpProxy, squidAddr, 3129); break; case HttpProxy | AuthNtlm: - proxy = QNetworkProxy(QNetworkProxy::HttpProxy, testServer, 3130); + proxy = QNetworkProxy(QNetworkProxy::HttpProxy, squidAddr, 3130); break; } QNetworkProxy::setApplicationProxy(proxy); diff --git a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro index c345d7379f..1ad42b309e 100644 --- a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro +++ b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro @@ -16,3 +16,9 @@ win32 { DEFINES += SRCDIR=\\\"$$PWD/\\\" requires(qtConfig(private_tests)) + +#DOCKERTODO Linux, docker is disabled on macOS and Windows. +linux { + QT_TEST_SERVER_LIST = squid danted + include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) +} diff --git a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/tst_qsslsocket_onDemandCertificates_static.cpp b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/tst_qsslsocket_onDemandCertificates_static.cpp index 503edc0bff..671a21b1c2 100644 --- a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/tst_qsslsocket_onDemandCertificates_static.cpp +++ b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/tst_qsslsocket_onDemandCertificates_static.cpp @@ -98,7 +98,15 @@ void tst_QSslSocket_onDemandCertificates_static::initTestCase_data() void tst_QSslSocket_onDemandCertificates_static::initTestCase() { +#ifdef QT_TEST_SERVER + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::socksProxyServerName(), 1080)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::socksProxyServerName(), 1081)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3128)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3129)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3130)); +#else QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); +#endif // QT_TEST_SERVER } void tst_QSslSocket_onDemandCertificates_static::init() @@ -106,28 +114,30 @@ void tst_QSslSocket_onDemandCertificates_static::init() QFETCH_GLOBAL(bool, setProxy); if (setProxy) { QFETCH_GLOBAL(int, proxyType); - QString testServer = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first().toString(); + const auto socksAddr = QtNetworkSettings::socksProxyServerIp().toString(); + const auto squidAddr = QtNetworkSettings::httpProxyServerIp().toString(); + QNetworkProxy proxy; switch (proxyType) { case Socks5Proxy: - proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, testServer, 1080); + proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, socksAddr, 1080); break; case Socks5Proxy | AuthBasic: - proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, testServer, 1081); + proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, socksAddr, 1081); break; case HttpProxy | NoAuth: - proxy = QNetworkProxy(QNetworkProxy::HttpProxy, testServer, 3128); + proxy = QNetworkProxy(QNetworkProxy::HttpProxy, squidAddr, 3128); break; case HttpProxy | AuthBasic: - proxy = QNetworkProxy(QNetworkProxy::HttpProxy, testServer, 3129); + proxy = QNetworkProxy(QNetworkProxy::HttpProxy, squidAddr, 3129); break; case HttpProxy | AuthNtlm: - proxy = QNetworkProxy(QNetworkProxy::HttpProxy, testServer, 3130); + proxy = QNetworkProxy(QNetworkProxy::HttpProxy, squidAddr, 3130); break; } QNetworkProxy::setApplicationProxy(proxy); From 7f1ae3f99dd84f17511fc05daf6b69c90504e61a Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Fri, 8 Feb 2019 11:45:59 +0100 Subject: [PATCH 047/292] Convert tst_qhttpsocketengine to work with the Docker-server MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I6590f9cc5159083cba58cfdbacfaee1f9482bd0b Reviewed-by: Mårten Nordheim Reviewed-by: Edward Welbourne --- .../qhttpsocketengine/qhttpsocketengine.pro | 5 +++ .../tst_qhttpsocketengine.cpp | 44 +++++++++++-------- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/tests/auto/network/socket/qhttpsocketengine/qhttpsocketengine.pro b/tests/auto/network/socket/qhttpsocketengine/qhttpsocketengine.pro index 56a4fb8aee..492bb6aa8d 100644 --- a/tests/auto/network/socket/qhttpsocketengine/qhttpsocketengine.pro +++ b/tests/auto/network/socket/qhttpsocketengine/qhttpsocketengine.pro @@ -10,3 +10,8 @@ MOC_DIR=tmp requires(qtConfig(private_tests)) QT = core-private network-private testlib +# TODO: For now linux-only, because cyrus is linux-only atm ... +linux { + QT_TEST_SERVER_LIST = squid danted cyrus apache2 + include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) +} diff --git a/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp b/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp index 68f3ea059b..cdc6fef663 100644 --- a/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp +++ b/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp @@ -122,7 +122,14 @@ public slots: void tst_QHttpSocketEngine::initTestCase() { +#ifdef QT_TEST_SERVER + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3128)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::socksProxyServerName(), 1080)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpServerName(), 80)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::imapServerName(), 143)); +#else QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); +#endif } void tst_QHttpSocketEngine::init() @@ -171,7 +178,7 @@ void tst_QHttpSocketEngine::errorTest_data() QTest::newRow("proxy-host-not-found") << "this-host-does-not-exist." << 1080 << QString() << QString() << int(QAbstractSocket::ProxyNotFoundError); - QTest::newRow("proxy-connection-refused") << QtNetworkSettings::serverName() << 2 << QString() + QTest::newRow("proxy-connection-refused") << QtNetworkSettings::socksProxyServerName() << 2 << QString() << QString() << int(QAbstractSocket::ProxyConnectionRefusedError); @@ -278,13 +285,12 @@ void tst_QHttpSocketEngine::simpleConnectToIMAP() QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); - socketDevice.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3128)); - - QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143)); + socketDevice.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::httpProxyServerName(), 3128)); + QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::imapServerIp(), 143)); QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState); QVERIFY(socketDevice.waitForWrite()); QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState); - QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::serverIP()); + QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::imapServerIp()); QVERIFY(!socketDevice.localAddress().isNull()); QVERIFY(socketDevice.localPort() > 0); @@ -292,10 +298,10 @@ void tst_QHttpSocketEngine::simpleConnectToIMAP() QVERIFY(socketDevice.waitForRead()); // Read the greeting - qint64 available = socketDevice.bytesAvailable(); + qint64 available = int(socketDevice.bytesAvailable()); QVERIFY(available > 0); QByteArray array; - array.resize(available); + array.resize(int(available)); QVERIFY(socketDevice.read(array.data(), array.size()) == available); // Check that the greeting is what we expect it to be @@ -310,9 +316,9 @@ void tst_QHttpSocketEngine::simpleConnectToIMAP() // Wait for the response QVERIFY(socketDevice.waitForRead()); - available = socketDevice.bytesAvailable(); + available = int(socketDevice.bytesAvailable()); QVERIFY(available > 0); - array.resize(available); + array.resize(int(available)); QVERIFY(socketDevice.read(array.data(), array.size()) == available); // Check that the greeting is what we expect it to be @@ -321,7 +327,7 @@ void tst_QHttpSocketEngine::simpleConnectToIMAP() // Wait for the response QVERIFY(socketDevice.waitForRead()); char c; - QCOMPARE(socketDevice.read(&c, sizeof(c)), (qint64) -1); + QCOMPARE(socketDevice.read(&c, sizeof(c)), qint64(-1)); QCOMPARE(socketDevice.error(), QAbstractSocket::RemoteHostClosedError); QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); } @@ -335,10 +341,10 @@ void tst_QHttpSocketEngine::simpleErrorsAndStates() // Initialize device QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); - socketDevice.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3128)); + socketDevice.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::httpProxyServerName(), 3128)); QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); - QVERIFY(!socketDevice.connectToHost(QHostAddress(QtNetworkSettings::serverName()), 8088)); + QVERIFY(!socketDevice.connectToHost(QHostAddress(QtNetworkSettings::socksProxyServerName()), 8088)); QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState); if (socketDevice.waitForWrite(30000)) { QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState || @@ -422,7 +428,7 @@ void tst_QHttpSocketEngine::tcpSocketBlockingTest() QTcpSocket socket; // Connect - socket.connectToHost(QtNetworkSettings::serverName(), 143); + socket.connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket.waitForConnected()); QCOMPARE(socket.state(), QTcpSocket::ConnectedState); @@ -479,7 +485,7 @@ void tst_QHttpSocketEngine::tcpSocketNonBlockingTest() tcpSocketNonBlocking_socket = &socket; // Connect - socket.connectToHost(QtNetworkSettings::serverName(), 143); + socket.connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket.state() == QTcpSocket::HostLookupState || socket.state() == QTcpSocket::ConnectingState); @@ -607,13 +613,13 @@ void tst_QHttpSocketEngine::downloadBigFile() connect(tmpSocket, SIGNAL(connected()), SLOT(exitLoopSlot())); connect(tmpSocket, SIGNAL(readyRead()), SLOT(downloadBigFileSlot())); - tmpSocket->connectToHost(QtNetworkSettings::serverName(), 80); + tmpSocket->connectToHost(QtNetworkSettings::httpServerName(), 80); QTestEventLoop::instance().enterLoop(30); if (QTestEventLoop::instance().timeout()) QFAIL("Network operation timed out"); - QByteArray hostName = QtNetworkSettings::serverName().toLatin1(); + QByteArray hostName = QtNetworkSettings::httpServerName().toLatin1(); QCOMPARE(tmpSocket->state(), QAbstractSocket::ConnectedState); QVERIFY(tmpSocket->write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0); QVERIFY(tmpSocket->write("Host: ") > 0); @@ -664,13 +670,13 @@ void tst_QHttpSocketEngine::passwordAuth() QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); - socketDevice.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3128, "qsockstest", "password")); + socketDevice.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::httpProxyServerName(), 3128, "qsockstest", "password")); - QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143)); + QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::imapServerIp(), 143)); QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState); QVERIFY(socketDevice.waitForWrite()); QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState); - QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::serverIP()); + QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::imapServerIp()); // Wait for the greeting QVERIFY(socketDevice.waitForRead()); From 381f79a53c57f59606c618769825569b3e7a7bcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Fri, 1 Mar 2019 12:29:16 +0100 Subject: [PATCH 048/292] Blacklist tst_qsocks5socketengine::passwordAuth2 It's flaky and has been for a while. However it is somewhat more flaky when using the docker setup. Task-number: QTBUG-74162 Change-Id: I49f346a39271b48395e0e17fa6821d73a24f81d4 Reviewed-by: Timur Pocheptsov --- tests/auto/network/socket/qsocks5socketengine/BLACKLIST | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/auto/network/socket/qsocks5socketengine/BLACKLIST b/tests/auto/network/socket/qsocks5socketengine/BLACKLIST index 60526827bf..8af3cea8dc 100644 --- a/tests/auto/network/socket/qsocks5socketengine/BLACKLIST +++ b/tests/auto/network/socket/qsocks5socketengine/BLACKLIST @@ -2,6 +2,9 @@ * [passwordAuth] * +# QTBUG-74162 +[passwordAuth2] +* [serverTest] windows [downloadBigFile] From 62f6fb30177043085d5ff3685ff24015b098ae14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Thu, 28 Feb 2019 14:28:00 +0100 Subject: [PATCH 049/292] Fix compilation without DTLS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I6062c4454c547b943d7ef26b22eeccf566888767 Reviewed-by: Mårten Nordheim --- src/network/ssl/qsslcontext_openssl11.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/network/ssl/qsslcontext_openssl11.cpp b/src/network/ssl/qsslcontext_openssl11.cpp index 21a5c779f7..db023b7331 100644 --- a/src/network/ssl/qsslcontext_openssl11.cpp +++ b/src/network/ssl/qsslcontext_openssl11.cpp @@ -193,7 +193,6 @@ init_context: minVersion = TLS1_2_VERSION; maxVersion = 0; break; -#if QT_CONFIG(dtls) case QSsl::DtlsV1_0: minVersion = DTLS1_VERSION; maxVersion = DTLS1_VERSION; @@ -210,7 +209,6 @@ init_context: minVersion = DTLS1_2_VERSION; maxVersion = DTLS_MAX_VERSION; break; -#endif // dtls case QSsl::TlsV1_3OrLater: #ifdef TLS1_3_VERSION minVersion = TLS1_3_VERSION; From b33eb938910392e2db45bfdfd3f1e2cb6aced7ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Thu, 28 Feb 2019 14:13:59 +0100 Subject: [PATCH 050/292] Disable DTLS is UDP socket is disabled The implementation of DTLS uses UDP socket. Change-Id: I8be5c286a47abe9fa80a5a0e139dedc2f297992d Reviewed-by: Paul Olav Tvete --- src/network/configure.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/configure.json b/src/network/configure.json index aaedc05ea4..2bccd35dc5 100644 --- a/src/network/configure.json +++ b/src/network/configure.json @@ -292,7 +292,7 @@ "label": "DTLS", "purpose": "Provides a DTLS implementation", "section": "Networking", - "condition": "features.openssl && tests.dtls", + "condition": "features.openssl && features.udpsocket && tests.dtls", "output": [ "publicFeature" ] }, "ocsp": { From 9eb50751b859cf46aa69ca5707346bd4a74a5f90 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Mon, 18 Feb 2019 22:18:24 +0100 Subject: [PATCH 051/292] QSpinBox: add new signal textChanged(QString) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a new signal textChanged(QString) as a replacement for valueChanged(QString) so valueChanged(QString) can be removed with Qt6. This removes the ambiguous valueChanged() signal and also matches the 'text' property naming. Change-Id: I0676a7112f70add20a3a7ef9381268cd9b8a5851 Reviewed-by: Konstantin Shegunov Reviewed-by: Luca Beldi Reviewed-by: André Hartmann Reviewed-by: Richard Moe Gustavsen --- src/widgets/widgets/qabstractspinbox.cpp | 14 +++--- src/widgets/widgets/qspinbox.cpp | 47 ++++++++++++++++--- src/widgets/widgets/qspinbox.h | 8 ++++ .../widgets/widgets/qspinbox/tst_qspinbox.cpp | 6 +-- 4 files changed, 59 insertions(+), 16 deletions(-) diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index 6a35dbe274..da4c2f98cf 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -252,7 +252,7 @@ QString QAbstractSpinBox::text() const All values are displayed with the prefix and suffix (if set), \e except for the special value, which only shows the special value - text. This special text is passed in the QSpinBox::valueChanged() + text. This special text is passed in the QSpinBox::textChanged() signal that passes a QString. To turn off the special-value text display, call this function @@ -342,18 +342,18 @@ void QAbstractSpinBox::setReadOnly(bool enable) \since 4.3 If keyboard tracking is enabled (the default), the spinbox - emits the valueChanged() signal while the new value is being - entered from the keyboard. + emits the valueChanged() and textChanged() signals while the + new value is being entered from the keyboard. E.g. when the user enters the value 600 by typing 6, 0, and 0, the spinbox emits 3 signals with the values 6, 60, and 600 respectively. If keyboard tracking is disabled, the spinbox doesn't emit the - valueChanged() signal while typing. It emits the signal later, - when the return key is pressed, when keyboard focus is lost, or - when other spinbox functionality is used, e.g. pressing an arrow - key. + valueChanged() and textChanged() signals while typing. It emits + the signals later, when the return key is pressed, when keyboard + focus is lost, or when other spinbox functionality is used, e.g. + pressing an arrow key. */ bool QAbstractSpinBox::keyboardTracking() const diff --git a/src/widgets/widgets/qspinbox.cpp b/src/widgets/widgets/qspinbox.cpp index 7624b1ed3c..40044223e2 100644 --- a/src/widgets/widgets/qspinbox.cpp +++ b/src/widgets/widgets/qspinbox.cpp @@ -128,9 +128,10 @@ public: manually. The spin box supports integer values but can be extended to use different strings with validate(), textFromValue() and valueFromText(). - Every time the value changes QSpinBox emits two valueChanged() signals, - one providing an int and the other a QString. The QString overload - provides the value with both prefix() and suffix(). + Every time the value changes QSpinBox emits valueChanged() and + textChanged() signals, the former providing a int and the latter + a QString. The textChanged() signal provides the value with both + prefix() and suffix(). The current value can be fetched with value() and set with setValue(). Clicking the up/down buttons or using the keyboard accelerator's @@ -182,13 +183,24 @@ public: The new value's integer value is passed in \a i. */ +/*! + \fn void QSpinBox::textChanged(const QString &text) + \since 5.14 + + This signal is emitted whenever the spin box's text is changed. + The new text is passed in \a text with prefix() and suffix(). +*/ + +#if QT_DEPRECATED_SINCE(5, 14) /*! \fn void QSpinBox::valueChanged(const QString &text) \overload + \obsolete Use textChanged(QString) instead The new value is passed in \a text with prefix() and suffix(). */ +#endif /*! Constructs a spin box with 0 as minimum value and 99 as maximum value, a @@ -594,9 +606,9 @@ void QSpinBox::fixup(QString &input) const values but can be extended to use different strings with validate(), textFromValue() and valueFromText(). - Every time the value changes QDoubleSpinBox emits two - valueChanged() signals, one taking providing a double and the other - a QString. The QString overload provides the value with both + Every time the value changes QDoubleSpinBox emits valueChanged() and + textChanged() signals, the former providing a double and the latter + a QString. The textChanged() signal provides the value with both prefix() and suffix(). The current value can be fetched with value() and set with setValue(). @@ -643,13 +655,24 @@ void QSpinBox::fixup(QString &input) const The new value is passed in \a d. */ +/*! + \fn void QDoubleSpinBox::textChanged(const QString &text) + \since 5.14 + + This signal is emitted whenever the spin box's text is changed. + The new text is passed in \a text with prefix() and suffix(). +*/ + +#if QT_DEPRECATED_SINCE(5, 14) /*! \fn void QDoubleSpinBox::valueChanged(const QString &text); \overload + \obsolete Use textChanged(QString) instead The new value is passed in \a text with prefix() and suffix(). */ +#endif /*! Constructs a spin box with 0.0 as minimum value and 99.99 as maximum value, @@ -1068,7 +1091,13 @@ void QSpinBoxPrivate::emitSignals(EmitPolicy ep, const QVariant &old) if (ep != NeverEmit) { pendingEmit = false; if (ep == AlwaysEmit || value != old) { +#if QT_DEPRECATED_SINCE(5, 14) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED emit q->valueChanged(edit->displayText()); +QT_WARNING_POP +#endif + emit q->textChanged(edit->displayText()); emit q->valueChanged(value.toInt()); } } @@ -1219,7 +1248,13 @@ void QDoubleSpinBoxPrivate::emitSignals(EmitPolicy ep, const QVariant &old) if (ep != NeverEmit) { pendingEmit = false; if (ep == AlwaysEmit || value != old) { +#if QT_DEPRECATED_SINCE(5, 14) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED emit q->valueChanged(edit->displayText()); +QT_WARNING_POP +#endif + emit q->textChanged(edit->displayText()); emit q->valueChanged(value.toDouble()); } } diff --git a/src/widgets/widgets/qspinbox.h b/src/widgets/widgets/qspinbox.h index d2eac903fb..762dd4a46a 100644 --- a/src/widgets/widgets/qspinbox.h +++ b/src/widgets/widgets/qspinbox.h @@ -106,7 +106,11 @@ public Q_SLOTS: Q_SIGNALS: void valueChanged(int); + void textChanged(const QString &); +#if QT_DEPRECATED_SINCE(5, 14) + QT_DEPRECATED_X("Use textChanged(QString) instead") void valueChanged(const QString &); +#endif private: Q_DISABLE_COPY(QSpinBox) @@ -168,7 +172,11 @@ public Q_SLOTS: Q_SIGNALS: void valueChanged(double); + void textChanged(const QString &); +#if QT_DEPRECATED_SINCE(5, 14) + QT_DEPRECATED_X("Use textChanged(QString) instead") void valueChanged(const QString &); +#endif private: Q_DISABLE_COPY(QDoubleSpinBox) diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp index 1d106f94f3..7174c274f9 100644 --- a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp +++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp @@ -206,7 +206,7 @@ private slots: void stepModifierPressAndHold_data(); void stepModifierPressAndHold(); public slots: - void valueChangedHelper(const QString &); + void textChangedHelper(const QString &); void valueChangedHelper(int); private: QStringList actualTexts; @@ -474,7 +474,7 @@ void tst_QSpinBox::setPrefixSuffix() QCOMPARE(spin.cleanText(), expectedCleanText); } -void tst_QSpinBox::valueChangedHelper(const QString &text) +void tst_QSpinBox::textChangedHelper(const QString &text) { actualTexts << text; } @@ -552,7 +552,7 @@ void tst_QSpinBox::setTracking() QSpinBox spin(0); spin.setKeyboardTracking(tracking); spin.show(); - connect(&spin, SIGNAL(valueChanged(QString)), this, SLOT(valueChangedHelper(QString))); + connect(&spin, &QSpinBox::textChanged, this, &tst_QSpinBox::textChangedHelper); keys.simulate(&spin); QCOMPARE(actualTexts, texts); From 785d2b9d0728bbbc0d2a92b7d4186a3114d54128 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Wed, 27 Feb 2019 12:08:42 +0000 Subject: [PATCH 052/292] Add QStyle::standardPixmap support to all entries in QDialogButtonBox QDialogButtonBox fetches icons from the qstyle for most of the buttons it creates, with the exception of 7. This patch adds support for the remaining buttons, so that all buttons can have icons added by the theme. Behavior is unchanged until a style implements these new enumerations. Change-Id: I2eba488a11e1b9979fff3b32dafbda11332a3d92 Reviewed-by: Kai Uwe Broulik Reviewed-by: Shawn Rutledge --- src/widgets/styles/qstyle.h | 7 +++++++ src/widgets/widgets/qdialogbuttonbox.cpp | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h index 5ee37bd8e9..ee234457f5 100644 --- a/src/widgets/styles/qstyle.h +++ b/src/widgets/styles/qstyle.h @@ -832,6 +832,13 @@ public: SP_MediaVolume, SP_MediaVolumeMuted, SP_LineEditClearButton, + SP_DialogYesToAllButton, + SP_DialogNoToAllButton, + SP_DialogSaveAllButton, + SP_DialogAbortButton, + SP_DialogRetryButton, + SP_DialogIgnoreButton, + SP_RestoreDefaultsButton, // do not add any values below/greater than this SP_CustomBase = 0xf0000000 }; diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp index 26b86f80be..28f6cdc7bd 100644 --- a/src/widgets/widgets/qdialogbuttonbox.cpp +++ b/src/widgets/widgets/qdialogbuttonbox.cpp @@ -387,12 +387,25 @@ QPushButton *QDialogButtonBoxPrivate::createButton(QDialogButtonBox::StandardBut icon = QStyle::SP_DialogNoButton; break; case QDialogButtonBox::YesToAll: + icon = QStyle::SP_DialogYesToAllButton; + break; case QDialogButtonBox::NoToAll: + icon = QStyle::SP_DialogNoToAllButton; + break; case QDialogButtonBox::SaveAll: + icon = QStyle::SP_DialogSaveAllButton; + break; case QDialogButtonBox::Abort: + icon = QStyle::SP_DialogAbortButton; + break; case QDialogButtonBox::Retry: + icon = QStyle::SP_DialogRetryButton; + break; case QDialogButtonBox::Ignore: + icon = QStyle::SP_DialogIgnoreButton; + break; case QDialogButtonBox::RestoreDefaults: + icon = QStyle::SP_RestoreDefaultsButton; break; case QDialogButtonBox::NoButton: return 0; From c6153660e458ee3790a446a327d29e622defee49 Mon Sep 17 00:00:00 2001 From: Lars Schmertmann Date: Sun, 11 Nov 2018 19:42:43 +0100 Subject: [PATCH 053/292] Extend the test for QSslKey MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check if QSslKey::handle() returns data representing the same key information as that passed to the constructor. Task-number: QTBUG-64495 Change-Id: I1a91264e6f6d92d259b51fca9de00fcbfd5cc845 Reviewed-by: Mårten Nordheim Reviewed-by: Timur Pocheptsov --- .../ssl/qsslsocket_openssl11_symbols_p.h | 1 + .../ssl/qsslsocket_openssl_symbols.cpp | 4 ++ .../ssl/qsslsocket_openssl_symbols_p.h | 7 ++-- .../auto/network/ssl/qsslkey/tst_qsslkey.cpp | 38 ++++++++++++++++++- 4 files changed, 46 insertions(+), 4 deletions(-) diff --git a/src/network/ssl/qsslsocket_openssl11_symbols_p.h b/src/network/ssl/qsslsocket_openssl11_symbols_p.h index a44d00a830..9d0a14360d 100644 --- a/src/network/ssl/qsslsocket_openssl11_symbols_p.h +++ b/src/network/ssl/qsslsocket_openssl11_symbols_p.h @@ -82,6 +82,7 @@ Q_AUTOTEST_EXPORT const BIO_METHOD *q_BIO_s_mem(); int q_DSA_bits(DSA *a); int q_EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *c); +Q_AUTOTEST_EXPORT int q_EVP_PKEY_up_ref(EVP_PKEY *a); int q_EVP_PKEY_base_id(EVP_PKEY *a); int q_RSA_bits(RSA *a); Q_AUTOTEST_EXPORT int q_OPENSSL_sk_num(OPENSSL_STACK *a); diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp index aa1dc681e0..f136c92a65 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols.cpp +++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp @@ -150,6 +150,7 @@ DEFINEFUNC(BIO *, BIO_new, const BIO_METHOD *a, a, return nullptr, return) DEFINEFUNC(const BIO_METHOD *, BIO_s_mem, void, DUMMYARG, return nullptr, return) DEFINEFUNC2(int, BN_is_word, BIGNUM *a, a, BN_ULONG w, w, return 0, return) DEFINEFUNC(int, EVP_CIPHER_CTX_reset, EVP_CIPHER_CTX *c, c, return 0, return) +DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return) DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return) DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return) DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return) @@ -366,6 +367,7 @@ DEFINEFUNC2(int, EVP_PKEY_set1_DH, EVP_PKEY *a, a, DH *b, b, return -1, return) #ifndef OPENSSL_NO_EC DEFINEFUNC2(int, EVP_PKEY_set1_EC_KEY, EVP_PKEY *a, a, EC_KEY *b, b, return -1, return) #endif +DEFINEFUNC2(int, EVP_PKEY_cmp, const EVP_PKEY *a, a, const EVP_PKEY *b, b, return -1, return) DEFINEFUNC(void, EVP_PKEY_free, EVP_PKEY *a, a, return, DUMMYARG) DEFINEFUNC(DSA *, EVP_PKEY_get1_DSA, EVP_PKEY *a, a, return nullptr, return) DEFINEFUNC(RSA *, EVP_PKEY_get1_RSA, EVP_PKEY *a, a, return nullptr, return) @@ -955,6 +957,7 @@ bool q_resolveOpenSslSymbols() RESOLVEFUNC(OPENSSL_init_crypto) RESOLVEFUNC(ASN1_STRING_get0_data) RESOLVEFUNC(EVP_CIPHER_CTX_reset) + RESOLVEFUNC(EVP_PKEY_up_ref) RESOLVEFUNC(EVP_PKEY_base_id) RESOLVEFUNC(RSA_bits) RESOLVEFUNC(OPENSSL_sk_new_null) @@ -1184,6 +1187,7 @@ bool q_resolveOpenSslSymbols() #ifndef OPENSSL_NO_EC RESOLVEFUNC(EVP_PKEY_set1_EC_KEY) #endif + RESOLVEFUNC(EVP_PKEY_cmp) RESOLVEFUNC(EVP_PKEY_free) RESOLVEFUNC(EVP_PKEY_get1_DSA) RESOLVEFUNC(EVP_PKEY_get1_RSA) diff --git a/src/network/ssl/qsslsocket_openssl_symbols_p.h b/src/network/ssl/qsslsocket_openssl_symbols_p.h index e09820b2f2..59b6e53940 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols_p.h +++ b/src/network/ssl/qsslsocket_openssl_symbols_p.h @@ -284,11 +284,12 @@ const EVP_CIPHER *q_EVP_rc2_cbc(); Q_AUTOTEST_EXPORT const EVP_MD *q_EVP_sha1(); int q_EVP_PKEY_assign(EVP_PKEY *a, int b, char *c); Q_AUTOTEST_EXPORT int q_EVP_PKEY_set1_RSA(EVP_PKEY *a, RSA *b); -int q_EVP_PKEY_set1_DSA(EVP_PKEY *a, DSA *b); -int q_EVP_PKEY_set1_DH(EVP_PKEY *a, DH *b); +Q_AUTOTEST_EXPORT int q_EVP_PKEY_set1_DSA(EVP_PKEY *a, DSA *b); +Q_AUTOTEST_EXPORT int q_EVP_PKEY_set1_DH(EVP_PKEY *a, DH *b); #ifndef OPENSSL_NO_EC -int q_EVP_PKEY_set1_EC_KEY(EVP_PKEY *a, EC_KEY *b); +Q_AUTOTEST_EXPORT int q_EVP_PKEY_set1_EC_KEY(EVP_PKEY *a, EC_KEY *b); #endif +Q_AUTOTEST_EXPORT int q_EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b); Q_AUTOTEST_EXPORT void q_EVP_PKEY_free(EVP_PKEY *a); RSA *q_EVP_PKEY_get1_RSA(EVP_PKEY *a); DSA *q_EVP_PKEY_get1_DSA(EVP_PKEY *a); diff --git a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp index 28476fce5b..d24fafb77b 100644 --- a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp +++ b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -233,15 +234,50 @@ void tst_QSslKey::constructorHandle() QByteArray passphrase; if (QByteArray(QTest::currentDataTag()).contains("-pkcs8-")) passphrase = "1234"; + BIO* bio = q_BIO_new(q_BIO_s_mem()); q_BIO_write(bio, pem.constData(), pem.length()); - QSslKey key(func(bio, nullptr, nullptr, static_cast(passphrase.data())), type); + EVP_PKEY *origin = func(bio, nullptr, nullptr, static_cast(passphrase.data())); +#if QT_CONFIG(opensslv11) + q_EVP_PKEY_up_ref(origin); +#endif + QSslKey key(origin, type); +#if !QT_CONFIG(opensslv11) + q_BIO_write(bio, pem.constData(), pem.length()); + origin = func(bio, nullptr, nullptr, static_cast(passphrase.data())); +#endif q_BIO_free(bio); + EVP_PKEY *handle = q_EVP_PKEY_new(); + switch (algorithm) { + case QSsl::Rsa: + q_EVP_PKEY_set1_RSA(handle, static_cast(key.handle())); + break; + case QSsl::Dsa: + q_EVP_PKEY_set1_DSA(handle, static_cast(key.handle())); + break; + case QSsl::Dh: + q_EVP_PKEY_set1_DH(handle, static_cast(key.handle())); + break; +#ifndef OPENSSL_NO_EC + case QSsl::Ec: + q_EVP_PKEY_set1_EC_KEY(handle, static_cast(key.handle())); + break; +#endif + default: + break; + } + + auto cleanup = qScopeGuard([origin, handle] { + q_EVP_PKEY_free(origin); + q_EVP_PKEY_free(handle); + }); + QVERIFY(!key.isNull()); QCOMPARE(key.algorithm(), algorithm); QCOMPARE(key.type(), type); QCOMPARE(key.length(), length); + QCOMPARE(q_EVP_PKEY_cmp(origin, handle), 1); #endif } From eea3947842e461662cea4a31c7a5dd7f1969ec23 Mon Sep 17 00:00:00 2001 From: Nils Jeisecke Date: Sat, 6 Oct 2018 07:37:27 +0200 Subject: [PATCH 054/292] sqlite: Remove SQLITE_OMIT_LOAD_EXTENSION define This define prevents the usage of some customization possibilities, e.g. injecting data by using virtual tables that are implemented as an extension. [ChangeLog][Third-Party Code] Build sqlite without SQLITE_OMIT_LOAD_EXTENSION Fixes: QTBUG-70972 Change-Id: Idaf1c2c7bccbaec6f7bbf3d79334ffb4a0bad3fc Reviewed-by: Nils Jeisecke Reviewed-by: Simon Hausmann --- src/3rdparty/sqlite.pri | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/3rdparty/sqlite.pri b/src/3rdparty/sqlite.pri index 068764c726..6405beb3d0 100644 --- a/src/3rdparty/sqlite.pri +++ b/src/3rdparty/sqlite.pri @@ -1,5 +1,6 @@ CONFIG(release, debug|release):DEFINES *= NDEBUG -DEFINES += SQLITE_ENABLE_COLUMN_METADATA SQLITE_OMIT_LOAD_EXTENSION SQLITE_OMIT_COMPLETE SQLITE_ENABLE_FTS3 SQLITE_ENABLE_FTS3_PARENTHESIS SQLITE_ENABLE_FTS5 SQLITE_ENABLE_RTREE SQLITE_ENABLE_JSON1 +QT_FOR_CONFIG += core-private +DEFINES += SQLITE_ENABLE_COLUMN_METADATA SQLITE_OMIT_COMPLETE SQLITE_ENABLE_FTS3 SQLITE_ENABLE_FTS3_PARENTHESIS SQLITE_ENABLE_FTS5 SQLITE_ENABLE_RTREE SQLITE_ENABLE_JSON1 !contains(CONFIG, largefile):DEFINES += SQLITE_DISABLE_LFS qtConfig(posix_fallocate): DEFINES += HAVE_POSIX_FALLOCATE=1 winrt { @@ -8,6 +9,7 @@ winrt { } qnx: DEFINES += _QNX_SOURCE !win32:!winrt:!winphone: DEFINES += HAVE_USLEEP=1 +qtConfig(dlopen): QMAKE_USE += libdl integrity: QMAKE_CFLAGS += -include qplatformdefs.h INCLUDEPATH += $$PWD/sqlite SOURCES += $$PWD/sqlite/sqlite3.c From fa1b8442b8e6d01d0352a062a6aa8df6956f77f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Thu, 28 Feb 2019 14:06:47 +0100 Subject: [PATCH 055/292] Fix warnings when compiling with QT_NO_XMLSTREAM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some of function arguments were unused. Change-Id: I29e8e4acbed87836044cac4f0b7ac59168181f5a Reviewed-by: Paul Olav Tvete Reviewed-by: Mårten Nordheim --- src/corelib/mimetypes/qmimeprovider.cpp | 1 + src/corelib/mimetypes/qmimetypeparser.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/corelib/mimetypes/qmimeprovider.cpp b/src/corelib/mimetypes/qmimeprovider.cpp index d5b8825972..5e1447aaa9 100644 --- a/src/corelib/mimetypes/qmimeprovider.cpp +++ b/src/corelib/mimetypes/qmimeprovider.cpp @@ -458,6 +458,7 @@ void QMimeBinaryProvider::addAllMimeTypes(QList &result) void QMimeBinaryProvider::loadMimeTypePrivate(QMimeTypePrivate &data) { #ifdef QT_NO_XMLSTREAMREADER + Q_UNUSED(data); qWarning("Cannot load mime type since QXmlStreamReader is not available."); return; #else diff --git a/src/corelib/mimetypes/qmimetypeparser.cpp b/src/corelib/mimetypes/qmimetypeparser.cpp index d10575cfe9..815e0aa03b 100644 --- a/src/corelib/mimetypes/qmimetypeparser.cpp +++ b/src/corelib/mimetypes/qmimetypeparser.cpp @@ -194,8 +194,9 @@ static CreateMagicMatchRuleResult createMagicMatchRule(const QXmlStreamAttribute bool QMimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString *errorMessage) { #ifdef QT_NO_XMLSTREAMREADER + Q_UNUSED(dev); if (errorMessage) - *errorMessage = QString::fromLatin1("QXmlStreamReader is not available, cannot parse."); + *errorMessage = QString::fromLatin1("QXmlStreamReader is not available, cannot parse '%1'.").arg(fileName); return false; #else QMimeTypePrivate data; From ab53f0f24e6ed01124b189a285686087a337b31b Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 21 Feb 2019 20:53:15 +0100 Subject: [PATCH 056/292] QtTestLib: unify handling of float and double using suitable templates The QTest::qCompare() implementations were almost duplicates; pull the common code out into a templated version. Tweaked the QTest::toString() specialization for float and double (a macro) and fixed a bous modifier in double's format. The doubleComparisons and floatComparisons tests in the tst_float.cpp selftest shared a large block of tests in common, aside from the difference of type. Break this out into a templated static function to save duplication. This prepares the way for using the same templated code for qfloat16. Change-Id: I2823fd006910c5ff88335d625d1fa05cb7753513 Reviewed-by: Thiago Macieira --- src/testlib/qtestcase.cpp | 42 ++- .../testlib/selftests/expected_float.lightxml | 6 +- .../auto/testlib/selftests/expected_float.tap | 276 +++++++++--------- .../testlib/selftests/expected_float.teamcity | 4 +- .../auto/testlib/selftests/expected_float.txt | 2 +- .../auto/testlib/selftests/expected_float.xml | 6 +- .../testlib/selftests/float/tst_float.cpp | 155 ++++------ 7 files changed, 230 insertions(+), 261 deletions(-) diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 3ee8094ddf..0911c64e57 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -2485,6 +2485,20 @@ bool QTest::compare_helper(bool success, const char *failureMsg, return QTestResult::compare(success, failureMsg, val1, val2, actual, expected, file, line); } +template +static bool floatingCompare(const T &t1, const T &t2) +{ + switch (std::fpclassify(t1)) + { + case FP_INFINITE: + return (t1 < 0) == (t2 < 0) && std::fpclassify(t2) == FP_INFINITE; + case FP_NAN: + return std::fpclassify(t2) == FP_NAN; + default: + return qFuzzyCompare(t1, t2); + } +} + /*! \fn bool QTest::qCompare(const qfloat16 &t1, const qfloat16 &t2, const char *actual, const char *expected, const char *file, int line) \internal */ @@ -2501,16 +2515,8 @@ bool QTest::qCompare(qfloat16 const &t1, qfloat16 const &t2, const char *actual, bool QTest::qCompare(float const &t1, float const &t2, const char *actual, const char *expected, const char *file, int line) { - bool equal = false; - int cl1 = std::fpclassify(t1); - int cl2 = std::fpclassify(t2); - if (cl1 == FP_INFINITE) - equal = ((t1 < 0) == (t2 < 0)) && cl2 == FP_INFINITE; - else if (cl1 == FP_NAN) - equal = (cl2 == FP_NAN); - else - equal = qFuzzyCompare(t1, t2); - return compare_helper(equal, "Compared floats are not the same (fuzzy compare)", + return compare_helper(floatingCompare(t1, t2), + "Compared floats are not the same (fuzzy compare)", toString(t1), toString(t2), actual, expected, file, line); } @@ -2520,16 +2526,8 @@ bool QTest::qCompare(float const &t1, float const &t2, const char *actual, const bool QTest::qCompare(double const &t1, double const &t2, const char *actual, const char *expected, const char *file, int line) { - bool equal = false; - int cl1 = std::fpclassify(t1); - int cl2 = std::fpclassify(t2); - if (cl1 == FP_INFINITE) - equal = ((t1 < 0) == (t2 < 0)) && cl2 == FP_INFINITE; - else if (cl1 == FP_NAN) - equal = (cl2 == FP_NAN); - else - equal = qFuzzyCompare(t1, t2); - return compare_helper(equal, "Compared doubles are not the same (fuzzy compare)", + return compare_helper(floatingCompare(t1, t2), + "Compared doubles are not the same (fuzzy compare)", toString(t1), toString(t2), actual, expected, file, line); } @@ -2607,7 +2605,7 @@ template <> Q_TESTLIB_EXPORT char *QTest::toString(const TYPE &t) \ qstrncpy(msg, "nan", 128); \ break; \ default: \ - qsnprintf(msg, 128, #FORMAT, t); \ + qsnprintf(msg, 128, #FORMAT, double(t)); \ massageExponent(msg); \ break; \ } \ @@ -2615,7 +2613,7 @@ template <> Q_TESTLIB_EXPORT char *QTest::toString(const TYPE &t) \ } TO_STRING_FLOAT(float, %g) -TO_STRING_FLOAT(double, %.12lg) +TO_STRING_FLOAT(double, %.12g) template <> Q_TESTLIB_EXPORT char *QTest::toString(const qfloat16 &t) { diff --git a/tests/auto/testlib/selftests/expected_float.lightxml b/tests/auto/testlib/selftests/expected_float.lightxml index 458f2277e6..54d6eabdbd 100644 --- a/tests/auto/testlib/selftests/expected_float.lightxml +++ b/tests/auto/testlib/selftests/expected_float.lightxml @@ -8,15 +8,15 @@ - - - + + + - - - + + + +static void nonFinite_data(F zero, F one) +{ + using Bounds = std::numeric_limits; + + // QCOMPARE special-cases non-finite values + if (Bounds::has_quiet_NaN) { + const F nan = Bounds::quiet_NaN(); + QTest::newRow("should PASS: NaN == NaN") << nan << nan; + QTest::newRow("should FAIL: NaN != 0") << nan << zero; + QTest::newRow("should FAIL: 0 != NaN") << zero << nan; + QTest::newRow("should FAIL: NaN != 1") << nan << one; + QTest::newRow("should FAIL: 1 != NaN") << one << nan; + } + + if (Bounds::has_infinity) { + const F uge = Bounds::infinity(); + QTest::newRow("should PASS: inf == inf") << uge << uge; + QTest::newRow("should PASS: -inf == -inf") << -uge << -uge; + QTest::newRow("should FAIL: inf != -inf") << uge << -uge; + QTest::newRow("should FAIL: -inf != inf") << -uge << uge; + if (Bounds::has_quiet_NaN) { + const F nan = Bounds::quiet_NaN(); + QTest::newRow("should FAIL: inf != nan") << uge << nan; + QTest::newRow("should FAIL: nan != inf") << nan << uge; + QTest::newRow("should FAIL: -inf != nan") << -uge << nan; + QTest::newRow("should FAIL: nan != -inf") << nan << -uge; + } + QTest::newRow("should FAIL: inf != 0") << uge << zero; + QTest::newRow("should FAIL: 0 != inf") << zero << uge; + QTest::newRow("should FAIL: -inf != 0") << -uge << zero; + QTest::newRow("should FAIL: 0 != -inf") << zero << -uge; + QTest::newRow("should FAIL: inf != 1") << uge << one; + QTest::newRow("should FAIL: 1 != inf") << one << uge; + QTest::newRow("should FAIL: -inf != 1") << -uge << one; + QTest::newRow("should FAIL: 1 != -inf") << one << -uge; + + const F big = Bounds::max(); + QTest::newRow("should FAIL: inf != max") << uge << big; + QTest::newRow("should FAIL: inf != -max") << uge << -big; + QTest::newRow("should FAIL: max != inf") << big << uge; + QTest::newRow("should FAIL: -max != inf") << -big << uge; + QTest::newRow("should FAIL: -inf != max") << -uge << big; + QTest::newRow("should FAIL: -inf != -max") << -uge << -big; + QTest::newRow("should FAIL: max != -inf") << big << -uge; + QTest::newRow("should FAIL: -max != -inf") << -big << -uge; + } +} + void tst_float::doubleComparisons() const { QFETCH(double, operandLeft); @@ -58,65 +107,26 @@ void tst_float::doubleComparisons_data() const { QTest::addColumn("operandLeft"); QTest::addColumn("operandRight"); + double zero(0.), one(1.); - QTest::newRow("should PASS 1") << 0. << 0.; - QTest::newRow("should FAIL 1") << 1.00000 << 3.00000; - QTest::newRow("should FAIL 2") << 1.00000e-7 << 3.00000e-7; + QTest::newRow("should FAIL 1") << one << 3.; + QTest::newRow("should PASS 1") << zero << zero; + QTest::newRow("should FAIL 2") << 1.e-7 << 3.e-7; // QCOMPARE for doubles uses qFuzzyCompare(), which succeeds if the numbers // differ by no more than 1e-12 times the smaller value. Thus // QCOMPARE(1e12-2, 1e12-1) should fail, while QCOMPARE(1e12+1, 1e12+2) // should pass. - QTest::newRow("should PASS 2") << 1e12 + 1. << 1e12 + 2.; - QTest::newRow("should FAIL 3") << 1e12 - 1. << 1e12 - 2.; + QTest::newRow("should PASS 2") << 1e12 + one << 1e12 + 2.; + QTest::newRow("should FAIL 3") << 1e12 - one << 1e12 - 2.; // ... but rounding makes that a bit unrelaible when scaled close to the bounds. QTest::newRow("should PASS 3") << 1e-310 + 1e-322 << 1e-310 + 2e-322; QTest::newRow("should FAIL 4") << 1e-310 - 1e-322 << 1e-310 - 3e-322; QTest::newRow("should PASS 4") << 1e307 + 1e295 << 1e307 + 2e295; QTest::newRow("should FAIL 5") << 1e307 - 1e295 << 1e307 - 3e295; - // QCOMPARE special-cases non-finite values - if (std::numeric_limits::has_quiet_NaN) { - const double nan = std::numeric_limits::quiet_NaN(); - QTest::newRow("should PASS: NaN == NaN") << nan << nan; - QTest::newRow("should FAIL: NaN != 0") << nan << 0.; - QTest::newRow("should FAIL: 0 != NaN") << 0. << nan; - QTest::newRow("should FAIL: NaN != 1") << nan << 1.; - QTest::newRow("should FAIL: 1 != NaN") << 1. << nan; - } - if (std::numeric_limits::has_infinity) { - const double uge = std::numeric_limits::infinity(); - QTest::newRow("should PASS: inf == inf") << uge << uge; - QTest::newRow("should PASS: -inf == -inf") << -uge << -uge; - QTest::newRow("should FAIL: inf != -inf") << uge << -uge; - QTest::newRow("should FAIL: -inf != inf") << -uge << uge; - if (std::numeric_limits::has_quiet_NaN) { - const double nan = std::numeric_limits::quiet_NaN(); - QTest::newRow("should FAIL: inf != nan") << uge << nan; - QTest::newRow("should FAIL: nan != inf") << nan << uge; - QTest::newRow("should FAIL: -inf != nan") << -uge << nan; - QTest::newRow("should FAIL: nan != -inf") << nan << -uge; - } - QTest::newRow("should FAIL: inf != 0") << uge << 0.; - QTest::newRow("should FAIL: 0 != inf") << 0. << uge; - QTest::newRow("should FAIL: -inf != 0") << -uge << 0.; - QTest::newRow("should FAIL: 0 != -inf") << 0. << -uge; - QTest::newRow("should FAIL: inf != 1") << uge << 1.; - QTest::newRow("should FAIL: 1 != inf") << 1. << uge; - QTest::newRow("should FAIL: -inf != 1") << -uge << 1.; - QTest::newRow("should FAIL: 1 != -inf") << 1. << -uge; - - const double big = std::numeric_limits::max(); - QTest::newRow("should FAIL: inf != max") << uge << big; - QTest::newRow("should FAIL: inf != -max") << uge << -big; - QTest::newRow("should FAIL: max != inf") << big << uge; - QTest::newRow("should FAIL: -max != inf") << -big << uge; - QTest::newRow("should FAIL: -inf != max") << -uge << big; - QTest::newRow("should FAIL: -inf != -max") << -uge << -big; - QTest::newRow("should FAIL: max != -inf") << big << -uge; - QTest::newRow("should FAIL: -max != -inf") << -big << -uge; - } + nonFinite_data(zero, one); } void tst_float::floatComparisons() const @@ -131,65 +141,26 @@ void tst_float::floatComparisons_data() const { QTest::addColumn("operandLeft"); QTest::addColumn("operandRight"); + float zero(0.f), one(1.f); - QTest::newRow("should FAIL 1") << 1.00000f << 3.00000f; - QTest::newRow("should PASS 1") << 0.f << 0.f; - QTest::newRow("should FAIL 2") << 1.00000e-7f << 3.00000e-7f; + QTest::newRow("should FAIL 1") << one << 3.f; + QTest::newRow("should PASS 1") << zero << zero; + QTest::newRow("should FAIL 2") << 1.e-7f << 3.e-7f; // QCOMPARE for floats uses qFuzzyCompare(), which succeeds if the numbers // differ by no more than 1e-5 times the smaller value. Thus // QCOMPARE(1e5-2, 1e5-1) should fail, while QCOMPARE(1e5+1, 1e5+2) // should pass. - QTest::newRow("should PASS 2") << 1e5f + 1.f << 1e5f + 2.f; - QTest::newRow("should FAIL 3") << 1e5f - 1.f << 1e5f - 2.f; + QTest::newRow("should PASS 2") << 1e5f + one << 1e5f + 2.f; + QTest::newRow("should FAIL 3") << 1e5f - one << 1e5f - 2.f; // ... but rounding makes that a bit unrelaible when scaled close to the bounds. QTest::newRow("should PASS 3") << 1e-39f + 1e-44f << 1e-39f + 2e-44f; QTest::newRow("should FAIL 4") << 1e-39f - 1e-44f << 1e-39f - 3e-44f; QTest::newRow("should PASS 4") << 1e38f + 1e33f << 1e38f + 2e33f; QTest::newRow("should FAIL 5") << 1e38f - 1e33f << 1e38f - 3e33f; - // QCOMPARE special-cases non-finite values - if (std::numeric_limits::has_quiet_NaN) { - const float nan = std::numeric_limits::quiet_NaN(); - QTest::newRow("should PASS: NaN == NaN") << nan << nan; - QTest::newRow("should FAIL: NaN != 0") << nan << 0.f; - QTest::newRow("should FAIL: 0 != NaN") << 0.f << nan; - QTest::newRow("should FAIL: NaN != 1") << nan << 1.f; - QTest::newRow("should FAIL: 1 != NaN") << 1.f << nan; - } - if (std::numeric_limits::has_infinity) { - const float uge = std::numeric_limits::infinity(); - QTest::newRow("should PASS: inf == inf") << uge << uge; - QTest::newRow("should PASS: -inf == -inf") << -uge << -uge; - QTest::newRow("should FAIL: inf != -inf") << uge << -uge; - QTest::newRow("should FAIL: -inf != inf") << -uge << uge; - if (std::numeric_limits::has_quiet_NaN) { - const float nan = std::numeric_limits::quiet_NaN(); - QTest::newRow("should FAIL: inf != nan") << uge << nan; - QTest::newRow("should FAIL: nan != inf") << nan << uge; - QTest::newRow("should FAIL: -inf != nan") << -uge << nan; - QTest::newRow("should FAIL: nan != -inf") << nan << -uge; - } - QTest::newRow("should FAIL: inf != 0") << uge << 0.f; - QTest::newRow("should FAIL: 0 != inf") << 0.f << uge; - QTest::newRow("should FAIL: -inf != 0") << -uge << 0.f; - QTest::newRow("should FAIL: 0 != -inf") << 0.f << -uge; - QTest::newRow("should FAIL: inf != 1") << uge << 1.f; - QTest::newRow("should FAIL: 1 != inf") << 1.f << uge; - QTest::newRow("should FAIL: -inf != 1") << -uge << 1.f; - QTest::newRow("should FAIL: 1 != -inf") << 1.f << -uge; - - const float big = std::numeric_limits::max(); - QTest::newRow("should FAIL: inf != max") << uge << big; - QTest::newRow("should FAIL: inf != -max") << uge << -big; - QTest::newRow("should FAIL: max != inf") << big << uge; - QTest::newRow("should FAIL: -max != inf") << -big << uge; - QTest::newRow("should FAIL: -inf != max") << -uge << big; - QTest::newRow("should FAIL: -inf != -max") << -uge << -big; - QTest::newRow("should FAIL: max != -inf") << big << -uge; - QTest::newRow("should FAIL: -max != -inf") << -big << -uge; - } + nonFinite_data(zero, one); } void tst_float::float16Comparisons() const From 48405219fbd43f4b309ca7c820e70e59e6375e5d Mon Sep 17 00:00:00 2001 From: Paul Wicking Date: Tue, 29 Jan 2019 13:36:02 +0100 Subject: [PATCH 057/292] Doc: Minor QDialog clarification Minor rewrite of a bit that caused some confusion. Fixes: QTBUG-73335 Change-Id: Ic1df44e62a29035c7b93052204fbe9ef72db5f40 Reviewed-by: Leena Miettinen --- src/widgets/dialogs/qdialog.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index e7b526445e..f8fc18d13d 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -263,12 +263,11 @@ void QDialogPrivate::deletePlatformHelper() The most common way to display a modal dialog is to call its exec() function. When the user closes the dialog, exec() will - provide a useful \l{#return}{return value}. Typically, - to get the dialog to close and return the appropriate value, we - connect a default button, e.g. \uicontrol OK, to the accept() slot and a - \uicontrol Cancel button to the reject() slot. - Alternatively you can call the done() slot with \c Accepted or - \c Rejected. + provide a useful \l{#return}{return value}. To close the dialog + and return the appropriate value, you must connect a default button, + e.g. an \uicontrol OK button to the accept() slot and a + \uicontrol Cancel button to the reject() slot. Alternatively, you + can call the done() slot with \c Accepted or \c Rejected. An alternative is to call setModal(true) or setWindowModality(), then show(). Unlike exec(), show() returns control to the caller From 7a7ec94d6c7b184a376d966f4b69804bd3dc9d37 Mon Sep 17 00:00:00 2001 From: Alexander Akulich Date: Tue, 20 Nov 2018 14:22:58 +0300 Subject: [PATCH 058/292] Add Q_ENUM for QValidator::State MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Besides to the usual value for debug output, this is wanted for some declarative API. Change-Id: I6c35cad96b6a6f33a7c90e8a254bfe0075e391ee Reviewed-by: Tor Arne Vestbø --- src/gui/util/qvalidator.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/util/qvalidator.h b/src/gui/util/qvalidator.h index cc7cbcb559..f0e72e3814 100644 --- a/src/gui/util/qvalidator.h +++ b/src/gui/util/qvalidator.h @@ -69,6 +69,7 @@ public: Intermediate, Acceptable }; + Q_ENUM(State) void setLocale(const QLocale &locale); QLocale locale() const; From f8f592d5c22c378ac94bba4a67d72ac4f2a52424 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Mon, 18 Feb 2019 21:53:22 +0100 Subject: [PATCH 059/292] QString: mark obsolete functions as deprecated MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mark obsolete functions in QString as deprecated so they can be removed with Qt6: - QString::sprintf() - QString::vsprintf() Change-Id: I9b7748db95291c34b95ff3ad3e3aabc8215aeaae Reviewed-by: Jędrzej Nowacki --- qmake/library/qmakebuiltins.cpp | 3 +- src/corelib/tools/qstring.cpp | 4 ++ src/corelib/tools/qstring.h | 4 ++ src/gui/painting/qpdf.cpp | 12 ++--- .../kmsconvenience/qkmsdevice.cpp | 4 +- .../dialogs/qprintpreviewdialog.cpp | 2 +- src/tools/qvkgen/qvkgen.cpp | 45 +++++++++---------- 7 files changed, 37 insertions(+), 37 deletions(-) diff --git a/qmake/library/qmakebuiltins.cpp b/qmake/library/qmakebuiltins.cpp index dd7766c8e0..3c4e509fc6 100644 --- a/qmake/library/qmakebuiltins.cpp +++ b/qmake/library/qmakebuiltins.cpp @@ -882,8 +882,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand( ret += values(map(args.at(0))); break; case E_LIST: { - QString tmp; - tmp.sprintf(".QMAKE_INTERNAL_TMP_variableName_%d", m_listCount++); + QString tmp(QString::asprintf(".QMAKE_INTERNAL_TMP_variableName_%d", m_listCount++)); ret = ProStringList(ProString(tmp)); ProStringList lst; for (const ProString &arg : args) diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 1f6fa89136..857b559aa4 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -6835,6 +6835,7 @@ QString QString::toUpper_helper(QString &str) return QUnicodeTables::convertCase(str); } +#if QT_DEPRECATED_SINCE(5, 14) /*! \obsolete @@ -6848,6 +6849,7 @@ QString &QString::sprintf(const char *cformat, ...) va_end(ap); return *this; } +#endif // ### Qt 6: Consider whether this function shouldn't be removed See task 202871. /*! @@ -6893,6 +6895,7 @@ QString QString::asprintf(const char *cformat, ...) return s; } +#if QT_DEPRECATED_SINCE(5, 14) /*! \obsolete @@ -6902,6 +6905,7 @@ QString &QString::vsprintf(const char *cformat, va_list ap) { return *this = vasprintf(cformat, ap); } +#endif static void append_utf8(QString &qs, const char *cs, int len) { diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index da76601e88..2b98787cc2 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -320,8 +320,12 @@ public: const QString &a4, const QString &a5, const QString &a6, const QString &a7, const QString &a8, const QString &a9) const; +#if QT_DEPRECATED_SINCE(5, 14) + QT_DEPRECATED_X("Use vasprintf(), arg() or QTextStream instead") QString &vsprintf(const char *format, va_list ap) Q_ATTRIBUTE_FORMAT_PRINTF(2, 0); + QT_DEPRECATED_X("Use asprintf(), arg() or QTextStream instead") QString &sprintf(const char *format, ...) Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); +#endif static QString vasprintf(const char *format, va_list ap) Q_ATTRIBUTE_FORMAT_PRINTF(1, 0); static QString asprintf(const char *format, ...) Q_ATTRIBUTE_FORMAT_PRINTF(1, 2); diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 6bdc82a8e9..25d488961c 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -1671,19 +1671,19 @@ int QPdfEnginePrivate::writeXmpMetaData() const QDateTime now = QDateTime::currentDateTime(); const QDate date = now.date(); const QTime time = now.time(); - - QString timeStr; - timeStr.sprintf("%d-%02d-%02dT%02d:%02d:%02d", date.year(), date.month(), date.day(), - time.hour(), time.minute(), time.second()); + const QString timeStr = + QString::asprintf("%d-%02d-%02dT%02d:%02d:%02d", + date.year(), date.month(), date.day(), + time.hour(), time.minute(), time.second()); const int offset = now.offsetFromUtc(); const int hours = (offset / 60) / 60; const int mins = (offset / 60) % 60; QString tzStr; if (offset < 0) - tzStr.sprintf("-%02d:%02d", -hours, -mins); + tzStr = QString::asprintf("-%02d:%02d", -hours, -mins); else if (offset > 0) - tzStr.sprintf("+%02d:%02d", hours , mins); + tzStr = QString::asprintf("+%02d:%02d", hours , mins); else tzStr = QLatin1String("Z"); diff --git a/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/src/platformsupport/kmsconvenience/qkmsdevice.cpp index ef81f6162d..4b27522976 100644 --- a/src/platformsupport/kmsconvenience/qkmsdevice.cpp +++ b/src/platformsupport/kmsconvenience/qkmsdevice.cpp @@ -777,9 +777,7 @@ void QKmsDevice::discoverPlanes() for (int i = 0; i < countFormats; ++i) { uint32_t f = drmplane->formats[i]; plane.supportedFormats.append(f); - QString s; - s.sprintf("%c%c%c%c ", f, f >> 8, f >> 16, f >> 24); - formatStr += s; + formatStr += QString::asprintf("%c%c%c%c ", f, f >> 8, f >> 16, f >> 24); } qCDebug(qLcKmsDebug, "plane %d: id = %u countFormats = %d possibleCrtcs = 0x%x supported formats = %s", diff --git a/src/printsupport/dialogs/qprintpreviewdialog.cpp b/src/printsupport/dialogs/qprintpreviewdialog.cpp index 258741c35c..39575d5f57 100644 --- a/src/printsupport/dialogs/qprintpreviewdialog.cpp +++ b/src/printsupport/dialogs/qprintpreviewdialog.cpp @@ -495,7 +495,7 @@ void QPrintPreviewDialogPrivate::updatePageNumLabel() void QPrintPreviewDialogPrivate::updateZoomFactor() { - zoomFactor->lineEdit()->setText(QString().sprintf("%.1f%%", preview->zoomFactor()*100)); + zoomFactor->lineEdit()->setText(QString::asprintf("%.1f%%", preview->zoomFactor()*100)); } void QPrintPreviewDialogPrivate::_q_fit(QAction* action) diff --git a/src/tools/qvkgen/qvkgen.cpp b/src/tools/qvkgen/qvkgen.cpp index 059f9413cb..4db3f26161 100644 --- a/src/tools/qvkgen/qvkgen.cpp +++ b/src/tools/qvkgen/qvkgen.cpp @@ -192,22 +192,20 @@ QString VkSpecParser::parseName() QString funcSig(const VkSpecParser::Command &c, const char *className = nullptr) { - QString s; - s.sprintf("%s %s%s%s", qPrintable(c.cmd.type), - (className ? className : ""), (className ? "::" : ""), - qPrintable(c.cmd.name)); + QString s(QString::asprintf("%s %s%s%s", qPrintable(c.cmd.type), + (className ? className : ""), (className ? "::" : ""), + qPrintable(c.cmd.name))); if (!c.args.isEmpty()) { s += QLatin1Char('('); bool first = true; for (const VkSpecParser::TypedName &a : c.args) { - QString argStr; - argStr.sprintf("%s%s%s%s", qPrintable(a.type), (a.type.endsWith(QLatin1Char('*')) ? "" : " "), - qPrintable(a.name), qPrintable(a.typeSuffix)); if (!first) s += QStringLiteral(", "); else first = false; - s += argStr; + s += QString::asprintf("%s%s%s%s", qPrintable(a.type), + (a.type.endsWith(QLatin1Char('*')) ? "" : " "), + qPrintable(a.name), qPrintable(a.typeSuffix)); } s += QLatin1Char(')'); } @@ -216,13 +214,12 @@ QString funcSig(const VkSpecParser::Command &c, const char *className = nullptr) QString funcCall(const VkSpecParser::Command &c, int idx) { - QString s; // template: // [return] reinterpret_cast(d_ptr->m_funcs[0])(instance, pPhysicalDeviceCount, pPhysicalDevices); - s.sprintf("%sreinterpret_cast(d_ptr->m_funcs[%d])", - (c.cmd.type == QStringLiteral("void") ? "" : "return "), - qPrintable(c.cmd.name), - idx); + QString s = QString::asprintf("%sreinterpret_cast(d_ptr->m_funcs[%d])", + (c.cmd.type == QStringLiteral("void") ? "" : "return "), + qPrintable(c.cmd.name), + idx); if (!c.args.isEmpty()) { s += QLatin1Char('('); bool first = true; @@ -338,10 +335,9 @@ bool genVulkanFunctionsH(const QVector &commands, const Q *dst += QStringLiteral(";\n"); } - QString str; - str.sprintf(s, preamble.get(licHeaderFn).constData(), instCmdStr.toUtf8().constData(), devCmdStr.toUtf8().constData()); - - f.write(str.toUtf8()); + f.write(QString::asprintf(s, preamble.get(licHeaderFn).constData(), + instCmdStr.toUtf8().constData(), + devCmdStr.toUtf8().constData()).toUtf8()); return true; } @@ -400,10 +396,7 @@ bool genVulkanFunctionsPH(const QVector &commands, const [](const VkSpecParser::Command &c) { return c.deviceLevel; }); const int instLevelCount = commands.count() - devLevelCount; - QString str; - str.sprintf(s, preamble.get(licHeaderFn).constData(), instLevelCount, devLevelCount); - - f.write(str.toUtf8()); + f.write(QString::asprintf(s, preamble.get(licHeaderFn).constData(), instLevelCount, devLevelCount).toUtf8()); return true; } @@ -478,10 +471,12 @@ bool genVulkanFunctionsPC(const QVector &commands, const if (instCmdNamesStr.count() > 2) instCmdNamesStr = instCmdNamesStr.left(instCmdNamesStr.count() - 2); - QString str; - str.sprintf(s, preamble.get(licHeaderFn).constData(), - instCmdWrapperStr.toUtf8().constData(), instCmdNamesStr.toUtf8().constData(), instIdx, - devCmdWrapperStr.toUtf8().constData(), devCmdNamesStr.toUtf8().constData(), commands.count() - instIdx); + const QString str = + QString::asprintf(s, preamble.get(licHeaderFn).constData(), + instCmdWrapperStr.toUtf8().constData(), + instCmdNamesStr.toUtf8().constData(), instIdx, + devCmdWrapperStr.toUtf8().constData(), + devCmdNamesStr.toUtf8().constData(), commands.count() - instIdx); f.write(str.toUtf8()); From 332f295743019a5b70eb923d6ad93352b0cb4079 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sat, 2 Mar 2019 21:27:56 +0100 Subject: [PATCH 060/292] QtBase: replace deprecated QString functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace deprecated QString functions in examples and tests: - QString::sprintf() - QString::null - QString::fromAscii Change-Id: I4404d17c1a65496c9079e8a7300e72a5b3740fe5 Reviewed-by: Luca Beldi Reviewed-by: Friedemann Kleint Reviewed-by: Jędrzej Nowacki --- .../hellovulkanwidget/hellovulkanwidget.cpp | 14 +- .../corelib/tools/qstring/tst_qstring.cpp | 132 ++++++++---------- .../corelib/tools/qtimezone/tst_qtimezone.cpp | 3 +- 3 files changed, 63 insertions(+), 86 deletions(-) diff --git a/examples/vulkan/hellovulkanwidget/hellovulkanwidget.cpp b/examples/vulkan/hellovulkanwidget/hellovulkanwidget.cpp index 81daa9bb96..cf95a0e6a0 100644 --- a/examples/vulkan/hellovulkanwidget/hellovulkanwidget.cpp +++ b/examples/vulkan/hellovulkanwidget/hellovulkanwidget.cpp @@ -140,12 +140,12 @@ void VulkanRenderer::initResources() m_devFuncs = inst->deviceFunctions(m_window->device()); QString info; - info += QString().sprintf("Number of physical devices: %d\n", m_window->availablePhysicalDevices().count()); + info += QString::asprintf("Number of physical devices: %d\n", m_window->availablePhysicalDevices().count()); QVulkanFunctions *f = inst->functions(); VkPhysicalDeviceProperties props; f->vkGetPhysicalDeviceProperties(m_window->physicalDevice(), &props); - info += QString().sprintf("Active physical device name: '%s' version %d.%d.%d\nAPI version %d.%d.%d\n", + info += QString::asprintf("Active physical device name: '%s' version %d.%d.%d\nAPI version %d.%d.%d\n", props.deviceName, VK_VERSION_MAJOR(props.driverVersion), VK_VERSION_MINOR(props.driverVersion), VK_VERSION_PATCH(props.driverVersion), @@ -154,19 +154,19 @@ void VulkanRenderer::initResources() info += QStringLiteral("Supported instance layers:\n"); for (const QVulkanLayer &layer : inst->supportedLayers()) - info += QString().sprintf(" %s v%u\n", layer.name.constData(), layer.version); + info += QString::asprintf(" %s v%u\n", layer.name.constData(), layer.version); info += QStringLiteral("Enabled instance layers:\n"); for (const QByteArray &layer : inst->layers()) - info += QString().sprintf(" %s\n", layer.constData()); + info += QString::asprintf(" %s\n", layer.constData()); info += QStringLiteral("Supported instance extensions:\n"); for (const QVulkanExtension &ext : inst->supportedExtensions()) - info += QString().sprintf(" %s v%u\n", ext.name.constData(), ext.version); + info += QString::asprintf(" %s v%u\n", ext.name.constData(), ext.version); info += QStringLiteral("Enabled instance extensions:\n"); for (const QByteArray &ext : inst->extensions()) - info += QString().sprintf(" %s\n", ext.constData()); + info += QString::asprintf(" %s\n", ext.constData()); - info += QString().sprintf("Color format: %u\nDepth-stencil format: %u\n", + info += QString::asprintf("Color format: %u\nDepth-stencil format: %u\n", m_window->colorFormat(), m_window->depthStencilFormat()); info += QStringLiteral("Supported sample counts:"); diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index e8ed22e427..e25c9e8395 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -482,8 +482,8 @@ private slots: void indexOf2(); void indexOf3_data(); // void indexOf3(); - void sprintf(); - void sprintfS(); + void asprintf(); + void asprintfS(); void fill(); void truncate(); void chop_data(); @@ -612,7 +612,7 @@ QString verifyZeroTermination(const QString &str) int strSize = str.size(); QChar strTerminator = str.constData()[strSize]; if (QChar('\0') != strTerminator) - return QString::fromAscii( + return QString::fromLatin1( "*** Result ('%1') not null-terminated: 0x%2 ***").arg(str) .arg(strTerminator.unicode(), 4, 16, QChar('0')); @@ -625,11 +625,11 @@ QString verifyZeroTermination(const QString &str) const_cast(strData)[strSize] = QChar('x'); if (QChar('x') != str.constData()[strSize]) { - return QString::fromAscii("*** Failed to replace null-terminator in " + return QString::fromLatin1("*** Failed to replace null-terminator in " "result ('%1') ***").arg(str); } if (str != strCopy) { - return QString::fromAscii( "*** Result ('%1') differs from its copy " + return QString::fromLatin1( "*** Result ('%1') differs from its copy " "after null-terminator was replaced ***").arg(str); } const_cast(strData)[strSize] = QChar('\0'); // Restore sanity @@ -1075,9 +1075,8 @@ void tst_QString::isNull() QString a; QVERIFY(a.isNull()); - const char *zero = 0; - a.sprintf( zero ); - QVERIFY(!a.isNull()); + const char *zero = nullptr; + QVERIFY(!QString::asprintf(zero).isNull()); } QT_WARNING_POP @@ -1263,75 +1262,66 @@ static inline const void *ptrValue(quintptr v) return reinterpret_cast(v); } -void tst_QString::sprintf() +void tst_QString::asprintf() { QString a; - a.sprintf("COMPARE"); - QCOMPARE(a, QLatin1String("COMPARE")); - a.sprintf("%%%d",1); - QCOMPARE(a, QLatin1String("%1")); - QCOMPARE(a.sprintf("X%dY",2), QLatin1String("X2Y")); - QCOMPARE(a.sprintf("X%9iY", 50000 ), QLatin1String("X 50000Y")); - QCOMPARE(a.sprintf("X%-9sY","hello"), QLatin1String("Xhello Y")); - QCOMPARE(a.sprintf("X%-9iY", 50000 ), QLatin1String("X50000 Y")); - QCOMPARE(a.sprintf("%lf", 1.23), QLatin1String("1.230000")); - QCOMPARE(a.sprintf("%lf", 1.23456789), QLatin1String("1.234568")); - QCOMPARE(a.sprintf("%p", ptrValue(0xbfffd350)), QLatin1String("0xbfffd350")); - QCOMPARE(a.sprintf("%p", ptrValue(0)), QLatin1String("0x0")); + QCOMPARE(QString::asprintf("COMPARE"), QLatin1String("COMPARE")); + QCOMPARE(QString::asprintf("%%%d", 1), QLatin1String("%1")); + QCOMPARE(QString::asprintf("X%dY",2), QLatin1String("X2Y")); + QCOMPARE(QString::asprintf("X%9iY", 50000 ), QLatin1String("X 50000Y")); + QCOMPARE(QString::asprintf("X%-9sY","hello"), QLatin1String("Xhello Y")); + QCOMPARE(QString::asprintf("X%-9iY", 50000 ), QLatin1String("X50000 Y")); + QCOMPARE(QString::asprintf("%lf", 1.23), QLatin1String("1.230000")); + QCOMPARE(QString::asprintf("%lf", 1.23456789), QLatin1String("1.234568")); + QCOMPARE(QString::asprintf("%p", ptrValue(0xbfffd350)), QLatin1String("0xbfffd350")); + QCOMPARE(QString::asprintf("%p", ptrValue(0)), QLatin1String("0x0")); int i = 6; long l = -2; float f = 4.023f; - QString S1; - S1.sprintf("%d %ld %f",i,l,f); - QCOMPARE(S1, QLatin1String("6 -2 4.023000")); + QCOMPARE(QString::asprintf("%d %ld %f", i, l, f), QLatin1String("6 -2 4.023000")); double d = -514.25683; - S1.sprintf("%f",d); - QCOMPARE(S1, QLatin1String("-514.256830")); + QCOMPARE(QString::asprintf("%f", d), QLatin1String("-514.256830")); } -void tst_QString::sprintfS() +void tst_QString::asprintfS() { - QString a; - QCOMPARE(a.sprintf("%.3s", "Hello" ), QLatin1String("Hel")); - QCOMPARE(a.sprintf("%10.3s", "Hello" ), QLatin1String(" Hel")); - QCOMPARE(a.sprintf("%.10s", "Hello" ), QLatin1String("Hello")); - QCOMPARE(a.sprintf("%10.10s", "Hello" ), QLatin1String(" Hello")); - QCOMPARE(a.sprintf("%-10.10s", "Hello" ), QLatin1String("Hello ")); - QCOMPARE(a.sprintf("%-10.3s", "Hello" ), QLatin1String("Hel ")); - QCOMPARE(a.sprintf("%-5.5s", "Hello" ), QLatin1String("Hello")); + QCOMPARE(QString::asprintf("%.3s", "Hello" ), QLatin1String("Hel")); + QCOMPARE(QString::asprintf("%10.3s", "Hello" ), QLatin1String(" Hel")); + QCOMPARE(QString::asprintf("%.10s", "Hello" ), QLatin1String("Hello")); + QCOMPARE(QString::asprintf("%10.10s", "Hello" ), QLatin1String(" Hello")); + QCOMPARE(QString::asprintf("%-10.10s", "Hello" ), QLatin1String("Hello ")); + QCOMPARE(QString::asprintf("%-10.3s", "Hello" ), QLatin1String("Hel ")); + QCOMPARE(QString::asprintf("%-5.5s", "Hello" ), QLatin1String("Hello")); // Check utf8 conversion for %s - QCOMPARE(a.sprintf("%s", "\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205"), QString::fromLatin1("\366\344\374\326\304\334\370\346\345\330\306\305")); + QCOMPARE(QString::asprintf("%s", "\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205"), QString::fromLatin1("\366\344\374\326\304\334\370\346\345\330\306\305")); int n1; - a.sprintf("%s%n%s", "hello", &n1, "goodbye"); + QCOMPARE(QString::asprintf("%s%n%s", "hello", &n1, "goodbye"), QString("hellogoodbye")); QCOMPARE(n1, 5); - QCOMPARE(a, QString("hellogoodbye")); qlonglong n2; - a.sprintf("%s%s%lln%s", "foo", "bar", &n2, "whiz"); + QCOMPARE(QString::asprintf("%s%s%lln%s", "foo", "bar", &n2, "whiz"), QString("foobarwhiz")); QCOMPARE((int)n2, 6); - QCOMPARE(a, QString("foobarwhiz")); { // %ls - QCOMPARE(a.sprintf("%.3ls", qUtf16Printable("Hello")), QLatin1String("Hel")); - QCOMPARE(a.sprintf("%10.3ls", qUtf16Printable("Hello")), QLatin1String(" Hel")); - QCOMPARE(a.sprintf("%.10ls", qUtf16Printable("Hello")), QLatin1String("Hello")); - QCOMPARE(a.sprintf("%10.10ls", qUtf16Printable("Hello")), QLatin1String(" Hello")); - QCOMPARE(a.sprintf("%-10.10ls", qUtf16Printable("Hello")), QLatin1String("Hello ")); - QCOMPARE(a.sprintf("%-10.3ls", qUtf16Printable("Hello")), QLatin1String("Hel ")); - QCOMPARE(a.sprintf("%-5.5ls", qUtf16Printable("Hello")), QLatin1String("Hello")); + QCOMPARE(QString::asprintf("%.3ls", qUtf16Printable("Hello")), QLatin1String("Hel")); + QCOMPARE(QString::asprintf("%10.3ls", qUtf16Printable("Hello")), QLatin1String(" Hel")); + QCOMPARE(QString::asprintf("%.10ls", qUtf16Printable("Hello")), QLatin1String("Hello")); + QCOMPARE(QString::asprintf("%10.10ls", qUtf16Printable("Hello")), QLatin1String(" Hello")); + QCOMPARE(QString::asprintf("%-10.10ls", qUtf16Printable("Hello")), QLatin1String("Hello ")); + QCOMPARE(QString::asprintf("%-10.3ls", qUtf16Printable("Hello")), QLatin1String("Hel ")); + QCOMPARE(QString::asprintf("%-5.5ls", qUtf16Printable("Hello")), QLatin1String("Hello")); // Check utf16 is preserved for %ls - QCOMPARE(a.sprintf("%ls", + QCOMPARE(QString::asprintf("%ls", qUtf16Printable("\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205")), QLatin1String("\366\344\374\326\304\334\370\346\345\330\306\305")); int n; - a.sprintf("%ls%n%s", qUtf16Printable("hello"), &n, "goodbye"); + QCOMPARE(QString::asprintf("%ls%n%s", qUtf16Printable("hello"), &n, "goodbye"), QLatin1String("hellogoodbye")); QCOMPARE(n, 5); - QCOMPARE(a, QLatin1String("hellogoodbye")); } } @@ -3789,7 +3779,7 @@ void tst_QString::startsWith() QVERIFY( !a.startsWith("C") ); QVERIFY( !a.startsWith("ABCDEF") ); QVERIFY( a.startsWith("") ); - QVERIFY( a.startsWith(QString::null) ); + QVERIFY( a.startsWith(QString()) ); QVERIFY( a.startsWith('A') ); QVERIFY( a.startsWith(QLatin1Char('A')) ); QVERIFY( a.startsWith(QChar('A')) ); @@ -3816,7 +3806,7 @@ void tst_QString::startsWith() QVERIFY( !a.startsWith("c", Qt::CaseInsensitive) ); QVERIFY( !a.startsWith("abcdef", Qt::CaseInsensitive) ); QVERIFY( a.startsWith("", Qt::CaseInsensitive) ); - QVERIFY( a.startsWith(QString::null, Qt::CaseInsensitive) ); + QVERIFY( a.startsWith(QString(), Qt::CaseInsensitive) ); QVERIFY( a.startsWith('a', Qt::CaseInsensitive) ); QVERIFY( a.startsWith('A', Qt::CaseInsensitive) ); QVERIFY( a.startsWith(QLatin1Char('a'), Qt::CaseInsensitive) ); @@ -3855,7 +3845,7 @@ void tst_QString::startsWith() a = ""; QVERIFY( a.startsWith("") ); - QVERIFY( a.startsWith(QString::null) ); + QVERIFY( a.startsWith(QString()) ); QVERIFY( !a.startsWith("ABC") ); QVERIFY( a.startsWith(QLatin1String("")) ); @@ -3868,7 +3858,7 @@ void tst_QString::startsWith() a = QString(); QVERIFY( !a.startsWith("") ); - QVERIFY( a.startsWith(QString::null) ); + QVERIFY( a.startsWith(QString()) ); QVERIFY( !a.startsWith("ABC") ); QVERIFY( !a.startsWith(QLatin1String("")) ); @@ -3897,7 +3887,7 @@ void tst_QString::endsWith() QVERIFY( !a.endsWith("C") ); QVERIFY( !a.endsWith("ABCDEF") ); QVERIFY( a.endsWith("") ); - QVERIFY( a.endsWith(QString::null) ); + QVERIFY( a.endsWith(QString()) ); QVERIFY( a.endsWith('B') ); QVERIFY( a.endsWith(QLatin1Char('B')) ); QVERIFY( a.endsWith(QChar('B')) ); @@ -3924,7 +3914,7 @@ void tst_QString::endsWith() QVERIFY( !a.endsWith("c", Qt::CaseInsensitive) ); QVERIFY( !a.endsWith("abcdef", Qt::CaseInsensitive) ); QVERIFY( a.endsWith("", Qt::CaseInsensitive) ); - QVERIFY( a.endsWith(QString::null, Qt::CaseInsensitive) ); + QVERIFY( a.endsWith(QString(), Qt::CaseInsensitive) ); QVERIFY( a.endsWith('b', Qt::CaseInsensitive) ); QVERIFY( a.endsWith('B', Qt::CaseInsensitive) ); QVERIFY( a.endsWith(QLatin1Char('b'), Qt::CaseInsensitive) ); @@ -3966,7 +3956,7 @@ void tst_QString::endsWith() a = ""; QVERIFY( a.endsWith("") ); - QVERIFY( a.endsWith(QString::null) ); + QVERIFY( a.endsWith(QString()) ); QVERIFY( !a.endsWith("ABC") ); QVERIFY( !a.endsWith(QLatin1Char(0)) ); QVERIFY( !a.endsWith(QLatin1Char('x')) ); @@ -3978,7 +3968,7 @@ void tst_QString::endsWith() a = QString(); QVERIFY( !a.endsWith("") ); - QVERIFY( a.endsWith(QString::null) ); + QVERIFY( a.endsWith(QString()) ); QVERIFY( !a.endsWith("ABC") ); QVERIFY( !a.endsWith(QLatin1String("")) ); @@ -4838,7 +4828,7 @@ void tst_QString::arg() QCOMPARE( QString("%1").arg("hello", 10), QLatin1String(" hello") ); QCOMPARE( QString("%1%1").arg("hello"), QLatin1String("hellohello") ); QCOMPARE( QString("%2%1").arg("hello"), QLatin1String("%2hello") ); - QCOMPARE( QString("%1%1").arg(QString::null), QLatin1String("") ); + QCOMPARE( QString("%1%1").arg(QString()), QLatin1String("") ); QCOMPARE( QString("%2%1").arg(""), QLatin1String("%2") ); QCOMPARE( QString("%2 %L1").arg(12345.6789).arg(12345.6789), @@ -4934,9 +4924,7 @@ void tst_QString::doubleOut() QCOMPARE(QString::number(micro), expect); QCOMPARE(QString("%1").arg(micro), expect); { - QString text; - text.sprintf("%g", micro); - QCOMPARE(text, expect); + QCOMPARE(QString::asprintf("%g", micro), expect); } { QString text; @@ -5480,8 +5468,6 @@ void tst_QString::tortureSprintfDouble() { const SprintfDoubleData *data = g_sprintf_double_data; - QString s; - for (; data->fmt != 0; ++data) { double d; char *buff = (char *)&d; @@ -5496,7 +5482,7 @@ void tst_QString::tortureSprintfDouble() for (uint i = 0; i < 8; ++i) buff[7 - i] = data->bytes[i]; # endif - s.sprintf(data->fmt, d); + const QString s = QString::asprintf(data->fmt, d); #ifdef QT_NO_FPU // reduced precision when running with hardfloats in qemu if (d - 0.1 < 1e12) QSKIP("clib sprintf doesn't fill with 0's on this platform"); @@ -6450,32 +6436,24 @@ void tst_QString::QCharRefDetaching() const void tst_QString::sprintfZU() const { { - QString string; size_t s = 6; - string.sprintf("%zu", s); - QCOMPARE(string, QString::fromLatin1("6")); + QCOMPARE(QString::asprintf("%zu", s), QString::fromLatin1("6")); } { - QString string; - string.sprintf("%s\n", "foo"); - QCOMPARE(string, QString::fromLatin1("foo\n")); + QCOMPARE(QString::asprintf("%s\n", "foo"), QString::fromLatin1("foo\n")); } { /* This code crashed. I don't know how to reduce it further. In other words, * both %zu and %s needs to be present. */ size_t s = 6; - QString string; - string.sprintf("%zu%s", s, "foo"); - QCOMPARE(string, QString::fromLatin1("6foo")); + QCOMPARE(QString::asprintf("%zu%s", s, "foo"), QString::fromLatin1("6foo")); } { size_t s = 6; - QString string; - string.sprintf("%zu %s\n", s, "foo"); - QCOMPARE(string, QString::fromLatin1("6 foo\n")); + QCOMPARE(QString::asprintf("%zu %s\n", s, "foo"), QString::fromLatin1("6 foo\n")); } } diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp index a25fd39693..fc4cb717ec 100644 --- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp @@ -480,11 +480,10 @@ void tst_QTimeZone::transitionEachZone_data() { 1288488600, -4, 8, 2010 } // 2010-10-31 01:30 UTC; Europe, Russia }; - QString name; const auto zones = QTimeZone::availableTimeZoneIds(); for (int k = sizeof(table) / sizeof(table[0]); k-- > 0; ) { for (const QByteArray &zone : zones) { - name.sprintf("%s@%d", zone.constData(), table[k].year); + const QString name = QString::asprintf("%s@%d", zone.constData(), table[k].year); QTest::newRow(name.toUtf8().constData()) << zone << table[k].baseSecs From d8ac4b40b5acb5582b1491f48f3d3c2cfc044666 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 3 Mar 2019 19:31:26 +0100 Subject: [PATCH 061/292] Examples: replace deprecated QComboBox functions Replace the deprecated currentIndexChanged(QString) and activated(QString) with the new currentTextChanged() and textActivated() functions Change-Id: I8616354fa06cc63dce6f5cfef0902f4b55981043 Reviewed-by: Friedemann Kleint --- examples/widgets/graphicsview/diagramscene/mainwindow.cpp | 4 ++-- .../widgets/graphicsview/embeddeddialogs/embeddeddialog.cpp | 2 +- examples/widgets/richtext/textedit/textedit.cpp | 4 ++-- examples/widgets/widgets/charactermap/mainwindow.cpp | 4 ++-- examples/widgets/widgets/spinboxes/window.cpp | 2 +- examples/widgets/widgets/styles/widgetgallery.cpp | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/widgets/graphicsview/diagramscene/mainwindow.cpp b/examples/widgets/graphicsview/diagramscene/mainwindow.cpp index 07f92f61c1..3327d4d5df 100644 --- a/examples/widgets/graphicsview/diagramscene/mainwindow.cpp +++ b/examples/widgets/graphicsview/diagramscene/mainwindow.cpp @@ -473,7 +473,7 @@ void MainWindow::createToolbars() fontSizeCombo->addItem(QString().setNum(i)); QIntValidator *validator = new QIntValidator(2, 64, this); fontSizeCombo->setValidator(validator); - connect(fontSizeCombo, QOverload::of(&QComboBox::currentIndexChanged), + connect(fontSizeCombo, &QComboBox::currentTextChanged, this, &MainWindow::fontSizeChanged); fontColorToolButton = new QToolButton; @@ -536,7 +536,7 @@ void MainWindow::createToolbars() scales << tr("50%") << tr("75%") << tr("100%") << tr("125%") << tr("150%"); sceneScaleCombo->addItems(scales); sceneScaleCombo->setCurrentIndex(2); - connect(sceneScaleCombo, QOverload::of(&QComboBox::currentIndexChanged), + connect(sceneScaleCombo, &QComboBox::currentTextChanged, this, &MainWindow::sceneScaleChanged); pointerToolbar = addToolBar(tr("Pointer type")); diff --git a/examples/widgets/graphicsview/embeddeddialogs/embeddeddialog.cpp b/examples/widgets/graphicsview/embeddeddialogs/embeddeddialog.cpp index 0c831360cf..9fa24fcd17 100644 --- a/examples/widgets/graphicsview/embeddeddialogs/embeddeddialog.cpp +++ b/examples/widgets/graphicsview/embeddeddialogs/embeddeddialog.cpp @@ -73,7 +73,7 @@ EmbeddedDialog::EmbeddedDialog(QWidget *parent) this, &EmbeddedDialog::spacingChanged); connect(ui->fontComboBox, &QFontComboBox::currentFontChanged, this, &EmbeddedDialog::fontChanged); - connect(ui->style, QOverload::of(&QComboBox::activated), + connect(ui->style, &QComboBox::textActivated, this, &EmbeddedDialog::styleChanged); } diff --git a/examples/widgets/richtext/textedit/textedit.cpp b/examples/widgets/richtext/textedit/textedit.cpp index 00ea0325dc..3ad9f48b67 100644 --- a/examples/widgets/richtext/textedit/textedit.cpp +++ b/examples/widgets/richtext/textedit/textedit.cpp @@ -369,7 +369,7 @@ void TextEdit::setupTextActions() comboFont = new QFontComboBox(tb); tb->addWidget(comboFont); - connect(comboFont, QOverload::of(&QComboBox::activated), this, &TextEdit::textFamily); + connect(comboFont, &QComboBox::textActivated, this, &TextEdit::textFamily); comboSize = new QComboBox(tb); comboSize->setObjectName("comboSize"); @@ -381,7 +381,7 @@ void TextEdit::setupTextActions() comboSize->addItem(QString::number(size)); comboSize->setCurrentIndex(standardSizes.indexOf(QApplication::font().pointSize())); - connect(comboSize, QOverload::of(&QComboBox::activated), this, &TextEdit::textSize); + connect(comboSize, &QComboBox::textActivated, this, &TextEdit::textSize); } bool TextEdit::load(const QString &f) diff --git a/examples/widgets/widgets/charactermap/mainwindow.cpp b/examples/widgets/widgets/charactermap/mainwindow.cpp index e84ded5afb..77aad145e7 100644 --- a/examples/widgets/widgets/charactermap/mainwindow.cpp +++ b/examples/widgets/widgets/charactermap/mainwindow.cpp @@ -114,9 +114,9 @@ MainWindow::MainWindow(QWidget *parent) this, &MainWindow::findSizes); connect(fontCombo, &QFontComboBox::currentFontChanged, characterWidget, &CharacterWidget::updateFont); - connect(sizeCombo, QOverload::of(&QComboBox::currentIndexChanged), + connect(sizeCombo, &QComboBox::currentTextChanged, characterWidget, &CharacterWidget::updateSize); - connect(styleCombo, QOverload::of(&QComboBox::currentIndexChanged), + connect(styleCombo, &QComboBox::currentTextChanged, characterWidget, &CharacterWidget::updateStyle); //! [4] //! [5] connect(characterWidget, &CharacterWidget::characterSelected, diff --git a/examples/widgets/widgets/spinboxes/window.cpp b/examples/widgets/widgets/spinboxes/window.cpp index fd7c5b527e..82e19527a7 100644 --- a/examples/widgets/widgets/spinboxes/window.cpp +++ b/examples/widgets/widgets/spinboxes/window.cpp @@ -176,7 +176,7 @@ void Window::createDateTimeEdits() formatComboBox->addItem("hh:mm ap"); //! [9] //! [10] - connect(formatComboBox, QOverload::of(&QComboBox::activated), + connect(formatComboBox, &QComboBox::textActivated, this, &Window::setFormatString); //! [10] diff --git a/examples/widgets/widgets/styles/widgetgallery.cpp b/examples/widgets/widgets/styles/widgetgallery.cpp index f0a0336a94..34c010df74 100644 --- a/examples/widgets/widgets/styles/widgetgallery.cpp +++ b/examples/widgets/widgets/styles/widgetgallery.cpp @@ -79,7 +79,7 @@ WidgetGallery::WidgetGallery(QWidget *parent) //! [0] //! [1] - connect(styleComboBox, QOverload::of(&QComboBox::activated), + connect(styleComboBox, &QComboBox::textActivated, //! [1] //! [2] this, &WidgetGallery::changeStyle); connect(useStylePaletteCheckBox, &QCheckBox::toggled, From d41a46bc39d35ddcf12f092c1b9ab41cc6c2aa16 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 4 Mar 2019 15:06:34 +0100 Subject: [PATCH 062/292] rcc test: Avoid repetitive invocation of QFINDTESTDATA() Store the test data path in a member variable. Task-number: PYSIDE-855 Change-Id: Ibb81e4024c870e67e209c79ec95264e747632bc6 Reviewed-by: Cristian Maureira-Fredes Reviewed-by: hjk --- tests/auto/tools/rcc/tst_rcc.cpp | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/tests/auto/tools/rcc/tst_rcc.cpp b/tests/auto/tools/rcc/tst_rcc.cpp index c810c6e364..dfe8ba556b 100644 --- a/tests/auto/tools/rcc/tst_rcc.cpp +++ b/tests/auto/tools/rcc/tst_rcc.cpp @@ -66,6 +66,7 @@ private slots: private: QString m_rcc; + QString m_dataPath; }; void tst_rcc::initTestCase() @@ -74,6 +75,9 @@ void tst_rcc::initTestCase() // we must force a certain hash order when testing or tst_rcc will fail, see QTBUG-25078 QVERIFY(qputenv("QT_RCC_TEST", "1")); m_rcc = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QLatin1String("/rcc"); + + m_dataPath = QFINDTESTDATA("data"); + QVERIFY(!m_dataPath.isEmpty()); } QString findExpectedFile(const QString &base) @@ -126,14 +130,10 @@ void tst_rcc::rcc_data() QTest::addColumn("qrcfile"); QTest::addColumn("expected"); - QString dataPath = QFINDTESTDATA("data/images/"); - if (dataPath.isEmpty()) - QFAIL("data path not found"); - QTest::newRow("images") << dataPath << "images.qrc" << "images.expected"; + const QString imagesPath = m_dataPath + QLatin1String("/images/"); + QTest::newRow("images") << imagesPath << "images.qrc" << "images.expected"; - QString sizesPath = QFINDTESTDATA("data/sizes/"); - if (sizesPath.isEmpty()) - QFAIL("data path not found"); + const QString sizesPath = m_dataPath + QLatin1String("/sizes/"); QTest::newRow("size-0") << sizesPath << "size-0.qrc" << "size-0.expected"; QTest::newRow("size-1") << sizesPath << "size-1.qrc" << "size-1.expected"; QTest::newRow("size-2-0-35-1") << sizesPath << "size-2-0-35-1.qrc" << "size-2-0-35-1.expected"; @@ -268,9 +268,7 @@ void tst_rcc::binary_data() QTest::addColumn("baseDirectory"); QTest::addColumn("expectedFiles"); - QString dataPath = QFINDTESTDATA("data/binary/"); - if (dataPath.isEmpty()) - QFAIL("data path not found"); + QString dataPath = m_dataPath + QLatin1String("/binary/"); QDirIterator iter(dataPath, QStringList() << QLatin1String("*.qrc")); while (iter.hasNext()) @@ -386,16 +384,12 @@ void tst_rcc::readback() QFETCH(QString, resourceName); QFETCH(QString, fileSystemName); - QString dataPath = QFINDTESTDATA("data/"); - if (dataPath.isEmpty()) - QFAIL("data path not found"); - QFile resourceFile(resourceName); QVERIFY(resourceFile.open(QIODevice::ReadOnly)); QByteArray resourceData = resourceFile.readAll(); resourceFile.close(); - QFile fileSystemFile(dataPath + fileSystemName); + QFile fileSystemFile(m_dataPath + QLatin1Char('/') + fileSystemName); QVERIFY(fileSystemFile.open(QIODevice::ReadOnly)); QByteArray fileSystemData = fileSystemFile.readAll(); fileSystemFile.close(); @@ -405,10 +399,7 @@ void tst_rcc::readback() void tst_rcc::cleanupTestCase() { - QString dataPath = QFINDTESTDATA("data/binary/"); - if (dataPath.isEmpty()) - return; - QDir dataDir(dataPath); + QDir dataDir(m_dataPath + QLatin1String("/binary")); QFileInfoList entries = dataDir.entryInfoList(QStringList() << QLatin1String("*.rcc")); foreach (const QFileInfo &entry, entries) QFile::remove(entry.absoluteFilePath()); From 40e4ab673a06d509f7672de6cbf05c80f981aeb6 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sun, 10 Feb 2019 18:43:46 +0100 Subject: [PATCH 063/292] Simplify toStdWString In C++17: just use std::basic_string::data(). In C++11: dereferencing begin() on an empty string is undefined behavior on all compilers, not just MSVC, so remove that workaround. Instead of the reference-dereference combo, use std::basic_string::front(). Change-Id: I3229597e000311ce71e4083dca6667bb56d8f8e3 Reviewed-by: Thiago Macieira --- src/corelib/tools/qstring.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 2b98787cc2..23972d196c 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -1380,14 +1380,12 @@ inline std::wstring QString::toStdWString() const { std::wstring str; str.resize(length()); - -#ifdef Q_CC_MSVC - // VS2005 crashes if the string is empty - if (!length()) - return str; +#if __cplusplus >= 201703L + str.resize(toWCharArray(str.data())); +#else + if (length()) + str.resize(toWCharArray(&str.front())); #endif - - str.resize(toWCharArray(&(*str.begin()))); return str; } From 6d46bc8aa2abeb37eb833c0905a74dcee13922fd Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 4 Mar 2019 12:54:43 +0100 Subject: [PATCH 064/292] Update qopengles2ext to the latest Khronos version Source: https://www.khronos.org/registry/OpenGL/api/GLES2/gl2ext.h Change-Id: If96c0c13784e9d3a254326971ef46527604fd46f Reviewed-by: Laszlo Agocs --- src/gui/opengl/qopengles2ext.h | 442 ++++++++++++++++++++++++++++++++- 1 file changed, 432 insertions(+), 10 deletions(-) diff --git a/src/gui/opengl/qopengles2ext.h b/src/gui/opengl/qopengles2ext.h index 8ff50a924e..8517e24267 100644 --- a/src/gui/opengl/qopengles2ext.h +++ b/src/gui/opengl/qopengles2ext.h @@ -1,5 +1,5 @@ -#ifndef __gl2ext_h_ -#define __gl2ext_h_ 1 +#ifndef __gles2_gl2ext_h_ +#define __gles2_gl2ext_h_ 1 #if 0 #pragma qt_no_master_include @@ -25,7 +25,7 @@ typedef struct __GLsync *GLsync; #endif /* -** Copyright (c) 2013-2017 The Khronos Group Inc. +** Copyright (c) 2013-2018 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the @@ -57,7 +57,7 @@ typedef struct __GLsync *GLsync; #define GL_APIENTRYP GL_APIENTRY* #endif -/* Generated on date 20170331 */ +/* Generated on date 20190228 */ /* Generated C header for: * API: gles2 @@ -178,6 +178,16 @@ GL_APICALL void GL_APIENTRY glGetPointervKHR (GLenum pname, void **params); #define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 #endif /* GL_KHR_no_error */ +#ifndef GL_KHR_parallel_shader_compile +#define GL_KHR_parallel_shader_compile 1 +#define GL_MAX_SHADER_COMPILER_THREADS_KHR 0x91B0 +#define GL_COMPLETION_STATUS_KHR 0x91B1 +typedef void (GL_APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSKHRPROC) (GLuint count); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glMaxShaderCompilerThreadsKHR (GLuint count); +#endif +#endif /* GL_KHR_parallel_shader_compile */ + #ifndef GL_KHR_robust_buffer_access_behavior #define GL_KHR_robust_buffer_access_behavior 1 #endif /* GL_KHR_robust_buffer_access_behavior */ @@ -343,12 +353,12 @@ GL_APICALL GLboolean GL_APIENTRY glIsEnablediOES (GLenum target, GLuint index); typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXOESPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); typedef void (GL_APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXOESPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXOESPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); -typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXOESPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, const GLint *basevertex); +typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, const GLint *basevertex); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glDrawElementsBaseVertexOES (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); GL_APICALL void GL_APIENTRY glDrawRangeElementsBaseVertexOES (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); GL_APICALL void GL_APIENTRY glDrawElementsInstancedBaseVertexOES (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); -GL_APICALL void GL_APIENTRY glMultiDrawElementsBaseVertexOES (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, const GLint *basevertex); +GL_APICALL void GL_APIENTRY glMultiDrawElementsBaseVertexEXT (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, const GLint *basevertex); #endif #endif /* GL_OES_draw_elements_base_vertex */ @@ -810,6 +820,22 @@ GL_APICALL void GL_APIENTRY glGetFloati_vOES (GLenum target, GLuint index, GLflo #define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE #endif /* GL_AMD_compressed_ATC_texture */ +#ifndef GL_AMD_framebuffer_multisample_advanced +#define GL_AMD_framebuffer_multisample_advanced 1 +#define GL_RENDERBUFFER_STORAGE_SAMPLES_AMD 0x91B2 +#define GL_MAX_COLOR_FRAMEBUFFER_SAMPLES_AMD 0x91B3 +#define GL_MAX_COLOR_FRAMEBUFFER_STORAGE_SAMPLES_AMD 0x91B4 +#define GL_MAX_DEPTH_STENCIL_FRAMEBUFFER_SAMPLES_AMD 0x91B5 +#define GL_NUM_SUPPORTED_MULTISAMPLE_MODES_AMD 0x91B6 +#define GL_SUPPORTED_MULTISAMPLE_MODES_AMD 0x91B7 +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEADVANCEDAMDPROC) (GLenum target, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEADVANCEDAMDPROC) (GLuint renderbuffer, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleAdvancedAMD (GLenum target, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glNamedRenderbufferStorageMultisampleAdvancedAMD (GLuint renderbuffer, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_AMD_framebuffer_multisample_advanced */ + #ifndef GL_AMD_performance_monitor #define GL_AMD_performance_monitor 1 #define GL_COUNTER_TYPE_AMD 0x8BC0 @@ -1070,6 +1096,20 @@ GL_APICALL void GL_APIENTRY glGetSyncivAPPLE (GLsync sync, GLenum pname, GLsizei #define GL_SHADER_BINARY_DMP 0x9250 #endif /* GL_DMP_shader_binary */ +#ifndef GL_EXT_EGL_image_array +#define GL_EXT_EGL_image_array 1 +#endif /* GL_EXT_EGL_image_array */ + +#ifndef GL_EXT_EGL_image_storage +#define GL_EXT_EGL_image_storage 1 +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXSTORAGEEXTPROC) (GLenum target, GLeglImageOES image, const GLint* attrib_list); +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURESTORAGEEXTPROC) (GLuint texture, GLeglImageOES image, const GLint* attrib_list); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glEGLImageTargetTexStorageEXT (GLenum target, GLeglImageOES image, const GLint* attrib_list); +GL_APICALL void GL_APIENTRY glEGLImageTargetTextureStorageEXT (GLuint texture, GLeglImageOES image, const GLint* attrib_list); +#endif +#endif /* GL_EXT_EGL_image_storage */ + #ifndef GL_EXT_YUV_target #define GL_EXT_YUV_target 1 #define GL_SAMPLER_EXTERNAL_2D_Y2Y_EXT 0x8BE7 @@ -1141,6 +1181,20 @@ GL_APICALL void GL_APIENTRY glClearTexSubImageEXT (GLuint texture, GLint level, #endif #endif /* GL_EXT_clear_texture */ +#ifndef GL_EXT_clip_control +#define GL_EXT_clip_control 1 +#define GL_LOWER_LEFT_EXT 0x8CA1 +#define GL_UPPER_LEFT_EXT 0x8CA2 +#define GL_NEGATIVE_ONE_TO_ONE_EXT 0x935E +#define GL_ZERO_TO_ONE_EXT 0x935F +#define GL_CLIP_ORIGIN_EXT 0x935C +#define GL_CLIP_DEPTH_MODE_EXT 0x935D +typedef void (GL_APIENTRYP PFNGLCLIPCONTROLEXTPROC) (GLenum origin, GLenum depth); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glClipControlEXT (GLenum origin, GLenum depth); +#endif +#endif /* GL_EXT_clip_control */ + #ifndef GL_EXT_clip_cull_distance #define GL_EXT_clip_cull_distance 1 #define GL_MAX_CLIP_DISTANCES_EXT 0x0D32 @@ -1211,6 +1265,11 @@ GL_APICALL void GL_APIENTRY glPopGroupMarkerEXT (void); #endif #endif /* GL_EXT_debug_marker */ +#ifndef GL_EXT_depth_clamp +#define GL_EXT_depth_clamp 1 +#define GL_DEPTH_CLAMP_EXT 0x864F +#endif /* GL_EXT_depth_clamp */ + #ifndef GL_EXT_discard_framebuffer #define GL_EXT_discard_framebuffer 1 #define GL_COLOR_EXT 0x1800 @@ -1326,12 +1385,10 @@ GL_APICALL GLboolean GL_APIENTRY glIsEnablediEXT (GLenum target, GLuint index); typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); typedef void (GL_APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); -typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, const GLint *basevertex); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glDrawElementsBaseVertexEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); GL_APICALL void GL_APIENTRY glDrawRangeElementsBaseVertexEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); GL_APICALL void GL_APIENTRY glDrawElementsInstancedBaseVertexEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); -GL_APICALL void GL_APIENTRY glMultiDrawElementsBaseVertexEXT (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, const GLint *basevertex); #endif #endif /* GL_EXT_draw_elements_base_vertex */ @@ -1355,6 +1412,17 @@ GL_APICALL void GL_APIENTRY glDrawTransformFeedbackInstancedEXT (GLenum mode, GL #endif #endif /* GL_EXT_draw_transform_feedback */ +#ifndef GL_EXT_external_buffer +#define GL_EXT_external_buffer 1 +typedef void *GLeglClientBufferEXT; +typedef void (GL_APIENTRYP PFNGLBUFFERSTORAGEEXTERNALEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +typedef void (GL_APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTERNALEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBufferStorageExternalEXT (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +GL_APICALL void GL_APIENTRY glNamedBufferStorageExternalEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +#endif +#endif /* GL_EXT_external_buffer */ + #ifndef GL_EXT_float_blend #define GL_EXT_float_blend 1 #endif /* GL_EXT_float_blend */ @@ -1433,6 +1501,85 @@ GL_APICALL void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr #endif #endif /* GL_EXT_map_buffer_range */ +#ifndef GL_EXT_memory_object +#define GL_EXT_memory_object 1 +#define GL_TEXTURE_TILING_EXT 0x9580 +#define GL_DEDICATED_MEMORY_OBJECT_EXT 0x9581 +#define GL_PROTECTED_MEMORY_OBJECT_EXT 0x959B +#define GL_NUM_TILING_TYPES_EXT 0x9582 +#define GL_TILING_TYPES_EXT 0x9583 +#define GL_OPTIMAL_TILING_EXT 0x9584 +#define GL_LINEAR_TILING_EXT 0x9585 +#define GL_NUM_DEVICE_UUIDS_EXT 0x9596 +#define GL_DEVICE_UUID_EXT 0x9597 +#define GL_DRIVER_UUID_EXT 0x9598 +#define GL_UUID_SIZE_EXT 16 +typedef void (GL_APIENTRYP PFNGLGETUNSIGNEDBYTEVEXTPROC) (GLenum pname, GLubyte *data); +typedef void (GL_APIENTRYP PFNGLGETUNSIGNEDBYTEI_VEXTPROC) (GLenum target, GLuint index, GLubyte *data); +typedef void (GL_APIENTRYP PFNGLDELETEMEMORYOBJECTSEXTPROC) (GLsizei n, const GLuint *memoryObjects); +typedef GLboolean (GL_APIENTRYP PFNGLISMEMORYOBJECTEXTPROC) (GLuint memoryObject); +typedef void (GL_APIENTRYP PFNGLCREATEMEMORYOBJECTSEXTPROC) (GLsizei n, GLuint *memoryObjects); +typedef void (GL_APIENTRYP PFNGLMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, const GLint *params); +typedef void (GL_APIENTRYP PFNGLGETMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGEMEM2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGEMEM2DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGEMEM3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGEMEM3DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLBUFFERSTORAGEMEMEXTPROC) (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGEMEM2DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGEMEM2DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGEMEM3DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGEMEM3DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLNAMEDBUFFERSTORAGEMEMEXTPROC) (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetUnsignedBytevEXT (GLenum pname, GLubyte *data); +GL_APICALL void GL_APIENTRY glGetUnsignedBytei_vEXT (GLenum target, GLuint index, GLubyte *data); +GL_APICALL void GL_APIENTRY glDeleteMemoryObjectsEXT (GLsizei n, const GLuint *memoryObjects); +GL_APICALL GLboolean GL_APIENTRY glIsMemoryObjectEXT (GLuint memoryObject); +GL_APICALL void GL_APIENTRY glCreateMemoryObjectsEXT (GLsizei n, GLuint *memoryObjects); +GL_APICALL void GL_APIENTRY glMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, const GLint *params); +GL_APICALL void GL_APIENTRY glGetMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glTexStorageMem2DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTexStorageMem2DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTexStorageMem3DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTexStorageMem3DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glBufferStorageMemEXT (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTextureStorageMem2DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTextureStorageMem2DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTextureStorageMem3DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTextureStorageMem3DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glNamedBufferStorageMemEXT (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); +#endif +#endif /* GL_EXT_memory_object */ + +#ifndef GL_EXT_memory_object_fd +#define GL_EXT_memory_object_fd 1 +#define GL_HANDLE_TYPE_OPAQUE_FD_EXT 0x9586 +typedef void (GL_APIENTRYP PFNGLIMPORTMEMORYFDEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glImportMemoryFdEXT (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); +#endif +#endif /* GL_EXT_memory_object_fd */ + +#ifndef GL_EXT_memory_object_win32 +#define GL_EXT_memory_object_win32 1 +#define GL_HANDLE_TYPE_OPAQUE_WIN32_EXT 0x9587 +#define GL_HANDLE_TYPE_OPAQUE_WIN32_KMT_EXT 0x9588 +#define GL_DEVICE_LUID_EXT 0x9599 +#define GL_DEVICE_NODE_MASK_EXT 0x959A +#define GL_LUID_SIZE_EXT 8 +#define GL_HANDLE_TYPE_D3D12_TILEPOOL_EXT 0x9589 +#define GL_HANDLE_TYPE_D3D12_RESOURCE_EXT 0x958A +#define GL_HANDLE_TYPE_D3D11_IMAGE_EXT 0x958B +#define GL_HANDLE_TYPE_D3D11_IMAGE_KMT_EXT 0x958C +typedef void (GL_APIENTRYP PFNGLIMPORTMEMORYWIN32HANDLEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, void *handle); +typedef void (GL_APIENTRYP PFNGLIMPORTMEMORYWIN32NAMEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, const void *name); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glImportMemoryWin32HandleEXT (GLuint memory, GLuint64 size, GLenum handleType, void *handle); +GL_APICALL void GL_APIENTRY glImportMemoryWin32NameEXT (GLuint memory, GLuint64 size, GLenum handleType, const void *name); +#endif +#endif /* GL_EXT_memory_object_win32 */ + #ifndef GL_EXT_multi_draw_arrays #define GL_EXT_multi_draw_arrays 1 typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); @@ -1598,6 +1745,55 @@ GL_APICALL void GL_APIENTRY glGetnUniformivEXT (GLuint program, GLint location, #define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 #endif /* GL_EXT_sRGB_write_control */ +#ifndef GL_EXT_semaphore +#define GL_EXT_semaphore 1 +#define GL_LAYOUT_GENERAL_EXT 0x958D +#define GL_LAYOUT_COLOR_ATTACHMENT_EXT 0x958E +#define GL_LAYOUT_DEPTH_STENCIL_ATTACHMENT_EXT 0x958F +#define GL_LAYOUT_DEPTH_STENCIL_READ_ONLY_EXT 0x9590 +#define GL_LAYOUT_SHADER_READ_ONLY_EXT 0x9591 +#define GL_LAYOUT_TRANSFER_SRC_EXT 0x9592 +#define GL_LAYOUT_TRANSFER_DST_EXT 0x9593 +#define GL_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_EXT 0x9530 +#define GL_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_EXT 0x9531 +typedef void (GL_APIENTRYP PFNGLGENSEMAPHORESEXTPROC) (GLsizei n, GLuint *semaphores); +typedef void (GL_APIENTRYP PFNGLDELETESEMAPHORESEXTPROC) (GLsizei n, const GLuint *semaphores); +typedef GLboolean (GL_APIENTRYP PFNGLISSEMAPHOREEXTPROC) (GLuint semaphore); +typedef void (GL_APIENTRYP PFNGLSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, const GLuint64 *params); +typedef void (GL_APIENTRYP PFNGLGETSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, GLuint64 *params); +typedef void (GL_APIENTRYP PFNGLWAITSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); +typedef void (GL_APIENTRYP PFNGLSIGNALSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGenSemaphoresEXT (GLsizei n, GLuint *semaphores); +GL_APICALL void GL_APIENTRY glDeleteSemaphoresEXT (GLsizei n, const GLuint *semaphores); +GL_APICALL GLboolean GL_APIENTRY glIsSemaphoreEXT (GLuint semaphore); +GL_APICALL void GL_APIENTRY glSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, const GLuint64 *params); +GL_APICALL void GL_APIENTRY glGetSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, GLuint64 *params); +GL_APICALL void GL_APIENTRY glWaitSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); +GL_APICALL void GL_APIENTRY glSignalSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); +#endif +#endif /* GL_EXT_semaphore */ + +#ifndef GL_EXT_semaphore_fd +#define GL_EXT_semaphore_fd 1 +typedef void (GL_APIENTRYP PFNGLIMPORTSEMAPHOREFDEXTPROC) (GLuint semaphore, GLenum handleType, GLint fd); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glImportSemaphoreFdEXT (GLuint semaphore, GLenum handleType, GLint fd); +#endif +#endif /* GL_EXT_semaphore_fd */ + +#ifndef GL_EXT_semaphore_win32 +#define GL_EXT_semaphore_win32 1 +#define GL_HANDLE_TYPE_D3D12_FENCE_EXT 0x9594 +#define GL_D3D12_FENCE_VALUE_EXT 0x9595 +typedef void (GL_APIENTRYP PFNGLIMPORTSEMAPHOREWIN32HANDLEEXTPROC) (GLuint semaphore, GLenum handleType, void *handle); +typedef void (GL_APIENTRYP PFNGLIMPORTSEMAPHOREWIN32NAMEEXTPROC) (GLuint semaphore, GLenum handleType, const void *name); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glImportSemaphoreWin32HandleEXT (GLuint semaphore, GLenum handleType, void *handle); +GL_APICALL void GL_APIENTRY glImportSemaphoreWin32NameEXT (GLuint semaphore, GLenum handleType, const void *name); +#endif +#endif /* GL_EXT_semaphore_win32 */ + #ifndef GL_EXT_separate_shader_objects #define GL_EXT_separate_shader_objects 1 #define GL_ACTIVE_PROGRAM_EXT 0x8259 @@ -1703,6 +1899,14 @@ GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLin #define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52 #endif /* GL_EXT_shader_framebuffer_fetch */ +#ifndef GL_EXT_shader_framebuffer_fetch_non_coherent +#define GL_EXT_shader_framebuffer_fetch_non_coherent 1 +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERFETCHBARRIEREXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferFetchBarrierEXT (void); +#endif +#endif /* GL_EXT_shader_framebuffer_fetch_non_coherent */ + #ifndef GL_EXT_shader_group_vote #define GL_EXT_shader_group_vote 1 #endif /* GL_EXT_shader_group_vote */ @@ -1890,18 +2094,42 @@ GL_APICALL void GL_APIENTRY glTexBufferRangeEXT (GLenum target, GLenum internalf #define GL_TEXTURE_ASTC_DECODE_PRECISION_EXT 0x8F69 #endif /* GL_EXT_texture_compression_astc_decode_mode */ +#ifndef GL_EXT_texture_compression_bptc +#define GL_EXT_texture_compression_bptc 1 +#define GL_COMPRESSED_RGBA_BPTC_UNORM_EXT 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT 0x8E8F +#endif /* GL_EXT_texture_compression_bptc */ + #ifndef GL_EXT_texture_compression_dxt1 #define GL_EXT_texture_compression_dxt1 1 #define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 #define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 #endif /* GL_EXT_texture_compression_dxt1 */ +#ifndef GL_EXT_texture_compression_rgtc +#define GL_EXT_texture_compression_rgtc 1 +#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC +#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE +#endif /* GL_EXT_texture_compression_rgtc */ + #ifndef GL_EXT_texture_compression_s3tc #define GL_EXT_texture_compression_s3tc 1 #define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 #define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 #endif /* GL_EXT_texture_compression_s3tc */ +#ifndef GL_EXT_texture_compression_s3tc_srgb +#define GL_EXT_texture_compression_s3tc_srgb 1 +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#endif /* GL_EXT_texture_compression_s3tc_srgb */ + #ifndef GL_EXT_texture_cube_map_array #define GL_EXT_texture_cube_map_array 1 #define GL_TEXTURE_CUBE_MAP_ARRAY_EXT 0x9009 @@ -1923,12 +2151,24 @@ GL_APICALL void GL_APIENTRY glTexBufferRangeEXT (GLenum target, GLenum internalf #ifndef GL_EXT_texture_filter_minmax #define GL_EXT_texture_filter_minmax 1 +#define GL_TEXTURE_REDUCTION_MODE_EXT 0x9366 +#define GL_WEIGHTED_AVERAGE_EXT 0x9367 #endif /* GL_EXT_texture_filter_minmax */ #ifndef GL_EXT_texture_format_BGRA8888 #define GL_EXT_texture_format_BGRA8888 1 #endif /* GL_EXT_texture_format_BGRA8888 */ +#ifndef GL_EXT_texture_format_sRGB_override +#define GL_EXT_texture_format_sRGB_override 1 +#define GL_TEXTURE_FORMAT_SRGB_OVERRIDE_EXT 0x8FBF +#endif /* GL_EXT_texture_format_sRGB_override */ + +#ifndef GL_EXT_texture_mirror_clamp_to_edge +#define GL_EXT_texture_mirror_clamp_to_edge 1 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#endif /* GL_EXT_texture_mirror_clamp_to_edge */ + #ifndef GL_EXT_texture_norm16 #define GL_EXT_texture_norm16 1 #define GL_R16_EXT 0x822A @@ -1938,6 +2178,10 @@ GL_APICALL void GL_APIENTRY glTexBufferRangeEXT (GLenum target, GLenum internalf #define GL_RGB16_SNORM_EXT 0x8F9A #endif /* GL_EXT_texture_norm16 */ +#ifndef GL_EXT_texture_query_lod +#define GL_EXT_texture_query_lod 1 +#endif /* GL_EXT_texture_query_lod */ + #ifndef GL_EXT_texture_rg #define GL_EXT_texture_rg 1 #define GL_RED_EXT 0x1903 @@ -2019,6 +2263,16 @@ GL_APICALL void GL_APIENTRY glTextureViewEXT (GLuint texture, GLenum target, GLu #define GL_UNPACK_SKIP_PIXELS_EXT 0x0CF4 #endif /* GL_EXT_unpack_subimage */ +#ifndef GL_EXT_win32_keyed_mutex +#define GL_EXT_win32_keyed_mutex 1 +typedef GLboolean (GL_APIENTRYP PFNGLACQUIREKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key, GLuint timeout); +typedef GLboolean (GL_APIENTRYP PFNGLRELEASEKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLboolean GL_APIENTRY glAcquireKeyedMutexWin32EXT (GLuint memory, GLuint64 key, GLuint timeout); +GL_APICALL GLboolean GL_APIENTRY glReleaseKeyedMutexWin32EXT (GLuint memory, GLuint64 key); +#endif +#endif /* GL_EXT_win32_keyed_mutex */ + #ifndef GL_EXT_window_rectangles #define GL_EXT_window_rectangles 1 #define GL_INCLUSIVE_EXT 0x8F10 @@ -2121,6 +2375,11 @@ GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum target, #define GL_CUBIC_MIPMAP_LINEAR_IMG 0x913B #endif /* GL_IMG_texture_filter_cubic */ +#ifndef GL_INTEL_blackhole_render +#define GL_INTEL_blackhole_render 1 +#define GL_BLACKHOLE_RENDER_INTEL 0x83FC +#endif /* GL_INTEL_blackhole_render */ + #ifndef GL_INTEL_conservative_rasterization #define GL_INTEL_conservative_rasterization 1 #define GL_CONSERVATIVE_RASTERIZATION_INTEL 0x83FE @@ -2163,7 +2422,7 @@ typedef void (GL_APIENTRYP PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle); typedef void (GL_APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint *queryId); typedef void (GL_APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint *nextQueryId); typedef void (GL_APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); -typedef void (GL_APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten); +typedef void (GL_APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); typedef void (GL_APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar *queryName, GLuint *queryId); typedef void (GL_APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); #ifdef GL_GLEXT_PROTOTYPES @@ -2174,12 +2433,22 @@ GL_APICALL void GL_APIENTRY glEndPerfQueryINTEL (GLuint queryHandle); GL_APICALL void GL_APIENTRY glGetFirstPerfQueryIdINTEL (GLuint *queryId); GL_APICALL void GL_APIENTRY glGetNextPerfQueryIdINTEL (GLuint queryId, GLuint *nextQueryId); GL_APICALL void GL_APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); -GL_APICALL void GL_APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten); +GL_APICALL void GL_APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); GL_APICALL void GL_APIENTRY glGetPerfQueryIdByNameINTEL (GLchar *queryName, GLuint *queryId); GL_APICALL void GL_APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); #endif #endif /* GL_INTEL_performance_query */ +#ifndef GL_MESA_framebuffer_flip_y +#define GL_MESA_framebuffer_flip_y 1 +#define GL_FRAMEBUFFER_FLIP_Y_MESA 0x8BBB +#endif /* GL_MESA_framebuffer_flip_y */ + +#ifndef GL_MESA_program_binary_formats +#define GL_MESA_program_binary_formats 1 +#define GL_PROGRAM_BINARY_FORMAT_MESA 0x875F +#endif /* GL_MESA_program_binary_formats */ + #ifndef GL_MESA_shader_integer_functions #define GL_MESA_shader_integer_functions 1 #endif /* GL_MESA_shader_integer_functions */ @@ -2284,6 +2553,27 @@ GL_APICALL void GL_APIENTRY glBlendBarrierNV (void); #define GL_BLEND_ADVANCED_COHERENT_NV 0x9285 #endif /* GL_NV_blend_equation_advanced_coherent */ +#ifndef GL_NV_blend_minmax_factor +#define GL_NV_blend_minmax_factor 1 +#define GL_FACTOR_MIN_AMD 0x901C +#define GL_FACTOR_MAX_AMD 0x901D +#endif /* GL_NV_blend_minmax_factor */ + +#ifndef GL_NV_clip_space_w_scaling +#define GL_NV_clip_space_w_scaling 1 +#define GL_VIEWPORT_POSITION_W_SCALE_NV 0x937C +#define GL_VIEWPORT_POSITION_W_SCALE_X_COEFF_NV 0x937D +#define GL_VIEWPORT_POSITION_W_SCALE_Y_COEFF_NV 0x937E +typedef void (GL_APIENTRYP PFNGLVIEWPORTPOSITIONWSCALENVPROC) (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glViewportPositionWScaleNV (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#endif +#endif /* GL_NV_clip_space_w_scaling */ + +#ifndef GL_NV_compute_shader_derivatives +#define GL_NV_compute_shader_derivatives 1 +#endif /* GL_NV_compute_shader_derivatives */ + #ifndef GL_NV_conditional_render #define GL_NV_conditional_render 1 #define GL_QUERY_WAIT_NV 0x8E13 @@ -2310,6 +2600,11 @@ GL_APICALL void GL_APIENTRY glSubpixelPrecisionBiasNV (GLuint xbits, GLuint ybit #endif #endif /* GL_NV_conservative_raster */ +#ifndef GL_NV_conservative_raster_pre_snap +#define GL_NV_conservative_raster_pre_snap 1 +#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_NV 0x9550 +#endif /* GL_NV_conservative_raster_pre_snap */ + #ifndef GL_NV_conservative_raster_pre_snap_triangles #define GL_NV_conservative_raster_pre_snap_triangles 1 #define GL_CONSERVATIVE_RASTER_MODE_NV 0x954D @@ -2655,6 +2950,34 @@ GL_APICALL void GL_APIENTRY glGetInternalformatSampleivNV (GLenum target, GLenum #endif #endif /* GL_NV_internalformat_sample_query */ +#ifndef GL_NV_memory_attachment +#define GL_NV_memory_attachment 1 +#define GL_ATTACHED_MEMORY_OBJECT_NV 0x95A4 +#define GL_ATTACHED_MEMORY_OFFSET_NV 0x95A5 +#define GL_MEMORY_ATTACHABLE_ALIGNMENT_NV 0x95A6 +#define GL_MEMORY_ATTACHABLE_SIZE_NV 0x95A7 +#define GL_MEMORY_ATTACHABLE_NV 0x95A8 +#define GL_DETACHED_MEMORY_INCARNATION_NV 0x95A9 +#define GL_DETACHED_TEXTURES_NV 0x95AA +#define GL_DETACHED_BUFFERS_NV 0x95AB +#define GL_MAX_DETACHED_TEXTURES_NV 0x95AC +#define GL_MAX_DETACHED_BUFFERS_NV 0x95AD +typedef void (GL_APIENTRYP PFNGLGETMEMORYOBJECTDETACHEDRESOURCESUIVNVPROC) (GLuint memory, GLenum pname, GLint first, GLsizei count, GLuint *params); +typedef void (GL_APIENTRYP PFNGLRESETMEMORYOBJECTPARAMETERNVPROC) (GLuint memory, GLenum pname); +typedef void (GL_APIENTRYP PFNGLTEXATTACHMEMORYNVPROC) (GLenum target, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLBUFFERATTACHMEMORYNVPROC) (GLenum target, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXTUREATTACHMEMORYNVPROC) (GLuint texture, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLNAMEDBUFFERATTACHMEMORYNVPROC) (GLuint buffer, GLuint memory, GLuint64 offset); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetMemoryObjectDetachedResourcesuivNV (GLuint memory, GLenum pname, GLint first, GLsizei count, GLuint *params); +GL_APICALL void GL_APIENTRY glResetMemoryObjectParameterNV (GLuint memory, GLenum pname); +GL_APICALL void GL_APIENTRY glTexAttachMemoryNV (GLenum target, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glBufferAttachMemoryNV (GLenum target, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTextureAttachMemoryNV (GLuint texture, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glNamedBufferAttachMemoryNV (GLuint buffer, GLuint memory, GLuint64 offset); +#endif +#endif /* GL_NV_memory_attachment */ + #ifndef GL_NV_non_square_matrices #define GL_NV_non_square_matrices 1 #define GL_FLOAT_MAT2x3_NV 0x8B65 @@ -2681,6 +3004,7 @@ GL_APICALL void GL_APIENTRY glUniformMatrix4x3fvNV (GLint location, GLsizei coun #ifndef GL_NV_path_rendering #define GL_NV_path_rendering 1 +typedef double GLdouble; #define GL_PATH_FORMAT_SVG_NV 0x9070 #define GL_PATH_FORMAT_PS_NV 0x9071 #define GL_STANDARD_FONT_NAME_NV 0x9072 @@ -2891,6 +3215,25 @@ typedef GLenum (GL_APIENTRYP PFNGLPATHGLYPHINDEXARRAYNVPROC) (GLuint firstPathNa typedef GLenum (GL_APIENTRYP PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); typedef void (GL_APIENTRYP PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC) (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); typedef void (GL_APIENTRYP PFNGLGETPROGRAMRESOURCEFVNVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (GL_APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (GL_APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (GL_APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (GL_APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (GL_APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (GL_APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +typedef void (GL_APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +typedef void (GL_APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (GL_APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (GL_APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (GL_APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL GLuint GL_APIENTRY glGenPathsNV (GLsizei range); GL_APICALL void GL_APIENTRY glDeletePathsNV (GLuint path, GLsizei range); @@ -2949,6 +3292,25 @@ GL_APICALL GLenum GL_APIENTRY glPathGlyphIndexArrayNV (GLuint firstPathName, GLe GL_APICALL GLenum GL_APIENTRY glPathMemoryGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); GL_APICALL void GL_APIENTRY glProgramPathFragmentInputGenNV (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); GL_APICALL void GL_APIENTRY glGetProgramResourcefvNV (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLfloat *params); +GL_APICALL void GL_APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GL_APICALL void GL_APIENTRY glMatrixLoadIdentityEXT (GLenum mode); +GL_APICALL void GL_APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); +GL_APICALL void GL_APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); +GL_APICALL void GL_APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); +GL_APICALL void GL_APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); +GL_APICALL void GL_APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GL_APICALL void GL_APIENTRY glMatrixPopEXT (GLenum mode); +GL_APICALL void GL_APIENTRY glMatrixPushEXT (GLenum mode); +GL_APICALL void GL_APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +GL_APICALL void GL_APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GL_APICALL void GL_APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); #endif #endif /* GL_NV_path_rendering */ @@ -2957,6 +3319,14 @@ GL_APICALL void GL_APIENTRY glGetProgramResourcefvNV (GLuint program, GLenum pro #define GL_SHARED_EDGE_NV 0xC0 #endif /* GL_NV_path_rendering_shared_edge */ +#ifndef GL_NV_pixel_buffer_object +#define GL_NV_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_NV 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_NV 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_NV 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_NV 0x88EF +#endif /* GL_NV_pixel_buffer_object */ + #ifndef GL_NV_polygon_mode #define GL_NV_polygon_mode 1 #define GL_POLYGON_MODE_NV 0x0B40 @@ -3034,6 +3404,18 @@ GL_APICALL void GL_APIENTRY glResolveDepthValuesNV (void); #define GL_NV_sample_mask_override_coverage 1 #endif /* GL_NV_sample_mask_override_coverage */ +#ifndef GL_NV_scissor_exclusive +#define GL_NV_scissor_exclusive 1 +#define GL_SCISSOR_TEST_EXCLUSIVE_NV 0x9555 +#define GL_SCISSOR_BOX_EXCLUSIVE_NV 0x9556 +typedef void (GL_APIENTRYP PFNGLSCISSOREXCLUSIVENVPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLSCISSOREXCLUSIVEARRAYVNVPROC) (GLuint first, GLsizei count, const GLint *v); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glScissorExclusiveNV (GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glScissorExclusiveArrayvNV (GLuint first, GLsizei count, const GLint *v); +#endif +#endif /* GL_NV_scissor_exclusive */ + #ifndef GL_NV_shader_atomic_fp16_vector #define GL_NV_shader_atomic_fp16_vector 1 #endif /* GL_NV_shader_atomic_fp16_vector */ @@ -3052,6 +3434,10 @@ GL_APICALL void GL_APIENTRY glResolveDepthValuesNV (void); #define GL_SAMPLER_CUBE_SHADOW_NV 0x8DC5 #endif /* GL_NV_shadow_samplers_cube */ +#ifndef GL_NV_stereo_view_rendering +#define GL_NV_stereo_view_rendering 1 +#endif /* GL_NV_stereo_view_rendering */ + #ifndef GL_NV_texture_border_clamp #define GL_NV_texture_border_clamp 1 #define GL_TEXTURE_BORDER_COLOR_NV 0x1004 @@ -3148,6 +3534,10 @@ GL_APICALL void GL_APIENTRY glFramebufferTextureMultisampleMultiviewOVR (GLenum #endif #endif /* GL_OVR_multiview_multisampled_render_to_texture */ +#ifndef GL_QCOM_YUV_texture_gather +#define GL_QCOM_YUV_texture_gather 1 +#endif /* GL_QCOM_YUV_texture_gather */ + #ifndef GL_QCOM_alpha_test #define GL_QCOM_alpha_test 1 #define GL_ALPHA_TEST_QCOM 0x0BC0 @@ -3245,6 +3635,38 @@ GL_APICALL void GL_APIENTRY glFramebufferFoveationParametersQCOM (GLuint framebu #define GL_PERFMON_GLOBAL_MODE_QCOM 0x8FA0 #endif /* GL_QCOM_perfmon_global_mode */ +#ifndef GL_QCOM_shader_framebuffer_fetch_noncoherent +#define GL_QCOM_shader_framebuffer_fetch_noncoherent 1 +#define GL_FRAMEBUFFER_FETCH_NONCOHERENT_QCOM 0x96A2 +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERFETCHBARRIERQCOMPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferFetchBarrierQCOM (void); +#endif +#endif /* GL_QCOM_shader_framebuffer_fetch_noncoherent */ + +#ifndef GL_QCOM_shader_framebuffer_fetch_rate +#define GL_QCOM_shader_framebuffer_fetch_rate 1 +#endif /* GL_QCOM_shader_framebuffer_fetch_rate */ + +#ifndef GL_QCOM_texture_foveated +#define GL_QCOM_texture_foveated 1 +#define GL_TEXTURE_FOVEATED_FEATURE_BITS_QCOM 0x8BFB +#define GL_TEXTURE_FOVEATED_MIN_PIXEL_DENSITY_QCOM 0x8BFC +#define GL_TEXTURE_FOVEATED_FEATURE_QUERY_QCOM 0x8BFD +#define GL_TEXTURE_FOVEATED_NUM_FOCAL_POINTS_QUERY_QCOM 0x8BFE +#define GL_FRAMEBUFFER_INCOMPLETE_FOVEATION_QCOM 0x8BFF +typedef void (GL_APIENTRYP PFNGLTEXTUREFOVEATIONPARAMETERSQCOMPROC) (GLuint texture, GLuint layer, GLuint focalPoint, GLfloat focalX, GLfloat focalY, GLfloat gainX, GLfloat gainY, GLfloat foveaArea); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTextureFoveationParametersQCOM (GLuint texture, GLuint layer, GLuint focalPoint, GLfloat focalX, GLfloat focalY, GLfloat gainX, GLfloat gainY, GLfloat foveaArea); +#endif +#endif /* GL_QCOM_texture_foveated */ + +#ifndef GL_QCOM_texture_foveated_subsampled_layout +#define GL_QCOM_texture_foveated_subsampled_layout 1 +#define GL_FOVEATION_SUBSAMPLED_LAYOUT_METHOD_BIT_QCOM 0x00000004 +#define GL_MAX_SHADER_SUBSAMPLED_IMAGE_UNITS_QCOM 0x8FA1 +#endif /* GL_QCOM_texture_foveated_subsampled_layout */ + #ifndef GL_QCOM_tiled_rendering #define GL_QCOM_tiled_rendering 1 #define GL_COLOR_BUFFER_BIT0_QCOM 0x00000001 From ef0a77d87230d7875522e517b3e6c99ce3b7113e Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 5 Mar 2019 10:22:03 +0100 Subject: [PATCH 065/292] Update qopenglext.h to the latest Khronos version Source: https://www.khronos.org/registry/OpenGL/api/GL/glext.h This change keeps the type definitions from the previous version, to avoid having to include KHR/khrplatform.h Change-Id: Idc1bee7b1e37b15a3dfd90a92381cd87392d22f7 Reviewed-by: Laszlo Agocs --- src/gui/opengl/qopenglext.h | 555 ++++++++++++++++++++++++++++++++++-- 1 file changed, 538 insertions(+), 17 deletions(-) diff --git a/src/gui/opengl/qopenglext.h b/src/gui/opengl/qopenglext.h index 63873476e4..e3f9205619 100644 --- a/src/gui/opengl/qopenglext.h +++ b/src/gui/opengl/qopenglext.h @@ -12,7 +12,7 @@ extern "C" { #endif /* -** Copyright (c) 2013-2017 The Khronos Group Inc. +** Copyright (c) 2013-2018 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the @@ -57,7 +57,7 @@ extern "C" { #define GLAPI extern #endif -#define GL_GLEXT_VERSION 20170325 +#define GL_GLEXT_VERSION 20190228 /* Generated C header for: * API: gl @@ -359,15 +359,17 @@ GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); #define GL_TEXTURE_FILTER_CONTROL 0x8500 #define GL_DEPTH_TEXTURE_MODE 0x884B #define GL_COMPARE_R_TO_TEXTURE 0x884E -#define GL_FUNC_ADD 0x8006 -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#define GL_MIN 0x8007 -#define GL_MAX 0x8008 +#define GL_BLEND_COLOR 0x8005 +#define GL_BLEND_EQUATION 0x8009 #define GL_CONSTANT_COLOR 0x8001 #define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 #define GL_CONSTANT_ALPHA 0x8003 #define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_FUNC_ADD 0x8006 +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_FUNC_SUBTRACT 0x800A +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); @@ -2872,6 +2874,42 @@ GLAPI void APIENTRY glTextureBarrier (void); #endif #endif /* GL_VERSION_4_5 */ +#ifndef GL_VERSION_4_6 +#define GL_VERSION_4_6 1 +#define GL_SHADER_BINARY_FORMAT_SPIR_V 0x9551 +#define GL_SPIR_V_BINARY 0x9552 +#define GL_PARAMETER_BUFFER 0x80EE +#define GL_PARAMETER_BUFFER_BINDING 0x80EF +#define GL_CONTEXT_FLAG_NO_ERROR_BIT 0x00000008 +#define GL_VERTICES_SUBMITTED 0x82EE +#define GL_PRIMITIVES_SUBMITTED 0x82EF +#define GL_VERTEX_SHADER_INVOCATIONS 0x82F0 +#define GL_TESS_CONTROL_SHADER_PATCHES 0x82F1 +#define GL_TESS_EVALUATION_SHADER_INVOCATIONS 0x82F2 +#define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED 0x82F3 +#define GL_FRAGMENT_SHADER_INVOCATIONS 0x82F4 +#define GL_COMPUTE_SHADER_INVOCATIONS 0x82F5 +#define GL_CLIPPING_INPUT_PRIMITIVES 0x82F6 +#define GL_CLIPPING_OUTPUT_PRIMITIVES 0x82F7 +#define GL_POLYGON_OFFSET_CLAMP 0x8E1B +#define GL_SPIR_V_EXTENSIONS 0x9553 +#define GL_NUM_SPIR_V_EXTENSIONS 0x9554 +#define GL_TEXTURE_MAX_ANISOTROPY 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY 0x84FF +#define GL_TRANSFORM_FEEDBACK_OVERFLOW 0x82EC +#define GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW 0x82ED +typedef void (APIENTRYP PFNGLSPECIALIZESHADERPROC) (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTPROC) (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLPOLYGONOFFSETCLAMPPROC) (GLfloat factor, GLfloat units, GLfloat clamp); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpecializeShader (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +GLAPI void APIENTRY glMultiDrawArraysIndirectCount (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectCount (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glPolygonOffsetClamp (GLfloat factor, GLfloat units, GLfloat clamp); +#endif +#endif /* GL_VERSION_4_6 */ + #ifndef GL_ARB_ES2_compatibility #define GL_ARB_ES2_compatibility 1 #endif /* GL_ARB_ES2_compatibility */ @@ -3475,8 +3513,6 @@ typedef unsigned short GLhalfARB; #ifndef GL_ARB_imaging #define GL_ARB_imaging 1 -#define GL_BLEND_COLOR 0x8005 -#define GL_BLEND_EQUATION 0x8009 #define GL_CONVOLUTION_1D 0x8010 #define GL_CONVOLUTION_2D 0x8011 #define GL_SEPARABLE_2D 0x8012 @@ -3613,11 +3649,11 @@ GLAPI void APIENTRY glResetMinmax (GLenum target); #define GL_ARB_indirect_parameters 1 #define GL_PARAMETER_BUFFER_ARB 0x80EE #define GL_PARAMETER_BUFFER_BINDING_ARB 0x80EF -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC) (GLenum mode, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC) (GLenum mode, GLenum type, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC) (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysIndirectCountARB (GLenum mode, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); -GLAPI void APIENTRY glMultiDrawElementsIndirectCountARB (GLenum mode, GLenum type, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawArraysIndirectCountARB (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectCountARB (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); #endif #endif /* GL_ARB_indirect_parameters */ @@ -3637,6 +3673,25 @@ GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor); #ifndef GL_ARB_internalformat_query2 #define GL_ARB_internalformat_query2 1 #define GL_SRGB_DECODE_ARB 0x8299 +#define GL_VIEW_CLASS_EAC_R11 0x9383 +#define GL_VIEW_CLASS_EAC_RG11 0x9384 +#define GL_VIEW_CLASS_ETC2_RGB 0x9385 +#define GL_VIEW_CLASS_ETC2_RGBA 0x9386 +#define GL_VIEW_CLASS_ETC2_EAC_RGBA 0x9387 +#define GL_VIEW_CLASS_ASTC_4x4_RGBA 0x9388 +#define GL_VIEW_CLASS_ASTC_5x4_RGBA 0x9389 +#define GL_VIEW_CLASS_ASTC_5x5_RGBA 0x938A +#define GL_VIEW_CLASS_ASTC_6x5_RGBA 0x938B +#define GL_VIEW_CLASS_ASTC_6x6_RGBA 0x938C +#define GL_VIEW_CLASS_ASTC_8x5_RGBA 0x938D +#define GL_VIEW_CLASS_ASTC_8x6_RGBA 0x938E +#define GL_VIEW_CLASS_ASTC_8x8_RGBA 0x938F +#define GL_VIEW_CLASS_ASTC_10x5_RGBA 0x9390 +#define GL_VIEW_CLASS_ASTC_10x6_RGBA 0x9391 +#define GL_VIEW_CLASS_ASTC_10x8_RGBA 0x9392 +#define GL_VIEW_CLASS_ASTC_10x10_RGBA 0x9393 +#define GL_VIEW_CLASS_ASTC_12x10_RGBA 0x9394 +#define GL_VIEW_CLASS_ASTC_12x12_RGBA 0x9395 #endif /* GL_ARB_internalformat_query2 */ #ifndef GL_ARB_invalidate_subdata @@ -3894,6 +3949,10 @@ GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params); #define GL_COORD_REPLACE_ARB 0x8862 #endif /* GL_ARB_point_sprite */ +#ifndef GL_ARB_polygon_offset_clamp +#define GL_ARB_polygon_offset_clamp 1 +#endif /* GL_ARB_polygon_offset_clamp */ + #ifndef GL_ARB_post_depth_coverage #define GL_ARB_post_depth_coverage 1 #endif /* GL_ARB_post_depth_coverage */ @@ -4292,6 +4351,10 @@ GLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xo #define GL_ARB_sparse_texture_clamp 1 #endif /* GL_ARB_sparse_texture_clamp */ +#ifndef GL_ARB_spirv_extensions +#define GL_ARB_spirv_extensions 1 +#endif /* GL_ARB_spirv_extensions */ + #ifndef GL_ARB_stencil_texturing #define GL_ARB_stencil_texturing 1 #endif /* GL_ARB_stencil_texturing */ @@ -4444,6 +4507,10 @@ GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, void #define GL_DOT3_RGBA_ARB 0x86AF #endif /* GL_ARB_texture_env_dot3 */ +#ifndef GL_ARB_texture_filter_anisotropic +#define GL_ARB_texture_filter_anisotropic 1 +#endif /* GL_ARB_texture_filter_anisotropic */ + #ifndef GL_ARB_texture_filter_minmax #define GL_ARB_texture_filter_minmax 1 #define GL_TEXTURE_REDUCTION_MODE_ARB 0x9366 @@ -4949,6 +5016,16 @@ GLAPI void APIENTRY glBlendBarrierKHR (void); #define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 #endif /* GL_KHR_no_error */ +#ifndef GL_KHR_parallel_shader_compile +#define GL_KHR_parallel_shader_compile 1 +#define GL_MAX_SHADER_COMPILER_THREADS_KHR 0x91B0 +#define GL_COMPLETION_STATUS_KHR 0x91B1 +typedef void (APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSKHRPROC) (GLuint count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMaxShaderCompilerThreadsKHR (GLuint count); +#endif +#endif /* GL_KHR_parallel_shader_compile */ + #ifndef GL_KHR_robust_buffer_access_behavior #define GL_KHR_robust_buffer_access_behavior 1 #endif /* GL_KHR_robust_buffer_access_behavior */ @@ -5389,6 +5466,22 @@ GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRG #endif #endif /* GL_AMD_draw_buffers_blend */ +#ifndef GL_AMD_framebuffer_multisample_advanced +#define GL_AMD_framebuffer_multisample_advanced 1 +#define GL_RENDERBUFFER_STORAGE_SAMPLES_AMD 0x91B2 +#define GL_MAX_COLOR_FRAMEBUFFER_SAMPLES_AMD 0x91B3 +#define GL_MAX_COLOR_FRAMEBUFFER_STORAGE_SAMPLES_AMD 0x91B4 +#define GL_MAX_DEPTH_STENCIL_FRAMEBUFFER_SAMPLES_AMD 0x91B5 +#define GL_NUM_SUPPORTED_MULTISAMPLE_MODES_AMD 0x91B6 +#define GL_SUPPORTED_MULTISAMPLE_MODES_AMD 0x91B7 +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEADVANCEDAMDPROC) (GLenum target, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEADVANCEDAMDPROC) (GLuint renderbuffer, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleAdvancedAMD (GLenum target, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleAdvancedAMD (GLuint renderbuffer, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_AMD_framebuffer_multisample_advanced */ + #ifndef GL_AMD_framebuffer_sample_positions #define GL_AMD_framebuffer_sample_positions 1 #define GL_SUBSAMPLE_DISTANCE_AMD 0x883F @@ -5428,6 +5521,10 @@ GLAPI void APIENTRY glGetNamedFramebufferParameterfvAMD (GLuint framebuffer, GLe #define GL_FLOAT16_MAT4x3_AMD 0x91CD #endif /* GL_AMD_gpu_shader_half_float */ +#ifndef GL_AMD_gpu_shader_int16 +#define GL_AMD_gpu_shader_int16 1 +#endif /* GL_AMD_gpu_shader_int16 */ + #ifndef GL_AMD_gpu_shader_int64 #define GL_AMD_gpu_shader_int64 1 typedef int64_t GLint64EXT; @@ -5649,6 +5746,14 @@ GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLf #define GL_AMD_shader_explicit_vertex_parameter 1 #endif /* GL_AMD_shader_explicit_vertex_parameter */ +#ifndef GL_AMD_shader_gpu_shader_half_float_fetch +#define GL_AMD_shader_gpu_shader_half_float_fetch 1 +#endif /* GL_AMD_shader_gpu_shader_half_float_fetch */ + +#ifndef GL_AMD_shader_image_load_store_lod +#define GL_AMD_shader_image_load_store_lod 1 +#endif /* GL_AMD_shader_image_load_store_lod */ + #ifndef GL_AMD_shader_stencil_export #define GL_AMD_shader_stencil_export 1 #endif /* GL_AMD_shader_stencil_export */ @@ -5688,6 +5793,10 @@ GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); #endif #endif /* GL_AMD_stencil_operation_extended */ +#ifndef GL_AMD_texture_gather_bias_lod +#define GL_AMD_texture_gather_bias_lod 1 +#endif /* GL_AMD_texture_gather_bias_lod */ + #ifndef GL_AMD_texture_texture4 #define GL_AMD_texture_texture4 1 #endif /* GL_AMD_texture_texture4 */ @@ -6388,6 +6497,17 @@ GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param); #define GL_422_REV_AVERAGE_EXT 0x80CF #endif /* GL_EXT_422_pixels */ +#ifndef GL_EXT_EGL_image_storage +#define GL_EXT_EGL_image_storage 1 +typedef void *GLeglImageOES; +typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXSTORAGEEXTPROC) (GLenum target, GLeglImageOES image, const GLint* attrib_list); +typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXTURESTORAGEEXTPROC) (GLuint texture, GLeglImageOES image, const GLint* attrib_list); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glEGLImageTargetTexStorageEXT (GLenum target, GLeglImageOES image, const GLint* attrib_list); +GLAPI void APIENTRY glEGLImageTargetTextureStorageEXT (GLuint texture, GLeglImageOES image, const GLint* attrib_list); +#endif +#endif /* GL_EXT_EGL_image_storage */ + #ifndef GL_EXT_abgr #define GL_EXT_abgr 1 #define GL_ABGR_EXT 0x8000 @@ -7239,6 +7359,17 @@ GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint en #endif #endif /* GL_EXT_draw_range_elements */ +#ifndef GL_EXT_external_buffer +#define GL_EXT_external_buffer 1 +typedef void *GLeglClientBufferEXT; +typedef void (APIENTRYP PFNGLBUFFERSTORAGEEXTERNALEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTERNALEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferStorageExternalEXT (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +GLAPI void APIENTRY glNamedBufferStorageExternalEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +#endif +#endif /* GL_EXT_external_buffer */ + #ifndef GL_EXT_fog_coord #define GL_EXT_fog_coord 1 #define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 @@ -7582,6 +7713,89 @@ GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode); #endif #endif /* GL_EXT_light_texture */ +#ifndef GL_EXT_memory_object +#define GL_EXT_memory_object 1 +#define GL_TEXTURE_TILING_EXT 0x9580 +#define GL_DEDICATED_MEMORY_OBJECT_EXT 0x9581 +#define GL_PROTECTED_MEMORY_OBJECT_EXT 0x959B +#define GL_NUM_TILING_TYPES_EXT 0x9582 +#define GL_TILING_TYPES_EXT 0x9583 +#define GL_OPTIMAL_TILING_EXT 0x9584 +#define GL_LINEAR_TILING_EXT 0x9585 +#define GL_NUM_DEVICE_UUIDS_EXT 0x9596 +#define GL_DEVICE_UUID_EXT 0x9597 +#define GL_DRIVER_UUID_EXT 0x9598 +#define GL_UUID_SIZE_EXT 16 +typedef void (APIENTRYP PFNGLGETUNSIGNEDBYTEVEXTPROC) (GLenum pname, GLubyte *data); +typedef void (APIENTRYP PFNGLGETUNSIGNEDBYTEI_VEXTPROC) (GLenum target, GLuint index, GLubyte *data); +typedef void (APIENTRYP PFNGLDELETEMEMORYOBJECTSEXTPROC) (GLsizei n, const GLuint *memoryObjects); +typedef GLboolean (APIENTRYP PFNGLISMEMORYOBJECTEXTPROC) (GLuint memoryObject); +typedef void (APIENTRYP PFNGLCREATEMEMORYOBJECTSEXTPROC) (GLsizei n, GLuint *memoryObjects); +typedef void (APIENTRYP PFNGLMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM2DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM3DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLBUFFERSTORAGEMEMEXTPROC) (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM2DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM2DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM3DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM3DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEMEMEXTPROC) (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM1DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUnsignedBytevEXT (GLenum pname, GLubyte *data); +GLAPI void APIENTRY glGetUnsignedBytei_vEXT (GLenum target, GLuint index, GLubyte *data); +GLAPI void APIENTRY glDeleteMemoryObjectsEXT (GLsizei n, const GLuint *memoryObjects); +GLAPI GLboolean APIENTRY glIsMemoryObjectEXT (GLuint memoryObject); +GLAPI void APIENTRY glCreateMemoryObjectsEXT (GLsizei n, GLuint *memoryObjects); +GLAPI void APIENTRY glMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, GLint *params); +GLAPI void APIENTRY glTexStorageMem2DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem2DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem3DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem3DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glBufferStorageMemEXT (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem2DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem2DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem3DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem3DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glNamedBufferStorageMemEXT (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem1DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem1DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +#endif +#endif /* GL_EXT_memory_object */ + +#ifndef GL_EXT_memory_object_fd +#define GL_EXT_memory_object_fd 1 +#define GL_HANDLE_TYPE_OPAQUE_FD_EXT 0x9586 +typedef void (APIENTRYP PFNGLIMPORTMEMORYFDEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportMemoryFdEXT (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); +#endif +#endif /* GL_EXT_memory_object_fd */ + +#ifndef GL_EXT_memory_object_win32 +#define GL_EXT_memory_object_win32 1 +#define GL_HANDLE_TYPE_OPAQUE_WIN32_EXT 0x9587 +#define GL_HANDLE_TYPE_OPAQUE_WIN32_KMT_EXT 0x9588 +#define GL_DEVICE_LUID_EXT 0x9599 +#define GL_DEVICE_NODE_MASK_EXT 0x959A +#define GL_LUID_SIZE_EXT 8 +#define GL_HANDLE_TYPE_D3D12_TILEPOOL_EXT 0x9589 +#define GL_HANDLE_TYPE_D3D12_RESOURCE_EXT 0x958A +#define GL_HANDLE_TYPE_D3D11_IMAGE_EXT 0x958B +#define GL_HANDLE_TYPE_D3D11_IMAGE_KMT_EXT 0x958C +typedef void (APIENTRYP PFNGLIMPORTMEMORYWIN32HANDLEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, void *handle); +typedef void (APIENTRYP PFNGLIMPORTMEMORYWIN32NAMEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, const void *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportMemoryWin32HandleEXT (GLuint memory, GLuint64 size, GLenum handleType, void *handle); +GLAPI void APIENTRY glImportMemoryWin32NameEXT (GLuint memory, GLuint64 size, GLenum handleType, const void *name); +#endif +#endif /* GL_EXT_memory_object_win32 */ + #ifndef GL_EXT_misc_attribute #define GL_EXT_misc_attribute 1 #endif /* GL_EXT_misc_attribute */ @@ -7823,6 +8037,55 @@ GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei #endif #endif /* GL_EXT_secondary_color */ +#ifndef GL_EXT_semaphore +#define GL_EXT_semaphore 1 +#define GL_LAYOUT_GENERAL_EXT 0x958D +#define GL_LAYOUT_COLOR_ATTACHMENT_EXT 0x958E +#define GL_LAYOUT_DEPTH_STENCIL_ATTACHMENT_EXT 0x958F +#define GL_LAYOUT_DEPTH_STENCIL_READ_ONLY_EXT 0x9590 +#define GL_LAYOUT_SHADER_READ_ONLY_EXT 0x9591 +#define GL_LAYOUT_TRANSFER_SRC_EXT 0x9592 +#define GL_LAYOUT_TRANSFER_DST_EXT 0x9593 +#define GL_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_EXT 0x9530 +#define GL_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_EXT 0x9531 +typedef void (APIENTRYP PFNGLGENSEMAPHORESEXTPROC) (GLsizei n, GLuint *semaphores); +typedef void (APIENTRYP PFNGLDELETESEMAPHORESEXTPROC) (GLsizei n, const GLuint *semaphores); +typedef GLboolean (APIENTRYP PFNGLISSEMAPHOREEXTPROC) (GLuint semaphore); +typedef void (APIENTRYP PFNGLSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, const GLuint64 *params); +typedef void (APIENTRYP PFNGLGETSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, GLuint64 *params); +typedef void (APIENTRYP PFNGLWAITSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); +typedef void (APIENTRYP PFNGLSIGNALSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenSemaphoresEXT (GLsizei n, GLuint *semaphores); +GLAPI void APIENTRY glDeleteSemaphoresEXT (GLsizei n, const GLuint *semaphores); +GLAPI GLboolean APIENTRY glIsSemaphoreEXT (GLuint semaphore); +GLAPI void APIENTRY glSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, const GLuint64 *params); +GLAPI void APIENTRY glGetSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, GLuint64 *params); +GLAPI void APIENTRY glWaitSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); +GLAPI void APIENTRY glSignalSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); +#endif +#endif /* GL_EXT_semaphore */ + +#ifndef GL_EXT_semaphore_fd +#define GL_EXT_semaphore_fd 1 +typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREFDEXTPROC) (GLuint semaphore, GLenum handleType, GLint fd); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportSemaphoreFdEXT (GLuint semaphore, GLenum handleType, GLint fd); +#endif +#endif /* GL_EXT_semaphore_fd */ + +#ifndef GL_EXT_semaphore_win32 +#define GL_EXT_semaphore_win32 1 +#define GL_HANDLE_TYPE_D3D12_FENCE_EXT 0x9594 +#define GL_D3D12_FENCE_VALUE_EXT 0x9595 +typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREWIN32HANDLEEXTPROC) (GLuint semaphore, GLenum handleType, void *handle); +typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREWIN32NAMEEXTPROC) (GLuint semaphore, GLenum handleType, const void *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportSemaphoreWin32HandleEXT (GLuint semaphore, GLenum handleType, void *handle); +GLAPI void APIENTRY glImportSemaphoreWin32NameEXT (GLuint semaphore, GLenum handleType, const void *name); +#endif +#endif /* GL_EXT_semaphore_win32 */ + #ifndef GL_EXT_separate_shader_objects #define GL_EXT_separate_shader_objects 1 #define GL_ACTIVE_PROGRAM_EXT 0x8B8D @@ -7843,6 +8106,19 @@ GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *strin #define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA #endif /* GL_EXT_separate_specular_color */ +#ifndef GL_EXT_shader_framebuffer_fetch +#define GL_EXT_shader_framebuffer_fetch 1 +#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52 +#endif /* GL_EXT_shader_framebuffer_fetch */ + +#ifndef GL_EXT_shader_framebuffer_fetch_non_coherent +#define GL_EXT_shader_framebuffer_fetch_non_coherent 1 +typedef void (APIENTRYP PFNGLFRAMEBUFFERFETCHBARRIEREXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferFetchBarrierEXT (void); +#endif +#endif /* GL_EXT_shader_framebuffer_fetch_non_coherent */ + #ifndef GL_EXT_shader_image_load_formatted #define GL_EXT_shader_image_load_formatted 1 #endif /* GL_EXT_shader_image_load_formatted */ @@ -8143,6 +8419,8 @@ GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint #ifndef GL_EXT_texture_filter_minmax #define GL_EXT_texture_filter_minmax 1 +#define GL_TEXTURE_REDUCTION_MODE_EXT 0x9366 +#define GL_WEIGHTED_AVERAGE_EXT 0x9367 #endif /* GL_EXT_texture_filter_minmax */ #ifndef GL_EXT_texture_integer @@ -8277,6 +8555,11 @@ GLAPI void APIENTRY glTextureNormalEXT (GLenum mode); #define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F #endif /* GL_EXT_texture_sRGB */ +#ifndef GL_EXT_texture_sRGB_R8 +#define GL_EXT_texture_sRGB_R8 1 +#define GL_SR8_EXT 0x8FBD +#endif /* GL_EXT_texture_sRGB_R8 */ + #ifndef GL_EXT_texture_sRGB_decode #define GL_EXT_texture_sRGB_decode 1 #define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 @@ -8689,6 +8972,16 @@ GLAPI void APIENTRY glVertexWeightPointerEXT (GLint size, GLenum type, GLsizei s #endif #endif /* GL_EXT_vertex_weighting */ +#ifndef GL_EXT_win32_keyed_mutex +#define GL_EXT_win32_keyed_mutex 1 +typedef GLboolean (APIENTRYP PFNGLACQUIREKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key, GLuint timeout); +typedef GLboolean (APIENTRYP PFNGLRELEASEKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAcquireKeyedMutexWin32EXT (GLuint memory, GLuint64 key, GLuint timeout); +GLAPI GLboolean APIENTRY glReleaseKeyedMutexWin32EXT (GLuint memory, GLuint64 key); +#endif +#endif /* GL_EXT_win32_keyed_mutex */ + #ifndef GL_EXT_window_rectangles #define GL_EXT_window_rectangles 1 #define GL_INCLUSIVE_EXT 0x8F10 @@ -8880,6 +9173,11 @@ GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRG #define GL_INTERLACE_READ_INGR 0x8568 #endif /* GL_INGR_interlace_read */ +#ifndef GL_INTEL_blackhole_render +#define GL_INTEL_blackhole_render 1 +#define GL_BLACKHOLE_RENDER_INTEL 0x83FC +#endif /* GL_INTEL_blackhole_render */ + #ifndef GL_INTEL_conservative_rasterization #define GL_INTEL_conservative_rasterization 1 #define GL_CONSERVATIVE_RASTERIZATION_INTEL 0x83FE @@ -8961,7 +9259,7 @@ typedef void (APIENTRYP PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle); typedef void (APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint *queryId); typedef void (APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint *nextQueryId); typedef void (APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); -typedef void (APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten); +typedef void (APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); typedef void (APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar *queryName, GLuint *queryId); typedef void (APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); #ifdef GL_GLEXT_PROTOTYPES @@ -8972,7 +9270,7 @@ GLAPI void APIENTRY glEndPerfQueryINTEL (GLuint queryHandle); GLAPI void APIENTRY glGetFirstPerfQueryIdINTEL (GLuint *queryId); GLAPI void APIENTRY glGetNextPerfQueryIdINTEL (GLuint queryId, GLuint *nextQueryId); GLAPI void APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); -GLAPI void APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten); +GLAPI void APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); GLAPI void APIENTRY glGetPerfQueryIdByNameINTEL (GLchar *queryName, GLuint *queryId); GLAPI void APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); #endif @@ -8993,6 +9291,11 @@ GLAPI void APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLen #define GL_PACK_INVERT_MESA 0x8758 #endif /* GL_MESA_pack_invert */ +#ifndef GL_MESA_program_binary_formats +#define GL_MESA_program_binary_formats 1 +#define GL_PROGRAM_BINARY_FORMAT_MESA 0x875F +#endif /* GL_MESA_program_binary_formats */ + #ifndef GL_MESA_resize_buffers #define GL_MESA_resize_buffers 1 typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); @@ -9005,6 +9308,13 @@ GLAPI void APIENTRY glResizeBuffersMESA (void); #define GL_MESA_shader_integer_functions 1 #endif /* GL_MESA_shader_integer_functions */ +#ifndef GL_MESA_tile_raster_order +#define GL_MESA_tile_raster_order 1 +#define GL_TILE_RASTER_ORDER_FIXED_MESA 0x8BB8 +#define GL_TILE_RASTER_ORDER_INCREASING_X_MESA 0x8BB9 +#define GL_TILE_RASTER_ORDER_INCREASING_Y_MESA 0x8BBA +#endif /* GL_MESA_tile_raster_order */ + #ifndef GL_MESA_window_pos #define GL_MESA_window_pos 1 typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); @@ -9231,6 +9541,10 @@ GLAPI void APIENTRY glBlendBarrierNV (void); #define GL_BLEND_ADVANCED_COHERENT_NV 0x9285 #endif /* GL_NV_blend_equation_advanced_coherent */ +#ifndef GL_NV_blend_minmax_factor +#define GL_NV_blend_minmax_factor 1 +#endif /* GL_NV_blend_minmax_factor */ + #ifndef GL_NV_blend_square #define GL_NV_blend_square 1 #endif /* GL_NV_blend_square */ @@ -9311,6 +9625,10 @@ GLAPI void APIENTRY glCallCommandListNV (GLuint list); #define GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV 0x90FC #endif /* GL_NV_compute_program5 */ +#ifndef GL_NV_compute_shader_derivatives +#define GL_NV_compute_shader_derivatives 1 +#endif /* GL_NV_compute_shader_derivatives */ + #ifndef GL_NV_conditional_render #define GL_NV_conditional_render 1 #define GL_QUERY_WAIT_NV 0x8E13 @@ -9348,6 +9666,11 @@ GLAPI void APIENTRY glConservativeRasterParameterfNV (GLenum pname, GLfloat valu #endif #endif /* GL_NV_conservative_raster_dilate */ +#ifndef GL_NV_conservative_raster_pre_snap +#define GL_NV_conservative_raster_pre_snap 1 +#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_NV 0x9550 +#endif /* GL_NV_conservative_raster_pre_snap */ + #ifndef GL_NV_conservative_raster_pre_snap_triangles #define GL_NV_conservative_raster_pre_snap_triangles 1 #define GL_CONSERVATIVE_RASTER_MODE_NV 0x954D @@ -9359,6 +9682,10 @@ GLAPI void APIENTRY glConservativeRasterParameteriNV (GLenum pname, GLint param) #endif #endif /* GL_NV_conservative_raster_pre_snap_triangles */ +#ifndef GL_NV_conservative_raster_underestimation +#define GL_NV_conservative_raster_underestimation 1 +#endif /* GL_NV_conservative_raster_underestimation */ + #ifndef GL_NV_copy_depth_to_color #define GL_NV_copy_depth_to_color 1 #define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E @@ -9600,6 +9927,10 @@ GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, cons #define GL_NV_fragment_program_option 1 #endif /* GL_NV_fragment_program_option */ +#ifndef GL_NV_fragment_shader_barycentric +#define GL_NV_fragment_shader_barycentric 1 +#endif /* GL_NV_fragment_shader_barycentric */ + #ifndef GL_NV_fragment_shader_interlock #define GL_NV_fragment_shader_interlock 1 #endif /* GL_NV_fragment_shader_interlock */ @@ -9667,7 +9998,7 @@ GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachmen #define GL_PER_GPU_STORAGE_NV 0x9548 #define GL_MULTICAST_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9549 typedef void (APIENTRYP PFNGLRENDERGPUMASKNVPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLMULTICASTBUFFERSUBDATANVPROC) (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef void (APIENTRYP PFNGLMULTICASTBUFFERSUBDATANVPROC) (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); typedef void (APIENTRYP PFNGLMULTICASTCOPYBUFFERSUBDATANVPROC) (GLuint readGpu, GLbitfield writeGpuMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); typedef void (APIENTRYP PFNGLMULTICASTCOPYIMAGESUBDATANVPROC) (GLuint srcGpu, GLbitfield dstGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); typedef void (APIENTRYP PFNGLMULTICASTBLITFRAMEBUFFERNVPROC) (GLuint srcGpu, GLuint dstGpu, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); @@ -9680,7 +10011,7 @@ typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTI64VNVPROC) (GLuint gpu, GLu typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTUI64VNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLuint64 *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glRenderGpuMaskNV (GLbitfield mask); -GLAPI void APIENTRY glMulticastBufferSubDataNV (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); +GLAPI void APIENTRY glMulticastBufferSubDataNV (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); GLAPI void APIENTRY glMulticastCopyBufferSubDataNV (GLuint readGpu, GLbitfield writeGpuMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); GLAPI void APIENTRY glMulticastCopyImageSubDataNV (GLuint srcGpu, GLbitfield dstGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); GLAPI void APIENTRY glMulticastBlitFramebufferNV (GLuint srcGpu, GLuint dstGpu, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); @@ -9884,6 +10215,96 @@ GLAPI void APIENTRY glGetInternalformatSampleivNV (GLenum target, GLenum interna #define GL_MAX_SPOT_EXPONENT_NV 0x8505 #endif /* GL_NV_light_max_exponent */ +#ifndef GL_NV_memory_attachment +#define GL_NV_memory_attachment 1 +#define GL_ATTACHED_MEMORY_OBJECT_NV 0x95A4 +#define GL_ATTACHED_MEMORY_OFFSET_NV 0x95A5 +#define GL_MEMORY_ATTACHABLE_ALIGNMENT_NV 0x95A6 +#define GL_MEMORY_ATTACHABLE_SIZE_NV 0x95A7 +#define GL_MEMORY_ATTACHABLE_NV 0x95A8 +#define GL_DETACHED_MEMORY_INCARNATION_NV 0x95A9 +#define GL_DETACHED_TEXTURES_NV 0x95AA +#define GL_DETACHED_BUFFERS_NV 0x95AB +#define GL_MAX_DETACHED_TEXTURES_NV 0x95AC +#define GL_MAX_DETACHED_BUFFERS_NV 0x95AD +typedef void (APIENTRYP PFNGLGETMEMORYOBJECTDETACHEDRESOURCESUIVNVPROC) (GLuint memory, GLenum pname, GLint first, GLsizei count, GLuint *params); +typedef void (APIENTRYP PFNGLRESETMEMORYOBJECTPARAMETERNVPROC) (GLuint memory, GLenum pname); +typedef void (APIENTRYP PFNGLTEXATTACHMEMORYNVPROC) (GLenum target, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLBUFFERATTACHMEMORYNVPROC) (GLenum target, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTUREATTACHMEMORYNVPROC) (GLuint texture, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLNAMEDBUFFERATTACHMEMORYNVPROC) (GLuint buffer, GLuint memory, GLuint64 offset); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetMemoryObjectDetachedResourcesuivNV (GLuint memory, GLenum pname, GLint first, GLsizei count, GLuint *params); +GLAPI void APIENTRY glResetMemoryObjectParameterNV (GLuint memory, GLenum pname); +GLAPI void APIENTRY glTexAttachMemoryNV (GLenum target, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glBufferAttachMemoryNV (GLenum target, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureAttachMemoryNV (GLuint texture, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glNamedBufferAttachMemoryNV (GLuint buffer, GLuint memory, GLuint64 offset); +#endif +#endif /* GL_NV_memory_attachment */ + +#ifndef GL_NV_mesh_shader +#define GL_NV_mesh_shader 1 +#define GL_MESH_SHADER_NV 0x9559 +#define GL_TASK_SHADER_NV 0x955A +#define GL_MAX_MESH_UNIFORM_BLOCKS_NV 0x8E60 +#define GL_MAX_MESH_TEXTURE_IMAGE_UNITS_NV 0x8E61 +#define GL_MAX_MESH_IMAGE_UNIFORMS_NV 0x8E62 +#define GL_MAX_MESH_UNIFORM_COMPONENTS_NV 0x8E63 +#define GL_MAX_MESH_ATOMIC_COUNTER_BUFFERS_NV 0x8E64 +#define GL_MAX_MESH_ATOMIC_COUNTERS_NV 0x8E65 +#define GL_MAX_MESH_SHADER_STORAGE_BLOCKS_NV 0x8E66 +#define GL_MAX_COMBINED_MESH_UNIFORM_COMPONENTS_NV 0x8E67 +#define GL_MAX_TASK_UNIFORM_BLOCKS_NV 0x8E68 +#define GL_MAX_TASK_TEXTURE_IMAGE_UNITS_NV 0x8E69 +#define GL_MAX_TASK_IMAGE_UNIFORMS_NV 0x8E6A +#define GL_MAX_TASK_UNIFORM_COMPONENTS_NV 0x8E6B +#define GL_MAX_TASK_ATOMIC_COUNTER_BUFFERS_NV 0x8E6C +#define GL_MAX_TASK_ATOMIC_COUNTERS_NV 0x8E6D +#define GL_MAX_TASK_SHADER_STORAGE_BLOCKS_NV 0x8E6E +#define GL_MAX_COMBINED_TASK_UNIFORM_COMPONENTS_NV 0x8E6F +#define GL_MAX_MESH_WORK_GROUP_INVOCATIONS_NV 0x95A2 +#define GL_MAX_TASK_WORK_GROUP_INVOCATIONS_NV 0x95A3 +#define GL_MAX_MESH_TOTAL_MEMORY_SIZE_NV 0x9536 +#define GL_MAX_TASK_TOTAL_MEMORY_SIZE_NV 0x9537 +#define GL_MAX_MESH_OUTPUT_VERTICES_NV 0x9538 +#define GL_MAX_MESH_OUTPUT_PRIMITIVES_NV 0x9539 +#define GL_MAX_TASK_OUTPUT_COUNT_NV 0x953A +#define GL_MAX_DRAW_MESH_TASKS_COUNT_NV 0x953D +#define GL_MAX_MESH_VIEWS_NV 0x9557 +#define GL_MESH_OUTPUT_PER_VERTEX_GRANULARITY_NV 0x92DF +#define GL_MESH_OUTPUT_PER_PRIMITIVE_GRANULARITY_NV 0x9543 +#define GL_MAX_MESH_WORK_GROUP_SIZE_NV 0x953B +#define GL_MAX_TASK_WORK_GROUP_SIZE_NV 0x953C +#define GL_MESH_WORK_GROUP_SIZE_NV 0x953E +#define GL_TASK_WORK_GROUP_SIZE_NV 0x953F +#define GL_MESH_VERTICES_OUT_NV 0x9579 +#define GL_MESH_PRIMITIVES_OUT_NV 0x957A +#define GL_MESH_OUTPUT_TYPE_NV 0x957B +#define GL_UNIFORM_BLOCK_REFERENCED_BY_MESH_SHADER_NV 0x959C +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TASK_SHADER_NV 0x959D +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_MESH_SHADER_NV 0x959E +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TASK_SHADER_NV 0x959F +#define GL_REFERENCED_BY_MESH_SHADER_NV 0x95A0 +#define GL_REFERENCED_BY_TASK_SHADER_NV 0x95A1 +#define GL_MESH_SUBROUTINE_NV 0x957C +#define GL_TASK_SUBROUTINE_NV 0x957D +#define GL_MESH_SUBROUTINE_UNIFORM_NV 0x957E +#define GL_TASK_SUBROUTINE_UNIFORM_NV 0x957F +#define GL_MESH_SHADER_BIT_NV 0x00000040 +#define GL_TASK_SHADER_BIT_NV 0x00000080 +typedef void (APIENTRYP PFNGLDRAWMESHTASKSNVPROC) (GLuint first, GLuint count); +typedef void (APIENTRYP PFNGLDRAWMESHTASKSINDIRECTNVPROC) (GLintptr indirect); +typedef void (APIENTRYP PFNGLMULTIDRAWMESHTASKSINDIRECTNVPROC) (GLintptr indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWMESHTASKSINDIRECTCOUNTNVPROC) (GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshTasksNV (GLuint first, GLuint count); +GLAPI void APIENTRY glDrawMeshTasksIndirectNV (GLintptr indirect); +GLAPI void APIENTRY glMultiDrawMeshTasksIndirectNV (GLintptr indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawMeshTasksIndirectCountNV (GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#endif +#endif /* GL_NV_mesh_shader */ + #ifndef GL_NV_multisample_coverage #define GL_NV_multisample_coverage 1 #endif /* GL_NV_multisample_coverage */ @@ -10311,6 +10732,32 @@ GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index); #endif #endif /* GL_NV_primitive_restart */ +#ifndef GL_NV_query_resource +#define GL_NV_query_resource 1 +#define GL_QUERY_RESOURCE_TYPE_VIDMEM_ALLOC_NV 0x9540 +#define GL_QUERY_RESOURCE_MEMTYPE_VIDMEM_NV 0x9542 +#define GL_QUERY_RESOURCE_SYS_RESERVED_NV 0x9544 +#define GL_QUERY_RESOURCE_TEXTURE_NV 0x9545 +#define GL_QUERY_RESOURCE_RENDERBUFFER_NV 0x9546 +#define GL_QUERY_RESOURCE_BUFFEROBJECT_NV 0x9547 +typedef GLint (APIENTRYP PFNGLQUERYRESOURCENVPROC) (GLenum queryType, GLint tagId, GLuint bufSize, GLint *buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glQueryResourceNV (GLenum queryType, GLint tagId, GLuint bufSize, GLint *buffer); +#endif +#endif /* GL_NV_query_resource */ + +#ifndef GL_NV_query_resource_tag +#define GL_NV_query_resource_tag 1 +typedef void (APIENTRYP PFNGLGENQUERYRESOURCETAGNVPROC) (GLsizei n, GLint *tagIds); +typedef void (APIENTRYP PFNGLDELETEQUERYRESOURCETAGNVPROC) (GLsizei n, const GLint *tagIds); +typedef void (APIENTRYP PFNGLQUERYRESOURCETAGNVPROC) (GLint tagId, const GLchar *tagString); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueryResourceTagNV (GLsizei n, GLint *tagIds); +GLAPI void APIENTRY glDeleteQueryResourceTagNV (GLsizei n, const GLint *tagIds); +GLAPI void APIENTRY glQueryResourceTagNV (GLint tagId, const GLchar *tagString); +#endif +#endif /* GL_NV_query_resource_tag */ + #ifndef GL_NV_register_combiners #define GL_NV_register_combiners 1 #define GL_REGISTER_COMBINERS_NV 0x8522 @@ -10403,6 +10850,11 @@ GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, #endif #endif /* GL_NV_register_combiners2 */ +#ifndef GL_NV_representative_fragment_test +#define GL_NV_representative_fragment_test 1 +#define GL_REPRESENTATIVE_FRAGMENT_TEST_NV 0x937F +#endif /* GL_NV_representative_fragment_test */ + #ifndef GL_NV_robustness_video_memory_purge #define GL_NV_robustness_video_memory_purge 1 #define GL_PURGED_CONTEXT_RESET_NV 0x92BB @@ -10432,6 +10884,18 @@ GLAPI void APIENTRY glResolveDepthValuesNV (void); #define GL_NV_sample_mask_override_coverage 1 #endif /* GL_NV_sample_mask_override_coverage */ +#ifndef GL_NV_scissor_exclusive +#define GL_NV_scissor_exclusive 1 +#define GL_SCISSOR_TEST_EXCLUSIVE_NV 0x9555 +#define GL_SCISSOR_BOX_EXCLUSIVE_NV 0x9556 +typedef void (APIENTRYP PFNGLSCISSOREXCLUSIVENVPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLSCISSOREXCLUSIVEARRAYVNVPROC) (GLuint first, GLsizei count, const GLint *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glScissorExclusiveNV (GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glScissorExclusiveArrayvNV (GLuint first, GLsizei count, const GLint *v); +#endif +#endif /* GL_NV_scissor_exclusive */ + #ifndef GL_NV_shader_atomic_counters #define GL_NV_shader_atomic_counters 1 #endif /* GL_NV_shader_atomic_counters */ @@ -10496,6 +10960,10 @@ GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLs #define GL_NV_shader_storage_buffer_object 1 #endif /* GL_NV_shader_storage_buffer_object */ +#ifndef GL_NV_shader_texture_footprint +#define GL_NV_shader_texture_footprint 1 +#endif /* GL_NV_shader_texture_footprint */ + #ifndef GL_NV_shader_thread_group #define GL_NV_shader_thread_group 1 #define GL_WARP_SIZE_NV 0x9339 @@ -10507,6 +10975,47 @@ GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLs #define GL_NV_shader_thread_shuffle 1 #endif /* GL_NV_shader_thread_shuffle */ +#ifndef GL_NV_shading_rate_image +#define GL_NV_shading_rate_image 1 +#define GL_SHADING_RATE_IMAGE_NV 0x9563 +#define GL_SHADING_RATE_NO_INVOCATIONS_NV 0x9564 +#define GL_SHADING_RATE_1_INVOCATION_PER_PIXEL_NV 0x9565 +#define GL_SHADING_RATE_1_INVOCATION_PER_1X2_PIXELS_NV 0x9566 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X1_PIXELS_NV 0x9567 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X2_PIXELS_NV 0x9568 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X4_PIXELS_NV 0x9569 +#define GL_SHADING_RATE_1_INVOCATION_PER_4X2_PIXELS_NV 0x956A +#define GL_SHADING_RATE_1_INVOCATION_PER_4X4_PIXELS_NV 0x956B +#define GL_SHADING_RATE_2_INVOCATIONS_PER_PIXEL_NV 0x956C +#define GL_SHADING_RATE_4_INVOCATIONS_PER_PIXEL_NV 0x956D +#define GL_SHADING_RATE_8_INVOCATIONS_PER_PIXEL_NV 0x956E +#define GL_SHADING_RATE_16_INVOCATIONS_PER_PIXEL_NV 0x956F +#define GL_SHADING_RATE_IMAGE_BINDING_NV 0x955B +#define GL_SHADING_RATE_IMAGE_TEXEL_WIDTH_NV 0x955C +#define GL_SHADING_RATE_IMAGE_TEXEL_HEIGHT_NV 0x955D +#define GL_SHADING_RATE_IMAGE_PALETTE_SIZE_NV 0x955E +#define GL_MAX_COARSE_FRAGMENT_SAMPLES_NV 0x955F +#define GL_SHADING_RATE_SAMPLE_ORDER_DEFAULT_NV 0x95AE +#define GL_SHADING_RATE_SAMPLE_ORDER_PIXEL_MAJOR_NV 0x95AF +#define GL_SHADING_RATE_SAMPLE_ORDER_SAMPLE_MAJOR_NV 0x95B0 +typedef void (APIENTRYP PFNGLBINDSHADINGRATEIMAGENVPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLGETSHADINGRATEIMAGEPALETTENVPROC) (GLuint viewport, GLuint entry, GLenum *rate); +typedef void (APIENTRYP PFNGLGETSHADINGRATESAMPLELOCATIONIVNVPROC) (GLenum rate, GLuint samples, GLuint index, GLint *location); +typedef void (APIENTRYP PFNGLSHADINGRATEIMAGEBARRIERNVPROC) (GLboolean synchronize); +typedef void (APIENTRYP PFNGLSHADINGRATEIMAGEPALETTENVPROC) (GLuint viewport, GLuint first, GLsizei count, const GLenum *rates); +typedef void (APIENTRYP PFNGLSHADINGRATESAMPLEORDERNVPROC) (GLenum order); +typedef void (APIENTRYP PFNGLSHADINGRATESAMPLEORDERCUSTOMNVPROC) (GLenum rate, GLuint samples, const GLint *locations); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindShadingRateImageNV (GLuint texture); +GLAPI void APIENTRY glGetShadingRateImagePaletteNV (GLuint viewport, GLuint entry, GLenum *rate); +GLAPI void APIENTRY glGetShadingRateSampleLocationivNV (GLenum rate, GLuint samples, GLuint index, GLint *location); +GLAPI void APIENTRY glShadingRateImageBarrierNV (GLboolean synchronize); +GLAPI void APIENTRY glShadingRateImagePaletteNV (GLuint viewport, GLuint first, GLsizei count, const GLenum *rates); +GLAPI void APIENTRY glShadingRateSampleOrderNV (GLenum order); +GLAPI void APIENTRY glShadingRateSampleOrderCustomNV (GLenum rate, GLuint samples, const GLint *locations); +#endif +#endif /* GL_NV_shading_rate_image */ + #ifndef GL_NV_stereo_view_rendering #define GL_NV_stereo_view_rendering 1 #endif /* GL_NV_stereo_view_rendering */ @@ -10587,6 +11096,10 @@ GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenu #define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 #endif /* GL_NV_texture_rectangle */ +#ifndef GL_NV_texture_rectangle_compressed +#define GL_NV_texture_rectangle_compressed 1 +#endif /* GL_NV_texture_rectangle_compressed */ + #ifndef GL_NV_texture_shader #define GL_NV_texture_shader 1 #define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C @@ -10813,6 +11326,14 @@ GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSur #endif #endif /* GL_NV_vdpau_interop */ +#ifndef GL_NV_vdpau_interop2 +#define GL_NV_vdpau_interop2 1 +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACEWITHPICTURESTRUCTURENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames, GLboolean isFrameStructure); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceWithPictureStructureNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames, GLboolean isFrameStructure); +#endif +#endif /* GL_NV_vdpau_interop2 */ + #ifndef GL_NV_vertex_array_range #define GL_NV_vertex_array_range 1 #define GL_VERTEX_ARRAY_RANGE_NV 0x851D From 10ec683a968486df68c013f456df4d1798ea27d3 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 3 Mar 2019 12:06:58 +0100 Subject: [PATCH 066/292] QLineF: mark angle(const QLineF&) as deprecated QLineF::angle(const QLineF&) was deprecated during Qt4 times but not decorated with QT_DEPRECATED_X. Add this so it can be removed with Qt6 Change-Id: I8950b646cc5fa8206e47bdd16647d17d615f6c6a Reviewed-by: Lars Knoll --- examples/widgets/painting/affine/xform.cpp | 5 +---- examples/widgets/painting/gradients/gradients.cpp | 4 +--- src/corelib/tools/qline.cpp | 2 ++ src/corelib/tools/qline.h | 3 +++ src/gui/painting/qstroker.cpp | 9 +++------ 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/examples/widgets/painting/affine/xform.cpp b/examples/widgets/painting/affine/xform.cpp index dc01acf453..482e0f3268 100644 --- a/examples/widgets/painting/affine/xform.cpp +++ b/examples/widgets/painting/affine/xform.cpp @@ -160,10 +160,7 @@ void XFormView::updateCtrlPoints(const QPolygonF &points) ctrlPoints = points; QLineF line(ctrlPoints.at(0), ctrlPoints.at(1)); - m_rotation = line.angle(QLineF(0, 0, 1, 0)); - if (line.dy() < 0) - m_rotation = 360 - m_rotation; - + m_rotation = 360 - QLineF(0, 0, 1, 0).angleTo(line); if (trans.isNull()) emit rotationChanged(int(m_rotation*10)); } diff --git a/examples/widgets/painting/gradients/gradients.cpp b/examples/widgets/painting/gradients/gradients.cpp index 7abaef771b..8df45be8d9 100644 --- a/examples/widgets/painting/gradients/gradients.cpp +++ b/examples/widgets/painting/gradients/gradients.cpp @@ -564,9 +564,7 @@ void GradientRenderer::paint(QPainter *p) } else { QLineF l(pts.at(0), pts.at(1)); - qreal angle = l.angle(QLineF(0, 0, 1, 0)); - if (l.dy() > 0) - angle = 360 - angle; + qreal angle = QLineF(0, 0, 1, 0).angleTo(l); g = QConicalGradient(pts.at(0), angle); } diff --git a/src/corelib/tools/qline.cpp b/src/corelib/tools/qline.cpp index 949f63ea15..6f3c22a6ec 100644 --- a/src/corelib/tools/qline.cpp +++ b/src/corelib/tools/qline.cpp @@ -805,6 +805,7 @@ qreal QLineF::angleTo(const QLineF &l) const return delta_normalized; } +#if QT_DEPRECATED_SINCE(5, 14) /*! \fn qreal QLineF::angle(const QLineF &line) const @@ -837,6 +838,7 @@ qreal QLineF::angle(const QLineF &l) const if (cos_line >= -1.0 && cos_line <= 1.0) rad = qAcos( cos_line ); return rad * 360 / M_2PI; } +#endif #ifndef QT_NO_DEBUG_STREAM diff --git a/src/corelib/tools/qline.h b/src/corelib/tools/qline.h index 6361c1af9f..14980b60a0 100644 --- a/src/corelib/tools/qline.h +++ b/src/corelib/tools/qline.h @@ -251,7 +251,10 @@ public: // ### Qt 6: rename intersects() or intersection() and rename IntersectType IntersectionType IntersectType intersect(const QLineF &l, QPointF *intersectionPoint) const; +#if QT_DEPRECATED_SINCE(5, 14) + QT_DEPRECATED_X("Use angleTo() instead, take care that the return value is between 0 and 360 degree.") qreal angle(const QLineF &l) const; +#endif Q_DECL_CONSTEXPR inline QPointF pointAt(qreal t) const; inline void translate(const QPointF &p); diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp index c01531caf2..f8f8d72d14 100644 --- a/src/gui/painting/qstroker.cpp +++ b/src/gui/painting/qstroker.cpp @@ -173,15 +173,12 @@ template bool qt_stroke_side(Iterator *it, QStroker *stroker, bool capFirst, QLineF *startTangent); /******************************************************************************* - * QLineF::angle gives us the smalles angle between two lines. Here we - * want to identify the line's angle direction on the unit circle. + * QLineF::angleTo gives us the angle between two lines with respecting the direction. + * Here we want to identify the line's angle direction on the unit circle. */ static inline qreal adapted_angle_on_x(const QLineF &line) { - qreal angle = line.angle(QLineF(0, 0, 1, 0)); - if (line.dy() > 0) - angle = 360 - angle; - return angle; + return QLineF(0, 0, 1, 0).angleTo(line); } QStrokerOps::QStrokerOps() From c9ff943f8f006a64aaae6c98c316235d6fc78956 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 4 Mar 2019 13:19:27 +0100 Subject: [PATCH 067/292] Restructure tst_QDir::mkdirRmdir_data() Iterate over a struct array rather than having a list of strings to pull things out of, by individual index; this makes it easy to include the non-existence check for directories in the same loop. In the process, give the absolute-path tests a prefix to mirror the relative- prefix on their partners. This prepares the way for adding more test-cases. Change-Id: Id839caedf92387dfa9b94f31253410285f72ff70 Reviewed-by: Thiago Macieira --- tests/auto/corelib/io/qdir/tst_qdir.cpp | 28 ++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index 34588b19bc..6cca360fef 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -349,21 +349,21 @@ void tst_QDir::mkdirRmdir_data() QTest::addColumn("path"); QTest::addColumn("recurse"); - QStringList dirs; - dirs << "testdir/one" - << "testdir/two/three/four" - << "testdir/../testdir/three"; - QTest::newRow("plain") << QDir::currentPath() + "/" + dirs.at(0) << false; - QTest::newRow("recursive") << QDir::currentPath() + "/" + dirs.at(1) << true; - QTest::newRow("with-..") << QDir::currentPath() + "/" + dirs.at(2) << false; + const struct { + const char *name; // shall have a prefix added + const char *path; // relative + bool recurse; + } cases[] = { + { "plain", "testdir/one", false }, + { "recursive", "testdir/two/three/four", true }, + { "with-..", "testdir/../testdir/three", false }, + }; - QTest::newRow("relative-plain") << dirs.at(0) << false; - QTest::newRow("relative-recursive") << dirs.at(1) << true; - QTest::newRow("relative-with-..") << dirs.at(2) << false; - - // Ensure that none of these directories already exist - for (int i = 0; i < dirs.count(); ++i) - QVERIFY(!QFile::exists(dirs.at(i))); + for (const auto &it : cases) { + QVERIFY(!QFile::exists(it.path)); + QTest::addRow("absolute-%s", it.name) << (QDir::currentPath() + "/") + it.path << it.recurse; + QTest::addRow("relative-%s", it.name) << QString::fromLatin1(it.path) << it.recurse; + } } void tst_QDir::mkdirRmdir() From 6bb22c12a6396d3bae2715936ca570bb57cae669 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 4 Mar 2019 15:51:17 +0100 Subject: [PATCH 068/292] rcc test: Properly check QProcess errors Separate waitForStarted() and waitForFinished() to properly catch startup errors and kill hanging processes. Also check exit status and code. Task-number: PYSIDE-855 Change-Id: Ic8e623f4a8c716a2892767a8dbc06ba4ffb90b5a Reviewed-by: hjk Reviewed-by: Cristian Maureira-Fredes --- tests/auto/tools/rcc/tst_rcc.cpp | 94 +++++++++++++++++++------------- 1 file changed, 57 insertions(+), 37 deletions(-) diff --git a/tests/auto/tools/rcc/tst_rcc.cpp b/tests/auto/tools/rcc/tst_rcc.cpp index dfe8ba556b..84db7688ef 100644 --- a/tests/auto/tools/rcc/tst_rcc.cpp +++ b/tests/auto/tools/rcc/tst_rcc.cpp @@ -46,6 +46,33 @@ typedef QMap QStringMap; Q_DECLARE_METATYPE(QStringMap) +static QByteArray msgProcessStartFailed(const QProcess &p) +{ + const QString result = QLatin1String("Could not start \"") + + QDir::toNativeSeparators(p.program()) + QLatin1String("\": ") + + p.errorString(); + return result.toLocal8Bit(); +} + +static QByteArray msgProcessTimeout(const QProcess &p) +{ + return '"' + QDir::toNativeSeparators(p.program()).toLocal8Bit() + + "\" timed out."; +} + +static QByteArray msgProcessCrashed(QProcess &p) +{ + return '"' + QDir::toNativeSeparators(p.program()).toLocal8Bit() + + "\" crashed.\n" + p.readAllStandardError(); +} + +static QByteArray msgProcessFailed(QProcess &p) +{ + return '"' + QDir::toNativeSeparators(p.program()).toLocal8Bit() + + "\" returned " + QByteArray::number(p.exitCode()) + ":\n" + + p.readAllStandardError(); +} + class tst_rcc : public QObject { Q_OBJECT @@ -163,12 +190,16 @@ void tst_rcc::rcc() // depending on the compression algorithm we're using QProcess process; process.start(m_rcc, { "-no-compress", qrcfile }); + QVERIFY2(process.waitForStarted(), msgProcessStartFailed(process).constData()); if (!process.waitForFinished()) { - const QString path = QString::fromLocal8Bit(qgetenv("PATH")); - QString message = QString::fromLatin1("'%1' could not be found when run from '%2'. Path: '%3' "). - arg(m_rcc, QDir::currentPath(), path); - QFAIL(qPrintable(message)); + process.kill(); + QFAIL(msgProcessTimeout(process).constData()); } + QVERIFY2(process.exitStatus() == QProcess::NormalExit, + msgProcessCrashed(process).constData()); + QVERIFY2(process.exitCode() == 0, + msgProcessFailed(process).constData()); + const QChar cr = QLatin1Char('\r'); const QString err = QString::fromLocal8Bit(process.readAllStandardError()).remove(cr); const QString out = QString::fromLatin1(process.readAllStandardOutput()).remove(cr); @@ -189,38 +220,6 @@ void tst_rcc::rcc() QFAIL(qPrintable(diff)); } - - -static void createRccBinaryData(const QString &rcc, const QString &baseDir, - const QString &qrcFileName, const QString &rccFileName) -{ - QString currentDir = QDir::currentPath(); - QDir::setCurrent(baseDir); - - // same as above: force no compression - QProcess rccProcess; - rccProcess.start(rcc, { "-binary", "-no-compress", "-o", rccFileName, qrcFileName }); - bool ok = rccProcess.waitForFinished(); - if (!ok) { - QString errorString = QString::fromLatin1("Could not start rcc (is it in PATH?): %1").arg(rccProcess.errorString()); - QFAIL(qPrintable(errorString)); - } - - QByteArray output = rccProcess.readAllStandardOutput(); - if (!output.isEmpty()) { - QString errorMessage = QString::fromLatin1("rcc stdout: %1").arg(QString::fromLocal8Bit(output)); - QWARN(qPrintable(errorMessage)); - } - - output = rccProcess.readAllStandardError(); - if (!output.isEmpty()) { - QString errorMessage = QString::fromLatin1("rcc stderr: %1").arg(QString::fromLocal8Bit(output)); - QWARN(qPrintable(errorMessage)); - } - - QDir::setCurrent(currentDir); -} - static QStringList readLinesFromFile(const QString &fileName) { QFile file(fileName); @@ -277,7 +276,28 @@ void tst_rcc::binary_data() QFileInfo qrcFileInfo = iter.fileInfo(); QString absoluteBaseName = QFileInfo(qrcFileInfo.absolutePath(), qrcFileInfo.baseName()).absoluteFilePath(); QString rccFileName = absoluteBaseName + QLatin1String(".rcc"); - createRccBinaryData(m_rcc, dataPath, qrcFileInfo.absoluteFilePath(), rccFileName); + + // same as above: force no compression + QProcess rccProcess; + rccProcess.setWorkingDirectory(dataPath); + rccProcess.start(m_rcc, { "-binary", "-no-compress", "-o", rccFileName, qrcFileInfo.absoluteFilePath() }); + QVERIFY2(rccProcess.waitForStarted(), msgProcessStartFailed(rccProcess).constData()); + if (!rccProcess.waitForFinished()) { + rccProcess.kill(); + QFAIL(msgProcessTimeout(rccProcess).constData()); + } + QVERIFY2(rccProcess.exitStatus() == QProcess::NormalExit, + msgProcessCrashed(rccProcess).constData()); + QVERIFY2(rccProcess.exitCode() == 0, + msgProcessFailed(rccProcess).constData()); + + QByteArray output = rccProcess.readAllStandardOutput(); + if (!output.isEmpty()) + qWarning("rcc stdout: %s", output.constData()); + + output = rccProcess.readAllStandardError(); + if (!output.isEmpty()) + qWarning("rcc stderr: %s", output.constData()); QString localeFileName = absoluteBaseName + QLatin1String(".locale"); QFile localeFile(localeFileName); From c212128a676aa906fdef79c3e5ccecf0d942e68c Mon Sep 17 00:00:00 2001 From: Konstantin Shegunov Date: Tue, 19 Feb 2019 23:53:58 +0200 Subject: [PATCH 069/292] Add input check for QSslSocket::setPrivateKey MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [ChangeLog][QtNetwork][QSslSocket] Added runtime validation of the SSL private key when it is loaded through a file path. Task-number: QTBUG-72016 Change-Id: Ie92c3a2fbf3ba896c4c838e03d677426be56a5db Reviewed-by: Mårten Nordheim Reviewed-by: Samuel Gaist Reviewed-by: Edward Welbourne --- src/network/ssl/qsslsocket.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index cf8a472606..fa012866e6 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -1209,12 +1209,21 @@ void QSslSocket::setPrivateKey(const QSslKey &key) void QSslSocket::setPrivateKey(const QString &fileName, QSsl::KeyAlgorithm algorithm, QSsl::EncodingFormat format, const QByteArray &passPhrase) { - Q_D(QSslSocket); QFile file(fileName); - if (file.open(QIODevice::ReadOnly)) { - d->configuration.privateKey = QSslKey(file.readAll(), algorithm, - format, QSsl::PrivateKey, passPhrase); + if (!file.open(QIODevice::ReadOnly)) { + qCWarning(lcSsl, "QSslSocket::setPrivateKey: Couldn't open file for reading"); + return; } + + QSslKey key(file.readAll(), algorithm, format, QSsl::PrivateKey, passPhrase); + if (key.isNull()) { + qCWarning(lcSsl, "QSslSocket::setPrivateKey: " + "The specified file does not contain a valid key"); + return; + } + + Q_D(QSslSocket); + d->configuration.privateKey = key; } /*! From ca037c06319c310ae2c41ca7f306593bb26b4153 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 5 Feb 2019 11:33:19 +0100 Subject: [PATCH 070/292] Convert tst_qudpsocket to use docker Currently docker is only used for the "echo" test, and then only the echo server. The SOCKS5 tests have been disabled from when our current test server was new. Change-Id: I21b0c5f10e722a42a0880b2500d1bcbc609a03bf Reviewed-by: Timur Pocheptsov --- .../network/socket/qudpsocket/test/test.pro | 6 ++++++ .../socket/qudpsocket/tst_qudpsocket.cpp | 19 +++++++++++++------ tests/testserver/docker-compose.yml | 12 ++++++++++++ tests/testserver/echo/echo.sh | 6 ++++++ 4 files changed, 37 insertions(+), 6 deletions(-) create mode 100755 tests/testserver/echo/echo.sh diff --git a/tests/auto/network/socket/qudpsocket/test/test.pro b/tests/auto/network/socket/qudpsocket/test/test.pro index e856776ddc..0fdb97ba27 100644 --- a/tests/auto/network/socket/qudpsocket/test/test.pro +++ b/tests/auto/network/socket/qudpsocket/test/test.pro @@ -17,3 +17,9 @@ win32 { } TARGET = tst_qudpsocket + +# Only on Linux until 'echo' has been added to docker-compose-for-{windows,macOS}.yml and tested +linux { + QT_TEST_SERVER_LIST = danted echo + include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) +} diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index 707c1acf48..a4b22cb000 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -235,6 +235,7 @@ void tst_QUdpSocket::initTestCase_data() // hack: we only enable the Socks5 over UDP tests on the old // test server, because they fail on the new one. See QTBUG-35490 bool newTestServer = true; +#ifndef QT_TEST_SERVER QTcpSocket socket; socket.connectToHost(QtNetworkSettings::serverName(), 22); if (socket.waitForConnected(10000)) { @@ -244,6 +245,7 @@ void tst_QUdpSocket::initTestCase_data() newTestServer = false; socket.disconnectFromHost(); } +#endif QTest::addColumn("setProxy"); QTest::addColumn("proxyType"); @@ -257,8 +259,13 @@ void tst_QUdpSocket::initTestCase_data() void tst_QUdpSocket::initTestCase() { +#ifdef QT_TEST_SERVER + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::socksProxyServerName(), 1080)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::echoServerName(), 7)); +#else if (!QtNetworkSettings::verifyTestNetworkSettings()) QSKIP("No network test server available"); +#endif allAddresses = QNetworkInterface::allAddresses(); m_skipUnsupportedIPv6Tests = shouldSkipIpv6TestsForBrokenSetsockopt(); @@ -300,7 +307,7 @@ void tst_QUdpSocket::init() #if QT_CONFIG(socks5) QFETCH_GLOBAL(int, proxyType); if (proxyType == QNetworkProxy::Socks5Proxy) { - QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080)); + QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1080)); } #else QSKIP("No proxy support"); @@ -981,7 +988,7 @@ void tst_QUdpSocket::writeDatagramToNonExistingPeer_data() QTest::addColumn("bind"); QTest::addColumn("peerAddress"); QHostAddress localhost(QHostAddress::LocalHost); - QList serverAddresses(QHostInfo::fromName(QtNetworkSettings::serverName()).addresses()); + QList serverAddresses(QHostInfo::fromName(QtNetworkSettings::socksProxyServerName()).addresses()); if (serverAddresses.isEmpty()) return; @@ -995,7 +1002,7 @@ void tst_QUdpSocket::writeDatagramToNonExistingPeer_data() void tst_QUdpSocket::writeDatagramToNonExistingPeer() { - if (QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().isEmpty()) + if (QHostInfo::fromName(QtNetworkSettings::socksProxyServerName()).addresses().isEmpty()) QFAIL("Could not find test server address"); QFETCH(bool, bind); QFETCH(QHostAddress, peerAddress); @@ -1015,7 +1022,7 @@ void tst_QUdpSocket::writeToNonExistingPeer_data() { QTest::addColumn("peerAddress"); QHostAddress localhost(QHostAddress::LocalHost); - QList serverAddresses(QHostInfo::fromName(QtNetworkSettings::serverName()).addresses()); + QList serverAddresses(QHostInfo::fromName(QtNetworkSettings::socksProxyServerName()).addresses()); if (serverAddresses.isEmpty()) return; @@ -1028,7 +1035,7 @@ void tst_QUdpSocket::writeToNonExistingPeer_data() void tst_QUdpSocket::writeToNonExistingPeer() { QSKIP("Connected-mode UDP sockets and their behaviour are erratic"); - if (QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().isEmpty()) + if (QHostInfo::fromName(QtNetworkSettings::socksProxyServerName()).addresses().isEmpty()) QFAIL("Could not find test server address"); QFETCH(QHostAddress, peerAddress); quint16 peerPort = 34534; @@ -1551,7 +1558,7 @@ void tst_QUdpSocket::echo_data() void tst_QUdpSocket::echo() { QFETCH(bool, connect); - QHostInfo info = QHostInfo::fromName(QtNetworkSettings::serverName()); + QHostInfo info = QHostInfo::fromName(QtNetworkSettings::echoServerName()); QVERIFY(info.addresses().count()); QHostAddress remote = info.addresses().first(); diff --git a/tests/testserver/docker-compose.yml b/tests/testserver/docker-compose.yml index 4286c88211..60ecfe6f21 100644 --- a/tests/testserver/docker-compose.yml +++ b/tests/testserver/docker-compose.yml @@ -80,6 +80,7 @@ services: - vsftpd:vsftpd.${TEST_DOMAIN} - ftp-proxy:ftp-proxy.${TEST_DOMAIN} - cyrus:cyrus.${TEST_DOMAIN} + - echo:echo.${TEST_DOMAIN} volumes: - ./common:/common:ro - ./danted:/service:ro @@ -110,3 +111,14 @@ services: cap_add: - NET_ADMIN - NET_RAW + + echo: + image: qt-test-server-echo:b29ad409e746a834c1055fd0f7a55fd5056da6ea + container_name: qt-test-server-echo + domainname: ${TEST_DOMAIN} + hostname: echo + volumes: + - ./common:/common:ro + - ./echo:/service:ro + entrypoint: common/startup.sh + command: service/echo.sh diff --git a/tests/testserver/echo/echo.sh b/tests/testserver/echo/echo.sh new file mode 100755 index 0000000000..a028d056e0 --- /dev/null +++ b/tests/testserver/echo/echo.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +# Disabled by default, enable it. +sed -i 's/disable\t\t= yes/disable = no/' /etc/xinetd.d/echo + +service xinetd restart From 329e3d4ec463349322568c0d8ff9a5141b8c045d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 6 Mar 2019 12:55:18 +0100 Subject: [PATCH 071/292] QComboxBox: Silence warnings about deprecated API Fix: widgets/qcombobox.cpp: In member function 'void QComboBoxPrivate::emitActivated(const QModelIndex&)': widgets/qcombobox.cpp:1369:22: warning: 'void QComboBox::activated(const QString&)' is deprecated: Use textActivated() instead [-Wdeprecated-declarations] In file included from widgets/qcombobox.cpp:40:0: widgets/qcombobox.h:234:10: note: declared here widgets/qcombobox.cpp: In member function 'void QComboBoxPrivate::_q_emitHighlighted(const QModelIndex&)': widgets/qcombobox.cpp:1382:24: warning: 'void QComboBox::highlighted(const QString&)' is deprecated: Use textHighlighted() instead [-Wdeprecated-declarations] Change-Id: I11bdbbeeaa05f1e1bd91351eba329ce9895951f9 Reviewed-by: Christian Ehrlicher --- src/widgets/widgets/qcombobox.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index fa000761ec..7e29a417ea 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -1366,7 +1366,10 @@ void QComboBoxPrivate::emitActivated(const QModelIndex &index) emit q->activated(index.row()); emit q->textActivated(text); #if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED emit q->activated(text); +QT_WARNING_POP #endif } @@ -1379,7 +1382,10 @@ void QComboBoxPrivate::_q_emitHighlighted(const QModelIndex &index) emit q->highlighted(index.row()); emit q->textHighlighted(text); #if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED emit q->highlighted(text); +QT_WARNING_POP #endif } From ba3480ebc678cd50c80e60693d03f49679405d82 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 5 Mar 2019 11:18:38 +0100 Subject: [PATCH 072/292] rcc test: Streamline test - Add the path to expand the timestamp files as a parameter to doCompare() and check that the file is found. It is then no longer necessary to change the working directory in rcc(). - Fix the line number output in doCompare() - Move helper readLinesFromFile() up and make the split mode a parameter so that it can be used for reading files without stripping empty lines - Remove the helper findExpectedFile() which apparently was meant to introduce some version scheme in Qt 4.5 but was never continued. Task-number: PYSIDE-855 Change-Id: I3d8cf957995fec8e34cddb4992fc8854148c7bdc Reviewed-by: Cristian Maureira-Fredes Reviewed-by: hjk --- tests/auto/tools/rcc/tst_rcc.cpp | 76 ++++++++++++++------------------ 1 file changed, 32 insertions(+), 44 deletions(-) diff --git a/tests/auto/tools/rcc/tst_rcc.cpp b/tests/auto/tools/rcc/tst_rcc.cpp index 84db7688ef..2c63b0c770 100644 --- a/tests/auto/tools/rcc/tst_rcc.cpp +++ b/tests/auto/tools/rcc/tst_rcc.cpp @@ -107,18 +107,8 @@ void tst_rcc::initTestCase() QVERIFY(!m_dataPath.isEmpty()); } -QString findExpectedFile(const QString &base) -{ - QString expectedrccfile = base; - - // Must be updated with each minor release. - if (QFileInfo(expectedrccfile + QLatin1String(".450")).exists()) - expectedrccfile += QLatin1String(".450"); - - return expectedrccfile; -} - -static QString doCompare(const QStringList &actual, const QStringList &expected) +static QString doCompare(const QStringList &actual, const QStringList &expected, + const QString &timeStampPath) { if (actual.size() != expected.size()) { return QString("Length count different: actual: %1, expected: %2") @@ -132,7 +122,12 @@ static QString doCompare(const QStringList &actual, const QStringList &expected) continue; if (expectedLine.startsWith("TIMESTAMP:")) { const QString relativePath = expectedLine.mid(strlen("TIMESTAMP:")); - const quint64 timeStamp = QFileInfo(relativePath).lastModified().toMSecsSinceEpoch(); + const QFileInfo fi(timeStampPath + QLatin1Char('/') + relativePath); + if (!fi.isFile()) { + ba.append("File " + fi.absoluteFilePath().toUtf8() + " does not exist!"); + break; + } + const quint64 timeStamp = quint64(fi.lastModified().toMSecsSinceEpoch()); expectedLine.clear(); for (int shift = 56; shift >= 0; shift -= 8) { expectedLine.append(QLatin1String("0x")); @@ -141,7 +136,7 @@ static QString doCompare(const QStringList &actual, const QStringList &expected) } } if (expectedLine != actual.at(i)) { - qDebug() << "LINES" << i << "DIFFER"; + qDebug() << "LINES" << (i + 1) << "DIFFER"; ba.append( "\n<<<<<< actual\n" + actual.at(i) + "\n======\n" + expectedLine + "\n>>>>>> expected\n" @@ -157,38 +152,42 @@ void tst_rcc::rcc_data() QTest::addColumn("qrcfile"); QTest::addColumn("expected"); - const QString imagesPath = m_dataPath + QLatin1String("/images/"); + const QString imagesPath = m_dataPath + QLatin1String("/images"); QTest::newRow("images") << imagesPath << "images.qrc" << "images.expected"; - const QString sizesPath = m_dataPath + QLatin1String("/sizes/"); + const QString sizesPath = m_dataPath + QLatin1String("/sizes"); QTest::newRow("size-0") << sizesPath << "size-0.qrc" << "size-0.expected"; QTest::newRow("size-1") << sizesPath << "size-1.qrc" << "size-1.expected"; QTest::newRow("size-2-0-35-1") << sizesPath << "size-2-0-35-1.qrc" << "size-2-0-35-1.expected"; } +static QStringList readLinesFromFile(const QString &fileName, + QString::SplitBehavior splitBehavior) +{ + QFile file(fileName); + + bool ok = file.open(QIODevice::ReadOnly | QIODevice::Text); + if (!ok) { + QWARN(qPrintable(QString::fromLatin1("Could not open testdata file %1: %2") + .arg(fileName, file.errorString()))); + } + + return QString::fromUtf8(file.readAll()).split(QLatin1Char('\n'), splitBehavior); +} + void tst_rcc::rcc() { QFETCH(QString, directory); QFETCH(QString, qrcfile); QFETCH(QString, expected); - if (!QDir::setCurrent(directory)) { - QString message = QString::fromLatin1("Unable to cd from '%1' to '%2'").arg(QDir::currentPath(), directory); - QFAIL(qPrintable(message)); - } - // If the file expectedoutput.txt exists, compare the // console output with the content of that file - const QString expected2 = findExpectedFile(expected); - QFile expectedFile(expected2); - if (!expectedFile.exists()) { - qDebug() << "NO EXPECTATIONS? " << expected2; - return; - } // Launch; force no compression, otherwise the output would be different // depending on the compression algorithm we're using QProcess process; + process.setWorkingDirectory(directory); process.start(m_rcc, { "-no-compress", qrcfile }); QVERIFY2(process.waitForStarted(), msgProcessStartFailed(process).constData()); if (!process.waitForFinished()) { @@ -212,31 +211,20 @@ void tst_rcc::rcc() const QChar nl = QLatin1Char('\n'); const QStringList actualLines = out.split(nl); - QVERIFY(expectedFile.open(QIODevice::ReadOnly|QIODevice::Text)); - const QStringList expectedLines = QString::fromLatin1(expectedFile.readAll()).split(nl); + const QStringList expectedLines = + readLinesFromFile(directory + QLatin1Char('/') + expected, QString::KeepEmptyParts); + QVERIFY(!expectedLines.isEmpty()); - const QString diff = doCompare(actualLines, expectedLines); + const QString diff = doCompare(actualLines, expectedLines, directory); if (diff.size()) QFAIL(qPrintable(diff)); } -static QStringList readLinesFromFile(const QString &fileName) -{ - QFile file(fileName); - - bool ok = file.open(QIODevice::ReadOnly | QIODevice::Text); - if (!ok) - QWARN(qPrintable(QString::fromLatin1("Could not open testdata file %1: %2").arg(fileName, file.errorString()))); - - QStringList lines = QString::fromUtf8(file.readAll()).split(QLatin1Char('\n'), QString::SkipEmptyParts); - return lines; -} - static QStringMap readExpectedFiles(const QString &fileName) { QStringMap expectedFiles; - QStringList lines = readLinesFromFile(fileName); + QStringList lines = readLinesFromFile(fileName, QString::SkipEmptyParts); foreach (const QString &line, lines) { QString resourceFileName = line.section(QLatin1Char(' '), 0, 0, QString::SectionSkipEmpty); QString actualFileName = line.section(QLatin1Char(' '), 1, 1, QString::SectionSkipEmpty); @@ -302,7 +290,7 @@ void tst_rcc::binary_data() QString localeFileName = absoluteBaseName + QLatin1String(".locale"); QFile localeFile(localeFileName); if (localeFile.exists()) { - QStringList locales = readLinesFromFile(localeFileName); + QStringList locales = readLinesFromFile(localeFileName, QString::SkipEmptyParts); foreach (const QString &locale, locales) { QString expectedFileName = QString::fromLatin1("%1.%2.%3").arg(absoluteBaseName, locale, QLatin1String("expected")); QStringMap expectedFiles = readExpectedFiles(expectedFileName); From ef840bef5c436a27ac69b063c548c35b00048ac5 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Tue, 5 Mar 2019 11:49:25 +0100 Subject: [PATCH 073/292] SecureTransport - make 'securetransport' feature public MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Given the current feature disparity, it makes sense to give our users ability to detect if they can use some feature or not in their application code, using our 'modern' QT_CONFIG(securetransport). Accordingly, use this new syntax in our own auto-tests. Change-Id: Ib33b03e7e602e9f8b0db8251377c89dbaada1049 Reviewed-by: Mårten Nordheim Reviewed-by: Timur Pocheptsov --- src/network/configure.json | 2 +- .../network/ssl/qsslcertificate/tst_qsslcertificate.cpp | 6 +++--- tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/network/configure.json b/src/network/configure.json index 2bccd35dc5..be9e35c7fe 100644 --- a/src/network/configure.json +++ b/src/network/configure.json @@ -270,7 +270,7 @@ "disable": "input.securetransport == 'no' || input.ssl == 'no'", "condition": "config.darwin && (input.openssl == '' || input.openssl == 'no')", "output": [ - "privateFeature", + "publicFeature", { "type": "define", "name": "QT_SECURETRANSPORT" } ] }, diff --git a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp index 88be13f41d..0c8535f2de 100644 --- a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp @@ -814,7 +814,7 @@ void tst_QSslCertificate::task256066toPem() void tst_QSslCertificate::nulInCN() { -#if defined(QT_SECURETRANSPORT) || defined(Q_OS_WINRT) || QT_CONFIG(schannel) +#if QT_CONFIG(securetransport) || defined(Q_OS_WINRT) || QT_CONFIG(schannel) QSKIP("Generic QSslCertificatePrivate fails this test"); #endif QList certList = @@ -833,7 +833,7 @@ void tst_QSslCertificate::nulInCN() void tst_QSslCertificate::nulInSan() { -#if defined(QT_SECURETRANSPORT) || defined(Q_OS_WINRT) || QT_CONFIG(schannel) +#if QT_CONFIG(securetransport) || defined(Q_OS_WINRT) || QT_CONFIG(schannel) QSKIP("Generic QSslCertificatePrivate fails this test"); #endif QList certList = @@ -968,7 +968,7 @@ void tst_QSslCertificate::subjectAndIssuerAttributes() void tst_QSslCertificate::verify() { -#ifdef QT_SECURETRANSPORT +#if QT_CONFIG(securetransport) QSKIP("Not implemented in SecureTransport"); #endif QList errors; diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index 1c27901844..0251f3da13 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -3255,14 +3255,14 @@ void tst_QSslSocket::verifyClientCertificate_data() void tst_QSslSocket::verifyClientCertificate() { -#ifdef QT_SECURETRANSPORT +#if QT_CONFIG(securetransport) // We run both client and server on the same machine, // this means, client can update keychain with client's certificates, // and server later will use the same certificates from the same // keychain thus making tests fail (wrong number of certificates, // success instead of failure etc.). QSKIP("This test can not work with Secure Transport"); -#endif +#endif // QT_CONFIG(securetransport) #ifdef Q_OS_WINRT QSKIP("Server-side encryption is not implemented on WinRT."); #endif @@ -3344,7 +3344,7 @@ void tst_QSslSocket::verifyClientCertificate() void tst_QSslSocket::readBufferMaxSize() { -#if defined(QT_SECURETRANSPORT) || QT_CONFIG(schannel) +#if QT_CONFIG(securetransport) || QT_CONFIG(schannel) // QTBUG-55170: // SecureTransport back-end was ignoring read-buffer // size limit, resulting (potentially) in a constantly @@ -3401,7 +3401,7 @@ void tst_QSslSocket::readBufferMaxSize() QCOMPARE(client->bytesAvailable() + readSoFar, message.size()); #else // Not needed, QSslSocket works correctly with other back-ends. -#endif +#endif // QT_CONFIG(securetransport) || QT_CONFIG(schannel) } void tst_QSslSocket::setEmptyDefaultConfiguration() // this test should be last, as it has some side effects From 1af234f24e1bdf5812f5b7addb5c83094b00a1bf Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 6 Mar 2019 10:16:43 +0100 Subject: [PATCH 074/292] QSslKey - clean up the code a bit (SecureTransport) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To get rid of different warnings (visible in qt-creator at least). Change-Id: Ic7b57cbd56494704eda3f0616fcd901a8fab63db Reviewed-by: Edward Welbourne Reviewed-by: Mårten Nordheim --- src/network/ssl/qsslkey_mac.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/network/ssl/qsslkey_mac.cpp b/src/network/ssl/qsslkey_mac.cpp index d460cbfdab..b0f726a2e6 100644 --- a/src/network/ssl/qsslkey_mac.cpp +++ b/src/network/ssl/qsslkey_mac.cpp @@ -42,7 +42,9 @@ #include -QT_USE_NAMESPACE +#include + +QT_BEGIN_NAMESPACE static QByteArray wrapCCCrypt(CCOperation ccOp, QSslKeyPrivate::Cipher cipher, @@ -69,12 +71,12 @@ static QByteArray wrapCCCrypt(CCOperation ccOp, QByteArray plain(data.size() + blockSize, 0); CCCryptorStatus status = CCCrypt( ccOp, ccAlgorithm, kCCOptionPKCS7Padding, - key.constData(), key.size(), + key.constData(), std::size_t(key.size()), iv.constData(), - data.constData(), data.size(), - plain.data(), plain.size(), &plainLength); + data.constData(), std::size_t(data.size()), + plain.data(), std::size_t(plain.size()), &plainLength); if (status == kCCSuccess) - return plain.left(plainLength); + return plain.left(int(plainLength)); return QByteArray(); } @@ -87,3 +89,5 @@ QByteArray QSslKeyPrivate::encrypt(Cipher cipher, const QByteArray &data, const { return wrapCCCrypt(kCCEncrypt, cipher, data, key, iv); } + +QT_END_NAMESPACE From de1e15af4460c164913cba00686b1e78bb6c2c9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Mon, 5 Nov 2018 13:44:30 +0100 Subject: [PATCH 075/292] Add support for C++ functions attributes in moc Done-with: Ryan Chu Change-Id: Id7f2ba35ccea79e0a0c316ca2736101b8cd57f97 Fixes: QTBUG-58628 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/tools/moc/moc.cpp | 20 +++++++-- src/tools/moc/moc.h | 2 + tests/auto/tools/moc/cxx-attributes.h | 60 +++++++++++++++++++++++++++ tests/auto/tools/moc/moc.pro | 3 +- tests/auto/tools/moc/tst_moc.cpp | 20 +++++++++ 5 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 tests/auto/tools/moc/cxx-attributes.h diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index c82a6d71ae..d811bf09f0 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -159,6 +159,7 @@ Type Moc::parseType() bool isVoid = false; type.firstToken = lookup(); for (;;) { + skipCxxAttributes(); switch (next()) { case SIGNED: case UNSIGNED: @@ -188,8 +189,11 @@ Type Moc::parseType() } break; } + + skipCxxAttributes(); test(ENUM) || test(CLASS) || test(STRUCT); for(;;) { + skipCxxAttributes(); switch (next()) { case IDENTIFIER: // void mySlot(unsigned myArg) @@ -356,6 +360,15 @@ bool Moc::testFunctionAttribute(Token tok, FunctionDef *def) return false; } +bool Moc::skipCxxAttributes() +{ + auto rewind = index; + if (test(LBRACK) && test(LBRACK) && until(RBRACK) && test(RBRACK)) + return true; + index = rewind; + return false; +} + bool Moc::testFunctionRevision(FunctionDef *def) { if (test(Q_REVISION_TOKEN)) { @@ -381,7 +394,7 @@ bool Moc::parseFunction(FunctionDef *def, bool inMacro) //skip modifiers and attributes while (test(INLINE) || (test(STATIC) && (def->isStatic = true) == true) || (test(VIRTUAL) && (def->isVirtual = true) == true) //mark as virtual - || testFunctionAttribute(def) || testFunctionRevision(def)) {} + || skipCxxAttributes() || testFunctionAttribute(def) || testFunctionRevision(def)) {} bool templateFunction = (lookup() == TEMPLATE); def->type = parseType(); if (def->type.name.isEmpty()) { @@ -454,10 +467,11 @@ bool Moc::parseFunction(FunctionDef *def, bool inMacro) until(RBRACE); else if ((def->isAbstract = test(EQ))) until(SEMIC); + else if (skipCxxAttributes()) + until(SEMIC); else error(); } - if (scopedFunctionName) { const QByteArray msg = "Function declaration " + def->name + " contains extra qualification. Ignoring as signal or slot."; @@ -475,7 +489,7 @@ bool Moc::parseMaybeFunction(const ClassDef *cdef, FunctionDef *def) //skip modifiers and attributes while (test(EXPLICIT) || test(INLINE) || (test(STATIC) && (def->isStatic = true) == true) || (test(VIRTUAL) && (def->isVirtual = true) == true) //mark as virtual - || testFunctionAttribute(def) || testFunctionRevision(def)) {} + || skipCxxAttributes() || testFunctionAttribute(def) || testFunctionRevision(def)) {} bool tilde = test(TILDE); def->type = parseType(); if (def->type.name.isEmpty()) diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h index 54f935a8da..2bba8a5bb9 100644 --- a/src/tools/moc/moc.h +++ b/src/tools/moc/moc.h @@ -257,6 +257,8 @@ public: bool testFunctionAttribute(Token tok, FunctionDef *def); bool testFunctionRevision(FunctionDef *def); + bool skipCxxAttributes(); + void checkSuperClasses(ClassDef *def); void checkProperties(ClassDef* cdef); }; diff --git a/tests/auto/tools/moc/cxx-attributes.h b/tests/auto/tools/moc/cxx-attributes.h new file mode 100644 index 0000000000..719f31e23c --- /dev/null +++ b/tests/auto/tools/moc/cxx-attributes.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** 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 CXXATTRIBUTE_H +#define CXXATTRIBUTE_H + +#include + +class CppAttribute : public QObject +{ + Q_OBJECT +signals: + [[deprecated]] void deprecatedSignal(); + +public slots: + [[deprecated]] void deprecatedSlot() {} + [[deprecated]] [[tst_moc::maybe_unused]] int deprecatedSlot2() { return 42; } + [[deprecated("reason")]] void deprecatedReason() {} + [[deprecated("reason[")]] void deprecatedReasonWithLBRACK() {} + [[deprecated("reason[[")]] void deprecatedReasonWith2LBRACK() {} + [[deprecated("reason]")]] void deprecatedReasonWithRBRACK() {} + [[deprecated("reason]]")]] void deprecatedReasonWith2RBRACK() {} + void slotWithArguments([[tst_moc::maybe_unused]] int) {} +#if !defined(_MSC_VER) || _MSC_VER >= 1912 + // On MSVC it causes: + // moc_cxx-attributes.cpp(133): fatal error C1001: An internal error has occurred in the compiler. + Q_INVOKABLE [[tst_moc::noreturn]] void noreturnSlot() { throw "unused"; } + [[tst_moc::noreturn]] Q_SCRIPTABLE void noreturnSlot2() { throw "unused"; } + [[deprecated]] int returnInt() { return 0; } + Q_SLOT [[tst_moc::noreturn]] [[deprecated]] void noreturnDeprecatedSlot() { throw "unused"; } + Q_INVOKABLE void noreturnSlot3() [[tst_moc::noreturn]] { throw "unused"; } +#endif +}; + +#endif // CXXATTRIBUTE_H diff --git a/tests/auto/tools/moc/moc.pro b/tests/auto/tools/moc/moc.pro index 3cbc9ebb5e..ad8c093add 100644 --- a/tests/auto/tools/moc/moc.pro +++ b/tests/auto/tools/moc/moc.pro @@ -29,7 +29,8 @@ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-n non-gadget-parent-class.h grand-parent-gadget-class.h \ related-metaobjects-in-gadget.h \ related-metaobjects-name-conflict.h \ - namespace.h cxx17-namespaces.h + namespace.h cxx17-namespaces.h \ + cxx-attributes.h if(*-g++*|*-icc*|*-clang*|*-llvm):!win32-*: HEADERS += os9-newlines.h win-newlines.h diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 0acc90fd11..4e5d902aa2 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -71,6 +71,7 @@ #include "grand-parent-gadget-class.h" #include "namespace.h" #include "cxx17-namespaces.h" +#include "cxx-attributes.h" #ifdef Q_MOC_RUN // check that moc can parse these constructs, they are being used in Windows winsock2.h header @@ -703,6 +704,7 @@ private slots: void optionsFileError(); void testQNamespace(); void cxx17Namespaces(); + void cxxAttributes(); signals: void sigWithUnsignedArg(unsigned foo); @@ -3908,6 +3910,24 @@ void tst_Moc::cxx17Namespaces() QCOMPARE(QMetaEnum::fromType().value(0), 3); } +void tst_Moc::cxxAttributes() +{ + auto so = CppAttribute::staticMetaObject; + QCOMPARE(so.className(), "CppAttribute"); + QCOMPARE(so.enumeratorCount(), 0); + QVERIFY(so.indexOfSignal("deprecatedSignal") != 1); + for (auto a: {"deprecatedSlot", "deprecatedSlot2", "deprecatedReason", "deprecatedReasonWithLBRACK", + "deprecatedReasonWith2LBRACK", "deprecatedReasonWithRBRACK", "deprecatedReasonWith2RBRACK", + "slotWithArguments" +#if !defined(_MSC_VER) || _MSC_VER >= 1912 + , "noreturnSlot", "noreturnSlot2", "returnInt", "noreturnDeprecatedSlot", + "noreturnSlot3" +#endif + }) { + QVERIFY(so.indexOfSlot(a) != 1); + } +} + QTEST_MAIN(tst_Moc) // the generated code must compile with QT_NO_KEYWORDS From f91aae6397378f7f86a3dd320f4e2caa3843a5de Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 1 Mar 2019 12:55:13 +0100 Subject: [PATCH 076/292] rcc: Support Python as output format Start with rcc -g python|python2 $name.qrc. [ChangeLog][rcc] Added support for Python as output format. Done-with: Friedemann Kleint Fixes: PYSIDE-855 Change-Id: I97a642c3721d6d95b7cd0972d21abb0b2752fd4f Reviewed-by: hjk Reviewed-by: Cristian Maureira-Fredes --- src/tools/rcc/main.cpp | 19 ++ src/tools/rcc/rcc.cpp | 201 +++++++++++++++--- src/tools/rcc/rcc.h | 3 +- .../data/sizes/size-2-0-35-1_python.expected | 68 ++++++ tests/auto/tools/rcc/tst_rcc.cpp | 41 ++++ 5 files changed, 306 insertions(+), 26 deletions(-) create mode 100644 tests/auto/tools/rcc/data/sizes/size-2-0-35-1_python.expected diff --git a/src/tools/rcc/main.cpp b/src/tools/rcc/main.cpp index 6e8c13be15..0eb6766b5a 100644 --- a/src/tools/rcc/main.cpp +++ b/src/tools/rcc/main.cpp @@ -155,6 +155,11 @@ int runRcc(int argc, char *argv[]) QCommandLineOption binaryOption(QStringLiteral("binary"), QStringLiteral("Output a binary file for use as a dynamic resource.")); parser.addOption(binaryOption); + QCommandLineOption generatorOption(QStringList{QStringLiteral("g"), QStringLiteral("generator")}); + generatorOption.setDescription(QStringLiteral("Select generator.")); + generatorOption.setValueName(QStringLiteral("cpp|python|python2")); + parser.addOption(generatorOption); + QCommandLineOption passOption(QStringLiteral("pass"), QStringLiteral("Pass number for big resources"), QStringLiteral("number")); parser.addOption(passOption); @@ -220,6 +225,18 @@ int runRcc(int argc, char *argv[]) library.setCompressThreshold(parser.value(thresholdOption).toInt()); if (parser.isSet(binaryOption)) library.setFormat(RCCResourceLibrary::Binary); + if (parser.isSet(generatorOption)) { + auto value = parser.value(generatorOption); + if (value == QLatin1String("cpp")) + library.setFormat(RCCResourceLibrary::C_Code); + else if (value == QLatin1String("python")) + library.setFormat(RCCResourceLibrary::Python3_Code); + else if (value == QLatin1String("python2")) + library.setFormat(RCCResourceLibrary::Python2_Code); + else + errorMsg = QLatin1String("Invalid generator: ") + value; + } + if (parser.isSet(passOption)) { if (parser.value(passOption) == QLatin1String("1")) library.setFormat(RCCResourceLibrary::Pass1); @@ -280,6 +297,8 @@ int runRcc(int argc, char *argv[]) switch (library.format()) { case RCCResourceLibrary::C_Code: case RCCResourceLibrary::Pass1: + case RCCResourceLibrary::Python3_Code: + case RCCResourceLibrary::Python2_Code: mode = QIODevice::WriteOnly | QIODevice::Text; break; case RCCResourceLibrary::Pass2: diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp index 862e574f2d..704c336860 100644 --- a/src/tools/rcc/rcc.cpp +++ b/src/tools/rcc/rcc.cpp @@ -68,6 +68,17 @@ enum { #define writeString(s) write(s, sizeof(s)) +static const char pythonHeader1[] = +R"(# Created by: object code +# Created by: The Resource Compiler for Qt version )"; + +static const char pythonHeader2[] = R"( +# WARNING! All changes made in this file will be lost! + +from PySide2 import QtCore + +)"; + void RCCResourceLibrary::write(const char *str, int len) { --len; // trailing \0 on string literals... @@ -176,6 +187,8 @@ void RCCFileInfo::writeDataInfo(RCCResourceLibrary &lib) { const bool text = lib.m_format == RCCResourceLibrary::C_Code; const bool pass1 = lib.m_format == RCCResourceLibrary::Pass1; + const bool python = lib.m_format == RCCResourceLibrary::Python3_Code + || lib.m_format == RCCResourceLibrary::Python2_Code; //some info if (text || pass1) { if (m_language != QLocale::C) { @@ -222,6 +235,8 @@ void RCCFileInfo::writeDataInfo(RCCResourceLibrary &lib) } if (text || pass1) lib.writeChar('\n'); + else if (python) + lib.writeString("\\\n"); if (lib.formatVersion() >= 2) { // last modified time stamp @@ -236,6 +251,8 @@ void RCCFileInfo::writeDataInfo(RCCResourceLibrary &lib) lib.writeNumber8(lastmod); if (text || pass1) lib.writeChar('\n'); + else if (python) + lib.writeString("\\\n"); } } @@ -246,6 +263,8 @@ qint64 RCCFileInfo::writeDataBlob(RCCResourceLibrary &lib, qint64 offset, const bool pass1 = lib.m_format == RCCResourceLibrary::Pass1; const bool pass2 = lib.m_format == RCCResourceLibrary::Pass2; const bool binary = lib.m_format == RCCResourceLibrary::Binary; + const bool python = lib.m_format == RCCResourceLibrary::Python3_Code + || lib.m_format == RCCResourceLibrary::Python2_Code; //capture the offset m_dataOffset = offset; @@ -343,20 +362,24 @@ qint64 RCCFileInfo::writeDataBlob(RCCResourceLibrary &lib, qint64 offset, } // write the length - - if (text || binary || pass2) + if (text || binary || pass2 || python) lib.writeNumber4(data.size()); if (text || pass1) lib.writeString("\n "); + else if (python) + lib.writeString("\\\n"); offset += 4; // write the payload const char *p = data.constData(); - if (text) { + if (text || python) { for (int i = data.size(), j = 0; --i >= 0; --j) { lib.writeHex(*p++); if (j == 0) { - lib.writeString("\n "); + if (text) + lib.writeString("\n "); + else + lib.writeString("\\\n"); j = 16; } } @@ -368,6 +391,9 @@ qint64 RCCFileInfo::writeDataBlob(RCCResourceLibrary &lib, qint64 offset, // done if (text || pass1) lib.writeString("\n "); + else if (python) + lib.writeString("\\\n"); + return offset; } @@ -375,6 +401,8 @@ qint64 RCCFileInfo::writeDataName(RCCResourceLibrary &lib, qint64 offset) { const bool text = lib.m_format == RCCResourceLibrary::C_Code; const bool pass1 = lib.m_format == RCCResourceLibrary::Pass1; + const bool python = lib.m_format == RCCResourceLibrary::Python3_Code + || lib.m_format == RCCResourceLibrary::Python2_Code; // capture the offset m_nameOffset = offset; @@ -390,12 +418,16 @@ qint64 RCCFileInfo::writeDataName(RCCResourceLibrary &lib, qint64 offset) lib.writeNumber2(m_name.length()); if (text || pass1) lib.writeString("\n "); + else if (python) + lib.writeString("\\\n"); offset += 2; // write the hash lib.writeNumber4(qt_hash(m_name)); if (text || pass1) lib.writeString("\n "); + else if (python) + lib.writeString("\\\n"); offset += 4; // write the m_name @@ -404,12 +436,17 @@ qint64 RCCFileInfo::writeDataName(RCCResourceLibrary &lib, qint64 offset) lib.writeNumber2(unicode[i].unicode()); if ((text || pass1) && i % 16 == 0) lib.writeString("\n "); + else if (python && i % 16 == 0) + lib.writeString("\\\n"); } offset += m_name.length()*2; // done if (text || pass1) lib.writeString("\n "); + else if (python) + lib.writeString("\\\n"); + return offset; } @@ -959,18 +996,37 @@ void RCCResourceLibrary::writeDecimal(int value) write(buf, n + 1); // write() takes a size including terminating NUL } +static const char hexDigits[] = "0123456789abcdef"; + +inline void RCCResourceLibrary::write2HexDigits(quint8 number) +{ + writeChar(hexDigits[number >> 4]); + writeChar(hexDigits[number & 0xf]); +} + void RCCResourceLibrary::writeHex(quint8 tmp) { - const char digits[] = "0123456789abcdef"; - writeChar('0'); - writeChar('x'); - if (tmp < 16) { - writeChar(digits[tmp]); - } else { - writeChar(digits[tmp >> 4]); - writeChar(digits[tmp & 0xf]); + switch (m_format) { + case RCCResourceLibrary::Python3_Code: + case RCCResourceLibrary::Python2_Code: + if (tmp >= 32 && tmp < 127 && tmp != '"' && tmp != '\\') { + writeChar(char(tmp)); + } else { + writeChar('\\'); + writeChar('x'); + write2HexDigits(tmp); + } + break; + default: + writeChar('0'); + writeChar('x'); + if (tmp < 16) + writeChar(hexDigits[tmp]); + else + write2HexDigits(tmp); + writeChar(','); + break; } - writeChar(','); } void RCCResourceLibrary::writeNumber2(quint16 number) @@ -1038,7 +1094,9 @@ void RCCResourceLibrary::writeNumber8(quint64 number) bool RCCResourceLibrary::writeHeader() { - if (m_format == C_Code || m_format == Pass1) { + switch (m_format) { + case C_Code: + case Pass1: writeString("/****************************************************************************\n"); writeString("** Resource object code\n"); writeString("**\n"); @@ -1047,7 +1105,17 @@ bool RCCResourceLibrary::writeHeader() writeString("\n**\n"); writeString("** WARNING! All changes made in this file will be lost!\n"); writeString( "*****************************************************************************/\n\n"); - } else if (m_format == Binary) { + break; + case Python3_Code: + case Python2_Code: + writeString("# Resource object code (Python "); + writeChar(m_format == Python3_Code ? '3' : '2'); + writeString(")\n"); + writeString(pythonHeader1); + writeByteArray(QT_VERSION_STR); + writeString(pythonHeader2); + break; + case Binary: writeString("qres"); writeNumber4(0); writeNumber4(0); @@ -1055,6 +1123,9 @@ bool RCCResourceLibrary::writeHeader() writeNumber4(0); if (m_formatVersion >= 3) writeNumber4(m_overallFlags); + break; + default: + break; } return true; } @@ -1062,10 +1133,21 @@ bool RCCResourceLibrary::writeHeader() bool RCCResourceLibrary::writeDataBlobs() { Q_ASSERT(m_errorDevice); - if (m_format == C_Code) { + switch (m_format) { + case C_Code: writeString("static const unsigned char qt_resource_data[] = {\n"); - } else if (m_format == Binary) { + break; + case Python3_Code: + writeString("qt_resource_data = b\"\\\n"); + break; + case Python2_Code: + writeString("qt_resource_data = \"\\\n"); + break; + case Binary: m_dataOffset = m_out.size(); + break; + default: + break; } if (!m_root) @@ -1091,24 +1173,46 @@ bool RCCResourceLibrary::writeDataBlobs() } } } - if (m_format == C_Code) + switch (m_format) { + case C_Code: writeString("\n};\n\n"); - else if (m_format == Pass1) { + break; + case Python3_Code: + case Python2_Code: + writeString("\"\n\n"); + break; + case Pass1: if (offset < 8) offset = 8; writeString("\nstatic const unsigned char qt_resource_data["); writeByteArray(QByteArray::number(offset)); writeString("] = { 'Q', 'R', 'C', '_', 'D', 'A', 'T', 'A' };\n\n"); + break; + default: + break; } return true; } bool RCCResourceLibrary::writeDataNames() { - if (m_format == C_Code || m_format == Pass1) + switch (m_format) { + case C_Code: + case Pass1: writeString("static const unsigned char qt_resource_name[] = {\n"); - else if (m_format == Binary) + break; + case Python3_Code: + writeString("qt_resource_name = b\"\\\n"); + break; + case Python2_Code: + writeString("qt_resource_name = \"\\\n"); + break; + case Binary: m_namesOffset = m_out.size(); + break; + default: + break; + } QHash names; QStack pending; @@ -1133,8 +1237,18 @@ bool RCCResourceLibrary::writeDataNames() } } } - if (m_format == C_Code || m_format == Pass1) + switch (m_format) { + case C_Code: + case Pass1: writeString("\n};\n\n"); + break; + case Python3_Code: + case Python2_Code: + writeString("\"\n\n"); + break; + default: + break; + } return true; } @@ -1149,10 +1263,24 @@ struct qt_rcc_compare_hash bool RCCResourceLibrary::writeDataStructure() { - if (m_format == C_Code || m_format == Pass1) + switch (m_format) { + case C_Code: + case Pass1: writeString("static const unsigned char qt_resource_struct[] = {\n"); - else if (m_format == Binary) + break; + case Python3_Code: + writeString("qt_resource_struct = b\"\\\n"); + break; + case Python2_Code: + writeString("qt_resource_struct = \"\\\n"); + break; + case Binary: m_treeOffset = m_out.size(); + break; + default: + break; + } + QStack pending; if (!m_root) @@ -1196,8 +1324,18 @@ bool RCCResourceLibrary::writeDataStructure() pending.push(child); } } - if (m_format == C_Code || m_format == Pass1) + switch (m_format) { + case C_Code: + case Pass1: writeString("\n};\n\n"); + break; + case Python3_Code: + case Python2_Code: + writeString("\"\n\n"); + break; + default: + break; + } return true; } @@ -1387,6 +1525,19 @@ bool RCCResourceLibrary::writeInitializer() p[i++] = (m_overallFlags >> 8) & 0xff; p[i++] = (m_overallFlags >> 0) & 0xff; } + } else if (m_format == Python3_Code || m_format == Python2_Code) { + writeString(R"(def qInitResources(): + QtCore.qRegisterResourceData(0x)"); + write2HexDigits(m_formatVersion); + writeString(R"(, qt_resource_struct, qt_resource_name, qt_resource_data) + +def qCleanupResources(): + QtCore.qUnregisterResourceData(0x)"); + write2HexDigits(m_formatVersion); + writeString(R"(, qt_resource_struct, qt_resource_name, qt_resource_data) + +qInitResources() +)"); } return true; } diff --git a/src/tools/rcc/rcc.h b/src/tools/rcc/rcc.h index ad1c5cd166..b301355e4f 100644 --- a/src/tools/rcc/rcc.h +++ b/src/tools/rcc/rcc.h @@ -58,7 +58,7 @@ public: bool readFiles(bool listMode, QIODevice &errorDevice); - enum Format { Binary, C_Code, Pass1, Pass2 }; + enum Format { Binary, C_Code, Pass1, Pass2, Python3_Code, Python2_Code }; void setFormat(Format f) { m_format = f; } Format format() const { return m_format; } @@ -136,6 +136,7 @@ private: void writeAddNamespaceFunction(const QByteArray &name); void writeDecimal(int value); void writeHex(quint8 number); + void write2HexDigits(quint8 number); void writeNumber2(quint16 number); void writeNumber4(quint32 number); void writeNumber8(quint64 number); diff --git a/tests/auto/tools/rcc/data/sizes/size-2-0-35-1_python.expected b/tests/auto/tools/rcc/data/sizes/size-2-0-35-1_python.expected new file mode 100644 index 0000000000..9dcd131af5 --- /dev/null +++ b/tests/auto/tools/rcc/data/sizes/size-2-0-35-1_python.expected @@ -0,0 +1,68 @@ +# Resource object code (Python 3) +# Created by: object code +# Created by: The Resource Compiler for Qt version 5.14.0 +# WARNING! All changes made in this file will be lost! + +from PySide2 import QtCore + +qt_resource_data = b"\ +\x00\x00\x00\x02\ +0\ +1\ +\x00\x00\x00#\ +0\ +123456789 012345\ +6789 0123456789 \ +12\ +\x00\x00\x00\x01\ +@\ +\ +\x00\x00\x00\x00\ +\ +" + +qt_resource_name = b"\ +\x00\x04\ +\x00\x06\xa8\xa1\ +\x00d\ +\x00a\x00t\x00a\ +\x00\x0a\ +\x04\x08\x0a\xb4\ +\x00d\ +\x00a\x00t\x00a\x00-\x002\x00.\x00t\x00x\x00t\ +\x00\x0b\ +\x00\xb5Ot\ +\x00d\ +\x00a\x00t\x00a\x00-\x003\x005\x00.\x00t\x00x\x00t\ +\x00\x0a\ +\x04\x11\x0a\xb4\ +\x00d\ +\x00a\x00t\x00a\x00-\x001\x00.\x00t\x00x\x00t\ +\x00\x0a\ +\x04\x0e\x0a\xb4\ +\x00d\ +\x00a\x00t\x00a\x00-\x000\x00.\x00t\x00x\x00t\ +" + +qt_resource_struct = b"\ +\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ +\x00\x00\x00\x00\x00\x00\x00\x00\ +\x00\x00\x00\x00\x00\x02\x00\x00\x00\x04\x00\x00\x00\x02\ +\x00\x00\x00\x00\x00\x00\x00\x00\ +\x00\x00\x00(\x00\x00\x00\x00\x00\x01\x00\x00\x00\x06\ +IGNORE: (time stamp) +\x00\x00\x00\x0e\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ +IGNORE: (time stamp) +\x00\x00\x00^\x00\x00\x00\x00\x00\x01\x00\x00\x002\ +IGNORE: (time stamp) +\x00\x00\x00D\x00\x00\x00\x00\x00\x01\x00\x00\x00-\ +IGNORE: (time stamp) +" + +def qInitResources(): + QtCore.qRegisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data) + +def qCleanupResources(): + QtCore.qUnregisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data) + +qInitResources() diff --git a/tests/auto/tools/rcc/tst_rcc.cpp b/tests/auto/tools/rcc/tst_rcc.cpp index 2c63b0c770..24fd79cf19 100644 --- a/tests/auto/tools/rcc/tst_rcc.cpp +++ b/tests/auto/tools/rcc/tst_rcc.cpp @@ -89,6 +89,8 @@ private slots: void readback_data(); void readback(); + void python(); + void cleanupTestCase(); private: @@ -107,6 +109,12 @@ void tst_rcc::initTestCase() QVERIFY(!m_dataPath.isEmpty()); } + +static inline bool isPythonComment(const QString &line) +{ + return line.startsWith(QLatin1Char('#')); +} + static QString doCompare(const QStringList &actual, const QStringList &expected, const QString &timeStampPath) { @@ -116,10 +124,13 @@ static QString doCompare(const QStringList &actual, const QStringList &expected, } QByteArray ba; + const bool isPython = isPythonComment(expected.constFirst()); for (int i = 0, n = expected.size(); i != n; ++i) { QString expectedLine = expected.at(i); if (expectedLine.startsWith("IGNORE:")) continue; + if (isPython && isPythonComment(expectedLine) && isPythonComment(actual.at(i))) + continue; if (expectedLine.startsWith("TIMESTAMP:")) { const QString relativePath = expectedLine.mid(strlen("TIMESTAMP:")); const QFileInfo fi(timeStampPath + QLatin1Char('/') + relativePath); @@ -405,6 +416,36 @@ void tst_rcc::readback() QCOMPARE(resourceData, fileSystemData); } +void tst_rcc::python() +{ + const QString path = m_dataPath + QLatin1String("/sizes"); + const QString testFileRoot = path + QLatin1String("/size-2-0-35-1"); + const QString qrcFile = testFileRoot + QLatin1String(".qrc"); + const QString expectedFile = testFileRoot + QLatin1String("_python.expected"); + const QString actualFile = testFileRoot + QLatin1String(".rcc"); + + QProcess process; + process.setWorkingDirectory(path); + process.start(m_rcc, { "-g", "python", "-o", actualFile, qrcFile}); + QVERIFY2(process.waitForStarted(), msgProcessStartFailed(process).constData()); + if (!process.waitForFinished()) { + process.kill(); + QFAIL(msgProcessTimeout(process).constData()); + } + QVERIFY2(process.exitStatus() == QProcess::NormalExit, + msgProcessCrashed(process).constData()); + QVERIFY2(process.exitCode() == 0, + msgProcessFailed(process).constData()); + + const auto actualLines = readLinesFromFile(actualFile, QString::KeepEmptyParts); + QVERIFY(!actualLines.isEmpty()); + const auto expectedLines = readLinesFromFile(expectedFile, QString::KeepEmptyParts); + QVERIFY(!expectedLines.isEmpty()); + const QString diff = doCompare(actualLines, expectedLines, path); + if (!diff.isEmpty()) + QFAIL(qPrintable(diff)); +} + void tst_rcc::cleanupTestCase() { QDir dataDir(m_dataPath + QLatin1String("/binary")); From 01a54342521de9994ef54f4a01916b8782c685f6 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 4 Mar 2019 16:11:20 +0100 Subject: [PATCH 077/292] QSslKey - add a support for AES encrypted keys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit for SecureTransport backend. OpenSSL, while reading RSA/DSA, is internally calling EVP_BytesToKey that essentially does the same thing this patch does in 'deriveAesKey' and thus able to correctly decrypt whatever it first encrypted (while generating/ encrypting keys). Fixes: QTBUG-54422 Change-Id: Ia9f7599c5b19bf364c179f2abd2aab7ea5359a65 Reviewed-by: Mårten Nordheim --- src/network/ssl/qsslkey_mac.cpp | 8 +++- src/network/ssl/qsslkey_openssl.cpp | 8 ++++ src/network/ssl/qsslkey_p.h | 5 +- src/network/ssl/qsslkey_qt.cpp | 48 +++++++++++++++++++ src/network/ssl/qsslkey_schannel.cpp | 1 + .../qsslkey/rsa-with-passphrase-aes128.pem | 30 ++++++++++++ .../qsslkey/rsa-with-passphrase-aes192.pem | 30 ++++++++++++ .../qsslkey/rsa-with-passphrase-aes256.pem | 30 ++++++++++++ .../auto/network/ssl/qsslkey/tst_qsslkey.cpp | 18 +++++-- 9 files changed, 172 insertions(+), 6 deletions(-) create mode 100644 tests/auto/network/ssl/qsslkey/rsa-with-passphrase-aes128.pem create mode 100644 tests/auto/network/ssl/qsslkey/rsa-with-passphrase-aes192.pem create mode 100644 tests/auto/network/ssl/qsslkey/rsa-with-passphrase-aes256.pem diff --git a/src/network/ssl/qsslkey_mac.cpp b/src/network/ssl/qsslkey_mac.cpp index b0f726a2e6..814fe1c4bc 100644 --- a/src/network/ssl/qsslkey_mac.cpp +++ b/src/network/ssl/qsslkey_mac.cpp @@ -66,7 +66,13 @@ static QByteArray wrapCCCrypt(CCOperation ccOp, blockSize = kCCBlockSizeRC2; ccAlgorithm = kCCAlgorithmRC2; break; - }; + case QSslKeyPrivate::Aes128Cbc: + case QSslKeyPrivate::Aes192Cbc: + case QSslKeyPrivate::Aes256Cbc: + blockSize = kCCBlockSizeAES128; + ccAlgorithm = kCCAlgorithmAES; + break; + } size_t plainLength = 0; QByteArray plain(data.size() + blockSize, 0); CCCryptorStatus status = CCCrypt( diff --git a/src/network/ssl/qsslkey_openssl.cpp b/src/network/ssl/qsslkey_openssl.cpp index 99c1a39c73..dfb80bd829 100644 --- a/src/network/ssl/qsslkey_openssl.cpp +++ b/src/network/ssl/qsslkey_openssl.cpp @@ -333,6 +333,14 @@ static QByteArray doCrypt(QSslKeyPrivate::Cipher cipher, const QByteArray &data, type = q_EVP_rc2_cbc(); #endif break; + case QSslKeyPrivate::Aes128Cbc: + case QSslKeyPrivate::Aes192Cbc: + case QSslKeyPrivate::Aes256Cbc: + // Just to avoid compiler warnings/errors. OpenSSL uses a different + // codepath when reading encrypted keys, and they all correctly + // deduce the cipher and know how to derive a key. + Q_UNREACHABLE(); + break; } if (type == nullptr) diff --git a/src/network/ssl/qsslkey_p.h b/src/network/ssl/qsslkey_p.h index 06403b5479..1f2b59904a 100644 --- a/src/network/ssl/qsslkey_p.h +++ b/src/network/ssl/qsslkey_p.h @@ -105,7 +105,10 @@ public: enum Cipher { DesCbc, DesEde3Cbc, - Rc2Cbc + Rc2Cbc, + Aes128Cbc, + Aes192Cbc, + Aes256Cbc }; Q_AUTOTEST_EXPORT static QByteArray decrypt(Cipher cipher, const QByteArray &data, const QByteArray &key, const QByteArray &iv); diff --git a/src/network/ssl/qsslkey_qt.cpp b/src/network/ssl/qsslkey_qt.cpp index 5ebd8ac3bd..61251b641b 100644 --- a/src/network/ssl/qsslkey_qt.cpp +++ b/src/network/ssl/qsslkey_qt.cpp @@ -124,6 +124,37 @@ static int numberOfBits(const QByteArray &modulus) return bits; } +static QByteArray deriveAesKey(QSslKeyPrivate::Cipher cipher, const QByteArray &passPhrase, const QByteArray &iv) +{ + // This is somewhat simplified and shortened version of what OpenSSL does. + // See, for example, EVP_BytesToKey for the "algorithm" itself and elsewhere + // in their code for what they pass as arguments to EVP_BytesToKey when + // deriving encryption keys (when reading/writing pems files with encrypted + // keys). + + Q_ASSERT(iv.size() >= 8); + + QCryptographicHash hash(QCryptographicHash::Md5); + + QByteArray data(passPhrase); + data.append(iv.data(), 8); // AKA PKCS5_SALT_LEN in OpenSSL. + + hash.addData(data); + + if (cipher == QSslKeyPrivate::Aes128Cbc) + return hash.result(); + + QByteArray key(hash.result()); + hash.reset(); + hash.addData(key); + hash.addData(data); + + if (cipher == QSslKeyPrivate::Aes192Cbc) + return key.append(hash.result().constData(), 8); + + return key.append(hash.result()); +} + static QByteArray deriveKey(QSslKeyPrivate::Cipher cipher, const QByteArray &passPhrase, const QByteArray &iv) { QByteArray key; @@ -145,6 +176,10 @@ static QByteArray deriveKey(QSslKeyPrivate::Cipher cipher, const QByteArray &pas case QSslKeyPrivate::Rc2Cbc: key = hash.result(); break; + case QSslKeyPrivate::Aes128Cbc: + case QSslKeyPrivate::Aes192Cbc: + case QSslKeyPrivate::Aes256Cbc: + return deriveAesKey(cipher, passPhrase, iv); } return key; } @@ -378,6 +413,15 @@ void QSslKeyPrivate::decodePem(const QByteArray &pem, const QByteArray &passPhra cipher = DesEde3Cbc; } else if (dekInfo.first() == "RC2-CBC") { cipher = Rc2Cbc; +// TODO: Add SChannel version too! +#ifdef QT_SECURETRANSPORT + } else if (dekInfo.first() == "AES-128-CBC") { + cipher = Aes128Cbc; + } else if (dekInfo.first() == "AES-192-CBC") { + cipher = Aes192Cbc; + } else if (dekInfo.first() == "AES-256-CBC") { + cipher = Aes256Cbc; +#endif // QT_SECURETRANSPORT } else { clear(deepClear); return; @@ -554,6 +598,10 @@ static EncryptionData readPbes2(const QVector &element, const QByt return {}; break; } // @todo(?): case (RC5 , AES) + case QSslKeyPrivate::Cipher::Aes128Cbc: + case QSslKeyPrivate::Cipher::Aes192Cbc: + case QSslKeyPrivate::Cipher::Aes256Cbc: + Q_UNREACHABLE(); } if (Q_LIKELY(keyDerivationAlgorithm == PKCS5_PBKDF2_ENCRYPTION_OID)) { diff --git a/src/network/ssl/qsslkey_schannel.cpp b/src/network/ssl/qsslkey_schannel.cpp index 5694068860..9dfbc87e9a 100644 --- a/src/network/ssl/qsslkey_schannel.cpp +++ b/src/network/ssl/qsslkey_schannel.cpp @@ -57,6 +57,7 @@ const wchar_t *getName(QSslKeyPrivate::Cipher cipher) return BCRYPT_3DES_ALGORITHM; case QSslKeyPrivate::Cipher::Rc2Cbc: return BCRYPT_RC2_ALGORITHM; + default:; } Q_UNREACHABLE(); } diff --git a/tests/auto/network/ssl/qsslkey/rsa-with-passphrase-aes128.pem b/tests/auto/network/ssl/qsslkey/rsa-with-passphrase-aes128.pem new file mode 100644 index 0000000000..1a8751874e --- /dev/null +++ b/tests/auto/network/ssl/qsslkey/rsa-with-passphrase-aes128.pem @@ -0,0 +1,30 @@ +-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: AES-128-CBC,A2A6F6BA67CFB2A992BA4FD3A0984B59 + +L5G1mwcXwW30lFty1HaEHlswFXAGk9+qf0TdYYNAAvVrsTMgfMq/6xM5XWo3IgbN +gG4K6T57gQkAywn+upqMHobB+7qc3DRzYlrm89gb74gHOe95l/iUJp4ii+ROLcmY +fg/vNmDSB/D0eM91WfwId7ticYD29+BUbbnqSYyY2S7K7DytYLpXqg3u335GYCdT +JwOsgcgbOICytkgK6c9ZDF3IrkzvWospVuiG5IfpLQkUXlJO3YGJ/oGf1BXnRd/b +kTzUiimUVunX62muHaUXKkAmXS8FCdB0puI+52pzLJ5FHdFxCcnwSG09TmoXbwwa +KoNM+IshNHPBGM7QxflVbSDxDaF1FWLwWSb8+Fhb2fTpfEGMxRCQ8HB1ZeMV4E5W +DSiNhih8ziC0k957ZYv8iuLanoM1YYIdToHeBwjyBJA836eIcq/ElY2QtKUq5PRw ++sU1BdG+f9rf4iAPHpgWZAKFmJ42ya71bEEVAmfysAOPuc4hpn3SsDTtihm9RKc9 +l7LWJHaTnTu6yJA+vMJwAmPWg+IdG5vntbb93X4cgl5ZadBySRtv37wWyQPnQcFh +ytX8z2CJNIFJb0ik8bXc39zOxExoTu/o86IuVJ87jFdS1wz3PRek6dJdl15icx76 +yAT0YB2/ZlRcRrO9hSm0D6P+sLOh//dyhhFAlUrDxqrKngI3KF4kgIrSlva3wmx2 +t16SiUKu6FGQZk6/KYOV27Cy+8UJEqlrNJzy+wSFi26d6e6xWTIR2ItzQCxhYDmq +Tpx0Mh0ml2+bgrKRoDAL5z6UNy0Pc6bYQjvMznIeiuGvL8bAKTDUFwbmrZqNScsl +tW7yNZG9iSJnAZGMTxuOhSvJRpQkxIcLICd+lsUxWZ2YvFxtSORuRNSwaC7oxtTD +gIXV08ayoDbDmcguqTXWuCxtguxNANjhsUOetNHL8iP8QFrzAd5Ith9FgASCIBJJ +3X7vL2YGc3E6DlAJE01loqySU/cnu6/zQapLB9BIzdtoLliwdrJ7PS8FSsBDfZ2X +i6/7gb1jxYkJAS1NqrUMJw6BphRAwF8ny+FtPJ23Oaf+1vRIGiHsh8qw6XBfwFw9 +vtsUUL19r+8zMpvIB6gf34TLuM7AW7idu3c/486EWgZBDL3mOTd3fsyADKv/HCk7 +c8M2dsafxI6QkTlWsB8G5vkZ8lCGKHjrmPWjfD7NXi+CvXIrDY+gOeVN3PlQCU/2 +zF2vIxKtR0CXuxLzIjFhIgTYR5G5ZnddMmHeVkZdPRl7szGtrxOA4QGJQ6ZT4W2e +O1whVU2KB0aBYskhClimapM5ypRkcNQ97cUR6/iNgdgSLqxGHCGeMR9bEyLl7/wr +M0XeDjdVfm/Tj548oHgb0SKLsfL6nnKwqB2viKj81moK9A/wO1Ec9RNaw0jtp2j3 +VIUnPj0GqEjnkHc2jWY2yt4SD6e2AZHwLyWi1q3pixZo1CFiEgFXxwNyYwyeJ6jV +CJHPRzoNjZ8dkvgRjsXdnWwN316JBNVcH8k7CCmg/8Gq3yAojXG1z8VJZ06GHckd +meCL1t89OgwIAmIsysKu7+DrKtSlhkQclZmdG6IrQzuPKaHzTPTDgg3ef3jQ4YQO +-----END RSA PRIVATE KEY----- diff --git a/tests/auto/network/ssl/qsslkey/rsa-with-passphrase-aes192.pem b/tests/auto/network/ssl/qsslkey/rsa-with-passphrase-aes192.pem new file mode 100644 index 0000000000..db74877a5a --- /dev/null +++ b/tests/auto/network/ssl/qsslkey/rsa-with-passphrase-aes192.pem @@ -0,0 +1,30 @@ +-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: AES-192-CBC,B408346ADE790F8CF0C902A4F0712B34 + +SwzPBGxmwW2JddOyug1LrWjlZn8siSp5yezjK1x/z2+J2r/vvH8OjGnA387tFtae +WVTmhT1ixQXMDI1UJuKx0gzrG2449c+BUVe2VXFPLZ2ocSgoXbBpVkfhEqtLAn91 +MSOpQMxvobQKltKhxgXGvuBJwhwfT7yK5HamohFGbxLUh4Dh+NBXwoYH4Qt+kM7C +kV8VIKvkr/QAL/SRxNoY8rVResPgYvUjdtiGSNZ6CZhNRu42Q2FqbH817cE0NDsN +il/xvWu4T/6VY1KpwMad/v6BhO45EeKz7YjbF/3Y5jj2JV9r45uf79lM9htMBw0d +L+Cc3YHeFffgU8NZo0+iUoroXcb7mjWNmgYksbkaZPbLG383YXAXwbkQS7zDMVIx +QhXn9w+78hNmEV/7PQ8mGXHEFwnfSR05phXoj8IyL5v0grRMA2dsjfxCgfQjH+kc +Miwr5pD/Flw175OpPFCb2qladdTKoIWiVShspbteoRC0EuiWHzkl5z6Tneyb/sam +yduLmSYD+RA6OBgUPY95Xm4AowlFFsuV/fxYZ53rFf4cZn9Z6VBVmvIEmapV7CtB +JzyIVclocwM0ag5u/esdEt/jndJq9chZlIsDS30y3gP6Rlqk5mj90DAs98l28FVG +WY9jP0babk8mxjYCcnAy7ikUc0D+vJVO6OTmfO3dkGjLpMBM6OlvfhN/0qeXrMDI +nU2qOshUrVna2kRe6FrcvosFTD8wvQ1/BjmCp1iWWsGdc/q1BqI3pgOlgq3TYfl6 +iUJoji3V2iexH+GPkHsrs+kii1clsO2tgIP7doIooSVkcTsRTHHxKeeHn3qL2028 +pTvieIFD/T4biLZ9Q8sX3XWiHNmXZlCx8lX8MDjTavWES8gY4H5Sr6FjRMy1qpZY +5w1aAyJ9YZ0J/jLPmFxt8mWgqHPiPlrQkryBBE3l1MSQ/hCEwlf9dP8a+ayINfd7 +3yNkHKjZ5fuoA+TZUQb/fyVM5o1zJ8ML01PaXWrMEgr3b36QL+Ivo2Rpnp9FpwuH +E405cwCEy5fNSyhHFqqatCbsPl80nkP8OpW6jdWvNy9u0Ap9PS+MbHGq/pfkaazl +fbKGOckrENzEXi6Uj/yY/0sMtbTJuC70n09X3edHyhl/RJPPUoNnwDM5W1FHfS3r +qqSOl/r3y5pEErRdBpR4wEgB7DCLBALGDPfXNAAga4ez/Z2X9Zj234+4ZbUzWoLN +1ER0QYyxLN7oz1qMA15J7nRyRIhDXNlXjyISOqy26T6/d4X0M+6RhNWfT/MHAjJ8 +6ogoGlQUITV3gPO4R6+FGZMF4R6zZXuKVtOXyzRwWnCLfo4gzBHmq+5mmCjGWRq8 +rSSkc6334bYuZOaEoR5EM5sh6ewkjSDPRrKR7EHO02YbiscyT/99TwT5pdIOPK3u +2T6/40fSmCWQyBLuWxV9CMD+rB/q8Ja5KisEseck7PgI2pMmHfiD5yQXhKR9eDrB +sRqZxjgRYxup+/0CIBshL8s1R88xelhXyIKyqFfVudM09yAZxEJLQhpDZ27g45ea +FMX2Ve+ah2NjYBgzAhwKouWg5RyWb6X99NsrCEU75fn/ek86LGs3FxRgB4Uv7Udv +-----END RSA PRIVATE KEY----- diff --git a/tests/auto/network/ssl/qsslkey/rsa-with-passphrase-aes256.pem b/tests/auto/network/ssl/qsslkey/rsa-with-passphrase-aes256.pem new file mode 100644 index 0000000000..3d96b3166e --- /dev/null +++ b/tests/auto/network/ssl/qsslkey/rsa-with-passphrase-aes256.pem @@ -0,0 +1,30 @@ +-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: AES-256-CBC,0F2F4695C8FFA35F4076FA0273A3A4E3 + +GCnMcAhhGuNkJ7SSMBrgNOaDfRtG22J0mdf/0VbrMOJF40P13YBjN3Kd6LpTqBya +TCIaxQqtfjH1ffhJk8qhwG7uJFGgcY9i0dkrEYklgThzTVqHp7FsQ2jjgJs5HKpc +euuVD1bxtuc9qI2hq4miA7Z/uDe3M34n+3xcpqccWS1dLFNFZ+fIDwIazfDCu3ah +fUQHDeWLwOqYiQxhUjjrHpZkI1FE2JYZFaf4zIagIIgzI2O+33fgbrTSoeN5meRs +F7V2fhDpyEoIlchwAmp6HE6ngtKP4Ecju00yn99AO42fn097yEVwvGFClQTaIzur +aPEtuKZ4kdc/lmzL2tqNcZckq28ZxpeMq0Fgdcpeg5sDcut811scOjQLFs551On1 +j3E1WfiLoBLKgd9cgmCrZb8hMO+UjcCaV7Jv3T9vDrbvhWs/YhTTwo8UFVplh7Vx +R1h3cKfzlbtOC5WHXGNK5dBu7SnpEk0+pscY5cxTrzN0odjMbbsjZQmKDZXbmZON +USzG3Qtafm6Nw/jwQeIjeqaxSho6xGdadTteGaURw6iGio3h0c6/dHayCsxye4tk +vODa0ZdJASwVh1605qDk9n/iYUT5B46KJCYwO/iN2kUmOcUcZeBqEfV1GfRmepZJ +bwM4sipzE15hOJ5DKSkHWnSlByRMAdSrMxZWraKUczn5frEBAqEFLlBAvf/FnjWa +yZJitgryCI2Y2bww1DEMnTCX345kUQIFmmjbzTIXnM28gW+fR3Br9dCf2FAsLNKr +tru1cYXocPaCUHEqS+XZqVb6BQVQ11YAAde0+x9RknJgsBc9Y7TLobaDBvrV5/nK +T3vm8el08upum6qPTPh6Z0zBbjx4sp6DYT977N1dYeH4n+0JqcSwIeZg/VAdG0RL +GzgZVADpiRlStmy65W95KExBjbO0tRTVk/nB1U1nfLbsswp9EKxXgwtpE/ECeTOi +hzeJBSsXGZ/ZXu/y+NlIu0B/GasFbfrHKslSSrUPTjGEtaEbLNiOEu2Etu3lRcMZ +oDtMxgNR0TUgCS5nte8lLauYYfB6IuxZXpvJdcI5ushqdOJvvYgJ9Yb2ZPlY8Bt5 +C92Ga69aPcMYk24BPpe15eBbXMsFF8RF+CprVoUPCc+PcuROtxdt+rqoqjQeZPmV +WQqq+pT2bychpwD7U5jxQnu4u2m+zeBXyk80euBbwEld9BCgfk9mFj6CdBJSEiGV +qL0ivxd3mDaIKPGd5tcbrOMK2uD7duZY7FrQpAYgryoQJoUHccL7cr9fDC75akHg +AbrG1+vAYEla/y+SlOg5VTHhiuIl17ZGMViXSqh7iqnnD0dNsZ/HDvk3XouhNxQy +RQmfdqyIqLuAcfWwQxCQ2E/oMUIHjNhyYmfLVLVGsfxuevMa1eJv7rZ5vIkD2Vpe +4VveZkNDSpCCNqnvub8+bMW+UXyzbxEZbK5PLkRp7cvtKdA5CUbTlT4060IV0YZ1 +vfMtzXRw8JDD9c1F1WF14afk+y9kvZN88XOH12bSKj+Re06Xx7OzuYU8fclq/pZB +UZVtRETFnLgb8neMuz3vCoPWK/DSHDZGAAicxq7vTljyoU/QP71Dw7UJIAuYx6Mc +-----END RSA PRIVATE KEY----- diff --git a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp index d24fafb77b..195f052266 100644 --- a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp +++ b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp @@ -466,15 +466,25 @@ void tst_QSslKey::toEncryptedPemOrDer() void tst_QSslKey::passphraseChecks_data() { QTest::addColumn("fileName"); + QTest::addColumn("passphrase"); - QTest::newRow("DES") << (testDataDir + "rsa-with-passphrase-des.pem"); - QTest::newRow("3DES") << (testDataDir + "rsa-with-passphrase-3des.pem"); - QTest::newRow("RC2") << (testDataDir + "rsa-with-passphrase-rc2.pem"); + const QByteArray pass("123"); + const QByteArray aesPass("1234"); + + QTest::newRow("DES") << QString(testDataDir + "rsa-with-passphrase-des.pem") << pass; + QTest::newRow("3DES") << QString(testDataDir + "rsa-with-passphrase-3des.pem") << pass; + QTest::newRow("RC2") << QString(testDataDir + "rsa-with-passphrase-rc2.pem") << pass; +#if (!defined(QT_NO_OPENSSL) && !defined(OPENSSL_NO_AES)) || defined(QT_SECURETRANSPORT) + QTest::newRow("AES128") << QString(testDataDir + "rsa-with-passphrase-aes128.pem") << aesPass; + QTest::newRow("AES192") << QString(testDataDir + "rsa-with-passphrase-aes192.pem") << aesPass; + QTest::newRow("AES256") << QString(testDataDir + "rsa-with-passphrase-aes256.pem") << aesPass; +#endif } void tst_QSslKey::passphraseChecks() { QFETCH(QString, fileName); + QFETCH(QByteArray, passphrase); QFile keyFile(fileName); QVERIFY(keyFile.exists()); @@ -507,7 +517,7 @@ void tst_QSslKey::passphraseChecks() keyFile.open(QIODevice::ReadOnly); else keyFile.reset(); - QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey, "123"); + QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey, passphrase); QVERIFY(!key.isNull()); // correct passphrase } } From e89fbd8c3aa50a24e5fc02ab710ccca67fce98e2 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 6 Mar 2019 14:22:06 +0100 Subject: [PATCH 078/292] Add QStringView::toWCharArray() to match QString QCollator needs it to add support for QStringView. In any case, it extends the mirror of QString's API. Naturally, we can reimplement QString's version using it. Change-Id: I5a23a3f2a98c7d59597b5e935542a93764b5e350 Reviewed-by: Paul Wicking Reviewed-by: Qt CI Bot --- src/corelib/tools/qstring.cpp | 2 +- src/corelib/tools/qstring.h | 7 +------ src/corelib/tools/qstringview.cpp | 31 +++++++++++++++++++++++++++++++ src/corelib/tools/qstringview.h | 2 ++ 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 857b559aa4..da010eca0c 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -2086,7 +2086,7 @@ int QString::toUcs4_helper(const ushort *uc, int length, uint *out) \note This function does not append a null character to the array. - \sa utf16(), toUcs4(), toLatin1(), toUtf8(), toLocal8Bit(), toStdWString() + \sa utf16(), toUcs4(), toLatin1(), toUtf8(), toLocal8Bit(), toStdWString(), QStringView::toWCharArray() */ /*! \fn QString::QString(const QString &other) diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 23972d196c..e9a205dfdf 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -1021,12 +1021,7 @@ QT_WARNING_DISABLE_INTEL(111) // "statement is unreachable" inline int QString::toWCharArray(wchar_t *array) const { - if (sizeof(wchar_t) == sizeof(QChar)) { - memcpy(array, d->data(), sizeof(QChar) * size()); - return size(); - } else { - return toUcs4_helper(d->data(), size(), reinterpret_cast(array)); - } + return QStringView(*this).toWCharArray(array); } QT_WARNING_POP diff --git a/src/corelib/tools/qstringview.cpp b/src/corelib/tools/qstringview.cpp index b97e989110..c863ca7ce2 100644 --- a/src/corelib/tools/qstringview.cpp +++ b/src/corelib/tools/qstringview.cpp @@ -38,6 +38,7 @@ ****************************************************************************/ #include "qstringview.h" +#include "qstring.h" QT_BEGIN_NAMESPACE @@ -794,4 +795,34 @@ QT_BEGIN_NAMESPACE \sa QString::isRightToLeft() */ +/*! + \since 5.14 + + Transcribes this string into the given \a array. + + Caller is responsible for ensuring \a array is large enough to hold the \t + wchar_t encoding of this string (allocating the array with the same length + as the string is always sufficient). The array is encoded in UTF-16 on + platforms where \t wchar_t is 2 bytes wide (e.g. Windows); otherwise (Unix + systems), \t wchar_t is assumed to be 4 bytes wide and the data is written + in UCS-4. + + \note This function writes no null terminator to the end of \a array. + + Returns the number of \t wchar_t entries written to \a array. + + \sa QString::toWCharArray() +*/ + +int QStringView::toWCharArray(wchar_t *array) const +{ + if (sizeof(wchar_t) == sizeof(QChar)) { + memcpy(array, data(), sizeof(QChar) * size()); + return size(); + } else { + return QString::toUcs4_helper(reinterpret_cast(data()), int(size()), + reinterpret_cast(array)); + } +} + QT_END_NAMESPACE diff --git a/src/corelib/tools/qstringview.h b/src/corelib/tools/qstringview.h index 2e95c2b218..4a900b5e89 100644 --- a/src/corelib/tools/qstringview.h +++ b/src/corelib/tools/qstringview.h @@ -272,6 +272,8 @@ public: Q_REQUIRED_RESULT bool isRightToLeft() const Q_DECL_NOTHROW { return QtPrivate::isRightToLeft(*this); } + Q_REQUIRED_RESULT Q_CORE_EXPORT int toWCharArray(wchar_t *array) const; + // // STL compatibility API: // From a769ab62cbcf957d049c8da74f898527dd27b328 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 7 Dec 2018 11:52:59 +0100 Subject: [PATCH 079/292] Extend QCollator to support QStringView This enables some simplification of the existing implementations. Refined wording of the documentation in the process. [ChangeLog][QtCore][QCollator] Added support for QStringView. Change-Id: Idffaae8d109173d47c7be076828f4b58dc334957 Reviewed-by: Thiago Macieira --- src/corelib/tools/qcollator.cpp | 39 ++++++++++++++++++++++----- src/corelib/tools/qcollator.h | 6 +++++ src/corelib/tools/qcollator_icu.cpp | 35 +++++++----------------- src/corelib/tools/qcollator_macx.cpp | 18 +++---------- src/corelib/tools/qcollator_posix.cpp | 14 ++-------- src/corelib/tools/qcollator_win.cpp | 23 +++++----------- 6 files changed, 59 insertions(+), 76 deletions(-) diff --git a/src/corelib/tools/qcollator.cpp b/src/corelib/tools/qcollator.cpp index 76dcf35833..f2c9c61c99 100644 --- a/src/corelib/tools/qcollator.cpp +++ b/src/corelib/tools/qcollator.cpp @@ -278,35 +278,60 @@ bool QCollator::ignorePunctuation() const } /*! - \fn int QCollator::compare(const QString &s1, const QString &s2) const + \since 5.13 + \fn bool QCollator::operator()(QStringView s1, QStringView s2) const + \internal +*/ + +/*! + \since 5.13 + \fn int QCollator::compare(QStringView s1, QStringView s2) const Compares \a s1 with \a s2. Returns an integer less than, equal to, or greater than zero - depending on whether \a s1 is smaller, equal or larger than \a s2. + depending on whether \a s1 sorts before, with or after \a s2. */ - +#if QT_STRINGVIEW_LEVEL < 2 /*! \fn bool QCollator::operator()(const QString &s1, const QString &s2) const \internal */ /*! - \fn int QCollator::compare(const QStringRef &s1, const QStringRef &s2) const \overload Compares \a s1 with \a s2. Returns an integer less than, equal to, or greater than zero - depending on whether \a s1 is smaller, equal or larger than \a s2. + depending on whether \a s1 sorts before, with or after \a s2. */ +int QCollator::compare(const QString &s1, const QString &s2) const +{ + return compare(QStringView(s1), QStringView(s2)); +} + +/*! + \overload + + Compares \a s1 with \a s2. Returns an integer less than, equal to, or greater than zero + depending on whether \a s1 sorts before, with or after \a s2. + */ +int QCollator::compare(const QStringRef &s1, const QStringRef &s2) const +{ + return compare(QStringView(s1), QStringView(s2)); +} /*! - \fn int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) const \overload Compares \a s1 with \a s2. \a len1 and \a len2 specify the length of the QChar arrays pointer to by \a s1 and \a s2. Returns an integer less than, equal to, or greater than zero - depending on whether \a s1 is smaller, equal or larger than \a s2. + depending on whether \a s1 sorts before, with or after \a s2. */ +int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) const +{ + return compare(QStringView(s1, len1), QStringView(s2, len2)); +} +#endif // QT_STRINGVIEW_LEVEL < 2 /*! \fn QCollatorSortKey QCollator::sortKey(const QString &string) const diff --git a/src/corelib/tools/qcollator.h b/src/corelib/tools/qcollator.h index 6fa199cb0f..700de739bb 100644 --- a/src/corelib/tools/qcollator.h +++ b/src/corelib/tools/qcollator.h @@ -109,12 +109,18 @@ public: void setIgnorePunctuation(bool on); bool ignorePunctuation() const; +#if QT_STRINGVIEW_LEVEL < 2 int compare(const QString &s1, const QString &s2) const; int compare(const QStringRef &s1, const QStringRef &s2) const; int compare(const QChar *s1, int len1, const QChar *s2, int len2) const; bool operator()(const QString &s1, const QString &s2) const { return compare(s1, s2) < 0; } +#endif + int compare(QStringView s1, QStringView s2) const; + + bool operator()(QStringView s1, QStringView s2) const + { return compare(s1, s2) < 0; } QCollatorSortKey sortKey(const QString &string) const; diff --git a/src/corelib/tools/qcollator_icu.cpp b/src/corelib/tools/qcollator_icu.cpp index ab45b9a1a1..eb0ba33676 100644 --- a/src/corelib/tools/qcollator_icu.cpp +++ b/src/corelib/tools/qcollator_icu.cpp @@ -105,37 +105,20 @@ void QCollatorPrivate::cleanup() collator = nullptr; } -int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) const +int QCollator::compare(QStringView s1, QStringView s2) const { if (d->dirty) d->init(); - if (d->collator) - return ucol_strcoll(d->collator, (const UChar *)s1, len1, (const UChar *)s2, len2); + if (d->collator) { + return ucol_strcoll(d->collator, + reinterpret_cast(s1.data()), s1.size(), + reinterpret_cast(s2.data()), s2.size()); + } - return QString::compare_helper(s1, len1, s2, len2, d->caseSensitivity); -} - -int QCollator::compare(const QString &s1, const QString &s2) const -{ - if (d->dirty) - d->init(); - - if (d->collator) - return compare(s1.constData(), s1.size(), s2.constData(), s2.size()); - - return QString::compare(s1, s2, d->caseSensitivity); -} - -int QCollator::compare(const QStringRef &s1, const QStringRef &s2) const -{ - if (d->dirty) - d->init(); - - if (d->collator) - return compare(s1.constData(), s1.size(), s2.constData(), s2.size()); - - return QStringRef::compare(s1, s2, d->caseSensitivity); + return QString::compare_helper(s1.data(), s1.size(), + s2.data(), s2.size(), + d->caseSensitivity); } QCollatorSortKey QCollator::sortKey(const QString &string) const diff --git a/src/corelib/tools/qcollator_macx.cpp b/src/corelib/tools/qcollator_macx.cpp index 42e67e0c12..9998ec4cda 100644 --- a/src/corelib/tools/qcollator_macx.cpp +++ b/src/corelib/tools/qcollator_macx.cpp @@ -97,18 +97,18 @@ void QCollatorPrivate::cleanup() collator = 0; } -int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) const +int QCollator::compare(QStringView s1, QStringView s2) const { if (d->dirty) d->init(); if (!d->collator) - return QStringView(s1, len1).compare(QStringView(s2, len2), caseSensitivity()); + return s1.compare(s2, caseSensitivity()); SInt32 result; Boolean equivalent; UCCompareText(d->collator, - reinterpret_cast(s1), len1, - reinterpret_cast(s2), len2, + reinterpret_cast(s1.data()), s1.size(), + reinterpret_cast(s2.data()), s2.size(), &equivalent, &result); if (equivalent) @@ -116,16 +116,6 @@ int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) con return result < 0 ? -1 : 1; } -int QCollator::compare(const QString &str1, const QString &str2) const -{ - return compare(str1.constData(), str1.size(), str2.constData(), str2.size()); -} - -int QCollator::compare(const QStringRef &s1, const QStringRef &s2) const -{ - return compare(s1.constData(), s1.size(), s2.constData(), s2.size()); -} - QCollatorSortKey QCollator::sortKey(const QString &string) const { if (d->dirty) diff --git a/src/corelib/tools/qcollator_posix.cpp b/src/corelib/tools/qcollator_posix.cpp index 81f97a02e1..9cbc539ebe 100644 --- a/src/corelib/tools/qcollator_posix.cpp +++ b/src/corelib/tools/qcollator_posix.cpp @@ -65,7 +65,7 @@ void QCollatorPrivate::cleanup() { } -static void stringToWCharArray(QVarLengthArray &ret, const QString &string) +static void stringToWCharArray(QVarLengthArray &ret, QStringView string) { ret.resize(string.length()); int len = string.toWCharArray(ret.data()); @@ -73,12 +73,7 @@ static void stringToWCharArray(QVarLengthArray &ret, const QString &str ret[len] = 0; } -int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) const -{ - return compare(QString::fromRawData(s1, len1), QString::fromRawData(s2, len2)); -} - -int QCollator::compare(const QString &s1, const QString &s2) const +int QCollator::compare(QStringView s1, QStringView s2) const { if (d->isC()) return s1.compare(s2, caseSensitivity()); @@ -91,11 +86,6 @@ int QCollator::compare(const QString &s1, const QString &s2) const return std::wcscoll(array1.constData(), array2.constData()); } -int QCollator::compare(const QStringRef &s1, const QStringRef &s2) const -{ - return compare(s1.toString(), s2.toString()); -} - QCollatorSortKey QCollator::sortKey(const QString &string) const { if (d->dirty) diff --git a/src/corelib/tools/qcollator_win.cpp b/src/corelib/tools/qcollator_win.cpp index 35142bb8b8..9cbdd96ee0 100644 --- a/src/corelib/tools/qcollator_win.cpp +++ b/src/corelib/tools/qcollator_win.cpp @@ -85,11 +85,10 @@ void QCollatorPrivate::cleanup() { } - -int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) const +int QCollator::compare(QStringView s1, QStringView s2) const { if (d->isC()) - return QString::compare_helper(s1, len1, s2, len2, d->caseSensitivity); + return s1.compare(s2, d->caseSensitivity); if (d->dirty) d->init(); @@ -101,25 +100,15 @@ int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) con #ifndef USE_COMPARESTRINGEX return CompareString(d->localeID, d->collator, - reinterpret_cast(s1), len1, - reinterpret_cast(s2), len2) - 2; + reinterpret_cast(s1.data()), s1.size(), + reinterpret_cast(s2.data()), s2.size()) - 2; #else return CompareStringEx(LPCWSTR(d->localeName.utf16()), d->collator, - reinterpret_cast(s1), len1, - reinterpret_cast(s2), len2, NULL, NULL, 0) - 2; + reinterpret_cast(s1.data()), s1.size(), + reinterpret_cast(s2.data()), s2.size(), NULL, NULL, 0) - 2; #endif } -int QCollator::compare(const QString &str1, const QString &str2) const -{ - return compare(str1.constData(), str1.size(), str2.constData(), str2.size()); -} - -int QCollator::compare(const QStringRef &s1, const QStringRef &s2) const -{ - return compare(s1.constData(), s1.size(), s2.constData(), s2.size()); -} - QCollatorSortKey QCollator::sortKey(const QString &string) const { if (d->dirty) From cdd3bd1d2cb3f5c23159a987c19b6919f08d68b7 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 11 Dec 2018 18:01:35 +0100 Subject: [PATCH 080/292] Report status codes in warnings about API failures Also reuse the status variable, since the value saved in the one previously declared int was an OSStatus, too. Change-Id: I8e8fe308ae71df51e8057d89bc76cab0c6bbedb2 Reviewed-by: Thiago Macieira --- src/corelib/tools/qcollator_macx.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/corelib/tools/qcollator_macx.cpp b/src/corelib/tools/qcollator_macx.cpp index 9998ec4cda..ff127a041d 100644 --- a/src/corelib/tools/qcollator_macx.cpp +++ b/src/corelib/tools/qcollator_macx.cpp @@ -65,9 +65,10 @@ void QCollatorPrivate::init() return; LocaleRef localeRef; - int rc = LocaleRefFromLocaleString(QLocalePrivate::get(locale)->bcp47Name().constData(), &localeRef); - if (rc != 0) - qWarning("couldn't initialize the locale"); + OSStatus status = + LocaleRefFromLocaleString(QLocalePrivate::get(locale)->bcp47Name().constData(), &localeRef); + if (status != 0) + qWarning("Couldn't initialize the locale (%d)", int(status)); UInt32 options = 0; @@ -78,14 +79,9 @@ void QCollatorPrivate::init() if (!ignorePunctuation) options |= kUCCollatePunctuationSignificantMask; - OSStatus status = UCCreateCollator( - localeRef, - 0, - options, - &collator - ); + status = UCCreateCollator(localeRef, 0, options, &collator); if (status != 0) - qWarning("Couldn't initialize the collator"); + qWarning("Couldn't initialize the collator (%d)", int(status)); dirty = false; } From 830e06a3f8173621a99426e7da6ad9704eb701b3 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 11 Dec 2018 17:41:24 +0100 Subject: [PATCH 081/292] Clean up the QCollator code and comments Broke over-long lines. Reflowed documentation, refined a phrasing, corrected some out of date details and typos. Change-Id: Ic3835bb198bd062f85b3c466b56dc9636d4d3fe4 Reviewed-by: Paul Wicking --- src/corelib/tools/qcollator.cpp | 91 ++++++++++++++++------------ src/corelib/tools/qcollator_icu.cpp | 6 +- src/corelib/tools/qcollator_macx.cpp | 12 ++-- src/corelib/tools/qcollator_win.cpp | 11 ++-- 4 files changed, 69 insertions(+), 51 deletions(-) diff --git a/src/corelib/tools/qcollator.cpp b/src/corelib/tools/qcollator.cpp index f2c9c61c99..d73eb0d07c 100644 --- a/src/corelib/tools/qcollator.cpp +++ b/src/corelib/tools/qcollator.cpp @@ -59,20 +59,21 @@ QT_BEGIN_NAMESPACE \ingroup string-processing \ingroup shared - QCollator is initialized with a QLocale and an optional collation strategy. It tries to - initialize the collator with the specified values. The collator can then be used to compare - and sort strings in a locale dependent fashion. + QCollator is initialized with a QLocale and an optional collation strategy. + It tries to initialize the collator with the specified values. The collator + can then be used to compare and sort strings in a locale dependent fashion. - A QCollator object can be used together with template based sorting algorithms such as std::sort - to sort a list of QStrings. + A QCollator object can be used together with template based sorting + algorithms such as std::sort to sort a list of QStrings. - In addition to the locale and collation strategy, several optional flags can be set that influence - the result of the collation. + In addition to the locale and collation strategy, several optional flags can + be set that influence the result of the collation. */ /*! - Constructs a QCollator from \a locale. If \a locale is not specified - the system's default locale is used. + Constructs a QCollator for \a locale. + + If \a locale is not specified, the system's default locale is used. \sa setLocale() */ @@ -128,9 +129,9 @@ QCollator &QCollator::operator=(const QCollator &other) Move constructor. Moves from \a other into this collator. - Note that a moved-from QCollator can only be destroyed or assigned - to. The effect of calling other functions than the destructor or - one of the assignment operators is undefined. + Note that a moved-from QCollator can only be destroyed or assigned to. + The effect of calling other functions than the destructor or one of the + assignment operators is undefined. */ /*! @@ -138,9 +139,9 @@ QCollator &QCollator::operator=(const QCollator &other) Move-assigns from \a other to this collator. - Note that a moved-from QCollator can only be destroyed or assigned - to. The effect of calling other functions than the destructor or - one of the assignment operators is undefined. + Note that a moved-from QCollator can only be destroyed or assigned to. + The effect of calling other functions than the destructor or one of the + assignment operators is undefined. */ /*! @@ -218,7 +219,8 @@ Qt::CaseSensitivity QCollator::caseSensitivity() const Enables numeric sorting mode when \a on is set to true. - This will enable proper sorting of numeric digits, so that e.g. 100 sorts after 99. + This will enable proper sorting of numeric digits, so that e.g. 100 sorts + after 99. By default this mode is off. @@ -248,11 +250,13 @@ bool QCollator::numericMode() const /*! \fn void QCollator::setIgnorePunctuation(bool on) - If \a on is set to true, punctuation characters and symbols are ignored when determining sort order. + If \a on is set to true, punctuation characters and symbols are ignored when + determining sort order. The default is locale dependent. - \note This method is not currently supported if Qt is configured to not use ICU on Linux. + \note This method is not currently supported if Qt is configured to not use + ICU on Linux. \sa ignorePunctuation() */ @@ -268,7 +272,8 @@ void QCollator::setIgnorePunctuation(bool on) /*! \fn bool QCollator::ignorePunctuation() const - Returns \c true if punctuation characters and symbols are ignored when determining sort order. + Returns \c true if punctuation characters and symbols are ignored when + determining sort order. \sa setIgnorePunctuation() */ @@ -287,9 +292,11 @@ bool QCollator::ignorePunctuation() const \since 5.13 \fn int QCollator::compare(QStringView s1, QStringView s2) const - Compares \a s1 with \a s2. Returns an integer less than, equal to, or greater than zero - depending on whether \a s1 sorts before, with or after \a s2. - */ + Compares \a s1 with \a s2. + + Returns an integer less than, equal to, or greater than zero depending on + whether \a s1 sorts before, with or after \a s2. +*/ #if QT_STRINGVIEW_LEVEL < 2 /*! \fn bool QCollator::operator()(const QString &s1, const QString &s2) const @@ -299,9 +306,11 @@ bool QCollator::ignorePunctuation() const /*! \overload - Compares \a s1 with \a s2. Returns an integer less than, equal to, or greater than zero - depending on whether \a s1 sorts before, with or after \a s2. - */ + Compares \a s1 with \a s2. + + Returns an integer less than, equal to, or greater than zero depending on + whether \a s1 sorts before, with or after \a s2. +*/ int QCollator::compare(const QString &s1, const QString &s2) const { return compare(QStringView(s1), QStringView(s2)); @@ -310,8 +319,10 @@ int QCollator::compare(const QString &s1, const QString &s2) const /*! \overload - Compares \a s1 with \a s2. Returns an integer less than, equal to, or greater than zero - depending on whether \a s1 sorts before, with or after \a s2. + Compares \a s1 with \a s2. + + Returns an integer less than, equal to, or greater than zero depending on + whether \a s1 sorts before, with or after \a s2. */ int QCollator::compare(const QStringRef &s1, const QStringRef &s2) const { @@ -321,11 +332,11 @@ int QCollator::compare(const QStringRef &s1, const QStringRef &s2) const /*! \overload - Compares \a s1 with \a s2. \a len1 and \a len2 specify the length of the - QChar arrays pointer to by \a s1 and \a s2. + Compares \a s1 with \a s2. \a len1 and \a len2 specify the lengths of the + QChar arrays pointed to by \a s1 and \a s2. - Returns an integer less than, equal to, or greater than zero - depending on whether \a s1 sorts before, with or after \a s2. + Returns an integer less than, equal to, or greater than zero depending on + whether \a s1 sorts before, with or after \a s2. */ int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) const { @@ -339,9 +350,9 @@ int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) con Returns a sortKey for \a string. Creating the sort key is usually somewhat slower, than using the compare() - methods directly. But if the string is compared repeatedly (e.g. when sorting - a whole list of strings), it's usually faster to create the sort keys for each - string and then sort using the keys. + methods directly. But if the string is compared repeatedly (e.g. when + sorting a whole list of strings), it's usually faster to create the sort + keys for each string and then sort using the keys. \note Not supported with the C (a.k.a. POSIX) locale on Darwin. */ @@ -353,8 +364,8 @@ int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) con \since 5.2 - The QCollatorSortKey class is always created by QCollator::sortKey() - and is used for fast strings collation, for example when collating many strings. + The QCollatorSortKey class is always created by QCollator::sortKey() and is + used for fast strings collation, for example when collating many strings. \reentrant \ingroup i18n @@ -423,9 +434,11 @@ QCollatorSortKey& QCollatorSortKey::operator=(const QCollatorSortKey &other) /*! \fn int QCollatorSortKey::compare(const QCollatorSortKey &otherKey) const - Compares the key to \a otherKey. Returns a negative value if the key - is less than \a otherKey, 0 if the key is equal to \a otherKey or a - positive value if the key is greater than \a otherKey. + Compares this key to \a otherKey. + + Returns a negative value if the key is less than \a otherKey, 0 if the key + is equal to \a otherKey or a positive value if the key is greater than \a + otherKey. \sa operator<() */ diff --git a/src/corelib/tools/qcollator_icu.cpp b/src/corelib/tools/qcollator_icu.cpp index eb0ba33676..8acda45070 100644 --- a/src/corelib/tools/qcollator_icu.cpp +++ b/src/corelib/tools/qcollator_icu.cpp @@ -78,7 +78,8 @@ void QCollatorPrivate::init() // and does case sensitive comparison. // UCOL_QUATERNARY is used as default in a few languages such as Japanese to take care of some // additional differences in those languages. - UColAttributeValue val = (caseSensitivity == Qt::CaseSensitive) ? UCOL_DEFAULT_STRENGTH : UCOL_SECONDARY; + UColAttributeValue val = (caseSensitivity == Qt::CaseSensitive) + ? UCOL_DEFAULT_STRENGTH : UCOL_SECONDARY; status = U_ZERO_ERROR; ucol_setAttribute(collator, UCOL_STRENGTH, val, &status); @@ -91,7 +92,8 @@ void QCollatorPrivate::init() qWarning("ucol_setAttribute: numeric collation failed: %d", status); status = U_ZERO_ERROR; - ucol_setAttribute(collator, UCOL_ALTERNATE_HANDLING, ignorePunctuation ? UCOL_SHIFTED : UCOL_NON_IGNORABLE, &status); + ucol_setAttribute(collator, UCOL_ALTERNATE_HANDLING, + ignorePunctuation ? UCOL_SHIFTED : UCOL_NON_IGNORABLE, &status); if (U_FAILURE(status)) qWarning("ucol_setAttribute: Alternate handling failed: %d", status); diff --git a/src/corelib/tools/qcollator_macx.cpp b/src/corelib/tools/qcollator_macx.cpp index ff127a041d..071d7c048f 100644 --- a/src/corelib/tools/qcollator_macx.cpp +++ b/src/corelib/tools/qcollator_macx.cpp @@ -71,7 +71,6 @@ void QCollatorPrivate::init() qWarning("Couldn't initialize the locale (%d)", int(status)); UInt32 options = 0; - if (caseSensitivity == Qt::CaseInsensitive) options |= kUCCollateCaseInsensitiveMask; if (numericMode) @@ -125,13 +124,14 @@ QCollatorSortKey QCollator::sortKey(const QString &string) const //Documentation recommends having it 5 times as big as the input QVector ret(string.size() * 5); ItemCount actualSize; - int status = UCGetCollationKey(d->collator, reinterpret_cast(string.constData()), string.count(), - ret.size(), &actualSize, ret.data()); + int status = UCGetCollationKey(d->collator, + reinterpret_cast(string.constData()), + string.count(), ret.size(), &actualSize, ret.data()); - ret.resize(actualSize+1); + ret.resize(actualSize + 1); if (status == kUCOutputBufferTooSmall) { - UCGetCollationKey(d->collator, reinterpret_cast(string.constData()), string.count(), - ret.size(), &actualSize, ret.data()); + UCGetCollationKey(d->collator, reinterpret_cast(string.constData()), + string.count(), ret.size(), &actualSize, ret.data()); } ret[actualSize] = 0; return QCollatorSortKey(new QCollatorSortKeyPrivate(std::move(ret))); diff --git a/src/corelib/tools/qcollator_win.cpp b/src/corelib/tools/qcollator_win.cpp index 9cbdd96ee0..4adbf4adf8 100644 --- a/src/corelib/tools/qcollator_win.cpp +++ b/src/corelib/tools/qcollator_win.cpp @@ -94,9 +94,10 @@ int QCollator::compare(QStringView s1, QStringView s2) const d->init(); //* from Windows documentation * - // Returns one of the following values if successful. To maintain the C runtime convention of - // comparing strings, the value 2 can be subtracted from a nonzero return value. Then, the - // meaning of <0, ==0, and >0 is consistent with the C runtime. + // Returns one of the following values if successful. To maintain the C + // runtime convention of comparing strings, the value 2 can be subtracted + // from a nonzero return value. Then, the meaning of <0, ==0, and >0 is + // consistent with the C runtime. #ifndef USE_COMPARESTRINGEX return CompareString(d->localeID, d->collator, @@ -137,7 +138,9 @@ QCollatorSortKey QCollator::sortKey(const QString &string) const NULL, NULL, 0); #endif if (finalSize == 0) { - qWarning() << "there were problems when generating the ::sortKey by LCMapStringW with error:" << GetLastError(); + qWarning() + << "there were problems when generating the ::sortKey by LCMapStringW with error:" + << GetLastError(); } return QCollatorSortKey(new QCollatorSortKeyPrivate(std::move(ret))); } From 75c6bd54d7e056e2818f942f9e40b897f575fd34 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 6 Mar 2019 10:00:09 +0100 Subject: [PATCH 082/292] Avoid copying QByteArray created via fromRawData in toDouble qt_asciiToDouble accepts a length parameter, so we can just pass that through. No need for explicitly null-terminating, which is where the copy of the data would be made. Change-Id: I4e7921541f03295a2fae6171b35157084ff3ed8c Fixes: QTBUG-65748 Reviewed-by: Edward Welbourne Reviewed-by: Thiago Macieira --- src/corelib/tools/qbytearray.cpp | 3 +-- tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index 64674ddc00..8770100749 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -4135,10 +4135,9 @@ ushort QByteArray::toUShort(bool *ok, int base) const double QByteArray::toDouble(bool *ok) const { - QByteArray nulled = nulTerminated(); bool nonNullOk = false; int processed = 0; - double d = qt_asciiToDouble(nulled.constData(), nulled.length(), + double d = qt_asciiToDouble(constData(), size(), nonNullOk, processed, WhitespacesAllowed); if (ok) *ok = nonNullOk; diff --git a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp index 1ed41793dc..d9e03439b8 100644 --- a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp @@ -1361,6 +1361,9 @@ void tst_QByteArray::toDouble_data() QTest::newRow("trailing spaces") << QByteArray("1.2345 \n\r\t") << 1.2345 << true; QTest::newRow("leading junk") << QByteArray("x1.2345") << 0.0 << false; QTest::newRow("trailing junk") << QByteArray("1.2345x") << 0.0 << false; + + QTest::newRow("raw, null plus junk") << QByteArray::fromRawData("1.2\0 junk", 9) << 0.0 << false; + QTest::newRow("raw, null-terminator not included") << QByteArray::fromRawData("2.3", 3) << 2.3 << true; } void tst_QByteArray::toDouble() From 2412cfac512cbf54ebd379ee8d7157b251f4932d Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Fri, 1 Mar 2019 09:38:45 +0100 Subject: [PATCH 083/292] moc: Fix parsing of [[deprecated]] enum values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit moc now successfully parses enum values, that have been deprecated with [[deprecated]]. This is valid c++17 and should be handled correctly. By adding that functionality it is possible to parse Windows headers which use this deprecation mechanism. To make sure, that moc works correctly even on compilers that do not support deprecated enum values yet, the auto test explicitly uses [[deprecated]] enum values during moc run. Fixes: QTBUG-74126 Change-Id: I7b9d9a49af6093a97f8fdb800ffbc5af3d54d262 Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Jędrzej Nowacki --- src/tools/moc/moc.cpp | 1 + tests/auto/tools/moc/cxx-attributes.h | 43 +++++++++++++++++++++++++++ tests/auto/tools/moc/tst_moc.cpp | 17 +++++++++++ 3 files changed, 61 insertions(+) diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index d811bf09f0..2f52dd6ca0 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -285,6 +285,7 @@ bool Moc::parseEnum(EnumDef *def) break; next(IDENTIFIER); def->values += lexem(); + skipCxxAttributes(); } while (test(EQ) ? until(COMMA) : test(COMMA)); next(RBRACE); if (isTypdefEnum) { diff --git a/tests/auto/tools/moc/cxx-attributes.h b/tests/auto/tools/moc/cxx-attributes.h index 719f31e23c..eff6a3ec41 100644 --- a/tests/auto/tools/moc/cxx-attributes.h +++ b/tests/auto/tools/moc/cxx-attributes.h @@ -57,4 +57,47 @@ public slots: #endif }; +#ifdef Q_MOC_RUN +# define TEST_COMPILER_DEPRECATION [[deprecated]] +# define TEST_COMPILER_DEPRECATION_X(x) [[deprecated(x)]] +#else +# define TEST_COMPILER_DEPRECATION Q_DECL_ENUMERATOR_DEPRECATED +# define TEST_COMPILER_DEPRECATION_X(x) Q_DECL_ENUMERATOR_DEPRECATED_X(x) +#endif + +namespace TestQNamespaceDeprecated { + Q_NAMESPACE + enum class TestEnum1 { + Key1 = 11, + Key2 TEST_COMPILER_DEPRECATION, + Key3 TEST_COMPILER_DEPRECATION_X("reason"), + Key4 TEST_COMPILER_DEPRECATION_X("reason["), + Key5 TEST_COMPILER_DEPRECATION_X("reason[["), + Key6 TEST_COMPILER_DEPRECATION_X("reason]"), + Key7 TEST_COMPILER_DEPRECATION_X("reason]]"), + }; + Q_ENUM_NS(TestEnum1) + + // try to dizzy moc by adding a struct in between + struct TestGadget { + Q_GADGET + public: + enum class TestGEnum1 { + Key1 = 13, + Key2 TEST_COMPILER_DEPRECATION, + Key3 TEST_COMPILER_DEPRECATION_X("reason") + }; + Q_ENUM(TestGEnum1) + }; + + enum class TestFlag1 { + None = 0, + Flag1 = 1, + Flag2 TEST_COMPILER_DEPRECATION = 2, + Flag3 TEST_COMPILER_DEPRECATION_X("reason") = 3, + Any = Flag1 | Flag2 | Flag3 + }; + Q_FLAG_NS(TestFlag1) +} + #endif // CXXATTRIBUTE_H diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 4e5d902aa2..f12df578f4 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -3926,6 +3926,23 @@ void tst_Moc::cxxAttributes() }) { QVERIFY(so.indexOfSlot(a) != 1); } + + QCOMPARE(TestQNamespaceDeprecated::staticMetaObject.enumeratorCount(), 2); + checkEnum(TestQNamespaceDeprecated::staticMetaObject.enumerator(0), "TestEnum1", + {{"Key1", 11}, {"Key2", 12}, {"Key3", 13}, {"Key4", 14}, {"Key5", 15}, {"Key6", 16}, + {"Key7", 17}}); + checkEnum(TestQNamespaceDeprecated::staticMetaObject.enumerator(1), "TestFlag1", + {{"None", 0}, {"Flag1", 1}, {"Flag2", 2}, {"Flag3", 3}, {"Any", 1 | 2 | 3}}); + + QCOMPARE(TestQNamespaceDeprecated::TestGadget::staticMetaObject.enumeratorCount(), 1); + checkEnum(TestQNamespaceDeprecated::TestGadget::staticMetaObject.enumerator(0), "TestGEnum1", + {{"Key1", 13}, {"Key2", 14}, {"Key3", 15}}); + + QMetaEnum meta = QMetaEnum::fromType(); + QVERIFY(meta.isValid()); + QCOMPARE(meta.name(), "TestEnum1"); + QCOMPARE(meta.enclosingMetaObject(), &TestQNamespaceDeprecated::staticMetaObject); + QCOMPARE(meta.keyCount(), 7); } QTEST_MAIN(tst_Moc) From 8d4e8217fdc01417ab8ea33303dd0ce7f769d10e Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 25 Feb 2019 16:15:18 +0100 Subject: [PATCH 084/292] Convert tst_QSslSocket to work with Docker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ifb075763e3a0c6c08677dd2ae7febbbc8e4e48a9 Reviewed-by: Ryan Chu Reviewed-by: Mårten Nordheim Reviewed-by: Timur Pocheptsov --- .../qsslsocket/certs/qt-test-server-cert.pem | 16 ++ .../network/ssl/qsslsocket/qsslsocket.pro | 7 + .../network/ssl/qsslsocket/tst_qsslsocket.cpp | 177 +++++++++++------- tests/testserver/cyrus/cyrus.sh | 8 +- tests/testserver/docker-compose.yml | 3 +- tests/testserver/echo/echo.sh | 1 + 6 files changed, 144 insertions(+), 68 deletions(-) create mode 100644 tests/auto/network/ssl/qsslsocket/certs/qt-test-server-cert.pem diff --git a/tests/auto/network/ssl/qsslsocket/certs/qt-test-server-cert.pem b/tests/auto/network/ssl/qsslsocket/certs/qt-test-server-cert.pem new file mode 100644 index 0000000000..43c8794ce2 --- /dev/null +++ b/tests/auto/network/ssl/qsslsocket/certs/qt-test-server-cert.pem @@ -0,0 +1,16 @@ +-----BEGIN CERTIFICATE----- +MIIClTCCAf4CCQC2xMhNhwvATDANBgkqhkiG9w0BAQQFADCBjjELMAkGA1UEChMC +UXQxGTAXBgNVBAsTEENvcmUgQW5kIE5ldHdvcmsxGzAZBgkqhkiG9w0BCQEWDG5v +Ym9keS5xdC5pbzENMAsGA1UEBxMET3NsbzENMAsGA1UECBMET3NsbzELMAkGA1UE +BhMCTk8xHDAaBgNVBAMUEyoudGVzdC1uZXQucXQubG9jYWwwHhcNMTgwNzAxMTgz +NjI3WhcNNDgwNjIzMTgzNjI3WjCBjjELMAkGA1UEChMCUXQxGTAXBgNVBAsTEENv +cmUgQW5kIE5ldHdvcmsxGzAZBgkqhkiG9w0BCQEWDG5vYm9keS5xdC5pbzENMAsG +A1UEBxMET3NsbzENMAsGA1UECBMET3NsbzELMAkGA1UEBhMCTk8xHDAaBgNVBAMU +EyoudGVzdC1uZXQucXQubG9jYWwwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGB +AM2q22/WNMmn8cC+5EEYGeICySLmp9W6Ay6eKHr0Xxp3X3epETuPfvAuxp7rOtkS +18EMUegkUj8jw0IMEcbyHKFC/rTCaYOt93CxGBXMIChiMPAsFeYzGa/D6xzAkfcR +aJRQ+Ek3CDLXPnXfo7xpABXezYcPXAJrgsgBfWrwHdxzAgMBAAEwDQYJKoZIhvcN +AQEEBQADgYEAZu/lQPy8PXeyyYGamOVms/FZKJ48BH1y8KC3BeBU5FYnhvgG7pz8 +Wz9JKvt2t/r45wQeAkNL6HnGUBhPJsHMjPHl5KktqN+db3D+FQygBeS2V1+zmC0X +UZNRE4aWiHvt1Lq+pTx89SOMOpfqWfh4qTQKiE5jC2V4DeCNQ3u7uI8= +-----END CERTIFICATE----- diff --git a/tests/auto/network/ssl/qsslsocket/qsslsocket.pro b/tests/auto/network/ssl/qsslsocket/qsslsocket.pro index 1260dc9410..03fbe89002 100644 --- a/tests/auto/network/ssl/qsslsocket/qsslsocket.pro +++ b/tests/auto/network/ssl/qsslsocket/qsslsocket.pro @@ -18,3 +18,10 @@ TESTDATA += certs DEFINES += SRCDIR=\\\"$$PWD/\\\" requires(qtConfig(private_tests)) + +# DOCKERTODO: it's 'linux' because it requires cyrus, which +# is linux-only for now ... +linux { + QT_TEST_SERVER_LIST = squid danted cyrus apache2 echo + include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) +} diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index 0251f3da13..96c2f8ec42 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -310,6 +310,21 @@ Q_DECLARE_METATYPE(tst_QSslSocket::PskConnectTestType) int tst_QSslSocket::loopLevel = 0; +namespace { + +QString httpServerCertChainPath() +{ + // DOCKERTODO: note how we use CA certificate on the real server. The docker container + // is using a different cert with a "special" CN. Check if it's important! +#ifdef QT_TEST_SERVER + return tst_QSslSocket::testDataDir + QStringLiteral("certs/qt-test-server-cert.pem"); +#else + return tst_QSslSocket::testDataDir + QStringLiteral("certs/qt-test-server-cacert.pem"); +#endif // QT_TEST_SERVER +} + +} // unnamed namespace + tst_QSslSocket::tst_QSslSocket() { #ifndef QT_NO_SSL @@ -363,8 +378,19 @@ void tst_QSslSocket::initTestCase() qDebug("Using SSL library %s (%ld)", qPrintable(QSslSocket::sslLibraryVersionString()), QSslSocket::sslLibraryVersionNumber()); +#ifdef QT_TEST_SERVER + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::socksProxyServerName(), 1080)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::socksProxyServerName(), 1081)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3128)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3129)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3130)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpServerName(), 443)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::imapServerName(), 993)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::echoServerName(), 13)); +#else QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); -#endif +#endif // QT_TEST_SERVER +#endif // QT_NO_SSL } void tst_QSslSocket::init() @@ -373,28 +399,29 @@ void tst_QSslSocket::init() if (setProxy) { #ifndef QT_NO_NETWORKPROXY QFETCH_GLOBAL(int, proxyType); - QString fluke = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first().toString(); + const QString socksProxyAddr = QtNetworkSettings::socksProxyServerIp().toString(); + const QString httpProxyAddr = QtNetworkSettings::httpProxyServerIp().toString(); QNetworkProxy proxy; switch (proxyType) { case Socks5Proxy: - proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, fluke, 1080); + proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, socksProxyAddr, 1080); break; case Socks5Proxy | AuthBasic: - proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, fluke, 1081); + proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, socksProxyAddr, 1081); break; case HttpProxy | NoAuth: - proxy = QNetworkProxy(QNetworkProxy::HttpProxy, fluke, 3128); + proxy = QNetworkProxy(QNetworkProxy::HttpProxy, httpProxyAddr, 3128); break; case HttpProxy | AuthBasic: - proxy = QNetworkProxy(QNetworkProxy::HttpProxy, fluke, 3129); + proxy = QNetworkProxy(QNetworkProxy::HttpProxy, httpProxyAddr, 3129); break; case HttpProxy | AuthNtlm: - proxy = QNetworkProxy(QNetworkProxy::HttpProxy, fluke, 3130); + proxy = QNetworkProxy(QNetworkProxy::HttpProxy, httpProxyAddr, 3130); break; } QNetworkProxy::setApplicationProxy(proxy); @@ -555,7 +582,7 @@ void tst_QSslSocket::simpleConnect() connect(&socket, SIGNAL(sslErrors(QList)), this, SLOT(exitLoop())); // Start connecting - socket.connectToHost(QtNetworkSettings::serverName(), 993); + socket.connectToHost(QtNetworkSettings::imapServerName(), 993); QCOMPARE(socket.state(), QAbstractSocket::HostLookupState); enterLoop(10); @@ -610,7 +637,7 @@ void tst_QSslSocket::simpleConnectWithIgnore() connect(&socket, SIGNAL(sslErrors(QList)), this, SLOT(exitLoop())); // Start connecting - socket.connectToHost(QtNetworkSettings::serverName(), 993); + socket.connectToHost(QtNetworkSettings::imapServerName(), 993); QVERIFY(socket.state() != QAbstractSocket::UnconnectedState); // something must be in progress enterLoop(10); @@ -642,7 +669,7 @@ void tst_QSslSocket::sslErrors_data() QString name = QtNetworkSettings::serverLocalName(); QTest::newRow(qPrintable(name)) << name << 993; - name = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first().toString(); + name = QtNetworkSettings::httpServerIp().toString(); QTest::newRow(qPrintable(name)) << name << 443; } @@ -659,7 +686,20 @@ void tst_QSslSocket::sslErrors() QSignalSpy sslErrorsSpy(socket.data(), SIGNAL(sslErrors(QList))); QSignalSpy peerVerifyErrorSpy(socket.data(), SIGNAL(peerVerifyError(QSslError))); - socket->connectToHostEncrypted(host, port); +#ifdef QT_TEST_SERVER + // On the old test server we had the same certificate on different services. + // The idea of this test is to fail with 'HostNameMismatch', when we're using + // either serverLocalName() or IP address directly. With Docker we connect + // to IMAP server, and we have to connect using imapServerName() and passing + // 'host' as peerVerificationName to the overload of connectToHostEncrypted(). + if (port == 993) { + socket->connectToHostEncrypted(QtNetworkSettings::imapServerName(), port, host); + } else +#endif // QT_TEST_SERVER + { + socket->connectToHostEncrypted(host, port); + } + if (!socket->waitForConnected()) QSKIP("Skipping flaky test - See QTBUG-29941"); socket->waitForEncrypted(10000); @@ -739,13 +779,13 @@ void tst_QSslSocket::connectToHostEncrypted() socket->setProtocol(QSsl::SslProtocol::TlsV1_1); #endif this->socket = socket.data(); - QVERIFY(socket->addCaCertificates(testDataDir + "certs/qt-test-server-cacert.pem")); + QVERIFY(socket->addCaCertificates(httpServerCertChainPath())); #ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND connect(socket.data(), SIGNAL(sslErrors(QList)), this, SLOT(untrustedWorkaroundSlot(QList))); #endif - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); // This should pass unconditionally when using fluke's CA certificate. // or use untrusted certificate workaround @@ -758,7 +798,7 @@ void tst_QSslSocket::connectToHostEncrypted() QCOMPARE(socket->mode(), QSslSocket::SslClientMode); - socket->connectToHost(QtNetworkSettings::serverName(), 13); + socket->connectToHost(QtNetworkSettings::echoServerName(), 13); QCOMPARE(socket->mode(), QSslSocket::UnencryptedMode); @@ -776,14 +816,18 @@ void tst_QSslSocket::connectToHostEncryptedWithVerificationPeerName() #endif this->socket = socket.data(); - socket->addCaCertificates(testDataDir + "certs/qt-test-server-cacert.pem"); + socket->addCaCertificates(httpServerCertChainPath()); #ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND connect(socket.data(), SIGNAL(sslErrors(QList)), this, SLOT(untrustedWorkaroundSlot(QList))); #endif - // connect to the server with its local name, but use the full name for verification. - socket->connectToHostEncrypted(QtNetworkSettings::serverLocalName(), 443, QtNetworkSettings::serverName()); +#ifdef QT_TEST_SERVER + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443, QtNetworkSettings::httpServerName()); +#else + // Connect to the server with its local name, but use the full name for verification. + socket->connectToHostEncrypted(QtNetworkSettings::serverLocalName(), 443, QtNetworkSettings::httpServerName()); +#endif // This should pass unconditionally when using fluke's CA certificate. QFETCH_GLOBAL(bool, setProxy); @@ -805,7 +849,7 @@ void tst_QSslSocket::sessionCipher() this->socket = socket.data(); connect(socket.data(), SIGNAL(sslErrors(QList)), this, SLOT(ignoreErrorSlot())); QVERIFY(socket->sessionCipher().isNull()); - socket->connectToHost(QtNetworkSettings::serverName(), 443 /* https */); + socket->connectToHost(QtNetworkSettings::httpServerName(), 443 /* https */); QVERIFY2(socket->waitForConnected(10000), qPrintable(socket->errorString())); QVERIFY(socket->sessionCipher().isNull()); socket->startClientEncryption(); @@ -840,12 +884,12 @@ void tst_QSslSocket::localCertificate() // values. This test should just run the codepath inside qsslsocket_openssl.cpp QSslSocketPtr socket = newSocket(); - QList localCert = QSslCertificate::fromPath(testDataDir + "certs/qt-test-server-cacert.pem"); + QList localCert = QSslCertificate::fromPath(httpServerCertChainPath()); socket->setCaCertificates(localCert); socket->setLocalCertificate(testDataDir + "certs/fluke.cert"); socket->setPrivateKey(testDataDir + "certs/fluke.key"); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); QFETCH_GLOBAL(bool, setProxy); if (setProxy && !socket->waitForEncrypted(10000)) QSKIP("Skipping flaky test - See QTBUG-29941"); @@ -868,8 +912,7 @@ void tst_QSslSocket::peerCertificateChain() QSslSocketPtr socket = newSocket(); this->socket = socket.data(); - - QList caCertificates = QSslCertificate::fromPath(testDataDir + "certs/qt-test-server-cacert.pem"); + QList caCertificates = QSslCertificate::fromPath(httpServerCertChainPath()); QCOMPARE(caCertificates.count(), 1); socket->addCaCertificates(caCertificates); #ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND @@ -877,7 +920,7 @@ void tst_QSslSocket::peerCertificateChain() this, SLOT(untrustedWorkaroundSlot(QList))); #endif - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); QCOMPARE(socket->mode(), QSslSocket::UnencryptedMode); QVERIFY(socket->peerCertificateChain().isEmpty()); QFETCH_GLOBAL(bool, setProxy); @@ -906,7 +949,7 @@ void tst_QSslSocket::peerCertificateChain() QVERIFY(socket->waitForDisconnected()); // now do it again back to the original server - socket->connectToHost(QtNetworkSettings::serverName(), 443); + socket->connectToHost(QtNetworkSettings::httpServerName(), 443); QCOMPARE(socket->mode(), QSslSocket::UnencryptedMode); QVERIFY(socket->peerCertificateChain().isEmpty()); QVERIFY2(socket->waitForConnected(10000), qPrintable(socket->errorString())); @@ -945,13 +988,13 @@ void tst_QSslSocket::privateKeyOpaque() // values. This test should just run the codepath inside qsslsocket_openssl.cpp QSslSocketPtr socket = newSocket(); - QList localCert = QSslCertificate::fromPath(testDataDir + "certs/qt-test-server-cacert.pem"); + QList localCert = QSslCertificate::fromPath(httpServerCertChainPath()); socket->setCaCertificates(localCert); socket->setLocalCertificate(testDataDir + "certs/fluke.cert"); socket->setPrivateKey(QSslKey(reinterpret_cast(pkey))); socket->setPeerVerifyMode(QSslSocket::QueryPeer); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); QFETCH_GLOBAL(bool, setProxy); if (setProxy && !socket->waitForEncrypted(10000)) QSKIP("Skipping flaky test - See QTBUG-29941"); @@ -965,7 +1008,7 @@ void tst_QSslSocket::protocol() QSslSocketPtr socket = newSocket(); this->socket = socket.data(); - QList certs = QSslCertificate::fromPath(testDataDir + "certs/qt-test-server-cacert.pem"); + QList certs = QSslCertificate::fromPath(httpServerCertChainPath()); socket->setCaCertificates(certs); #ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND @@ -979,13 +1022,13 @@ void tst_QSslSocket::protocol() // qt-test-server allows TLSV1. socket->setProtocol(QSsl::TlsV1_0); QCOMPARE(socket->protocol(), QSsl::TlsV1_0); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); if (setProxy && !socket->waitForEncrypted()) QSKIP("Skipping flaky test - See QTBUG-29941"); QCOMPARE(socket->protocol(), QSsl::TlsV1_0); socket->abort(); QCOMPARE(socket->protocol(), QSsl::TlsV1_0); - socket->connectToHost(QtNetworkSettings::serverName(), 443); + socket->connectToHost(QtNetworkSettings::httpServerName(), 443); QVERIFY2(socket->waitForConnected(), qPrintable(socket->errorString())); socket->startClientEncryption(); if (setProxy && !socket->waitForEncrypted()) @@ -998,13 +1041,13 @@ void tst_QSslSocket::protocol() // qt-test-server probably doesn't allow TLSV1.1 socket->setProtocol(QSsl::TlsV1_1); QCOMPARE(socket->protocol(), QSsl::TlsV1_1); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); if (setProxy && !socket->waitForEncrypted()) QSKIP("Skipping flaky test - See QTBUG-29941"); QCOMPARE(socket->protocol(), QSsl::TlsV1_1); socket->abort(); QCOMPARE(socket->protocol(), QSsl::TlsV1_1); - socket->connectToHost(QtNetworkSettings::serverName(), 443); + socket->connectToHost(QtNetworkSettings::httpServerName(), 443); QVERIFY2(socket->waitForConnected(), qPrintable(socket->errorString())); socket->startClientEncryption(); if (setProxy && !socket->waitForEncrypted()) @@ -1016,13 +1059,13 @@ void tst_QSslSocket::protocol() // qt-test-server probably doesn't allows TLSV1.2 socket->setProtocol(QSsl::TlsV1_2); QCOMPARE(socket->protocol(), QSsl::TlsV1_2); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); if (setProxy && !socket->waitForEncrypted()) QSKIP("Skipping flaky test - See QTBUG-29941"); QCOMPARE(socket->protocol(), QSsl::TlsV1_2); socket->abort(); QCOMPARE(socket->protocol(), QSsl::TlsV1_2); - socket->connectToHost(QtNetworkSettings::serverName(), 443); + socket->connectToHost(QtNetworkSettings::httpServerName(), 443); QVERIFY2(socket->waitForConnected(), qPrintable(socket->errorString())); socket->startClientEncryption(); if (setProxy && !socket->waitForEncrypted()) @@ -1036,13 +1079,13 @@ void tst_QSslSocket::protocol() // qt-test-server probably doesn't allow TLSV1.3 socket->setProtocol(QSsl::TlsV1_3); QCOMPARE(socket->protocol(), QSsl::TlsV1_3); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); if (setProxy && !socket->waitForEncrypted()) QSKIP("TLS 1.3 is not supported by the test server or the test is flaky - see QTBUG-29941"); QCOMPARE(socket->protocol(), QSsl::TlsV1_3); socket->abort(); QCOMPARE(socket->protocol(), QSsl::TlsV1_3); - socket->connectToHost(QtNetworkSettings::serverName(), 443); + socket->connectToHost(QtNetworkSettings::httpServerName(), 443); QVERIFY2(socket->waitForConnected(), qPrintable(socket->errorString())); socket->startClientEncryption(); if (setProxy && !socket->waitForEncrypted()) @@ -1055,13 +1098,13 @@ void tst_QSslSocket::protocol() // qt-test-server allows SSLV3, so it allows AnyProtocol. socket->setProtocol(QSsl::AnyProtocol); QCOMPARE(socket->protocol(), QSsl::AnyProtocol); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); if (setProxy && !socket->waitForEncrypted()) QSKIP("Skipping flaky test - See QTBUG-29941"); QCOMPARE(socket->protocol(), QSsl::AnyProtocol); socket->abort(); QCOMPARE(socket->protocol(), QSsl::AnyProtocol); - socket->connectToHost(QtNetworkSettings::serverName(), 443); + socket->connectToHost(QtNetworkSettings::httpServerName(), 443); QVERIFY2(socket->waitForConnected(), qPrintable(socket->errorString())); socket->startClientEncryption(); if (setProxy && !socket->waitForEncrypted()) @@ -1073,13 +1116,13 @@ void tst_QSslSocket::protocol() // qt-test-server allows TlsV1, so it allows TlsV1SslV3 socket->setProtocol(QSsl::TlsV1SslV3); QCOMPARE(socket->protocol(), QSsl::TlsV1SslV3); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); if (setProxy && !socket->waitForEncrypted()) QSKIP("Skipping flaky test - See QTBUG-29941"); QCOMPARE(socket->protocol(), QSsl::TlsV1SslV3); socket->abort(); QCOMPARE(socket->protocol(), QSsl::TlsV1SslV3); - socket->connectToHost(QtNetworkSettings::serverName(), 443); + socket->connectToHost(QtNetworkSettings::httpServerName(), 443); if (setProxy && !socket->waitForConnected()) QSKIP("Skipping flaky test - See QTBUG-29941"); socket->startClientEncryption(); @@ -1491,7 +1534,7 @@ void tst_QSslSocket::setSslConfiguration_data() QTest::newRow("empty") << QSslConfiguration() << false; QSslConfiguration conf = QSslConfiguration::defaultConfiguration(); QTest::newRow("default") << conf << false; // does not contain test server cert - QList testServerCert = QSslCertificate::fromPath(testDataDir + "certs/qt-test-server-cacert.pem"); + QList testServerCert = QSslCertificate::fromPath(httpServerCertChainPath()); conf.setCaCertificates(testServerCert); QTest::newRow("set-root-cert") << conf << true; conf.setProtocol(QSsl::SecureProtocols); @@ -1510,7 +1553,7 @@ void tst_QSslSocket::setSslConfiguration() socket->setProtocol(QSsl::SslProtocol::TlsV1_1); #endif this->socket = socket.data(); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); QFETCH(bool, works); QFETCH_GLOBAL(bool, setProxy); if (setProxy && (socket->waitForEncrypted(10000) != works)) @@ -1530,7 +1573,7 @@ void tst_QSslSocket::waitForEncrypted() this->socket = socket.data(); connect(this->socket, SIGNAL(sslErrors(QList)), this, SLOT(ignoreErrorSlot())); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); QFETCH_GLOBAL(bool, setProxy); if (setProxy && !socket->waitForEncrypted(10000)) @@ -1549,7 +1592,7 @@ void tst_QSslSocket::waitForEncryptedMinusOne() this->socket = socket.data(); connect(this->socket, SIGNAL(sslErrors(QList)), this, SLOT(ignoreErrorSlot())); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); QFETCH_GLOBAL(bool, setProxy); if (setProxy && !socket->waitForEncrypted(-1)) @@ -1565,7 +1608,7 @@ void tst_QSslSocket::waitForConnectedEncryptedReadyRead() this->socket = socket.data(); connect(this->socket, SIGNAL(sslErrors(QList)), this, SLOT(ignoreErrorSlot())); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 993); + socket->connectToHostEncrypted(QtNetworkSettings::imapServerName(), 993); QVERIFY2(socket->waitForConnected(10000), qPrintable(socket->errorString())); QFETCH_GLOBAL(bool, setProxy); @@ -1597,7 +1640,7 @@ void tst_QSslSocket::addDefaultCaCertificate() // Reset the global CA chain QSslSocket::setDefaultCaCertificates(QSslSocket::systemCaCertificates()); - QList flukeCerts = QSslCertificate::fromPath(testDataDir + "certs/qt-test-server-cacert.pem"); + QList flukeCerts = QSslCertificate::fromPath(httpServerCertChainPath()); QCOMPARE(flukeCerts.size(), 1); QList globalCerts = QSslSocket::defaultCaCertificates(); QVERIFY(!globalCerts.contains(flukeCerts.first())); @@ -1968,7 +2011,7 @@ void tst_QSslSocket::setReadBufferSize_task_250027() QSslSocketPtr socket = newSocket(); socket->setReadBufferSize(1000); // limit to 1 kb/sec socket->ignoreSslErrors(); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); socket->ignoreSslErrors(); QVERIFY2(socket->waitForConnected(10*1000), qPrintable(socket->errorString())); if (setProxy && !socket->waitForEncrypted(10*1000)) @@ -1981,7 +2024,7 @@ void tst_QSslSocket::setReadBufferSize_task_250027() // provoke a response by sending a request socket->write("GET /qtest/fluke.gif HTTP/1.0\n"); // this file is 27 KB socket->write("Host: "); - socket->write(QtNetworkSettings::serverName().toLocal8Bit().constData()); + socket->write(QtNetworkSettings::httpServerName().toLocal8Bit().constData()); socket->write("\n"); socket->write("Connection: close\n"); socket->write("\n"); @@ -2232,7 +2275,7 @@ void tst_QSslSocket::verifyMode() socket.setPeerVerifyMode(QSslSocket::VerifyPeer); QCOMPARE(socket.peerVerifyMode(), QSslSocket::VerifyPeer); - socket.connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket.connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); if (socket.waitForEncrypted()) QSKIP("Skipping flaky test - See QTBUG-29941"); @@ -2271,7 +2314,7 @@ void tst_QSslSocket::verifyDepth() void tst_QSslSocket::disconnectFromHostWhenConnecting() { QSslSocketPtr socket = newSocket(); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 993); + socket->connectToHostEncrypted(QtNetworkSettings::imapServerName(), 993); socket->ignoreSslErrors(); socket->write("XXXX LOGOUT\r\n"); QAbstractSocket::SocketState state = socket->state(); @@ -2300,7 +2343,7 @@ void tst_QSslSocket::disconnectFromHostWhenConnecting() void tst_QSslSocket::disconnectFromHostWhenConnected() { QSslSocketPtr socket = newSocket(); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 993); + socket->connectToHostEncrypted(QtNetworkSettings::imapServerName(), 993); socket->ignoreSslErrors(); if (!socket->waitForEncrypted(5000)) QSKIP("Skipping flaky test - See QTBUG-29941"); @@ -2387,13 +2430,13 @@ void tst_QSslSocket::resetProxy() // make sure the connection works, and then set a nonsense proxy, and then // make sure it does not work anymore QSslSocket socket; - socket.addCaCertificates(testDataDir + "certs/qt-test-server-cacert.pem"); + socket.addCaCertificates(httpServerCertChainPath()); socket.setProxy(goodProxy); - socket.connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket.connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); QVERIFY2(socket.waitForConnected(10000), qPrintable(socket.errorString())); socket.abort(); socket.setProxy(badProxy); - socket.connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket.connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); QVERIFY(! socket.waitForConnected(10000)); // don't forget to login @@ -2406,13 +2449,13 @@ void tst_QSslSocket::resetProxy() // set the nonsense proxy and make sure the connection does not work, // and then set the right proxy and make sure it works QSslSocket socket2; - socket2.addCaCertificates(testDataDir + "certs/qt-test-server-cacert.pem"); + socket2.addCaCertificates(httpServerCertChainPath()); socket2.setProxy(badProxy); - socket2.connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket2.connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); QVERIFY(! socket2.waitForConnected(10000)); socket2.abort(); socket2.setProxy(goodProxy); - socket2.connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket2.connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); QVERIFY2(socket2.waitForConnected(10000), qPrintable(socket.errorString())); #endif // QT_NO_NETWORKPROXY } @@ -2425,7 +2468,7 @@ void tst_QSslSocket::ignoreSslErrorsList_data() // construct the list of errors that we will get with the SSL handshake and that we will ignore QList expectedSslErrors; // fromPath gives us a list of certs, but it actually only contains one - QList certs = QSslCertificate::fromPath(testDataDir + "certs/qt-test-server-cacert.pem"); + QList certs = QSslCertificate::fromPath(httpServerCertChainPath()); QSslError rightError(FLUKE_CERTIFICATE_ERROR, certs.at(0)); QSslError wrongError(FLUKE_CERTIFICATE_ERROR); @@ -2456,7 +2499,7 @@ void tst_QSslSocket::ignoreSslErrorsList() QFETCH(int, expectedSslErrorSignalCount); QSignalSpy sslErrorsSpy(&socket, SIGNAL(error(QAbstractSocket::SocketError))); - socket.connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket.connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); bool expectEncryptionSuccess = (expectedSslErrorSignalCount == 0); if (socket.waitForEncrypted(10000) != expectEncryptionSuccess) @@ -2487,7 +2530,7 @@ void tst_QSslSocket::ignoreSslErrorsListWithSlot() this, SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); connect(&socket, SIGNAL(sslErrors(QList)), this, SLOT(ignoreErrorListSlot(QList))); - socket.connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket.connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); QFETCH(int, expectedSslErrorSignalCount); bool expectEncryptionSuccess = (expectedSslErrorSignalCount == 0); @@ -2529,14 +2572,14 @@ void tst_QSslSocket::readFromClosedSocket() socket->setProtocol(QSsl::SslProtocol::TlsV1_1); #endif socket->ignoreSslErrors(); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); socket->ignoreSslErrors(); socket->waitForConnected(); socket->waitForEncrypted(); // provoke a response by sending a request socket->write("GET /qtest/fluke.gif HTTP/1.1\n"); socket->write("Host: "); - socket->write(QtNetworkSettings::serverName().toLocal8Bit().constData()); + socket->write(QtNetworkSettings::httpServerName().toLocal8Bit().constData()); socket->write("\n"); socket->write("\n"); socket->waitForBytesWritten(); @@ -2560,7 +2603,7 @@ void tst_QSslSocket::writeBigChunk() this->socket = socket.data(); connect(this->socket, SIGNAL(sslErrors(QList)), this, SLOT(ignoreErrorSlot())); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); QByteArray data; data.resize(1024*1024*10); // 10 MB @@ -2719,7 +2762,9 @@ void tst_QSslSocket::resume_data() QTest::newRow("DoNotIgnoreErrors") << false << QList() << false; QTest::newRow("ignoreAllErrors") << true << QList() << true; - QList certs = QSslCertificate::fromPath(testDataDir + "certs/qt-test-server-cacert.pem"); + // Note, httpServerCertChainPath() it's ... because we use the same certificate on + // different services. We'll be actually connecting to IMAP server. + QList certs = QSslCertificate::fromPath(httpServerCertChainPath()); QSslError rightError(FLUKE_CERTIFICATE_ERROR, certs.at(0)); QSslError wrongError(FLUKE_CERTIFICATE_ERROR); errorsList.append(wrongError); @@ -2752,7 +2797,7 @@ void tst_QSslSocket::resume() this, SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), &QTestEventLoop::instance(), SLOT(exitLoop())); - socket.connectToHostEncrypted(QtNetworkSettings::serverName(), 993); + socket.connectToHostEncrypted(QtNetworkSettings::imapServerName(), 993); QTestEventLoop::instance().enterLoop(10); QFETCH_GLOBAL(bool, setProxy); if (setProxy && QTestEventLoop::instance().timeout()) @@ -3418,7 +3463,7 @@ void tst_QSslSocket::setEmptyDefaultConfiguration() // this test should be last, socket = client.data(); connect(socket, SIGNAL(sslErrors(QList)), this, SLOT(ignoreErrorSlot())); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); QFETCH_GLOBAL(bool, setProxy); if (setProxy && socket->waitForEncrypted(4000)) QSKIP("Skipping flaky test - See QTBUG-29941"); @@ -4127,7 +4172,7 @@ void tst_QSslSocket::forwardReadChannelFinished() }); connect(&socket, &QSslSocket::readChannelFinished, &QTestEventLoop::instance(), &QTestEventLoop::exitLoop); - socket.connectToHostEncrypted(QtNetworkSettings::serverLocalName(), 443); + socket.connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); enterLoop(10); QVERIFY(readChannelFinishedSpy.count()); } diff --git a/tests/testserver/cyrus/cyrus.sh b/tests/testserver/cyrus/cyrus.sh index bd09acffc8..92c3bfa703 100755 --- a/tests/testserver/cyrus/cyrus.sh +++ b/tests/testserver/cyrus/cyrus.sh @@ -31,4 +31,10 @@ set -ex -service cyrus-imapd start +echo "tls_cert_file: /home/qt-test-server/ssl-certs/qt-test-server-cert.pem" >> /etc/imapd.conf +echo "tls_key_file: /home/qt-test-server/ssl-certs/private/qt-test-server-key.pem" >> /etc/imapd.conf +chmod +3 /home/qt-test-server/ssl-certs/private/ +mkdir -m 007 -p /run/cyrus/proc +sed -i 's/#imaps\t\tcmd="imapd/imaps\t\tcmd="imapd/' /etc/cyrus.conf + +service cyrus-imapd restart diff --git a/tests/testserver/docker-compose.yml b/tests/testserver/docker-compose.yml index 60ecfe6f21..962daad3c9 100644 --- a/tests/testserver/docker-compose.yml +++ b/tests/testserver/docker-compose.yml @@ -34,6 +34,7 @@ services: - cyrus:cyrus.${TEST_DOMAIN} - iptables:iptables.${TEST_DOMAIN} - vsftpd:vsftpd.${TEST_DOMAIN} + - echo:echo.${TEST_DOMAIN} volumes: - ./common:/common:ro - ./squid:/service:ro @@ -96,7 +97,7 @@ services: - ./common:/common:ro - ./cyrus:/service:ro entrypoint: common/startup.sh - command: service/cyrus.sh + command: [common/ssl.sh, service/cyrus.sh] iptables: image: qt-test-server-iptables:cb7a8bd6d28602085a88c8ced7d67e28e75781e2 diff --git a/tests/testserver/echo/echo.sh b/tests/testserver/echo/echo.sh index a028d056e0..f0da9627d5 100755 --- a/tests/testserver/echo/echo.sh +++ b/tests/testserver/echo/echo.sh @@ -2,5 +2,6 @@ # Disabled by default, enable it. sed -i 's/disable\t\t= yes/disable = no/' /etc/xinetd.d/echo +sed -i 's/disable\t\t= yes/disable = no/' /etc/xinetd.d/daytime service xinetd restart From 29a70348d4ed4f5acca82bfb9f73a1acf06c3aa8 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Tue, 12 Mar 2019 11:46:43 +0100 Subject: [PATCH 085/292] Add qstringview.cpp into bootstrap After e89fbd8c, QString depends on QStringView. Fixes: QTBUG-74340 Change-Id: I9cba49db73b74deca05b9a9ddfeec580f30b5e35 Reviewed-by: Edward Welbourne --- src/tools/bootstrap/bootstrap.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro index 3a1a186e8e..1662e99674 100644 --- a/src/tools/bootstrap/bootstrap.pro +++ b/src/tools/bootstrap/bootstrap.pro @@ -91,6 +91,7 @@ SOURCES += \ ../../corelib/tools/qstringbuilder.cpp \ ../../corelib/tools/qstring_compat.cpp \ ../../corelib/tools/qstringlist.cpp \ + ../../corelib/tools/qstringview.cpp \ ../../corelib/tools/qversionnumber.cpp \ ../../corelib/tools/qvsnprintf.cpp \ ../../xml/dom/qdom.cpp \ From b35eec360d4d88d094094fb54c101fad6cee5768 Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Tue, 12 Mar 2019 02:40:01 -0700 Subject: [PATCH 086/292] QStringMatcher: add QStringView support While touching the code, deduplicate some methods. Change-Id: I28f469f0e9ae000a34466b0ecc604b5f3bd09e63 Reviewed-by: Thiago Macieira --- src/corelib/tools/qstringmatcher.cpp | 46 +++++++++++++++---- src/corelib/tools/qstringmatcher.h | 5 ++ .../qstringmatcher/tst_qstringmatcher.cpp | 6 +++ 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/src/corelib/tools/qstringmatcher.cpp b/src/corelib/tools/qstringmatcher.cpp index 67d3f0ebc8..b99c113d52 100644 --- a/src/corelib/tools/qstringmatcher.cpp +++ b/src/corelib/tools/qstringmatcher.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 Mail.ru Group. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -175,13 +176,26 @@ QStringMatcher::QStringMatcher(const QString &pattern, Qt::CaseSensitivity cs) by \a uc with the given \a length and case sensitivity specified by \a cs. */ QStringMatcher::QStringMatcher(const QChar *uc, int len, Qt::CaseSensitivity cs) - : d_ptr(0), q_cs(cs) + : QStringMatcher(QStringView(uc, len), cs) { - p.uc = uc; - p.len = len; - bm_init_skiptable((const ushort *)p.uc, len, p.q_skiptable, cs); } +/*! + \fn QStringMatcher::QStringMatcher(QStringView str, Qt::CaseSensitivity cs) + \since 5.14 + + Constructs a string matcher that will search for \a pattern, with + case sensitivity \a cs. + + Call indexIn() to perform a search. +*/ +QStringMatcher::QStringMatcher(QStringView str, Qt::CaseSensitivity cs) + : d_ptr(nullptr), q_cs(cs) +{ + p.uc = str.data(); + p.len = int(str.size()); + bm_init_skiptable((const ushort *)p.uc, p.len, p.q_skiptable, cs); +} /*! Copies the \a other string matcher to this string matcher. */ @@ -267,11 +281,7 @@ void QStringMatcher::setCaseSensitivity(Qt::CaseSensitivity cs) */ int QStringMatcher::indexIn(const QString &str, int from) const { - if (from < 0) - from = 0; - return bm_find((const ushort *)str.unicode(), str.size(), from, - (const ushort *)p.uc, p.len, - p.q_skiptable, q_cs); + return int(indexIn(QStringView(str), from)); } /*! @@ -287,10 +297,26 @@ int QStringMatcher::indexIn(const QString &str, int from) const \sa setPattern(), setCaseSensitivity() */ int QStringMatcher::indexIn(const QChar *str, int length, int from) const +{ + return int(indexIn(QStringView(str, length), from)); +} + +/*! + \since 5.14 + + Searches the string \a str from character position \a from + (default 0, i.e. from the first character), for the string + pattern() that was set in the constructor or in the most recent + call to setPattern(). Returns the position where the pattern() + matched in \a str, or -1 if no match was found. + + \sa setPattern(), setCaseSensitivity() +*/ +qsizetype QStringMatcher::indexIn(QStringView str, qsizetype from) const { if (from < 0) from = 0; - return bm_find((const ushort *)str, length, from, + return bm_find((const ushort *)str.data(), str.size(), from, (const ushort *)p.uc, p.len, p.q_skiptable, q_cs); } diff --git a/src/corelib/tools/qstringmatcher.h b/src/corelib/tools/qstringmatcher.h index 549bff9f29..6de4353930 100644 --- a/src/corelib/tools/qstringmatcher.h +++ b/src/corelib/tools/qstringmatcher.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 Mail.ru Group. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -41,6 +42,7 @@ #define QSTRINGMATCHER_H #include +#include QT_BEGIN_NAMESPACE @@ -55,6 +57,8 @@ public: Qt::CaseSensitivity cs = Qt::CaseSensitive); QStringMatcher(const QChar *uc, int len, Qt::CaseSensitivity cs = Qt::CaseSensitive); + QStringMatcher(QStringView pattern, + Qt::CaseSensitivity cs = Qt::CaseSensitive); QStringMatcher(const QStringMatcher &other); ~QStringMatcher(); @@ -65,6 +69,7 @@ public: int indexIn(const QString &str, int from = 0) const; int indexIn(const QChar *str, int length, int from = 0) const; + qsizetype indexIn(QStringView str, qsizetype from = 0) const; QString pattern() const; inline Qt::CaseSensitivity caseSensitivity() const { return q_cs; } diff --git a/tests/auto/corelib/tools/qstringmatcher/tst_qstringmatcher.cpp b/tests/auto/corelib/tools/qstringmatcher/tst_qstringmatcher.cpp index 8a55f54449..2d577bb0ab 100644 --- a/tests/auto/corelib/tools/qstringmatcher/tst_qstringmatcher.cpp +++ b/tests/auto/corelib/tools/qstringmatcher/tst_qstringmatcher.cpp @@ -100,6 +100,11 @@ void tst_QStringMatcher::indexIn() matcher.setPattern(needle); QCOMPARE(matcher.indexIn(haystack, from), indexIn); + + const auto needleSV = QStringView(needle); + QStringMatcher matcherSV(needleSV); + + QCOMPARE(matcherSV.indexIn(QStringView(haystack), from), indexIn); } void tst_QStringMatcher::setCaseSensitivity_data() @@ -128,6 +133,7 @@ void tst_QStringMatcher::setCaseSensitivity() matcher.setCaseSensitivity(static_cast (cs)); QCOMPARE(matcher.indexIn(haystack, from), indexIn); + QCOMPARE(matcher.indexIn(QStringView(haystack), from), indexIn); } void tst_QStringMatcher::assignOperator() From 41e7b71c410b77a81d09d3cc2e169ffd7975b4d2 Mon Sep 17 00:00:00 2001 From: Kevin Funk Date: Tue, 12 Mar 2019 11:46:26 +0100 Subject: [PATCH 087/292] More nullptr usage in headers Diff generated by running clang-tidy's modernize-use-nullptr checker on the CMake-based Qt version. Skipping src/3rdparty, examples/, tests/ Change-Id: Ib182074e2e2fd52f63093f73b3e2e4c0cb7af188 Reviewed-by: Friedemann Kleint Reviewed-by: Simon Hausmann --- src/concurrent/qtconcurrentcompilertest.h | 2 +- src/concurrent/qtconcurrentfilterkernel.h | 2 +- src/concurrent/qtconcurrentmapkernel.h | 2 +- src/corelib/animation/qabstractanimation_p.h | 2 +- src/corelib/animation/qanimationgroup_p.h | 2 +- src/corelib/animation/qpropertyanimation_p.h | 2 +- .../animation/qsequentialanimationgroup_p.h | 2 +- src/corelib/codecs/qtextcodec_p.h | 2 +- src/corelib/global/qglobalstatic.h | 4 +-- src/corelib/io/qabstractfileengine_p.h | 2 +- src/corelib/io/qfileinfo_p.h | 2 +- src/corelib/io/qfilesystemengine_p.h | 2 +- src/corelib/io/qfilesystemmetadata_p.h | 4 +-- src/corelib/io/qfsfileengine_p.h | 2 +- src/corelib/io/qprocess_p.h | 2 +- src/corelib/io/qresource_p.h | 2 +- src/corelib/io/qurl_p.h | 2 +- src/corelib/itemmodels/qabstractitemmodel_p.h | 2 +- .../itemmodels/qabstractproxymodel_p.h | 2 +- .../itemmodels/qitemselectionmodel_p.h | 2 +- src/corelib/kernel/qcore_unix_p.h | 2 +- src/corelib/kernel/qcoreapplication_p.h | 2 +- src/corelib/kernel/qeventdispatcher_glib_p.h | 6 ++-- src/corelib/kernel/qeventdispatcher_unix_p.h | 10 +++--- src/corelib/kernel/qmetaobject_moc_p.h | 4 +-- src/corelib/kernel/qmetaobject_p.h | 4 +-- src/corelib/kernel/qmetaobjectbuilder_p.h | 8 ++--- src/corelib/kernel/qsharedmemory_p.h | 2 +- src/corelib/kernel/qvariant_p.h | 10 +++--- src/corelib/plugin/qlibrary_p.h | 2 +- src/corelib/serialization/qjson_p.h | 4 +-- src/corelib/serialization/qxmlstream_p.h | 10 +++--- src/corelib/statemachine/qstate_p.h | 8 ++--- src/corelib/statemachine/qstatemachine_p.h | 4 +-- src/corelib/thread/qatomic_bootstrap.h | 2 +- src/corelib/thread/qresultstore.h | 4 +-- src/corelib/thread/qthread_p.h | 12 +++---- src/corelib/thread/qthreadpool_p.h | 2 +- src/corelib/thread/qthreadstorage.h | 4 +-- src/corelib/tools/qcache.h | 14 ++++---- src/corelib/tools/qdatetime_p.h | 2 +- src/corelib/tools/qdatetimeparser_p.h | 8 ++--- src/corelib/tools/qfreelist_p.h | 4 +-- src/corelib/tools/qlist.h | 2 +- src/corelib/tools/qlocale_p.h | 2 +- src/dbus/qdbusargument_p.h | 6 ++-- src/dbus/qdbusconnection_p.h | 10 +++--- src/dbus/qdbusintegrator_p.h | 6 ++-- src/dbus/qdbuspendingcall_p.h | 2 +- src/dbus/qdbuspendingreply.h | 2 +- src/dbus/qdbusutil_p.h | 2 +- src/gui/accessible/qaccessiblecache_p.h | 2 +- src/gui/image/qimage_p.h | 2 +- src/gui/image/qpixmapcache_p.h | 2 +- src/gui/image/qppmhandler_p.h | 2 +- src/gui/itemmodels/qstandarditemmodel_p.h | 12 +++---- src/gui/kernel/qdnd_p.h | 6 ++-- src/gui/kernel/qguiapplication_p.h | 4 +-- src/gui/kernel/qinputmethod_p.h | 2 +- src/gui/kernel/qopenglcontext_p.h | 22 ++++++------- src/gui/kernel/qplatformintegration.h | 2 +- src/gui/kernel/qplatformtheme.h | 2 +- src/gui/kernel/qscreen_p.h | 4 +-- src/gui/kernel/qshapedpixmapdndwindow_p.h | 2 +- src/gui/kernel/qwindow_p.h | 10 +++--- src/gui/kernel/qwindowsysteminterface_p.h | 10 +++--- src/gui/opengl/qopenglengineshadermanager_p.h | 2 +- src/gui/opengl/qopenglextensions_p.h | 2 +- src/gui/opengl/qopenglframebufferobject_p.h | 8 ++--- src/gui/opengl/qopenglpaintengine_p.h | 8 ++--- src/gui/opengl/qopenglqueryhelper_p.h | 24 +++++++------- src/gui/opengl/qopengltextureglyphcache_p.h | 2 +- src/gui/opengl/qopengltexturehelper_p.h | 18 +++++------ src/gui/painting/qcosmeticstroker_p.h | 4 +-- src/gui/painting/qdatabuffer_p.h | 4 +-- src/gui/painting/qdrawhelper_p.h | 2 +- src/gui/painting/qoutlinemapper_p.h | 4 +-- src/gui/painting/qpaintengine_p.h | 6 ++-- src/gui/painting/qpaintengine_raster_p.h | 2 +- src/gui/painting/qpainter_p.h | 6 ++-- src/gui/painting/qpainterpath_p.h | 4 +-- src/gui/painting/qpathclipper_p.h | 12 +++---- src/gui/painting/qplatformbackingstore.h | 4 +-- src/gui/painting/qrbtree_p.h | 14 ++++---- src/gui/painting/qtextureglyphcache_p.h | 2 +- src/gui/painting/qvectorpath_p.h | 8 ++--- src/gui/text/qabstracttextdocumentlayout_p.h | 6 ++-- src/gui/text/qcssparser_p.h | 12 +++---- src/gui/text/qdistancefield_p.h | 2 +- src/gui/text/qfont_p.h | 2 +- src/gui/text/qfontengine_p.h | 8 ++--- src/gui/text/qfragmentmap_p.h | 2 +- src/gui/text/qglyphrun_p.h | 2 +- src/gui/text/qrawfont_p.h | 22 ++++++------- src/gui/text/qstatictext_p.h | 2 +- src/gui/text/qtextdocument_p.h | 4 +-- src/gui/text/qtextdocumentfragment_p.h | 6 ++-- src/gui/text/qtextengine_p.h | 14 ++++---- src/gui/text/qtextimagehandler_p.h | 2 +- src/gui/text/qtextobject_p.h | 2 +- src/gui/text/qtexttable_p.h | 2 +- src/gui/util/qgridlayoutengine_p.h | 8 ++--- src/gui/vulkan/qvulkanwindow_p.h | 2 +- src/network/access/qftp_p.h | 4 +-- src/network/access/qhttpmultipart_p.h | 2 +- src/network/access/qhttpnetworkconnection_p.h | 4 +-- src/network/access/qhttpnetworkreply_p.h | 2 +- src/network/access/qhttpthreaddelegate_p.h | 10 +++--- .../qnetworkaccessauthenticationmanager_p.h | 4 +-- src/network/access/qnetworkdiskcache_p.h | 4 +-- src/network/access/qnetworkreplyimpl_p.h | 2 +- src/network/bearer/qbearerengine_p.h | 2 +- src/network/bearer/qbearerplugin_p.h | 2 +- src/network/kernel/qdnslookup_p.h | 2 +- src/network/kernel/qhostinfo_p.h | 2 +- src/network/kernel/qnetworkinterface_p.h | 2 +- src/network/kernel/qnetworkinterface_unix_p.h | 2 +- src/network/socket/qabstractsocketengine_p.h | 12 +++---- src/network/socket/qhttpsocketengine_p.h | 8 ++--- src/network/socket/qlocalserver_p.h | 2 +- src/network/socket/qnativesocketengine_p.h | 10 +++--- src/network/socket/qsocks5socketengine_p.h | 10 +++--- src/network/ssl/qasn1element_p.h | 4 +-- src/network/ssl/qsslcertificate_p.h | 2 +- src/network/ssl/qsslcontext_openssl_p.h | 2 +- src/network/ssl/qsslkey_p.h | 2 +- .../qglengineshadermanager_p.h | 2 +- .../qpaintengineex_opengl2_p.h | 4 +-- .../qtextureglyphcache_gl_p.h | 2 +- src/opengl/qgl_p.h | 12 +++---- src/opengl/qglframebufferobject_p.h | 6 ++-- src/opengl/qglpixelbuffer_p.h | 2 +- src/opengl/qgraphicsshadereffect_p.h | 2 +- .../nativecontexts/qeglnativecontext.h | 4 +-- .../devicediscovery/qdevicediscovery_p.h | 2 +- .../devicediscovery/qdevicediscovery_udev_p.h | 2 +- .../eglconvenience/qeglpbuffer_p.h | 2 +- .../eglconvenience/qeglplatformcontext_p.h | 4 +-- .../qeventdispatcher_glib_p.h | 4 +-- .../qunixeventdispatcher_qpa_p.h | 2 +- .../fbconvenience/qfbvthandler_p.h | 2 +- .../fontdatabases/freetype/qfontengine_ft_p.h | 2 +- .../evdevkeyboard/qevdevkeyboardmanager_p.h | 2 +- .../input/evdevmouse/qevdevmousemanager_p.h | 2 +- .../input/evdevtablet/qevdevtablethandler_p.h | 4 +-- .../input/evdevtablet/qevdevtabletmanager_p.h | 2 +- .../input/evdevtouch/qevdevtouchmanager_p.h | 2 +- .../input/libinput/qlibinputtouch_p.h | 2 +- .../linuxaccessibility/atspiadaptor_p.h | 2 +- .../linuxaccessibility/cache_p.h | 2 +- .../linuxaccessibility/dbusconnection_p.h | 2 +- .../dbusmenu/qdbusmenuconnection_p.h | 2 +- .../dbustray/qxdgnotificationproxy_p.h | 2 +- .../themes/genericunix/qgenericunixthemes_p.h | 4 +-- src/plugins/bearer/connman/qconnmanengine.h | 2 +- .../bearer/connman/qconnmanservice_linux_p.h | 6 ++-- src/plugins/bearer/generic/qgenericengine.h | 2 +- .../linux_common/qofonoservice_linux_p.h | 10 +++--- .../networkmanager/qnetworkmanagerengine.h | 4 +-- .../networkmanager/qnetworkmanagerservice.h | 22 ++++++------- src/plugins/bearer/qbearerengine_impl.h | 2 +- src/plugins/bearer/qnetworksession_impl.h | 2 +- .../ibus/qibusinputcontextproxy.h | 2 +- .../ibus/qibusplatforminputcontext.h | 6 ++-- .../platforminputcontexts/ibus/qibusproxy.h | 2 +- src/plugins/platforms/vnc/qvnc_p.h | 2 +- src/plugins/platforms/vnc/qvncscreen.h | 6 ++-- .../gl_integrations/qxcbglintegrationplugin.h | 2 +- src/plugins/platforms/xcb/qxcbconnection.h | 4 +-- src/plugins/platforms/xcb/qxcbcursor.h | 2 +- src/plugins/platforms/xcb/qxcbdrag.h | 4 +-- src/plugins/platforms/xcb/qxcbobject.h | 2 +- src/plugins/platforms/xcb/qxcbwindow.h | 2 +- .../xdgdesktopportal/qxdgdesktopportaltheme.h | 2 +- src/plugins/sqldrivers/odbc/qsql_odbc_p.h | 4 +-- src/plugins/sqldrivers/sqlite/qsql_sqlite_p.h | 4 +-- src/sql/models/qsqlquerymodel_p.h | 2 +- src/sql/models/qsqltablemodel_p.h | 2 +- src/testlib/qabstracttestlogger_p.h | 6 ++-- src/testlib/qcsvbenchmarklogger_p.h | 4 +-- src/testlib/qplaintestlogger_p.h | 6 ++-- src/testlib/qsignalspy.h | 2 +- src/testlib/qtaptestlogger_p.h | 4 +-- src/testlib/qteamcitylogger_p.h | 4 +-- src/testlib/qtestcoreelement_p.h | 10 +++--- src/testlib/qtestcorelist_p.h | 8 ++--- src/testlib/qxmltestlogger_p.h | 4 +-- src/testlib/qxunittestlogger_p.h | 4 +-- src/tools/moc/generator.h | 2 +- src/tools/moc/parser.h | 6 ++-- src/tools/uic/driver.h | 4 +-- src/widgets/dialogs/qdialog_p.h | 10 +++--- src/widgets/dialogs/qfiledialog_p.h | 8 ++--- src/widgets/dialogs/qfileinfogatherer_p.h | 2 +- src/widgets/dialogs/qfilesystemmodel_p.h | 12 +++---- src/widgets/dialogs/qfscompleter_p.h | 4 +-- src/widgets/dialogs/qsidebar_p.h | 6 ++-- src/widgets/effects/qgraphicseffect_p.h | 8 ++--- src/widgets/effects/qpixmapfilter_p.h | 8 ++--- .../graphicsview/qgraphicsanchorlayout_p.h | 12 +++---- .../qgraphicsgridlayoutengine_p.h | 4 +-- src/widgets/graphicsview/qgraphicsitem_p.h | 28 ++++++++-------- src/widgets/graphicsview/qgraphicslayout_p.h | 4 +-- .../graphicsview/qgraphicslayoutstyleinfo_p.h | 2 +- src/widgets/graphicsview/qgraphicsscene_p.h | 8 ++--- .../qgraphicsscenebsptreeindex_p.h | 2 +- .../graphicsview/qgraphicssceneindex_p.h | 2 +- .../qgraphicsscenelinearindex_p.h | 2 +- .../graphicsview/qgraphicstransform_p.h | 2 +- src/widgets/graphicsview/qgraphicswidget_p.h | 2 +- src/widgets/graphicsview/qsimplex_p.h | 2 +- src/widgets/itemviews/qcolumnview_p.h | 4 +-- src/widgets/itemviews/qcolumnviewgrip_p.h | 4 +-- src/widgets/itemviews/qheaderview_p.h | 2 +- src/widgets/itemviews/qlistview_p.h | 2 +- src/widgets/itemviews/qtableview_p.h | 2 +- src/widgets/itemviews/qtreeview_p.h | 4 +-- src/widgets/itemviews/qtreewidget_p.h | 4 +-- src/widgets/kernel/qapplication_p.h | 8 ++--- src/widgets/kernel/qgesture_p.h | 2 +- src/widgets/kernel/qlayout_p.h | 2 +- src/widgets/kernel/qlayoutengine_p.h | 6 ++-- src/widgets/kernel/qwidget_p.h | 32 +++++++++---------- src/widgets/kernel/qwidgetbackingstore_p.h | 6 ++-- src/widgets/kernel/qwindowcontainer_p.h | 2 +- .../statemachine/qbasickeyeventtransition_p.h | 6 ++-- .../qbasicmouseeventtransition_p.h | 4 +-- src/widgets/styles/qcommonstyle_p.h | 2 +- src/widgets/styles/qfusionstyle_p.h | 18 +++++------ src/widgets/styles/qpixmapstyle_p.h | 2 +- src/widgets/styles/qproxystyle_p.h | 2 +- src/widgets/styles/qstyle_p.h | 2 +- src/widgets/styles/qstylehelper_p.h | 4 +-- src/widgets/styles/qstylesheetstyle_p.h | 32 +++++++++---------- src/widgets/styles/qwindowsstyle_p.h | 22 ++++++------- src/widgets/styles/qwindowsstyle_p_p.h | 4 +-- src/widgets/util/qcompleter_p.h | 2 +- src/widgets/util/qflickgesture_p.h | 2 +- src/widgets/util/qundostack_p.h | 4 +-- src/widgets/widgets/qabstractslider_p.h | 2 +- src/widgets/widgets/qabstractspinbox_p.h | 2 +- src/widgets/widgets/qcombobox_p.h | 4 +-- src/widgets/widgets/qdatetimeedit_p.h | 4 +-- src/widgets/widgets/qdockarealayout_p.h | 2 +- src/widgets/widgets/qdockwidget_p.h | 12 +++---- src/widgets/widgets/qlineedit_p.h | 4 +-- src/widgets/widgets/qmainwindowlayout_p.h | 6 ++-- src/widgets/widgets/qmdiarea_p.h | 4 +-- src/widgets/widgets/qmdisubwindow_p.h | 8 ++--- src/widgets/widgets/qmenu_p.h | 8 ++--- src/widgets/widgets/qmenubar_p.h | 4 +-- src/widgets/widgets/qscrollarea_p.h | 2 +- src/widgets/widgets/qsplitter_p.h | 6 ++-- src/widgets/widgets/qtabbar_p.h | 4 +-- src/widgets/widgets/qtoolbar_p.h | 2 +- src/widgets/widgets/qtoolbararealayout_p.h | 2 +- src/widgets/widgets/qtoolbarlayout_p.h | 2 +- src/widgets/widgets/qwidgetlinecontrol_p.h | 4 +-- src/widgets/widgets/qwidgetresizehandler_p.h | 2 +- src/widgets/widgets/qwidgettextcontrol_p.h | 18 +++++------ src/widgets/widgets/qwidgettextcontrol_p_p.h | 4 +-- 261 files changed, 641 insertions(+), 641 deletions(-) diff --git a/src/concurrent/qtconcurrentcompilertest.h b/src/concurrent/qtconcurrentcompilertest.h index cddfd06ca1..72cf1670a0 100644 --- a/src/concurrent/qtconcurrentcompilertest.h +++ b/src/concurrent/qtconcurrentcompilertest.h @@ -52,7 +52,7 @@ template class HasResultType { typedef char Yes; typedef void *No; - template static Yes test(int, const typename U::result_type * = 0); + template static Yes test(int, const typename U::result_type * = nullptr); template static No test(double); public: enum { Value = (sizeof(test(0)) == sizeof(Yes)) }; diff --git a/src/concurrent/qtconcurrentfilterkernel.h b/src/concurrent/qtconcurrentfilterkernel.h index 9cbea2e671..e921a3d51a 100644 --- a/src/concurrent/qtconcurrentfilterkernel.h +++ b/src/concurrent/qtconcurrentfilterkernel.h @@ -266,7 +266,7 @@ public: if (keep(*it)) this->reportResult(&(*it), index); else - this->reportResult(0, index); + this->reportResult(nullptr, index); return false; } diff --git a/src/concurrent/qtconcurrentmapkernel.h b/src/concurrent/qtconcurrentmapkernel.h index 3424124118..87fcf30cf9 100644 --- a/src/concurrent/qtconcurrentmapkernel.h +++ b/src/concurrent/qtconcurrentmapkernel.h @@ -74,7 +74,7 @@ public: Iterator it = sequenceBeginIterator; std::advance(it, beginIndex); for (int i = beginIndex; i < endIndex; ++i) { - runIteration(it, i, 0); + runIteration(it, i, nullptr); std::advance(it, 1); } diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h index 3b6e8d6cc4..037d3be74f 100644 --- a/src/corelib/animation/qabstractanimation_p.h +++ b/src/corelib/animation/qabstractanimation_p.h @@ -78,7 +78,7 @@ public: hasRegisteredTimer(false), isPause(false), isGroup(false), - group(0) + group(nullptr) { } diff --git a/src/corelib/animation/qanimationgroup_p.h b/src/corelib/animation/qanimationgroup_p.h index ff759d11fd..215734b656 100644 --- a/src/corelib/animation/qanimationgroup_p.h +++ b/src/corelib/animation/qanimationgroup_p.h @@ -76,7 +76,7 @@ public: void disconnectUncontrolledAnimation(QAbstractAnimation *anim) { //0 for the signal here because we might be called from the animation destructor - QObject::disconnect(anim, 0, q_func(), SLOT(_q_uncontrolledAnimationFinished())); + QObject::disconnect(anim, nullptr, q_func(), SLOT(_q_uncontrolledAnimationFinished())); } void connectUncontrolledAnimation(QAbstractAnimation *anim) diff --git a/src/corelib/animation/qpropertyanimation_p.h b/src/corelib/animation/qpropertyanimation_p.h index 479762f573..cbd3ce287d 100644 --- a/src/corelib/animation/qpropertyanimation_p.h +++ b/src/corelib/animation/qpropertyanimation_p.h @@ -64,7 +64,7 @@ class QPropertyAnimationPrivate : public QVariantAnimationPrivate Q_DECLARE_PUBLIC(QPropertyAnimation) public: QPropertyAnimationPrivate() - : targetValue(0), propertyType(0), propertyIndex(-1) + : targetValue(nullptr), propertyType(0), propertyIndex(-1) { } diff --git a/src/corelib/animation/qsequentialanimationgroup_p.h b/src/corelib/animation/qsequentialanimationgroup_p.h index 88dac4f566..c082d6b524 100644 --- a/src/corelib/animation/qsequentialanimationgroup_p.h +++ b/src/corelib/animation/qsequentialanimationgroup_p.h @@ -63,7 +63,7 @@ class QSequentialAnimationGroupPrivate : public QAnimationGroupPrivate Q_DECLARE_PUBLIC(QSequentialAnimationGroup) public: QSequentialAnimationGroupPrivate() - : currentAnimation(0), currentAnimationIndex(-1), lastLoop(0) + : currentAnimation(nullptr), currentAnimationIndex(-1), lastLoop(0) { } diff --git a/src/corelib/codecs/qtextcodec_p.h b/src/corelib/codecs/qtextcodec_p.h index 0e449d994c..7fcf6df984 100644 --- a/src/corelib/codecs/qtextcodec_p.h +++ b/src/corelib/codecs/qtextcodec_p.h @@ -98,7 +98,7 @@ public: struct ConverterState { ConverterState(ConversionFlags f = DefaultConversion) - : flags(f), remainingChars(0), invalidChars(0), d(0) { state_data[0] = state_data[1] = state_data[2] = 0; } + : flags(f), remainingChars(0), invalidChars(0), d(nullptr) { state_data[0] = state_data[1] = state_data[2] = 0; } ~ConverterState() { } ConversionFlags flags; int remainingChars; diff --git a/src/corelib/global/qglobalstatic.h b/src/corelib/global/qglobalstatic.h index 555bdf04c1..93d71cee57 100644 --- a/src/corelib/global/qglobalstatic.h +++ b/src/corelib/global/qglobalstatic.h @@ -131,8 +131,8 @@ struct QGlobalStatic bool isDestroyed() const { return guard.load() <= QtGlobalStatic::Destroyed; } bool exists() const { return guard.load() == QtGlobalStatic::Initialized; } - operator Type *() { if (isDestroyed()) return 0; return innerFunction(); } - Type *operator()() { if (isDestroyed()) return 0; return innerFunction(); } + operator Type *() { if (isDestroyed()) return nullptr; return innerFunction(); } + Type *operator()() { if (isDestroyed()) return nullptr; return innerFunction(); } Type *operator->() { Q_ASSERT_X(!isDestroyed(), "Q_GLOBAL_STATIC", "The global static was used after being destroyed"); diff --git a/src/corelib/io/qabstractfileengine_p.h b/src/corelib/io/qabstractfileengine_p.h index 4a7fe7bff5..c88b66c7ce 100644 --- a/src/corelib/io/qabstractfileengine_p.h +++ b/src/corelib/io/qabstractfileengine_p.h @@ -193,7 +193,7 @@ public: uchar *address; }; - virtual bool extension(Extension extension, const ExtensionOption *option = 0, ExtensionReturn *output = 0); + virtual bool extension(Extension extension, const ExtensionOption *option = nullptr, ExtensionReturn *output = nullptr); virtual bool supportsExtension(Extension extension) const; // Factory diff --git a/src/corelib/io/qfileinfo_p.h b/src/corelib/io/qfileinfo_p.h index e4b28f4519..36f440812f 100644 --- a/src/corelib/io/qfileinfo_p.h +++ b/src/corelib/io/qfileinfo_p.h @@ -80,7 +80,7 @@ public: }; inline QFileInfoPrivate() - : QSharedData(), fileEngine(0), + : QSharedData(), fileEngine(nullptr), cachedFlags(0), isDefaultConstructed(true), cache_enabled(true), fileFlags(0), fileSize(0) diff --git a/src/corelib/io/qfilesystemengine_p.h b/src/corelib/io/qfilesystemengine_p.h index 09ec2d6a10..e44837747c 100644 --- a/src/corelib/io/qfilesystemengine_p.h +++ b/src/corelib/io/qfilesystemengine_p.h @@ -130,7 +130,7 @@ public: static bool removeFile(const QFileSystemEntry &entry, QSystemError &error); static bool setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QSystemError &error, - QFileSystemMetaData *data = 0); + QFileSystemMetaData *data = nullptr); // unused, therefore not implemented static bool setFileTime(const QFileSystemEntry &entry, const QDateTime &newDate, diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h index 4d2a5acb9b..81f4b3ba13 100644 --- a/src/corelib/io/qfilesystemmetadata_p.h +++ b/src/corelib/io/qfilesystemmetadata_p.h @@ -76,7 +76,7 @@ class Q_AUTOTEST_EXPORT QFileSystemMetaData { public: QFileSystemMetaData() - : knownFlagsMask(0), + : knownFlagsMask(nullptr), size_(-1) { } @@ -184,7 +184,7 @@ public: void clear() { - knownFlagsMask = 0; + knownFlagsMask = nullptr; } void clearFlags(MetaDataFlags flags = AllMetaDataFlags) diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h index 6b091a8eef..0f416f4886 100644 --- a/src/corelib/io/qfsfileengine_p.h +++ b/src/corelib/io/qfsfileengine_p.h @@ -115,7 +115,7 @@ public: virtual bool isUnnamedFile() const { return false; } - bool extension(Extension extension, const ExtensionOption *option = 0, ExtensionReturn *output = 0) override; + bool extension(Extension extension, const ExtensionOption *option = nullptr, ExtensionReturn *output = nullptr) override; bool supportsExtension(Extension extension) const override; //FS only!! diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h index aa7ecbe91d..1bc63240fe 100644 --- a/src/corelib/io/qprocess_p.h +++ b/src/corelib/io/qprocess_p.h @@ -247,7 +247,7 @@ public: // if you add "= 4" here, increase the number of bits below }; - Channel() : process(0), notifier(0), type(Normal), closed(false), append(false) + Channel() : process(nullptr), notifier(nullptr), type(Normal), closed(false), append(false) { pipe[0] = INVALID_Q_PIPE; pipe[1] = INVALID_Q_PIPE; diff --git a/src/corelib/io/qresource_p.h b/src/corelib/io/qresource_p.h index 7451de8809..fedf95bb33 100644 --- a/src/corelib/io/qresource_p.h +++ b/src/corelib/io/qresource_p.h @@ -108,7 +108,7 @@ public: Iterator *beginEntryList(QDir::Filters filters, const QStringList &filterNames) override; Iterator *endEntryList() override; - bool extension(Extension extension, const ExtensionOption *option = 0, ExtensionReturn *output = 0) override; + bool extension(Extension extension, const ExtensionOption *option = nullptr, ExtensionReturn *output = nullptr) override; bool supportsExtension(Extension extension) const override; }; diff --git a/src/corelib/io/qurl_p.h b/src/corelib/io/qurl_p.h index 1b9237e58a..e75de32e03 100644 --- a/src/corelib/io/qurl_p.h +++ b/src/corelib/io/qurl_p.h @@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE // in qurlrecode.cpp extern Q_AUTOTEST_EXPORT int qt_urlRecode(QString &appendTo, const QChar *begin, const QChar *end, - QUrl::ComponentFormattingOptions encoding, const ushort *tableModifications = 0); + QUrl::ComponentFormattingOptions encoding, const ushort *tableModifications = nullptr); // in qurlidna.cpp enum AceLeadingDot { AllowLeadingDot, ForbidLeadingDot }; diff --git a/src/corelib/itemmodels/qabstractitemmodel_p.h b/src/corelib/itemmodels/qabstractitemmodel_p.h index e6085eca94..92a440a125 100644 --- a/src/corelib/itemmodels/qabstractitemmodel_p.h +++ b/src/corelib/itemmodels/qabstractitemmodel_p.h @@ -98,7 +98,7 @@ public: void itemsMoved(const QModelIndex &srcParent, int srcFirst, int srcLast, const QModelIndex &destinationParent, int destinationChild, Qt::Orientation orientation); bool allowMove(const QModelIndex &srcParent, int srcFirst, int srcLast, const QModelIndex &destinationParent, int destinationChild, Qt::Orientation orientation); - inline QModelIndex createIndex(int row, int column, void *data = 0) const { + inline QModelIndex createIndex(int row, int column, void *data = nullptr) const { return q_func()->createIndex(row, column, data); } diff --git a/src/corelib/itemmodels/qabstractproxymodel_p.h b/src/corelib/itemmodels/qabstractproxymodel_p.h index f7bd5cc691..a95687c970 100644 --- a/src/corelib/itemmodels/qabstractproxymodel_p.h +++ b/src/corelib/itemmodels/qabstractproxymodel_p.h @@ -62,7 +62,7 @@ class Q_CORE_EXPORT QAbstractProxyModelPrivate : public QAbstractItemModelPrivat { Q_DECLARE_PUBLIC(QAbstractProxyModel) public: - QAbstractProxyModelPrivate() : QAbstractItemModelPrivate(), model(0) {} + QAbstractProxyModelPrivate() : QAbstractItemModelPrivate(), model(nullptr) {} QAbstractItemModel *model; virtual void _q_sourceModelDestroyed(); void mapDropCoordinatesToSource(int row, int column, const QModelIndex &parent, diff --git a/src/corelib/itemmodels/qitemselectionmodel_p.h b/src/corelib/itemmodels/qitemselectionmodel_p.h index e12a0c2928..ba85f22be3 100644 --- a/src/corelib/itemmodels/qitemselectionmodel_p.h +++ b/src/corelib/itemmodels/qitemselectionmodel_p.h @@ -62,7 +62,7 @@ class QItemSelectionModelPrivate: public QObjectPrivate Q_DECLARE_PUBLIC(QItemSelectionModel) public: QItemSelectionModelPrivate() - : model(0), + : model(nullptr), currentCommand(QItemSelectionModel::NoUpdate), tableSelected(false), tableColCount(0), tableRowCount(0) {} diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h index 5a2a29a327..32ef6408c2 100644 --- a/src/corelib/kernel/qcore_unix_p.h +++ b/src/corelib/kernel/qcore_unix_p.h @@ -171,7 +171,7 @@ inline void qt_ignore_sigpipe() struct sigaction noaction; memset(&noaction, 0, sizeof(noaction)); noaction.sa_handler = SIG_IGN; - ::sigaction(SIGPIPE, &noaction, 0); + ::sigaction(SIGPIPE, &noaction, nullptr); atom.store(1); } } diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h index b3479414ab..14ca3efd7f 100644 --- a/src/corelib/kernel/qcoreapplication_p.h +++ b/src/corelib/kernel/qcoreapplication_p.h @@ -149,7 +149,7 @@ public: QString cachedApplicationDirPath; static QString *cachedApplicationFilePath; static void setApplicationFilePath(const QString &path); - static inline void clearApplicationFilePath() { delete cachedApplicationFilePath; cachedApplicationFilePath = 0; } + static inline void clearApplicationFilePath() { delete cachedApplicationFilePath; cachedApplicationFilePath = nullptr; } #ifndef QT_NO_QOBJECT void execCleanup(); diff --git a/src/corelib/kernel/qeventdispatcher_glib_p.h b/src/corelib/kernel/qeventdispatcher_glib_p.h index 88ff316ee5..313825d0a7 100644 --- a/src/corelib/kernel/qeventdispatcher_glib_p.h +++ b/src/corelib/kernel/qeventdispatcher_glib_p.h @@ -66,8 +66,8 @@ class Q_CORE_EXPORT QEventDispatcherGlib : public QAbstractEventDispatcher Q_DECLARE_PRIVATE(QEventDispatcherGlib) public: - explicit QEventDispatcherGlib(QObject *parent = 0); - explicit QEventDispatcherGlib(GMainContext *context, QObject *parent = 0); + explicit QEventDispatcherGlib(QObject *parent = nullptr); + explicit QEventDispatcherGlib(GMainContext *context, QObject *parent = nullptr); ~QEventDispatcherGlib(); bool processEvents(QEventLoop::ProcessEventsFlags flags) override; @@ -102,7 +102,7 @@ class Q_CORE_EXPORT QEventDispatcherGlibPrivate : public QAbstractEventDispatche { public: - QEventDispatcherGlibPrivate(GMainContext *context = 0); + QEventDispatcherGlibPrivate(GMainContext *context = nullptr); GMainContext *mainContext; GPostEventSource *postEventSource; GSocketNotifierSource *socketNotifierSource; diff --git a/src/corelib/kernel/qeventdispatcher_unix_p.h b/src/corelib/kernel/qeventdispatcher_unix_p.h index 0fd068b074..8cfa4bbdf7 100644 --- a/src/corelib/kernel/qeventdispatcher_unix_p.h +++ b/src/corelib/kernel/qeventdispatcher_unix_p.h @@ -102,7 +102,7 @@ class Q_CORE_EXPORT QEventDispatcherUNIX : public QAbstractEventDispatcher Q_DECLARE_PRIVATE(QEventDispatcherUNIX) public: - explicit QEventDispatcherUNIX(QObject *parent = 0); + explicit QEventDispatcherUNIX(QObject *parent = nullptr); ~QEventDispatcherUNIX(); bool processEvents(QEventLoop::ProcessEventsFlags flags) override; @@ -123,7 +123,7 @@ public: void flush() override; protected: - QEventDispatcherUNIX(QEventDispatcherUNIXPrivate &dd, QObject *parent = 0); + QEventDispatcherUNIX(QEventDispatcherUNIXPrivate &dd, QObject *parent = nullptr); }; class Q_CORE_EXPORT QEventDispatcherUNIXPrivate : public QAbstractEventDispatcherPrivate @@ -152,9 +152,9 @@ public: inline QSocketNotifierSetUNIX::QSocketNotifierSetUNIX() Q_DECL_NOTHROW { - notifiers[0] = 0; - notifiers[1] = 0; - notifiers[2] = 0; + notifiers[0] = nullptr; + notifiers[1] = nullptr; + notifiers[2] = nullptr; } inline bool QSocketNotifierSetUNIX::isEmpty() const Q_DECL_NOTHROW diff --git a/src/corelib/kernel/qmetaobject_moc_p.h b/src/corelib/kernel/qmetaobject_moc_p.h index ad258acfcd..8c7900767b 100644 --- a/src/corelib/kernel/qmetaobject_moc_p.h +++ b/src/corelib/kernel/qmetaobject_moc_p.h @@ -138,7 +138,7 @@ static QByteArray normalizeTypeInternal(const char *t, const char *e, bool fixSc { "struct ", 7 }, { "class ", 6 }, { "enum ", 5 }, - { 0, 0 } + { nullptr, 0 } }; int i = 0; do { @@ -146,7 +146,7 @@ static QByteArray normalizeTypeInternal(const char *t, const char *e, bool fixSc t += optional[i].len; break; } - } while (optional[++i].keyword != 0); + } while (optional[++i].keyword != nullptr); } bool star = false; diff --git a/src/corelib/kernel/qmetaobject_p.h b/src/corelib/kernel/qmetaobject_p.h index 5b412b5140..26d86fdf14 100644 --- a/src/corelib/kernel/qmetaobject_p.h +++ b/src/corelib/kernel/qmetaobject_p.h @@ -226,8 +226,8 @@ struct QMetaObjectPrivate static QObjectPrivate::Connection *connect(const QObject *sender, int signal_index, const QMetaObject *smeta, const QObject *receiver, int method_index_relative, - const QMetaObject *rmeta = 0, - int type = 0, int *types = 0); + const QMetaObject *rmeta = nullptr, + int type = 0, int *types = nullptr); static bool disconnect(const QObject *sender, int signal_index, const QMetaObject *smeta, const QObject *receiver, int method_index, void **slot, diff --git a/src/corelib/kernel/qmetaobjectbuilder_p.h b/src/corelib/kernel/qmetaobjectbuilder_p.h index 6100835bad..6d43be7811 100644 --- a/src/corelib/kernel/qmetaobjectbuilder_p.h +++ b/src/corelib/kernel/qmetaobjectbuilder_p.h @@ -173,7 +173,7 @@ public: void setStaticMetacallFunction(QMetaObjectBuilder::StaticMetacallFunction value); QMetaObject *toMetaObject() const; - QByteArray toRelocatableData(bool * = 0) const; + QByteArray toRelocatableData(bool * = nullptr) const; static void fromRelocatableData(QMetaObject *, const QMetaObject *, const QByteArray &); #ifndef QT_NO_DATASTREAM @@ -196,7 +196,7 @@ private: class Q_CORE_EXPORT QMetaMethodBuilder { public: - QMetaMethodBuilder() : _mobj(0), _index(0) {} + QMetaMethodBuilder() : _mobj(nullptr), _index(0) {} int index() const; @@ -238,7 +238,7 @@ private: class Q_CORE_EXPORT QMetaPropertyBuilder { public: - QMetaPropertyBuilder() : _mobj(0), _index(0) {} + QMetaPropertyBuilder() : _mobj(nullptr), _index(0) {} int index() const { return _index; } @@ -294,7 +294,7 @@ private: class Q_CORE_EXPORT QMetaEnumBuilder { public: - QMetaEnumBuilder() : _mobj(0), _index(0) {} + QMetaEnumBuilder() : _mobj(nullptr), _index(0) {} int index() const { return _index; } diff --git a/src/corelib/kernel/qsharedmemory_p.h b/src/corelib/kernel/qsharedmemory_p.h index 95fe0d1083..59802eb6ce 100644 --- a/src/corelib/kernel/qsharedmemory_p.h +++ b/src/corelib/kernel/qsharedmemory_p.h @@ -98,7 +98,7 @@ public: { if (q_sm && q_sm->lock()) return true; - q_sm = 0; + q_sm = nullptr; return false; } diff --git a/src/corelib/kernel/qvariant_p.h b/src/corelib/kernel/qvariant_p.h index b22b7c231e..3d87beac83 100644 --- a/src/corelib/kernel/qvariant_p.h +++ b/src/corelib/kernel/qvariant_p.h @@ -88,7 +88,7 @@ inline T *v_cast(const QVariant::Private *nd, T * = 0) #else // every other compiler in this world template -inline const T *v_cast(const QVariant::Private *d, T * = 0) +inline const T *v_cast(const QVariant::Private *d, T * = nullptr) { return !QVariantIntegrator::CanUseInternalSpace ? static_cast(d->data.shared->ptr) @@ -96,7 +96,7 @@ inline const T *v_cast(const QVariant::Private *d, T * = 0) } template -inline T *v_cast(QVariant::Private *d, T * = 0) +inline T *v_cast(QVariant::Private *d, T * = nullptr) { return !QVariantIntegrator::CanUseInternalSpace ? static_cast(d->data.shared->ptr) @@ -154,7 +154,7 @@ inline void v_construct(QVariant::Private *x, const T &t) // constructs a new variant if copy is 0, otherwise copy-constructs template -inline void v_construct(QVariant::Private *x, const void *copy, T * = 0) +inline void v_construct(QVariant::Private *x, const void *copy, T * = nullptr) { if (copy) v_construct(x, *static_cast(copy)); @@ -164,7 +164,7 @@ inline void v_construct(QVariant::Private *x, const void *copy, T * = 0) // deletes the internal structures template -inline void v_clear(QVariant::Private *d, T* = 0) +inline void v_clear(QVariant::Private *d, T* = nullptr) { if (!QVariantIntegrator::CanUseInternalSpace) { @@ -264,7 +264,7 @@ class QVariantIsNull struct No { char unused[2]; }; Q_STATIC_ASSERT(sizeof(Yes) != sizeof(No)); - template static decltype(static_cast(0)->isNull(), Yes()) test(int); + template static decltype(static_cast(nullptr)->isNull(), Yes()) test(int); template static No test(...); public: static const bool Value = (sizeof(test(0)) == sizeof(Yes)); diff --git a/src/corelib/plugin/qlibrary_p.h b/src/corelib/plugin/qlibrary_p.h index 3f650501c8..1a216c98b5 100644 --- a/src/corelib/plugin/qlibrary_p.h +++ b/src/corelib/plugin/qlibrary_p.h @@ -96,7 +96,7 @@ public: void setLoadHints(QLibrary::LoadHints lh); static QLibraryPrivate *findOrCreate(const QString &fileName, const QString &version = QString(), - QLibrary::LoadHints loadHints = 0); + QLibrary::LoadHints loadHints = nullptr); static QStringList suffixes_sys(const QString &fullVersion); static QStringList prefixes_sys(); diff --git a/src/corelib/serialization/qjson_p.h b/src/corelib/serialization/qjson_p.h index 40b2414e4a..a9e7059cbe 100644 --- a/src/corelib/serialization/qjson_p.h +++ b/src/corelib/serialization/qjson_p.h @@ -686,7 +686,7 @@ public: { } inline Data(int reserved, QJsonValue::Type valueType) - : rawData(0), compactionCounter(0), ownsData(true) + : rawData(nullptr), compactionCounter(0), ownsData(true) { Q_ASSERT(valueType == QJsonValue::Array || valueType == QJsonValue::Object); @@ -728,7 +728,7 @@ public: size = qMax(size + reserve, qMin(size *2, (int)Value::MaxSize)); if (size > Value::MaxSize) { qWarning("QJson: Document too large to store in data structure"); - return 0; + return nullptr; } } char *raw = (char *)malloc(size); diff --git a/src/corelib/serialization/qxmlstream_p.h b/src/corelib/serialization/qxmlstream_p.h index 61f501f81b..cde66a48a3 100644 --- a/src/corelib/serialization/qxmlstream_p.h +++ b/src/corelib/serialization/qxmlstream_p.h @@ -162,12 +162,12 @@ public: const char *const QXmlStreamReader_Table::spell [] = { - "end of file", 0, " ", "<", ">", "&", "#", "\'", "\"", "[", + "end of file", nullptr, " ", "<", ">", "&", "#", "\'", "\"", "[", "]", "(", ")", "|", "=", "%", "/", ":", ";", ",", "-", "+", "*", ".", "?", "!", "[a-zA-Z]", "[0-9]", "[CDATA[", "DOCTYPE", "ELEMENT", "ATTLIST", "ENTITY", "NOTATION", "SYSTEM", "PUBLIC", "NDATA", "REQUIRED", "IMPLIED", "FIXED", - "EMPTY", "ANY", "PCDATA", 0, 0, 0, 0, "CDATA", "ID", "IDREF", - "IDREFS", "ENTITIES", "NMTOKEN", "NMTOKENS", " class QXmlStreamSimpleStack { T *data; int tos, cap; public: - inline QXmlStreamSimpleStack():data(0), tos(-1), cap(0){} + inline QXmlStreamSimpleStack():data(nullptr), tos(-1), cap(0){} inline ~QXmlStreamSimpleStack(){ if (data) free(data); } inline void reserve(int extraCapacity) { @@ -995,7 +995,7 @@ public: int fastScanLiteralContent(); int fastScanSpace(); int fastScanContentCharList(); - int fastScanName(int *prefix = 0); + int fastScanName(int *prefix = nullptr); inline int fastScanNMTOKEN(); diff --git a/src/corelib/statemachine/qstate_p.h b/src/corelib/statemachine/qstate_p.h index 7fb40392e7..ec746caae1 100644 --- a/src/corelib/statemachine/qstate_p.h +++ b/src/corelib/statemachine/qstate_p.h @@ -68,14 +68,14 @@ QT_BEGIN_NAMESPACE struct QPropertyAssignment { QPropertyAssignment() - : object(0), explicitlySet(true) {} + : object(nullptr), explicitlySet(true) {} QPropertyAssignment(QObject *o, const QByteArray &n, const QVariant &v, bool es = true) : object(o), propertyName(n), value(v), explicitlySet(es) {} bool objectDeleted() const { return !object; } - void write() const { Q_ASSERT(object != 0); object->setProperty(propertyName, value); } + void write() const { Q_ASSERT(object != nullptr); object->setProperty(propertyName, value); } bool hasTarget(QObject *o, const QByteArray &pn) const { return object == o && propertyName == pn; } @@ -99,8 +99,8 @@ public: QStatePrivate(); ~QStatePrivate(); - static QStatePrivate *get(QState *q) { return q ? q->d_func() : 0; } - static const QStatePrivate *get(const QState *q) { return q? q->d_func() : 0; } + static QStatePrivate *get(QState *q) { return q ? q->d_func() : nullptr; } + static const QStatePrivate *get(const QState *q) { return q? q->d_func() : nullptr; } QList childStates() const; QList historyStates() const; diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h index f3366ca5f7..c66130b8ce 100644 --- a/src/corelib/statemachine/qstatemachine_p.h +++ b/src/corelib/statemachine/qstatemachine_p.h @@ -108,7 +108,7 @@ public: ~QStateMachinePrivate(); static QStateMachinePrivate *get(QStateMachine *q) - { return q ? q->d_func() : 0; } + { return q ? q->d_func() : nullptr; } QState *findLCA(const QList &states, bool onlyCompound = false) const; QState *findLCCA(const QList &states) const; @@ -313,7 +313,7 @@ public: DelayedEvent(QEvent *e, int tid) : event(e), timerId(tid) {} DelayedEvent() - : event(0), timerId(0) {} + : event(nullptr), timerId(0) {} }; QHash delayedEvents; QHash timerIdToDelayedEventId; diff --git a/src/corelib/thread/qatomic_bootstrap.h b/src/corelib/thread/qatomic_bootstrap.h index b463f817bd..27a67fb2ee 100644 --- a/src/corelib/thread/qatomic_bootstrap.h +++ b/src/corelib/thread/qatomic_bootstrap.h @@ -65,7 +65,7 @@ template struct QAtomicOps: QGenericAtomicOps > return --_q_value != 0; } - static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue = 0) Q_DECL_NOTHROW + static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue = nullptr) Q_DECL_NOTHROW { if (currentValue) *currentValue = _q_value; diff --git a/src/corelib/thread/qresultstore.h b/src/corelib/thread/qresultstore.h index 1f29e8d187..7a65089396 100644 --- a/src/corelib/thread/qresultstore.h +++ b/src/corelib/thread/qresultstore.h @@ -142,7 +142,7 @@ public: template int addResult(int index, const T *result) { - if (result == 0) + if (result == nullptr) return addResult(index, static_cast(nullptr)); else return addResult(index, static_cast(new T(*result))); @@ -158,7 +158,7 @@ public: int addResults(int index, const QVector *results, int totalCount) { if (m_filterMode == true && results->count() != totalCount && 0 == results->count()) - return addResults(index, 0, 0, totalCount); + return addResults(index, nullptr, 0, totalCount); else return addResults(index, new QVector(*results), results->count(), totalCount); } diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h index 7d9442ab79..e614ddd004 100644 --- a/src/corelib/thread/qthread_p.h +++ b/src/corelib/thread/qthread_p.h @@ -89,7 +89,7 @@ public: QEvent *event; int priority; inline QPostEvent() - : receiver(0), event(0), priority(0) + : receiver(nullptr), event(nullptr), priority(0) { } inline QPostEvent(QObject *r, QEvent *e, int p) : receiver(r), event(e), priority(p) @@ -148,7 +148,7 @@ private: class Q_CORE_EXPORT QDaemonThread : public QThread { public: - QDaemonThread(QObject *parent = 0); + QDaemonThread(QObject *parent = nullptr); ~QDaemonThread(); }; @@ -157,7 +157,7 @@ class QThreadPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QThread) public: - QThreadPrivate(QThreadData *d = 0); + QThreadPrivate(QThreadData *d = nullptr); ~QThreadPrivate(); void setPriority(QThread::Priority prio); @@ -248,7 +248,7 @@ public: #endif static void clearCurrentThreadData(); static QThreadData *get2(QThread *thread) - { Q_ASSERT_X(thread != 0, "QThread", "internal error"); return thread->d_func()->data; } + { Q_ASSERT_X(thread != nullptr, "QThread", "internal error"); return thread->d_func()->data; } void ref(); @@ -281,7 +281,7 @@ public: public: FlaggedDebugSignatures() : idx(0) - { std::fill_n(locations, Count, static_cast(0)); } + { std::fill_n(locations, Count, static_cast(nullptr)); } void store(const char* method) { locations[idx++ % Count] = method; } @@ -328,7 +328,7 @@ class QAdoptedThread : public QThread Q_DECLARE_PRIVATE(QThread) public: - QAdoptedThread(QThreadData *data = 0); + QAdoptedThread(QThreadData *data = nullptr); ~QAdoptedThread(); void init(); diff --git a/src/corelib/thread/qthreadpool_p.h b/src/corelib/thread/qthreadpool_p.h index 952e02ef20..01852d8366 100644 --- a/src/corelib/thread/qthreadpool_p.h +++ b/src/corelib/thread/qthreadpool_p.h @@ -162,7 +162,7 @@ public: void tryToStartMoreThreads(); bool tooManyThreadsActive() const; - void startThread(QRunnable *runnable = 0); + void startThread(QRunnable *runnable = nullptr); void reset(); bool waitForDone(int msecs); bool waitForDone(const QDeadlineTimer &timer); diff --git a/src/corelib/thread/qthreadstorage.h b/src/corelib/thread/qthreadstorage.h index 55fc482da3..9eb8672e92 100644 --- a/src/corelib/thread/qthreadstorage.h +++ b/src/corelib/thread/qthreadstorage.h @@ -69,7 +69,7 @@ inline T *&qThreadStorage_localData(QThreadStorageData &d, T **) { void **v = d.get(); - if (!v) v = d.set(0); + if (!v) v = d.set(nullptr); return *(reinterpret_cast(v)); } @@ -139,7 +139,7 @@ public: inline ~QThreadStorage() { } inline bool hasLocalData() const - { return d.get() != 0; } + { return d.get() != nullptr; } inline T& localData() { return qThreadStorage_localData(d, reinterpret_cast(0)); } diff --git a/src/corelib/tools/qcache.h b/src/corelib/tools/qcache.h index 8c0e7860f7..b558a8358d 100644 --- a/src/corelib/tools/qcache.h +++ b/src/corelib/tools/qcache.h @@ -51,7 +51,7 @@ class QCache struct Node { inline Node() : keyPtr(0) {} inline Node(T *data, int cost) - : keyPtr(0), t(data), c(cost), p(0), n(0) {} + : keyPtr(nullptr), t(data), c(cost), p(nullptr), n(nullptr) {} const Key *keyPtr; T *t; int c; Node *p,*n; }; Node *f, *l; @@ -71,14 +71,14 @@ class QCache inline T *relink(const Key &key) { typename QHash::iterator i = hash.find(key); if (typename QHash::const_iterator(i) == hash.constEnd()) - return 0; + return nullptr; Node &n = *i; if (f != &n) { if (n.p) n.p->n = n.n; if (n.n) n.n->p = n.p; if (l == &n) l = n.p; - n.p = 0; + n.p = nullptr; n.n = f; f->p = &n; f = &n; @@ -117,12 +117,12 @@ private: template inline QCache::QCache(int amaxCost) Q_DECL_NOTHROW - : f(0), l(0), mx(amaxCost), total(0) {} + : f(nullptr), l(nullptr), mx(amaxCost), total(0) {} template inline void QCache::clear() { while (f) { delete f->t; f = f->n; } - hash.clear(); l = 0; total = 0; } + hash.clear(); l = nullptr; total = 0; } template inline void QCache::setMaxCost(int m) @@ -153,11 +153,11 @@ inline T *QCache::take(const Key &key) { typename QHash::iterator i = hash.find(key); if (i == hash.end()) - return 0; + return nullptr; Node &n = *i; T *t = n.t; - n.t = 0; + n.t = nullptr; unlink(n); return t; } diff --git a/src/corelib/tools/qdatetime_p.h b/src/corelib/tools/qdatetime_p.h index 4d30d4192b..6e4120d762 100644 --- a/src/corelib/tools/qdatetime_p.h +++ b/src/corelib/tools/qdatetime_p.h @@ -135,7 +135,7 @@ public: #if QT_CONFIG(timezone) static qint64 zoneMSecsToEpochMSecs(qint64 msecs, const QTimeZone &zone, DaylightStatus hint = UnknownDaylightTime, - QDate *localDate = 0, QTime *localTime = 0); + QDate *localDate = nullptr, QTime *localTime = nullptr); // Inlined for its one caller in qdatetime.cpp inline void setUtcOffsetByTZ(qint64 atMSecsSinceEpoch); diff --git a/src/corelib/tools/qdatetimeparser_p.h b/src/corelib/tools/qdatetimeparser_p.h index f7e6e351fe..e244fed09a 100644 --- a/src/corelib/tools/qdatetimeparser_p.h +++ b/src/corelib/tools/qdatetimeparser_p.h @@ -86,7 +86,7 @@ public: DateTimeEdit }; QDateTimeParser(QVariant::Type t, Context ctx) - : currentSectionIndex(-1), display(0), cachedDay(-1), parserType(t), + : currentSectionIndex(-1), display(nullptr), cachedDay(-1), parserType(t), fixday(false), spec(Qt::LocalTime), context(ctx) { defaultLocale = QLocale::system(); @@ -218,9 +218,9 @@ private: ParsedSection parseSection(const QDateTime ¤tValue, int sectionIndex, int offset, QString *text) const; int findMonth(const QString &str1, int monthstart, int sectionIndex, - QString *monthName = 0, int *used = 0) const; + QString *monthName = nullptr, int *used = nullptr) const; int findDay(const QString &str1, int intDaystart, int sectionIndex, - QString *dayName = 0, int *used = 0) const; + QString *dayName = nullptr, int *used = nullptr) const; ParsedSection findTimeZone(QStringRef str, const QDateTime &when, int maxVal, int minVal) const; #if QT_CONFIG(timezone) @@ -236,7 +236,7 @@ private: PossiblePM = 3, PossibleBoth = 4 }; - AmPmFinder findAmPm(QString &str, int index, int *used = 0) const; + AmPmFinder findAmPm(QString &str, int index, int *used = nullptr) const; #endif // datestring bool potentialValue(const QStringRef &str, int min, int max, int index, diff --git a/src/corelib/tools/qfreelist_p.h b/src/corelib/tools/qfreelist_p.h index 63be0952ff..d72d6e1b4b 100644 --- a/src/corelib/tools/qfreelist_p.h +++ b/src/corelib/tools/qfreelist_p.h @@ -249,11 +249,11 @@ inline int QFreeList::next() if (!v) { v = allocate((id & ConstantsType::IndexMask) - at, ConstantsType::Sizes[block]); - if (!_v[block].testAndSetRelease(0, v)) { + if (!_v[block].testAndSetRelease(nullptr, v)) { // race with another thread lost delete [] v; v = _v[block].loadAcquire(); - Q_ASSERT(v != 0); + Q_ASSERT(v != nullptr); } } diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 6643288bd5..34577acaa5 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -526,7 +526,7 @@ inline typename QList::iterator QList::insert(iterator before, const T &t) Q_ASSERT_X(isValidIterator(before), "QList::insert", "The specified iterator argument 'before' is invalid"); int iBefore = int(before.i - reinterpret_cast(p.begin())); - Node *n = 0; + Node *n = nullptr; if (d->ref.isShared()) n = detach_helper_grow(iBefore, 1); else diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index 98b6a31a46..1e8dc28fbf 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -249,7 +249,7 @@ public: if (qIsInf(d)) return float(d); if (std::fabs(d) > std::numeric_limits::max()) { - if (ok != 0) + if (ok != nullptr) *ok = false; const float huge = std::numeric_limits::infinity(); return d < 0 ? -huge : huge; diff --git a/src/dbus/qdbusargument_p.h b/src/dbus/qdbusargument_p.h index b678b9606f..3553d3d151 100644 --- a/src/dbus/qdbusargument_p.h +++ b/src/dbus/qdbusargument_p.h @@ -71,7 +71,7 @@ class QDBusArgumentPrivate { public: inline QDBusArgumentPrivate(int flags = 0) - : message(0), ref(1), capabilities(flags) + : message(nullptr), ref(1), capabilities(flags) { } virtual ~QDBusArgumentPrivate(); @@ -104,7 +104,7 @@ public: class QDBusMarshaller: public QDBusArgumentPrivate { public: - QDBusMarshaller(int flags) : QDBusArgumentPrivate(flags), parent(0), ba(0), closeCode(0), ok(true), skipSignature(false) + QDBusMarshaller(int flags) : QDBusArgumentPrivate(flags), parent(nullptr), ba(nullptr), closeCode(0), ok(true), skipSignature(false) { direction = Marshalling; } ~QDBusMarshaller(); @@ -161,7 +161,7 @@ private: class QDBusDemarshaller: public QDBusArgumentPrivate { public: - inline QDBusDemarshaller(int flags) : QDBusArgumentPrivate(flags), parent(0) + inline QDBusDemarshaller(int flags) : QDBusArgumentPrivate(flags), parent(nullptr) { direction = Demarshalling; } ~QDBusDemarshaller(); diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h index 7769b9ea71..da67a6c5d4 100644 --- a/src/dbus/qdbusconnection_p.h +++ b/src/dbus/qdbusconnection_p.h @@ -115,7 +115,7 @@ public: struct Watcher { - Watcher(): watch(0), read(0), write(0) {} + Watcher(): watch(nullptr), read(nullptr), write(nullptr) {} DBusWatch *watch; QSocketNotifier *read; QSocketNotifier *write; @@ -132,7 +132,7 @@ public: struct SignalHook { - inline SignalHook() : obj(0), midx(-1) { } + inline SignalHook() : obj(nullptr), midx(-1) { } QString service, path, signature; QObject* obj; int midx; @@ -150,9 +150,9 @@ public: { typedef QVector DataList; - inline ObjectTreeNode() : obj(0), flags(0) { } + inline ObjectTreeNode() : obj(nullptr), flags(0) { } inline ObjectTreeNode(const QString &n) // intentionally implicit - : name(n), obj(0), flags(0) { } + : name(n), obj(nullptr), flags(0) { } inline bool operator<(const QString &other) const { return name < other; } inline bool operator<(const QStringRef &other) const @@ -194,7 +194,7 @@ public: public: // public methods are entry points from other objects - explicit QDBusConnectionPrivate(QObject *parent = 0); + explicit QDBusConnectionPrivate(QObject *parent = nullptr); ~QDBusConnectionPrivate(); void createBusService(); diff --git a/src/dbus/qdbusintegrator_p.h b/src/dbus/qdbusintegrator_p.h index 3cd029a933..0f7e00fde0 100644 --- a/src/dbus/qdbusintegrator_p.h +++ b/src/dbus/qdbusintegrator_p.h @@ -106,7 +106,7 @@ class QDBusCallDeliveryEvent: public QMetaCallEvent public: QDBusCallDeliveryEvent(const QDBusConnection &c, int id, QObject *sender, const QDBusMessage &msg, const QVector &types, int f = 0) - : QMetaCallEvent(0, id, 0, sender, -1), connection(c), message(msg), metaTypes(types), flags(f) + : QMetaCallEvent(0, id, nullptr, sender, -1), connection(c), message(msg), metaTypes(types), flags(f) { } void placeMetaCall(QObject *object) override @@ -126,8 +126,8 @@ class QDBusActivateObjectEvent: public QMetaCallEvent public: QDBusActivateObjectEvent(const QDBusConnection &c, QObject *sender, const QDBusConnectionPrivate::ObjectTreeNode &n, - int p, const QDBusMessage &m, QSemaphore *s = 0) - : QMetaCallEvent(0, ushort(-1), 0, sender, -1, 0, 0, 0, s), connection(c), node(n), + int p, const QDBusMessage &m, QSemaphore *s = nullptr) + : QMetaCallEvent(0, ushort(-1), nullptr, sender, -1, 0, nullptr, nullptr, s), connection(c), node(n), pathStartPos(p), message(m), handled(false) { } ~QDBusActivateObjectEvent(); diff --git a/src/dbus/qdbuspendingcall_p.h b/src/dbus/qdbuspendingcall_p.h index 10f189ae43..e1f6240f3e 100644 --- a/src/dbus/qdbuspendingcall_p.h +++ b/src/dbus/qdbuspendingcall_p.h @@ -99,7 +99,7 @@ public: // } QDBusPendingCallPrivate(const QDBusMessage &sent, QDBusConnectionPrivate *connection) - : sentMessage(sent), connection(connection), watcherHelper(0), pending(0) + : sentMessage(sent), connection(connection), watcherHelper(nullptr), pending(nullptr) { } ~QDBusPendingCallPrivate(); bool setReplyCallback(QObject *target, const char *member); diff --git a/src/dbus/qdbuspendingreply.h b/src/dbus/qdbuspendingreply.h index bc5cd92c84..1d7e60ad7f 100644 --- a/src/dbus/qdbuspendingreply.h +++ b/src/dbus/qdbuspendingreply.h @@ -156,7 +156,7 @@ public: { Q_STATIC_ASSERT_X(Index >= 0 && Index < Count, "Index out of bounds"); typedef typename Select::Type ResultType; - return qdbus_cast(argumentAt(Index), 0); + return qdbus_cast(argumentAt(Index), nullptr); } #endif diff --git a/src/dbus/qdbusutil_p.h b/src/dbus/qdbusutil_p.h index 2f187687b8..5a4b461194 100644 --- a/src/dbus/qdbusutil_p.h +++ b/src/dbus/qdbusutil_p.h @@ -134,7 +134,7 @@ namespace Q_DBUS_NO_EXPORT QDBusUtil return false; } - inline bool checkMemberName(const QString &name, AllowEmptyFlag empty, QDBusError *error, const char *nameType = 0) + inline bool checkMemberName(const QString &name, AllowEmptyFlag empty, QDBusError *error, const char *nameType = nullptr) { if (!nameType) nameType = "member"; if (name.isEmpty()) { diff --git a/src/gui/accessible/qaccessiblecache_p.h b/src/gui/accessible/qaccessiblecache_p.h index a976277c1d..cf1ed04f35 100644 --- a/src/gui/accessible/qaccessiblecache_p.h +++ b/src/gui/accessible/qaccessiblecache_p.h @@ -73,7 +73,7 @@ public: QAccessibleInterface *interfaceForId(QAccessible::Id id) const; QAccessible::Id idForInterface(QAccessibleInterface *iface) const; QAccessible::Id insert(QObject *object, QAccessibleInterface *iface) const; - void deleteInterface(QAccessible::Id id, QObject *obj = 0); + void deleteInterface(QAccessible::Id id, QObject *obj = nullptr); #ifdef Q_OS_MAC QT_MANGLE_NAMESPACE(QMacAccessibilityElement) *elementForId(QAccessible::Id axid) const; diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h index a599fc17c9..1e0578a0f4 100644 --- a/src/gui/image/qimage_p.h +++ b/src/gui/image/qimage_p.h @@ -67,7 +67,7 @@ struct Q_GUI_EXPORT QImageData { // internal image data QImageData(); ~QImageData(); static QImageData *create(const QSize &size, QImage::Format format); - static QImageData *create(uchar *data, int w, int h, int bpl, QImage::Format format, bool readOnly, QImageCleanupFunction cleanupFunction = 0, void *cleanupInfo = 0); + static QImageData *create(uchar *data, int w, int h, int bpl, QImage::Format format, bool readOnly, QImageCleanupFunction cleanupFunction = nullptr, void *cleanupInfo = nullptr); QAtomicInt ref; diff --git a/src/gui/image/qpixmapcache_p.h b/src/gui/image/qpixmapcache_p.h index 3c57367514..ab8e2b7558 100644 --- a/src/gui/image/qpixmapcache_p.h +++ b/src/gui/image/qpixmapcache_p.h @@ -87,7 +87,7 @@ public: && !d->image.d->paintEngine->isActive()) { delete d->image.d->paintEngine; - d->image.d->paintEngine = 0; + d->image.d->paintEngine = nullptr; } } } diff --git a/src/gui/image/qppmhandler_p.h b/src/gui/image/qppmhandler_p.h index f3c9d0f139..2f3811b759 100644 --- a/src/gui/image/qppmhandler_p.h +++ b/src/gui/image/qppmhandler_p.h @@ -71,7 +71,7 @@ public: QByteArray name() const override; #endif - static bool canRead(QIODevice *device, QByteArray *subType = 0); + static bool canRead(QIODevice *device, QByteArray *subType = nullptr); QVariant option(ImageOption option) const override; void setOption(ImageOption option, const QVariant &value) override; diff --git a/src/gui/itemmodels/qstandarditemmodel_p.h b/src/gui/itemmodels/qstandarditemmodel_p.h index 23d2938bc4..97c2e6f01b 100644 --- a/src/gui/itemmodels/qstandarditemmodel_p.h +++ b/src/gui/itemmodels/qstandarditemmodel_p.h @@ -109,11 +109,11 @@ class QStandardItemPrivate Q_DECLARE_PUBLIC(QStandardItem) public: inline QStandardItemPrivate() - : model(0), - parent(0), + : model(nullptr), + parent(nullptr), rows(0), columns(0), - q_ptr(0), + q_ptr(nullptr), lastKnownIndex(-1) { } @@ -220,10 +220,10 @@ public: if (!index.isValid()) return root.data(); if (index.model() != q) - return 0; + return nullptr; QStandardItem *parent = static_cast(index.internalPointer()); - if (parent == 0) - return 0; + if (parent == nullptr) + return nullptr; return parent->child(index.row(), index.column()); } diff --git a/src/gui/kernel/qdnd_p.h b/src/gui/kernel/qdnd_p.h index 8f8eb03f87..b1219c8658 100644 --- a/src/gui/kernel/qdnd_p.h +++ b/src/gui/kernel/qdnd_p.h @@ -73,9 +73,9 @@ class QDragPrivate : public QObjectPrivate { public: QDragPrivate() - : source(0) - , target(0) - , data(0) + : source(nullptr) + , target(nullptr) + , data(nullptr) { } QObject *source; QObject *target; diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 61d9661286..65afa5de1b 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -115,7 +115,7 @@ public: if (QCoreApplication::instance()) return QCoreApplication::instance()->d_func()->threadData->eventDispatcher.load(); else - return 0; + return nullptr; } static void processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e); @@ -205,7 +205,7 @@ public: static void showModalWindow(QWindow *window); static void hideModalWindow(QWindow *window); static void updateBlockedStatus(QWindow *window); - virtual bool isWindowBlocked(QWindow *window, QWindow **blockingWindow = 0) const; + virtual bool isWindowBlocked(QWindow *window, QWindow **blockingWindow = nullptr) const; virtual bool popupActive() { return false; } static ulong mousePressTime; diff --git a/src/gui/kernel/qinputmethod_p.h b/src/gui/kernel/qinputmethod_p.h index 0c2b739d92..5657edeb4e 100644 --- a/src/gui/kernel/qinputmethod_p.h +++ b/src/gui/kernel/qinputmethod_p.h @@ -67,7 +67,7 @@ class QInputMethodPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QInputMethod) public: - inline QInputMethodPrivate() : testContext(0) + inline QInputMethodPrivate() : testContext(nullptr) {} QPlatformInputContext *platformInputContext() const { diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h index 2849d0c58e..c6ad893ee6 100644 --- a/src/gui/kernel/qopenglcontext_p.h +++ b/src/gui/kernel/qopenglcontext_p.h @@ -131,7 +131,7 @@ class Q_GUI_EXPORT QOpenGLContextGroupPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QOpenGLContextGroup) public: QOpenGLContextGroupPrivate() - : m_context(0) + : m_context(nullptr) , m_mutex(QMutex::Recursive) , m_refs(0) { @@ -198,20 +198,20 @@ class Q_GUI_EXPORT QOpenGLContextPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QOpenGLContext) public: QOpenGLContextPrivate() - : qGLContextHandle(0) - , qGLContextDeleteFunction(0) - , platformGLContext(0) - , shareContext(0) - , shareGroup(0) - , screen(0) - , surface(0) - , functions(0) - , textureFunctions(0) + : qGLContextHandle(nullptr) + , qGLContextDeleteFunction(nullptr) + , platformGLContext(nullptr) + , shareContext(nullptr) + , shareGroup(nullptr) + , screen(nullptr) + , surface(nullptr) + , functions(nullptr) + , textureFunctions(nullptr) , max_texture_size(-1) , workaround_brokenFBOReadBack(false) , workaround_brokenTexSubImage(false) , workaround_missingPrecisionQualifiers(false) - , active_engine(0) + , active_engine(nullptr) , qgl_current_fbo_invalid(false) , qgl_current_fbo(nullptr) , defaultFboRedirect(0) diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h index de5f9c1c9a..8ece390420 100644 --- a/src/gui/kernel/qplatformintegration.h +++ b/src/gui/kernel/qplatformintegration.h @@ -114,7 +114,7 @@ public: virtual QPlatformPixmap *createPlatformPixmap(QPlatformPixmap::PixelType type) const; virtual QPlatformWindow *createPlatformWindow(QWindow *window) const = 0; - virtual QPlatformWindow *createForeignWindow(QWindow *, WId) const { return 0; } + virtual QPlatformWindow *createForeignWindow(QWindow *, WId) const { return nullptr; } virtual QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const = 0; #ifndef QT_NO_OPENGL virtual QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const; diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h index 54c8c70025..356c4ea3ea 100644 --- a/src/gui/kernel/qplatformtheme.h +++ b/src/gui/kernel/qplatformtheme.h @@ -309,7 +309,7 @@ public: virtual QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const; virtual QIcon fileIcon(const QFileInfo &fileInfo, - QPlatformTheme::IconOptions iconOptions = 0) const; + QPlatformTheme::IconOptions iconOptions = nullptr) const; virtual QIconEngine *createIconEngine(const QString &iconName) const; #ifndef QT_NO_SHORTCUT diff --git a/src/gui/kernel/qscreen_p.h b/src/gui/kernel/qscreen_p.h index f31658355b..8e81c7bf87 100644 --- a/src/gui/kernel/qscreen_p.h +++ b/src/gui/kernel/qscreen_p.h @@ -65,8 +65,8 @@ class QScreenPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QScreen) public: QScreenPrivate() - : platformScreen(0) - , orientationUpdateMask(0) + : platformScreen(nullptr) + , orientationUpdateMask(nullptr) { } diff --git a/src/gui/kernel/qshapedpixmapdndwindow_p.h b/src/gui/kernel/qshapedpixmapdndwindow_p.h index d9a6ea4888..5089be7284 100644 --- a/src/gui/kernel/qshapedpixmapdndwindow_p.h +++ b/src/gui/kernel/qshapedpixmapdndwindow_p.h @@ -63,7 +63,7 @@ class QShapedPixmapWindow : public QRasterWindow { Q_OBJECT public: - explicit QShapedPixmapWindow(QScreen *screen = 0); + explicit QShapedPixmapWindow(QScreen *screen = nullptr); ~QShapedPixmapWindow(); void setUseCompositing(bool on) { m_useCompositing = on; } diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h index 25f9a8a9b2..1098321135 100644 --- a/src/gui/kernel/qwindow_p.h +++ b/src/gui/kernel/qwindow_p.h @@ -79,8 +79,8 @@ public: : QObjectPrivate() , surfaceType(QWindow::RasterSurface) , windowFlags(Qt::Window) - , parentWindow(0) - , platformWindow(0) + , parentWindow(nullptr) + , platformWindow(nullptr) , visible(false) , visibilityOnDestroy(false) , exposed(false) @@ -97,8 +97,8 @@ public: , modality(Qt::NonModal) , blockedByModalWindow(false) , updateRequestPending(false) - , transientParent(0) - , topLevelScreen(0) + , transientParent(nullptr) + , topLevelScreen(nullptr) #ifndef QT_NO_CURSOR , cursor(Qt::ArrowCursor) , hasCursor(false) @@ -119,7 +119,7 @@ public: void maybeQuitOnLastWindowClosed(); #ifndef QT_NO_CURSOR - void setCursor(const QCursor *c = 0); + void setCursor(const QCursor *c = nullptr); bool applyCursor(); #endif diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h index 6c818a9030..d6513f1836 100644 --- a/src/gui/kernel/qwindowsysteminterface_p.h +++ b/src/gui/kernel/qwindowsysteminterface_p.h @@ -123,7 +123,7 @@ public: class CloseEvent : public WindowSystemEvent { public: - explicit CloseEvent(QWindow *w, bool *a = 0) + explicit CloseEvent(QWindow *w, bool *a = nullptr) : WindowSystemEvent(Close), window(w), accepted(a) { } QPointer window; @@ -398,7 +398,7 @@ public: class TabletEnterProximityEvent : public InputEvent { public: TabletEnterProximityEvent(ulong time, int device, int pointerType, qint64 uid) - : InputEvent(0, time, TabletEnterProximity, Qt::NoModifier), + : InputEvent(nullptr, time, TabletEnterProximity, Qt::NoModifier), device(device), pointerType(pointerType), uid(uid) { } int device; int pointerType; @@ -408,7 +408,7 @@ public: class TabletLeaveProximityEvent : public InputEvent { public: TabletLeaveProximityEvent(ulong time, int device, int pointerType, qint64 uid) - : InputEvent(0, time, TabletLeaveProximity, Qt::NoModifier), + : InputEvent(nullptr, time, TabletLeaveProximity, Qt::NoModifier), device(device), pointerType(pointerType), uid(uid) { } int device; int pointerType; @@ -474,7 +474,7 @@ public: for (int i = 0; i < impl.size(); ++i) if (!(impl.at(i)->type & QWindowSystemInterfacePrivate::UserInputEvent)) return impl.takeAt(i); - return 0; + return nullptr; } bool nonUserInputEventsQueued() { @@ -495,7 +495,7 @@ public: if (impl.at(i)->type == t) return impl.at(i); } - return 0; + return nullptr; } void remove(const WindowSystemEvent *e) { diff --git a/src/gui/opengl/qopenglengineshadermanager_p.h b/src/gui/opengl/qopenglengineshadermanager_p.h index d43788d777..14c79f5de3 100644 --- a/src/gui/opengl/qopenglengineshadermanager_p.h +++ b/src/gui/opengl/qopenglengineshadermanager_p.h @@ -370,7 +370,7 @@ private: class QOpenGLEngineShaderProg { public: - QOpenGLEngineShaderProg() : program(0) {} + QOpenGLEngineShaderProg() : program(nullptr) {} ~QOpenGLEngineShaderProg() { if (program) diff --git a/src/gui/opengl/qopenglextensions_p.h b/src/gui/opengl/qopenglextensions_p.h index af8ee8201d..137f1e831f 100644 --- a/src/gui/opengl/qopenglextensions_p.h +++ b/src/gui/opengl/qopenglextensions_p.h @@ -107,7 +107,7 @@ public: QOpenGLExtensionsPrivate *d() const; private: - static bool isInitialized(const QOpenGLFunctionsPrivate *d) { return d != 0; } + static bool isInitialized(const QOpenGLFunctionsPrivate *d) { return d != nullptr; } }; Q_DECLARE_OPERATORS_FOR_FLAGS(QOpenGLExtensions::OpenGLExtensions) diff --git a/src/gui/opengl/qopenglframebufferobject_p.h b/src/gui/opengl/qopenglframebufferobject_p.h index 778a38b823..644bb6c59b 100644 --- a/src/gui/opengl/qopenglframebufferobject_p.h +++ b/src/gui/opengl/qopenglframebufferobject_p.h @@ -109,8 +109,8 @@ public: class QOpenGLFramebufferObjectPrivate { public: - QOpenGLFramebufferObjectPrivate() : fbo_guard(0), depth_buffer_guard(0) - , stencil_buffer_guard(0) + QOpenGLFramebufferObjectPrivate() : fbo_guard(nullptr), depth_buffer_guard(nullptr) + , stencil_buffer_guard(nullptr) , valid(false) {} ~QOpenGLFramebufferObjectPrivate() {} @@ -135,9 +135,9 @@ public: QOpenGLExtensions funcs; struct ColorAttachment { - ColorAttachment() : internalFormat(0), guard(0) { } + ColorAttachment() : internalFormat(0), guard(nullptr) { } ColorAttachment(const QSize &size, GLenum internalFormat) - : size(size), internalFormat(internalFormat), guard(0) { } + : size(size), internalFormat(internalFormat), guard(nullptr) { } QSize size; GLenum internalFormat; QOpenGLSharedResourceGuard *guard; diff --git a/src/gui/opengl/qopenglpaintengine_p.h b/src/gui/opengl/qopenglpaintengine_p.h index 15ac240b89..81f17572b2 100644 --- a/src/gui/opengl/qopenglpaintengine_p.h +++ b/src/gui/opengl/qopenglpaintengine_p.h @@ -187,9 +187,9 @@ public: QOpenGL2PaintEngineExPrivate(QOpenGL2PaintEngineEx *q_ptr) : q(q_ptr), - shaderManager(0), + shaderManager(nullptr), width(0), height(0), - ctx(0), + ctx(nullptr), useSystemClip(true), elementIndicesVBOId(0), opacityArray(0), @@ -361,9 +361,9 @@ void QOpenGL2PaintEngineExPrivate::uploadData(unsigned int arrayIndex, const GLf opacityBuffer.allocate(data, count * sizeof(float)); } if (arrayIndex == QT_OPACITY_ATTR) - funcs.glVertexAttribPointer(arrayIndex, 1, GL_FLOAT, GL_FALSE, 0, 0); + funcs.glVertexAttribPointer(arrayIndex, 1, GL_FLOAT, GL_FALSE, 0, nullptr); else - funcs.glVertexAttribPointer(arrayIndex, 2, GL_FLOAT, GL_FALSE, 0, 0); + funcs.glVertexAttribPointer(arrayIndex, 2, GL_FLOAT, GL_FALSE, 0, nullptr); } else { // If we already uploaded the data we don't have to do it again if (data == vertexAttribPointers[arrayIndex]) diff --git a/src/gui/opengl/qopenglqueryhelper_p.h b/src/gui/opengl/qopenglqueryhelper_p.h index 60dbf9c743..ad91ca9f96 100644 --- a/src/gui/opengl/qopenglqueryhelper_p.h +++ b/src/gui/opengl/qopenglqueryhelper_p.h @@ -65,18 +65,18 @@ class QOpenGLQueryHelper { public: QOpenGLQueryHelper(QOpenGLContext *context) - : GetQueryObjectuiv(0), - GetQueryObjectiv(0), - GetQueryiv(0), - EndQuery(0), - BeginQuery(0), - IsQuery(0), - DeleteQueries(0), - GenQueries(0), - GetInteger64v(0), - GetQueryObjectui64v(0), - GetQueryObjecti64v(0), - QueryCounter(0) + : GetQueryObjectuiv(nullptr), + GetQueryObjectiv(nullptr), + GetQueryiv(nullptr), + EndQuery(nullptr), + BeginQuery(nullptr), + IsQuery(nullptr), + DeleteQueries(nullptr), + GenQueries(nullptr), + GetInteger64v(nullptr), + GetQueryObjectui64v(nullptr), + GetQueryObjecti64v(nullptr), + QueryCounter(nullptr) { Q_ASSERT(context); diff --git a/src/gui/opengl/qopengltextureglyphcache_p.h b/src/gui/opengl/qopengltextureglyphcache_p.h index 598cb00ee5..aed128cf9e 100644 --- a/src/gui/opengl/qopengltextureglyphcache_p.h +++ b/src/gui/opengl/qopengltextureglyphcache_p.h @@ -139,7 +139,7 @@ public: inline void setPaintEnginePrivate(QOpenGL2PaintEngineExPrivate *p) { pex = p; } - inline const QOpenGLContextGroup *contextGroup() const { return m_textureResource ? m_textureResource->group() : 0; } + inline const QOpenGLContextGroup *contextGroup() const { return m_textureResource ? m_textureResource->group() : nullptr; } inline int serialNumber() const { return m_serialNumber; } diff --git a/src/gui/opengl/qopengltexturehelper_p.h b/src/gui/opengl/qopengltexturehelper_p.h index 00f6f9e5aa..62d0125daf 100644 --- a/src/gui/opengl/qopengltexturehelper_p.h +++ b/src/gui/opengl/qopengltexturehelper_p.h @@ -167,7 +167,7 @@ public: inline void glTextureSubImage3D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, - const GLvoid *pixels, const QOpenGLPixelTransferOptions * const options = 0) + const GLvoid *pixels, const QOpenGLPixelTransferOptions * const options = nullptr) { if (options) { QOpenGLPixelTransferOptions oldOptions = savePixelUploadOptions(); @@ -181,7 +181,7 @@ public: inline void glTextureSubImage2D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, - const GLvoid *pixels, const QOpenGLPixelTransferOptions * const options = 0) + const GLvoid *pixels, const QOpenGLPixelTransferOptions * const options = nullptr) { if (options) { QOpenGLPixelTransferOptions oldOptions = savePixelUploadOptions(); @@ -195,7 +195,7 @@ public: inline void glTextureSubImage1D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, - const GLvoid *pixels, const QOpenGLPixelTransferOptions * const options = 0) + const GLvoid *pixels, const QOpenGLPixelTransferOptions * const options = nullptr) { if (options) { QOpenGLPixelTransferOptions oldOptions = savePixelUploadOptions(); @@ -222,7 +222,7 @@ public: inline void glCompressedTextureSubImage1D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits, - const QOpenGLPixelTransferOptions * const options = 0) + const QOpenGLPixelTransferOptions * const options = nullptr) { if (options) { QOpenGLPixelTransferOptions oldOptions = savePixelUploadOptions(); @@ -238,7 +238,7 @@ public: GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits, - const QOpenGLPixelTransferOptions * const options = 0) + const QOpenGLPixelTransferOptions * const options = nullptr) { if (options) { QOpenGLPixelTransferOptions oldOptions = savePixelUploadOptions(); @@ -254,7 +254,7 @@ public: GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits, - const QOpenGLPixelTransferOptions * const options = 0) + const QOpenGLPixelTransferOptions * const options = nullptr) { if (options) { QOpenGLPixelTransferOptions oldOptions = savePixelUploadOptions(); @@ -269,7 +269,7 @@ public: inline void glCompressedTextureImage1D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits, - const QOpenGLPixelTransferOptions * const options = 0) + const QOpenGLPixelTransferOptions * const options = nullptr) { if (options) { QOpenGLPixelTransferOptions oldOptions = savePixelUploadOptions(); @@ -284,7 +284,7 @@ public: inline void glCompressedTextureImage2D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits, - const QOpenGLPixelTransferOptions * const options = 0) + const QOpenGLPixelTransferOptions * const options = nullptr) { if (options) { @@ -300,7 +300,7 @@ public: inline void glCompressedTextureImage3D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits, - const QOpenGLPixelTransferOptions * const options = 0) + const QOpenGLPixelTransferOptions * const options = nullptr) { if (options) { QOpenGLPixelTransferOptions oldOptions = savePixelUploadOptions(); diff --git a/src/gui/painting/qcosmeticstroker_p.h b/src/gui/painting/qcosmeticstroker_p.h index 082ddee30f..8571b0476a 100644 --- a/src/gui/painting/qcosmeticstroker_p.h +++ b/src/gui/painting/qcosmeticstroker_p.h @@ -98,8 +98,8 @@ public: : state(s), deviceRect(dr_unclipped), clip(dr), - pattern(0), - reversePattern(0), + pattern(nullptr), + reversePattern(nullptr), patternSize(0), patternLength(0), patternOffset(0), diff --git a/src/gui/painting/qdatabuffer_p.h b/src/gui/painting/qdatabuffer_p.h index 28d5f6d6c5..181d19da0b 100644 --- a/src/gui/painting/qdatabuffer_p.h +++ b/src/gui/painting/qdatabuffer_p.h @@ -69,7 +69,7 @@ public: buffer = (Type*) malloc(capacity * sizeof(Type)); Q_CHECK_PTR(buffer); } else { - buffer = 0; + buffer = nullptr; } siz = 0; } @@ -128,7 +128,7 @@ public: Q_CHECK_PTR(buffer); } else { free(buffer); - buffer = 0; + buffer = nullptr; } } diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index 37108949d6..1e99a34842 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -328,7 +328,7 @@ struct QTextureData struct QSpanData { - QSpanData() : tempImage(0) {} + QSpanData() : tempImage(nullptr) {} ~QSpanData() { delete tempImage; } QRasterBuffer *rasterBuffer; diff --git a/src/gui/painting/qoutlinemapper_p.h b/src/gui/painting/qoutlinemapper_p.h index 71999fbdee..04a68797c2 100644 --- a/src/gui/painting/qoutlinemapper_p.h +++ b/src/gui/painting/qoutlinemapper_p.h @@ -180,13 +180,13 @@ public: QT_FT_Outline *outline() { if (m_valid) return &m_outline; - return 0; + return nullptr; } QT_FT_Outline *convertPath(const QPainterPath &path); QT_FT_Outline *convertPath(const QVectorPath &path); - inline QPainterPath::ElementType *elementTypes() const { return m_element_types.size() == 0 ? 0 : m_element_types.data(); } + inline QPainterPath::ElementType *elementTypes() const { return m_element_types.size() == 0 ? nullptr : m_element_types.data(); } public: QDataBuffer m_element_types; diff --git a/src/gui/painting/qpaintengine_p.h b/src/gui/painting/qpaintengine_p.h index 8ac3fcff5c..40b9474165 100644 --- a/src/gui/painting/qpaintengine_p.h +++ b/src/gui/painting/qpaintengine_p.h @@ -65,7 +65,7 @@ class Q_GUI_EXPORT QPaintEnginePrivate { Q_DECLARE_PUBLIC(QPaintEngine) public: - QPaintEnginePrivate() : pdev(0), q_ptr(0), currentClipDevice(0), hasSystemTransform(0), + QPaintEnginePrivate() : pdev(nullptr), q_ptr(nullptr), currentClipDevice(nullptr), hasSystemTransform(0), hasSystemViewport(0) {} virtual ~QPaintEnginePrivate(); @@ -138,8 +138,8 @@ public: static QPaintEnginePrivate *get(QPaintEngine *paintEngine) { return paintEngine->d_func(); } - virtual QPaintEngine *aggregateEngine() { return 0; } - virtual Qt::HANDLE nativeHandle() { return 0; } + virtual QPaintEngine *aggregateEngine() { return nullptr; } + virtual Qt::HANDLE nativeHandle() { return nullptr; } }; QT_END_NAMESPACE diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h index c3734f1c62..500e0fae54 100644 --- a/src/gui/painting/qpaintengine_raster_p.h +++ b/src/gui/painting/qpaintengine_raster_p.h @@ -426,7 +426,7 @@ inline void QClipData::appendSpans(const QSpan *s, int num) class QRasterBuffer { public: - QRasterBuffer() : m_width(0), m_height(0), m_buffer(0) { init(); } + QRasterBuffer() : m_width(0), m_height(0), m_buffer(nullptr) { init(); } ~QRasterBuffer(); diff --git a/src/gui/painting/qpainter_p.h b/src/gui/painting/qpainter_p.h index 9857a59070..bd2bc4c9b3 100644 --- a/src/gui/painting/qpainter_p.h +++ b/src/gui/painting/qpainter_p.h @@ -193,9 +193,9 @@ class QPainterPrivate Q_DECLARE_PUBLIC(QPainter) public: QPainterPrivate(QPainter *painter) - : q_ptr(painter), d_ptrs(0), state(0), dummyState(0), txinv(0), inDestructor(false), d_ptrs_size(0), - refcount(1), device(0), original_device(0), helper_device(0), engine(0), emulationEngine(0), - extended(0) + : q_ptr(painter), d_ptrs(nullptr), state(nullptr), dummyState(nullptr), txinv(0), inDestructor(false), d_ptrs_size(0), + refcount(1), device(nullptr), original_device(nullptr), helper_device(nullptr), engine(nullptr), emulationEngine(nullptr), + extended(nullptr) { } diff --git a/src/gui/painting/qpainterpath_p.h b/src/gui/painting/qpainterpath_p.h index a36c8005bc..98056483bc 100644 --- a/src/gui/painting/qpainterpath_p.h +++ b/src/gui/painting/qpainterpath_p.h @@ -168,7 +168,7 @@ public: fillRule(Qt::OddEvenFill), dirtyBounds(false), dirtyControlBounds(false), - pathConverter(0) + pathConverter(nullptr) { require_moveTo = false; convex = false; @@ -181,7 +181,7 @@ public: dirtyBounds(other.dirtyBounds), dirtyControlBounds(other.dirtyControlBounds), convex(other.convex), - pathConverter(0) + pathConverter(nullptr) { require_moveTo = false; elements = other.elements; diff --git a/src/gui/painting/qpathclipper_p.h b/src/gui/painting/qpathclipper_p.h index c25a479807..9444a87b71 100644 --- a/src/gui/painting/qpathclipper_p.h +++ b/src/gui/painting/qpathclipper_p.h @@ -82,7 +82,7 @@ public: bool intersect(); bool contains(); - static bool pathToRect(const QPainterPath &path, QRectF *rect = 0); + static bool pathToRect(const QPainterPath &path, QRectF *rect = nullptr); static QPainterPath intersect(const QPainterPath &path, const QRectF &rect); private: @@ -394,7 +394,7 @@ inline const QPathSegments::Intersection *QPathSegments::intersectionAt(int inde { const int intersection = m_segments.at(index).intersection; if (intersection < 0) - return 0; + return nullptr; else return &m_intersections.at(intersection); } @@ -428,12 +428,12 @@ inline int QWingedEdge::edgeCount() const inline QPathEdge *QWingedEdge::edge(int edge) { - return edge < 0 ? 0 : &m_edges.at(edge); + return edge < 0 ? nullptr : &m_edges.at(edge); } inline const QPathEdge *QWingedEdge::edge(int edge) const { - return edge < 0 ? 0 : &m_edges.at(edge); + return edge < 0 ? nullptr : &m_edges.at(edge); } inline int QWingedEdge::vertexCount() const @@ -449,12 +449,12 @@ inline int QWingedEdge::addVertex(const QPointF &p) inline QPathVertex *QWingedEdge::vertex(int vertex) { - return vertex < 0 ? 0 : &m_vertices.at(vertex); + return vertex < 0 ? nullptr : &m_vertices.at(vertex); } inline const QPathVertex *QWingedEdge::vertex(int vertex) const { - return vertex < 0 ? 0 : &m_vertices.at(vertex); + return vertex < 0 ? nullptr : &m_vertices.at(vertex); } inline QPathEdge::Traversal QWingedEdge::flip(QPathEdge::Traversal traversal) diff --git a/src/gui/painting/qplatformbackingstore.h b/src/gui/painting/qplatformbackingstore.h index de5ba964dc..414d2bf0de 100644 --- a/src/gui/painting/qplatformbackingstore.h +++ b/src/gui/painting/qplatformbackingstore.h @@ -85,7 +85,7 @@ public: }; Q_DECLARE_FLAGS(Flags, Flag) - explicit QPlatformTextureList(QObject *parent = 0); + explicit QPlatformTextureList(QObject *parent = nullptr); ~QPlatformTextureList(); int count() const; @@ -99,7 +99,7 @@ public: bool isLocked() const; void appendTexture(void *source, GLuint textureId, const QRect &geometry, - const QRect &clipRect = QRect(), Flags flags = 0); + const QRect &clipRect = QRect(), Flags flags = nullptr); void clear(); Q_SIGNALS: diff --git a/src/gui/painting/qrbtree_p.h b/src/gui/painting/qrbtree_p.h index d3ee23a91c..42e88889a1 100644 --- a/src/gui/painting/qrbtree_p.h +++ b/src/gui/painting/qrbtree_p.h @@ -60,7 +60,7 @@ struct QRBTree { struct Node { - inline Node() : parent(0), left(0), right(0), red(true) { } + inline Node() : parent(nullptr), left(nullptr), right(nullptr), red(true) { } inline ~Node() {if (left) delete left; if (right) delete right;} T data; Node *parent; @@ -69,7 +69,7 @@ struct QRBTree bool red; }; - inline QRBTree() : root(0), freeList(0) { } + inline QRBTree() : root(nullptr), freeList(nullptr) { } inline ~QRBTree(); inline void clear(); @@ -120,7 +120,7 @@ inline QRBTree::~QRBTree() while (freeList) { // Avoid recursively calling the destructor, as this list may become large. Node *next = freeList->right; - freeList->right = 0; + freeList->right = nullptr; delete freeList; freeList = next; } @@ -131,7 +131,7 @@ inline void QRBTree::clear() { if (root) delete root; - root = 0; + root = nullptr; } template @@ -359,7 +359,7 @@ void QRBTree::detach(Node *node) // call this before removing a node. ref = child; if (child) child->parent = node->parent; - node->left = node->right = node->parent = 0; + node->left = node->right = node->parent = nullptr; } // 'node' must be black. rebalance will reduce the depth of black nodes by one in the sibling tree. @@ -513,7 +513,7 @@ inline void QRBTree::deleteNode(Node *&node) detach(node); node->right = freeList; freeList = node; - node = 0; + node = nullptr; } template @@ -522,7 +522,7 @@ inline typename QRBTree::Node *QRBTree::newNode() if (freeList) { Node *node = freeList; freeList = freeList->right; - node->parent = node->left = node->right = 0; + node->parent = node->left = node->right = nullptr; node->red = true; return node; } diff --git a/src/gui/painting/qtextureglyphcache_p.h b/src/gui/painting/qtextureglyphcache_p.h index 3da28872b1..1e83ab46d1 100644 --- a/src/gui/painting/qtextureglyphcache_p.h +++ b/src/gui/painting/qtextureglyphcache_p.h @@ -75,7 +75,7 @@ class Q_GUI_EXPORT QTextureGlyphCache : public QFontEngineGlyphCache { public: QTextureGlyphCache(QFontEngine::GlyphFormat format, const QTransform &matrix) - : QFontEngineGlyphCache(format, matrix), m_current_fontengine(0), + : QFontEngineGlyphCache(format, matrix), m_current_fontengine(nullptr), m_w(0), m_h(0), m_cx(0), m_cy(0), m_currentRowHeight(0) { } diff --git a/src/gui/painting/qvectorpath_p.h b/src/gui/painting/qvectorpath_p.h index 1b649a5d2a..df5772d4cc 100644 --- a/src/gui/painting/qvectorpath_p.h +++ b/src/gui/painting/qvectorpath_p.h @@ -106,7 +106,7 @@ public: // ### Falcon: introduca a struct XY for points so lars is not so confused... QVectorPath(const qreal *points, int count, - const QPainterPath::ElementType *elements = 0, + const QPainterPath::ElementType *elements = nullptr, uint hints = ArbitraryShapeHint) : m_elements(elements), m_points(points), @@ -128,12 +128,12 @@ public: inline bool hasExplicitOpen() const { return m_hints & ExplicitOpen; } inline bool hasWindingFill() const { return m_hints & WindingFill; } - inline void makeCacheable() const { m_hints |= ShouldUseCacheHint; m_cache = 0; } + inline void makeCacheable() const { m_hints |= ShouldUseCacheHint; m_cache = nullptr; } inline uint hints() const { return m_hints; } inline const QPainterPath::ElementType *elements() const { return m_elements; } inline const qreal *points() const { return m_points; } - inline bool isEmpty() const { return m_points == 0; } + inline bool isEmpty() const { return m_points == nullptr; } inline int elementCount() const { return m_count; } inline const QPainterPath convertToPainterPath() const; @@ -165,7 +165,7 @@ public: return e; e = e->next; } - return 0; + return nullptr; } template static inline bool isRect(const T *pts, int elementCount) { diff --git a/src/gui/text/qabstracttextdocumentlayout_p.h b/src/gui/text/qabstracttextdocumentlayout_p.h index 191c463dc6..d631ce3197 100644 --- a/src/gui/text/qabstracttextdocumentlayout_p.h +++ b/src/gui/text/qabstracttextdocumentlayout_p.h @@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE struct QTextObjectHandler { - QTextObjectHandler() : iface(0) {} + QTextObjectHandler() : iface(nullptr) {} QTextObjectInterface *iface; QPointer component; }; @@ -71,12 +71,12 @@ public: Q_DECLARE_PUBLIC(QAbstractTextDocumentLayout) inline QAbstractTextDocumentLayoutPrivate() - : paintDevice(0) {} + : paintDevice(nullptr) {} ~QAbstractTextDocumentLayoutPrivate(); inline void setDocument(QTextDocument *doc) { document = doc; - docPrivate = 0; + docPrivate = nullptr; if (doc) docPrivate = doc->docHandle(); } diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h index 860bbe382a..62578f75e5 100644 --- a/src/gui/text/qcssparser_p.h +++ b/src/gui/text/qcssparser_p.h @@ -467,8 +467,8 @@ struct Q_GUI_EXPORT Declaration Attachment attachmentValue() const; int styleFeaturesValue() const; - bool intValue(int *i, const char *unit = 0) const; - bool realValue(qreal *r, const char *unit = 0) const; + bool intValue(int *i, const char *unit = nullptr) const; + bool realValue(qreal *r, const char *unit = nullptr) const; QSize sizeValue() const; QRect rectValue() const; @@ -584,7 +584,7 @@ struct Q_GUI_EXPORT Selector { QVector basicSelectors; int specificity() const; - quint64 pseudoClass(quint64 *negated = 0) const; + quint64 pseudoClass(quint64 *negated = nullptr) const; QString pseudoElement() const; }; QT_CSS_DECLARE_TYPEINFO(Selector, Q_MOVABLE_TYPE) @@ -656,7 +656,7 @@ public: }; QVector styleRulesForNode(NodePtr node); - QVector declarationsForNode(NodePtr node, const char *extraPseudo = 0); + QVector declarationsForNode(NodePtr node, const char *extraPseudo = nullptr); virtual bool nodeNameEquals(NodePtr node, const QString& nodeName) const; virtual QString attribute(NodePtr node, const QString &name) const = 0; @@ -744,7 +744,7 @@ QT_CSS_DECLARE_TYPEINFO(Symbol, Q_MOVABLE_TYPE) class Q_GUI_EXPORT Scanner { public: - static QString preprocess(const QString &input, bool *hasEscapeSequences = 0); + static QString preprocess(const QString &input, bool *hasEscapeSequences = nullptr); static void scan(const QString &preprocessedInput, QVector *symbols); }; @@ -845,7 +845,7 @@ struct Q_GUI_EXPORT ValueExtractor bool extractGeometry(int *w, int *h, int *minw, int *minh, int *maxw, int *maxh); bool extractPosition(int *l, int *t, int *r, int *b, QCss::Origin *, Qt::Alignment *, QCss::PositionMode *, Qt::Alignment *); - bool extractBox(int *margins, int *paddings, int *spacing = 0); + bool extractBox(int *margins, int *paddings, int *spacing = nullptr); bool extractBorder(int *borders, QBrush *colors, BorderStyle *Styles, QSize *radii); bool extractOutline(int *borders, QBrush *colors, BorderStyle *Styles, QSize *radii, int *offsets); bool extractPalette(QBrush *fg, QBrush *sfg, QBrush *sbg, QBrush *abg); diff --git a/src/gui/text/qdistancefield_p.h b/src/gui/text/qdistancefield_p.h index 31cdf7edd2..1a1b6866a2 100644 --- a/src/gui/text/qdistancefield_p.h +++ b/src/gui/text/qdistancefield_p.h @@ -72,7 +72,7 @@ int Q_GUI_EXPORT QT_DISTANCEFIELD_HIGHGLYPHCOUNT(); class Q_GUI_EXPORT QDistanceFieldData : public QSharedData { public: - QDistanceFieldData() : glyph(0), width(0), height(0), nbytes(0), data(0) {} + QDistanceFieldData() : glyph(0), width(0), height(0), nbytes(0), data(nullptr) {} QDistanceFieldData(const QDistanceFieldData &other); ~QDistanceFieldData(); diff --git a/src/gui/text/qfont_p.h b/src/gui/text/qfont_p.h index e86ec31e47..6156faa788 100644 --- a/src/gui/text/qfont_p.h +++ b/src/gui/text/qfont_p.h @@ -266,7 +266,7 @@ public: // QFontEngine cache struct Engine { - Engine() : data(0), timestamp(0), hits(0) { } + Engine() : data(nullptr), timestamp(0), hits(0) { } Engine(QFontEngine *d) : data(d), timestamp(0), hits(0) { } QFontEngine *data; diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index 708c79c2ae..05c6746185 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -194,7 +194,7 @@ public: virtual QImage *lockedAlphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, GlyphFormat neededFormat, const QTransform &t = QTransform(), - QPoint *offset = 0); + QPoint *offset = nullptr); virtual void unlockAlphaMapForGlyph(); virtual bool hasInternalCaching() const { return false; } @@ -224,7 +224,7 @@ public: virtual qreal minLeftBearing() const; virtual qreal minRightBearing() const; - virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0); + virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = nullptr, qreal *rightBearing = nullptr); inline bool canRender(uint ucs4) const { return glyphIndex(ucs4) != 0; } virtual bool canRender(const QChar *str, int len) const; @@ -234,7 +234,7 @@ public: virtual int glyphCount() const; virtual int glyphMargin(GlyphFormat format) { return format == Format_A32 ? 2 : 0; } - virtual QFontEngine *cloneWithSize(qreal /*pixelSize*/) const { return 0; } + virtual QFontEngine *cloneWithSize(qreal /*pixelSize*/) const { return nullptr; } virtual Qt::HANDLE handle() const; @@ -458,7 +458,7 @@ public: virtual void recalcAdvances(QGlyphLayout *, ShaperFlags) const override; virtual void doKerning(QGlyphLayout *, ShaperFlags) const override; virtual void addOutlineToPath(qreal, qreal, const QGlyphLayout &, QPainterPath *, QTextItem::RenderFlags flags) override; - virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0) override; + virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = nullptr, qreal *rightBearing = nullptr) override; virtual QFixed ascent() const override; virtual QFixed capHeight() const override; diff --git a/src/gui/text/qfragmentmap_p.h b/src/gui/text/qfragmentmap_p.h index 35f60ac961..1d781352f8 100644 --- a/src/gui/text/qfragmentmap_p.h +++ b/src/gui/text/qfragmentmap_p.h @@ -216,7 +216,7 @@ private: template QFragmentMapData::QFragmentMapData() - : fragments(0) + : fragments(nullptr) { init(); } diff --git a/src/gui/text/qglyphrun_p.h b/src/gui/text/qglyphrun_p.h index 5b6bdad648..465c3c7000 100644 --- a/src/gui/text/qglyphrun_p.h +++ b/src/gui/text/qglyphrun_p.h @@ -65,7 +65,7 @@ class QGlyphRunPrivate: public QSharedData { public: QGlyphRunPrivate() - : flags(0) + : flags(nullptr) , glyphIndexData(glyphIndexes.constData()) , glyphIndexDataSize(0) , glyphPositionData(glyphPositions.constData()) diff --git a/src/gui/text/qrawfont_p.h b/src/gui/text/qrawfont_p.h index 0fc8739bfb..dced165475 100644 --- a/src/gui/text/qrawfont_p.h +++ b/src/gui/text/qrawfont_p.h @@ -67,9 +67,9 @@ class Q_GUI_EXPORT QRawFontPrivate { public: QRawFontPrivate() - : fontEngine(0) + : fontEngine(nullptr) , hintingPreference(QFont::PreferDefaultHinting) - , thread(0) + , thread(nullptr) {} QRawFontPrivate(const QRawFontPrivate &other) @@ -78,9 +78,9 @@ public: , thread(other.thread) { #ifndef QT_NO_DEBUG - Q_ASSERT(fontEngine == 0 || thread == QThread::currentThread()); + Q_ASSERT(fontEngine == nullptr || thread == QThread::currentThread()); #endif - if (fontEngine != 0) + if (fontEngine != nullptr) fontEngine->ref.ref(); } @@ -94,37 +94,37 @@ public: inline void cleanUp() { - setFontEngine(0); + setFontEngine(nullptr); hintingPreference = QFont::PreferDefaultHinting; } inline bool isValid() const { #ifndef QT_NO_DEBUG - Q_ASSERT(fontEngine == 0 || thread == QThread::currentThread()); + Q_ASSERT(fontEngine == nullptr || thread == QThread::currentThread()); #endif - return fontEngine != 0; + return fontEngine != nullptr; } inline void setFontEngine(QFontEngine *engine) { #ifndef QT_NO_DEBUG - Q_ASSERT(fontEngine == 0 || thread == QThread::currentThread()); + Q_ASSERT(fontEngine == nullptr || thread == QThread::currentThread()); #endif if (fontEngine == engine) return; - if (fontEngine != 0) { + if (fontEngine != nullptr) { if (!fontEngine->ref.deref()) delete fontEngine; #ifndef QT_NO_DEBUG - thread = 0; + thread = nullptr; #endif } fontEngine = engine; - if (fontEngine != 0) { + if (fontEngine != nullptr) { fontEngine->ref.ref(); #ifndef QT_NO_DEBUG thread = QThread::currentThread(); diff --git a/src/gui/text/qstatictext_p.h b/src/gui/text/qstatictext_p.h index 4ec09297c5..8d6792216d 100644 --- a/src/gui/text/qstatictext_p.h +++ b/src/gui/text/qstatictext_p.h @@ -80,7 +80,7 @@ class Q_GUI_EXPORT QStaticTextItem public: QStaticTextItem() : useBackendOptimizations(false), userDataNeedsUpdate(0), usesRawFont(0), - m_fontEngine(0), m_userData(0) {} + m_fontEngine(nullptr), m_userData(nullptr) {} void setUserData(QStaticTextUserData *newUserData) { diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h index cad9131fbf..d95f5bef6a 100644 --- a/src/gui/text/qtextdocument_p.h +++ b/src/gui/text/qtextdocument_p.h @@ -101,10 +101,10 @@ class QTextBlockData : public QFragment<3> { public: inline void initialize() - { layout = 0; userData = 0; userState = -1; revision = 0; hidden = 0; } + { layout = nullptr; userData = nullptr; userState = -1; revision = 0; hidden = 0; } void invalidate() const; inline void free() - { delete layout; layout = 0; delete userData; userData = 0; } + { delete layout; layout = nullptr; delete userData; userData = nullptr; } mutable int format; // ##### probably store a QTextEngine * here! diff --git a/src/gui/text/qtextdocumentfragment_p.h b/src/gui/text/qtextdocumentfragment_p.h index de01a02fbb..67b0c2c600 100644 --- a/src/gui/text/qtextdocumentfragment_p.h +++ b/src/gui/text/qtextdocumentfragment_p.h @@ -125,7 +125,7 @@ public: QTextHtmlImporter(QTextDocument *_doc, const QString &html, ImportMode mode, - const QTextDocument *resourceProvider = 0); + const QTextDocument *resourceProvider = nullptr); void import(); @@ -163,7 +163,7 @@ private: #endif struct TableCellIterator { - inline TableCellIterator(QTextTable *t = 0) : table(t), row(0), column(0) {} + inline TableCellIterator(QTextTable *t = nullptr) : table(t), row(0), column(0) {} inline TableCellIterator &operator++() { if (atEnd()) @@ -182,7 +182,7 @@ private: return *this; } - inline bool atEnd() const { return table == 0 || row >= table->rows(); } + inline bool atEnd() const { return table == nullptr || row >= table->rows(); } QTextTableCell cell() const { return table->cellAt(row, column); } diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index e9187ea605..fb2e812183 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -304,8 +304,8 @@ class QTextItemInt : public QTextItem { public: inline QTextItemInt() - : justified(false), underlineStyle(QTextCharFormat::NoUnderline), num_chars(0), chars(0), - logClusters(0), f(0), fontEngine(0) + : justified(false), underlineStyle(QTextCharFormat::NoUnderline), num_chars(0), chars(nullptr), + logClusters(nullptr), f(nullptr), fontEngine(nullptr) {} QTextItemInt(const QScriptItem &si, QFont *font, const QTextCharFormat &format = QTextCharFormat()); QTextItemInt(const QGlyphLayout &g, QFont *font, const QChar *chars, int numChars, QFontEngine *fe, @@ -484,7 +484,7 @@ public: return end - si->position; } - QFontEngine *fontEngine(const QScriptItem &si, QFixed *ascent = 0, QFixed *descent = 0, QFixed *leading = 0) const; + QFontEngine *fontEngine(const QScriptItem &si, QFixed *ascent = nullptr, QFixed *descent = nullptr, QFixed *leading = nullptr) const; QFont font(const QScriptItem &si) const; inline QFont font() const { return fnt; } @@ -530,7 +530,7 @@ public: inline QTextFormatCollection *formatCollection() const { if (block.docHandle()) return block.docHandle()->formatCollection(); - return specialData ? specialData->formatCollection.data() : 0; + return specialData ? specialData->formatCollection.data() : nullptr; } QTextCharFormat format(const QScriptItem *si) const; inline QAbstractTextDocumentLayout *docLayout() const { @@ -553,8 +553,8 @@ private: mutable int prevPosition; mutable int prevLength; inline void reset() { - prevFontEngine = 0; - prevScaledFontEngine = 0; + prevFontEngine = nullptr; + prevScaledFontEngine = nullptr; prevScript = -1; prevPosition = -1; prevLength = -1; @@ -684,7 +684,7 @@ Q_DECLARE_TYPEINFO(QTextEngine::ItemDecoration, Q_MOVABLE_TYPE); struct QTextLineItemIterator { QTextLineItemIterator(QTextEngine *eng, int lineNum, const QPointF &pos = QPointF(), - const QTextLayout::FormatRange *_selection = 0); + const QTextLayout::FormatRange *_selection = nullptr); inline bool atEnd() const { return logicalItem >= nItems - 1; } inline bool atBeginning() const { return logicalItem <= 0; } diff --git a/src/gui/text/qtextimagehandler_p.h b/src/gui/text/qtextimagehandler_p.h index 339ef0af4f..fafd394ad3 100644 --- a/src/gui/text/qtextimagehandler_p.h +++ b/src/gui/text/qtextimagehandler_p.h @@ -65,7 +65,7 @@ class Q_GUI_EXPORT QTextImageHandler : public QObject, Q_OBJECT Q_INTERFACES(QTextObjectInterface) public: - explicit QTextImageHandler(QObject *parent = 0); + explicit QTextImageHandler(QObject *parent = nullptr); virtual QSizeF intrinsicSize(QTextDocument *doc, int posInDocument, const QTextFormat &format) override; virtual void drawObject(QPainter *p, const QRectF &rect, QTextDocument *doc, int posInDocument, const QTextFormat &format) override; diff --git a/src/gui/text/qtextobject_p.h b/src/gui/text/qtextobject_p.h index 81ab023cc3..87c83868da 100644 --- a/src/gui/text/qtextobject_p.h +++ b/src/gui/text/qtextobject_p.h @@ -93,7 +93,7 @@ class QTextFramePrivate : public QTextObjectPrivate Q_DECLARE_PUBLIC(QTextFrame) public: QTextFramePrivate(QTextDocument *doc) - : QTextObjectPrivate(doc), fragment_start(0), fragment_end(0), parentFrame(0), layoutData(0) + : QTextObjectPrivate(doc), fragment_start(0), fragment_end(0), parentFrame(nullptr), layoutData(nullptr) { } virtual void fragmentAdded(QChar type, uint fragment); diff --git a/src/gui/text/qtexttable_p.h b/src/gui/text/qtexttable_p.h index c969e1d5bc..5c05611009 100644 --- a/src/gui/text/qtexttable_p.h +++ b/src/gui/text/qtexttable_p.h @@ -61,7 +61,7 @@ class QTextTablePrivate : public QTextFramePrivate { Q_DECLARE_PUBLIC(QTextTable) public: - QTextTablePrivate(QTextDocument *document) : QTextFramePrivate(document), grid(0), nRows(0), nCols(0), dirty(true), blockFragmentUpdates(false) {} + QTextTablePrivate(QTextDocument *document) : QTextFramePrivate(document), grid(nullptr), nRows(0), nCols(0), dirty(true), blockFragmentUpdates(false) {} ~QTextTablePrivate(); static QTextTable *createTable(QTextDocumentPrivate *, int pos, int rows, int cols, const QTextTableFormat &tableFormat); diff --git a/src/gui/util/qgridlayoutengine_p.h b/src/gui/util/qgridlayoutengine_p.h index 5f0cc5da73..5f0e84edb1 100644 --- a/src/gui/util/qgridlayoutengine_p.h +++ b/src/gui/util/qgridlayoutengine_p.h @@ -180,7 +180,7 @@ public: t = &q_minimumAscent; break; default: - t = 0; + t = nullptr; break; } return *t; @@ -205,7 +205,7 @@ public: t = &q_minimumAscent; break; default: - t = 0; + t = nullptr; break; } return *t; @@ -276,7 +276,7 @@ class Q_GUI_EXPORT QGridLayoutItem { public: QGridLayoutItem(int row, int column, int rowSpan = 1, int columnSpan = 1, - Qt::Alignment alignment = 0); + Qt::Alignment alignment = nullptr); virtual ~QGridLayoutItem() {} inline int firstRow() const { return q_firstRows[Ver]; } @@ -339,7 +339,7 @@ private: class Q_GUI_EXPORT QGridLayoutEngine { public: - QGridLayoutEngine(Qt::Alignment defaultAlignment = Qt::Alignment(0), bool snapToPixelGrid = false); + QGridLayoutEngine(Qt::Alignment defaultAlignment = Qt::Alignment(nullptr), bool snapToPixelGrid = false); inline ~QGridLayoutEngine() { qDeleteAll(q_items); } int rowCount(Qt::Orientation orientation) const; diff --git a/src/gui/vulkan/qvulkanwindow_p.h b/src/gui/vulkan/qvulkanwindow_p.h index c6a772bc31..fb374a5564 100644 --- a/src/gui/vulkan/qvulkanwindow_p.h +++ b/src/gui/vulkan/qvulkanwindow_p.h @@ -97,7 +97,7 @@ public: int physDevIndex = 0; QVector physDevs; QVector physDevProps; - QVulkanWindow::Flags flags = 0; + QVulkanWindow::Flags flags = nullptr; QByteArrayList requestedDevExtensions; QHash > supportedDevExtensions; QVector requestedColorFormats; diff --git a/src/network/access/qftp_p.h b/src/network/access/qftp_p.h index 0516c3d1f9..91d78d1351 100644 --- a/src/network/access/qftp_p.h +++ b/src/network/access/qftp_p.h @@ -67,7 +67,7 @@ class Q_AUTOTEST_EXPORT QFtp : public QObject Q_OBJECT public: - explicit QFtp(QObject *parent = 0); + explicit QFtp(QObject *parent = nullptr); virtual ~QFtp(); enum State { @@ -118,7 +118,7 @@ public: int setTransferMode(TransferMode mode); int list(const QString &dir = QString()); int cd(const QString &dir); - int get(const QString &file, QIODevice *dev=0, TransferType type = Binary); + int get(const QString &file, QIODevice *dev=nullptr, TransferType type = Binary); int put(const QByteArray &data, const QString &file, TransferType type = Binary); int put(QIODevice *dev, const QString &file, TransferType type = Binary); int remove(const QString &file); diff --git a/src/network/access/qhttpmultipart_p.h b/src/network/access/qhttpmultipart_p.h index 363e0b346c..ead1eadf3b 100644 --- a/src/network/access/qhttpmultipart_p.h +++ b/src/network/access/qhttpmultipart_p.h @@ -64,7 +64,7 @@ QT_BEGIN_NAMESPACE class QHttpPartPrivate: public QSharedData, public QNetworkHeadersPrivate { public: - inline QHttpPartPrivate() : bodyDevice(0), headerCreated(false), readPointer(0) + inline QHttpPartPrivate() : bodyDevice(nullptr), headerCreated(false), readPointer(0) { } ~QHttpPartPrivate() diff --git a/src/network/access/qhttpnetworkconnection_p.h b/src/network/access/qhttpnetworkconnection_p.h index 2bd727e0af..2f3c334248 100644 --- a/src/network/access/qhttpnetworkconnection_p.h +++ b/src/network/access/qhttpnetworkconnection_p.h @@ -101,10 +101,10 @@ public: #ifndef QT_NO_BEARERMANAGEMENT explicit QHttpNetworkConnection(const QString &hostName, quint16 port = 80, bool encrypt = false, ConnectionType connectionType = ConnectionTypeHTTP, - QObject *parent = 0, QSharedPointer networkSession + QObject *parent = nullptr, QSharedPointer networkSession = QSharedPointer()); QHttpNetworkConnection(quint16 channelCount, const QString &hostName, quint16 port = 80, - bool encrypt = false, QObject *parent = 0, + bool encrypt = false, QObject *parent = nullptr, QSharedPointer networkSession = QSharedPointer(), ConnectionType connectionType = ConnectionTypeHTTP); #else diff --git a/src/network/access/qhttpnetworkreply_p.h b/src/network/access/qhttpnetworkreply_p.h index 863e21ea3e..12cfe359aa 100644 --- a/src/network/access/qhttpnetworkreply_p.h +++ b/src/network/access/qhttpnetworkreply_p.h @@ -89,7 +89,7 @@ class Q_AUTOTEST_EXPORT QHttpNetworkReply : public QObject, public QHttpNetworkH Q_OBJECT public: - explicit QHttpNetworkReply(const QUrl &url = QUrl(), QObject *parent = 0); + explicit QHttpNetworkReply(const QUrl &url = QUrl(), QObject *parent = nullptr); virtual ~QHttpNetworkReply(); QUrl url() const override; diff --git a/src/network/access/qhttpthreaddelegate_p.h b/src/network/access/qhttpthreaddelegate_p.h index 019a8b8b74..6184b39b30 100644 --- a/src/network/access/qhttpthreaddelegate_p.h +++ b/src/network/access/qhttpthreaddelegate_p.h @@ -82,7 +82,7 @@ class QHttpThreadDelegate : public QObject { Q_OBJECT public: - explicit QHttpThreadDelegate(QObject *parent = 0); + explicit QHttpThreadDelegate(QObject *parent = nullptr); ~QHttpThreadDelegate(); @@ -207,7 +207,7 @@ public: : QNonContiguousByteDevice(), wantDataPending(false), m_amount(0), - m_data(0), + m_data(nullptr), m_atEnd(aE), m_size(s), m_pos(0) @@ -240,12 +240,12 @@ public: // Do nothing, we already sent a wantData signal and wait for results len = 0; } - return 0; + return nullptr; } bool advanceReadPointer(qint64 a) override { - if (m_data == 0) + if (m_data == nullptr) return false; m_amount -= a; @@ -269,7 +269,7 @@ public: bool reset() override { m_amount = 0; - m_data = 0; + m_data = nullptr; m_dataArray.clear(); if (wantDataPending) { diff --git a/src/network/access/qnetworkaccessauthenticationmanager_p.h b/src/network/access/qnetworkaccessauthenticationmanager_p.h index 548675728f..31111ca2a5 100644 --- a/src/network/access/qnetworkaccessauthenticationmanager_p.h +++ b/src/network/access/qnetworkaccessauthenticationmanager_p.h @@ -90,12 +90,12 @@ public: void cacheCredentials(const QUrl &url, const QAuthenticator *auth); QNetworkAuthenticationCredential fetchCachedCredentials(const QUrl &url, - const QAuthenticator *auth = 0); + const QAuthenticator *auth = nullptr); #ifndef QT_NO_NETWORKPROXY void cacheProxyCredentials(const QNetworkProxy &proxy, const QAuthenticator *auth); QNetworkAuthenticationCredential fetchCachedProxyCredentials(const QNetworkProxy &proxy, - const QAuthenticator *auth = 0); + const QAuthenticator *auth = nullptr); #endif void clearCache(); diff --git a/src/network/access/qnetworkdiskcache_p.h b/src/network/access/qnetworkdiskcache_p.h index f7988e7dda..c797e63830 100644 --- a/src/network/access/qnetworkdiskcache_p.h +++ b/src/network/access/qnetworkdiskcache_p.h @@ -67,7 +67,7 @@ class QFile; class QCacheItem { public: - QCacheItem() : file(0) + QCacheItem() : file(nullptr) { } ~QCacheItem() @@ -85,7 +85,7 @@ public: metaData = QNetworkCacheMetaData(); data.close(); delete file; - file = 0; + file = nullptr; } void writeHeader(QFile *device) const; void writeCompressedData(QFile *device) const; diff --git a/src/network/access/qnetworkreplyimpl_p.h b/src/network/access/qnetworkreplyimpl_p.h index f4e8284ab6..4881e84e9c 100644 --- a/src/network/access/qnetworkreplyimpl_p.h +++ b/src/network/access/qnetworkreplyimpl_p.h @@ -74,7 +74,7 @@ class QNetworkReplyImpl: public QNetworkReply { Q_OBJECT public: - QNetworkReplyImpl(QObject *parent = 0); + QNetworkReplyImpl(QObject *parent = nullptr); ~QNetworkReplyImpl(); virtual void abort() override; diff --git a/src/network/bearer/qbearerengine_p.h b/src/network/bearer/qbearerengine_p.h index 5fc2578a78..a5a020a857 100644 --- a/src/network/bearer/qbearerengine_p.h +++ b/src/network/bearer/qbearerengine_p.h @@ -77,7 +77,7 @@ class Q_NETWORK_EXPORT QBearerEngine : public QObject friend class QNetworkConfigurationManagerPrivate; public: - explicit QBearerEngine(QObject *parent = 0); + explicit QBearerEngine(QObject *parent = nullptr); virtual ~QBearerEngine(); virtual bool hasIdentifier(const QString &id) = 0; diff --git a/src/network/bearer/qbearerplugin_p.h b/src/network/bearer/qbearerplugin_p.h index 0cdde3c06c..ac787d0541 100644 --- a/src/network/bearer/qbearerplugin_p.h +++ b/src/network/bearer/qbearerplugin_p.h @@ -68,7 +68,7 @@ class Q_NETWORK_EXPORT QBearerEnginePlugin : public QObject { Q_OBJECT public: - explicit QBearerEnginePlugin(QObject *parent = 0); + explicit QBearerEnginePlugin(QObject *parent = nullptr); virtual ~QBearerEnginePlugin(); virtual QBearerEngine *create(const QString &key) const = 0; diff --git a/src/network/kernel/qdnslookup_p.h b/src/network/kernel/qdnslookup_p.h index 2dc98e527a..8c3c2ed3e1 100644 --- a/src/network/kernel/qdnslookup_p.h +++ b/src/network/kernel/qdnslookup_p.h @@ -95,7 +95,7 @@ public: QDnsLookupPrivate() : isFinished(false) , type(QDnsLookup::A) - , runnable(0) + , runnable(nullptr) { } void _q_lookupFinished(const QDnsLookupReply &reply); diff --git a/src/network/kernel/qhostinfo_p.h b/src/network/kernel/qhostinfo_p.h index 8cce302166..da02163ddf 100644 --- a/src/network/kernel/qhostinfo_p.h +++ b/src/network/kernel/qhostinfo_p.h @@ -101,7 +101,7 @@ public Q_SLOTS: { if (slotObj) { QHostInfo copy = info; - void *args[2] = { 0, reinterpret_cast(©) }; + void *args[2] = { nullptr, reinterpret_cast(©) }; slotObj->call(const_cast(receiver.data()), args); slotObj->destroyIfLastRef(); } else { diff --git a/src/network/kernel/qnetworkinterface_p.h b/src/network/kernel/qnetworkinterface_p.h index 87a46b75fa..44e27a7e34 100644 --- a/src/network/kernel/qnetworkinterface_p.h +++ b/src/network/kernel/qnetworkinterface_p.h @@ -82,7 +82,7 @@ public: class QNetworkInterfacePrivate: public QSharedData { public: - QNetworkInterfacePrivate() : index(0), flags(0) + QNetworkInterfacePrivate() : index(0), flags(nullptr) { } ~QNetworkInterfacePrivate() { } diff --git a/src/network/kernel/qnetworkinterface_unix_p.h b/src/network/kernel/qnetworkinterface_unix_p.h index c085194e3c..553af5a303 100644 --- a/src/network/kernel/qnetworkinterface_unix_p.h +++ b/src/network/kernel/qnetworkinterface_unix_p.h @@ -80,7 +80,7 @@ QT_BEGIN_NAMESPACE static QNetworkInterface::InterfaceFlags convertFlags(uint rawFlags) { - QNetworkInterface::InterfaceFlags flags = 0; + QNetworkInterface::InterfaceFlags flags = nullptr; flags |= (rawFlags & IFF_UP) ? QNetworkInterface::IsUp : QNetworkInterface::InterfaceFlag(0); flags |= (rawFlags & IFF_RUNNING) ? QNetworkInterface::IsRunning : QNetworkInterface::InterfaceFlag(0); flags |= (rawFlags & IFF_BROADCAST) ? QNetworkInterface::CanBroadcast : QNetworkInterface::InterfaceFlag(0); diff --git a/src/network/socket/qabstractsocketengine_p.h b/src/network/socket/qabstractsocketengine_p.h index 8eebb06a4d..112e7032d6 100644 --- a/src/network/socket/qabstractsocketengine_p.h +++ b/src/network/socket/qabstractsocketengine_p.h @@ -88,7 +88,7 @@ public: static QAbstractSocketEngine *createSocketEngine(QAbstractSocket::SocketType socketType, const QNetworkProxy &, QObject *parent); static QAbstractSocketEngine *createSocketEngine(qintptr socketDescriptor, QObject *parent); - QAbstractSocketEngine(QObject *parent = 0); + QAbstractSocketEngine(QObject *parent = nullptr); enum SocketOption { NonBlockingSocketOption, @@ -155,7 +155,7 @@ public: virtual qint64 pendingDatagramSize() const = 0; #endif // QT_NO_UDPSOCKET - virtual qint64 readDatagram(char *data, qint64 maxlen, QIpPacketHeader *header = 0, + virtual qint64 readDatagram(char *data, qint64 maxlen, QIpPacketHeader *header = nullptr, PacketHeaderOptions = WantNone) = 0; virtual qint64 writeDatagram(const char *data, qint64 len, const QIpPacketHeader &header) = 0; virtual qint64 bytesToWrite() const = 0; @@ -163,11 +163,11 @@ public: virtual int option(SocketOption option) const = 0; virtual bool setOption(SocketOption option, int value) = 0; - virtual bool waitForRead(int msecs = 30000, bool *timedOut = 0) = 0; - virtual bool waitForWrite(int msecs = 30000, bool *timedOut = 0) = 0; + virtual bool waitForRead(int msecs = 30000, bool *timedOut = nullptr) = 0; + virtual bool waitForWrite(int msecs = 30000, bool *timedOut = nullptr) = 0; virtual bool waitForReadOrWrite(bool *readyToRead, bool *readyToWrite, bool checkRead, bool checkWrite, - int msecs = 30000, bool *timedOut = 0) = 0; + int msecs = 30000, bool *timedOut = nullptr) = 0; QAbstractSocket::SocketError error() const; QString errorString() const; @@ -202,7 +202,7 @@ public Q_SLOTS: public: void setReceiver(QAbstractSocketEngineReceiver *receiver); protected: - QAbstractSocketEngine(QAbstractSocketEnginePrivate &dd, QObject* parent = 0); + QAbstractSocketEngine(QAbstractSocketEnginePrivate &dd, QObject* parent = nullptr); void setError(QAbstractSocket::SocketError error, const QString &errorString) const; void setState(QAbstractSocket::SocketState state); diff --git a/src/network/socket/qhttpsocketengine_p.h b/src/network/socket/qhttpsocketengine_p.h index bbcc09eee9..0c2c450c81 100644 --- a/src/network/socket/qhttpsocketengine_p.h +++ b/src/network/socket/qhttpsocketengine_p.h @@ -79,7 +79,7 @@ public: ReadResponseContent, ReadResponseHeader }; - QHttpSocketEngine(QObject *parent = 0); + QHttpSocketEngine(QObject *parent = nullptr); ~QHttpSocketEngine(); bool initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::IPv4Protocol) override; @@ -126,11 +126,11 @@ public: int option(SocketOption option) const override; bool setOption(SocketOption option, int value) override; - bool waitForRead(int msecs = 30000, bool *timedOut = 0) override; - bool waitForWrite(int msecs = 30000, bool *timedOut = 0) override; + bool waitForRead(int msecs = 30000, bool *timedOut = nullptr) override; + bool waitForWrite(int msecs = 30000, bool *timedOut = nullptr) override; bool waitForReadOrWrite(bool *readyToRead, bool *readyToWrite, bool checkRead, bool checkWrite, - int msecs = 30000, bool *timedOut = 0) override; + int msecs = 30000, bool *timedOut = nullptr) override; bool isReadNotificationEnabled() const override; void setReadNotificationEnabled(bool enable) override; diff --git a/src/network/socket/qlocalserver_p.h b/src/network/socket/qlocalserver_p.h index 2c073908cb..92616e59ce 100644 --- a/src/network/socket/qlocalserver_p.h +++ b/src/network/socket/qlocalserver_p.h @@ -78,7 +78,7 @@ class QLocalServerPrivate : public QObjectPrivate public: QLocalServerPrivate() : #if !defined(QT_LOCALSOCKET_TCP) && !defined(Q_OS_WIN) - listenSocket(-1), socketNotifier(0), + listenSocket(-1), socketNotifier(nullptr), #endif maxPendingConnections(30), error(QAbstractSocket::UnknownSocketError), socketOptions(QLocalServer::NoOptions) diff --git a/src/network/socket/qnativesocketengine_p.h b/src/network/socket/qnativesocketengine_p.h index 2292566265..e5f0701d14 100644 --- a/src/network/socket/qnativesocketengine_p.h +++ b/src/network/socket/qnativesocketengine_p.h @@ -125,7 +125,7 @@ class Q_AUTOTEST_EXPORT QNativeSocketEngine : public QAbstractSocketEngine { Q_OBJECT public: - QNativeSocketEngine(QObject *parent = 0); + QNativeSocketEngine(QObject *parent = nullptr); ~QNativeSocketEngine(); bool initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::IPv4Protocol) override; @@ -161,7 +161,7 @@ public: qint64 pendingDatagramSize() const override; #endif // QT_NO_UDPSOCKET - qint64 readDatagram(char *data, qint64 maxlen, QIpPacketHeader * = 0, + qint64 readDatagram(char *data, qint64 maxlen, QIpPacketHeader * = nullptr, PacketHeaderOptions = WantNone) override; qint64 writeDatagram(const char *data, qint64 len, const QIpPacketHeader &) override; qint64 bytesToWrite() const override; @@ -177,11 +177,11 @@ public: int option(SocketOption option) const override; bool setOption(SocketOption option, int value) override; - bool waitForRead(int msecs = 30000, bool *timedOut = 0) override; - bool waitForWrite(int msecs = 30000, bool *timedOut = 0) override; + bool waitForRead(int msecs = 30000, bool *timedOut = nullptr) override; + bool waitForWrite(int msecs = 30000, bool *timedOut = nullptr) override; bool waitForReadOrWrite(bool *readyToRead, bool *readyToWrite, bool checkRead, bool checkWrite, - int msecs = 30000, bool *timedOut = 0) override; + int msecs = 30000, bool *timedOut = nullptr) override; bool isReadNotificationEnabled() const override; void setReadNotificationEnabled(bool enable) override; diff --git a/src/network/socket/qsocks5socketengine_p.h b/src/network/socket/qsocks5socketengine_p.h index ef9d771753..c256987e2d 100644 --- a/src/network/socket/qsocks5socketengine_p.h +++ b/src/network/socket/qsocks5socketengine_p.h @@ -65,7 +65,7 @@ class Q_AUTOTEST_EXPORT QSocks5SocketEngine : public QAbstractSocketEngine { Q_OBJECT public: - QSocks5SocketEngine(QObject *parent = 0); + QSocks5SocketEngine(QObject *parent = nullptr); ~QSocks5SocketEngine(); bool initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::IPv4Protocol) override; @@ -104,7 +104,7 @@ public: qint64 pendingDatagramSize() const override; #endif // QT_NO_UDPSOCKET - qint64 readDatagram(char *data, qint64 maxlen, QIpPacketHeader * = 0, + qint64 readDatagram(char *data, qint64 maxlen, QIpPacketHeader * = nullptr, PacketHeaderOptions = WantNone) override; qint64 writeDatagram(const char *data, qint64 len, const QIpPacketHeader &) override; qint64 bytesToWrite() const override; @@ -112,11 +112,11 @@ public: int option(SocketOption option) const override; bool setOption(SocketOption option, int value) override; - bool waitForRead(int msecs = 30000, bool *timedOut = 0) override; - bool waitForWrite(int msecs = 30000, bool *timedOut = 0) override; + bool waitForRead(int msecs = 30000, bool *timedOut = nullptr) override; + bool waitForWrite(int msecs = 30000, bool *timedOut = nullptr) override; bool waitForReadOrWrite(bool *readyToRead, bool *readyToWrite, bool checkRead, bool checkWrite, - int msecs = 30000, bool *timedOut = 0) override; + int msecs = 30000, bool *timedOut = nullptr) override; bool isReadNotificationEnabled() const override; void setReadNotificationEnabled(bool enable) override; diff --git a/src/network/ssl/qasn1element_p.h b/src/network/ssl/qasn1element_p.h index 22948e3ca5..020b5aa1af 100644 --- a/src/network/ssl/qasn1element_p.h +++ b/src/network/ssl/qasn1element_p.h @@ -156,10 +156,10 @@ public: static QAsn1Element fromVector(const QVector &items); static QAsn1Element fromObjectId(const QByteArray &id); - bool toBool(bool *ok = 0) const; + bool toBool(bool *ok = nullptr) const; QDateTime toDateTime() const; QMultiMap toInfo() const; - qint64 toInteger(bool *ok = 0) const; + qint64 toInteger(bool *ok = nullptr) const; QVector toVector() const; QByteArray toObjectId() const; QByteArray toObjectName() const; diff --git a/src/network/ssl/qsslcertificate_p.h b/src/network/ssl/qsslcertificate_p.h index 4b331d4c4e..234cd45ceb 100644 --- a/src/network/ssl/qsslcertificate_p.h +++ b/src/network/ssl/qsslcertificate_p.h @@ -87,7 +87,7 @@ class QSslCertificatePrivate { public: QSslCertificatePrivate() - : null(true), x509(0) + : null(true), x509(nullptr) { #ifndef QT_NO_SSL QSslSocketPrivate::ensureInitialized(); diff --git a/src/network/ssl/qsslcontext_openssl_p.h b/src/network/ssl/qsslcontext_openssl_p.h index 48beebf134..1fa27279c7 100644 --- a/src/network/ssl/qsslcontext_openssl_p.h +++ b/src/network/ssl/qsslcontext_openssl_p.h @@ -89,7 +89,7 @@ public: #if OPENSSL_VERSION_NUMBER >= 0x1000100fL && !defined(OPENSSL_NO_NEXTPROTONEG) // must be public because we want to use it from an OpenSSL callback struct NPNContext { - NPNContext() : data(0), + NPNContext() : data(nullptr), len(0), status(QSslConfiguration::NextProtocolNegotiationNone) { } diff --git a/src/network/ssl/qsslkey_p.h b/src/network/ssl/qsslkey_p.h index 1f2b59904a..dd1a31b0e5 100644 --- a/src/network/ssl/qsslkey_p.h +++ b/src/network/ssl/qsslkey_p.h @@ -68,7 +68,7 @@ class QSslKeyPrivate public: inline QSslKeyPrivate() : algorithm(QSsl::Opaque) - , opaque(0) + , opaque(nullptr) { clear(false); } diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h index ec472da2e8..d23b3ad550 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h @@ -372,7 +372,7 @@ private: class QGLEngineShaderProg { public: - QGLEngineShaderProg() : program(0) {} + QGLEngineShaderProg() : program(nullptr) {} ~QGLEngineShaderProg() { if (program) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index abf5b8ea48..762aac2f65 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -175,9 +175,9 @@ public: QGL2PaintEngineExPrivate(QGL2PaintEngineEx *q_ptr) : q(q_ptr), - shaderManager(0), + shaderManager(nullptr), width(0), height(0), - ctx(0), + ctx(nullptr), useSystemClip(true), elementIndicesVBOId(0), opacityArray(0), diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h index e76216ef5d..7c12ce8998 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h @@ -139,7 +139,7 @@ public: inline void setPaintEnginePrivate(QGL2PaintEngineExPrivate *p) { pex = p; } - inline const QOpenGLContextGroup *contextGroup() const { return m_textureResource ? m_textureResource->group() : 0; } + inline const QOpenGLContextGroup *contextGroup() const { return m_textureResource ? m_textureResource->group() : nullptr; } inline int serialNumber() const { return m_serialNumber; } diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index ed364283cc..4e52c0f5e9 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -203,7 +203,7 @@ const QGLContext *qt_gl_transfer_context(const QGLContext *); class QGLTemporaryContextPrivate; class QGLTemporaryContext { public: - explicit QGLTemporaryContext(bool directRendering = true, QWidget *parent = 0); + explicit QGLTemporaryContext(bool directRendering = true, QWidget *parent = nullptr); ~QGLTemporaryContext(); private: @@ -302,7 +302,7 @@ class Q_OPENGL_EXPORT QGLShareContextScope { public: QGLShareContextScope(const QGLContext *ctx) - : m_oldContext(0) + : m_oldContext(nullptr) { QGLContext *currentContext = const_cast(QGLContext::currentContext()); if (currentContext != ctx && !QGLContext::areSharing(ctx, currentContext)) { @@ -367,7 +367,7 @@ Q_SIGNALS: class QGLTexture { public: - explicit QGLTexture(QGLContext *ctx = 0, GLuint tx_id = 0, GLenum tx_target = GL_TEXTURE_2D, + explicit QGLTexture(QGLContext *ctx = nullptr, GLuint tx_id = 0, GLenum tx_target = GL_TEXTURE_2D, QGLContext::BindOptions opt = QGLContext::DefaultBindOption) : context(ctx), id(tx_id), @@ -378,7 +378,7 @@ public: ~QGLTexture() { if (options & QGLContext::MemoryManagedBindOption) { Q_ASSERT(context); - QPlatformPixmap *boundPixmap = 0; + QPlatformPixmap *boundPixmap = nullptr; context->d_ptr->texture_destroyer->emitFreeTexture(context, boundPixmap, id); } } @@ -392,9 +392,9 @@ public: bool canBindCompressedTexture (const char *buf, int len, const char *format, bool *hasAlpha); QSize bindCompressedTexture - (const QString& fileName, const char *format = 0); + (const QString& fileName, const char *format = nullptr); QSize bindCompressedTexture - (const char *buf, int len, const char *format = 0); + (const char *buf, int len, const char *format = nullptr); QSize bindCompressedTextureDDS(const char *buf, int len); QSize bindCompressedTexturePVR(const char *buf, int len); }; diff --git a/src/opengl/qglframebufferobject_p.h b/src/opengl/qglframebufferobject_p.h index bf5e21cf0b..9d536527c3 100644 --- a/src/opengl/qglframebufferobject_p.h +++ b/src/opengl/qglframebufferobject_p.h @@ -124,9 +124,9 @@ private: class QGLFramebufferObjectPrivate { public: - QGLFramebufferObjectPrivate() : fbo_guard(0), texture_guard(0), depth_buffer_guard(0) - , stencil_buffer_guard(0), color_buffer_guard(0) - , valid(false), engine(0) {} + QGLFramebufferObjectPrivate() : fbo_guard(nullptr), texture_guard(nullptr), depth_buffer_guard(nullptr) + , stencil_buffer_guard(nullptr), color_buffer_guard(nullptr) + , valid(false), engine(nullptr) {} ~QGLFramebufferObjectPrivate() {} void init(QGLFramebufferObject *q, const QSize& sz, diff --git a/src/opengl/qglpixelbuffer_p.h b/src/opengl/qglpixelbuffer_p.h index 9125fcfb4b..2729ade2b6 100644 --- a/src/opengl/qglpixelbuffer_p.h +++ b/src/opengl/qglpixelbuffer_p.h @@ -77,7 +77,7 @@ private: class QGLPixelBufferPrivate { Q_DECLARE_PUBLIC(QGLPixelBuffer) public: - QGLPixelBufferPrivate(QGLPixelBuffer *q) : q_ptr(q), invalid(true), qctx(0), widget(0), fbo(0), blit_fbo(0), pbuf(0), ctx(0) + QGLPixelBufferPrivate(QGLPixelBuffer *q) : q_ptr(q), invalid(true), qctx(nullptr), widget(nullptr), fbo(nullptr), blit_fbo(nullptr), pbuf(nullptr), ctx(nullptr) { } bool init(const QSize &size, const QGLFormat &f, QGLWidget *shareWidget); diff --git a/src/opengl/qgraphicsshadereffect_p.h b/src/opengl/qgraphicsshadereffect_p.h index 1a32f24d70..218caa2936 100644 --- a/src/opengl/qgraphicsshadereffect_p.h +++ b/src/opengl/qgraphicsshadereffect_p.h @@ -67,7 +67,7 @@ class Q_OPENGL_EXPORT QGraphicsShaderEffect : public QGraphicsEffect { Q_OBJECT public: - QGraphicsShaderEffect(QObject *parent = 0); + QGraphicsShaderEffect(QObject *parent = nullptr); virtual ~QGraphicsShaderEffect(); QByteArray pixelShaderFragment() const; diff --git a/src/platformheaders/nativecontexts/qeglnativecontext.h b/src/platformheaders/nativecontexts/qeglnativecontext.h index d4a0e998da..5af2b304fe 100644 --- a/src/platformheaders/nativecontexts/qeglnativecontext.h +++ b/src/platformheaders/nativecontexts/qeglnativecontext.h @@ -54,8 +54,8 @@ typedef int EGLDisplay; struct QEGLNativeContext { QEGLNativeContext() - : m_context(0), - m_display(0) + : m_context(nullptr), + m_display(nullptr) { } QEGLNativeContext(EGLContext ctx, EGLDisplay dpy) diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_p.h b/src/platformsupport/devicediscovery/qdevicediscovery_p.h index b1ce14b5c3..f1f50e9708 100644 --- a/src/platformsupport/devicediscovery/qdevicediscovery_p.h +++ b/src/platformsupport/devicediscovery/qdevicediscovery_p.h @@ -86,7 +86,7 @@ public: Q_ENUM(QDeviceType) Q_DECLARE_FLAGS(QDeviceTypes, QDeviceType) - static QDeviceDiscovery *create(QDeviceTypes type, QObject *parent = 0); + static QDeviceDiscovery *create(QDeviceTypes type, QObject *parent = nullptr); virtual QStringList scanConnectedDevices() = 0; diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_udev_p.h b/src/platformsupport/devicediscovery/qdevicediscovery_udev_p.h index 28618d0b21..82b475776d 100644 --- a/src/platformsupport/devicediscovery/qdevicediscovery_udev_p.h +++ b/src/platformsupport/devicediscovery/qdevicediscovery_udev_p.h @@ -61,7 +61,7 @@ class QDeviceDiscoveryUDev : public QDeviceDiscovery Q_OBJECT public: - QDeviceDiscoveryUDev(QDeviceTypes types, struct udev *udev, QObject *parent = 0); + QDeviceDiscoveryUDev(QDeviceTypes types, struct udev *udev, QObject *parent = nullptr); ~QDeviceDiscoveryUDev(); QStringList scanConnectedDevices() override; diff --git a/src/platformsupport/eglconvenience/qeglpbuffer_p.h b/src/platformsupport/eglconvenience/qeglpbuffer_p.h index 0285e067a6..8ad2eb7248 100644 --- a/src/platformsupport/eglconvenience/qeglpbuffer_p.h +++ b/src/platformsupport/eglconvenience/qeglpbuffer_p.h @@ -60,7 +60,7 @@ class QEGLPbuffer : public QPlatformOffscreenSurface { public: QEGLPbuffer(EGLDisplay display, const QSurfaceFormat &format, QOffscreenSurface *offscreenSurface, - QEGLPlatformContext::Flags flags = 0); + QEGLPlatformContext::Flags flags = nullptr); ~QEGLPbuffer(); QSurfaceFormat format() const override { return m_format; } diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext_p.h b/src/platformsupport/eglconvenience/qeglplatformcontext_p.h index d6cbbe4131..ed77c57df5 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcontext_p.h +++ b/src/platformsupport/eglconvenience/qeglplatformcontext_p.h @@ -68,8 +68,8 @@ public: Q_DECLARE_FLAGS(Flags, Flag) QEGLPlatformContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display, - EGLConfig *config = 0, const QVariant &nativeHandle = QVariant(), - Flags flags = 0); + EGLConfig *config = nullptr, const QVariant &nativeHandle = QVariant(), + Flags flags = nullptr); ~QEGLPlatformContext(); void initialize() override; diff --git a/src/platformsupport/eventdispatchers/qeventdispatcher_glib_p.h b/src/platformsupport/eventdispatchers/qeventdispatcher_glib_p.h index 085a1c52f3..b9254d3071 100644 --- a/src/platformsupport/eventdispatchers/qeventdispatcher_glib_p.h +++ b/src/platformsupport/eventdispatchers/qeventdispatcher_glib_p.h @@ -64,7 +64,7 @@ class QPAEventDispatcherGlib : public QEventDispatcherGlib Q_DECLARE_PRIVATE(QPAEventDispatcherGlib) public: - explicit QPAEventDispatcherGlib(QObject *parent = 0); + explicit QPAEventDispatcherGlib(QObject *parent = nullptr); ~QPAEventDispatcherGlib(); bool processEvents(QEventLoop::ProcessEventsFlags flags) override; @@ -77,7 +77,7 @@ class QPAEventDispatcherGlibPrivate : public QEventDispatcherGlibPrivate { Q_DECLARE_PUBLIC(QPAEventDispatcherGlib) public: - QPAEventDispatcherGlibPrivate(GMainContext *context = 0); + QPAEventDispatcherGlibPrivate(GMainContext *context = nullptr); GUserEventSource *userEventSource; }; diff --git a/src/platformsupport/eventdispatchers/qunixeventdispatcher_qpa_p.h b/src/platformsupport/eventdispatchers/qunixeventdispatcher_qpa_p.h index 7f775b73ee..8157b8793d 100644 --- a/src/platformsupport/eventdispatchers/qunixeventdispatcher_qpa_p.h +++ b/src/platformsupport/eventdispatchers/qunixeventdispatcher_qpa_p.h @@ -61,7 +61,7 @@ class QUnixEventDispatcherQPA : public QEventDispatcherUNIX Q_OBJECT public: - explicit QUnixEventDispatcherQPA(QObject *parent = 0); + explicit QUnixEventDispatcherQPA(QObject *parent = nullptr); ~QUnixEventDispatcherQPA(); bool processEvents(QEventLoop::ProcessEventsFlags flags); diff --git a/src/platformsupport/fbconvenience/qfbvthandler_p.h b/src/platformsupport/fbconvenience/qfbvthandler_p.h index 17d07317b2..d565ec3632 100644 --- a/src/platformsupport/fbconvenience/qfbvthandler_p.h +++ b/src/platformsupport/fbconvenience/qfbvthandler_p.h @@ -63,7 +63,7 @@ class QFbVtHandler : public QObject Q_OBJECT public: - QFbVtHandler(QObject *parent = 0); + QFbVtHandler(QObject *parent = nullptr); ~QFbVtHandler(); signals: diff --git a/src/platformsupport/fontdatabases/freetype/qfontengine_ft_p.h b/src/platformsupport/fontdatabases/freetype/qfontengine_ft_p.h index d498b0ac8b..2d1d5e6572 100644 --- a/src/platformsupport/fontdatabases/freetype/qfontengine_ft_p.h +++ b/src/platformsupport/fontdatabases/freetype/qfontengine_ft_p.h @@ -268,7 +268,7 @@ private: inline bool isScalableBitmap() const { return freetype->isScalableBitmap(); } inline Glyph *loadGlyph(uint glyph, QFixed subPixelPosition, GlyphFormat format = Format_None, bool fetchMetricsOnly = false, bool disableOutlineDrawing = false) const - { return loadGlyph(cacheEnabled ? &defaultGlyphSet : 0, glyph, subPixelPosition, format, fetchMetricsOnly, disableOutlineDrawing); } + { return loadGlyph(cacheEnabled ? &defaultGlyphSet : nullptr, glyph, subPixelPosition, format, fetchMetricsOnly, disableOutlineDrawing); } Glyph *loadGlyph(QGlyphSet *set, uint glyph, QFixed subPixelPosition, GlyphFormat = Format_None, bool fetchMetricsOnly = false, bool disableOutlineDrawing = false) const; Glyph *loadGlyphFor(glyph_t g, QFixed subPixelPosition, GlyphFormat format, const QTransform &t, bool fetchBoundingBox = false, bool disableOutlineDrawing = false); diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h index 326e438a7c..01b7e9fc0e 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h @@ -64,7 +64,7 @@ QT_BEGIN_NAMESPACE class QEvdevKeyboardManager : public QObject { public: - QEvdevKeyboardManager(const QString &key, const QString &specification, QObject *parent = 0); + QEvdevKeyboardManager(const QString &key, const QString &specification, QObject *parent = nullptr); ~QEvdevKeyboardManager(); void loadKeymap(const QString &file); diff --git a/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h b/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h index 13a8e3dec5..c63ca29a71 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h +++ b/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h @@ -65,7 +65,7 @@ class QDeviceDiscovery; class QEvdevMouseManager : public QObject { public: - QEvdevMouseManager(const QString &key, const QString &specification, QObject *parent = 0); + QEvdevMouseManager(const QString &key, const QString &specification, QObject *parent = nullptr); ~QEvdevMouseManager(); void handleMouseEvent(int x, int y, bool abs, Qt::MouseButtons buttons, diff --git a/src/platformsupport/input/evdevtablet/qevdevtablethandler_p.h b/src/platformsupport/input/evdevtablet/qevdevtablethandler_p.h index 66e821117a..b83bb21258 100644 --- a/src/platformsupport/input/evdevtablet/qevdevtablethandler_p.h +++ b/src/platformsupport/input/evdevtablet/qevdevtablethandler_p.h @@ -64,7 +64,7 @@ class QEvdevTabletData; class QEvdevTabletHandler : public QObject { public: - explicit QEvdevTabletHandler(const QString &device, const QString &spec = QString(), QObject *parent = 0); + explicit QEvdevTabletHandler(const QString &device, const QString &spec = QString(), QObject *parent = nullptr); ~QEvdevTabletHandler(); qint64 deviceId() const; @@ -83,7 +83,7 @@ private: class QEvdevTabletHandlerThread : public QDaemonThread { public: - explicit QEvdevTabletHandlerThread(const QString &device, const QString &spec, QObject *parent = 0); + explicit QEvdevTabletHandlerThread(const QString &device, const QString &spec, QObject *parent = nullptr); ~QEvdevTabletHandlerThread(); void run() override; QEvdevTabletHandler *handler() { return m_handler; } diff --git a/src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h b/src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h index cde91c55aa..b598156e52 100644 --- a/src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h +++ b/src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h @@ -63,7 +63,7 @@ class QEvdevTabletHandlerThread; class QEvdevTabletManager : public QObject { public: - QEvdevTabletManager(const QString &key, const QString &spec, QObject *parent = 0); + QEvdevTabletManager(const QString &key, const QString &spec, QObject *parent = nullptr); ~QEvdevTabletManager(); void addDevice(const QString &deviceNode); diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchmanager_p.h b/src/platformsupport/input/evdevtouch/qevdevtouchmanager_p.h index e524c516f1..b9b772fb3a 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchmanager_p.h +++ b/src/platformsupport/input/evdevtouch/qevdevtouchmanager_p.h @@ -63,7 +63,7 @@ class QEvdevTouchScreenHandlerThread; class QEvdevTouchManager : public QObject { public: - QEvdevTouchManager(const QString &key, const QString &spec, QObject *parent = 0); + QEvdevTouchManager(const QString &key, const QString &spec, QObject *parent = nullptr); ~QEvdevTouchManager(); void addDevice(const QString &deviceNode); diff --git a/src/platformsupport/input/libinput/qlibinputtouch_p.h b/src/platformsupport/input/libinput/qlibinputtouch_p.h index 6f88001d19..51304e6a21 100644 --- a/src/platformsupport/input/libinput/qlibinputtouch_p.h +++ b/src/platformsupport/input/libinput/qlibinputtouch_p.h @@ -73,7 +73,7 @@ public: private: struct DeviceState { - DeviceState() : m_touchDevice(0) { } + DeviceState() : m_touchDevice(nullptr) { } QWindowSystemInterface::TouchPoint *point(int32_t slot); QList m_points; QTouchDevice *m_touchDevice; diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor_p.h b/src/platformsupport/linuxaccessibility/atspiadaptor_p.h index b5704f53ad..0b624389a3 100644 --- a/src/platformsupport/linuxaccessibility/atspiadaptor_p.h +++ b/src/platformsupport/linuxaccessibility/atspiadaptor_p.h @@ -76,7 +76,7 @@ class AtSpiAdaptor :public QDBusVirtualObject Q_OBJECT public: - explicit AtSpiAdaptor(DBusConnection *connection, QObject *parent = 0); + explicit AtSpiAdaptor(DBusConnection *connection, QObject *parent = nullptr); ~AtSpiAdaptor(); void registerApplication(); diff --git a/src/platformsupport/linuxaccessibility/cache_p.h b/src/platformsupport/linuxaccessibility/cache_p.h index e8529b779b..cc55acc6f8 100644 --- a/src/platformsupport/linuxaccessibility/cache_p.h +++ b/src/platformsupport/linuxaccessibility/cache_p.h @@ -65,7 +65,7 @@ class QSpiDBusCache : public QObject Q_OBJECT public: - explicit QSpiDBusCache(QDBusConnection c, QObject* parent = 0); + explicit QSpiDBusCache(QDBusConnection c, QObject* parent = nullptr); void emitAddAccessible(const QSpiAccessibleCacheItem& item); void emitRemoveAccessible(const QSpiObjectReference& item); diff --git a/src/platformsupport/linuxaccessibility/dbusconnection_p.h b/src/platformsupport/linuxaccessibility/dbusconnection_p.h index 4030fabc22..860c18ca05 100644 --- a/src/platformsupport/linuxaccessibility/dbusconnection_p.h +++ b/src/platformsupport/linuxaccessibility/dbusconnection_p.h @@ -65,7 +65,7 @@ class DBusConnection : public QObject Q_OBJECT public: - DBusConnection(QObject *parent = 0); + DBusConnection(QObject *parent = nullptr); QDBusConnection connection() const; bool isEnabled() const { return m_enabled; } diff --git a/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h b/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h index c7c3f4bc5b..565af6c947 100644 --- a/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h +++ b/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h @@ -67,7 +67,7 @@ class QDBusMenuConnection : public QObject Q_OBJECT public: - QDBusMenuConnection(QObject *parent = 0, const QString &serviceName = QString()); + QDBusMenuConnection(QObject *parent = nullptr, const QString &serviceName = QString()); QDBusConnection connection() const { return m_connection; } QDBusServiceWatcher *dbusWatcher() const { return m_dbusWatcher; } bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; } diff --git a/src/platformsupport/themes/genericunix/dbustray/qxdgnotificationproxy_p.h b/src/platformsupport/themes/genericunix/dbustray/qxdgnotificationproxy_p.h index 352b4aa5d6..ab99ea65dd 100644 --- a/src/platformsupport/themes/genericunix/dbustray/qxdgnotificationproxy_p.h +++ b/src/platformsupport/themes/genericunix/dbustray/qxdgnotificationproxy_p.h @@ -88,7 +88,7 @@ public: public: QXdgNotificationInterface(const QString &service, const QString &path, - const QDBusConnection &connection, QObject *parent = 0); + const QDBusConnection &connection, QObject *parent = nullptr); ~QXdgNotificationInterface(); diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h b/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h index a5963b79ea..c0da9d8370 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h @@ -109,7 +109,7 @@ public: QVariant themeHint(ThemeHint hint) const override; QIcon fileIcon(const QFileInfo &fileInfo, - QPlatformTheme::IconOptions iconOptions = 0) const override; + QPlatformTheme::IconOptions iconOptions = nullptr) const override; const QPalette *palette(Palette type = SystemPalette) const override; @@ -134,7 +134,7 @@ public: QGnomeTheme(); QVariant themeHint(ThemeHint hint) const override; QIcon fileIcon(const QFileInfo &fileInfo, - QPlatformTheme::IconOptions = 0) const override; + QPlatformTheme::IconOptions = nullptr) const override; const QFont *font(Font type) const override; QString standardButtonText(int button) const override; diff --git a/src/plugins/bearer/connman/qconnmanengine.h b/src/plugins/bearer/connman/qconnmanengine.h index c9ff17f801..ef80d38fa2 100644 --- a/src/plugins/bearer/connman/qconnmanengine.h +++ b/src/plugins/bearer/connman/qconnmanengine.h @@ -68,7 +68,7 @@ class QConnmanEngine : public QBearerEngineImpl Q_OBJECT public: - QConnmanEngine(QObject *parent = 0); + QConnmanEngine(QObject *parent = nullptr); ~QConnmanEngine(); bool connmanAvailable() const; diff --git a/src/plugins/bearer/connman/qconnmanservice_linux_p.h b/src/plugins/bearer/connman/qconnmanservice_linux_p.h index d2804ebca6..790325f9a1 100644 --- a/src/plugins/bearer/connman/qconnmanservice_linux_p.h +++ b/src/plugins/bearer/connman/qconnmanservice_linux_p.h @@ -105,7 +105,7 @@ class QConnmanManagerInterface : public QDBusAbstractInterface public: - QConnmanManagerInterface( QObject *parent = 0); + QConnmanManagerInterface( QObject *parent = nullptr); ~QConnmanManagerInterface(); QDBusObjectPath path() const; @@ -155,7 +155,7 @@ class QConnmanServiceInterface : public QDBusAbstractInterface public: - explicit QConnmanServiceInterface(const QString &dbusPathName,QObject *parent = 0); + explicit QConnmanServiceInterface(const QString &dbusPathName,QObject *parent = nullptr); ~QConnmanServiceInterface(); QVariantMap getProperties(); @@ -202,7 +202,7 @@ class QConnmanTechnologyInterface : public QDBusAbstractInterface public: - explicit QConnmanTechnologyInterface(const QString &dbusPathName,QObject *parent = 0); + explicit QConnmanTechnologyInterface(const QString &dbusPathName,QObject *parent = nullptr); ~QConnmanTechnologyInterface(); QString type(); diff --git a/src/plugins/bearer/generic/qgenericengine.h b/src/plugins/bearer/generic/qgenericengine.h index 08960d66f6..79c71ca7a3 100644 --- a/src/plugins/bearer/generic/qgenericengine.h +++ b/src/plugins/bearer/generic/qgenericengine.h @@ -55,7 +55,7 @@ class QGenericEngine : public QBearerEngineImpl Q_OBJECT public: - QGenericEngine(QObject *parent = 0); + QGenericEngine(QObject *parent = nullptr); ~QGenericEngine(); QString getInterfaceFromId(const QString &id) override; diff --git a/src/plugins/bearer/linux_common/qofonoservice_linux_p.h b/src/plugins/bearer/linux_common/qofonoservice_linux_p.h index 35614a20f2..62df5d4fa7 100644 --- a/src/plugins/bearer/linux_common/qofonoservice_linux_p.h +++ b/src/plugins/bearer/linux_common/qofonoservice_linux_p.h @@ -100,7 +100,7 @@ class QOfonoManagerInterface : public QDBusAbstractInterface public: - QOfonoManagerInterface( QObject *parent = 0); + QOfonoManagerInterface( QObject *parent = nullptr); ~QOfonoManagerInterface(); QStringList getModems(); @@ -120,7 +120,7 @@ class QOfonoModemInterface : public QDBusAbstractInterface public: - explicit QOfonoModemInterface(const QString &dbusModemPathName, QObject *parent = 0); + explicit QOfonoModemInterface(const QString &dbusModemPathName, QObject *parent = nullptr); ~QOfonoModemInterface(); bool isPowered(); @@ -140,7 +140,7 @@ class QOfonoNetworkRegistrationInterface : public QDBusAbstractInterface public: - explicit QOfonoNetworkRegistrationInterface(const QString &dbusModemPathName, QObject *parent = 0); + explicit QOfonoNetworkRegistrationInterface(const QString &dbusModemPathName, QObject *parent = nullptr); ~QOfonoNetworkRegistrationInterface(); QString getTechnology(); @@ -159,7 +159,7 @@ class QOfonoDataConnectionManagerInterface : public QDBusAbstractInterface public: - explicit QOfonoDataConnectionManagerInterface(const QString &dbusPathName, QObject *parent = 0); + explicit QOfonoDataConnectionManagerInterface(const QString &dbusPathName, QObject *parent = nullptr); ~QOfonoDataConnectionManagerInterface(); QStringList contexts(); @@ -184,7 +184,7 @@ class QOfonoConnectionContextInterface : public QDBusAbstractInterface public: - explicit QOfonoConnectionContextInterface(const QString &dbusPathName, QObject *parent = 0); + explicit QOfonoConnectionContextInterface(const QString &dbusPathName, QObject *parent = nullptr); ~QOfonoConnectionContextInterface(); QVariant getProperty(const QString &); diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h index 74fe24b5ab..a95c68abdf 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h @@ -69,7 +69,7 @@ class QNetworkManagerEngine : public QBearerEngineImpl Q_OBJECT public: - QNetworkManagerEngine(QObject *parent = 0); + QNetworkManagerEngine(QObject *parent = nullptr); ~QNetworkManagerEngine(); bool networkManagerAvailable() const; @@ -99,7 +99,7 @@ private Q_SLOTS: void interfacePropertiesChanged(const QMap &properties); void activeConnectionPropertiesChanged(const QMap &properties); - void newConnection(const QDBusObjectPath &path, QNetworkManagerSettings *settings = 0); + void newConnection(const QDBusObjectPath &path, QNetworkManagerSettings *settings = nullptr); void removeConnection(const QString &path); void updateConnection(); void activationFinished(QDBusPendingCallWatcher *watcher); diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h index c879083faf..bff7a71097 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h @@ -152,7 +152,7 @@ public: NM_STATE_CONNECTED_GLOBAL = 70 } NMState; - QNetworkManagerInterface(QObject *parent = 0); + QNetworkManagerInterface(QObject *parent = nullptr); ~QNetworkManagerInterface(); QList getDevices(); @@ -228,7 +228,7 @@ public: Q_DECLARE_FLAGS(ApSecurityFlags, ApSecurityFlag) - explicit QNetworkManagerInterfaceAccessPoint(const QString &dbusPathName, QObject *parent = 0); + explicit QNetworkManagerInterfaceAccessPoint(const QString &dbusPathName, QObject *parent = nullptr); ~QNetworkManagerInterfaceAccessPoint(); quint32 flags() const; @@ -259,7 +259,7 @@ class QNetworkManagerInterfaceDevice : public QDBusAbstractInterface public: - explicit QNetworkManagerInterfaceDevice(const QString &deviceObjectPath, QObject *parent = 0); + explicit QNetworkManagerInterfaceDevice(const QString &deviceObjectPath, QObject *parent = nullptr); ~QNetworkManagerInterfaceDevice(); QString udi() const; @@ -288,7 +288,7 @@ class QNetworkManagerInterfaceDeviceWired : public QDBusAbstractInterface public: explicit QNetworkManagerInterfaceDeviceWired(const QString &ifaceDevicePath, - QObject *parent = 0); + QObject *parent = nullptr); ~QNetworkManagerInterfaceDeviceWired(); QString hwAddress() const; @@ -325,7 +325,7 @@ public: }; explicit QNetworkManagerInterfaceDeviceWireless(const QString &ifaceDevicePath, - QObject *parent = 0); + QObject *parent = nullptr); ~QNetworkManagerInterfaceDeviceWireless(); QList getAccessPoints(); @@ -367,7 +367,7 @@ public: Q_DECLARE_FLAGS(ModemCapabilities, ModemCapability) explicit QNetworkManagerInterfaceDeviceModem(const QString &ifaceDevicePath, - QObject *parent = 0); + QObject *parent = nullptr); ~QNetworkManagerInterfaceDeviceModem(); ModemCapabilities modemCapabilities() const; @@ -392,7 +392,7 @@ class QNetworkManagerSettings : public QDBusAbstractInterface public: - explicit QNetworkManagerSettings(const QString &settingsService, QObject *parent = 0); + explicit QNetworkManagerSettings(const QString &settingsService, QObject *parent = nullptr); ~QNetworkManagerSettings(); QList listConnections(); @@ -413,7 +413,7 @@ class QNetworkManagerSettingsConnection : public QDBusAbstractInterface public: - QNetworkManagerSettingsConnection(const QString &settingsService, const QString &connectionObjectPath, QObject *parent = 0); + QNetworkManagerSettingsConnection(const QString &settingsService, const QString &connectionObjectPath, QObject *parent = nullptr); ~QNetworkManagerSettingsConnection(); QNmSettingsMap getSettings(); @@ -451,7 +451,7 @@ public: Activated = 2 }; - explicit QNetworkManagerConnectionActive(const QString &dbusPathName, QObject *parent = 0); + explicit QNetworkManagerConnectionActive(const QString &dbusPathName, QObject *parent = nullptr); ~ QNetworkManagerConnectionActive(); QDBusObjectPath connection() const; @@ -478,7 +478,7 @@ class QNetworkManagerIp4Config : public QDBusAbstractInterface Q_OBJECT public: - explicit QNetworkManagerIp4Config(const QString &dbusPathName, QObject *parent = 0); + explicit QNetworkManagerIp4Config(const QString &dbusPathName, QObject *parent = nullptr); ~QNetworkManagerIp4Config(); QStringList domains() const; @@ -489,7 +489,7 @@ class PropertiesDBusInterface : public QDBusAbstractInterface public: PropertiesDBusInterface(const QString &service, const QString &path, const QString &interface, const QDBusConnection &connection, - QObject *parent = 0) + QObject *parent = nullptr) : QDBusAbstractInterface(service, path, interface.toLatin1().data(), connection, parent) {} }; diff --git a/src/plugins/bearer/qbearerengine_impl.h b/src/plugins/bearer/qbearerengine_impl.h index 3f8a4d821d..5c003aaaf6 100644 --- a/src/plugins/bearer/qbearerengine_impl.h +++ b/src/plugins/bearer/qbearerengine_impl.h @@ -56,7 +56,7 @@ public: DisconnectionError, }; - QBearerEngineImpl(QObject *parent = 0) : QBearerEngine(parent) {} + QBearerEngineImpl(QObject *parent = nullptr) : QBearerEngine(parent) {} ~QBearerEngineImpl() {} virtual void connectToId(const QString &id) = 0; diff --git a/src/plugins/bearer/qnetworksession_impl.h b/src/plugins/bearer/qnetworksession_impl.h index d9aa6ca8fb..0f8e014900 100644 --- a/src/plugins/bearer/qnetworksession_impl.h +++ b/src/plugins/bearer/qnetworksession_impl.h @@ -66,7 +66,7 @@ class QNetworkSessionPrivateImpl : public QNetworkSessionPrivate public: QNetworkSessionPrivateImpl() - : engine(0), startTime(0), lastError(QNetworkSession::UnknownSessionError), sessionTimeout(-1), currentPolicies(QNetworkSession::NoPolicy), opened(false) + : engine(nullptr), startTime(0), lastError(QNetworkSession::UnknownSessionError), sessionTimeout(-1), currentPolicies(QNetworkSession::NoPolicy), opened(false) {} ~QNetworkSessionPrivateImpl() {} diff --git a/src/plugins/platforminputcontexts/ibus/qibusinputcontextproxy.h b/src/plugins/platforminputcontexts/ibus/qibusinputcontextproxy.h index 47a40ab8c2..396a213aaa 100644 --- a/src/plugins/platforminputcontexts/ibus/qibusinputcontextproxy.h +++ b/src/plugins/platforminputcontexts/ibus/qibusinputcontextproxy.h @@ -31,7 +31,7 @@ public: { return "org.freedesktop.IBus.InputContext"; } public: - QIBusInputContextProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); + QIBusInputContextProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = nullptr); ~QIBusInputContextProxy(); diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h index d4daea2eb3..8e7b8df120 100644 --- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h +++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h @@ -59,9 +59,9 @@ class QIBusFilterEventWatcher: public QDBusPendingCallWatcher { public: explicit QIBusFilterEventWatcher(const QDBusPendingCall &call, - QObject *parent = 0, - QWindow *window = 0, - const Qt::KeyboardModifiers modifiers = 0, + QObject *parent = nullptr, + QWindow *window = nullptr, + const Qt::KeyboardModifiers modifiers = nullptr, const QVariantList arguments = QVariantList()) : QDBusPendingCallWatcher(call, parent) , m_window(window) diff --git a/src/plugins/platforminputcontexts/ibus/qibusproxy.h b/src/plugins/platforminputcontexts/ibus/qibusproxy.h index 839e972c34..c9876deebf 100644 --- a/src/plugins/platforminputcontexts/ibus/qibusproxy.h +++ b/src/plugins/platforminputcontexts/ibus/qibusproxy.h @@ -35,7 +35,7 @@ public: { return QStringLiteral("org.freedesktop.DBus.Properties"); } public: - QIBusProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); + QIBusProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = nullptr); ~QIBusProxy(); diff --git a/src/plugins/platforms/vnc/qvnc_p.h b/src/plugins/platforms/vnc/qvnc_p.h index 338fae9f87..f7f2f74ddb 100644 --- a/src/plugins/platforms/vnc/qvnc_p.h +++ b/src/plugins/platforms/vnc/qvnc_p.h @@ -139,7 +139,7 @@ public: class QRfbServerInit { public: - QRfbServerInit() { name = 0; } + QRfbServerInit() { name = nullptr; } ~QRfbServerInit() { delete[] name; } int size() const { return QRfbPixelFormat::size() + 8 + strlen(name); } diff --git a/src/plugins/platforms/vnc/qvncscreen.h b/src/plugins/platforms/vnc/qvncscreen.h index e69aa90d41..db658d4ecc 100644 --- a/src/plugins/platforms/vnc/qvncscreen.h +++ b/src/plugins/platforms/vnc/qvncscreen.h @@ -82,12 +82,12 @@ public: qreal dpiX = 96; qreal dpiY = 96; - QVncDirtyMap *dirty = 0; + QVncDirtyMap *dirty = nullptr; QRegion dirtyRegion; int refreshRate = 30; - QVncServer *vncServer = 0; + QVncServer *vncServer = nullptr; #if QT_CONFIG(cursor) - QVncClientCursor *clientCursor = 0; + QVncClientCursor *clientCursor = nullptr; #endif }; diff --git a/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationplugin.h b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationplugin.h index d5a0af97b0..b18248570f 100644 --- a/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationplugin.h +++ b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationplugin.h @@ -54,7 +54,7 @@ class Q_XCB_EXPORT QXcbGlIntegrationPlugin : public QObject { Q_OBJECT public: - explicit QXcbGlIntegrationPlugin(QObject *parent = 0) + explicit QXcbGlIntegrationPlugin(QObject *parent = nullptr) : QObject(parent) { } diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 0e3ecd135b..6747b237da 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -108,7 +108,7 @@ public: virtual void handleXIMouseEvent(xcb_ge_event_t *, Qt::MouseEventSource = Qt::MouseEventNotSynthesized) {} virtual void handleXIEnterLeave(xcb_ge_event_t *) {} #endif - virtual QXcbWindow *toWindow() { return 0; } + virtual QXcbWindow *toWindow() { return nullptr; } }; typedef QHash WindowMapper; @@ -364,7 +364,7 @@ private: WindowMapper m_mapper; - Qt::MouseButtons m_buttonState = 0; + Qt::MouseButtons m_buttonState = nullptr; Qt::MouseButton m_button = Qt::NoButton; QXcbWindow *m_focusWindow = nullptr; diff --git a/src/plugins/platforms/xcb/qxcbcursor.h b/src/plugins/platforms/xcb/qxcbcursor.h index 5bc806381c..488988cbe9 100644 --- a/src/plugins/platforms/xcb/qxcbcursor.h +++ b/src/plugins/platforms/xcb/qxcbcursor.h @@ -83,7 +83,7 @@ public: QPoint pos() const override; void setPos(const QPoint &pos) override; - static void queryPointer(QXcbConnection *c, QXcbVirtualDesktop **virtualDesktop, QPoint *pos, int *keybMask = 0); + static void queryPointer(QXcbConnection *c, QXcbVirtualDesktop **virtualDesktop, QPoint *pos, int *keybMask = nullptr); #ifndef QT_NO_CURSOR xcb_cursor_t xcbCursor(const QCursor &c) const diff --git a/src/plugins/platforms/xcb/qxcbdrag.h b/src/plugins/platforms/xcb/qxcbdrag.h index c19008c04b..1388e68acc 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.h +++ b/src/plugins/platforms/xcb/qxcbdrag.h @@ -86,7 +86,7 @@ public: void handlePosition(QPlatformWindow *w, const xcb_client_message_event_t *event); void handleLeave(QPlatformWindow *w, const xcb_client_message_event_t *event); void handleDrop(QPlatformWindow *, const xcb_client_message_event_t *event, - Qt::MouseButtons b = 0, Qt::KeyboardModifiers mods = 0); + Qt::MouseButtons b = nullptr, Qt::KeyboardModifiers mods = nullptr); void handleStatus(const xcb_client_message_event_t *event); void handleSelectionRequest(const xcb_selection_request_event_t *event); @@ -109,7 +109,7 @@ private: void init(); void handle_xdnd_position(QPlatformWindow *w, const xcb_client_message_event_t *event, - Qt::MouseButtons b = 0, Qt::KeyboardModifiers mods = 0); + Qt::MouseButtons b = nullptr, Qt::KeyboardModifiers mods = nullptr); void handle_xdnd_status(const xcb_client_message_event_t *event); void send_leave(); diff --git a/src/plugins/platforms/xcb/qxcbobject.h b/src/plugins/platforms/xcb/qxcbobject.h index 1b98d9346b..931bed9ec1 100644 --- a/src/plugins/platforms/xcb/qxcbobject.h +++ b/src/plugins/platforms/xcb/qxcbobject.h @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE class QXcbObject { public: - QXcbObject(QXcbConnection *connection = 0) : m_connection(connection) {} + QXcbObject(QXcbConnection *connection = nullptr) : m_connection(connection) {} void setConnection(QXcbConnection *connection) { m_connection = connection; } QXcbConnection *connection() const { return m_connection; } diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index f98cd8a74d..e4a04f5308 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -166,7 +166,7 @@ public: bool needsSync() const; void postSyncWindowRequest(); - void clearSyncWindowRequest() { m_pendingSyncRequest = 0; } + void clearSyncWindowRequest() { m_pendingSyncRequest = nullptr; } QXcbScreen *xcbScreen() const; diff --git a/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.h b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.h index 3497c6a6f1..5cfc4df0d0 100644 --- a/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.h +++ b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.h @@ -72,7 +72,7 @@ public: QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const override; QIcon fileIcon(const QFileInfo &fileInfo, - QPlatformTheme::IconOptions iconOptions = 0) const override; + QPlatformTheme::IconOptions iconOptions = nullptr) const override; QIconEngine *createIconEngine(const QString &iconName) const override; diff --git a/src/plugins/sqldrivers/odbc/qsql_odbc_p.h b/src/plugins/sqldrivers/odbc/qsql_odbc_p.h index ea0aa6fc8b..ccd0206f38 100644 --- a/src/plugins/sqldrivers/odbc/qsql_odbc_p.h +++ b/src/plugins/sqldrivers/odbc/qsql_odbc_p.h @@ -89,8 +89,8 @@ class Q_EXPORT_SQLDRIVER_ODBC QODBCDriver : public QSqlDriver friend class QODBCResultPrivate; public: - explicit QODBCDriver(QObject *parent=0); - QODBCDriver(SQLHANDLE env, SQLHANDLE con, QObject * parent=0); + explicit QODBCDriver(QObject *parent=nullptr); + QODBCDriver(SQLHANDLE env, SQLHANDLE con, QObject * parent=nullptr); virtual ~QODBCDriver(); bool hasFeature(DriverFeature f) const override; void close() override; diff --git a/src/plugins/sqldrivers/sqlite/qsql_sqlite_p.h b/src/plugins/sqldrivers/sqlite/qsql_sqlite_p.h index 61be4c937f..c7952bca9a 100644 --- a/src/plugins/sqldrivers/sqlite/qsql_sqlite_p.h +++ b/src/plugins/sqldrivers/sqlite/qsql_sqlite_p.h @@ -72,8 +72,8 @@ class Q_EXPORT_SQLDRIVER_SQLITE QSQLiteDriver : public QSqlDriver Q_OBJECT friend class QSQLiteResultPrivate; public: - explicit QSQLiteDriver(QObject *parent = 0); - explicit QSQLiteDriver(sqlite3 *connection, QObject *parent = 0); + explicit QSQLiteDriver(QObject *parent = nullptr); + explicit QSQLiteDriver(sqlite3 *connection, QObject *parent = nullptr); ~QSQLiteDriver(); bool hasFeature(DriverFeature f) const override; bool open(const QString & db, diff --git a/src/sql/models/qsqlquerymodel_p.h b/src/sql/models/qsqlquerymodel_p.h index d5ca2f89cb..64e9aeb3db 100644 --- a/src/sql/models/qsqlquerymodel_p.h +++ b/src/sql/models/qsqlquerymodel_p.h @@ -75,7 +75,7 @@ public: void initColOffsets(int size); int columnInQuery(int modelColumn) const; - mutable QSqlQuery query = { QSqlQuery(0) }; + mutable QSqlQuery query = { QSqlQuery(nullptr) }; mutable QSqlError error; QModelIndex bottom; QSqlRecord rec; diff --git a/src/sql/models/qsqltablemodel_p.h b/src/sql/models/qsqltablemodel_p.h index bb568ab444..9ac34e7259 100644 --- a/src/sql/models/qsqltablemodel_p.h +++ b/src/sql/models/qsqltablemodel_p.h @@ -93,7 +93,7 @@ public: QSqlTableModel::EditStrategy strategy; bool busyInsertingRows; - QSqlQuery editQuery = { QSqlQuery(0) }; + QSqlQuery editQuery = { QSqlQuery(nullptr) }; QSqlIndex primaryIndex; QString tableName; QString filter; diff --git a/src/testlib/qabstracttestlogger_p.h b/src/testlib/qabstracttestlogger_p.h index a64e7ea96f..9bb1d1e80c 100644 --- a/src/testlib/qabstracttestlogger_p.h +++ b/src/testlib/qabstracttestlogger_p.h @@ -97,14 +97,14 @@ public: virtual void enterTestData(QTestData *) {} virtual void addIncident(IncidentTypes type, const char *description, - const char *file = 0, int line = 0) = 0; + const char *file = nullptr, int line = 0) = 0; virtual void addBenchmarkResult(const QBenchmarkResult &result) = 0; virtual void addMessage(QtMsgType, const QMessageLogContext &, const QString &); virtual void addMessage(MessageTypes type, const QString &message, - const char *file = 0, int line = 0) = 0; + const char *file = nullptr, int line = 0) = 0; void outputString(const char *msg); @@ -151,7 +151,7 @@ struct QTestCharBuffer inline bool reset(int newSize) { - char *newBuf = 0; + char *newBuf = nullptr; if (buf == staticBuf) { // if we point to our internal buffer, we need to malloc first newBuf = reinterpret_cast(malloc(newSize)); diff --git a/src/testlib/qcsvbenchmarklogger_p.h b/src/testlib/qcsvbenchmarklogger_p.h index 5840aee0f5..83e465c859 100644 --- a/src/testlib/qcsvbenchmarklogger_p.h +++ b/src/testlib/qcsvbenchmarklogger_p.h @@ -68,11 +68,11 @@ public: void leaveTestFunction() override; void addIncident(IncidentTypes type, const char *description, - const char *file = 0, int line = 0) override; + const char *file = nullptr, int line = 0) override; void addBenchmarkResult(const QBenchmarkResult &result) override; void addMessage(MessageTypes type, const QString &message, - const char *file = 0, int line = 0) override; + const char *file = nullptr, int line = 0) override; }; QT_END_NAMESPACE diff --git a/src/testlib/qplaintestlogger_p.h b/src/testlib/qplaintestlogger_p.h index 55755830b2..80ef4864c1 100644 --- a/src/testlib/qplaintestlogger_p.h +++ b/src/testlib/qplaintestlogger_p.h @@ -68,17 +68,17 @@ public: void leaveTestFunction() override; void addIncident(IncidentTypes type, const char *description, - const char *file = 0, int line = 0) override; + const char *file = nullptr, int line = 0) override; void addBenchmarkResult(const QBenchmarkResult &result) override; void addMessage(QtMsgType, const QMessageLogContext &, const QString &) override; void addMessage(MessageTypes type, const QString &message, - const char *file = 0, int line = 0) override; + const char *file = nullptr, int line = 0) override; private: - void printMessage(const char *type, const char *msg, const char *file = 0, int line = 0); + void printMessage(const char *type, const char *msg, const char *file = nullptr, int line = 0); void outputMessage(const char *str); void printBenchmarkResult(const QBenchmarkResult &result); }; diff --git a/src/testlib/qsignalspy.h b/src/testlib/qsignalspy.h index 218a26ec5c..0285080662 100644 --- a/src/testlib/qsignalspy.h +++ b/src/testlib/qsignalspy.h @@ -122,7 +122,7 @@ public: } if (!QMetaObject::connect(obj, sigIndex, this, memberOffset, - Qt::DirectConnection, 0)) { + Qt::DirectConnection, nullptr)) { qWarning("QSignalSpy: QMetaObject::connect returned false. Unable to connect."); return; } diff --git a/src/testlib/qtaptestlogger_p.h b/src/testlib/qtaptestlogger_p.h index b51343e4fe..967c724b51 100644 --- a/src/testlib/qtaptestlogger_p.h +++ b/src/testlib/qtaptestlogger_p.h @@ -70,9 +70,9 @@ public: void enterTestData(QTestData *data) override; void addIncident(IncidentTypes type, const char *description, - const char *file = 0, int line = 0) override; + const char *file = nullptr, int line = 0) override; void addMessage(MessageTypes type, const QString &message, - const char *file = 0, int line = 0) override; + const char *file = nullptr, int line = 0) override; void addBenchmarkResult(const QBenchmarkResult &) override {}; private: diff --git a/src/testlib/qteamcitylogger_p.h b/src/testlib/qteamcitylogger_p.h index 80f2454724..dd7c0cdcf0 100644 --- a/src/testlib/qteamcitylogger_p.h +++ b/src/testlib/qteamcitylogger_p.h @@ -70,11 +70,11 @@ public: void leaveTestFunction() override; void addIncident(IncidentTypes type, const char *description, - const char *file = 0, int line = 0) override; + const char *file = nullptr, int line = 0) override; void addBenchmarkResult(const QBenchmarkResult &result) override; void addMessage(MessageTypes type, const QString &message, - const char *file = 0, int line = 0) override; + const char *file = nullptr, int line = 0) override; private: QString currTestFuncName; diff --git a/src/testlib/qtestcoreelement_p.h b/src/testlib/qtestcoreelement_p.h index e79efdd87f..84406fed85 100644 --- a/src/testlib/qtestcoreelement_p.h +++ b/src/testlib/qtestcoreelement_p.h @@ -80,7 +80,7 @@ class QTestCoreElement: public QTestCoreList template QTestCoreElement::QTestCoreElement(int t) - :listOfAttributes(0), type(QTest::LogElementType(t)) + :listOfAttributes(nullptr), type(QTest::LogElementType(t)) { } @@ -114,7 +114,7 @@ const char *QTestCoreElement::attributeValue(QTest::AttributeIndex if (attrb) return attrb->value(); - return 0; + return nullptr; } template @@ -124,7 +124,7 @@ const char *QTestCoreElement::attributeName(QTest::AttributeIndex i if (attrb) return attrb->name(); - return 0; + return nullptr; } template @@ -145,7 +145,7 @@ const char *QTestCoreElement::elementName() const if (type != QTest::LET_Undefined) return xmlElementNames[type]; - return 0; + return nullptr; } template @@ -165,7 +165,7 @@ const QTestElementAttribute *QTestCoreElement::attribute(QTest::Att iterator = iterator->nextElement(); } - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/testlib/qtestcorelist_p.h b/src/testlib/qtestcorelist_p.h index 4d080f6758..daeb293644 100644 --- a/src/testlib/qtestcorelist_p.h +++ b/src/testlib/qtestcorelist_p.h @@ -73,8 +73,8 @@ class QTestCoreList template QTestCoreList::QTestCoreList() - : next(0) - , prev(0) + : next(nullptr) + , prev(nullptr) { } @@ -82,12 +82,12 @@ template QTestCoreList::~QTestCoreList() { if (prev) { - prev->next = 0; + prev->next = nullptr; } delete prev; if (next) { - next->prev = 0; + next->prev = nullptr; } delete next; } diff --git a/src/testlib/qxmltestlogger_p.h b/src/testlib/qxmltestlogger_p.h index b85742f939..04ed57d587 100644 --- a/src/testlib/qxmltestlogger_p.h +++ b/src/testlib/qxmltestlogger_p.h @@ -71,11 +71,11 @@ public: void leaveTestFunction() override; void addIncident(IncidentTypes type, const char *description, - const char *file = 0, int line = 0) override; + const char *file = nullptr, int line = 0) override; void addBenchmarkResult(const QBenchmarkResult &result) override; void addMessage(MessageTypes type, const QString &message, - const char *file = 0, int line = 0) override; + const char *file = nullptr, int line = 0) override; static int xmlCdata(QTestCharBuffer *dest, char const* src); static int xmlQuote(QTestCharBuffer *dest, char const* src); diff --git a/src/testlib/qxunittestlogger_p.h b/src/testlib/qxunittestlogger_p.h index 8fb01fbe61..48f07ddcf2 100644 --- a/src/testlib/qxunittestlogger_p.h +++ b/src/testlib/qxunittestlogger_p.h @@ -71,12 +71,12 @@ class QXunitTestLogger : public QAbstractTestLogger void leaveTestFunction() override; void addIncident(IncidentTypes type, const char *description, - const char *file = 0, int line = 0) override; + const char *file = nullptr, int line = 0) override; void addBenchmarkResult(const QBenchmarkResult &result) override; void addTag(QTestElement* element); void addMessage(MessageTypes type, const QString &message, - const char *file = 0, int line = 0) override; + const char *file = nullptr, int line = 0) override; private: QTestElement *listOfTestcases; diff --git a/src/tools/moc/generator.h b/src/tools/moc/generator.h index 134166580b..eae0353199 100644 --- a/src/tools/moc/generator.h +++ b/src/tools/moc/generator.h @@ -39,7 +39,7 @@ class Generator ClassDef *cdef; QVector meta_data; public: - Generator(ClassDef *classDef, const QVector &metaTypes, const QHash &knownQObjectClasses, const QHash &knownGadgets, FILE *outfile = 0); + Generator(ClassDef *classDef, const QVector &metaTypes, const QHash &knownQObjectClasses, const QHash &knownGadgets, FILE *outfile = nullptr); void generateCode(); private: bool registerableMetaType(const QByteArray &propertyType); diff --git a/src/tools/moc/parser.h b/src/tools/moc/parser.h index bedcbbf7e2..63f4cf0d9a 100644 --- a/src/tools/moc/parser.h +++ b/src/tools/moc/parser.h @@ -69,9 +69,9 @@ public: inline const Symbol &symbol() { return symbols.at(index-1);} Q_NORETURN void error(int rollback); - Q_NORETURN void error(const char *msg = 0); - void warning(const char * = 0); - void note(const char * = 0); + Q_NORETURN void error(const char *msg = nullptr); + void warning(const char * = nullptr); + void note(const char * = nullptr); }; diff --git a/src/tools/uic/driver.h b/src/tools/uic/driver.h index 1303d0bf8a..69206e1608 100644 --- a/src/tools/uic/driver.h +++ b/src/tools/uic/driver.h @@ -56,8 +56,8 @@ public: // tools bool printDependencies(const QString &fileName); - bool uic(const QString &fileName, QTextStream *output = 0); - bool uic(const QString &fileName, DomUI *ui, QTextStream *output = 0); + bool uic(const QString &fileName, QTextStream *output = nullptr); + bool uic(const QString &fileName, DomUI *ui, QTextStream *output = nullptr); // configuration inline QTextStream &output() const { return *m_output; } diff --git a/src/widgets/dialogs/qdialog_p.h b/src/widgets/dialogs/qdialog_p.h index 92634f6793..77f9fae09a 100644 --- a/src/widgets/dialogs/qdialog_p.h +++ b/src/widgets/dialogs/qdialog_p.h @@ -75,15 +75,15 @@ public: QDialogPrivate() : #if QT_CONFIG(pushbutton) - mainDef(0), + mainDef(nullptr), #endif - orientation(Qt::Horizontal),extension(0), doShowExtension(false), + orientation(Qt::Horizontal),extension(nullptr), doShowExtension(false), #if QT_CONFIG(sizegrip) - resizer(0), + resizer(nullptr), sizeGripEnabled(false), #endif - rescode(0), resetModalityTo(-1), wasModalitySet(true), eventLoop(0), - nativeDialogInUse(false), m_platformHelper(0), m_platformHelperCreated(false) + rescode(0), resetModalityTo(-1), wasModalitySet(true), eventLoop(nullptr), + nativeDialogInUse(false), m_platformHelper(nullptr), m_platformHelperCreated(false) {} ~QDialogPrivate(); diff --git a/src/widgets/dialogs/qfiledialog_p.h b/src/widgets/dialogs/qfiledialog_p.h index 463c77aa23..7e53b61031 100644 --- a/src/widgets/dialogs/qfiledialog_p.h +++ b/src/widgets/dialogs/qfiledialog_p.h @@ -98,7 +98,7 @@ class QPlatformDialogHelper; struct QFileDialogArgs { - QFileDialogArgs() : parent(0), mode(QFileDialog::AnyFile) {} + QFileDialogArgs() : parent(nullptr), mode(QFileDialog::AnyFile) {} QWidget *parent; QString caption; @@ -292,7 +292,7 @@ private: class QFileDialogLineEdit : public QLineEdit { public: - QFileDialogLineEdit(QWidget *parent = 0) : QLineEdit(parent), d_ptr(0){} + QFileDialogLineEdit(QWidget *parent = nullptr) : QLineEdit(parent), d_ptr(nullptr){} void setFileDialogPrivate(QFileDialogPrivate *d_pointer) {d_ptr = d_pointer; } void keyPressEvent(QKeyEvent *e) override; bool hideOnEsc; @@ -303,7 +303,7 @@ private: class QFileDialogComboBox : public QComboBox { public: - QFileDialogComboBox(QWidget *parent = 0) : QComboBox(parent), urlModel(0) {} + QFileDialogComboBox(QWidget *parent = nullptr) : QComboBox(parent), urlModel(nullptr) {} void setFileDialogPrivate(QFileDialogPrivate *d_pointer); void showPopup() override; void setHistory(const QStringList &paths); @@ -319,7 +319,7 @@ private: class QFileDialogListView : public QListView { public: - QFileDialogListView(QWidget *parent = 0); + QFileDialogListView(QWidget *parent = nullptr); void setFileDialogPrivate(QFileDialogPrivate *d_pointer); QSize sizeHint() const override; protected: diff --git a/src/widgets/dialogs/qfileinfogatherer_p.h b/src/widgets/dialogs/qfileinfogatherer_p.h index 134a14b7ce..795f60249f 100644 --- a/src/widgets/dialogs/qfileinfogatherer_p.h +++ b/src/widgets/dialogs/qfileinfogatherer_p.h @@ -166,7 +166,7 @@ Q_SIGNALS: void directoryLoaded(const QString &path); public: - explicit QFileInfoGatherer(QObject *parent = 0); + explicit QFileInfoGatherer(QObject *parent = nullptr); ~QFileInfoGatherer(); #if QT_CONFIG(filesystemwatcher) && defined(Q_OS_WIN) diff --git a/src/widgets/dialogs/qfilesystemmodel_p.h b/src/widgets/dialogs/qfilesystemmodel_p.h index 9c432e1ae6..d8f9f2b076 100644 --- a/src/widgets/dialogs/qfilesystemmodel_p.h +++ b/src/widgets/dialogs/qfilesystemmodel_p.h @@ -99,13 +99,13 @@ public: class QFileSystemNode { public: - explicit QFileSystemNode(const QString &filename = QString(), QFileSystemNode *p = 0) - : fileName(filename), populatedChildren(false), isVisible(false), dirtyChildrenIndex(-1), parent(p), info(0) {} + explicit QFileSystemNode(const QString &filename = QString(), QFileSystemNode *p = nullptr) + : fileName(filename), populatedChildren(false), isVisible(false), dirtyChildrenIndex(-1), parent(p), info(nullptr) {} ~QFileSystemNode() { qDeleteAll(children); delete info; - info = 0; - parent = 0; + info = nullptr; + parent = nullptr; } QString fileName; @@ -116,7 +116,7 @@ public: inline qint64 size() const { if (info && !info->isDir()) return info->size(); return 0; } inline QString type() const { if (info) return info->displayType; return QLatin1String(""); } inline QDateTime lastModified() const { if (info) return info->lastModified(); return QDateTime(); } - inline QFile::Permissions permissions() const { if (info) return info->permissions(); return 0; } + inline QFile::Permissions permissions() const { if (info) return info->permissions(); return nullptr; } inline bool isReadable() const { return ((permissions() & QFile::ReadUser) != 0); } inline bool isWritable() const { return ((permissions() & QFile::WriteUser) != 0); } inline bool isExecutable() const { return ((permissions() & QFile::ExeUser) != 0); } @@ -162,7 +162,7 @@ public: return info && (*info == fileInfo); } - inline bool hasInformation() const { return info != 0; } + inline bool hasInformation() const { return info != nullptr; } void populate(const QExtendedInformation &fileInfo) { if (!info) diff --git a/src/widgets/dialogs/qfscompleter_p.h b/src/widgets/dialogs/qfscompleter_p.h index 3b829d4a52..f5110a7622 100644 --- a/src/widgets/dialogs/qfscompleter_p.h +++ b/src/widgets/dialogs/qfscompleter_p.h @@ -64,8 +64,8 @@ QT_BEGIN_NAMESPACE */ class Q_WIDGETS_EXPORT QFSCompleter : public QCompleter { public: - explicit QFSCompleter(QFileSystemModel *model, QObject *parent = 0) - : QCompleter(model, parent), proxyModel(0), sourceModel(model) + explicit QFSCompleter(QFileSystemModel *model, QObject *parent = nullptr) + : QCompleter(model, parent), proxyModel(nullptr), sourceModel(model) { #if defined(Q_OS_WIN) setCaseSensitivity(Qt::CaseInsensitive); diff --git a/src/widgets/dialogs/qsidebar_p.h b/src/widgets/dialogs/qsidebar_p.h index 4a82f88878..6056f19452 100644 --- a/src/widgets/dialogs/qsidebar_p.h +++ b/src/widgets/dialogs/qsidebar_p.h @@ -67,7 +67,7 @@ class QFileSystemModel; class QSideBarDelegate : public QStyledItemDelegate { public: - QSideBarDelegate(QWidget *parent = 0) : QStyledItemDelegate(parent) {} + QSideBarDelegate(QWidget *parent = nullptr) : QStyledItemDelegate(parent) {} void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const override; }; @@ -82,7 +82,7 @@ public: EnabledRole = Qt::UserRole + 2 }; - QUrlModel(QObject *parent = 0); + QUrlModel(QObject *parent = nullptr); QStringList mimeTypes() const override; QMimeData *mimeData(const QModelIndexList &indexes) const override; @@ -127,7 +127,7 @@ Q_SIGNALS: void goToUrl(const QUrl &url); public: - QSidebar(QWidget *parent = 0); + QSidebar(QWidget *parent = nullptr); void setModelAndUrls(QFileSystemModel *model, const QList &newUrls); ~QSidebar(); diff --git a/src/widgets/effects/qgraphicseffect_p.h b/src/widgets/effects/qgraphicseffect_p.h index 2f3bd2f7fd..7e342a9f3c 100644 --- a/src/widgets/effects/qgraphicseffect_p.h +++ b/src/widgets/effects/qgraphicseffect_p.h @@ -80,11 +80,11 @@ public: QRectF boundingRect(Qt::CoordinateSystem coordinateSystem = Qt::LogicalCoordinates) const; QRect deviceRect() const; QPixmap pixmap(Qt::CoordinateSystem system = Qt::LogicalCoordinates, - QPoint *offset = 0, + QPoint *offset = nullptr, QGraphicsEffect::PixmapPadMode mode = QGraphicsEffect::PadToEffectiveBoundingRect) const; protected: - QGraphicsEffectSource(QGraphicsEffectSourcePrivate &dd, QObject *parent = 0); + QGraphicsEffectSource(QGraphicsEffectSourcePrivate &dd, QObject *parent = nullptr); private: Q_DECLARE_PRIVATE(QGraphicsEffectSource) @@ -125,7 +125,7 @@ public: virtual void draw(QPainter *p) = 0; virtual void update() = 0; virtual bool isPixmap() const = 0; - virtual QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset = 0, + virtual QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset = nullptr, QGraphicsEffect::PixmapPadMode mode = QGraphicsEffect::PadToTransparentBorder) const = 0; virtual void effectBoundingRectChanged() = 0; @@ -149,7 +149,7 @@ class Q_WIDGETS_EXPORT QGraphicsEffectPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QGraphicsEffect) public: - QGraphicsEffectPrivate() : source(0), isEnabled(1) {} + QGraphicsEffectPrivate() : source(nullptr), isEnabled(1) {} ~QGraphicsEffectPrivate(); inline void setGraphicsEffectSource(QGraphicsEffectSource *newSource) diff --git a/src/widgets/effects/qpixmapfilter_p.h b/src/widgets/effects/qpixmapfilter_p.h index 0f582bde60..c56acb8a24 100644 --- a/src/widgets/effects/qpixmapfilter_p.h +++ b/src/widgets/effects/qpixmapfilter_p.h @@ -100,7 +100,7 @@ class Q_WIDGETS_EXPORT QPixmapConvolutionFilter : public QPixmapFilter Q_DECLARE_PRIVATE(QPixmapConvolutionFilter) public: - QPixmapConvolutionFilter(QObject *parent = 0); + QPixmapConvolutionFilter(QObject *parent = nullptr); ~QPixmapConvolutionFilter(); void setConvolutionKernel(const qreal *matrix, int rows, int columns); @@ -124,7 +124,7 @@ class Q_WIDGETS_EXPORT QPixmapBlurFilter : public QPixmapFilter Q_DECLARE_PRIVATE(QPixmapBlurFilter) public: - QPixmapBlurFilter(QObject *parent = 0); + QPixmapBlurFilter(QObject *parent = nullptr); ~QPixmapBlurFilter(); void setRadius(qreal radius); @@ -148,7 +148,7 @@ class Q_WIDGETS_EXPORT QPixmapColorizeFilter : public QPixmapFilter Q_DECLARE_PRIVATE(QPixmapColorizeFilter) public: - QPixmapColorizeFilter(QObject *parent = 0); + QPixmapColorizeFilter(QObject *parent = nullptr); ~QPixmapColorizeFilter(); void setColor(const QColor& color); @@ -168,7 +168,7 @@ class Q_WIDGETS_EXPORT QPixmapDropShadowFilter : public QPixmapFilter Q_DECLARE_PRIVATE(QPixmapDropShadowFilter) public: - QPixmapDropShadowFilter(QObject *parent = 0); + QPixmapDropShadowFilter(QObject *parent = nullptr); ~QPixmapDropShadowFilter(); QRectF boundingRectFor(const QRectF &rect) const override; diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.h b/src/widgets/graphicsview/qgraphicsanchorlayout_p.h index 699ca32bfe..b5f14948ac 100644 --- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.h @@ -89,7 +89,7 @@ struct AnchorVertex { : m_item(item), m_edge(edge), m_type(Normal) {} AnchorVertex() - : m_item(0), m_edge(Qt::AnchorPoint(0)), m_type(Normal) {} + : m_item(nullptr), m_edge(Qt::AnchorPoint(0)), m_type(Normal) {} #ifdef QT_DEBUG inline QString toString() const; @@ -123,18 +123,18 @@ struct AnchorData : public QSimplexVariable { }; AnchorData() - : QSimplexVariable(), from(0), to(0), + : QSimplexVariable(), from(nullptr), to(nullptr), minSize(0), prefSize(0), maxSize(0), minPrefSize(0), maxPrefSize(0), sizeAtMinimum(0), sizeAtPreferred(0), - sizeAtMaximum(0), item(0), graphicsAnchor(0), + sizeAtMaximum(0), item(nullptr), graphicsAnchor(nullptr), type(Normal), isLayoutAnchor(false), isCenterAnchor(false), orientation(0), dependency(Independent) {} virtual ~AnchorData(); virtual void updateChildrenSizes() {} - void refreshSizeHints(const QLayoutStyleInfo *styleInfo = 0); + void refreshSizeHints(const QLayoutStyleInfo *styleInfo = nullptr); #ifdef QT_DEBUG void dump(int indent = 2); @@ -402,7 +402,7 @@ public: static QGraphicsAnchorLayoutPrivate *get(QGraphicsAnchorLayout *q) { - return q ? q->d_func() : 0; + return q ? q->d_func() : nullptr; } static Qt::AnchorPoint oppositeEdge( @@ -443,7 +443,7 @@ public: Qt::AnchorPoint firstEdge, QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge, - qreal *spacing = 0); + qreal *spacing = nullptr); // Helper for Anchor Manipulation methods void addAnchor_helper(QGraphicsLayoutItem *firstItem, diff --git a/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h b/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h index 370df9eed7..e98160e40f 100644 --- a/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h +++ b/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h @@ -68,7 +68,7 @@ class QGraphicsLayoutPrivate; class QGraphicsGridLayoutEngineItem : public QGridLayoutItem { public: QGraphicsGridLayoutEngineItem(QGraphicsLayoutItem *item, int row, int columns, int rowSpan = 1, int columnSpan = 1, - Qt::Alignment alignment = 0) + Qt::Alignment alignment = nullptr) : QGridLayoutItem(row, columns, rowSpan, columnSpan, alignment), q_layoutItem(item) {} virtual QLayoutPolicy::Policy sizePolicy(Qt::Orientation orientation) const override @@ -115,7 +115,7 @@ public: { const int index = indexOf(layoutItem); if (index < 0) - return 0; + return nullptr; return static_cast(q_items.at(index)); } diff --git a/src/widgets/graphicsview/qgraphicsitem_p.h b/src/widgets/graphicsview/qgraphicsitem_p.h index d586a22544..a2c3774f65 100644 --- a/src/widgets/graphicsview/qgraphicsitem_p.h +++ b/src/widgets/graphicsview/qgraphicsitem_p.h @@ -78,13 +78,13 @@ public: typedef void (*ClearFunction)(QDeclarativeListProperty *); QDeclarativeListProperty() - : object(0), data(0), append(0), count(0), at(0), clear(0), dummy1(0), dummy2(0) {} + : object(nullptr), data(nullptr), append(nullptr), count(nullptr), at(nullptr), clear(nullptr), dummy1(nullptr), dummy2(nullptr) {} QDeclarativeListProperty(QObject *o, QList &list) : object(o), data(&list), append(qlist_append), count(qlist_count), at(qlist_at), - clear(qlist_clear), dummy1(0), dummy2(0) {} + clear(qlist_clear), dummy1(nullptr), dummy2(nullptr) {} QDeclarativeListProperty(QObject *o, void *d, AppendFunction a, CountFunction c = 0, AtFunction t = 0, ClearFunction r = 0) - : object(o), data(d), append(a), count(c), at(t), clear(r), dummy1(0), dummy2(0) {} + : object(o), data(d), append(a), count(c), at(t), clear(r), dummy1(nullptr), dummy2(nullptr) {} bool operator==(const QDeclarativeListProperty &o) const { return object == o.object && @@ -198,8 +198,8 @@ public: || (ancestorFlags & AncestorIgnoresTransformations); } - void combineTransformToParent(QTransform *x, const QTransform *viewTransform = 0) const; - void combineTransformFromParent(QTransform *x, const QTransform *viewTransform = 0) const; + void combineTransformToParent(QTransform *x, const QTransform *viewTransform = nullptr) const; + void combineTransformFromParent(QTransform *x, const QTransform *viewTransform = nullptr) const; virtual void updateSceneTransformFromParent(); static bool movableAncestorIsSelected(const QGraphicsItem *item); @@ -232,7 +232,7 @@ public: void childrenBoundingRectHelper(QTransform *x, QRectF *rect, QGraphicsItem *topMostEffectItem); void initStyleOption(QStyleOptionGraphicsItem *option, const QTransform &worldTransform, const QRegion &exposedRegion, bool allItems = false) const; - QRectF effectiveBoundingRect(QGraphicsItem *topMostEffectItem = 0) const; + QRectF effectiveBoundingRect(QGraphicsItem *topMostEffectItem = nullptr) const; QRectF sceneEffectiveBoundingRect() const; QRectF effectiveBoundingRect(const QRectF &rect) const; @@ -408,8 +408,8 @@ public: void setFocusHelper(Qt::FocusReason focusReason, bool climb, bool focusFromHide); void clearFocusHelper(bool giveFocusToParent, bool hiddenByParentPanel); - void setSubFocus(QGraphicsItem *rootItem = 0, QGraphicsItem *stopItem = 0); - void clearSubFocus(QGraphicsItem *rootItem = 0, QGraphicsItem *stopItem = 0); + void setSubFocus(QGraphicsItem *rootItem = nullptr, QGraphicsItem *stopItem = nullptr); + void clearSubFocus(QGraphicsItem *rootItem = nullptr, QGraphicsItem *stopItem = nullptr); void resetFocusProxy(); virtual void subFocusItemChange(); virtual void focusScopeItemChange(bool isSubFocusItem); @@ -541,7 +541,7 @@ struct QGraphicsItemPrivate::TransformData onlyTransform(true) { } - QTransform computedFullTransform(QTransform *postmultiplyTransform = 0) const + QTransform computedFullTransform(QTransform *postmultiplyTransform = nullptr) const { if (onlyTransform) { if (!postmultiplyTransform || postmultiplyTransform->isIdentity()) @@ -595,12 +595,12 @@ class QGraphicsItemEffectSourcePrivate : public QGraphicsEffectSourcePrivate { public: QGraphicsItemEffectSourcePrivate(QGraphicsItem *i) - : QGraphicsEffectSourcePrivate(), item(i), info(0) + : QGraphicsEffectSourcePrivate(), item(i), info(nullptr) {} void detach() override { - item->d_ptr->graphicsEffect = 0; + item->d_ptr->graphicsEffect = nullptr; item->prepareGeometryChange(); } @@ -608,7 +608,7 @@ public: { return item; } const QWidget *widget() const override - { return 0; } + { return nullptr; } void update() override { item->d_ptr->updateDueToGraphicsEffect = true; @@ -628,7 +628,7 @@ public: } const QStyleOption *styleOption() const override - { return info ? info->option : 0; } + { return info ? info->option : nullptr; } QRect deviceRect() const override { @@ -644,7 +644,7 @@ public: QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset, QGraphicsEffect::PixmapPadMode mode) const override; - QRect paddedEffectRect(Qt::CoordinateSystem system, QGraphicsEffect::PixmapPadMode mode, const QRectF &sourceRect, bool *unpadded = 0) const; + QRect paddedEffectRect(Qt::CoordinateSystem system, QGraphicsEffect::PixmapPadMode mode, const QRectF &sourceRect, bool *unpadded = nullptr) const; QGraphicsItem *item; QGraphicsItemPaintInfo *info; diff --git a/src/widgets/graphicsview/qgraphicslayout_p.h b/src/widgets/graphicsview/qgraphicslayout_p.h index 302ad1e116..0d91151e22 100644 --- a/src/widgets/graphicsview/qgraphicslayout_p.h +++ b/src/widgets/graphicsview/qgraphicslayout_p.h @@ -91,7 +91,7 @@ public: m_defaultSpacing[1] = style->pixelMetric(QStyle::PM_LayoutVerticalSpacing); } - inline void invalidate() { m_valid = false; m_style = 0; m_widget = 0; } + inline void invalidate() { m_valid = false; m_style = nullptr; m_widget = nullptr; } inline QStyle *style() const { return m_style; } inline QWidget *widget() const { return m_widget; } @@ -130,7 +130,7 @@ class Q_AUTOTEST_EXPORT QGraphicsLayoutPrivate : public QGraphicsLayoutItemPriva Q_DECLARE_PUBLIC(QGraphicsLayout) public: - QGraphicsLayoutPrivate() : QGraphicsLayoutItemPrivate(0, true), left(-1.0), top(-1.0), right(-1.0), bottom(-1.0), + QGraphicsLayoutPrivate() : QGraphicsLayoutItemPrivate(nullptr, true), left(-1.0), top(-1.0), right(-1.0), bottom(-1.0), activated(true) { } void reparentChildItems(QGraphicsItem *newParent); diff --git a/src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h b/src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h index c3af9f4554..9807efb26e 100644 --- a/src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h +++ b/src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h @@ -84,7 +84,7 @@ public: virtual void invalidate() override { - m_style = 0; + m_style = nullptr; QAbstractLayoutStyleInfo::invalidate(); } diff --git a/src/widgets/graphicsview/qgraphicsscene_p.h b/src/widgets/graphicsview/qgraphicsscene_p.h index a2d13436fc..7934359cee 100644 --- a/src/widgets/graphicsview/qgraphicsscene_p.h +++ b/src/widgets/graphicsview/qgraphicsscene_p.h @@ -226,7 +226,7 @@ public: void drawSubtreeRecursive(QGraphicsItem *item, QPainter *painter, const QTransform *const, QRegion *exposedRegion, QWidget *widget, qreal parentOpacity = qreal(1.0), - const QTransform *const effectTransform = 0); + const QTransform *const effectTransform = nullptr); void draw(QGraphicsItem *, QPainter *, const QTransform *const, const QTransform *const, QRegion *, QWidget *, qreal, const QTransform *const, bool, bool); @@ -312,9 +312,9 @@ public: void gestureTargetsAtHotSpots(const QSet &gestures, Qt::GestureFlag flag, QHash > *targets, - QSet *itemsSet = 0, - QSet *normal = 0, - QSet *conflicts = 0); + QSet *itemsSet = nullptr, + QSet *normal = nullptr, + QSet *conflicts = nullptr); void cancelGesturesForChildren(QGesture *original); void grabGesture(QGraphicsItem *, Qt::GestureType gesture); void ungrabGesture(QGraphicsItem *, Qt::GestureType gesture); diff --git a/src/widgets/graphicsview/qgraphicsscenebsptreeindex_p.h b/src/widgets/graphicsview/qgraphicsscenebsptreeindex_p.h index eb6bbbf49b..7e0e525a6b 100644 --- a/src/widgets/graphicsview/qgraphicsscenebsptreeindex_p.h +++ b/src/widgets/graphicsview/qgraphicsscenebsptreeindex_p.h @@ -74,7 +74,7 @@ class Q_AUTOTEST_EXPORT QGraphicsSceneBspTreeIndex : public QGraphicsSceneIndex Q_OBJECT Q_PROPERTY(int bspTreeDepth READ bspTreeDepth WRITE setBspTreeDepth) public: - QGraphicsSceneBspTreeIndex(QGraphicsScene *scene = 0); + QGraphicsSceneBspTreeIndex(QGraphicsScene *scene = nullptr); ~QGraphicsSceneBspTreeIndex(); QList estimateItems(const QRectF &rect, Qt::SortOrder order) const override; diff --git a/src/widgets/graphicsview/qgraphicssceneindex_p.h b/src/widgets/graphicsview/qgraphicssceneindex_p.h index 86637e836b..b494c52671 100644 --- a/src/widgets/graphicsview/qgraphicssceneindex_p.h +++ b/src/widgets/graphicsview/qgraphicssceneindex_p.h @@ -77,7 +77,7 @@ class Q_AUTOTEST_EXPORT QGraphicsSceneIndex : public QObject Q_OBJECT public: - QGraphicsSceneIndex(QGraphicsScene *scene = 0); + QGraphicsSceneIndex(QGraphicsScene *scene = nullptr); virtual ~QGraphicsSceneIndex(); QGraphicsScene *scene() const; diff --git a/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h b/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h index 07d5d80ef1..ead52c1fb0 100644 --- a/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h +++ b/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h @@ -67,7 +67,7 @@ class Q_AUTOTEST_EXPORT QGraphicsSceneLinearIndex : public QGraphicsSceneIndex Q_OBJECT public: - QGraphicsSceneLinearIndex(QGraphicsScene *scene = 0) : QGraphicsSceneIndex(scene), m_numSortedElements(0) + QGraphicsSceneLinearIndex(QGraphicsScene *scene = nullptr) : QGraphicsSceneIndex(scene), m_numSortedElements(0) { } QList items(Qt::SortOrder order = Qt::DescendingOrder) const override diff --git a/src/widgets/graphicsview/qgraphicstransform_p.h b/src/widgets/graphicsview/qgraphicstransform_p.h index e54ee9fb3c..05e12c3e64 100644 --- a/src/widgets/graphicsview/qgraphicstransform_p.h +++ b/src/widgets/graphicsview/qgraphicstransform_p.h @@ -66,7 +66,7 @@ public: Q_DECLARE_PUBLIC(QGraphicsTransform) QGraphicsTransformPrivate() - : QObjectPrivate(), item(0) {} + : QObjectPrivate(), item(nullptr) {} ~QGraphicsTransformPrivate(); QGraphicsItem *item; diff --git a/src/widgets/graphicsview/qgraphicswidget_p.h b/src/widgets/graphicsview/qgraphicswidget_p.h index 505a2a24c0..821f8c73f1 100644 --- a/src/widgets/graphicsview/qgraphicswidget_p.h +++ b/src/widgets/graphicsview/qgraphicswidget_p.h @@ -82,7 +82,7 @@ public: mutable qreal *margins; void ensureMargins() const; - void fixFocusChainBeforeReparenting(QGraphicsWidget *newParent, QGraphicsScene *oldScene, QGraphicsScene *newScene = 0); + void fixFocusChainBeforeReparenting(QGraphicsWidget *newParent, QGraphicsScene *oldScene, QGraphicsScene *newScene = nullptr); void setLayout_helper(QGraphicsLayout *l); // Layouts diff --git a/src/widgets/graphicsview/qsimplex_p.h b/src/widgets/graphicsview/qsimplex_p.h index 369f2f5f82..a69cef6115 100644 --- a/src/widgets/graphicsview/qsimplex_p.h +++ b/src/widgets/graphicsview/qsimplex_p.h @@ -82,7 +82,7 @@ struct QSimplexVariable */ struct QSimplexConstraint { - QSimplexConstraint() : constant(0), ratio(Equal), artificial(0) {} + QSimplexConstraint() : constant(0), ratio(Equal), artificial(nullptr) {} enum Ratio { LessOrEqual = 0, diff --git a/src/widgets/itemviews/qcolumnview_p.h b/src/widgets/itemviews/qcolumnview_p.h index 7b36b1f3da..c60579255e 100644 --- a/src/widgets/itemviews/qcolumnview_p.h +++ b/src/widgets/itemviews/qcolumnview_p.h @@ -74,7 +74,7 @@ QT_BEGIN_NAMESPACE class QColumnViewPreviewColumn : public QAbstractItemView { public: - explicit QColumnViewPreviewColumn(QWidget *parent) : QAbstractItemView(parent), previewWidget(0) { + explicit QColumnViewPreviewColumn(QWidget *parent) : QAbstractItemView(parent), previewWidget(nullptr) { } void setPreviewWidget(QWidget *widget) { @@ -186,7 +186,7 @@ class QColumnViewDelegate : public QItemDelegate { public: - explicit QColumnViewDelegate(QObject *parent = 0) : QItemDelegate(parent) {} + explicit QColumnViewDelegate(QObject *parent = nullptr) : QItemDelegate(parent) {} ~QColumnViewDelegate() {} void paint(QPainter *painter, diff --git a/src/widgets/itemviews/qcolumnviewgrip_p.h b/src/widgets/itemviews/qcolumnviewgrip_p.h index 5eb8012204..4311edbeb4 100644 --- a/src/widgets/itemviews/qcolumnviewgrip_p.h +++ b/src/widgets/itemviews/qcolumnviewgrip_p.h @@ -68,12 +68,12 @@ Q_SIGNALS: void gripMoved(int offset); public: - explicit QColumnViewGrip(QWidget *parent = 0); + explicit QColumnViewGrip(QWidget *parent = nullptr); ~QColumnViewGrip(); int moveGrip(int offset); protected: - QColumnViewGrip(QColumnViewGripPrivate &, QWidget *parent = 0, Qt::WindowFlags f = 0); + QColumnViewGrip(QColumnViewGripPrivate &, QWidget *parent = nullptr, Qt::WindowFlags f = nullptr); void paintEvent(QPaintEvent *event) override; void mouseDoubleClickEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; diff --git a/src/widgets/itemviews/qheaderview_p.h b/src/widgets/itemviews/qheaderview_p.h index d9fc1baec5..766adef36d 100644 --- a/src/widgets/itemviews/qheaderview_p.h +++ b/src/widgets/itemviews/qheaderview_p.h @@ -102,7 +102,7 @@ public: lastSectionLogicalIdx(-1), // Only trust when we stretch last section sectionIndicatorOffset(0), #if QT_CONFIG(label) - sectionIndicator(0), + sectionIndicator(nullptr), #endif globalResizeMode(QHeaderView::Interactive), sectionStartposRecalc(true), diff --git a/src/widgets/itemviews/qlistview_p.h b/src/widgets/itemviews/qlistview_p.h index c6810f8fdc..86331bb862 100644 --- a/src/widgets/itemviews/qlistview_p.h +++ b/src/widgets/itemviews/qlistview_p.h @@ -248,7 +248,7 @@ private: class QIconModeViewBase : public QCommonListViewBase { public: - QIconModeViewBase(QListView *q, QListViewPrivate *d) : QCommonListViewBase(q, d), interSectingVector(0) {} + QIconModeViewBase(QListView *q, QListViewPrivate *d) : QCommonListViewBase(q, d), interSectingVector(nullptr) {} QBspTree tree; QVector items; diff --git a/src/widgets/itemviews/qtableview_p.h b/src/widgets/itemviews/qtableview_p.h index d55462c28b..f629dfcd09 100644 --- a/src/widgets/itemviews/qtableview_p.h +++ b/src/widgets/itemviews/qtableview_p.h @@ -137,7 +137,7 @@ public: : showGrid(true), gridStyle(Qt::SolidLine), rowSectionAnchor(-1), columnSectionAnchor(-1), columnResizeTimerID(0), rowResizeTimerID(0), - horizontalHeader(0), verticalHeader(0), + horizontalHeader(nullptr), verticalHeader(nullptr), sortingEnabled(false), geometryRecursionBlock(false), visualCursor(QPoint()) { diff --git a/src/widgets/itemviews/qtreeview_p.h b/src/widgets/itemviews/qtreeview_p.h index 9666a9f8c2..836d8f0c2d 100644 --- a/src/widgets/itemviews/qtreeview_p.h +++ b/src/widgets/itemviews/qtreeview_p.h @@ -87,7 +87,7 @@ public: QTreeViewPrivate() : QAbstractItemViewPrivate(), - header(0), indent(20), lastViewedItem(0), defaultItemHeight(-1), + header(nullptr), indent(20), lastViewedItem(0), defaultItemHeight(-1), uniformRowHeights(false), rootDecoration(true), itemsExpandable(true), sortingEnabled(false), expandsOnDoubleClick(true), @@ -157,7 +157,7 @@ public: bool checkViewItems() const; #endif - int firstVisibleItem(int *offset = 0) const; + int firstVisibleItem(int *offset = nullptr) const; int lastVisibleItem(int firstVisual = -1, int offset = -1) const; int columnAt(int x) const; bool hasVisibleChildren( const QModelIndex& parent) const; diff --git a/src/widgets/itemviews/qtreewidget_p.h b/src/widgets/itemviews/qtreewidget_p.h index ee4a633468..81e7e86203 100644 --- a/src/widgets/itemviews/qtreewidget_p.h +++ b/src/widgets/itemviews/qtreewidget_p.h @@ -78,7 +78,7 @@ class QTreeModel : public QAbstractItemModel friend class QTreeWidgetItemIteratorPrivate; public: - explicit QTreeModel(int columns = 0, QTreeWidget *parent = 0); + explicit QTreeModel(int columns = 0, QTreeWidget *parent = nullptr); ~QTreeModel(); inline QTreeWidget *view() const @@ -140,7 +140,7 @@ public: { return createIndex(row, col, item); } protected: - QTreeModel(QTreeModelPrivate &, QTreeWidget *parent = 0); + QTreeModel(QTreeModelPrivate &, QTreeWidget *parent = nullptr); void emitDataChanged(QTreeWidgetItem *item, int column, const QVector &roles); void beginInsertItems(QTreeWidgetItem *parent, int row, int count); void endInsertItems(); diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index 133279f977..98eb9b73c6 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -128,10 +128,10 @@ public: void notifyWindowIconChanged() override; //modality - bool isWindowBlocked(QWindow *window, QWindow **blockingWindow = 0) const override; + bool isWindowBlocked(QWindow *window, QWindow **blockingWindow = nullptr) const override; static bool isBlockedByModal(QWidget *widget); static bool modalState(); - static bool tryModalHelper(QWidget *widget, QWidget **rettop = 0); + static bool tryModalHelper(QWidget *widget, QWidget **rettop = nullptr); #if 0 // Used to be included in Qt4 for Q_WS_MAC static QWidget *tryModalHelper_sys(QWidget *top); bool canQuit(); @@ -157,7 +157,7 @@ public: void openPopup(QWidget *popup); static void setFocusWidget(QWidget *focus, Qt::FocusReason reason); static QWidget *focusNextPrevChild_helper(QWidget *toplevel, bool next, - bool *wrappingOccurred = 0); + bool *wrappingOccurred = nullptr); #if QT_CONFIG(graphicsview) // Maintain a list of all scenes to ensure font and palette propagation to @@ -238,7 +238,7 @@ public: return window; if (const QWidget *nativeParent = widget->nativeParentWidget()) return nativeParent->windowHandle(); - return 0; + return nullptr; } #ifdef Q_OS_WIN diff --git a/src/widgets/kernel/qgesture_p.h b/src/widgets/kernel/qgesture_p.h index 636103c1e1..cbf8d60892 100644 --- a/src/widgets/kernel/qgesture_p.h +++ b/src/widgets/kernel/qgesture_p.h @@ -111,7 +111,7 @@ class QPinchGesturePrivate : public QGesturePrivate public: QPinchGesturePrivate() - : totalChangeFlags(0), changeFlags(0), + : totalChangeFlags(nullptr), changeFlags(nullptr), totalScaleFactor(1), lastScaleFactor(1), scaleFactor(1), totalRotationAngle(0), lastRotationAngle(0), rotationAngle(0), isNewSequence(true) diff --git a/src/widgets/kernel/qlayout_p.h b/src/widgets/kernel/qlayout_p.h index 8a1b12a6be..8e1d773355 100644 --- a/src/widgets/kernel/qlayout_p.h +++ b/src/widgets/kernel/qlayout_p.h @@ -80,7 +80,7 @@ public: static QWidgetItem *createWidgetItem(const QLayout *layout, QWidget *widget); static QSpacerItem *createSpacerItem(const QLayout *layout, int w, int h, QSizePolicy::Policy hPolicy = QSizePolicy::Minimum, QSizePolicy::Policy vPolicy = QSizePolicy::Minimum); - virtual QLayoutItem* replaceAt(int index, QLayoutItem *newitem) { Q_UNUSED(index); Q_UNUSED(newitem); return 0; } + virtual QLayoutItem* replaceAt(int index, QLayoutItem *newitem) { Q_UNUSED(index); Q_UNUSED(newitem); return nullptr; } static QWidgetItemFactoryMethod widgetItemFactoryMethod; static QSpacerItemFactoryMethod spacerItemFactoryMethod; diff --git a/src/widgets/kernel/qlayoutengine_p.h b/src/widgets/kernel/qlayoutengine_p.h index 812fa7cf3b..948c2424e6 100644 --- a/src/widgets/kernel/qlayoutengine_p.h +++ b/src/widgets/kernel/qlayoutengine_p.h @@ -105,9 +105,9 @@ Q_WIDGETS_EXPORT QSize qSmartMinSize(const QWidgetItem *i); Q_WIDGETS_EXPORT QSize qSmartMinSize(const QWidget *w); Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QSize &sizeHint, const QSize &minSize, const QSize &maxSize, - const QSizePolicy &sizePolicy, Qt::Alignment align = 0); -Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QWidgetItem *i, Qt::Alignment align = 0); -Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QWidget *w, Qt::Alignment align = 0); + const QSizePolicy &sizePolicy, Qt::Alignment align = nullptr); +Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QWidgetItem *i, Qt::Alignment align = nullptr); +Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QWidget *w, Qt::Alignment align = nullptr); Q_WIDGETS_EXPORT int qSmartSpacing(const QLayout *layout, QStyle::PixelMetric pm); diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index 797963b931..90c4c2a945 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -146,7 +146,7 @@ public: inline operator bool() const { - return (0 != m_ptr); + return (nullptr != m_ptr); } private: @@ -411,7 +411,7 @@ public: void render(QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags); void drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags, - QPainter *sharedPainter = 0, QWidgetBackingStore *backingStore = 0); + QPainter *sharedPainter = nullptr, QWidgetBackingStore *backingStore = nullptr); void sendPaintEvent(const QRegion &toBePainted); @@ -428,7 +428,7 @@ public: QRegion clipRegion() const; void setSystemClip(QPaintEngine *paintEngine, qreal devicePixelRatio, const QRegion ®ion); void subtractOpaqueChildren(QRegion &rgn, const QRect &clipRect) const; - void subtractOpaqueSiblings(QRegion &source, bool *hasDirtySiblingsAbove = 0, + void subtractOpaqueSiblings(QRegion &source, bool *hasDirtySiblingsAbove = nullptr, bool alsoNonOpaque = false) const; void clipToEffectiveMask(QRegion ®ion) const; void updateIsOpaque(); @@ -525,7 +525,7 @@ public: void getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const; void setLayoutItemMargins(int left, int top, int right, int bottom); - void setLayoutItemMargins(QStyle::SubElement element, const QStyleOption *opt = 0); + void setLayoutItemMargins(QStyle::SubElement element, const QStyleOption *opt = nullptr); void updateContentsRect(); QMargins safeAreaMargins() const; @@ -555,7 +555,7 @@ public: QGraphicsProxyWidget *ancestorProxy = widget->d_func()->nearestGraphicsProxyWidget(widget); //It's embedded if it has an ancestor if (ancestorProxy) { - if (!bypassGraphicsProxyWidget(widget) && ancestorProxy->scene() != 0) { + if (!bypassGraphicsProxyWidget(widget) && ancestorProxy->scene() != nullptr) { // One view, let be smart and return the viewport rect then the popup is aligned if (ancestorProxy->scene()->views().size() == 1) { QGraphicsView *view = ancestorProxy->scene()->views().at(0); @@ -586,7 +586,7 @@ public: } inline void restoreRedirected() - { redirectDev = 0; } + { redirectDev = nullptr; } inline void enforceNativeChildren() { @@ -652,7 +652,7 @@ public: QOpenGLContext *shareContext() const; - virtual QObject *focusObject() { return 0; } + virtual QObject *focusObject() { return nullptr; } #ifndef QT_NO_OPENGL virtual GLuint textureId() const { return 0; } @@ -660,7 +660,7 @@ public: Q_Q(QWidget); return q->testAttribute(Qt::WA_AlwaysStackOnTop) ? QPlatformTextureList::StacksOnTop - : QPlatformTextureList::Flags(0); + : QPlatformTextureList::Flags(nullptr); } virtual QImage grabFramebuffer() { return QImage(); } virtual void beginBackingStorePainting() { } @@ -904,7 +904,7 @@ struct QWidgetPaintContext { inline QWidgetPaintContext(QPaintDevice *d, const QRegion &r, const QPoint &o, int f, QPainter *p, QWidgetBackingStore *b) - : pdev(d), rgn(r), offset(o), flags(f), sharedPainter(p), backingStore(b), painter(0) {} + : pdev(d), rgn(r), offset(o), flags(f), sharedPainter(p), backingStore(b), painter(nullptr) {} QPaintDevice *pdev; QRegion rgn; @@ -920,14 +920,14 @@ class QWidgetEffectSourcePrivate : public QGraphicsEffectSourcePrivate { public: QWidgetEffectSourcePrivate(QWidget *widget) - : QGraphicsEffectSourcePrivate(), m_widget(widget), context(0), updateDueToGraphicsEffect(false) + : QGraphicsEffectSourcePrivate(), m_widget(widget), context(nullptr), updateDueToGraphicsEffect(false) {} void detach() override - { m_widget->d_func()->graphicsEffect = 0; } + { m_widget->d_func()->graphicsEffect = nullptr; } const QGraphicsItem *graphicsItem() const override - { return 0; } + { return nullptr; } const QWidget *widget() const override { return m_widget; } @@ -953,7 +953,7 @@ public: } const QStyleOption *styleOption() const override - { return 0; } + { return nullptr; } QRect deviceRect() const override { return m_widget->window()->rect(); } @@ -983,14 +983,14 @@ inline QTLWExtra *QWidgetPrivate::topData() const inline QTLWExtra *QWidgetPrivate::maybeTopData() const { - return extra ? extra->topextra : 0; + return extra ? extra->topextra : nullptr; } inline QPainter *QWidgetPrivate::sharedPainter() const { Q_Q(const QWidget); QTLWExtra *x = q->window()->d_func()->maybeTopData(); - return x ? x->sharedPainter : 0; + return x ? x->sharedPainter : nullptr; } inline void QWidgetPrivate::setSharedPainter(QPainter *painter) @@ -1011,7 +1011,7 @@ inline QWidgetBackingStore *QWidgetPrivate::maybeBackingStore() const { Q_Q(const QWidget); QTLWExtra *x = q->window()->d_func()->maybeTopData(); - return x ? x->backingStoreTracker.data() : 0; + return x ? x->backingStoreTracker.data() : nullptr; } inline QWidgetWindow *QWidgetPrivate::windowHandle() const diff --git a/src/widgets/kernel/qwidgetbackingstore_p.h b/src/widgets/kernel/qwidgetbackingstore_p.h index e7a2bca33a..9409ba7832 100644 --- a/src/widgets/kernel/qwidgetbackingstore_p.h +++ b/src/widgets/kernel/qwidgetbackingstore_p.h @@ -109,7 +109,7 @@ public: void sync(QWidget *exposedWidget, const QRegion &exposedRegion); void sync(); - void flush(QWidget *widget = 0); + void flush(QWidget *widget = nullptr); QBackingStore *backingStore() const { return store; } @@ -154,8 +154,8 @@ private: BeginPaintInfo *returnInfo, bool toCleanIsInTopLevelCoordinates = true); void endPaint(const QRegion &cleaned, QBackingStore *backingStore, BeginPaintInfo *beginPaintInfo); - QRegion dirtyRegion(QWidget *widget = 0) const; - QRegion staticContents(QWidget *widget = 0, const QRect &withinClipRect = QRect()) const; + QRegion dirtyRegion(QWidget *widget = nullptr) const; + QRegion staticContents(QWidget *widget = nullptr, const QRect &withinClipRect = QRect()) const; void markDirtyOnScreen(const QRegion &dirtyOnScreen, QWidget *widget, const QPoint &topLevelOffset); diff --git a/src/widgets/kernel/qwindowcontainer_p.h b/src/widgets/kernel/qwindowcontainer_p.h index a8754232a8..c6de168c10 100644 --- a/src/widgets/kernel/qwindowcontainer_p.h +++ b/src/widgets/kernel/qwindowcontainer_p.h @@ -64,7 +64,7 @@ class Q_WIDGETS_EXPORT QWindowContainer : public QWidget Q_DECLARE_PRIVATE(QWindowContainer) public: - explicit QWindowContainer(QWindow *embeddedWindow, QWidget *parent = 0, Qt::WindowFlags f = 0); + explicit QWindowContainer(QWindow *embeddedWindow, QWidget *parent = nullptr, Qt::WindowFlags f = nullptr); ~QWindowContainer(); QWindow *containedWindow() const; diff --git a/src/widgets/statemachine/qbasickeyeventtransition_p.h b/src/widgets/statemachine/qbasickeyeventtransition_p.h index 7e1b978bba..f23c078570 100644 --- a/src/widgets/statemachine/qbasickeyeventtransition_p.h +++ b/src/widgets/statemachine/qbasickeyeventtransition_p.h @@ -63,11 +63,11 @@ class Q_AUTOTEST_EXPORT QBasicKeyEventTransition : public QAbstractTransition { Q_OBJECT public: - QBasicKeyEventTransition(QState *sourceState = 0); - QBasicKeyEventTransition(QEvent::Type type, int key, QState *sourceState = 0); + QBasicKeyEventTransition(QState *sourceState = nullptr); + QBasicKeyEventTransition(QEvent::Type type, int key, QState *sourceState = nullptr); QBasicKeyEventTransition(QEvent::Type type, int key, Qt::KeyboardModifiers modifierMask, - QState *sourceState = 0); + QState *sourceState = nullptr); ~QBasicKeyEventTransition(); QEvent::Type eventType() const; diff --git a/src/widgets/statemachine/qbasicmouseeventtransition_p.h b/src/widgets/statemachine/qbasicmouseeventtransition_p.h index 132e223535..dd619d189c 100644 --- a/src/widgets/statemachine/qbasicmouseeventtransition_p.h +++ b/src/widgets/statemachine/qbasicmouseeventtransition_p.h @@ -65,9 +65,9 @@ class Q_AUTOTEST_EXPORT QBasicMouseEventTransition : public QAbstractTransition { Q_OBJECT public: - QBasicMouseEventTransition(QState *sourceState = 0); + QBasicMouseEventTransition(QState *sourceState = nullptr); QBasicMouseEventTransition(QEvent::Type type, Qt::MouseButton button, - QState *sourceState = 0); + QState *sourceState = nullptr); ~QBasicMouseEventTransition(); QEvent::Type eventType() const; diff --git a/src/widgets/styles/qcommonstyle_p.h b/src/widgets/styles/qcommonstyle_p.h index 296f89ce5f..4860dfe4c9 100644 --- a/src/widgets/styles/qcommonstyle_p.h +++ b/src/widgets/styles/qcommonstyle_p.h @@ -71,7 +71,7 @@ class Q_WIDGETS_EXPORT QCommonStylePrivate : public QStylePrivate public: inline QCommonStylePrivate() : #if QT_CONFIG(itemviews) - cachedOption(0), + cachedOption(nullptr), #endif animationFps(30) { } diff --git a/src/widgets/styles/qfusionstyle_p.h b/src/widgets/styles/qfusionstyle_p.h index e67e792727..cbefe3e1af 100644 --- a/src/widgets/styles/qfusionstyle_p.h +++ b/src/widgets/styles/qfusionstyle_p.h @@ -72,28 +72,28 @@ public: QPalette standardPalette () const override; void drawPrimitive(PrimitiveElement elem, const QStyleOption *option, - QPainter *painter, const QWidget *widget = 0) const override; + QPainter *painter, const QWidget *widget = nullptr) const override; void drawControl(ControlElement ce, const QStyleOption *option, QPainter *painter, const QWidget *widget) const override; - int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const override; + int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const override; void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const override; - QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const override; + QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = nullptr) const override; QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const override; SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, - const QPoint &pt, const QWidget *w = 0) const override; + const QPoint &pt, const QWidget *w = nullptr) const override; QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const override; QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const override; - int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, - QStyleHintReturn *returnData = 0) const override; + int styleHint(StyleHint hint, const QStyleOption *option = nullptr, const QWidget *widget = nullptr, + QStyleHintReturn *returnData = nullptr) const override; QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const override; - QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = 0, - const QWidget *widget = 0) const override; + QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = nullptr, + const QWidget *widget = nullptr) const override; QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, - const QWidget *widget = 0) const override; + const QWidget *widget = nullptr) const override; void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const override; void drawItemText(QPainter *painter, const QRect &rect, diff --git a/src/widgets/styles/qpixmapstyle_p.h b/src/widgets/styles/qpixmapstyle_p.h index 590434d95e..d32631a527 100644 --- a/src/widgets/styles/qpixmapstyle_p.h +++ b/src/widgets/styles/qpixmapstyle_p.h @@ -147,7 +147,7 @@ public: void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const override; void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *option, - QPainter *painter, const QWidget *widget=0) const override; + QPainter *painter, const QWidget *widget=nullptr) const override; QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget = nullptr) const override; diff --git a/src/widgets/styles/qproxystyle_p.h b/src/widgets/styles/qproxystyle_p.h index 2343a03e2a..2321f0fed0 100644 --- a/src/widgets/styles/qproxystyle_p.h +++ b/src/widgets/styles/qproxystyle_p.h @@ -67,7 +67,7 @@ public: void ensureBaseStyle() const; private: QProxyStylePrivate() : - QCommonStylePrivate(), baseStyle(0) {} + QCommonStylePrivate(), baseStyle(nullptr) {} mutable QPointer baseStyle; }; diff --git a/src/widgets/styles/qstyle_p.h b/src/widgets/styles/qstyle_p.h index cdea29f944..d68bbfd03b 100644 --- a/src/widgets/styles/qstyle_p.h +++ b/src/widgets/styles/qstyle_p.h @@ -66,7 +66,7 @@ class QStylePrivate: public QObjectPrivate Q_DECLARE_PUBLIC(QStyle) public: inline QStylePrivate() - : layoutSpacingIndex(-1), proxyStyle(0) {} + : layoutSpacingIndex(-1), proxyStyle(nullptr) {} mutable int layoutSpacingIndex; QStyle *proxyStyle; }; diff --git a/src/widgets/styles/qstylehelper_p.h b/src/widgets/styles/qstylehelper_p.h index d79dfe4288..fe052b8984 100644 --- a/src/widgets/styles/qstylehelper_p.h +++ b/src/widgets/styles/qstylehelper_p.h @@ -89,11 +89,11 @@ namespace QStyleHelper Q_WIDGETS_EXPORT bool isInstanceOf(QObject *obj, QAccessible::Role role); Q_WIDGETS_EXPORT bool hasAncestor(QObject *obj, QAccessible::Role role); #endif - Q_WIDGETS_EXPORT QColor backgroundColor(const QPalette &pal, const QWidget* widget = 0); + Q_WIDGETS_EXPORT QColor backgroundColor(const QPalette &pal, const QWidget* widget = nullptr); enum WidgetSizePolicy { SizeLarge = 0, SizeSmall = 1, SizeMini = 2, SizeDefault = -1 }; - Q_WIDGETS_EXPORT WidgetSizePolicy widgetSizePolicy(const QWidget *w, const QStyleOption *opt = 0); + Q_WIDGETS_EXPORT WidgetSizePolicy widgetSizePolicy(const QWidget *w, const QStyleOption *opt = nullptr); } diff --git a/src/widgets/styles/qstylesheetstyle_p.h b/src/widgets/styles/qstylesheetstyle_p.h index 9c4b87fc32..c5266558af 100644 --- a/src/widgets/styles/qstylesheetstyle_p.h +++ b/src/widgets/styles/qstylesheetstyle_p.h @@ -82,40 +82,40 @@ public: ~QStyleSheetStyle(); void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, - const QWidget *w = 0) const override; + const QWidget *w = nullptr) const override; void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, - const QWidget *w = 0) const override; + const QWidget *w = nullptr) const override; void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const override; void drawItemText(QPainter *painter, const QRect& rect, int alignment, const QPalette &pal, bool enabled, const QString& text, QPalette::ColorRole textRole = QPalette::NoRole) const override; void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, - const QWidget *w = 0) const override; + const QWidget *w = nullptr) const override; QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *option) const override; SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, - const QPoint &pt, const QWidget *w = 0) const override; + const QPoint &pt, const QWidget *w = nullptr) const override; QRect itemPixmapRect(const QRect &rect, int alignment, const QPixmap &pixmap) const override; QRect itemTextRect(const QFontMetrics &metrics, const QRect &rect, int alignment, bool enabled, const QString &text) const override; - int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const override; + int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const override; void polish(QWidget *widget) override; void polish(QApplication *app) override; void polish(QPalette &pal) override; QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, - const QSize &contentsSize, const QWidget *widget = 0) const override; + const QSize &contentsSize, const QWidget *widget = nullptr) const override; QPalette standardPalette() const override; - QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *opt = 0, - const QWidget *widget = 0) const override; - QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option = 0, - const QWidget *w = 0 ) const override; + QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *opt = nullptr, + const QWidget *widget = nullptr) const override; + QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option = nullptr, + const QWidget *w = nullptr ) const override; int layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, - Qt::Orientation orientation, const QStyleOption *option = 0, - const QWidget *widget = 0) const override; - int styleHint(StyleHint sh, const QStyleOption *opt = 0, const QWidget *w = 0, - QStyleHintReturn *shret = 0) const override; - QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const override; + Qt::Orientation orientation, const QStyleOption *option = nullptr, + const QWidget *widget = nullptr) const override; + int styleHint(StyleHint sh, const QStyleOption *opt = nullptr, const QWidget *w = nullptr, + QStyleHintReturn *shret = nullptr) const override; + QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = nullptr) const override; QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, - const QWidget *w = 0) const override; + const QWidget *w = nullptr) const override; // These functions are called from QApplication/QWidget. Be careful. QStyle *baseStyle() const; diff --git a/src/widgets/styles/qwindowsstyle_p.h b/src/widgets/styles/qwindowsstyle_p.h index 47816ff651..b5f0bd68a1 100644 --- a/src/widgets/styles/qwindowsstyle_p.h +++ b/src/widgets/styles/qwindowsstyle_p.h @@ -77,25 +77,25 @@ public: void polish(QPalette &) override; void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, - const QWidget *w = 0) const override; + const QWidget *w = nullptr) const override; void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, - const QWidget *w = 0) const override; - QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const override; + const QWidget *w = nullptr) const override; + QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = nullptr) const override; void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, - const QWidget *w = 0) const override; + const QWidget *w = nullptr) const override; QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, - const QSize &contentsSize, const QWidget *widget = 0) const override; + const QSize &contentsSize, const QWidget *widget = nullptr) const override; - int pixelMetric(PixelMetric pm, const QStyleOption *option = 0, const QWidget *widget = 0) const override; + int pixelMetric(PixelMetric pm, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const override; - int styleHint(StyleHint hint, const QStyleOption *opt = 0, const QWidget *widget = 0, - QStyleHintReturn *returnData = 0) const override; + int styleHint(StyleHint hint, const QStyleOption *opt = nullptr, const QWidget *widget = nullptr, + QStyleHintReturn *returnData = nullptr) const override; QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, - const QWidget *widget = 0) const override; + const QWidget *widget = nullptr) const override; - QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = 0, - const QWidget *widget = 0) const override; + QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = nullptr, + const QWidget *widget = nullptr) const override; protected: bool eventFilter(QObject *o, QEvent *e) override; diff --git a/src/widgets/styles/qwindowsstyle_p_p.h b/src/widgets/styles/qwindowsstyle_p_p.h index 67fa6a2f86..e6ea809f11 100644 --- a/src/widgets/styles/qwindowsstyle_p_p.h +++ b/src/widgets/styles/qwindowsstyle_p_p.h @@ -69,9 +69,9 @@ public: enum { InvalidMetric = -23576 }; QWindowsStylePrivate(); - static int pixelMetricFromSystemDp(QStyle::PixelMetric pm, const QStyleOption *option = 0, const QWidget *widget = 0); + static int pixelMetricFromSystemDp(QStyle::PixelMetric pm, const QStyleOption *option = nullptr, const QWidget *widget = nullptr); static int fixedPixelMetric(QStyle::PixelMetric pm); - static qreal devicePixelRatio(const QWidget *widget = 0) + static qreal devicePixelRatio(const QWidget *widget = nullptr) { return widget ? widget->devicePixelRatioF() : QWindowsStylePrivate::appDevicePixelRatio(); } static qreal nativeMetricScaleFactor(const QWidget *widget = nullptr); diff --git a/src/widgets/util/qcompleter_p.h b/src/widgets/util/qcompleter_p.h index 21dddf446e..a52e63a6e2 100644 --- a/src/widgets/util/qcompleter_p.h +++ b/src/widgets/util/qcompleter_p.h @@ -75,7 +75,7 @@ class QCompleterPrivate : public QObjectPrivate public: QCompleterPrivate(); ~QCompleterPrivate() { delete popup; } - void init(QAbstractItemModel *model = 0); + void init(QAbstractItemModel *model = nullptr); QPointer widget; QCompletionModel *proxy; diff --git a/src/widgets/util/qflickgesture_p.h b/src/widgets/util/qflickgesture_p.h index d5ace887ae..0b47516047 100644 --- a/src/widgets/util/qflickgesture_p.h +++ b/src/widgets/util/qflickgesture_p.h @@ -71,7 +71,7 @@ class Q_WIDGETS_EXPORT QFlickGesture : public QGesture Q_DECLARE_PRIVATE(QFlickGesture) public: - QFlickGesture(QObject *receiver, Qt::MouseButton button, QObject *parent = 0); + QFlickGesture(QObject *receiver, Qt::MouseButton button, QObject *parent = nullptr); ~QFlickGesture(); friend class QFlickGestureRecognizer; diff --git a/src/widgets/util/qundostack_p.h b/src/widgets/util/qundostack_p.h index 04bc381114..05c9e0d27e 100644 --- a/src/widgets/util/qundostack_p.h +++ b/src/widgets/util/qundostack_p.h @@ -80,7 +80,7 @@ class QUndoStackPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QUndoStack) public: - QUndoStackPrivate() : index(0), clean_index(0), group(0), undo_limit(0) {} + QUndoStackPrivate() : index(0), clean_index(0), group(nullptr), undo_limit(0) {} QList command_list; QList macro_stack; @@ -98,7 +98,7 @@ class QUndoAction : public QAction { Q_OBJECT public: - explicit QUndoAction(const QString &prefix, QObject *parent = 0); + explicit QUndoAction(const QString &prefix, QObject *parent = nullptr); void setTextFormat(const QString &textFormat, const QString &defaultText); public Q_SLOTS: void setPrefixedText(const QString &text); diff --git a/src/widgets/widgets/qabstractslider_p.h b/src/widgets/widgets/qabstractslider_p.h index 419ce2ba07..1b8c76c7ec 100644 --- a/src/widgets/widgets/qabstractslider_p.h +++ b/src/widgets/widgets/qabstractslider_p.h @@ -134,7 +134,7 @@ public: inline void setAdjustedSliderPosition(int position) { Q_Q(QAbstractSlider); - if (q->style()->styleHint(QStyle::SH_Slider_StopMouseOverSlider, 0, q)) { + if (q->style()->styleHint(QStyle::SH_Slider_StopMouseOverSlider, nullptr, q)) { if ((position > pressValue - 2 * pageStep) && (position < pressValue + 2 * pageStep)) { repeatAction = QAbstractSlider::SliderNoAction; q->setSliderPosition(pressValue); diff --git a/src/widgets/widgets/qabstractspinbox_p.h b/src/widgets/widgets/qabstractspinbox_p.h index fce88e43f4..ad169fde19 100644 --- a/src/widgets/widgets/qabstractspinbox_p.h +++ b/src/widgets/widgets/qabstractspinbox_p.h @@ -97,7 +97,7 @@ public: void init(); void reset(); void updateState(bool up, bool fromKeyboard = false); - QString stripped(const QString &text, int *pos = 0) const; + QString stripped(const QString &text, int *pos = nullptr) const; bool specialValue() const; virtual QVariant getZeroVariant() const; virtual void setRange(const QVariant &min, const QVariant &max); diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h index 71404964da..eadb21628f 100644 --- a/src/widgets/widgets/qcombobox_p.h +++ b/src/widgets/widgets/qcombobox_p.h @@ -86,7 +86,7 @@ class QComboBoxListView : public QListView { Q_OBJECT public: - QComboBoxListView(QComboBox *cmb = 0) : combo(cmb) {} + QComboBoxListView(QComboBox *cmb = nullptr) : combo(cmb) {} protected: void resizeEvent(QResizeEvent *event) override @@ -331,7 +331,7 @@ protected: QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override { if (isSeparator(index)) { - int pm = mCombo->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, mCombo); + int pm = mCombo->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, nullptr, mCombo); return QSize(pm, pm); } return QItemDelegate::sizeHint(option, index); diff --git a/src/widgets/widgets/qdatetimeedit_p.h b/src/widgets/widgets/qdatetimeedit_p.h index 1ebc98dedf..c05e7d9b48 100644 --- a/src/widgets/widgets/qdatetimeedit_p.h +++ b/src/widgets/widgets/qdatetimeedit_p.h @@ -123,7 +123,7 @@ public: static QDateTimeEdit::Sections convertSections(QDateTimeParser::Sections s); static QDateTimeEdit::Section convertToPublic(QDateTimeParser::Section s); - void initCalendarPopup(QCalendarWidget *cw = 0); + void initCalendarPopup(QCalendarWidget *cw = nullptr); void positionCalendarPopup(); QDateTimeEdit::Sections sections; @@ -145,7 +145,7 @@ class QCalendarPopup : public QWidget { Q_OBJECT public: - explicit QCalendarPopup(QWidget *parent = 0, QCalendarWidget *cw = 0); + explicit QCalendarPopup(QWidget *parent = nullptr, QCalendarWidget *cw = nullptr); QDate selectedDate() { return verifyCalendarInstance()->selectedDate(); } void setDate(const QDate &date); void setDateRange(const QDate &min, const QDate &max); diff --git a/src/widgets/widgets/qdockarealayout_p.h b/src/widgets/widgets/qdockarealayout_p.h index 49bd157179..ab9c0c476c 100644 --- a/src/widgets/widgets/qdockarealayout_p.h +++ b/src/widgets/widgets/qdockarealayout_p.h @@ -89,7 +89,7 @@ struct QDockAreaLayoutItem { enum ItemFlags { NoFlags = 0, GapItem = 1, KeepSize = 2 }; - explicit QDockAreaLayoutItem(QLayoutItem *_widgetItem = 0); + explicit QDockAreaLayoutItem(QLayoutItem *_widgetItem = nullptr); explicit QDockAreaLayoutItem(QDockAreaLayoutInfo *_subinfo); explicit QDockAreaLayoutItem(QPlaceHolderItem *_placeHolderItem); QDockAreaLayoutItem(const QDockAreaLayoutItem &other); diff --git a/src/widgets/widgets/qdockwidget_p.h b/src/widgets/widgets/qdockwidget_p.h index 14d73e815f..2543f10f97 100644 --- a/src/widgets/widgets/qdockwidget_p.h +++ b/src/widgets/widgets/qdockwidget_p.h @@ -82,11 +82,11 @@ class QDockWidgetPrivate : public QWidgetPrivate public: inline QDockWidgetPrivate() - : QWidgetPrivate(), state(0), + : QWidgetPrivate(), state(nullptr), features(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable), - allowedAreas(Qt::AllDockWidgetAreas), resizer(0) + allowedAreas(Qt::AllDockWidgetAreas), resizer(nullptr) { } void init(); @@ -136,7 +136,7 @@ class Q_WIDGETS_EXPORT QDockWidgetLayout : public QLayout { Q_OBJECT public: - QDockWidgetLayout(QWidget *parent = 0); + QDockWidgetLayout(QWidget *parent = nullptr); ~QDockWidgetLayout(); void addItem(QLayoutItem *item) override; QLayoutItem *itemAt(int index) const override; @@ -194,15 +194,15 @@ inline QLayoutItem *QDockWidgetItem::dockWidgetChildItem() const { if (QDockWidgetLayout *layout = dockWidgetLayout()) return layout->itemForRole(QDockWidgetLayout::Content); - return 0; + return nullptr; } inline QDockWidgetLayout *QDockWidgetItem::dockWidgetLayout() const { QWidget *w = const_cast(this)->widget(); - if (w != 0) + if (w != nullptr) return qobject_cast(w->layout()); - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h index dce5bf605a..3f98aab901 100644 --- a/src/widgets/widgets/qlineedit_p.h +++ b/src/widgets/widgets/qlineedit_p.h @@ -85,7 +85,7 @@ class Q_AUTOTEST_EXPORT QLineEditIconButton : public QToolButton Q_OBJECT Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity) public: - explicit QLineEditIconButton(QWidget *parent = 0); + explicit QLineEditIconButton(QWidget *parent = nullptr); qreal opacity() const { return m_opacity; } void setOpacity(qreal value); @@ -134,7 +134,7 @@ public: }; struct SideWidgetEntry { - explicit SideWidgetEntry(QWidget *w = 0, QAction *a = 0, int _flags = 0) : widget(w), action(a), flags(_flags) {} + explicit SideWidgetEntry(QWidget *w = nullptr, QAction *a = nullptr, int _flags = 0) : widget(w), action(a), flags(_flags) {} QWidget *widget; QAction *action; diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h index a375d856bb..7cdb8ead2f 100644 --- a/src/widgets/widgets/qmainwindowlayout_p.h +++ b/src/widgets/widgets/qmainwindowlayout_p.h @@ -122,7 +122,7 @@ template QCursor QMainWindowLayoutSeparatorHelper::separatorCursor(const QList &path) { const QDockAreaLayoutInfo *info = layout()->dockAreaLayoutInfo()->info(path); - Q_ASSERT(info != 0); + Q_ASSERT(info != nullptr); if (path.size() == 1) { // is this the "top-level" separator which separates a dock area // from the central widget? switch (path.first()) { @@ -334,7 +334,7 @@ class QDockWidgetGroupWindow : public QWidget { Q_OBJECT public: - explicit QDockWidgetGroupWindow(QWidget* parent = 0, Qt::WindowFlags f = 0) + explicit QDockWidgetGroupWindow(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr) : QWidget(parent, f) {} QDockAreaLayoutInfo *layoutInfo() const; const QDockAreaLayoutInfo *tabLayoutInfo() const; @@ -430,7 +430,7 @@ public: bool isValid() const; QLayoutItem *plug(const QList &path); - QLayoutItem *unplug(const QList &path, QMainWindowLayoutState *savedState = 0); + QLayoutItem *unplug(const QList &path, QMainWindowLayoutState *savedState = nullptr); void saveState(QDataStream &stream) const; bool checkFormat(QDataStream &stream); diff --git a/src/widgets/widgets/qmdiarea_p.h b/src/widgets/widgets/qmdiarea_p.h index fd00118ec6..0a6368044a 100644 --- a/src/widgets/widgets/qmdiarea_p.h +++ b/src/widgets/widgets/qmdiarea_p.h @@ -183,7 +183,7 @@ public: int tabToPreviousTimerId; // Slots. - void _q_deactivateAllWindows(QMdiSubWindow *aboutToActivate = 0); + void _q_deactivateAllWindows(QMdiSubWindow *aboutToActivate = nullptr); void _q_processWindowStateChanged(Qt::WindowStates oldState, Qt::WindowStates newState); void _q_currentTabChanged(int index); void _q_closeTab(int index); @@ -198,7 +198,7 @@ public: void activateCurrentWindow(); void activateHighlightedWindow(); void emitWindowActivated(QMdiSubWindow *child); - void resetActiveWindow(QMdiSubWindow *child = 0); + void resetActiveWindow(QMdiSubWindow *child = nullptr); void updateActiveWindow(int removedIndex, bool activeRemoved); void updateScrollBars(); void internalRaise(QMdiSubWindow *child) const; diff --git a/src/widgets/widgets/qmdisubwindow_p.h b/src/widgets/widgets/qmdisubwindow_p.h index 719984c8d4..d3513b6708 100644 --- a/src/widgets/widgets/qmdisubwindow_p.h +++ b/src/widgets/widgets/qmdisubwindow_p.h @@ -78,7 +78,7 @@ template class ControlElement : public T { public: - ControlElement(QMdiSubWindow *child) : T(child, 0) + ControlElement(QMdiSubWindow *child) : T(child, nullptr) { Q_ASSERT(child); mdiChild = child; @@ -88,7 +88,7 @@ public: { if (classname && strcmp(classname, "ControlElement") == 0) return this; - return 0; + return nullptr; } QPointer mdiChild; @@ -102,7 +102,7 @@ public: #if QT_CONFIG(menubar) void showButtonsInMenuBar(QMenuBar *menuBar); - void removeButtonsFromMenuBar(QMenuBar *menuBar = 0); + void removeButtonsFromMenuBar(QMenuBar *menuBar = nullptr); QMenuBar *menuBar() const { return m_menuBar; } #endif void updateWindowIcon(const QIcon &windowIcon); @@ -331,7 +331,7 @@ public: inline bool autoRaise() const { Q_Q(const QMdiSubWindow); - return q->style()->styleHint(QStyle::SH_TitleBar_AutoRaise, 0, q); + return q->style()->styleHint(QStyle::SH_TitleBar_AutoRaise, nullptr, q); } inline bool isResizeOperation() const diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h index 12521e7a36..0fd0f9219c 100644 --- a/src/widgets/widgets/qmenu_p.h +++ b/src/widgets/widgets/qmenu_p.h @@ -135,9 +135,9 @@ public: void initialize(QMenu *menu) { m_menu = menu; - m_uni_directional = menu->style()->styleHint(QStyle::SH_Menu_SubMenuUniDirection, 0, menu); - m_uni_dir_fail_at_count = short(menu->style()->styleHint(QStyle::SH_Menu_SubMenuUniDirectionFailCount, 0, menu)); - m_select_other_actions = menu->style()->styleHint(QStyle::SH_Menu_SubMenuSloppySelectOtherActions, 0 , menu); + m_uni_directional = menu->style()->styleHint(QStyle::SH_Menu_SubMenuUniDirection, nullptr, menu); + m_uni_dir_fail_at_count = short(menu->style()->styleHint(QStyle::SH_Menu_SubMenuUniDirectionFailCount, nullptr, menu)); + m_select_other_actions = menu->style()->styleHint(QStyle::SH_Menu_SubMenuSloppySelectOtherActions, nullptr , menu); m_timeout = short(menu->style()->styleHint(QStyle::SH_Menu_SubMenuSloppyCloseTimeout)); m_discard_state_when_entering_parent = menu->style()->styleHint(QStyle::SH_Menu_SubMenuResetWhenReenteringParent); m_dont_start_time_on_leave = menu->style()->styleHint(QStyle::SH_Menu_SubMenuDontStartSloppyOnLeave); @@ -377,7 +377,7 @@ public: } void stop() { - action = 0; + action = nullptr; timer.stop(); } diff --git a/src/widgets/widgets/qmenubar_p.h b/src/widgets/widgets/qmenubar_p.h index c276a4512d..e3db16d190 100644 --- a/src/widgets/widgets/qmenubar_p.h +++ b/src/widgets/widgets/qmenubar_p.h @@ -65,9 +65,9 @@ class QMenuBarPrivate : public QWidgetPrivate { Q_DECLARE_PUBLIC(QMenuBar) public: - QMenuBarPrivate() : itemsDirty(0), currentAction(0), mouseDown(0), + QMenuBarPrivate() : itemsDirty(0), currentAction(nullptr), mouseDown(0), closePopupMode(0), defaultPopDown(1), popupState(0), keyboardState(0), altPressed(0), - doChildEffects(false), platformMenuBar(0) + doChildEffects(false), platformMenuBar(nullptr) { } ~QMenuBarPrivate() diff --git a/src/widgets/widgets/qscrollarea_p.h b/src/widgets/widgets/qscrollarea_p.h index fa2e0241cf..2bdf9ed596 100644 --- a/src/widgets/widgets/qscrollarea_p.h +++ b/src/widgets/widgets/qscrollarea_p.h @@ -65,7 +65,7 @@ class QScrollAreaPrivate: public QAbstractScrollAreaPrivate Q_DECLARE_PUBLIC(QScrollArea) public: - QScrollAreaPrivate(): resizable(false), alignment(0){} + QScrollAreaPrivate(): resizable(false), alignment(nullptr){} void updateScrollBars(); void updateWidgetPosition(); QPointer widget; diff --git a/src/widgets/widgets/qsplitter_p.h b/src/widgets/widgets/qsplitter_p.h index f0d621004f..871406a51d 100644 --- a/src/widgets/widgets/qsplitter_p.h +++ b/src/widgets/widgets/qsplitter_p.h @@ -70,7 +70,7 @@ public: QWidget *widget; QSplitterHandle *handle; - QSplitterLayoutStruct() : sizer(-1), collapsed(false), collapsible(Default), widget(0), handle(0) {} + QSplitterLayoutStruct() : sizer(-1), collapsed(false), collapsible(Default), widget(nullptr), handle(nullptr) {} ~QSplitterLayoutStruct() { delete handle; } int getWidgetSize(Qt::Orientation orient); int getHandleSize(Qt::Orientation orient); @@ -84,7 +84,7 @@ class QSplitterPrivate : public QFramePrivate public: QSplitterPrivate() : #if QT_CONFIG(rubberband) - rubberBand(0), + rubberBand(nullptr), #endif opaque(true), firstShow(true), childrenCollapsible(true), compatMode(false), handleWidth(-1), blockChildAdd(false), opaqueResizeSet(false) {} @@ -140,7 +140,7 @@ class QSplitterHandlePrivate : public QWidgetPrivate { Q_DECLARE_PUBLIC(QSplitterHandle) public: - QSplitterHandlePrivate() : s(0), orient(Qt::Horizontal), mouseOffset(0), opaq(false), hover(false), pressed(false) {} + QSplitterHandlePrivate() : s(nullptr), orient(Qt::Horizontal), mouseOffset(0), opaq(false), hover(false), pressed(false) {} inline int pick(const QPoint &pos) const { return orient == Qt::Horizontal ? pos.x() : pos.y(); } diff --git a/src/widgets/widgets/qtabbar_p.h b/src/widgets/widgets/qtabbar_p.h index 9b798e89c9..458d486b10 100644 --- a/src/widgets/widgets/qtabbar_p.h +++ b/src/widgets/widgets/qtabbar_p.h @@ -92,7 +92,7 @@ public: drawBase(true), scrollOffset(0), hoverIndex(-1), elideModeSetByUser(false), useScrollButtonsSetByUser(false), expanding(true), closeButtonOnTabs(false), selectionBehaviorOnRemove(QTabBar::SelectRightTab), paintWithOffsets(true), movable(false), dragInProgress(false), documentMode(false), autoHide(false), changeCurrentOnDrag(false), - switchTabCurrentIndex(-1), switchTabTimerId(0), movingTab(0) + switchTabCurrentIndex(-1), switchTabTimerId(0), movingTab(nullptr) #if 0 // Used to be included in Qt4 for Q_WS_MAC , previousPressedIndex(-1) #endif @@ -182,7 +182,7 @@ public: int indexAtPos(const QPoint &p) const; - inline bool isAnimated() const { Q_Q(const QTabBar); return q->style()->styleHint(QStyle::SH_Widget_Animation_Duration, 0, q) > 0; } + inline bool isAnimated() const { Q_Q(const QTabBar); return q->style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, q) > 0; } inline bool validIndex(int index) const { return index >= 0 && index < tabList.count(); } void setCurrentNextEnabledIndex(int offset); diff --git a/src/widgets/widgets/qtoolbar_p.h b/src/widgets/widgets/qtoolbar_p.h index 4db75762c8..8cb5850903 100644 --- a/src/widgets/widgets/qtoolbar_p.h +++ b/src/widgets/widgets/qtoolbar_p.h @@ -73,7 +73,7 @@ public: : explicitIconSize(false), explicitToolButtonStyle(false), movable(true), floatable(true), allowedAreas(Qt::AllToolBarAreas), orientation(Qt::Horizontal), toolButtonStyle(Qt::ToolButtonIconOnly), - layout(0), state(0) + layout(nullptr), state(nullptr) #ifdef Q_OS_OSX , macWindowDragging(false) #endif diff --git a/src/widgets/widgets/qtoolbararealayout_p.h b/src/widgets/widgets/qtoolbararealayout_p.h index 17747ef29b..5df95a3038 100644 --- a/src/widgets/widgets/qtoolbararealayout_p.h +++ b/src/widgets/widgets/qtoolbararealayout_p.h @@ -69,7 +69,7 @@ class QStyleOptionToolBar; class QToolBarAreaLayoutItem { public: - QToolBarAreaLayoutItem(QLayoutItem *item = 0) + QToolBarAreaLayoutItem(QLayoutItem *item = nullptr) : widgetItem(item), pos(0), size(-1), preferredSize(-1), gap(false) {} bool skip() const; diff --git a/src/widgets/widgets/qtoolbarlayout_p.h b/src/widgets/widgets/qtoolbarlayout_p.h index a788d30450..b5dc121b93 100644 --- a/src/widgets/widgets/qtoolbarlayout_p.h +++ b/src/widgets/widgets/qtoolbarlayout_p.h @@ -79,7 +79,7 @@ class QToolBarLayout : public QLayout Q_OBJECT public: - QToolBarLayout(QWidget *parent = 0); + QToolBarLayout(QWidget *parent = nullptr); ~QToolBarLayout(); void addItem(QLayoutItem *item) override; diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h index f4df95865d..940a17714f 100644 --- a/src/widgets/widgets/qwidgetlinecontrol_p.h +++ b/src/widgets/widgets/qwidgetlinecontrol_p.h @@ -91,7 +91,7 @@ public: m_dragEnabled(0), m_echoMode(0), m_textDirty(0), m_selDirty(0), m_validInput(1), m_blinkStatus(0), m_blinkEnabled(false), m_blinkTimer(0), m_deleteAllTimer(0), m_ascent(0), m_maxLength(32767), m_lastCursorPos(-1), - m_tripleClickTimer(0), m_maskData(0), m_modifiedState(0), m_undoState(0), + m_tripleClickTimer(0), m_maskData(nullptr), m_modifiedState(0), m_undoState(0), m_selstart(0), m_selend(0), m_passwordEchoEditing(false) , m_passwordEchoTimer(0) , m_passwordMaskDelay(-1) @@ -103,7 +103,7 @@ public: , m_passwordMaskDelayOverride(-1) #endif , m_keyboardScheme(0) - , m_accessibleObject(0) + , m_accessibleObject(nullptr) { init(txt); } diff --git a/src/widgets/widgets/qwidgetresizehandler_p.h b/src/widgets/widgets/qwidgetresizehandler_p.h index 89bc759cc2..df3ac7cb8a 100644 --- a/src/widgets/widgets/qwidgetresizehandler_p.h +++ b/src/widgets/widgets/qwidgetresizehandler_p.h @@ -73,7 +73,7 @@ public: Any = Move|Resize }; - explicit QWidgetResizeHandler(QWidget *parent, QWidget *cw = 0); + explicit QWidgetResizeHandler(QWidget *parent, QWidget *cw = nullptr); void setActive(bool b) { setActive(Any, b); } void setActive(Action ac, bool b); bool isActive() const { return isActive(Any); } diff --git a/src/widgets/widgets/qwidgettextcontrol_p.h b/src/widgets/widgets/qwidgettextcontrol_p.h index 202ba36454..9c80d53728 100644 --- a/src/widgets/widgets/qwidgettextcontrol_p.h +++ b/src/widgets/widgets/qwidgettextcontrol_p.h @@ -97,9 +97,9 @@ class Q_WIDGETS_EXPORT QWidgetTextControl : public QInputControl Q_PROPERTY(bool openExternalLinks READ openExternalLinks WRITE setOpenExternalLinks) Q_PROPERTY(bool ignoreUnusedNavigationEvents READ ignoreUnusedNavigationEvents WRITE setIgnoreUnusedNavigationEvents) public: - explicit QWidgetTextControl(QObject *parent = 0); - explicit QWidgetTextControl(const QString &text, QObject *parent = 0); - explicit QWidgetTextControl(QTextDocument *doc, QObject *parent = 0); + explicit QWidgetTextControl(QObject *parent = nullptr); + explicit QWidgetTextControl(const QString &text, QObject *parent = nullptr); + explicit QWidgetTextControl(QTextDocument *doc, QObject *parent = nullptr); virtual ~QWidgetTextControl(); void setDocument(QTextDocument *document); @@ -116,12 +116,12 @@ public: void setCurrentCharFormat(const QTextCharFormat &format); QTextCharFormat currentCharFormat() const; - bool find(const QString &exp, QTextDocument::FindFlags options = 0); + bool find(const QString &exp, QTextDocument::FindFlags options = nullptr); #ifndef QT_NO_REGEXP - bool find(const QRegExp &exp, QTextDocument::FindFlags options = 0); + bool find(const QRegExp &exp, QTextDocument::FindFlags options = nullptr); #endif #if QT_CONFIG(regularexpression) - bool find(const QRegularExpression &exp, QTextDocument::FindFlags options = 0); + bool find(const QRegularExpression &exp, QTextDocument::FindFlags options = nullptr); #endif QString toPlainText() const; @@ -243,11 +243,11 @@ public: QPalette palette() const; void setPalette(const QPalette &pal); - virtual void processEvent(QEvent *e, const QMatrix &matrix, QWidget *contextWidget = 0); - void processEvent(QEvent *e, const QPointF &coordinateOffset = QPointF(), QWidget *contextWidget = 0); + virtual void processEvent(QEvent *e, const QMatrix &matrix, QWidget *contextWidget = nullptr); + void processEvent(QEvent *e, const QPointF &coordinateOffset = QPointF(), QWidget *contextWidget = nullptr); // control methods - void drawContents(QPainter *painter, const QRectF &rect = QRectF(), QWidget *widget = 0); + void drawContents(QPainter *painter, const QRectF &rect = QRectF(), QWidget *widget = nullptr); void setFocus(bool focus, Qt::FocusReason = Qt::OtherFocusReason); diff --git a/src/widgets/widgets/qwidgettextcontrol_p_p.h b/src/widgets/widgets/qwidgettextcontrol_p_p.h index 232dab180f..6a1ee564cd 100644 --- a/src/widgets/widgets/qwidgettextcontrol_p_p.h +++ b/src/widgets/widgets/qwidgettextcontrol_p_p.h @@ -89,9 +89,9 @@ public: void createAutoBulletList(); void init(Qt::TextFormat format = Qt::RichText, const QString &text = QString(), - QTextDocument *document = 0); + QTextDocument *document = nullptr); void setContent(Qt::TextFormat format = Qt::RichText, const QString &text = QString(), - QTextDocument *document = 0); + QTextDocument *document = nullptr); void startDrag(); void paste(const QMimeData *source); From 7111ba173673a950eec70a9e881a4181d714cf0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 5 Mar 2019 17:05:13 +0100 Subject: [PATCH 088/292] Schannel: support for AES-encrypted keys Task-number: QTBUG-54422 Change-Id: I7387cdf9ca927c91cccf3dab7d2deb577ce71802 Reviewed-by: Timur Pocheptsov Reviewed-by: Edward Welbourne --- src/network/ssl/qsslkey_qt.cpp | 5 ++--- src/network/ssl/qsslkey_schannel.cpp | 5 ++++- tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/network/ssl/qsslkey_qt.cpp b/src/network/ssl/qsslkey_qt.cpp index 61251b641b..1b2d9a49aa 100644 --- a/src/network/ssl/qsslkey_qt.cpp +++ b/src/network/ssl/qsslkey_qt.cpp @@ -413,15 +413,14 @@ void QSslKeyPrivate::decodePem(const QByteArray &pem, const QByteArray &passPhra cipher = DesEde3Cbc; } else if (dekInfo.first() == "RC2-CBC") { cipher = Rc2Cbc; -// TODO: Add SChannel version too! -#ifdef QT_SECURETRANSPORT +#if defined(QT_SECURETRANSPORT) || QT_CONFIG(schannel) } else if (dekInfo.first() == "AES-128-CBC") { cipher = Aes128Cbc; } else if (dekInfo.first() == "AES-192-CBC") { cipher = Aes192Cbc; } else if (dekInfo.first() == "AES-256-CBC") { cipher = Aes256Cbc; -#endif // QT_SECURETRANSPORT +#endif // QT_SECURETRANSPORT || schannel } else { clear(deepClear); return; diff --git a/src/network/ssl/qsslkey_schannel.cpp b/src/network/ssl/qsslkey_schannel.cpp index 9dfbc87e9a..1e21d123f4 100644 --- a/src/network/ssl/qsslkey_schannel.cpp +++ b/src/network/ssl/qsslkey_schannel.cpp @@ -57,7 +57,10 @@ const wchar_t *getName(QSslKeyPrivate::Cipher cipher) return BCRYPT_3DES_ALGORITHM; case QSslKeyPrivate::Cipher::Rc2Cbc: return BCRYPT_RC2_ALGORITHM; - default:; + case QSslKeyPrivate::Cipher::Aes128Cbc: + case QSslKeyPrivate::Cipher::Aes192Cbc: + case QSslKeyPrivate::Cipher::Aes256Cbc: + return BCRYPT_AES_ALGORITHM; } Q_UNREACHABLE(); } diff --git a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp index 195f052266..059efae63d 100644 --- a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp +++ b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp @@ -474,7 +474,7 @@ void tst_QSslKey::passphraseChecks_data() QTest::newRow("DES") << QString(testDataDir + "rsa-with-passphrase-des.pem") << pass; QTest::newRow("3DES") << QString(testDataDir + "rsa-with-passphrase-3des.pem") << pass; QTest::newRow("RC2") << QString(testDataDir + "rsa-with-passphrase-rc2.pem") << pass; -#if (!defined(QT_NO_OPENSSL) && !defined(OPENSSL_NO_AES)) || defined(QT_SECURETRANSPORT) +#if (!defined(QT_NO_OPENSSL) && !defined(OPENSSL_NO_AES)) || defined(QT_SECURETRANSPORT) || QT_CONFIG(schannel) QTest::newRow("AES128") << QString(testDataDir + "rsa-with-passphrase-aes128.pem") << aesPass; QTest::newRow("AES192") << QString(testDataDir + "rsa-with-passphrase-aes192.pem") << aesPass; QTest::newRow("AES256") << QString(testDataDir + "rsa-with-passphrase-aes256.pem") << aesPass; From 73a2e9c4098037aaa540b97ff097c660290622da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Fri, 22 Feb 2019 10:16:19 +0100 Subject: [PATCH 089/292] tst_qhostinfo: remove dependency on network test server Change-Id: Ic66a60bfe80d3ec05e9826939e3739bb5549749d Reviewed-by: Thiago Macieira Reviewed-by: Timur Pocheptsov --- tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp index 82825f608c..d85845284a 100644 --- a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp +++ b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp @@ -179,7 +179,6 @@ void tst_QHostInfo::staticInformation() void tst_QHostInfo::initTestCase() { - QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); #ifndef QT_NO_BEARERMANAGEMENT //start the default network netConfMan = new QNetworkConfigurationManager(this); @@ -240,8 +239,6 @@ void tst_QHostInfo::lookupIPv4_data() QTest::addColumn("addresses"); QTest::addColumn("err"); - // Test server lookup - QTest::newRow("lookup_01") << QtNetworkSettings::serverName() << QtNetworkSettings::serverIP().toString() << int(QHostInfo::NoError); QTest::newRow("empty") << "" << "" << int(QHostInfo::HostNotFound); QTest::newRow("single_ip4") << "a-single" TEST_DOMAIN << "192.0.2.1" << int(QHostInfo::NoError); From c0ab2ad98f5c3907be032dc4de938ba5d88e697d Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 22 Feb 2019 17:49:45 +0100 Subject: [PATCH 090/292] Clean up and document the generator for qurltld_p.h This scans the public suffix list and emits suitable content for the header. Made some modest efficiency gains while hopefully making the code easier to understand. Check for success when opening files. Change-Id: If6b25c5c85f86209b33d9188743e820690e7dc05 Reviewed-by: Timur Pocheptsov --- util/corelib/qurl-generateTLDs/main.cpp | 169 ++++++++++++++---------- 1 file changed, 99 insertions(+), 70 deletions(-) diff --git a/util/corelib/qurl-generateTLDs/main.cpp b/util/corelib/qurl-generateTLDs/main.cpp index 7268fb077a..6fde287049 100644 --- a/util/corelib/qurl-generateTLDs/main.cpp +++ b/util/corelib/qurl-generateTLDs/main.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the utils of the Qt Toolkit. @@ -28,33 +28,66 @@ #include +const QString quadQuote = QStringLiteral("\"\""); // Closes one string, opens a new one. + static QString utf8encode(const QByteArray &array) // turns e.g. tranøy.no to tran\xc3\xb8y.no { QString result; result.reserve(array.length() + array.length() / 3); + bool wasHex = false; for (int i = 0; i < array.length(); ++i) { char c = array.at(i); // if char is non-ascii, escape it if (c < 0x20 || uchar(c) >= 0x7f) { result += "\\x" + QString::number(uchar(c), 16); + wasHex = true; } else { // if previous char was escaped, we need to make sure the next char is not // interpreted as part of the hex value, e.g. "äc.com" -> "\xabc.com"; this // should be "\xab""c.com" - QRegExp hexEscape("\\\\x[a-fA-F0-9][a-fA-F0-9]$"); bool isHexChar = ((c >= '0' && c <= '9') || - (c >= 'a' && c <= 'f') || - (c >= 'A' && c <= 'F')); - if (result.contains(hexEscape) && isHexChar) - result += "\"\""; + (c >= 'a' && c <= 'f') || + (c >= 'A' && c <= 'F')); + if (wasHex && isHexChar) + result += quadQuote; result += c; + wasHex = false; } } return result; } -int main(int argc, char **argv) { +/* + Digest public suffix data into efficiently-searchable form. + Takes the public suffix list (see usage message), a list of DNS domains + whose child domains should not be presumed to trust one another, and + converts it to a form that lets qtbase/src/corelib/io/qtldurl.cpp's query + functions find entries efficiently. + + Each line of the suffix file (aside from comments and blanks) gives a suffix + (starting with a dot) with an optional prefix of '*' (to include every + immediate child) or of '!' (to exclude the suffix, e.g. from a '*' line for + a tail of it). A line with neither of these prefixes is an exact match. + + Each line is hashed and the hash is reduced modulo the number of lines + (tldCount); lines are grouped by reduced hash and separated by '\0' bytes + within each group. Conceptually, the groups are then emitted to a single + huge string, along with a table (tldIndices[tldCount]) of indices into that + string of the starts of the the various groups. + + However, that huge string would exceed the 64k limit at least one compiler + imposes on a single string literal, so we actually split up the huge string + into an array of chunks, each less than 64k in size. Each group is written + to a single chunk (so we start a new chunk if the next group would take the + present chunk over the limit). There are tldChunkCount chunks; their lengths + are saved in tldChunks[tldChunkCount]; the chunks themselves in + tldData[tldChunkCount]. See qtldurl.cpp's containsTLDEntry() for how to + search for a string in the resulting data. +*/ + +int main(int argc, char **argv) +{ QCoreApplication app(argc, argv); if (argc < 3) { printf("\nusage: %s inputFile outputFile\n\n", argv[0]); @@ -68,14 +101,20 @@ int main(int argc, char **argv) { exit(1); } QFile file(argv[1]); + if (!file.open(QIODevice::ReadOnly)) { + fprintf("Failed to open input file (%s); see %s -usage", argv[1], argv[0]); + return 1; + } + QFile outFile(argv[2]); - file.open(QIODevice::ReadOnly); - outFile.open(QIODevice::WriteOnly); - - QByteArray outIndicesBufferBA; - QBuffer outIndicesBuffer(&outIndicesBufferBA); - outIndicesBuffer.open(QIODevice::WriteOnly); + if (!outFile.open(QIODevice::WriteOnly)) { + file.close() + fprintf("Failed to open output file (%s); see %s -usage", argv[2], argv[0]); + return 1; + } + // Write tldData[] and tldIndices[] in one scan of the (input) file, but + // buffer tldData[] so we don'te interleave them in the outFile. QByteArray outDataBufferBA; QBuffer outDataBuffer(&outDataBufferBA); outDataBuffer.open(QIODevice::WriteOnly); @@ -85,76 +124,66 @@ int main(int argc, char **argv) { file.readLine(); lineCount++; } + outFile.write("static const quint16 tldCount = "); + outFile.write(QByteArray::number(lineCount)); + outFile.write(";\n"); + file.reset(); QVector strings(lineCount); while (!file.atEnd()) { - QString s = QString::fromUtf8(file.readLine()); - QString st = s.trimmed(); + QString st = QString::fromUtf8(file.readLine()).trimmed(); int num = qt_hash(st) % lineCount; + QString &entry = strings[num]; + st = utf8encode(st.toUtf8()); - QString utf8String = utf8encode(st.toUtf8()); + // For domain 1.com, we could get something like a.com\01.com, which + // would be misinterpreted as octal 01, so we need to separate such + // strings with quotes: + if (!entry.isEmpty() && st.at(0).isDigit()) + entry.append(quadQuote); - // for domain 1.com, we could get something like - // a.com\01.com, which would be interpreted as octal 01, - // so we need to separate those strings with quotes - QRegExp regexpOctalEscape(QLatin1String("^[0-9]")); - if (!strings.at(num).isEmpty() && st.contains(regexpOctalEscape)) - strings[num].append("\"\""); - - strings[num].append(utf8String); - strings[num].append("\\0"); + entry.append(st); + entry.append("\\0"); } - - outIndicesBuffer.write("static const quint16 tldCount = "); - outIndicesBuffer.write(QByteArray::number(lineCount)); - outIndicesBuffer.write(";\n"); - outIndicesBuffer.write("static const quint32 tldIndices["); -// outIndicesBuffer.write(QByteArray::number(lineCount+1)); // not needed - outIndicesBuffer.write("] = {\n"); + outFile.write("static const quint32 tldIndices[] = {\n"); + outDataBuffer.write("\nstatic const char *tldData[] = {\n"); int totalUtf8Size = 0; int chunkSize = 0; // strlen of the current chunk (sizeof is bigger by 1) - int stringUtf8Size = 0; QStringList chunks; for (int a = 0; a < lineCount; a++) { - bool lineIsEmpty = strings.at(a).isEmpty(); - if (!lineIsEmpty) { - strings[a].prepend("\""); - strings[a].append("\""); - } - int zeroCount = strings.at(a).count(QLatin1String("\\0")); - int utf8CharsCount = strings.at(a).count(QLatin1String("\\x")); - int quoteCount = strings.at(a).count('"'); - stringUtf8Size = strings.at(a).count() - (zeroCount + quoteCount + utf8CharsCount * 3); - chunkSize += stringUtf8Size; - // MSVC 2015 chokes if sizeof(a single string) > 0xffff - if (chunkSize >= 0xffff) { - static int chunkCount = 0; - qWarning() << "chunk" << ++chunkCount << "has length" << chunkSize - stringUtf8Size; - outDataBuffer.write(",\n\n"); - chunks.append(QByteArray::number(totalUtf8Size)); - chunkSize = 0; - } - outDataBuffer.write(strings.at(a).toUtf8()); - if (!lineIsEmpty) - outDataBuffer.write("\n"); - outIndicesBuffer.write(QByteArray::number(totalUtf8Size)); - outIndicesBuffer.write(",\n"); - totalUtf8Size += stringUtf8Size; - } - chunks.append(QByteArray::number(totalUtf8Size)); - outIndicesBuffer.write(QByteArray::number(totalUtf8Size)); - outIndicesBuffer.write("};\n"); - outIndicesBuffer.close(); - outFile.write(outIndicesBufferBA); + outFile.write(QByteArray::number(totalUtf8Size)); + outFile.write(",\n"); + const QString &entry = strings.at(a); + if (!entry.isEmpty()) { + const int zeroCount = entry.count(QLatin1String("\\0")); + const int utf8CharsCount = entry.count(QLatin1String("\\x")); + const int quoteCount = entry.count('"'); + const int stringUtf8Size = entry.count() - (zeroCount + quoteCount + utf8CharsCount * 3); + chunkSize += stringUtf8Size; + // MSVC 2015 chokes if sizeof(a single string) > 0xffff + if (chunkSize >= 0xffff) { + static int chunkCount = 0; + qWarning() << "chunk" << ++chunkCount << "has length" << chunkSize - stringUtf8Size; + outDataBuffer.write(",\n\n"); + chunks.append(QString::number(totalUtf8Size)); + chunkSize = 0; + } + totalUtf8Size += stringUtf8Size; - outDataBuffer.close(); - outFile.write("\nstatic const char *tldData["); -// outFile.write(QByteArray::number(charSize)); // not needed - outFile.write("] = {\n"); - outFile.write(outDataBufferBA); + outDataBuffer.write("\""); + outDataBuffer.write(entry.toUtf8()); + outDataBuffer.write("\"\n"); + } + } + chunks.append(QString::number(totalUtf8Size)); + outFile.write(QByteArray::number(totalUtf8Size)); outFile.write("};\n"); + outDataBuffer.write("};\n"); + outDataBuffer.close(); + outFile.write(outDataBufferBA); + // write chunk information outFile.write("\nstatic const quint16 tldChunkCount = "); outFile.write(QByteArray::number(chunks.count())); @@ -162,6 +191,6 @@ int main(int argc, char **argv) { outFile.write(chunks.join(", ").toLatin1()); outFile.write("};\n"); outFile.close(); - printf("data generated to %s . Now copy the data from this file to src/corelib/io/qurltlds_p.h in your Qt repo\n", argv[2]); - exit(0); + printf("Data generated to %s - now revise qtbase/src/corelib/io/qurltlds_p.h to use this data.\n", argv[2]); + return 0; } From 368eb2ecec7cc54ea987de00df7caa52a0d4503a Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 13 Mar 2019 19:30:53 +0100 Subject: [PATCH 091/292] Refine and extend tst_qnumeric's checks on infinity and NaN Renamed the test, since it covers both, verified slightly more and added checks that QCOMPARE() copes as intended. Fixed some minor coding-style defects in the process. Change-Id: I49c2ffa0568a29e9e4b7f7395d4cacdeb0401da0 Reviewed-by: Thiago Macieira --- .../corelib/global/qnumeric/tst_qnumeric.cpp | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp index 03300c6dbe..f37dcbbbba 100644 --- a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp +++ b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp @@ -42,7 +42,7 @@ class tst_QNumeric: public QObject private slots: void fuzzyCompare_data(); void fuzzyCompare(); - void qNan(); + void qNanInf(); void floatDistance_data(); void floatDistance(); void floatDistance_double_data(); @@ -91,7 +91,7 @@ void tst_QNumeric::fuzzyCompare() # pragma GCC optimize "no-fast-math" #endif -void tst_QNumeric::qNan() +void tst_QNumeric::qNanInf() { #if defined __FAST_MATH__ && (__GNUC__ * 100 + __GNUC_MINOR__ < 404) QSKIP("Non-conformant fast math mode is enabled, cannot run test"); @@ -99,9 +99,16 @@ void tst_QNumeric::qNan() double nan = qQNaN(); QVERIFY(!(0 > nan)); QVERIFY(!(0 < nan)); + QVERIFY(!(0 == nan)); + QVERIFY(!(nan == nan)); QVERIFY(qIsNaN(nan)); QVERIFY(qIsNaN(nan + 1)); QVERIFY(qIsNaN(-nan)); + QVERIFY(qIsNaN(1.0 / nan)); + QVERIFY(qIsNaN(0.0 / nan)); + QVERIFY(qIsNaN(0.0 * nan)); + QCOMPARE(nan, nan); + QCOMPARE(nan, -nan); Q_STATIC_ASSERT(sizeof(double) == 8); #ifdef Q_LITTLE_ENDIAN @@ -113,17 +120,27 @@ void tst_QNumeric::qNan() QVERIFY(!qIsFinite(nan)); QVERIFY(!qIsInf(nan)); QVERIFY(qIsNaN(nan)); + QVERIFY(qIsNaN(-nan)); + QVERIFY(!(nan == nan)); + QVERIFY(qIsNaN(0.0 * nan)); + QCOMPARE(nan, nan); + QCOMPARE(nan, -nan); + QCOMPARE(nan, qQNaN()); double inf = qInf(); QVERIFY(inf > 0); QVERIFY(-inf < 0); QVERIFY(qIsInf(inf)); + QCOMPARE(inf, inf); + QCOMPARE(-inf, -inf); QVERIFY(qIsInf(-inf)); - QVERIFY(qIsInf(2*inf)); - QCOMPARE(1/inf, 0.0); - QVERIFY(qIsNaN(0*nan)); - QVERIFY(qIsNaN(0*inf)); - QVERIFY(qFuzzyCompare(1/inf, 0.0)); + QVERIFY(qIsInf(inf + 1)); + QVERIFY(qIsInf(inf - 1)); + QVERIFY(qIsInf(inf * 2.0)); + QVERIFY(qIsInf(inf / 2.0)); + QVERIFY(qFuzzyCompare(1.0 / inf, 0.0)); + QCOMPARE(1.0 / inf, 0.0); + QVERIFY(qIsNaN(0.0 * inf)); } void tst_QNumeric::floatDistance_data() From 84aea6c091d020a37c2b452a6f56ca27b3b2c7cb Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 13 Mar 2019 18:49:04 +0100 Subject: [PATCH 092/292] Add qFpClassify() to mirror std::fpclassify() The rules of std don't permit us to add an overload for fpclassify(qfloat16), so we need our own equivalent that we *can* overload. Deploy it in the few places we use fpclassify(). Extended qnumeric's testing to cover qFpClassify(). Change-Id: Ie5a0a5cc24599d1571404c573d33c682b0d305a5 Reviewed-by: Thiago Macieira Reviewed-by: Paul Wicking --- src/corelib/global/qnumeric.cpp | 25 ++++++++++++++- src/corelib/global/qnumeric.h | 4 ++- src/corelib/global/qnumeric_p.h | 19 ++++++++++- src/corelib/kernel/qvariant.cpp | 6 ++-- src/testlib/qtestcase.cpp | 10 +++--- .../corelib/global/qnumeric/tst_qnumeric.cpp | 32 ++++++++++++++++++- 6 files changed, 84 insertions(+), 12 deletions(-) diff --git a/src/corelib/global/qnumeric.cpp b/src/corelib/global/qnumeric.cpp index fc2b052edf..e6ba62f530 100644 --- a/src/corelib/global/qnumeric.cpp +++ b/src/corelib/global/qnumeric.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -46,6 +46,7 @@ QT_BEGIN_NAMESPACE /*! Returns \c true if the double \a {d} is equivalent to infinity. \relates + \sa qInf() */ Q_CORE_EXPORT bool qIsInf(double d) { return qt_is_inf(d); } @@ -64,6 +65,7 @@ Q_CORE_EXPORT bool qIsFinite(double d) { return qt_is_finite(d); } /*! Returns \c true if the float \a {f} is equivalent to infinity. \relates + \sa qInf() */ Q_CORE_EXPORT bool qIsInf(float f) { return qt_is_inf(f); } @@ -88,15 +90,36 @@ Q_CORE_EXPORT double qSNaN() { return qt_snan(); } /*! Returns the bit pattern of a quiet NaN as a double. \relates + \sa qIsNaN() */ Q_CORE_EXPORT double qQNaN() { return qt_qnan(); } /*! Returns the bit pattern for an infinite number as a double. \relates + \sa qIsInf() */ Q_CORE_EXPORT double qInf() { return qt_inf(); } +/*! + \relates + Classifies a floating-point value. + + The return values are defined in \c{}: returns one of the following, + determined by the floating-point class of \a val: + \list + \li FP_NAN not a number + \li FP_INFINITE infinities (positive or negative) + \li FP_NORMAL finite with a full mantissa + \li FP_SUBNORMAL finite with a reduced mantissa + \endlist +*/ +Q_CORE_EXPORT int qFpClassify(double val) { return qt_fpclassify(val); } + +/*! + \overload +*/ +Q_CORE_EXPORT int qFpClassify(float val) { return qt_fpclassify(val); } /*! diff --git a/src/corelib/global/qnumeric.h b/src/corelib/global/qnumeric.h index 535a96aaec..6a0c64712f 100644 --- a/src/corelib/global/qnumeric.h +++ b/src/corelib/global/qnumeric.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -48,9 +48,11 @@ QT_BEGIN_NAMESPACE Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qIsInf(double d); Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qIsNaN(double d); Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qIsFinite(double d); +Q_CORE_EXPORT Q_DECL_CONST_FUNCTION int qFpClassify(double val); Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qIsInf(float f); Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qIsNaN(float f); Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qIsFinite(float f); +Q_CORE_EXPORT Q_DECL_CONST_FUNCTION int qFpClassify(float val); Q_CORE_EXPORT Q_DECL_CONST_FUNCTION double qSNaN(); Q_CORE_EXPORT Q_DECL_CONST_FUNCTION double qQNaN(); Q_CORE_EXPORT Q_DECL_CONST_FUNCTION double qInf(); diff --git a/src/corelib/global/qnumeric_p.h b/src/corelib/global/qnumeric_p.h index 4a225b2599..56e670c477 100644 --- a/src/corelib/global/qnumeric_p.h +++ b/src/corelib/global/qnumeric_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Copyright (C) 2018 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** @@ -85,9 +85,11 @@ namespace qnumeric_std_wrapper { Q_DECL_CONST_FUNCTION static inline bool math_h_isnan(double d) { using namespace std; return isnan(d); } Q_DECL_CONST_FUNCTION static inline bool math_h_isinf(double d) { using namespace std; return isinf(d); } Q_DECL_CONST_FUNCTION static inline bool math_h_isfinite(double d) { using namespace std; return isfinite(d); } +Q_DECL_CONST_FUNCTION static inline int math_h_fpclassify(double d) { using namespace std; return fpclassify(d); } Q_DECL_CONST_FUNCTION static inline bool math_h_isnan(float f) { using namespace std; return isnan(f); } Q_DECL_CONST_FUNCTION static inline bool math_h_isinf(float f) { using namespace std; return isinf(f); } Q_DECL_CONST_FUNCTION static inline bool math_h_isfinite(float f) { using namespace std; return isfinite(f); } +Q_DECL_CONST_FUNCTION static inline int math_h_fpclassify(float f) { using namespace std; return fpclassify(f); } } QT_END_NAMESPACE // These macros from math.h conflict with the real functions in the std namespace. @@ -95,6 +97,7 @@ QT_END_NAMESPACE # undef isnan # undef isinf # undef isfinite +# undef fpclassify # endif // defined(isnan) #endif @@ -106,16 +109,20 @@ namespace qnumeric_std_wrapper { Q_DECL_CONST_FUNCTION static inline bool isnan(double d) { return math_h_isnan(d); } Q_DECL_CONST_FUNCTION static inline bool isinf(double d) { return math_h_isinf(d); } Q_DECL_CONST_FUNCTION static inline bool isfinite(double d) { return math_h_isfinite(d); } +Q_DECL_CONST_FUNCTION static inline int fpclassify(double d) { return math_h_fpclassify(d); } Q_DECL_CONST_FUNCTION static inline bool isnan(float f) { return math_h_isnan(f); } Q_DECL_CONST_FUNCTION static inline bool isinf(float f) { return math_h_isinf(f); } Q_DECL_CONST_FUNCTION static inline bool isfinite(float f) { return math_h_isfinite(f); } +Q_DECL_CONST_FUNCTION static inline int fpclassify(float f) { return math_h_fpclassify(f); } #else Q_DECL_CONST_FUNCTION static inline bool isnan(double d) { return std::isnan(d); } Q_DECL_CONST_FUNCTION static inline bool isinf(double d) { return std::isinf(d); } Q_DECL_CONST_FUNCTION static inline bool isfinite(double d) { return std::isfinite(d); } +Q_DECL_CONST_FUNCTION static inline int fpclassify(double d) { return std::fpclassify(d); } Q_DECL_CONST_FUNCTION static inline bool isnan(float f) { return std::isnan(f); } Q_DECL_CONST_FUNCTION static inline bool isinf(float f) { return std::isinf(f); } Q_DECL_CONST_FUNCTION static inline bool isfinite(float f) { return std::isfinite(f); } +Q_DECL_CONST_FUNCTION static inline int fpclassify(float f) { return std::fpclassify(f); } #endif } @@ -157,6 +164,11 @@ Q_DECL_CONST_FUNCTION static inline bool qt_is_finite(double d) return qnumeric_std_wrapper::isfinite(d); } +Q_DECL_CONST_FUNCTION static inline int qt_fpclassify(double d) +{ + return qnumeric_std_wrapper::fpclassify(d); +} + Q_DECL_CONST_FUNCTION static inline bool qt_is_inf(float f) { return qnumeric_std_wrapper::isinf(f); @@ -172,6 +184,11 @@ Q_DECL_CONST_FUNCTION static inline bool qt_is_finite(float f) return qnumeric_std_wrapper::isfinite(f); } +Q_DECL_CONST_FUNCTION static inline int qt_fpclassify(float f) +{ + return qnumeric_std_wrapper::fpclassify(f); +} + #ifndef Q_CLANG_QDOC namespace { /*! diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 18c7f7648d..deba977f77 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Copyright (C) 2018 Intel Corporation. ** Copyright (C) 2015 Olivier Goffart ** Contact: https://www.qt.io/licensing/ @@ -4002,8 +4002,8 @@ static int numericCompare(const QVariant::Private *d1, const QVariant::Private * return 0; // only do fuzzy comparisons for finite, non-zero numbers - int c1 = std::fpclassify(r1); - int c2 = std::fpclassify(r2); + int c1 = qFpClassify(r1); + int c2 = qFpClassify(r2); if ((c1 == FP_NORMAL || c1 == FP_SUBNORMAL) && (c2 == FP_NORMAL || c2 == FP_SUBNORMAL)) { if (qFuzzyCompare(r1, r2)) return 0; diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index a010ea467b..d9f8dd7805 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Copyright (C) 2016 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** @@ -2522,12 +2522,12 @@ bool QTest::compare_helper(bool success, const char *failureMsg, template static bool floatingCompare(const T &t1, const T &t2) { - switch (std::fpclassify(t1)) + switch (qFpClassify(t1)) { case FP_INFINITE: - return (t1 < 0) == (t2 < 0) && std::fpclassify(t2) == FP_INFINITE; + return (t1 < 0) == (t2 < 0) && qFpClassify(t2) == FP_INFINITE; case FP_NAN: - return std::fpclassify(t2) == FP_NAN; + return qFpClassify(t2) == FP_NAN; default: return qFuzzyCompare(t1, t2); } @@ -2631,7 +2631,7 @@ static void massageExponent(char *text) template <> Q_TESTLIB_EXPORT char *QTest::toString(const TYPE &t) \ { \ char *msg = new char[128]; \ - switch (std::fpclassify(t)) { \ + switch (qFpClassify(t)) { \ case FP_INFINITE: \ qstrncpy(msg, (t < 0 ? "-inf" : "inf"), 128); \ break; \ diff --git a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp index f37dcbbbba..e567e465f7 100644 --- a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp +++ b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Copyright (C) 2016 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** @@ -43,6 +43,7 @@ private slots: void fuzzyCompare_data(); void fuzzyCompare(); void qNanInf(); + void classifyfp(); void floatDistance_data(); void floatDistance(); void floatDistance_double_data(); @@ -123,6 +124,7 @@ void tst_QNumeric::qNanInf() QVERIFY(qIsNaN(-nan)); QVERIFY(!(nan == nan)); QVERIFY(qIsNaN(0.0 * nan)); + QCOMPARE(qFpClassify(nan), FP_NAN); QCOMPARE(nan, nan); QCOMPARE(nan, -nan); QCOMPARE(nan, qQNaN()); @@ -143,6 +145,34 @@ void tst_QNumeric::qNanInf() QVERIFY(qIsNaN(0.0 * inf)); } +void tst_QNumeric::classifyfp() +{ + QCOMPARE(qFpClassify(qQNaN()), FP_NAN); + + QCOMPARE(qFpClassify(qInf()), FP_INFINITE); + QCOMPARE(qFpClassify(-qInf()), FP_INFINITE); + QCOMPARE(qFpClassify(DBL_MAX * 2.0), FP_INFINITE); + QCOMPARE(qFpClassify(FLT_MAX * 2.f), FP_INFINITE); + QCOMPARE(qFpClassify(DBL_MAX * -2.0), FP_INFINITE); + QCOMPARE(qFpClassify(FLT_MAX * -2.f), FP_INFINITE); + + QCOMPARE(qFpClassify(1.0), FP_NORMAL); + QCOMPARE(qFpClassify(DBL_MAX), FP_NORMAL); + QCOMPARE(qFpClassify(-DBL_MAX), FP_NORMAL); + QCOMPARE(qFpClassify(DBL_MIN), FP_NORMAL); + QCOMPARE(qFpClassify(-DBL_MIN), FP_NORMAL); + QCOMPARE(qFpClassify(DBL_MIN / 2.0), FP_SUBNORMAL); + QCOMPARE(qFpClassify(DBL_MIN / -2.0), FP_SUBNORMAL); + + QCOMPARE(qFpClassify(1.f), FP_NORMAL); + QCOMPARE(qFpClassify(FLT_MAX), FP_NORMAL); + QCOMPARE(qFpClassify(-FLT_MAX), FP_NORMAL); + QCOMPARE(qFpClassify(FLT_MIN), FP_NORMAL); + QCOMPARE(qFpClassify(-FLT_MIN), FP_NORMAL); + QCOMPARE(qFpClassify(FLT_MIN / 2.f), FP_SUBNORMAL); + QCOMPARE(qFpClassify(FLT_MIN / -2.f), FP_SUBNORMAL); +} + void tst_QNumeric::floatDistance_data() { QTest::addColumn("val1"); From 3c4e202fe4ada03473fc29dd36d9c8f9c0c3c6d5 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 18 Mar 2019 18:30:33 +0100 Subject: [PATCH 093/292] Make tst_QTemporaryFile::fileTemplate() more informative on failure A QCOMPARE(..., true) isn't much use; and failure would have set the object's .errorString(), which seems like it'd be worth reporting, so use QVERIFY2() instead. Change-Id: I2f3f9379984694891de81d2ffebc696d91eec70f Reviewed-by: Friedemann Kleint Reviewed-by: Thiago Macieira --- tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp index cf4ab4902d..67d8c55b04 100644 --- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp @@ -215,7 +215,7 @@ void tst_QTemporaryFile::fileTemplate() if (!fileTemplate.isEmpty()) file.setFileTemplate(fileTemplate); - QCOMPARE(file.open(), true); + QVERIFY2(file.open(), qPrintable(file.errorString())); QString fileName = QFileInfo(file).fileName(); if (prefix.length()) From 322b052dd7d12193d028188bb133b4026ff97be4 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 7 Mar 2019 18:18:59 +0100 Subject: [PATCH 094/292] rcc: Avoid raw string literals Subjective, but for me its easier to follow code flow if indentation is not interrupted. Change-Id: If811ba1b975189c94a671627be8eb3a1fd67aeb9 Reviewed-by: Friedemann Kleint --- src/tools/rcc/rcc.cpp | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp index 704c336860..bb4e6e3615 100644 --- a/src/tools/rcc/rcc.cpp +++ b/src/tools/rcc/rcc.cpp @@ -68,17 +68,6 @@ enum { #define writeString(s) write(s, sizeof(s)) -static const char pythonHeader1[] = -R"(# Created by: object code -# Created by: The Resource Compiler for Qt version )"; - -static const char pythonHeader2[] = R"( -# WARNING! All changes made in this file will be lost! - -from PySide2 import QtCore - -)"; - void RCCResourceLibrary::write(const char *str, int len) { --len; // trailing \0 on string literals... @@ -1111,9 +1100,12 @@ bool RCCResourceLibrary::writeHeader() writeString("# Resource object code (Python "); writeChar(m_format == Python3_Code ? '3' : '2'); writeString(")\n"); - writeString(pythonHeader1); + writeString("# Created by: object code\n"); + writeString("# Created by: The Resource Compiler for Qt version "); writeByteArray(QT_VERSION_STR); - writeString(pythonHeader2); + writeString("\n"); + writeString("# WARNING! All changes made in this file will be lost!\n\n"); + writeString("from PySide2 import QtCore\n\n"); break; case Binary: writeString("qres"); @@ -1526,18 +1518,15 @@ bool RCCResourceLibrary::writeInitializer() p[i++] = (m_overallFlags >> 0) & 0xff; } } else if (m_format == Python3_Code || m_format == Python2_Code) { - writeString(R"(def qInitResources(): - QtCore.qRegisterResourceData(0x)"); + writeString("def qInitResources():\n"); + writeString(" QtCore.qRegisterResourceData(0x"); write2HexDigits(m_formatVersion); - writeString(R"(, qt_resource_struct, qt_resource_name, qt_resource_data) - -def qCleanupResources(): - QtCore.qUnregisterResourceData(0x)"); + writeString(", qt_resource_struct, qt_resource_name, qt_resource_data)\n\n"); + writeString("def qCleanupResources():\n"); + writeString(" QtCore.qUnregisterResourceData(0x"); write2HexDigits(m_formatVersion); - writeString(R"(, qt_resource_struct, qt_resource_name, qt_resource_data) - -qInitResources() -)"); + writeString(", qt_resource_struct, qt_resource_name, qt_resource_data)\n\n"); + writeString("qInitResources()\n"); } return true; } From 36827faa18e245dfc6dad155201d8670fd171328 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Mon, 18 Mar 2019 17:17:22 +0800 Subject: [PATCH 095/292] Clang: Add Thin LTO in addition to Full LTO Change-Id: I6502f3ff31c16faebd9b931b99b77a273971f611 Reviewed-by: Thiago Macieira --- mkspecs/common/clang.conf | 4 +++- mkspecs/features/ltcg.prf | 2 +- mkspecs/win32-clang-g++/qmake.conf | 6 ++++++ mkspecs/win32-clang-msvc/qmake.conf | 4 +++- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/mkspecs/common/clang.conf b/mkspecs/common/clang.conf index dacd1539cf..e03dc7de14 100644 --- a/mkspecs/common/clang.conf +++ b/mkspecs/common/clang.conf @@ -19,7 +19,8 @@ QMAKE_PCH_OUTPUT_EXT = .pch QMAKE_CFLAGS_ISYSTEM = -isystem QMAKE_CFLAGS_PRECOMPILE = -x c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT} QMAKE_CFLAGS_USE_PRECOMPILE = -Xclang -include-pch -Xclang ${QMAKE_PCH_OUTPUT} -QMAKE_CFLAGS_LTCG = -flto +QMAKE_CFLAGS_LTCG = -flto=thin +QMAKE_CFLAGS_LTCG_FATOBJECTS = -flto QMAKE_CFLAGS_DISABLE_LTCG = -fno-lto QMAKE_CFLAGS_GNUC99 = -std=gnu99 QMAKE_CFLAGS_GNUC11 = -std=gnu11 @@ -27,6 +28,7 @@ QMAKE_CFLAGS_GNUC11 = -std=gnu11 QMAKE_CXXFLAGS_PRECOMPILE = -x c++-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT} QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE QMAKE_CXXFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG +QMAKE_CXXFLAGS_LTCG_FATOBJECTS = $$QMAKE_CFLAGS_LTCG_FATOBJECTS QMAKE_CXXFLAGS_DISABLE_LTCG = $$QMAKE_CFLAGS_DISABLE_LTCG QMAKE_CXXFLAGS_CXX11 = -std=c++11 QMAKE_CXXFLAGS_CXX14 = -std=c++1y diff --git a/mkspecs/features/ltcg.prf b/mkspecs/features/ltcg.prf index ccf0226272..d113caf35c 100644 --- a/mkspecs/features/ltcg.prf +++ b/mkspecs/features/ltcg.prf @@ -2,7 +2,7 @@ CONFIG(release, debug|release) { # We need fat object files when creating static libraries on some platforms # so the linker will know to load a particular object from the library # in the first place. On others, we have special ar and nm to create the symbol - # tables so the linker will know better. For other compilers, we disable LTCG + # tables so the linker will know better. For other compilers, we disable LTCG # for static libraries. msvc { # Nothing to do diff --git a/mkspecs/win32-clang-g++/qmake.conf b/mkspecs/win32-clang-g++/qmake.conf index 4630ec4602..4bceb2780c 100644 --- a/mkspecs/win32-clang-g++/qmake.conf +++ b/mkspecs/win32-clang-g++/qmake.conf @@ -24,4 +24,10 @@ QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON QMAKE_LINK = $${CROSS_COMPILE}clang++ QMAKE_LINK_C = $${CROSS_COMPILE}clang +QMAKE_CFLAGS_LTCG = -flto=thin +QMAKE_CXXFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG +QMAKE_CFLAGS_LTCG_FATOBJECTS = -flto +QMAKE_CXXFLAGS_LTCG_FATOBJECTS = $$QMAKE_CFLAGS_LTCG_FATOBJECTS +QMAKE_LFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG + load(qt_config) diff --git a/mkspecs/win32-clang-msvc/qmake.conf b/mkspecs/win32-clang-msvc/qmake.conf index c639ad6f3d..8bbe0105f0 100644 --- a/mkspecs/win32-clang-msvc/qmake.conf +++ b/mkspecs/win32-clang-msvc/qmake.conf @@ -39,8 +39,10 @@ QMAKE_CXXFLAGS += -Wno-microsoft-enum-value QMAKE_LINK = lld-link QMAKE_LIB = llvm-lib /NOLOGO -QMAKE_CFLAGS_LTCG = -flto +QMAKE_CFLAGS_LTCG = -flto=thin QMAKE_CXXFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG +QMAKE_CFLAGS_LTCG_FATOBJECTS = -flto +QMAKE_CXXFLAGS_LTCG_FATOBJECTS = $$QMAKE_CFLAGS_LTCG_FATOBJECTS # Leave QMAKE_LFLAGS_LTCG empty because lld-link doesn't need any additional parameters QMAKE_LFLAGS_LTCG = From 6a210e0329aaf697e6760e2019e0cb0f9236ba14 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Thu, 21 Mar 2019 02:32:07 +0800 Subject: [PATCH 096/292] clang-cl: Enable linker optimization explicitly In release mode, MSVC linker will enable it by default while clang-cl won't. So enable it explicitly. Change-Id: Iabfd8698d426290fee59662acf6c124b9f226c11 Reviewed-by: Thiago Macieira --- mkspecs/win32-clang-msvc/qmake.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mkspecs/win32-clang-msvc/qmake.conf b/mkspecs/win32-clang-msvc/qmake.conf index 8bbe0105f0..d6f7ad7be7 100644 --- a/mkspecs/win32-clang-msvc/qmake.conf +++ b/mkspecs/win32-clang-msvc/qmake.conf @@ -46,6 +46,8 @@ QMAKE_CXXFLAGS_LTCG_FATOBJECTS = $$QMAKE_CFLAGS_LTCG_FATOBJECTS # Leave QMAKE_LFLAGS_LTCG empty because lld-link doesn't need any additional parameters QMAKE_LFLAGS_LTCG = +QMAKE_LFLAGS_RELEASE += /OPT:REF,ICF,LBR + # Precompiled headers are not supported yet by clang CONFIG -= precompile_header From 758151d077536eb8fe2cd1a3252dec5619b9789f Mon Sep 17 00:00:00 2001 From: Timo Lang Date: Wed, 20 Mar 2019 09:50:51 +0100 Subject: [PATCH 097/292] QVariant: Fix isNull() == true after downcasting QObject* MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [ChangeLog][QtCore][QVariant] Fixed a bug that caused isNull() to be true after downcasting a QObject* payload using convert(). Fixes: QTBUG-73196 Change-Id: Ifda15952f873d7142c95609b69ac424bbf16b723 Reviewed-by: Thiago Macieira Reviewed-by: Jędrzej Nowacki --- src/corelib/kernel/qvariant.cpp | 2 ++ tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index deba977f77..77d2c8cbe1 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -1462,6 +1462,7 @@ static void customConstruct(QVariant::Private *d, const void *copy) if (size <= sizeof(QVariant::Private::Data) && (type.flags() & (QMetaType::MovableType | QMetaType::IsEnumeration))) { type.construct(&d->data.ptr, copy); + d->is_null = d->data.ptr == nullptr; d->is_shared = false; } else { // Private::Data contains long long, and long double is the biggest standard type. @@ -1472,6 +1473,7 @@ static void customConstruct(QVariant::Private *d, const void *copy) void *data = operator new(offset + size); void *ptr = static_cast(data) + offset; type.construct(ptr, copy); + d->is_null = ptr == nullptr; d->is_shared = true; d->data.shared = new (data) QVariant::PrivateShared(ptr); } diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index 4da34c407e..a9162a6a6f 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -2761,6 +2761,14 @@ void tst_QVariant::qvariant_cast_QObject_derived() QCOMPARE(data.value(), object); QCOMPARE(data.value(), object); } + { + QObject *object = new CustomQObjectDerivedNoMetaType(this); + QVariant data = QVariant::fromValue(object); + QVERIFY(data.canConvert()); + QVERIFY(data.convert(qMetaTypeId())); + QCOMPARE(data.value(), object); + QCOMPARE(data.isNull(), false); + } } struct QObjectWrapper From 3c4721488af0f33515911d07033d3f9981952543 Mon Sep 17 00:00:00 2001 From: Kari Oikarinen Date: Thu, 7 Mar 2019 17:34:16 +0200 Subject: [PATCH 098/292] QVector: Add assignment from std::initializer_list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I88a66e4b78ca6f40c328070f275e7163fb0d691c Reviewed-by: Ville Voutilainen Reviewed-by: Giuseppe D'Angelo Reviewed-by: Lars Knoll Reviewed-by: Jędrzej Nowacki --- src/corelib/tools/qvector.h | 12 +++++- src/corelib/tools/qvector.qdoc | 11 +++++ .../corelib/tools/qvector/tst_qvector.cpp | 42 +++++++++++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 988d5a9e1b..9762ec1b5b 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -79,6 +79,7 @@ public: void swap(QVector &other) Q_DECL_NOTHROW { qSwap(d, other.d); } #ifdef Q_COMPILER_INITIALIZER_LISTS inline QVector(std::initializer_list args); + QVector &operator=(std::initializer_list args); #endif bool operator==(const QVector &v) const; inline bool operator!=(const QVector &v) const { return !(*this == v); } @@ -542,10 +543,19 @@ QVector::QVector(std::initializer_list args) d = Data::sharedNull(); } } + +template +QVector &QVector::operator=(std::initializer_list args) +{ + QVector tmp(args); + tmp.swap(*this); + return *this; +} + # if defined(Q_CC_MSVC) QT_WARNING_POP # endif // Q_CC_MSVC -#endif // Q_COMPILER_INITALIZER_LISTS +#endif // Q_COMPILER_INITIALIZER_LISTS template void QVector::freeData(Data *x) diff --git a/src/corelib/tools/qvector.qdoc b/src/corelib/tools/qvector.qdoc index 75b17a4207..69bbb5f9a2 100644 --- a/src/corelib/tools/qvector.qdoc +++ b/src/corelib/tools/qvector.qdoc @@ -263,6 +263,17 @@ \since 5.2 */ +/*! + \fn template QVector &QVector::operator=(std::initializer_list args) + + Assigns the collection of values in \a args to this QVector instance. + + This operator is only enabled if the compiler supports C++11 initializer + lists. + + \since 5.14 +*/ + /*! \fn template void QVector::swap(QVector &other) \since 4.8 diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp index a7faeb5ca5..2278e0ba13 100644 --- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp +++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp @@ -206,6 +206,9 @@ private slots: void assignmentInt() const; void assignmentMovable() const; void assignmentCustom() const; + void assignFromInitializerListInt() const; + void assignFromInitializerListMovable() const; + void assignFromInitializerListCustom() const; void addInt() const; void addMovable() const; void addCustom() const; @@ -330,6 +333,7 @@ private: template void copyConstructor() const; template void add() const; template void append() const; + template void assignFromInitializerList() const; template void capacity() const; template void clear() const; template void count() const; @@ -542,6 +546,44 @@ void tst_QVector::assignmentCustom() const testAssignment(); } +template +void tst_QVector::assignFromInitializerList() const +{ +#ifdef Q_COMPILER_INITIALIZER_LISTS + T val1(SimpleValue::at(1)); + T val2(SimpleValue::at(2)); + T val3(SimpleValue::at(3)); + + QVector v1 = {val1, val2, val3}; + QCOMPARE(v1, QVector() << val1 << val2 << val3); + QCOMPARE(v1, (QVector {val1, val2, val3})); + + v1 = {}; + QCOMPARE(v1.size(), 0); +#else + QSKIP("This test requires support for C++11 initializer lists."); +#endif +} + +void tst_QVector::assignFromInitializerListInt() const +{ + assignFromInitializerList(); +} + +void tst_QVector::assignFromInitializerListMovable() const +{ + const int instancesCount = Movable::counter.loadAcquire(); + assignFromInitializerList(); + QCOMPARE(instancesCount, Movable::counter.loadAcquire()); +} + +void tst_QVector::assignFromInitializerListCustom() const +{ + const int instancesCount = Custom::counter.loadAcquire(); + assignFromInitializerList(); + QCOMPARE(instancesCount, Custom::counter.loadAcquire()); +} + template void tst_QVector::add() const { From 12bc039baa2672c98518277ea146bedec3a92ac0 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 21 Mar 2019 13:03:21 +0100 Subject: [PATCH 099/292] Don't iterate over the connections without holding a lock When checking whether a slot is connected to a signal, we need to hold the signalSlotLock to be sure about the answer, or we can get crashes when a connection gets removed while doing the check. The check in activate() can handle some uncertainty as it's only a shortcut to the longer path. Fixes: QTBUG-74604 Change-Id: I3fc822455fbadc0223ef68632f5fb3df3ff3e86d Reviewed-by: Aapo Keskimolo --- src/corelib/kernel/qobject.cpp | 18 +++++++++++++++++- src/corelib/kernel/qobject_p.h | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 759ccaacd8..268f3949fd 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -415,6 +415,22 @@ bool QObjectPrivate::isSignalConnected(uint signalIndex, bool checkDeclarative) return false; } +bool QObjectPrivate::maybeSignalConnected(uint signalIndex) const +{ + ConnectionData *cd = connections.load(); + if (!cd) + return false; + + if (cd->allsignals.first) + return true; + + if (signalIndex < uint(cd->signalVector.count())) { + const QObjectPrivate::Connection *c = cd->signalVector.at(signalIndex).first; + return c != nullptr; + } + return false; +} + /*! \internal @@ -3599,7 +3615,7 @@ void doActivate(QObject *sender, int signal_index, void **argv) if (!argv) argv = empty_argv; - if (!sp->isSignalConnected(signal_index, false)) { + if (!sp->maybeSignalConnected(signal_index)) { // The possible declarative connection is done, and nothing else is connected if (callbacks_enabled && signal_spy_set->signal_begin_callback != nullptr) signal_spy_set->signal_begin_callback(sender, signal_index, argv); diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 823c7a195a..863689fddd 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -254,6 +254,7 @@ public: int signalIndex(const char *signalName, const QMetaObject **meta = nullptr) const; bool isSignalConnected(uint signalIdx, bool checkDeclarative = true) const; + bool maybeSignalConnected(uint signalIndex) const; inline bool isDeclarativeSignalConnected(uint signalIdx) const; // To allow abitrary objects to call connectNotify()/disconnectNotify() without making From b73eef0b511b0e92c954c0b1355897108db827ba Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Wed, 20 Mar 2019 20:33:25 +0800 Subject: [PATCH 100/292] Clang: Enable precompiled header for qmake Tested with Clang 8.0.0, everything works fine. Task-number: QTBUG-74563 Change-Id: I3e216b062352851a7be59543ef1a4029f919111d Reviewed-by: Thiago Macieira --- qmake/Makefile.win32 | 2 -- 1 file changed, 2 deletions(-) diff --git a/qmake/Makefile.win32 b/qmake/Makefile.win32 index 506e9deb19..6ab40c6765 100644 --- a/qmake/Makefile.win32 +++ b/qmake/Makefile.win32 @@ -24,10 +24,8 @@ LINKER = link CFLAGS_EXTRA = /MP /wd4577 $(CFLAGS_CRT) !endif # !win32-icc -!if "$(QMAKESPEC)" != "win32-clang-msvc" CFLAGS_PCH = -Yuqmake_pch.h -FIqmake_pch.h -Fpqmake_pch.pch PCH_OBJECT = qmake_pch.obj -!endif CFLAGS_BARE = -c -Fo./ -Fdqmake.pdb \ -W2 -nologo -O2 \ From b43988ada2b107258833deb8fa229f1f142d3851 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Wed, 20 Mar 2019 20:26:23 +0800 Subject: [PATCH 101/292] Clang: use -Oz instead of -O1 to optimize for size Change-Id: I60fecba64e968d10b87a9c1af571ff4a3aa98ad7 Reviewed-by: Thiago Macieira --- mkspecs/android-clang/qmake.conf | 2 -- mkspecs/common/clang.conf | 2 ++ mkspecs/win32-clang-g++/qmake.conf | 2 ++ mkspecs/win32-clang-msvc/qmake.conf | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mkspecs/android-clang/qmake.conf b/mkspecs/android-clang/qmake.conf index a077c70cba..dd29473969 100644 --- a/mkspecs/android-clang/qmake.conf +++ b/mkspecs/android-clang/qmake.conf @@ -51,6 +51,4 @@ exists($$ANDROID_SOURCES_CXX_STL_LIBDIR/libc++.so): \ else: \ ANDROID_CXX_STL_LIBS = $$ANDROID_SOURCES_CXX_STL_LIBDIR/libc++.so.$$replace(ANDROID_PLATFORM, "android-", "") -QMAKE_CFLAGS_OPTIMIZE_SIZE = -Oz - include(../common/android-base-tail.conf) diff --git a/mkspecs/common/clang.conf b/mkspecs/common/clang.conf index e03dc7de14..1666843136 100644 --- a/mkspecs/common/clang.conf +++ b/mkspecs/common/clang.conf @@ -16,6 +16,8 @@ QMAKE_LINK_SHLIB = $$QMAKE_CXX CONFIG += clang_pch_style QMAKE_PCH_OUTPUT_EXT = .pch +QMAKE_CFLAGS_OPTIMIZE_SIZE = -Oz + QMAKE_CFLAGS_ISYSTEM = -isystem QMAKE_CFLAGS_PRECOMPILE = -x c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT} QMAKE_CFLAGS_USE_PRECOMPILE = -Xclang -include-pch -Xclang ${QMAKE_PCH_OUTPUT} diff --git a/mkspecs/win32-clang-g++/qmake.conf b/mkspecs/win32-clang-g++/qmake.conf index 4bceb2780c..59d42176f0 100644 --- a/mkspecs/win32-clang-g++/qmake.conf +++ b/mkspecs/win32-clang-g++/qmake.conf @@ -30,4 +30,6 @@ QMAKE_CFLAGS_LTCG_FATOBJECTS = -flto QMAKE_CXXFLAGS_LTCG_FATOBJECTS = $$QMAKE_CFLAGS_LTCG_FATOBJECTS QMAKE_LFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG +QMAKE_CFLAGS_OPTIMIZE_SIZE = -Oz + load(qt_config) diff --git a/mkspecs/win32-clang-msvc/qmake.conf b/mkspecs/win32-clang-msvc/qmake.conf index d6f7ad7be7..e15c18b9e6 100644 --- a/mkspecs/win32-clang-msvc/qmake.conf +++ b/mkspecs/win32-clang-msvc/qmake.conf @@ -46,6 +46,8 @@ QMAKE_CXXFLAGS_LTCG_FATOBJECTS = $$QMAKE_CFLAGS_LTCG_FATOBJECTS # Leave QMAKE_LFLAGS_LTCG empty because lld-link doesn't need any additional parameters QMAKE_LFLAGS_LTCG = +QMAKE_CFLAGS_OPTIMIZE_SIZE = -Xclang -Oz + QMAKE_LFLAGS_RELEASE += /OPT:REF,ICF,LBR # Precompiled headers are not supported yet by clang From e8bde992e073072e795cdb2d4fa5d36089953645 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Tue, 12 Feb 2019 16:20:36 +0100 Subject: [PATCH 102/292] Update handling of TESTSERVER_COMPOSE_FILE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Initially TESTSERVER_COMPOSE_FILE could be manually specified. Later this got removed by accident. Re-enable this feature. Furthermore, check if a module has a platform-specific compose file. If not, fall back to a default docker-compose.yml. This is useful to include testserver.pri from other modules, where no platform-specific requirements are present, ie the image from provisioning works on all platforms. Change-Id: Icb92552fd61196be332b2431ab0f8a43b9157fc8 Reviewed-by: Ryan Chu Reviewed-by: Mårten Nordheim --- tests/auto/testserver.pri | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/auto/testserver.pri b/tests/auto/testserver.pri index eb83c6c2cc..455f88fa5d 100644 --- a/tests/auto/testserver.pri +++ b/tests/auto/testserver.pri @@ -93,7 +93,7 @@ isEmpty(TESTSERVER_VERSION) { # but it causes a port conflict if the user is running a service that # binds the same port on the host. An alternative solution is to deploy # the docker environment into VirtualBox using docker-machine. - TESTSERVER_COMPOSE_FILE = \ + isEmpty(TESTSERVER_COMPOSE_FILE): TESTSERVER_COMPOSE_FILE = \ $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose-for-macOS.yml # The connection configuration for the target machine @@ -106,7 +106,7 @@ isEmpty(TESTSERVER_VERSION) { } else:equals(QMAKE_HOST.os, Windows) { # There is no docker bridge on Windows. It is impossible to ping a container. # Use docker-machine to deploy the docker environment into VirtualBox. - TESTSERVER_COMPOSE_FILE = \ + isEmpty(TESTSERVER_COMPOSE_FILE): TESTSERVER_COMPOSE_FILE = \ $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose-for-windows.yml # The connection configuration for the target machine @@ -123,12 +123,14 @@ isEmpty(TESTSERVER_VERSION) { TEST_CMD = 'PowerShell -noprofile' CONFIG += PowerShell } else { - TESTSERVER_COMPOSE_FILE = $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose.yml - + isEmpty(TESTSERVER_COMPOSE_FILE): TESTSERVER_COMPOSE_FILE = \ + $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose.yml # The environment variables passed to the docker-compose file TEST_ENV = 'TEST_DOMAIN=$$DNSDOMAIN' TEST_CMD = env } + !exists($$TESTSERVER_COMPOSE_FILE): error("Invalid TESTSERVER_COMPOSE_FILE specified") + # The domain name is relevant to https keycert (qnetworkreply/crts/qt-test-net-cacert.pem). DEFINES += QT_TEST_SERVER QT_TEST_SERVER_DOMAIN=$$shell_quote(\"$${DNSDOMAIN}\") From 3b38c73c7ffa71c00c172cf0e05742835a304300 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 22 Mar 2019 11:20:31 +0100 Subject: [PATCH 103/292] Widen out parameter "result" of the native event filters for Qt 6 LRESULT on Windows 64 is a 64bit type, adapt filter functions of QAbstractNativeEventFilter and QAbstractEventDispatcher accordingly. Fixes: QTBUG-72968 Change-Id: Ie53193e355f0b8e9bd59fa377f43e2b4664a2ded Reviewed-by: Thiago Macieira --- src/corelib/io/qfilesystemwatcher_win.cpp | 8 ++++++++ .../kernel/qabstracteventdispatcher.cpp | 4 ++++ src/corelib/kernel/qabstracteventdispatcher.h | 4 ++++ .../kernel/qabstractnativeeventfilter.cpp | 1 + .../kernel/qabstractnativeeventfilter.h | 4 ++++ src/corelib/kernel/qeventdispatcher_win.cpp | 4 ++++ src/gui/kernel/qguiapplication.cpp | 4 ++++ src/gui/kernel/qguiapplication_p.h | 4 ++++ src/gui/kernel/qwindow.cpp | 5 +++++ src/gui/kernel/qwindow.h | 4 ++++ src/gui/kernel/qwindowsysteminterface.cpp | 4 ++++ src/gui/kernel/qwindowsysteminterface.h | 4 ++++ .../platforms/qnx/qqnxscreeneventhandler.cpp | 4 ++++ .../platforms/windows/qwindowscontext.cpp | 8 ++++++++ .../xcb_glx/qxcbglxintegration.cpp | 4 ++++ src/plugins/platforms/xcb/qxcbconnection.cpp | 8 ++++++++ src/plugins/platforms/xcb/qxcbwindow.cpp | 4 ++++ src/testlib/qbenchmarkevent.cpp | 4 ++++ src/testlib/qbenchmarkevent_p.h | 4 ++++ src/widgets/dialogs/qwizard.cpp | 4 ++++ src/widgets/dialogs/qwizard.h | 4 ++++ src/widgets/dialogs/qwizard_win.cpp | 20 +++++++++++++++++++ src/widgets/dialogs/qwizard_win_p.h | 8 ++++++++ src/widgets/kernel/qwidget.cpp | 4 ++++ src/widgets/kernel/qwidget.h | 5 +++++ src/widgets/kernel/qwidgetwindow.cpp | 4 ++++ src/widgets/kernel/qwidgetwindow_p.h | 4 ++++ .../widgets/kernel/qwidget/tst_qwidget.cpp | 8 ++++++++ 28 files changed, 147 insertions(+) diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp index 66985f8982..7f4f9d345b 100644 --- a/src/corelib/io/qfilesystemwatcher_win.cpp +++ b/src/corelib/io/qfilesystemwatcher_win.cpp @@ -108,7 +108,11 @@ public: // Call from QFileSystemWatcher::addPaths() to set up notifications on drives void addPath(const QString &path); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + bool nativeEventFilter(const QByteArray &, void *messageIn, qintptr *) override; +#else bool nativeEventFilter(const QByteArray &, void *messageIn, long *) override; +#endif signals: void driveAdded(); @@ -255,7 +259,11 @@ inline void QWindowsRemovableDriveListener::handleDbtDriveArrivalRemoval(const M } } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +bool QWindowsRemovableDriveListener::nativeEventFilter(const QByteArray &, void *messageIn, qintptr *) +#else bool QWindowsRemovableDriveListener::nativeEventFilter(const QByteArray &, void *messageIn, long *) +#endif { const MSG *msg = reinterpret_cast(messageIn); if (msg->message == WM_DEVICECHANGE) { diff --git a/src/corelib/kernel/qabstracteventdispatcher.cpp b/src/corelib/kernel/qabstracteventdispatcher.cpp index 8e1b560874..0ecfc7a8c7 100644 --- a/src/corelib/kernel/qabstracteventdispatcher.cpp +++ b/src/corelib/kernel/qabstracteventdispatcher.cpp @@ -470,7 +470,11 @@ void QAbstractEventDispatcher::removeNativeEventFilter(QAbstractNativeEventFilte \sa installNativeEventFilter(), QAbstractNativeEventFilter::nativeEventFilter() \since 5.0 */ +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +bool QAbstractEventDispatcher::filterNativeEvent(const QByteArray &eventType, void *message, qintptr *result) +#else bool QAbstractEventDispatcher::filterNativeEvent(const QByteArray &eventType, void *message, long *result) +#endif { Q_D(QAbstractEventDispatcher); if (!d->eventFilters.isEmpty()) { diff --git a/src/corelib/kernel/qabstracteventdispatcher.h b/src/corelib/kernel/qabstracteventdispatcher.h index bd8da5c35d..4ef9c068df 100644 --- a/src/corelib/kernel/qabstracteventdispatcher.h +++ b/src/corelib/kernel/qabstracteventdispatcher.h @@ -110,7 +110,11 @@ public: void installNativeEventFilter(QAbstractNativeEventFilter *filterObj); void removeNativeEventFilter(QAbstractNativeEventFilter *filterObj); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + bool filterNativeEvent(const QByteArray &eventType, void *message, qintptr *result); +#else bool filterNativeEvent(const QByteArray &eventType, void *message, long *result); +#endif #if QT_DEPRECATED_SINCE(5, 0) QT_DEPRECATED bool filterEvent(void *message) { return filterNativeEvent("", message, nullptr); } diff --git a/src/corelib/kernel/qabstractnativeeventfilter.cpp b/src/corelib/kernel/qabstractnativeeventfilter.cpp index dcbb92f044..eaadea4c12 100644 --- a/src/corelib/kernel/qabstractnativeeventfilter.cpp +++ b/src/corelib/kernel/qabstractnativeeventfilter.cpp @@ -74,6 +74,7 @@ QAbstractNativeEventFilter::~QAbstractNativeEventFilter() eventDispatcher->removeNativeEventFilter(this); } +// ### fixme Qt 6: result will be qintptr * /*! \fn bool QAbstractNativeEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, long *result) diff --git a/src/corelib/kernel/qabstractnativeeventfilter.h b/src/corelib/kernel/qabstractnativeeventfilter.h index d7baa42513..a468bffd61 100644 --- a/src/corelib/kernel/qabstractnativeeventfilter.h +++ b/src/corelib/kernel/qabstractnativeeventfilter.h @@ -52,7 +52,11 @@ public: QAbstractNativeEventFilter(); virtual ~QAbstractNativeEventFilter(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + virtual bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result) = 0; +#else virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) = 0; +#endif private: Q_DISABLE_COPY(QAbstractNativeEventFilter) diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index 685d765adb..84378454ca 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -136,7 +136,11 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA msg.wParam = wp; msg.lParam = lp; QAbstractEventDispatcher* dispatcher = QAbstractEventDispatcher::instance(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + qintptr result; +#else long result; +#endif if (!dispatcher) { if (message == WM_TIMER) KillTimer(hwnd, wp); diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 7218e55627..8e587f6b39 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1825,7 +1825,11 @@ bool QGuiApplicationPrivate::sendQWindowEventToQPlatformWindow(QWindow *window, return platformWindow->windowEvent(event); } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +bool QGuiApplicationPrivate::processNativeEvent(QWindow *window, const QByteArray &eventType, void *message, qintptr *result) +#else bool QGuiApplicationPrivate::processNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result) +#endif { return window->nativeEvent(eventType, message, result); } diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 65afa5de1b..c9619daa3d 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -172,7 +172,11 @@ public: Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers); #endif +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + static bool processNativeEvent(QWindow *window, const QByteArray &eventType, void *message, qintptr *result); +#else static bool processNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result); +#endif static bool sendQWindowEventToQPlatformWindow(QWindow *window, QEvent *event); diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 1cc2435239..6e0c2de240 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -2523,7 +2523,12 @@ void QWindow::tabletEvent(QTabletEvent *ev) Should return true only if the event was handled. */ + +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +bool QWindow::nativeEvent(const QByteArray &eventType, void *message, qintptr *result) +#else bool QWindow::nativeEvent(const QByteArray &eventType, void *message, long *result) +#endif { Q_UNUSED(eventType); Q_UNUSED(message); diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h index 1be3c845fe..5ee1d00f5b 100644 --- a/src/gui/kernel/qwindow.h +++ b/src/gui/kernel/qwindow.h @@ -364,7 +364,11 @@ protected: #if QT_CONFIG(tabletevent) virtual void tabletEvent(QTabletEvent *); #endif +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + virtual bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result); +#else virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result); +#endif QWindow(QWindowPrivate &dd, QWindow *parent); diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 7067ece1d8..8e6e3ce618 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -863,7 +863,11 @@ QPlatformDropQtResponse QWindowSystemInterface::handleDrop(QWindow *window, cons \note This function can only be called from the GUI thread. */ +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +bool QWindowSystemInterface::handleNativeEvent(QWindow *window, const QByteArray &eventType, void *message, qintptr *result) +#else bool QWindowSystemInterface::handleNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result) +#endif { return QGuiApplicationPrivate::processNativeEvent(window, eventType, message, result); } diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index 1dde9130ac..03b3bd16f0 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -230,7 +230,11 @@ public: Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers); #endif // QT_CONFIG(draganddrop) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + static bool handleNativeEvent(QWindow *window, const QByteArray &eventType, void *message, qintptr *result); +#else static bool handleNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result); +#endif // Changes to the screen static void handleScreenOrientationChange(QScreen *screen, Qt::ScreenOrientation newOrientation); diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp index f29e11489b..c2471751f5 100644 --- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp +++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp @@ -242,7 +242,11 @@ void QQnxScreenEventHandler::processEvents() break; ++count; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + qintptr result = 0; +#else long result = 0; +#endif QAbstractEventDispatcher* dispatcher = QAbstractEventDispatcher::instance(); bool handled = dispatcher && dispatcher->filterNativeEvent(QByteArrayLiteral("screen_event_t"), event, &result); if (!handled) diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 80517ffe69..073d6da536 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -1605,7 +1605,11 @@ static inline QByteArray nativeEventType() { return QByteArrayLiteral("windows_g bool QWindowsContext::filterNativeEvent(MSG *msg, LRESULT *result) { QAbstractEventDispatcher *dispatcher = QAbstractEventDispatcher::instance(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + qintptr filterResult = 0; +#else long filterResult = 0; +#endif if (dispatcher && dispatcher->filterNativeEvent(nativeEventType(), msg, &filterResult)) { *result = LRESULT(filterResult); return true; @@ -1616,7 +1620,11 @@ bool QWindowsContext::filterNativeEvent(MSG *msg, LRESULT *result) // Send to QWindowSystemInterface bool QWindowsContext::filterNativeEvent(QWindow *window, MSG *msg, LRESULT *result) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + qintptr filterResult = 0; +#else long filterResult = 0; +#endif if (QWindowSystemInterface::handleNativeEvent(window, nativeEventType(), msg, &filterResult)) { *result = LRESULT(filterResult); return true; diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp index b751aaf8a3..34895caaa2 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp @@ -164,7 +164,11 @@ bool QXcbGlxIntegration::handleXcbEvent(xcb_generic_event_t *event, uint respons XUnlockDisplay(xdisplay); locked = false; auto eventType = m_connection->nativeInterface()->nativeEventType(); +# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + qintptr result = 0; +# else long result = 0; +# endif handled = dispatcher->filterNativeEvent(eventType, &ev, &result); } #endif diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 1ff06dd39e..e35b97dab4 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -439,7 +439,11 @@ const char *xcb_protocol_request_codes[] = void QXcbConnection::handleXcbError(xcb_generic_error_t *error) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + qintptr result = 0; +#else long result = 0; +#endif QAbstractEventDispatcher* dispatcher = QAbstractEventDispatcher::instance(); if (dispatcher && dispatcher->filterNativeEvent(m_nativeInterface->nativeEventType(), error, &result)) return; @@ -536,7 +540,11 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event) if (Q_UNLIKELY(lcQpaEvents().isDebugEnabled())) printXcbEvent(lcQpaEvents(), "Event", event); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + qintptr result = 0; // Used only by MS Windows +#else long result = 0; // Used only by MS Windows +#endif if (QAbstractEventDispatcher *dispatcher = QAbstractEventDispatcher::instance()) { if (dispatcher->filterNativeEvent(m_nativeInterface->nativeEventType(), event, &result)) return; diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 9382488b74..396b47001d 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -1657,7 +1657,11 @@ bool QXcbWindow::requestSystemTrayWindowDock() bool QXcbWindow::handleNativeEvent(xcb_generic_event_t *event) { auto eventType = connection()->nativeInterface()->nativeEventType(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + qintptr result = 0; // Used only by MS Windows +#else long result = 0; // Used only by MS Windows +#endif return QWindowSystemInterface::handleNativeEvent(window(), eventType, event, &result); } diff --git a/src/testlib/qbenchmarkevent.cpp b/src/testlib/qbenchmarkevent.cpp index f696f8b1eb..a8270219e4 100644 --- a/src/testlib/qbenchmarkevent.cpp +++ b/src/testlib/qbenchmarkevent.cpp @@ -96,7 +96,11 @@ QTest::QBenchmarkMetric QBenchmarkEvent::metricType() } // This could be done in a much better way, this is just the beginning. +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +bool QBenchmarkEvent::nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result) +#else bool QBenchmarkEvent::nativeEventFilter(const QByteArray &eventType, void *message, long *result) +#endif { Q_UNUSED(eventType); Q_UNUSED(message); diff --git a/src/testlib/qbenchmarkevent_p.h b/src/testlib/qbenchmarkevent_p.h index af42a17141..0f47aa475c 100644 --- a/src/testlib/qbenchmarkevent_p.h +++ b/src/testlib/qbenchmarkevent_p.h @@ -71,7 +71,11 @@ public: int adjustMedianCount(int suggestion) override; bool repeatCount() override { return 1; } QTest::QBenchmarkMetric metricType() override; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result) override; +#else bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override; +#endif qint64 eventCounter; }; diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index 88b187cd7f..c692a0f8db 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -3257,7 +3257,11 @@ void QWizard::paintEvent(QPaintEvent * event) /*! \reimp */ +# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +bool QWizard::nativeEvent(const QByteArray &eventType, void *message, qintptr *result) +# else bool QWizard::nativeEvent(const QByteArray &eventType, void *message, long *result) +# endif { #if QT_CONFIG(style_windowsvista) Q_D(QWizard); diff --git a/src/widgets/dialogs/qwizard.h b/src/widgets/dialogs/qwizard.h index 0dd837b197..ef71efa0cb 100644 --- a/src/widgets/dialogs/qwizard.h +++ b/src/widgets/dialogs/qwizard.h @@ -188,7 +188,11 @@ protected: void resizeEvent(QResizeEvent *event) override; void paintEvent(QPaintEvent *event) override; #if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC) +# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result) override; +# else bool nativeEvent(const QByteArray &eventType, void *message, long *result) override; +# endif #endif void done(int result) override; virtual void initializePage(int id); diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp index aa9ad7f290..62738f732c 100644 --- a/src/widgets/dialogs/qwizard_win.cpp +++ b/src/widgets/dialogs/qwizard_win.cpp @@ -339,7 +339,11 @@ void QVistaHelper::setTitleBarIconAndCaptionVisible(bool visible) SetWindowThemeAttribute(handle, WTA_NONCLIENT, &opt, sizeof(WTA_OPTIONS)); } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +bool QVistaHelper::winEvent(MSG* msg, qintptr *result) +#else bool QVistaHelper::winEvent(MSG* msg, long* result) +#endif { switch (msg->message) { case WM_NCHITTEST: { @@ -401,7 +405,11 @@ void QVistaHelper::mouseEvent(QEvent *event) } } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +bool QVistaHelper::handleWinEvent(MSG *message, qintptr *result) +#else bool QVistaHelper::handleWinEvent(MSG *message, long *result) +#endif { if (message->message == WM_THEMECHANGED || message->message == WM_DWMCOMPOSITIONCHANGED) cachedVistaState = Dirty; @@ -509,7 +517,11 @@ bool QVistaHelper::eventFilter(QObject *obj, QEvent *event) if (event->type() == QEvent::MouseMove) { QMouseEvent *mouseEvent = static_cast(event); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + qintptr result; +#else long result; +#endif MSG msg; msg.message = WM_NCHITTEST; msg.wParam = 0; @@ -523,7 +535,11 @@ bool QVistaHelper::eventFilter(QObject *obj, QEvent *event) QMouseEvent *mouseEvent = static_cast(event); if (mouseEvent->button() == Qt::LeftButton) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + qintptr result; +#else long result; +#endif MSG msg; msg.message = WM_NCHITTEST; msg.wParam = 0; @@ -538,7 +554,11 @@ bool QVistaHelper::eventFilter(QObject *obj, QEvent *event) QMouseEvent *mouseEvent = static_cast(event); if (mouseEvent->button() == Qt::LeftButton) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + qintptr result; +#else long result; +#endif MSG msg; msg.message = WM_NCHITTEST; msg.wParam = 0; diff --git a/src/widgets/dialogs/qwizard_win_p.h b/src/widgets/dialogs/qwizard_win_p.h index 02c5e52c2c..b3796e3f48 100644 --- a/src/widgets/dialogs/qwizard_win_p.h +++ b/src/widgets/dialogs/qwizard_win_p.h @@ -93,7 +93,11 @@ public: bool setDWMTitleBar(TitleBarChangeType type); void setTitleBarIconAndCaptionVisible(bool visible); void mouseEvent(QEvent *event); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + bool handleWinEvent(MSG *message, qintptr *result); +#else bool handleWinEvent(MSG *message, long *result); +#endif void resizeEvent(QResizeEvent *event); void paintEvent(QPaintEvent *event); QVistaBackButton *backButton() const { return backButton_; } @@ -130,7 +134,11 @@ private: void drawTitleBar(QPainter *painter); void setMouseCursor(QPoint pos); void collapseTopFrameStrut(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + bool winEvent(MSG *message, qintptr *result); +#else bool winEvent(MSG *message, long *result); +#endif void mouseMoveEvent(QMouseEvent *event); void mousePressEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index de79fd4154..90a23f7cd4 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -10149,7 +10149,11 @@ void QWidget::hideEvent(QHideEvent *) \endtable */ +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +bool QWidget::nativeEvent(const QByteArray &eventType, void *message, qintptr *result) +#else bool QWidget::nativeEvent(const QByteArray &eventType, void *message, long *result) +#endif { Q_UNUSED(eventType); Q_UNUSED(message); diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h index 4e5ef5a111..aec3eee639 100644 --- a/src/widgets/kernel/qwidget.h +++ b/src/widgets/kernel/qwidget.h @@ -648,7 +648,12 @@ protected: virtual void showEvent(QShowEvent *event); virtual void hideEvent(QHideEvent *event); + +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + virtual bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result); +#else virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result); +#endif // Misc. protected functions virtual void changeEvent(QEvent *); diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index e9b749d7c2..c6f22aa21a 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -1020,7 +1020,11 @@ void QWidgetWindow::handleWindowStateChangedEvent(QWindowStateChangeEvent *event } } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +bool QWidgetWindow::nativeEvent(const QByteArray &eventType, void *message, qintptr *result) +#else bool QWidgetWindow::nativeEvent(const QByteArray &eventType, void *message, long *result) +#endif { return m_widget->nativeEvent(eventType, message, result); } diff --git a/src/widgets/kernel/qwidgetwindow_p.h b/src/widgets/kernel/qwidgetwindow_p.h index 0728135467..80a345465d 100644 --- a/src/widgets/kernel/qwidgetwindow_p.h +++ b/src/widgets/kernel/qwidgetwindow_p.h @@ -103,7 +103,11 @@ protected: #endif void handleExposeEvent(QExposeEvent *); void handleWindowStateChangedEvent(QWindowStateChangeEvent *event); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result) override; +#else bool nativeEvent(const QByteArray &eventType, void *message, long *result) override; +#endif #if QT_CONFIG(tabletevent) void handleTabletEvent(QTabletEvent *); #endif diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 2d4d5249d2..0ac8ccdbe7 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -6146,7 +6146,11 @@ public: return false; } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + bool nativeEvent(const QByteArray &eventType, void *message, qintptr *) override +#else bool nativeEvent(const QByteArray &eventType, void *message, long *) override +#endif { if (isMapNotify(eventType, message)) gotExpectedMapNotify = true; @@ -6154,7 +6158,11 @@ public: } // QAbstractNativeEventFilter interface +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *) override +#else bool nativeEventFilter(const QByteArray &eventType, void *message, long *) override +#endif { if (isMapNotify(eventType, message)) gotExpectedGlobalEvent = true; From 68d75aef76b24086ea676aa1646fec4e9358f0de Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Wed, 13 Mar 2019 00:20:25 +0300 Subject: [PATCH 104/292] qstringalgorithms: add find methods Also add qsizetype support. It's needed to add find methods to QStringView Change-Id: I45eac082924e27778c24eebbb19d694221c28978 Reviewed-by: Edward Welbourne Reviewed-by: Thiago Macieira --- src/corelib/tools/qregexp.cpp | 6 +- src/corelib/tools/qstring.cpp | 365 +++++++++++++------------- src/corelib/tools/qstringalgorithms.h | 5 + src/corelib/tools/qstringmatcher.cpp | 36 +-- 4 files changed, 208 insertions(+), 204 deletions(-) diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp index 87b30c952e..589eb74520 100644 --- a/src/corelib/tools/qregexp.cpp +++ b/src/corelib/tools/qregexp.cpp @@ -58,9 +58,6 @@ QT_BEGIN_NAMESPACE -int qFindString(const QChar *haystack, int haystackLen, int from, - const QChar *needle, int needleLen, Qt::CaseSensitivity cs); - // error strings for the regexp parser #define RXERR_OK QT_TRANSLATE_NOOP("QRegExp", "no error occurred") #define RXERR_DISABLED QT_TRANSLATE_NOOP("QRegExp", "disabled feature used") @@ -1423,7 +1420,8 @@ void QRegExpMatchState::match(const QChar *str0, int len0, int pos0, #ifndef QT_NO_REGEXP_OPTIM if (eng->trivial && !oneTest) { - pos = qFindString(str0, len0, pos0, eng->goodStr.unicode(), eng->goodStr.length(), eng->cs); + // ### Qt6: qsize + pos = int(QtPrivate::findString(QStringView(str0, len0), pos0, QStringView(eng->goodStr.unicode(), eng->goodStr.length()), eng->cs)); matchLen = eng->goodStr.length(); matched = (pos != -1); } else diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 98cce87464..65519d1f98 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -2,6 +2,7 @@ ** ** Copyright (C) 2016 The Qt Company Ltd. ** Copyright (C) 2018 Intel Corporation. +** Copyright (C) 2019 Mail.ru Group. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -142,19 +143,11 @@ extern "C" void qt_toLatin1_mips_dsp_asm(uchar *dst, const ushort *src, int leng #endif // internal -int qFindString(const QChar *haystack, int haystackLen, int from, - const QChar *needle, int needleLen, Qt::CaseSensitivity cs); -int qFindStringBoyerMoore(const QChar *haystack, int haystackLen, int from, - const QChar *needle, int needleLen, Qt::CaseSensitivity cs); -static inline int qt_last_index_of(const QChar *haystack, int haystackLen, QChar needle, - int from, Qt::CaseSensitivity cs); -static inline int qt_string_count(const QChar *haystack, int haystackLen, - const QChar *needle, int needleLen, - Qt::CaseSensitivity cs); -static inline int qt_string_count(const QChar *haystack, int haystackLen, - QChar needle, Qt::CaseSensitivity cs); -static inline int qt_find_latin1_string(const QChar *hay, int size, QLatin1String needle, - int from, Qt::CaseSensitivity cs); +qsizetype qFindStringBoyerMoore(QStringView haystack, qsizetype from, QStringView needle, Qt::CaseSensitivity cs); +static inline qsizetype qt_last_index_of(QStringView haystack, QChar needle, qsizetype from, Qt::CaseSensitivity cs); +static inline qsizetype qt_string_count(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs); +static inline qsizetype qt_string_count(QStringView haystack, QChar needle, Qt::CaseSensitivity cs); + static inline bool qt_starts_with(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs); static inline bool qt_starts_with(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs); static inline bool qt_starts_with(QStringView haystack, QChar needle, Qt::CaseSensitivity cs); @@ -1283,42 +1276,9 @@ int QtPrivate::compareStrings(QLatin1String lhs, QLatin1String rhs, Qt::CaseSens return qt_compare_strings(lhs, rhs, cs); } -/*! - \internal - - Returns the index position of the first occurrence of the - character \a ch in the string given by \a str and \a len, - searching forward from index - position \a from. Returns -1 if \a ch could not be found. -*/ -static int findChar(const QChar *str, int len, QChar ch, int from, - Qt::CaseSensitivity cs) -{ - const ushort *s = (const ushort *)str; - ushort c = ch.unicode(); - if (from < 0) - from = qMax(from + len, 0); - if (from < len) { - const ushort *n = s + from; - const ushort *e = s + len; - if (cs == Qt::CaseSensitive) { - n = QtPrivate::qustrchr(QStringView(n, e), c); - if (n != e) - return n - s; - } else { - c = foldCase(c); - --n; - while (++n != e) - if (foldCase(*n) == c) - return n - s; - } - } - return -1; -} - #define REHASH(a) \ - if (sl_minus_1 < sizeof(uint) * CHAR_BIT) \ - hashHaystack -= uint(a) << sl_minus_1; \ + if (sl_minus_1 < sizeof(std::size_t) * CHAR_BIT) \ + hashHaystack -= std::size_t(a) << sl_minus_1; \ hashHaystack <<= 1 inline bool qIsUpper(char ch) @@ -3735,7 +3695,8 @@ bool QString::operator>(QLatin1String other) const Q_DECL_NOTHROW */ int QString::indexOf(const QString &str, int from, Qt::CaseSensitivity cs) const { - return qFindString(unicode(), length(), from, str.unicode(), str.length(), cs); + // ### Qt6: qsize + return int(QtPrivate::findString(QStringView(unicode(), length()), from, QStringView(str.unicode(), str.length()), cs)); } /*! @@ -3759,85 +3720,8 @@ int QString::indexOf(const QString &str, int from, Qt::CaseSensitivity cs) const int QString::indexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) const { - return qt_find_latin1_string(unicode(), size(), str, from, cs); -} - -int qFindString( - const QChar *haystack0, int haystackLen, int from, - const QChar *needle0, int needleLen, Qt::CaseSensitivity cs) -{ - const int l = haystackLen; - const int sl = needleLen; - if (from < 0) - from += l; - if (uint(sl + from) > (uint)l) - return -1; - if (!sl) - return from; - if (!l) - return -1; - - if (sl == 1) - return findChar(haystack0, haystackLen, needle0[0], from, cs); - - /* - We use the Boyer-Moore algorithm in cases where the overhead - for the skip table should pay off, otherwise we use a simple - hash function. - */ - if (l > 500 && sl > 5) - return qFindStringBoyerMoore(haystack0, haystackLen, from, - needle0, needleLen, cs); - - auto sv = [sl](const ushort *v) { return QStringView(v, sl); }; - /* - We use some hashing for efficiency's sake. Instead of - comparing strings, we compare the hash value of str with that - of a part of this QString. Only if that matches, we call - qt_string_compare(). - */ - const ushort *needle = (const ushort *)needle0; - const ushort *haystack = (const ushort *)haystack0 + from; - const ushort *end = (const ushort *)haystack0 + (l-sl); - const uint sl_minus_1 = sl - 1; - uint hashNeedle = 0, hashHaystack = 0; - int idx; - - if (cs == Qt::CaseSensitive) { - for (idx = 0; idx < sl; ++idx) { - hashNeedle = ((hashNeedle<<1) + needle[idx]); - hashHaystack = ((hashHaystack<<1) + haystack[idx]); - } - hashHaystack -= haystack[sl_minus_1]; - - while (haystack <= end) { - hashHaystack += haystack[sl_minus_1]; - if (hashHaystack == hashNeedle - && qt_compare_strings(sv(needle), sv(haystack), Qt::CaseSensitive) == 0) - return haystack - (const ushort *)haystack0; - - REHASH(*haystack); - ++haystack; - } - } else { - const ushort *haystack_start = (const ushort *)haystack0; - for (idx = 0; idx < sl; ++idx) { - hashNeedle = (hashNeedle<<1) + foldCase(needle + idx, needle); - hashHaystack = (hashHaystack<<1) + foldCase(haystack + idx, haystack_start); - } - hashHaystack -= foldCase(haystack + sl_minus_1, haystack_start); - - while (haystack <= end) { - hashHaystack += foldCase(haystack + sl_minus_1, haystack_start); - if (hashHaystack == hashNeedle - && qt_compare_strings(sv(needle), sv(haystack), Qt::CaseInsensitive) == 0) - return haystack - (const ushort *)haystack0; - - REHASH(foldCase(haystack, haystack_start)); - ++haystack; - } - } - return -1; + // ### Qt6: qsize + return int(QtPrivate::findString(QStringView(unicode(), size()), from, str, cs)); } /*! @@ -3849,7 +3733,8 @@ int qFindString( */ int QString::indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const { - return findChar(unicode(), length(), ch, from, cs); + // ### Qt6: qsize + return int(QtPrivate::findChar(QStringView(unicode(), length()), ch, from, cs)); } /*! @@ -3866,7 +3751,8 @@ int QString::indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const */ int QString::indexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs) const { - return qFindString(unicode(), length(), from, str.unicode(), str.length(), cs); + // ### Qt6: qsize + return int(QtPrivate::findString(QStringView(unicode(), length()), from, QStringView(str.unicode(), str.length()), cs)); } static int lastIndexOfHelper(const ushort *haystack, int from, const ushort *needle, int sl, Qt::CaseSensitivity cs) @@ -3989,7 +3875,8 @@ int QString::lastIndexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) co */ int QString::lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const { - return qt_last_index_of(unicode(), size(), ch, from, cs); + // ### Qt6: qsize + return int(qt_last_index_of(QStringView(unicode(), size()), ch, from, cs)); } /*! @@ -4322,7 +4209,8 @@ QString &QString::replace(const QRegularExpression &re, const QString &after) int QString::count(const QString &str, Qt::CaseSensitivity cs) const { - return qt_string_count(unicode(), size(), str.unicode(), str.size(), cs); + // ### Qt6: qsize + return int(qt_string_count(QStringView(unicode(), size()), QStringView(str.unicode(), str.size()), cs)); } /*! @@ -4338,8 +4226,9 @@ int QString::count(const QString &str, Qt::CaseSensitivity cs) const int QString::count(QChar ch, Qt::CaseSensitivity cs) const { - return qt_string_count(unicode(), size(), ch, cs); - } + // ### Qt6: qsize + return int(qt_string_count(QStringView(unicode(), size()), ch, cs)); +} /*! \since 4.8 @@ -4354,7 +4243,8 @@ int QString::count(QChar ch, Qt::CaseSensitivity cs) const */ int QString::count(const QStringRef &str, Qt::CaseSensitivity cs) const { - return qt_string_count(unicode(), size(), str.unicode(), str.size(), cs); + // ### Qt6: qsize + return int(qt_string_count(QStringView(unicode(), size()), QStringView(str.unicode(), str.size()), cs)); } @@ -7782,10 +7672,10 @@ static ResultList splitString(const StringSource &source, const QChar *sep, QString::SplitBehavior behavior, Qt::CaseSensitivity cs, const int separatorSize) { ResultList list; - int start = 0; - int end; - int extra = 0; - while ((end = qFindString(source.constData(), source.size(), start + extra, sep, separatorSize, cs)) != -1) { + typename StringSource::size_type start = 0; + typename StringSource::size_type end; + typename StringSource::size_type extra = 0; + while ((end = QtPrivate::findString(QStringView(source.constData(), source.size()), start + extra, QStringView(sep, separatorSize), cs)) != -1) { if (start != end || behavior == QString::KeepEmptyParts) list.append(source.mid(start, end - start)); start = end + separatorSize; @@ -11158,7 +11048,8 @@ QStringRef QString::midRef(int position, int n) const */ int QStringRef::indexOf(const QString &str, int from, Qt::CaseSensitivity cs) const { - return qFindString(unicode(), length(), from, str.unicode(), str.length(), cs); + // ### Qt6: qsize + return int(QtPrivate::findString(QStringView(unicode(), length()), from, QStringView(str.unicode(), str.length()), cs)); } /*! @@ -11173,7 +11064,8 @@ int QStringRef::indexOf(const QString &str, int from, Qt::CaseSensitivity cs) co */ int QStringRef::indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const { - return findChar(unicode(), length(), ch, from, cs); + // ### Qt6: qsize + return int(QtPrivate::findChar(QStringView(unicode(), length()), ch, from, cs)); } /*! @@ -11193,7 +11085,8 @@ int QStringRef::indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const */ int QStringRef::indexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) const { - return qt_find_latin1_string(unicode(), size(), str, from, cs); + // ### Qt6: qsize + return int(QtPrivate::findString(QStringView(unicode(), size()), from, str, cs)); } /*! @@ -11212,7 +11105,8 @@ int QStringRef::indexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) con */ int QStringRef::indexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs) const { - return qFindString(unicode(), size(), from, str.unicode(), str.size(), cs); + // ### Qt6: qsize + return int(QtPrivate::findString(QStringView(unicode(), size()), from, QStringView(str.unicode(), str.size()), cs)); } /*! @@ -11245,7 +11139,8 @@ int QStringRef::lastIndexOf(const QString &str, int from, Qt::CaseSensitivity cs */ int QStringRef::lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const { - return qt_last_index_of(unicode(), size(), ch, from, cs); + // ### Qt6: qsize + return int(qt_last_index_of(QStringView(unicode(), size()), ch, from, cs)); } template @@ -11321,7 +11216,8 @@ int QStringRef::lastIndexOf(const QStringRef &str, int from, Qt::CaseSensitivity */ int QStringRef::count(const QString &str, Qt::CaseSensitivity cs) const { - return qt_string_count(unicode(), size(), str.unicode(), str.size(), cs); + // ### Qt6: qsize + return int(qt_string_count(QStringView(unicode(), size()), QStringView(str.unicode(), str.size()), cs)); } /*! @@ -11338,7 +11234,8 @@ int QStringRef::count(const QString &str, Qt::CaseSensitivity cs) const */ int QStringRef::count(QChar ch, Qt::CaseSensitivity cs) const { - return qt_string_count(unicode(), size(), ch, cs); + // ### Qt6: qsize + return int(qt_string_count(QStringView(unicode(), size()), ch, cs)); } /*! @@ -11355,7 +11252,8 @@ int QStringRef::count(QChar ch, Qt::CaseSensitivity cs) const */ int QStringRef::count(const QStringRef &str, Qt::CaseSensitivity cs) const { - return qt_string_count(unicode(), size(), str.unicode(), str.size(), cs); + // ### Qt6: qsize + return int(qt_string_count(QStringView(unicode(), size()), QStringView(str.unicode(), str.size()), cs)); } /*! @@ -11592,16 +11490,16 @@ bool QStringRef::endsWith(const QStringRef &str, Qt::CaseSensitivity cs) const \sa indexOf(), count() */ -static inline int qt_last_index_of(const QChar *haystack, int haystackLen, QChar needle, - int from, Qt::CaseSensitivity cs) +static inline qsizetype qt_last_index_of(QStringView haystack, QChar needle, + qsizetype from, Qt::CaseSensitivity cs) { - ushort c = needle.unicode(); if (from < 0) - from += haystackLen; - if (uint(from) >= uint(haystackLen)) + from += haystack.size(); + if (std::size_t(from) >= std::size_t(haystack.size())) return -1; if (from >= 0) { - const ushort *b = reinterpret_cast(haystack); + ushort c = needle.unicode(); + const ushort *b = reinterpret_cast(haystack.data()); const ushort *n = b + from; if (cs == Qt::CaseSensitive) { for (; n >= b; --n) @@ -11619,30 +11517,28 @@ static inline int qt_last_index_of(const QChar *haystack, int haystackLen, QChar } -static inline int qt_string_count(const QChar *haystack, int haystackLen, - const QChar *needle, int needleLen, - Qt::CaseSensitivity cs) +static inline qsizetype qt_string_count(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs) { - int num = 0; - int i = -1; - if (haystackLen > 500 && needleLen > 5) { - QStringMatcher matcher(needle, needleLen, cs); - while ((i = matcher.indexIn(haystack, haystackLen, i + 1)) != -1) + qsizetype num = 0; + qsizetype i = -1; + if (haystack.size() > 500 && needle.size() > 5) { + QStringMatcher matcher(needle, cs); + while ((i = matcher.indexIn(haystack, i + 1)) != -1) ++num; } else { - while ((i = qFindString(haystack, haystackLen, i + 1, needle, needleLen, cs)) != -1) + while ((i = QtPrivate::findString(haystack, i + 1, needle, cs)) != -1) ++num; } return num; } -static inline int qt_string_count(const QChar *unicode, int size, QChar ch, +static inline qsizetype qt_string_count(QStringView haystack, QChar ch, Qt::CaseSensitivity cs) { ushort c = ch.unicode(); - int num = 0; - const ushort *b = reinterpret_cast(unicode); - const ushort *i = b + size; + qsizetype num = 0; + const ushort *b = reinterpret_cast(haystack.data()); + const ushort *i = b + haystack.size(); if (cs == Qt::CaseSensitive) { while (i != b) if (*--i == c) @@ -11656,22 +11552,6 @@ static inline int qt_string_count(const QChar *unicode, int size, QChar ch, return num; } -static inline int qt_find_latin1_string(const QChar *haystack, int size, - QLatin1String needle, - int from, Qt::CaseSensitivity cs) -{ - if (size < needle.size()) - return -1; - - const char *latin1 = needle.latin1(); - int len = needle.size(); - QVarLengthArray s(len); - qt_from_latin1(s.data(), latin1, len); - - return qFindString(haystack, size, from, - reinterpret_cast(s.constData()), len, cs); -} - template bool qt_starts_with_impl(Haystack haystack, Needle needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW { @@ -11818,6 +11698,127 @@ bool QtPrivate::endsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseS return qt_ends_with_impl(haystack, needle, cs); } +/*! + \internal + + Returns the index position of the first occurrence of the + character \a ch in the string given by \a str and \a len, + searching forward from index + position \a from. Returns -1 if \a ch could not be found. +*/ + +qsizetype QtPrivate::findChar(QStringView str, QChar ch, qsizetype from, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +{ + if (from < 0) + from = qMax(from + str.size(), qsizetype(0)); + if (from < str.size()) { + const ushort *s = (const ushort *)str.data(); + ushort c = ch.unicode(); + const ushort *n = s + from; + const ushort *e = s + str.size(); + if (cs == Qt::CaseSensitive) { + n = QtPrivate::qustrchr(QStringView(n, e), c); + if (n != e) + return n - s; + } else { + c = foldCase(c); + --n; + while (++n != e) + if (foldCase(*n) == c) + return n - s; + } + } + return -1; +} + +qsizetype QtPrivate::findString(QStringView haystack0, qsizetype from, QStringView needle0, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +{ + const qsizetype l = haystack0.size(); + const qsizetype sl = needle0.size(); + if (from < 0) + from += l; + if (std::size_t(sl + from) > std::size_t(l)) + return -1; + if (!sl) + return from; + if (!l) + return -1; + + if (sl == 1) + return QtPrivate::findChar(haystack0, needle0[0], from, cs); + + /* + We use the Boyer-Moore algorithm in cases where the overhead + for the skip table should pay off, otherwise we use a simple + hash function. + */ + if (l > 500 && sl > 5) + return qFindStringBoyerMoore(haystack0, from, needle0, cs); + + auto sv = [sl](const ushort *v) { return QStringView(v, sl); }; + /* + We use some hashing for efficiency's sake. Instead of + comparing strings, we compare the hash value of str with that + of a part of this QString. Only if that matches, we call + qt_string_compare(). + */ + const ushort *needle = (const ushort *)needle0.data(); + const ushort *haystack = (const ushort *)(haystack0.data()) + from; + const ushort *end = (const ushort *)(haystack0.data()) + (l - sl); + const std::size_t sl_minus_1 = sl - 1; + std::size_t hashNeedle = 0, hashHaystack = 0; + qsizetype idx; + + if (cs == Qt::CaseSensitive) { + for (idx = 0; idx < sl; ++idx) { + hashNeedle = ((hashNeedle<<1) + needle[idx]); + hashHaystack = ((hashHaystack<<1) + haystack[idx]); + } + hashHaystack -= haystack[sl_minus_1]; + + while (haystack <= end) { + hashHaystack += haystack[sl_minus_1]; + if (hashHaystack == hashNeedle + && qt_compare_strings(needle0, sv(haystack), Qt::CaseSensitive) == 0) + return haystack - (const ushort *)haystack0.data(); + + REHASH(*haystack); + ++haystack; + } + } else { + const ushort *haystack_start = (const ushort *)haystack0.data(); + for (idx = 0; idx < sl; ++idx) { + hashNeedle = (hashNeedle<<1) + foldCase(needle + idx, needle); + hashHaystack = (hashHaystack<<1) + foldCase(haystack + idx, haystack_start); + } + hashHaystack -= foldCase(haystack + sl_minus_1, haystack_start); + + while (haystack <= end) { + hashHaystack += foldCase(haystack + sl_minus_1, haystack_start); + if (hashHaystack == hashNeedle + && qt_compare_strings(needle0, sv(haystack), Qt::CaseInsensitive) == 0) + return haystack - (const ushort *)haystack0.data(); + + REHASH(foldCase(haystack, haystack_start)); + ++haystack; + } + } + return -1; +} + +qsizetype QtPrivate::findString(QStringView haystack, qsizetype from, QLatin1String needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +{ + if (haystack.size() < needle.size()) + return -1; + + const char *latin1 = needle.latin1(); + const qsizetype len = needle.size(); + QVarLengthArray s(len); + qt_from_latin1(s.data(), latin1, len); + + return QtPrivate::findString(haystack, from, QStringView(reinterpret_cast(s.constData()), len), cs); +} + /*! \since 4.8 diff --git a/src/corelib/tools/qstringalgorithms.h b/src/corelib/tools/qstringalgorithms.h index cc0eda71f3..e94f725598 100644 --- a/src/corelib/tools/qstringalgorithms.h +++ b/src/corelib/tools/qstringalgorithms.h @@ -51,6 +51,7 @@ QT_BEGIN_NAMESPACE class QByteArray; class QLatin1String; class QStringView; +class QChar; template class QVector; namespace QtPrivate { @@ -74,6 +75,10 @@ Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QStringView Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findChar(QStringView str, QChar ch, qsizetype from, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findString(QStringView haystack, qsizetype from, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findString(QStringView haystack, qsizetype from, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; + Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION QStringView trimmed(QStringView s) Q_DECL_NOTHROW; Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION QLatin1String trimmed(QLatin1String s) Q_DECL_NOTHROW; diff --git a/src/corelib/tools/qstringmatcher.cpp b/src/corelib/tools/qstringmatcher.cpp index b99c113d52..417910b6ec 100644 --- a/src/corelib/tools/qstringmatcher.cpp +++ b/src/corelib/tools/qstringmatcher.cpp @@ -42,43 +42,43 @@ QT_BEGIN_NAMESPACE -static void bm_init_skiptable(const ushort *uc, int len, uchar *skiptable, Qt::CaseSensitivity cs) +static void bm_init_skiptable(const ushort *uc, qsizetype len, uchar *skiptable, Qt::CaseSensitivity cs) { - int l = qMin(len, 255); - memset(skiptable, l, 256*sizeof(uchar)); + int l = int(qMin(len, qsizetype(255))); + memset(skiptable, l, 256 * sizeof(uchar)); uc += len - l; if (cs == Qt::CaseSensitive) { while (l--) { skiptable[*uc & 0xff] = l; - uc++; + ++uc; } } else { const ushort *start = uc; while (l--) { skiptable[foldCase(uc, start) & 0xff] = l; - uc++; + ++uc; } } } -static inline int bm_find(const ushort *uc, uint l, int index, const ushort *puc, uint pl, +static inline qsizetype bm_find(const ushort *uc, qsizetype l, qsizetype index, const ushort *puc, qsizetype pl, const uchar *skiptable, Qt::CaseSensitivity cs) { if (pl == 0) - return index > (int)l ? -1 : index; - const uint pl_minus_one = pl - 1; + return index > l ? -1 : index; + const qsizetype pl_minus_one = pl - 1; const ushort *current = uc + index + pl_minus_one; const ushort *end = uc + l; if (cs == Qt::CaseSensitive) { while (current < end) { - uint skip = skiptable[*current & 0xff]; + qsizetype skip = skiptable[*current & 0xff]; if (!skip) { // possible match while (skip < pl) { if (*(current - skip) != puc[pl_minus_one-skip]) break; - skip++; + ++skip; } if (skip > pl_minus_one) // we have a match return (current - uc) - pl_minus_one; @@ -96,13 +96,13 @@ static inline int bm_find(const ushort *uc, uint l, int index, const ushort *puc } } else { while (current < end) { - uint skip = skiptable[foldCase(current, uc) & 0xff]; + qsizetype skip = skiptable[foldCase(current, uc) & 0xff]; if (!skip) { // possible match while (skip < pl) { if (foldCase(current - skip, uc) != foldCase(puc + pl_minus_one - skip, puc)) break; - skip++; + ++skip; } if (skip > pl_minus_one) // we have a match return (current - uc) - pl_minus_one; @@ -333,16 +333,16 @@ qsizetype QStringMatcher::indexIn(QStringView str, qsizetype from) const \internal */ -int qFindStringBoyerMoore( - const QChar *haystack, int haystackLen, int haystackOffset, - const QChar *needle, int needleLen, Qt::CaseSensitivity cs) +qsizetype qFindStringBoyerMoore( + QStringView haystack, qsizetype haystackOffset, + QStringView needle, Qt::CaseSensitivity cs) { uchar skiptable[256]; - bm_init_skiptable((const ushort *)needle, needleLen, skiptable, cs); + bm_init_skiptable((const ushort *)needle.data(), needle.size(), skiptable, cs); if (haystackOffset < 0) haystackOffset = 0; - return bm_find((const ushort *)haystack, haystackLen, haystackOffset, - (const ushort *)needle, needleLen, skiptable, cs); + return bm_find((const ushort *)haystack.data(), haystack.size(), haystackOffset, + (const ushort *)needle.data(), needle.size(), skiptable, cs); } QT_END_NAMESPACE From 1e70781e7f0b012fcfbf85f86c24f3b46e362d4e Mon Sep 17 00:00:00 2001 From: Milian Wolff Date: Fri, 22 Mar 2019 11:18:14 +0100 Subject: [PATCH 105/292] Stabilize tst_QStateMachine::dontProcessSlotsWhenMachineIsNotRunning The test is flaky which was uncovered by the upcoming QTimer::singleShot optimization patches: When the Emitter's thread is started and executes the timout functor before the state machine is started, then the state machine will never see the emitSignalWithNoArg signal and thus never transition to the final state and finish. This patch ensures that the code in the background thread is only run after the state machine was started to fix this flakyness. Change-Id: I6f91a2420165662ece75e550a6d73fe098137d4c Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Kari Oikarinen --- .../statemachine/qstatemachine/tst_qstatemachine.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp index 810698fb4e..55a672aae1 100644 --- a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp @@ -6680,13 +6680,13 @@ void tst_QStateMachine::dontProcessSlotsWhenMachineIsNotRunning() } emitter; initialState.addTransition(&emitter, &Emitter::signalWithNoArg, &finalState); - QTimer::singleShot(0, [&]() { - metaObject()->invokeMethod(&emitter, "emitSignalWithNoArg"); - metaObject()->invokeMethod(&emitter, "emitSignalWithNoArg"); - }); machine.addState(&initialState); machine.addState(&finalState); machine.setInitialState(&initialState); + connect(&machine, &QStateMachine::started, &emitter, [&]() { + metaObject()->invokeMethod(&emitter, "emitSignalWithNoArg"); + metaObject()->invokeMethod(&emitter, "emitSignalWithNoArg"); + }); connect(&machine, &QStateMachine::finished, &emitter.thread, &QThread::quit); machine.start(); QSignalSpy emittedSpy(&emitter, &SignalEmitter::signalWithNoArg); From 461e89ee1a53f7669e0215f9015380c4a9d62371 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 24 Oct 2018 16:49:45 +0200 Subject: [PATCH 106/292] Clean up QTextStream functions They are the only Qt symbols neither prefixed with q or with the Qt namespace. This changes preserves source and binary compatibility while making it possible to define conflicting symbols. Change-Id: I6d4181206e63faa922fa0c8b644e0a4b88826a97 Reviewed-by: Ulf Hermann --- src/corelib/serialization/qtextstream.cpp | 100 +++++++++++++----- src/corelib/serialization/qtextstream.h | 19 ++++ .../qtextstream/tst_qtextstream.cpp | 93 ++++++++-------- 3 files changed, 143 insertions(+), 69 deletions(-) diff --git a/src/corelib/serialization/qtextstream.cpp b/src/corelib/serialization/qtextstream.cpp index c9ba183a50..0d83bb6cd4 100644 --- a/src/corelib/serialization/qtextstream.cpp +++ b/src/corelib/serialization/qtextstream.cpp @@ -135,30 +135,30 @@ static const int QTEXTSTREAM_BUFFERSIZE = 16384; \table \header \li Manipulator \li Description - \row \li \c bin \li Same as setIntegerBase(2). - \row \li \c oct \li Same as setIntegerBase(8). - \row \li \c dec \li Same as setIntegerBase(10). - \row \li \c hex \li Same as setIntegerBase(16). - \row \li \c showbase \li Same as setNumberFlags(numberFlags() | ShowBase). - \row \li \c forcesign \li Same as setNumberFlags(numberFlags() | ForceSign). - \row \li \c forcepoint \li Same as setNumberFlags(numberFlags() | ForcePoint). - \row \li \c noshowbase \li Same as setNumberFlags(numberFlags() & ~ShowBase). - \row \li \c noforcesign \li Same as setNumberFlags(numberFlags() & ~ForceSign). - \row \li \c noforcepoint \li Same as setNumberFlags(numberFlags() & ~ForcePoint). - \row \li \c uppercasebase \li Same as setNumberFlags(numberFlags() | UppercaseBase). - \row \li \c uppercasedigits \li Same as setNumberFlags(numberFlags() | UppercaseDigits). - \row \li \c lowercasebase \li Same as setNumberFlags(numberFlags() & ~UppercaseBase). - \row \li \c lowercasedigits \li Same as setNumberFlags(numberFlags() & ~UppercaseDigits). - \row \li \c fixed \li Same as setRealNumberNotation(FixedNotation). - \row \li \c scientific \li Same as setRealNumberNotation(ScientificNotation). - \row \li \c left \li Same as setFieldAlignment(AlignLeft). - \row \li \c right \li Same as setFieldAlignment(AlignRight). - \row \li \c center \li Same as setFieldAlignment(AlignCenter). - \row \li \c endl \li Same as operator<<('\\n') and flush(). - \row \li \c flush \li Same as flush(). - \row \li \c reset \li Same as reset(). - \row \li \c ws \li Same as skipWhiteSpace(). - \row \li \c bom \li Same as setGenerateByteOrderMark(true). + \row \li \c Qt::bin \li Same as setIntegerBase(2). + \row \li \c Qt::oct \li Same as setIntegerBase(8). + \row \li \c Qt::dec \li Same as setIntegerBase(10). + \row \li \c Qt::hex \li Same as setIntegerBase(16). + \row \li \c Qt::showbase \li Same as setNumberFlags(numberFlags() | ShowBase). + \row \li \c Qt::forcesign \li Same as setNumberFlags(numberFlags() | ForceSign). + \row \li \c Qt::forcepoint \li Same as setNumberFlags(numberFlags() | ForcePoint). + \row \li \c Qt::noshowbase \li Same as setNumberFlags(numberFlags() & ~ShowBase). + \row \li \c Qt::noforcesign \li Same as setNumberFlags(numberFlags() & ~ForceSign). + \row \li \c Qt::noforcepoint \li Same as setNumberFlags(numberFlags() & ~ForcePoint). + \row \li \c Qt::uppercasebase \li Same as setNumberFlags(numberFlags() | UppercaseBase). + \row \li \c Qt::uppercasedigits \li Same as setNumberFlags(numberFlags() | UppercaseDigits). + \row \li \c Qt::lowercasebase \li Same as setNumberFlags(numberFlags() & ~UppercaseBase). + \row \li \c Qt::lowercasedigits \li Same as setNumberFlags(numberFlags() & ~UppercaseDigits). + \row \li \c Qt::fixed \li Same as setRealNumberNotation(FixedNotation). + \row \li \c Qt::scientific \li Same as setRealNumberNotation(ScientificNotation). + \row \li \c Qt::left \li Same as setFieldAlignment(AlignLeft). + \row \li \c Qt::right \li Same as setFieldAlignment(AlignRight). + \row \li \c Qt::center \li Same as setFieldAlignment(AlignCenter). + \row \li \c Qt::endl \li Same as operator<<('\\n') and flush(). + \row \li \c Qt::flush \li Same as flush(). + \row \li \c Qt::reset \li Same as reset(). + \row \li \c Qt::ws \li Same as skipWhiteSpace(). + \row \li \c Qt::bom \li Same as setGenerateByteOrderMark(true). \endtable In addition, Qt provides three global manipulators that take a @@ -2689,6 +2689,11 @@ QTextStream &QTextStream::operator<<(const void *ptr) d->params.numberFlags = oldFlags; return *this; } +#if defined(Q_QDOC) || QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +namespace Qt { +#else +namespace QTextStreamFunctions { +#endif /*! \relates QTextStream @@ -3015,6 +3020,8 @@ QTextStream &ws(QTextStream &stream) return stream; } +} // namespace QTextStreamFunctions + /*! \fn QTextStreamManipulator qSetFieldWidth(int width) \relates QTextStream @@ -3037,6 +3044,12 @@ QTextStream &ws(QTextStream &stream) */ #if QT_CONFIG(textcodec) + +#if defined(Q_QDOC) || QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +namespace Qt { +#else +namespace QTextStreamFunctions { +#endif /*! \relates QTextStream @@ -3051,6 +3064,8 @@ QTextStream &bom(QTextStream &stream) return stream; } +} // namespace QTextStreamFunctions + /*! Sets the codec for this stream to \a codec. The codec is used for decoding any data that is read from the assigned device, and for @@ -3200,6 +3215,43 @@ QLocale QTextStream::locale() const return d->locale; } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && !defined(Q_QDOC) +// Binary compatible definitions for Qt<5.14 +Q_CORE_EXPORT QTextStream &bin(QTextStream &s) { return Qt::bin(s); } +Q_CORE_EXPORT QTextStream &oct(QTextStream &s) { return Qt::oct(s); } +Q_CORE_EXPORT QTextStream &dec(QTextStream &s) { return Qt::dec(s); } +Q_CORE_EXPORT QTextStream &hex(QTextStream &s) { return Qt::hex(s); } + +Q_CORE_EXPORT QTextStream &showbase(QTextStream &s) { return Qt::showbase(s); } +Q_CORE_EXPORT QTextStream &forcesign(QTextStream &s) { return Qt::forcesign(s); } +Q_CORE_EXPORT QTextStream &forcepoint(QTextStream &s) { return Qt::forcepoint(s); } +Q_CORE_EXPORT QTextStream &noshowbase(QTextStream &s) { return Qt::noshowbase(s); } +Q_CORE_EXPORT QTextStream &noforcesign(QTextStream &s) { return Qt::noforcesign(s); } +Q_CORE_EXPORT QTextStream &noforcepoint(QTextStream &s) { return Qt::noforcepoint(s); } + +Q_CORE_EXPORT QTextStream &uppercasebase(QTextStream &s) { return Qt::uppercasebase(s); } +Q_CORE_EXPORT QTextStream &uppercasedigits(QTextStream &s) { return Qt::uppercasedigits(s); } +Q_CORE_EXPORT QTextStream &lowercasebase(QTextStream &s) { return Qt::lowercasebase(s); } +Q_CORE_EXPORT QTextStream &lowercasedigits(QTextStream &s) { return Qt::lowercasedigits(s); } + +Q_CORE_EXPORT QTextStream &fixed(QTextStream &s) { return Qt::fixed(s); } +Q_CORE_EXPORT QTextStream &scientific(QTextStream &s) { return Qt::scientific(s); } + +Q_CORE_EXPORT QTextStream &left(QTextStream &s) { return Qt::left(s); } +Q_CORE_EXPORT QTextStream &right(QTextStream &s) { return Qt::right(s); } +Q_CORE_EXPORT QTextStream ¢er(QTextStream &s) { return Qt::center(s); } + +Q_CORE_EXPORT QTextStream &endl(QTextStream &s) { return Qt::endl(s); } +Q_CORE_EXPORT QTextStream &flush(QTextStream &s) { return Qt::flush(s); } +Q_CORE_EXPORT QTextStream &reset(QTextStream &s) { return Qt::reset(s); } + +Q_CORE_EXPORT QTextStream &ws(QTextStream &s) { return Qt::ws(s); } + +#if QT_CONFIG(textcodec) +Q_CORE_EXPORT QTextStream &bom(QTextStream &s) { return Qt::bom(s); } +#endif +#endif + QT_END_NAMESPACE #ifndef QT_NO_QOBJECT diff --git a/src/corelib/serialization/qtextstream.h b/src/corelib/serialization/qtextstream.h index 1d86a18b9c..7673e5d87e 100644 --- a/src/corelib/serialization/qtextstream.h +++ b/src/corelib/serialization/qtextstream.h @@ -233,6 +233,13 @@ inline QTextStream &operator<<(QTextStream &s, QTextStreamFunction f) inline QTextStream &operator<<(QTextStream &s, QTextStreamManipulator m) { m.exec(s); return s; } +#if defined(Q_QDOC) || QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +namespace Qt { +#else +// This namespace only exists for 'using namespace' declarations. +namespace QTextStreamFunctions { +#endif + Q_CORE_EXPORT QTextStream &bin(QTextStream &s); Q_CORE_EXPORT QTextStream &oct(QTextStream &s); Q_CORE_EXPORT QTextStream &dec(QTextStream &s); @@ -265,6 +272,18 @@ Q_CORE_EXPORT QTextStream &bom(QTextStream &s); Q_CORE_EXPORT QTextStream &ws(QTextStream &s); +} // namespace QTextStreamFunctions + +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && !defined(Q_QDOC) +namespace Qt { +using namespace QTextStreamFunctions; +} + +// We use 'using namespace' as that doesn't cause +// conflicting definitions compiler errors. +using namespace QTextStreamFunctions; +#endif // QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && !defined(Q_QDOC) + inline QTextStreamManipulator qSetFieldWidth(int width) { QTSMFI func = &QTextStream::setFieldWidth; diff --git a/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp index 8bb35554c8..af97d4a003 100644 --- a/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp @@ -1102,7 +1102,7 @@ void tst_QTextStream::hexTest() QByteArray array; QTextStream stream(&array); - stream << showbase << hex << number; + stream << Qt::showbase << Qt::hex << number; stream.flush(); QCOMPARE(array, data); } @@ -1132,7 +1132,7 @@ void tst_QTextStream::binTest() QByteArray array; QTextStream stream(&array); - stream << showbase << bin << number; + stream << Qt::showbase << Qt::bin << number; stream.flush(); QCOMPARE(array.constData(), data.constData()); } @@ -1155,7 +1155,7 @@ void tst_QTextStream::octTest() QByteArray array; QTextStream stream(&array); - stream << showbase << oct << number; + stream << Qt::showbase << Qt::oct << number; stream.flush(); QCOMPARE(array, data); } @@ -1196,7 +1196,7 @@ void tst_QTextStream::ws_manipulator() QTextStream stream(&string); char a, b, c, d; - stream >> a >> ws >> b >> ws >> c >> ws >> d; + stream >> a >> Qt::ws >> b >> Qt::ws >> c >> Qt::ws >> d; QCOMPARE(a, 'a'); QCOMPARE(b, 'b'); QCOMPARE(c, 'c'); @@ -1623,18 +1623,18 @@ void tst_QTextStream::forcePoint() { QString str; QTextStream stream(&str); - stream << fixed << forcepoint << 1.0 << ' ' << 1 << ' ' << 0 << ' ' << -1.0 << ' ' << -1; + stream << Qt::fixed << Qt::forcepoint << 1.0 << ' ' << 1 << ' ' << 0 << ' ' << -1.0 << ' ' << -1; QCOMPARE(str, QString("1.000000 1 0 -1.000000 -1")); str.clear(); stream.seek(0); - stream << scientific << forcepoint << 1.0 << ' ' << 1 << ' ' << 0 << ' ' << -1.0 << ' ' << -1; + stream << Qt::scientific << Qt::forcepoint << 1.0 << ' ' << 1 << ' ' << 0 << ' ' << -1.0 << ' ' << -1; QCOMPARE(str, QString("1.000000e+00 1 0 -1.000000e+00 -1")); str.clear(); stream.seek(0); stream.setRealNumberNotation(QTextStream::SmartNotation); - stream << forcepoint << 1.0 << ' ' << 1 << ' ' << 0 << ' ' << -1.0 << ' ' << -1; + stream << Qt::forcepoint << 1.0 << ' ' << 1 << ' ' << 0 << ' ' << -1.0 << ' ' << -1; QCOMPARE(str, QString("1.00000 1 0 -1.00000 -1")); } @@ -1644,7 +1644,7 @@ void tst_QTextStream::forceSign() { QString str; QTextStream stream(&str); - stream << forcesign << 1.2 << ' ' << -1.2 << ' ' << 0; + stream << Qt::forcesign << 1.2 << ' ' << -1.2 << ' ' << 0; QCOMPARE(str, QString("+1.2 -1.2 +0")); } @@ -1663,19 +1663,22 @@ void tst_QTextStream::read0d0d0a() Q_DECLARE_METATYPE(QTextStreamFunction); +// Also tests that we can have namespaces that conflict with our QTextStream constants. +namespace ws { QTextStream &noop(QTextStream &s) { return s; } +} void tst_QTextStream::numeralCase_data() { - QTextStreamFunction noop_ = noop; - QTextStreamFunction bin_ = bin; - QTextStreamFunction oct_ = oct; - QTextStreamFunction hex_ = hex; - QTextStreamFunction base = showbase; - QTextStreamFunction ucb = uppercasebase; - QTextStreamFunction lcb = lowercasebase; - QTextStreamFunction ucd = uppercasedigits; - QTextStreamFunction lcd = lowercasedigits; + QTextStreamFunction noop_ = ws::noop; + QTextStreamFunction bin = Qt::bin; + QTextStreamFunction oct = Qt::oct; + QTextStreamFunction hex = Qt::hex; + QTextStreamFunction base = Qt::showbase; + QTextStreamFunction ucb = Qt::uppercasebase; + QTextStreamFunction lcb = Qt::lowercasebase; + QTextStreamFunction ucd = Qt::uppercasedigits; + QTextStreamFunction lcd = Qt::lowercasedigits; QTest::addColumn("func1"); QTest::addColumn("func2"); @@ -1686,30 +1689,30 @@ void tst_QTextStream::numeralCase_data() QTest::newRow("dec 1") << noop_ << noop_ << noop_ << noop_ << 31 << "31"; QTest::newRow("dec 2") << noop_ << base << noop_ << noop_ << 31 << "31"; - QTest::newRow("hex 1") << hex_ << noop_ << noop_ << noop_ << 31 << "1f"; - QTest::newRow("hex 2") << hex_ << noop_ << noop_ << lcd << 31 << "1f"; - QTest::newRow("hex 3") << hex_ << noop_ << ucb << noop_ << 31 << "1f"; - QTest::newRow("hex 4") << hex_ << noop_ << noop_ << ucd << 31 << "1F"; - QTest::newRow("hex 5") << hex_ << noop_ << lcb << ucd << 31 << "1F"; - QTest::newRow("hex 6") << hex_ << noop_ << ucb << ucd << 31 << "1F"; - QTest::newRow("hex 7") << hex_ << base << noop_ << noop_ << 31 << "0x1f"; - QTest::newRow("hex 8") << hex_ << base << lcb << lcd << 31 << "0x1f"; - QTest::newRow("hex 9") << hex_ << base << ucb << noop_ << 31 << "0X1f"; - QTest::newRow("hex 10") << hex_ << base << ucb << lcd << 31 << "0X1f"; - QTest::newRow("hex 11") << hex_ << base << noop_ << ucd << 31 << "0x1F"; - QTest::newRow("hex 12") << hex_ << base << lcb << ucd << 31 << "0x1F"; - QTest::newRow("hex 13") << hex_ << base << ucb << ucd << 31 << "0X1F"; + QTest::newRow("hex 1") << hex << noop_ << noop_ << noop_ << 31 << "1f"; + QTest::newRow("hex 2") << hex << noop_ << noop_ << lcd << 31 << "1f"; + QTest::newRow("hex 3") << hex << noop_ << ucb << noop_ << 31 << "1f"; + QTest::newRow("hex 4") << hex << noop_ << noop_ << ucd << 31 << "1F"; + QTest::newRow("hex 5") << hex << noop_ << lcb << ucd << 31 << "1F"; + QTest::newRow("hex 6") << hex << noop_ << ucb << ucd << 31 << "1F"; + QTest::newRow("hex 7") << hex << base << noop_ << noop_ << 31 << "0x1f"; + QTest::newRow("hex 8") << hex << base << lcb << lcd << 31 << "0x1f"; + QTest::newRow("hex 9") << hex << base << ucb << noop_ << 31 << "0X1f"; + QTest::newRow("hex 10") << hex << base << ucb << lcd << 31 << "0X1f"; + QTest::newRow("hex 11") << hex << base << noop_ << ucd << 31 << "0x1F"; + QTest::newRow("hex 12") << hex << base << lcb << ucd << 31 << "0x1F"; + QTest::newRow("hex 13") << hex << base << ucb << ucd << 31 << "0X1F"; - QTest::newRow("bin 1") << bin_ << noop_ << noop_ << noop_ << 31 << "11111"; - QTest::newRow("bin 2") << bin_ << base << noop_ << noop_ << 31 << "0b11111"; - QTest::newRow("bin 3") << bin_ << base << lcb << noop_ << 31 << "0b11111"; - QTest::newRow("bin 4") << bin_ << base << ucb << noop_ << 31 << "0B11111"; - QTest::newRow("bin 5") << bin_ << base << noop_ << ucd << 31 << "0b11111"; - QTest::newRow("bin 6") << bin_ << base << lcb << ucd << 31 << "0b11111"; - QTest::newRow("bin 7") << bin_ << base << ucb << ucd << 31 << "0B11111"; + QTest::newRow("bin 1") << bin << noop_ << noop_ << noop_ << 31 << "11111"; + QTest::newRow("bin 2") << bin << base << noop_ << noop_ << 31 << "0b11111"; + QTest::newRow("bin 3") << bin << base << lcb << noop_ << 31 << "0b11111"; + QTest::newRow("bin 4") << bin << base << ucb << noop_ << 31 << "0B11111"; + QTest::newRow("bin 5") << bin << base << noop_ << ucd << 31 << "0b11111"; + QTest::newRow("bin 6") << bin << base << lcb << ucd << 31 << "0b11111"; + QTest::newRow("bin 7") << bin << base << ucb << ucd << 31 << "0B11111"; - QTest::newRow("oct 1") << oct_ << noop_ << noop_ << noop_ << 31 << "37"; - QTest::newRow("oct 2") << oct_ << base << noop_ << noop_ << 31 << "037"; + QTest::newRow("oct 1") << oct << noop_ << noop_ << noop_ << 31 << "37"; + QTest::newRow("oct 2") << oct << base << noop_ << noop_ << 31 << "037"; } void tst_QTextStream::numeralCase() @@ -1782,9 +1785,9 @@ void tst_QTextStream::nanInf() QString s; QTextStream out(&s); out << qInf() << ' ' << -qInf() << ' ' << qQNaN() - << uppercasedigits << ' ' + << Qt::uppercasedigits << ' ' << qInf() << ' ' << -qInf() << ' ' << qQNaN() - << flush; + << Qt::flush; QCOMPARE(s, QString("inf -inf nan INF -INF NAN")); } @@ -1859,9 +1862,9 @@ void tst_QTextStream::writeSeekWriteNoBOM() int number = 0; QString sizeStr = QLatin1String("Size=") + QString::number(number).rightJustified(10, QLatin1Char('0')); - stream << sizeStr << endl; - stream << "Version=" << QString::number(14) << endl; - stream << "blah blah blah" << endl; + stream << sizeStr << Qt::endl; + stream << "Version=" << QString::number(14) << Qt::endl; + stream << "blah blah blah" << Qt::endl; stream.flush(); QCOMPARE(out.buffer().constData(), "Size=0000000000\nVersion=14\nblah blah blah\n"); @@ -1871,7 +1874,7 @@ void tst_QTextStream::writeSeekWriteNoBOM() stream.seek(0); sizeStr = QLatin1String("Size=") + QString::number(number).rightJustified(10, QLatin1Char('0')); - stream << sizeStr << endl; + stream << sizeStr << Qt::endl; stream.flush(); // Check buffer is still OK From 4054759aecd06313a775c8c71748ec52ca7dc27d Mon Sep 17 00:00:00 2001 From: Mikhail Svetkin Date: Fri, 8 Mar 2019 15:38:33 +0100 Subject: [PATCH 107/292] core: Add deduction guides for QPair [ChangeLog][QtCore] Added support of deduction guides for QPair Change-Id: I41a798390dc2c925b0f8432ba12aa345724de2d7 Reviewed-by: Martin Smith Reviewed-by: Thiago Macieira Reviewed-by: Ville Voutilainen --- src/corelib/tools/qpair.h | 5 ++++ tests/auto/corelib/tools/qpair/qpair.pro | 3 +++ tests/auto/corelib/tools/qpair/tst_qpair.cpp | 26 ++++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/src/corelib/tools/qpair.h b/src/corelib/tools/qpair.h index 94977fc826..1af43d0a68 100644 --- a/src/corelib/tools/qpair.h +++ b/src/corelib/tools/qpair.h @@ -97,6 +97,11 @@ struct QPair T2 second; }; +#if defined(__cpp_deduction_guides) && __cpp_deduction_guides >= 201606 +template +QPair(T1, T2) -> QPair; +#endif + template void swap(QPair &lhs, QPair &rhs) Q_DECL_NOEXCEPT_EXPR(noexcept(lhs.swap(rhs))) { lhs.swap(rhs); } diff --git a/tests/auto/corelib/tools/qpair/qpair.pro b/tests/auto/corelib/tools/qpair/qpair.pro index 659be887d3..d684a24a57 100644 --- a/tests/auto/corelib/tools/qpair/qpair.pro +++ b/tests/auto/corelib/tools/qpair/qpair.pro @@ -2,3 +2,6 @@ CONFIG += testcase TARGET = tst_qpair QT = core testlib SOURCES = tst_qpair.cpp + +# Force C++17 if available (needed due to Q_COMPILER_DEDUCTION_GUIDES) +contains(QT_CONFIG, c++1z): CONFIG += c++1z diff --git a/tests/auto/corelib/tools/qpair/tst_qpair.cpp b/tests/auto/corelib/tools/qpair/tst_qpair.cpp index dedc353e67..3c972329bc 100644 --- a/tests/auto/corelib/tools/qpair/tst_qpair.cpp +++ b/tests/auto/corelib/tools/qpair/tst_qpair.cpp @@ -39,6 +39,7 @@ private Q_SLOTS: void testConstexpr(); void testConversions(); void taskQTBUG_48780_pairContainingCArray(); + void testDeducationRules(); }; class C { C() {} char _[4]; }; @@ -202,5 +203,30 @@ void tst_QPair::taskQTBUG_48780_pairContainingCArray() Q_UNUSED(pair); } +void tst_QPair::testDeducationRules() +{ +#if defined(__cpp_deduction_guides) && __cpp_deduction_guides >= 201606 + QPair p1{1, 2}; + static_assert(std::is_same::value); + static_assert(std::is_same::value); + QCOMPARE(p1.first, 1); + QCOMPARE(p1.second, 2); + + QPair p2{QString("string"), 2}; + static_assert(std::is_same::value); + static_assert(std::is_same::value); + QCOMPARE(p2.first, "string"); + QCOMPARE(p2.second, 2); + + QPair p3(p2); + static_assert(std::is_same::value); + static_assert(std::is_same::value); + QCOMPARE(p3.first, "string"); + QCOMPARE(p3.second, 2); +#else + QSKIP("Unsupported"); +#endif +} + QTEST_APPLESS_MAIN(tst_QPair) #include "tst_qpair.moc" From d0f016ebfb86fcebcf72c37c489260a0d02147e7 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 19 Mar 2019 17:31:56 +0100 Subject: [PATCH 108/292] Ensure that layouts don't move widgets outside of their parent When using a style that wants to draw into the layout's margin (like macOS style does with group box titles), parts of the widgets would be clipped by the parent if the available margin is smaller than necessary. This moves the x/y coordinates to at least 0/0, and adjusts width and height accordingly. [ChangeLog][QtWidgets][QLayout] Prevent clipping of group box titles on macOS (and similar styles that draw into layout margins) Change-Id: I32148a92858c13fb2325da4d0a2a58996e0e8930 Fixes: QTBUG-67608 Reviewed-by: Paul Olav Tvete --- src/widgets/kernel/qlayoutitem.cpp | 11 ++++ .../kernel/qboxlayout/tst_qboxlayout.cpp | 64 +++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp index 9e6d1c5eac..0aab0bb06d 100644 --- a/src/widgets/kernel/qlayoutitem.cpp +++ b/src/widgets/kernel/qlayoutitem.cpp @@ -502,6 +502,17 @@ void QWidgetItem::setGeometry(const QRect &rect) else if (!(align & Qt::AlignTop)) y = y + (r.height() - s.height()) / 2; + // Make sure we don't move outside of the parent, e.g when styles demand + // surplus space that exceeds the available margins (f.ex macOS with QGroupBox) + if (x < 0) { + s.rwidth() += x; + x = 0; + } + if (y < 0) { + s.rheight() += y; + y = 0; + } + wid->setGeometry(x, y, s.width(), s.height()); } diff --git a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp index b2650d1f32..fa9769a002 100644 --- a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp +++ b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp @@ -47,6 +47,7 @@ private slots: void sizeConstraints(); void setGeometry(); void setStyleShouldChangeSpacing(); + void widgetSurplus(); void testLayoutEngine_data(); void testLayoutEngine(); @@ -236,6 +237,69 @@ void tst_QBoxLayout::setStyleShouldChangeSpacing() QTRY_COMPARE(spacing(), 10); } +class MarginEatingStyle : public QProxyStyle +{ +public: + MarginEatingStyle() : QProxyStyle(QStyleFactory::create("windows")) + { + } + + virtual QRect subElementRect(SubElement sr, const QStyleOption *opt, + const QWidget *widget) const + { + QRect rect = opt->rect; + switch (sr) { + case SE_GroupBoxLayoutItem: + // this is a simplifed version of what the macOS style does + rect.setTop(rect.top() + 20); + rect.setLeft(rect.left() + 20); + rect.setRight(rect.right() - 20); + rect.setBottom(rect.bottom() - 20); + break; + default: + return QProxyStyle::subElementRect(sr, opt, widget); + } + + return rect; + } +}; + +void tst_QBoxLayout::widgetSurplus() +{ + // Test case for QTBUG-67608 - a style requests space in the margin + + QDialog window; + QScopedPointer marginEater(new MarginEatingStyle); + QVBoxLayout *vbox = new QVBoxLayout(&window); + vbox->setMargin(0); + vbox->setSpacing(0); + + QLabel *hiddenLabel = new QLabel(tr("Invisible label")); + hiddenLabel->setVisible(false); + + QGroupBox *groupBox = new QGroupBox(tr("Groupbox Title")); + groupBox->setStyle(marginEater.data()); + groupBox->setObjectName("Test group box"); + QPushButton *button1 = new QPushButton(tr("Button 1")); + QPushButton *button2 = new QPushButton(tr("Button 2")); + QVBoxLayout *groupLayout = new QVBoxLayout; + groupLayout->addWidget(button1); + groupLayout->addWidget(button2); + groupBox->setLayout(groupLayout); + + QLabel *label = new QLabel(tr("Visible label")); + + vbox->addWidget(hiddenLabel); + vbox->addWidget(groupBox); + vbox->addWidget(label); + window.setLayout(vbox); + + window.show(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + QCOMPARE(groupBox->y(), 0); + QCOMPARE(groupBox->x(), 0); +} + void tst_QBoxLayout::taskQTBUG_7103_minMaxWidthNotRespected() { QLabel *label = new QLabel("Qt uses standard C++, but makes extensive use of the C pre-processor to enrich the language. Qt can also be used in several other programming languages via language bindings. It runs on all major platforms, and has extensive internationalization support. Non-GUI features include SQL database access, XML parsing, thread management, network support and a unified cross-platform API for file handling."); From a57ac1b20e34decced0355935fe352eb55f51e5c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 18 Mar 2019 09:30:04 +0100 Subject: [PATCH 109/292] Add missing implementation of a QOpenGLTexture::setData() overload Change d15b02ff291e3124d9bb8ac3b06b704c292f52ab was missing the implementation of: void setData(int xOffset, int yOffset, int zOffset, int width, int height, int depth, int mipLevel, PixelFormat sourceFormat, PixelType sourceType, const void *data, const QOpenGLPixelTransferOptions * const options = nullptr); Change-Id: Ie0d1679cc54bc6bd6b51392a22707566d238845a Reviewed-by: Giuseppe D'Angelo --- src/gui/opengl/qopengltexture.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/gui/opengl/qopengltexture.cpp b/src/gui/opengl/qopengltexture.cpp index 1e4d627e2a..61a6202017 100644 --- a/src/gui/opengl/qopengltexture.cpp +++ b/src/gui/opengl/qopengltexture.cpp @@ -3523,6 +3523,35 @@ void QOpenGLTexture::setData(int xOffset, int yOffset, int zOffset, sourceType, data, options); } +/*! + \since 5.14 + \overload + + This overload is to be used to update a part of the texture. Parameters \a + xOffset, \a yOffset, \a zOffset specify the texel offsets within the + texture. Parameters \a width, \a height and \a depth specify the dimensions + of the sub image. The mip map level the sub image we want to + update is specified with \a mipLevel. + + The structure of the pixel data pointed to by \a data is specified by \a + sourceFormat and \a sourceType. The pixel data upload can optionally be + controlled by \a options. +*/ +void QOpenGLTexture::setData(int xOffset, int yOffset, int zOffset, + int width, int height, int depth, + int mipLevel, + PixelFormat sourceFormat, PixelType sourceType, + const void *data, const QOpenGLPixelTransferOptions * const options) +{ + Q_D(QOpenGLTexture); + Q_ASSERT(d->textureId); + d->setData(xOffset, yOffset, zOffset, + width, height, depth, + mipLevel, 0, 1, + QOpenGLTexture::CubeMapPositiveX, sourceFormat, + sourceType, data, options); +} + /*! \since 5.14 \overload From b58c723404594d04f0b31b425da77b4fcbeec3b9 Mon Sep 17 00:00:00 2001 From: Vincas Dargis Date: Fri, 22 Mar 2019 10:40:12 +0200 Subject: [PATCH 110/292] QSqlError: fix redundant space in text() output QSqlError::text() returns single space if QSqlError is not valid. In addition, it adds space in case one of driverText or databaseText is empty. Change condition upon which space is added between databaseText and driverText, and update unit test to cover these cases. Fixes: QTBUG-74575 Change-Id: I52cce9b0287a523d7ff9059cff38bcd8b26eb303 Reviewed-by: Andy Shaw --- src/sql/kernel/qsqlerror.cpp | 2 +- .../sql/kernel/qsqlerror/tst_qsqlerror.cpp | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/sql/kernel/qsqlerror.cpp b/src/sql/kernel/qsqlerror.cpp index 41ea497ad7..7a1a91948c 100644 --- a/src/sql/kernel/qsqlerror.cpp +++ b/src/sql/kernel/qsqlerror.cpp @@ -365,7 +365,7 @@ QString QSqlError::nativeErrorCode() const QString QSqlError::text() const { QString result = d->databaseError; - if (!d->databaseError.endsWith(QLatin1String("\n"))) + if (!d->databaseError.isEmpty() && !d->driverError.isEmpty() && !d->databaseError.endsWith(QLatin1String("\n"))) result += QLatin1Char(' '); result += d->driverError; return result; diff --git a/tests/auto/sql/kernel/qsqlerror/tst_qsqlerror.cpp b/tests/auto/sql/kernel/qsqlerror/tst_qsqlerror.cpp index 08c6039e37..be0285537e 100644 --- a/tests/auto/sql/kernel/qsqlerror/tst_qsqlerror.cpp +++ b/tests/auto/sql/kernel/qsqlerror/tst_qsqlerror.cpp @@ -46,6 +46,7 @@ private slots: void construction(); void moveOperator(); void operators(); + void qtbug_74575(); }; tst_QSqlError::tst_QSqlError() @@ -113,6 +114,7 @@ void tst_QSqlError::construction() QVERIFY(!obj4.isValid()); QCOMPARE(obj4.driverText(), QString()); QCOMPARE(obj4.databaseText(), QString()); + QCOMPARE(obj4.text(), QString()); QCOMPARE(obj4.type(), QSqlError::NoError); QCOMPARE(obj4.number(), -1); QCOMPARE(obj4.nativeErrorCode(), QString()); @@ -180,6 +182,28 @@ void tst_QSqlError::operators() QVERIFY(error1 != error3); } +void tst_QSqlError::qtbug_74575() +{ + const QString driverText(QStringLiteral("drivertext")); + const QString databaseText(QStringLiteral("databasetext")); + const QString databaseTextNewline(QStringLiteral("databasetext\n")); + + QSqlError error1(driverText, databaseText, + QSqlError::UnknownError, QStringLiteral("123")); + QCOMPARE(error1.text(), databaseText + QLatin1Char(' ') + driverText); + + QSqlError error2(QString(), databaseText, + QSqlError::UnknownError, QStringLiteral("123")); + QCOMPARE(error2.text(), databaseText); + + QSqlError error3(driverText, QString(), + QSqlError::UnknownError, QStringLiteral("123")); + QCOMPARE(error3.text(), driverText); + + QSqlError error4(driverText, databaseTextNewline, + QSqlError::UnknownError, QStringLiteral("123")); + QCOMPARE(error4.text(), databaseTextNewline + driverText); +} QTEST_MAIN(tst_QSqlError) #include "tst_qsqlerror.moc" From 3e6d42b65c1c827394f4c269dbc229ae5791fa35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Tue, 26 Mar 2019 09:48:48 +0100 Subject: [PATCH 111/292] Cleanup widgets/kernel.pro after modularization QSound test lives in QtMultimedia. Change-Id: Id47b5744b9494c77eb2c2c0d1fe2f807d2dd2083 --- tests/auto/widgets/kernel/kernel.pro | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/auto/widgets/kernel/kernel.pro b/tests/auto/widgets/kernel/kernel.pro index 73fd934502..af85a2bd13 100644 --- a/tests/auto/widgets/kernel/kernel.pro +++ b/tests/auto/widgets/kernel/kernel.pro @@ -22,5 +22,3 @@ SUBDIRS=\ darwin:SUBDIRS -= \ # Uses native recognizers qgesturerecognizer \ - -SUBDIRS -= qsound From 921fa344e19218b650e44f3307943fe4ec77f098 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 27 Feb 2019 11:17:45 +0100 Subject: [PATCH 112/292] Simplify finite/NaN testing for qfloat16 Doing endian-dependent selection of bytes of the value was a clumsy surrogate for just accessing the intenal quint16 shifted suitably. Change-Id: Icfd9d1d18f69eb94b041b8d32275df606c14c2b4 Reviewed-by: Qt CI Bot Reviewed-by: Thiago Macieira --- src/corelib/global/global.pri | 1 - src/corelib/global/qfloat16.cpp | 17 +++--- src/corelib/global/qfloat16.h | 14 +++-- src/corelib/global/qfloat16_p.h | 95 --------------------------------- 4 files changed, 20 insertions(+), 107 deletions(-) delete mode 100644 src/corelib/global/qfloat16_p.h diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri index 029357ff43..428c674307 100644 --- a/src/corelib/global/global.pri +++ b/src/corelib/global/global.pri @@ -12,7 +12,6 @@ HEADERS += \ global/qendian_p.h \ global/qnumeric_p.h \ global/qnumeric.h \ - global/qfloat16_p.h \ global/qfloat16.h \ global/qglobalstatic.h \ global/qlibraryinfo.h \ diff --git a/src/corelib/global/qfloat16.cpp b/src/corelib/global/qfloat16.cpp index fd608efe55..110d7c4d7c 100644 --- a/src/corelib/global/qfloat16.cpp +++ b/src/corelib/global/qfloat16.cpp @@ -37,7 +37,7 @@ ** ****************************************************************************/ -#include "qfloat16_p.h" +#include "qfloat16.h" #include "private/qsimd_p.h" QT_BEGIN_NAMESPACE @@ -65,28 +65,31 @@ QT_BEGIN_NAMESPACE */ /*! - Returns true if the \c qfloat16 \a {f} is equivalent to infinity. + \fn bool qIsInf(qfloat16 f) \relates + Returns true if the \c qfloat16 \a {f} is equivalent to infinity. + \sa qIsInf */ -Q_REQUIRED_RESULT bool qIsInf(qfloat16 f) Q_DECL_NOTHROW { return qt_is_inf(f); } /*! - Returns true if the \c qfloat16 \a {f} is not a number (NaN). + \fn bool qIsNaN(qfloat16 f) \relates + Returns true if the \c qfloat16 \a {f} is not a number (NaN). + \sa qIsNaN */ -Q_REQUIRED_RESULT bool qIsNaN(qfloat16 f) Q_DECL_NOTHROW { return qt_is_nan(f); } /*! - Returns true if the \c qfloat16 \a {f} is a finite number. + \fn bool qIsFinite(qfloat16 f) \relates + Returns true if the \c qfloat16 \a {f} is a finite number. + \sa qIsFinite */ -Q_REQUIRED_RESULT bool qIsFinite(qfloat16 f) Q_DECL_NOTHROW { return qt_is_finite(f); } /*! \fn int qRound(qfloat16 value) \relates diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h index 42cb1357f1..e823d0298b 100644 --- a/src/corelib/global/qfloat16.h +++ b/src/corelib/global/qfloat16.h @@ -67,10 +67,14 @@ QT_BEGIN_NAMESPACE class qfloat16 { public: - Q_DECL_CONSTEXPR inline qfloat16() Q_DECL_NOTHROW : b16(0) { } + constexpr inline qfloat16() Q_DECL_NOTHROW : b16(0) {} inline qfloat16(float f) Q_DECL_NOTHROW; inline operator float() const Q_DECL_NOTHROW; + // Support for qIs{Inf,NaN,Finite}: + bool isInf() const Q_DECL_NOTHROW { return ((b16 >> 8) & 0x7e) == 0x7c; } + bool isNaN() const Q_DECL_NOTHROW { return ((b16 >> 8) & 0x7e) == 0x7e; } + bool isFinite() const Q_DECL_NOTHROW { return ((b16 >> 8) & 0x7c) != 0x7c; } private: quint16 b16; @@ -89,9 +93,11 @@ Q_DECLARE_TYPEINFO(qfloat16, Q_PRIMITIVE_TYPE); Q_CORE_EXPORT void qFloatToFloat16(qfloat16 *, const float *, qsizetype length) Q_DECL_NOTHROW; Q_CORE_EXPORT void qFloatFromFloat16(float *, const qfloat16 *, qsizetype length) Q_DECL_NOTHROW; -Q_REQUIRED_RESULT Q_CORE_EXPORT bool qIsInf(qfloat16 f) Q_DECL_NOTHROW; // complements qnumeric.h -Q_REQUIRED_RESULT Q_CORE_EXPORT bool qIsNaN(qfloat16 f) Q_DECL_NOTHROW; // complements qnumeric.h -Q_REQUIRED_RESULT Q_CORE_EXPORT bool qIsFinite(qfloat16 f) Q_DECL_NOTHROW; // complements qnumeric.h +// Complement qnumeric.h: +Q_REQUIRED_RESULT inline bool qIsInf(qfloat16 f) Q_DECL_NOTHROW { return f.isInf(); } +Q_REQUIRED_RESULT inline bool qIsNaN(qfloat16 f) Q_DECL_NOTHROW { return f.isNaN(); } +Q_REQUIRED_RESULT inline bool qIsFinite(qfloat16 f) Q_DECL_NOTHROW { return f.isFinite(); } +// Q_REQUIRED_RESULT quint32 qFloatDistance(qfloat16 a, qfloat16 b); // The remainder of these utility functions complement qglobal.h Q_REQUIRED_RESULT inline int qRound(qfloat16 d) Q_DECL_NOTHROW diff --git a/src/corelib/global/qfloat16_p.h b/src/corelib/global/qfloat16_p.h deleted file mode 100644 index f3fc96e119..0000000000 --- a/src/corelib/global/qfloat16_p.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 by Southwest Research Institute (R) -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QFLOAT16_P_H -#define QFLOAT16_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include - -QT_BEGIN_NAMESPACE - -static inline bool qt_is_inf(qfloat16 d) Q_DECL_NOTHROW -{ - bool is_inf; - uchar *ch = (uchar *)&d; - if (QSysInfo::ByteOrder == QSysInfo::BigEndian) - is_inf = (ch[0] & 0x7c) == 0x7c && (ch[0] & 0x02) == 0; - else - is_inf = (ch[1] & 0x7c) == 0x7c && (ch[1] & 0x02) == 0; - return is_inf; -} - -static inline bool qt_is_nan(qfloat16 d) Q_DECL_NOTHROW -{ - bool is_nan; - uchar *ch = (uchar *)&d; - if (QSysInfo::ByteOrder == QSysInfo::BigEndian) - is_nan = (ch[0] & 0x7c) == 0x7c && (ch[0] & 0x02) != 0; - else - is_nan = (ch[1] & 0x7c) == 0x7c && (ch[1] & 0x02) != 0; - return is_nan; -} - -static inline bool qt_is_finite(qfloat16 d) Q_DECL_NOTHROW -{ - bool is_finite; - uchar *ch = (uchar *)&d; - if (QSysInfo::ByteOrder == QSysInfo::BigEndian) - is_finite = (ch[0] & 0x7c) != 0x7c; - else - is_finite = (ch[1] & 0x7c) != 0x7c; - return is_finite; -} - - -QT_END_NAMESPACE - -#endif // QFLOAT16_P_H From 03ada0217c201903b8282f77e292f1964e00b880 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Mon, 18 Mar 2019 11:39:50 +0100 Subject: [PATCH 113/292] WinRT: Add support for AES-encrypted keys Task-number: QTBUG-54422 Change-Id: Icbf2b153edacb348e475d6adb9aecb63519874de Reviewed-by: Timur Pocheptsov Reviewed-by: Edward Welbourne --- src/network/ssl/qsslkey_qt.cpp | 2 -- src/network/ssl/qsslkey_winrt.cpp | 9 +++++++++ tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/network/ssl/qsslkey_qt.cpp b/src/network/ssl/qsslkey_qt.cpp index 1b2d9a49aa..2662418a05 100644 --- a/src/network/ssl/qsslkey_qt.cpp +++ b/src/network/ssl/qsslkey_qt.cpp @@ -413,14 +413,12 @@ void QSslKeyPrivate::decodePem(const QByteArray &pem, const QByteArray &passPhra cipher = DesEde3Cbc; } else if (dekInfo.first() == "RC2-CBC") { cipher = Rc2Cbc; -#if defined(QT_SECURETRANSPORT) || QT_CONFIG(schannel) } else if (dekInfo.first() == "AES-128-CBC") { cipher = Aes128Cbc; } else if (dekInfo.first() == "AES-192-CBC") { cipher = Aes192Cbc; } else if (dekInfo.first() == "AES-256-CBC") { cipher = Aes256Cbc; -#endif // QT_SECURETRANSPORT || schannel } else { clear(deepClear); return; diff --git a/src/network/ssl/qsslkey_winrt.cpp b/src/network/ssl/qsslkey_winrt.cpp index f2ed813965..69eaaa387f 100644 --- a/src/network/ssl/qsslkey_winrt.cpp +++ b/src/network/ssl/qsslkey_winrt.cpp @@ -83,6 +83,15 @@ struct SslKeyGlobal hr = keyProviderFactory->OpenAlgorithm(HString::MakeReference(L"RC2_CBC").Get(), &keyProviders[QSslKeyPrivate::Rc2Cbc]); Q_ASSERT_SUCCEEDED(hr); + hr = keyProviderFactory->OpenAlgorithm(HString::MakeReference(L"AES_CBC").Get(), + &keyProviders[QSslKeyPrivate::Aes128Cbc]); + Q_ASSERT_SUCCEEDED(hr); + hr = keyProviderFactory->OpenAlgorithm(HString::MakeReference(L"AES_CBC").Get(), + &keyProviders[QSslKeyPrivate::Aes192Cbc]); + Q_ASSERT_SUCCEEDED(hr); + hr = keyProviderFactory->OpenAlgorithm(HString::MakeReference(L"AES_CBC").Get(), + &keyProviders[QSslKeyPrivate::Aes256Cbc]); + Q_ASSERT_SUCCEEDED(hr); hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Security_Cryptography_CryptographicBuffer).Get(), &bufferFactory); diff --git a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp index 059efae63d..0ce4256ce1 100644 --- a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp +++ b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp @@ -474,11 +474,11 @@ void tst_QSslKey::passphraseChecks_data() QTest::newRow("DES") << QString(testDataDir + "rsa-with-passphrase-des.pem") << pass; QTest::newRow("3DES") << QString(testDataDir + "rsa-with-passphrase-3des.pem") << pass; QTest::newRow("RC2") << QString(testDataDir + "rsa-with-passphrase-rc2.pem") << pass; -#if (!defined(QT_NO_OPENSSL) && !defined(OPENSSL_NO_AES)) || defined(QT_SECURETRANSPORT) || QT_CONFIG(schannel) +#if (!defined(QT_NO_OPENSSL) && !defined(OPENSSL_NO_AES)) || (defined(QT_NO_OPENSSL) && QT_CONFIG(ssl)) QTest::newRow("AES128") << QString(testDataDir + "rsa-with-passphrase-aes128.pem") << aesPass; QTest::newRow("AES192") << QString(testDataDir + "rsa-with-passphrase-aes192.pem") << aesPass; QTest::newRow("AES256") << QString(testDataDir + "rsa-with-passphrase-aes256.pem") << aesPass; -#endif +#endif // (OpenSSL && AES) || generic backend } void tst_QSslKey::passphraseChecks() From a06dfed4cc94fefca3f0db7eca679f083a984c9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 12 Mar 2019 12:28:47 +0100 Subject: [PATCH 114/292] tst_qsslkey: test AES encryption in the 'encrypt' test And export the required symbols in OpenSSL so we can run the test there as well even if it's not needed for any functionality. Change-Id: I4246d2b0bbdd42079d255f97f3c66ce8bb37390b Reviewed-by: Timur Pocheptsov --- src/network/ssl/qsslkey_openssl.cpp | 9 +- .../ssl/qsslsocket_openssl_symbols.cpp | 10 ++ .../ssl/qsslsocket_openssl_symbols_p.h | 5 + .../auto/network/ssl/qsslkey/tst_qsslkey.cpp | 92 +++++++++++++++---- 4 files changed, 94 insertions(+), 22 deletions(-) diff --git a/src/network/ssl/qsslkey_openssl.cpp b/src/network/ssl/qsslkey_openssl.cpp index dfb80bd829..888058df22 100644 --- a/src/network/ssl/qsslkey_openssl.cpp +++ b/src/network/ssl/qsslkey_openssl.cpp @@ -334,12 +334,13 @@ static QByteArray doCrypt(QSslKeyPrivate::Cipher cipher, const QByteArray &data, #endif break; case QSslKeyPrivate::Aes128Cbc: + type = q_EVP_aes_128_cbc(); + break; case QSslKeyPrivate::Aes192Cbc: + type = q_EVP_aes_192_cbc(); + break; case QSslKeyPrivate::Aes256Cbc: - // Just to avoid compiler warnings/errors. OpenSSL uses a different - // codepath when reading encrypted keys, and they all correctly - // deduce the cipher and know how to derive a key. - Q_UNREACHABLE(); + type = q_EVP_aes_256_cbc(); break; } diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp index f136c92a65..e04d45c10c 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols.cpp +++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp @@ -359,6 +359,11 @@ DEFINEFUNC(const EVP_CIPHER *, EVP_des_ede3_cbc, DUMMYARG, DUMMYARG, return null #ifndef OPENSSL_NO_RC2 DEFINEFUNC(const EVP_CIPHER *, EVP_rc2_cbc, DUMMYARG, DUMMYARG, return nullptr, return) #endif +#ifndef OPENSSL_NO_AES +DEFINEFUNC(const EVP_CIPHER *, EVP_aes_128_cbc, DUMMYARG, DUMMYARG, return nullptr, return) +DEFINEFUNC(const EVP_CIPHER *, EVP_aes_192_cbc, DUMMYARG, DUMMYARG, return nullptr, return) +DEFINEFUNC(const EVP_CIPHER *, EVP_aes_256_cbc, DUMMYARG, DUMMYARG, return nullptr, return) +#endif DEFINEFUNC(const EVP_MD *, EVP_sha1, DUMMYARG, DUMMYARG, return nullptr, return) DEFINEFUNC3(int, EVP_PKEY_assign, EVP_PKEY *a, a, int b, b, char *c, c, return -1, return) DEFINEFUNC2(int, EVP_PKEY_set1_RSA, EVP_PKEY *a, a, RSA *b, b, return -1, return) @@ -1178,6 +1183,11 @@ bool q_resolveOpenSslSymbols() #endif #ifndef OPENSSL_NO_RC2 RESOLVEFUNC(EVP_rc2_cbc) +#endif +#ifndef OPENSSL_NO_AES + RESOLVEFUNC(EVP_aes_128_cbc) + RESOLVEFUNC(EVP_aes_192_cbc) + RESOLVEFUNC(EVP_aes_256_cbc) #endif RESOLVEFUNC(EVP_sha1) RESOLVEFUNC(EVP_PKEY_assign) diff --git a/src/network/ssl/qsslsocket_openssl_symbols_p.h b/src/network/ssl/qsslsocket_openssl_symbols_p.h index 59b6e53940..fcf96dbd47 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols_p.h +++ b/src/network/ssl/qsslsocket_openssl_symbols_p.h @@ -281,6 +281,11 @@ const EVP_CIPHER *q_EVP_des_ede3_cbc(); #ifndef OPENSSL_NO_RC2 const EVP_CIPHER *q_EVP_rc2_cbc(); #endif +#ifndef OPENSSL_NO_AES +const EVP_CIPHER *q_EVP_aes_128_cbc(); +const EVP_CIPHER *q_EVP_aes_192_cbc(); +const EVP_CIPHER *q_EVP_aes_256_cbc(); +#endif Q_AUTOTEST_EXPORT const EVP_MD *q_EVP_sha1(); int q_EVP_PKEY_assign(EVP_PKEY *a, int b, char *c); Q_AUTOTEST_EXPORT int q_EVP_PKEY_set1_RSA(EVP_PKEY *a, RSA *b); diff --git a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp index 0ce4256ce1..f94756ed73 100644 --- a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp +++ b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp @@ -562,79 +562,135 @@ void tst_QSslKey::encrypt_data() QTest::addColumn("key"); QTest::addColumn("plainText"); QTest::addColumn("cipherText"); + QTest::addColumn("iv"); + QByteArray iv("abcdefgh"); QTest::newRow("DES-CBC, length 0") << QSslKeyPrivate::DesCbc << QByteArray("01234567") << QByteArray() - << QByteArray::fromHex("956585228BAF9B1F"); + << QByteArray::fromHex("956585228BAF9B1F") + << iv; QTest::newRow("DES-CBC, length 1") << QSslKeyPrivate::DesCbc << QByteArray("01234567") << QByteArray(1, 'a') - << QByteArray::fromHex("E6880AF202BA3C12"); + << QByteArray::fromHex("E6880AF202BA3C12") + << iv; QTest::newRow("DES-CBC, length 2") << QSslKeyPrivate::DesCbc << QByteArray("01234567") << QByteArray(2, 'a') - << QByteArray::fromHex("A82492386EED6026"); + << QByteArray::fromHex("A82492386EED6026") + << iv; QTest::newRow("DES-CBC, length 3") << QSslKeyPrivate::DesCbc << QByteArray("01234567") << QByteArray(3, 'a') - << QByteArray::fromHex("90B76D5B79519CBA"); + << QByteArray::fromHex("90B76D5B79519CBA") + << iv; QTest::newRow("DES-CBC, length 4") << QSslKeyPrivate::DesCbc << QByteArray("01234567") << QByteArray(4, 'a') - << QByteArray::fromHex("63E3DD6FED87052A"); + << QByteArray::fromHex("63E3DD6FED87052A") + << iv; QTest::newRow("DES-CBC, length 5") << QSslKeyPrivate::DesCbc << QByteArray("01234567") << QByteArray(5, 'a') - << QByteArray::fromHex("03ACDB0EACBDFA94"); + << QByteArray::fromHex("03ACDB0EACBDFA94") + << iv; QTest::newRow("DES-CBC, length 6") << QSslKeyPrivate::DesCbc << QByteArray("01234567") << QByteArray(6, 'a') - << QByteArray::fromHex("7D95024E42A3A88A"); + << QByteArray::fromHex("7D95024E42A3A88A") + << iv; QTest::newRow("DES-CBC, length 7") << QSslKeyPrivate::DesCbc << QByteArray("01234567") << QByteArray(7, 'a') - << QByteArray::fromHex("5003436B8A8E42E9"); + << QByteArray::fromHex("5003436B8A8E42E9") + << iv; QTest::newRow("DES-CBC, length 8") << QSslKeyPrivate::DesCbc << QByteArray("01234567") << QByteArray(8, 'a') - << QByteArray::fromHex("E4C1F054BF5521C0A4A0FD4A2BC6C1B1"); + << QByteArray::fromHex("E4C1F054BF5521C0A4A0FD4A2BC6C1B1") + << iv; QTest::newRow("DES-EDE3-CBC, length 0") << QSslKeyPrivate::DesEde3Cbc << QByteArray("0123456789abcdefghijklmn") << QByteArray() - << QByteArray::fromHex("3B2B4CD0B0FD495F"); + << QByteArray::fromHex("3B2B4CD0B0FD495F") + << iv; QTest::newRow("DES-EDE3-CBC, length 8") << QSslKeyPrivate::DesEde3Cbc << QByteArray("0123456789abcdefghijklmn") << QByteArray(8, 'a') - << QByteArray::fromHex("F2A5A87763C54A72A3224103D90CDB03"); + << QByteArray::fromHex("F2A5A87763C54A72A3224103D90CDB03") + << iv; QTest::newRow("RC2-40-CBC, length 0") << QSslKeyPrivate::Rc2Cbc << QByteArray("01234") << QByteArray() - << QByteArray::fromHex("6D05D52392FF6E7A"); + << QByteArray::fromHex("6D05D52392FF6E7A") + << iv; QTest::newRow("RC2-40-CBC, length 8") << QSslKeyPrivate::Rc2Cbc << QByteArray("01234") << QByteArray(8, 'a') - << QByteArray::fromHex("75768E64C5749072A5D168F3AFEB0005"); + << QByteArray::fromHex("75768E64C5749072A5D168F3AFEB0005") + << iv; QTest::newRow("RC2-64-CBC, length 0") << QSslKeyPrivate::Rc2Cbc << QByteArray("01234567") << QByteArray() - << QByteArray::fromHex("ADAE6BF70F420130"); + << QByteArray::fromHex("ADAE6BF70F420130") + << iv; QTest::newRow("RC2-64-CBC, length 8") << QSslKeyPrivate::Rc2Cbc << QByteArray("01234567") << QByteArray(8, 'a') - << QByteArray::fromHex("C7BF5C80AFBE9FBEFBBB9FD935F6D0DF"); + << QByteArray::fromHex("C7BF5C80AFBE9FBEFBBB9FD935F6D0DF") + << iv; QTest::newRow("RC2-128-CBC, length 0") << QSslKeyPrivate::Rc2Cbc << QByteArray("012345679abcdefg") << QByteArray() - << QByteArray::fromHex("1E965D483A13C8FB"); + << QByteArray::fromHex("1E965D483A13C8FB") + << iv; QTest::newRow("RC2-128-CBC, length 8") << QSslKeyPrivate::Rc2Cbc << QByteArray("012345679abcdefg") << QByteArray(8, 'a') - << QByteArray::fromHex("5AEC1A5B295660B02613454232F7DECE"); + << QByteArray::fromHex("5AEC1A5B295660B02613454232F7DECE") + << iv; + +#if (!defined(QT_NO_OPENSSL) && !defined(OPENSSL_NO_AES)) || (defined(QT_NO_OPENSSL) && QT_CONFIG(ssl)) + // AES needs a longer IV + iv = QByteArray("abcdefghijklmnop"); + QTest::newRow("AES-128-CBC, length 0") + << QSslKeyPrivate::Aes128Cbc << QByteArray("012345679abcdefg") + << QByteArray() + << QByteArray::fromHex("28DE1A9AA26601C30DD2527407121D1A") + << iv; + QTest::newRow("AES-128-CBC, length 8") + << QSslKeyPrivate::Aes128Cbc << QByteArray("012345679abcdefg") + << QByteArray(8, 'a') + << QByteArray::fromHex("08E880B1BA916F061C1E801D7F44D0EC") + << iv; + + QTest::newRow("AES-192-CBC, length 0") + << QSslKeyPrivate::Aes192Cbc << QByteArray("0123456789abcdefghijklmn") + << QByteArray() + << QByteArray::fromHex("E169E0E205CDC2BA895B7CF6097673B1") + << iv; + QTest::newRow("AES-192-CBC, length 8") + << QSslKeyPrivate::Aes192Cbc << QByteArray("0123456789abcdefghijklmn") + << QByteArray(8, 'a') + << QByteArray::fromHex("3A227D6A3A13237316D30AA17FF9B0A7") + << iv; + + QTest::newRow("AES-256-CBC, length 0") + << QSslKeyPrivate::Aes256Cbc << QByteArray("0123456789abcdefghijklmnopqrstuv") + << QByteArray() + << QByteArray::fromHex("4BAACAA0D22199C97DE206C465B7B14A") + << iv; + QTest::newRow("AES-256-CBC, length 8") + << QSslKeyPrivate::Aes256Cbc << QByteArray("0123456789abcdefghijklmnopqrstuv") + << QByteArray(8, 'a') + << QByteArray::fromHex("879C8C25EC135CDF0B14490A0A7C2F67") + << iv; +#endif // (OpenSSL && AES) || generic backend } void tst_QSslKey::encrypt() @@ -643,7 +699,7 @@ void tst_QSslKey::encrypt() QFETCH(QByteArray, key); QFETCH(QByteArray, plainText); QFETCH(QByteArray, cipherText); - QByteArray iv("abcdefgh"); + QFETCH(QByteArray, iv); #if defined(Q_OS_WINRT) || QT_CONFIG(schannel) QEXPECT_FAIL("RC2-40-CBC, length 0", "WinRT/Schannel treats RC2 as 128-bit", Abort); From e79b1dcdf542be3a20d5c21ea163ff857ed875bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Mon, 11 Mar 2019 15:56:51 +0100 Subject: [PATCH 115/292] tst_qsslsocket: fix racy test In this threaded setup the server can sometimes have the data before it calls "waitForReadyRead", what happens then is that we fail the wait and as a result the test fails overall. Let's check if we actually got some data after all and then continue if we did. Since both the client and the server currently wait the same amount of time (2s) the max timeout for the client was increased by 0.5s so it has some time to notice that the server got the message. Change-Id: Ib5915958853413047aa5a7574712585bcae28f79 Reviewed-by: Edward Welbourne Reviewed-by: Timur Pocheptsov --- tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index 96c2f8ec42..7912063bc8 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -2139,7 +2139,7 @@ protected: // delayed reading data QTest::qSleep(100); - if (!socket->waitForReadyRead(2000)) + if (!socket->waitForReadyRead(2000) && socket->bytesAvailable() == 0) return; // error socket->readAll(); dataReadSemaphore.release(); @@ -2210,7 +2210,7 @@ void tst_QSslSocket::waitForMinusOne() socket.write("How are you doing?"); QVERIFY(socket.bytesToWrite() != 0); QVERIFY(socket.waitForBytesWritten(-1)); - QVERIFY(server.dataReadSemaphore.tryAcquire(1, 2000)); + QVERIFY(server.dataReadSemaphore.tryAcquire(1, 2500)); // third verification: it should wait for 100 ms: QVERIFY(socket.waitForReadyRead(-1)); From 742a07ece1c99db964617015c06a05b4cb0dd995 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 25 Mar 2019 15:27:39 +0100 Subject: [PATCH 116/292] Use QScopedValueRollback more as a reentrancy guard It is documented for the use, but we were rarely using it. Change-Id: I812b9e6c8fbf204aba43ce2b79eca308ca75de88 Reviewed-by: Thiago Macieira --- src/corelib/animation/qabstractanimation.cpp | 16 ++++++++-------- src/corelib/io/qprocess.cpp | 4 ++-- src/corelib/io/qwindowspipereader.cpp | 4 ++-- src/corelib/io/qwindowspipewriter.cpp | 4 ++-- src/gui/painting/qoutlinemapper.cpp | 5 ++--- src/gui/text/qsyntaxhighlighter.cpp | 7 ++++--- src/gui/text/qtextdocument_p.cpp | 18 ++++++++++-------- src/gui/text/qtextdocument_p.h | 2 +- 8 files changed, 31 insertions(+), 29 deletions(-) diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 9d7a256191..e37f9a0271 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -152,6 +152,7 @@ #include #include #include +#include #define DEFAULT_TIMER_INTERVAL 16 #define PAUSE_TIMER_COARSE_THRESHOLD 2000 @@ -315,14 +316,13 @@ void QUnifiedTimer::updateAnimationTimers(qint64 currentTick) //* it might happen in some cases that the delta is negative because the animation driver // advances faster than time.elapsed() if (delta > 0) { - insideTick = true; + QScopedValueRollback guard(insideTick, true); if (profilerCallback) profilerCallback(delta); for (currentAnimationIdx = 0; currentAnimationIdx < animationTimers.count(); ++currentAnimationIdx) { QAbstractAnimationTimer *animation = animationTimers.at(currentAnimationIdx); animation->updateAnimationsTime(delta); } - insideTick = false; currentAnimationIdx = 0; } } @@ -361,10 +361,11 @@ void QUnifiedTimer::localRestart() void QUnifiedTimer::restart() { - insideRestart = true; - for (int i = 0; i < animationTimers.count(); ++i) - animationTimers.at(i)->restartAnimationTimer(); - insideRestart = false; + { + QScopedValueRollback guard(insideRestart, true); + for (int i = 0; i < animationTimers.count(); ++i) + animationTimers.at(i)->restartAnimationTimer(); + } localRestart(); } @@ -599,14 +600,13 @@ void QAnimationTimer::updateAnimationsTime(qint64 delta) //it might happen in some cases that the time doesn't change because events are delayed //when the CPU load is high if (delta) { - insideTick = true; + QScopedValueRollback guard(insideTick, true); for (currentAnimationIdx = 0; currentAnimationIdx < animations.count(); ++currentAnimationIdx) { QAbstractAnimation *animation = animations.at(currentAnimationIdx); int elapsed = QAbstractAnimationPrivate::get(animation)->totalCurrentTime + (animation->direction() == QAbstractAnimation::Forward ? delta : -delta); animation->setCurrentTime(elapsed); } - insideTick = false; currentAnimationIdx = 0; } } diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index d5d67d86f3..c7635cc7b4 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -42,6 +42,7 @@ #include #include +#include #if defined(Q_OS_WIN) #include #endif @@ -1062,9 +1063,8 @@ bool QProcessPrivate::tryReadFromChannel(Channel *channel) if (currentReadChannel == channelIdx) { didRead = true; if (!emittedReadyRead) { - emittedReadyRead = true; + QScopedValueRollback guard(emittedReadyRead, true); emit q->readyRead(); - emittedReadyRead = false; } } emit q->channelReadyRead(int(channelIdx)); diff --git a/src/corelib/io/qwindowspipereader.cpp b/src/corelib/io/qwindowspipereader.cpp index 15c9f52cf3..1f03ac5d5a 100644 --- a/src/corelib/io/qwindowspipereader.cpp +++ b/src/corelib/io/qwindowspipereader.cpp @@ -40,6 +40,7 @@ #include "qwindowspipereader_p.h" #include "qiodevice_p.h" #include +#include QT_BEGIN_NAMESPACE @@ -301,9 +302,8 @@ void QWindowsPipeReader::emitPendingReadyRead() { if (readyReadPending) { readyReadPending = false; - inReadyRead = true; + QScopedValueRollback guard(inReadyRead, true); emit readyRead(); - inReadyRead = false; } } diff --git a/src/corelib/io/qwindowspipewriter.cpp b/src/corelib/io/qwindowspipewriter.cpp index 92e8b6db52..32536f495b 100644 --- a/src/corelib/io/qwindowspipewriter.cpp +++ b/src/corelib/io/qwindowspipewriter.cpp @@ -39,6 +39,7 @@ #include "qwindowspipewriter_p.h" #include "qiodevice_p.h" +#include QT_BEGIN_NAMESPACE @@ -111,9 +112,8 @@ void QWindowsPipeWriter::emitPendingBytesWrittenValue() emit canWrite(); if (!inBytesWritten) { - inBytesWritten = true; + QScopedValueRollback guard(inBytesWritten, true); emit bytesWritten(bytes); - inBytesWritten = false; } } } diff --git a/src/gui/painting/qoutlinemapper.cpp b/src/gui/painting/qoutlinemapper.cpp index b2d02182c3..2074f98069 100644 --- a/src/gui/painting/qoutlinemapper.cpp +++ b/src/gui/painting/qoutlinemapper.cpp @@ -42,6 +42,7 @@ #include "qbezier_p.h" #include "qmath.h" #include "qpainterpath_p.h" +#include "qscopedvaluerollback.h" #include @@ -354,7 +355,7 @@ void QOutlineMapper::clipElements(const QPointF *elements, // instead of going through convenience functionallity, but since // this part of code hardly every used, it shouldn't matter. - m_in_clip_elements = true; + QScopedValueRollback in_clip_elements(m_in_clip_elements, true); QPainterPath path; @@ -397,8 +398,6 @@ void QOutlineMapper::clipElements(const QPointF *elements, convertPath(clippedPath); m_transform = oldTransform; } - - m_in_clip_elements = false; } QT_END_NAMESPACE diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp index 102a776ed3..cf584f6980 100644 --- a/src/gui/text/qsyntaxhighlighter.cpp +++ b/src/gui/text/qsyntaxhighlighter.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -68,14 +69,14 @@ public: void reformatBlocks(int from, int charsRemoved, int charsAdded); void reformatBlock(const QTextBlock &block); - inline void rehighlight(QTextCursor &cursor, QTextCursor::MoveOperation operation) { - inReformatBlocks = true; + inline void rehighlight(QTextCursor &cursor, QTextCursor::MoveOperation operation) + { + QScopedValueRollback bg(inReformatBlocks, true); cursor.beginEditBlock(); int from = cursor.position(); cursor.movePosition(operation); reformatBlocks(from, 0, cursor.position() - from); cursor.endEditBlock(); - inReformatBlocks = false; } inline void _q_delayedRehighlight() { diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp index c0a0c1a177..0e3c8d0e83 100644 --- a/src/gui/text/qtextdocument_p.cpp +++ b/src/gui/text/qtextdocument_p.cpp @@ -40,6 +40,7 @@ #include #include +#include #include "qtextdocument_p.h" #include "qtextdocument.h" #include @@ -274,9 +275,10 @@ void QTextDocumentPrivate::clear() rtFrame = 0; init(); cursors = oldCursors; - inContentsChange = true; - emit q->contentsChange(0, len, 0); - inContentsChange = false; + { + QScopedValueRollback bg(inContentsChange, true); + emit q->contentsChange(0, len, 0); + } if (lout) lout->documentChanged(0, len, 0); } QT_CATCH(...) { @@ -309,9 +311,10 @@ void QTextDocumentPrivate::setLayout(QAbstractTextDocumentLayout *layout) it->free(); emit q->documentLayoutChanged(); - inContentsChange = true; - emit q->contentsChange(0, 0, length()); - inContentsChange = false; + { + QScopedValueRollback bg(inContentsChange, true); + emit q->contentsChange(0, 0, length()); + } if (lout) lout->documentChanged(0, 0, length()); } @@ -1213,9 +1216,8 @@ void QTextDocumentPrivate::finishEdit() if (lout && docChangeFrom >= 0) { if (!inContentsChange) { - inContentsChange = true; + QScopedValueRollback bg(inContentsChange, true); emit q->contentsChange(docChangeFrom, docChangeOldLength, docChangeLength); - inContentsChange = false; } lout->documentChanged(docChangeFrom, docChangeOldLength, docChangeLength); } diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h index d95f5bef6a..a8e17bfc08 100644 --- a/src/gui/text/qtextdocument_p.h +++ b/src/gui/text/qtextdocument_p.h @@ -339,6 +339,7 @@ private: int lastBlockCount; public: + bool inContentsChange; QTextOption defaultTextOption; Qt::CursorMoveStyle defaultCursorMoveStyle; #ifndef QT_NO_CSSPARSER @@ -346,7 +347,6 @@ public: #endif int maximumBlockCount; uint needsEnsureMaximumBlockCount : 1; - uint inContentsChange : 1; uint blockCursorAdjustment : 1; QSizeF pageSize; QString title; From 4413f7070aa0a1b16944de552a72d7fe62681b1c Mon Sep 17 00:00:00 2001 From: Milian Wolff Date: Thu, 11 Jan 2018 17:31:18 +0100 Subject: [PATCH 117/292] Enable and extend the qtimer_vs_qmetaobject benchmark This benchmark was not compiled, and it only covered some parts of the API. Enable it, and also measure the performance of PMF and Functor API variants, for both QTimer::singleShot and QMetaObject::invokeMethod. This uncovers that the zero-timeout optimization for the singleShot is not applied to the PMF and Functor API variants: ********* Start testing of qtimer_vs_qmetaobject ********* Config: Using QtTest library 5.11.0, Qt 5.11.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 7.2.1 20171224) PASS : qtimer_vs_qmetaobject::initTestCase() PASS : qtimer_vs_qmetaobject::bench(singleShot_slot) RESULT : qtimer_vs_qmetaobject::bench():"singleShot_slot": 5.20 msecs per iteration (total: 520, iterations: 100) PASS : qtimer_vs_qmetaobject::bench(singleShot_pmf) RESULT : qtimer_vs_qmetaobject::bench():"singleShot_pmf": 75.93 msecs per iteration (total: 7,594, iterations: 100) PASS : qtimer_vs_qmetaobject::bench(singleShot_functor) RESULT : qtimer_vs_qmetaobject::bench():"singleShot_functor": 77.90 msecs per iteration (total: 7,790, iterations: 100) PASS : qtimer_vs_qmetaobject::bench(singleShot_functor_noctx) RESULT : qtimer_vs_qmetaobject::bench():"singleShot_functor_noctx": 76.23 msecs per iteration (total: 7,624, iterations: 100) PASS : qtimer_vs_qmetaobject::bench(invokeMethod_string) RESULT : qtimer_vs_qmetaobject::bench():"invokeMethod_string": 4.99 msecs per iteration (total: 499, iterations: 100) PASS : qtimer_vs_qmetaobject::bench(invokeMethod_pmf) RESULT : qtimer_vs_qmetaobject::bench():"invokeMethod_pmf": 5.37 msecs per iteration (total: 538, iterations: 100) PASS : qtimer_vs_qmetaobject::bench(invokeMethod_functor) RESULT : qtimer_vs_qmetaobject::bench():"invokeMethod_functor": 4.74 msecs per iteration (total: 474, iterations: 100) PASS : qtimer_vs_qmetaobject::cleanupTestCase() Totals: 9 passed, 0 failed, 0 skipped, 0 blacklisted, 50220ms ********* Finished testing of qtimer_vs_qmetaobject ********* Change-Id: I46336613188317124804638627f07eb135dc0286 Reviewed-by: Olivier Goffart (Woboq GmbH) --- tests/benchmarks/corelib/kernel/kernel.pro | 3 +- .../tst_qtimer_vs_qmetaobject.cpp | 67 +++++++++++++++---- 2 files changed, 56 insertions(+), 14 deletions(-) diff --git a/tests/benchmarks/corelib/kernel/kernel.pro b/tests/benchmarks/corelib/kernel/kernel.pro index 02eeeaa254..92f7174419 100644 --- a/tests/benchmarks/corelib/kernel/kernel.pro +++ b/tests/benchmarks/corelib/kernel/kernel.pro @@ -5,7 +5,8 @@ SUBDIRS = \ qmetatype \ qobject \ qvariant \ - qcoreapplication + qcoreapplication \ + qtimer_vs_qmetaobject !qtHaveModule(widgets): SUBDIRS -= \ qmetaobject \ diff --git a/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp b/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp index 66a29780f0..07976aa056 100644 --- a/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp +++ b/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp @@ -35,8 +35,8 @@ class qtimer_vs_qmetaobject : public QObject { Q_OBJECT private slots: - void testZeroTimerSingleShot(); - void testQueuedInvokeMethod(); + void bench(); + void bench_data(); }; class InvokeCounter : public QObject { @@ -53,28 +53,69 @@ protected: int count; }; -void qtimer_vs_qmetaobject::testZeroTimerSingleShot() +void qtimer_vs_qmetaobject::bench() { + QFETCH(int, type); + + std::function invoke; + if (type == 0) { + invoke = [](InvokeCounter* invokeCounter) { + QTimer::singleShot(0, invokeCounter, SLOT(invokeSlot())); + }; + } else if (type == 1) { + invoke = [](InvokeCounter* invokeCounter) { + QTimer::singleShot(0, invokeCounter, &InvokeCounter::invokeSlot); + }; + } else if (type == 2) { + invoke = [](InvokeCounter* invokeCounter) { + QTimer::singleShot(0, invokeCounter, [invokeCounter]() { + invokeCounter->invokeSlot(); + }); + }; + } else if (type == 3) { + invoke = [](InvokeCounter* invokeCounter) { + QTimer::singleShot(0, [invokeCounter]() { + invokeCounter->invokeSlot(); + }); + }; + } else if (type == 4) { + invoke = [](InvokeCounter* invokeCounter) { + QMetaObject::invokeMethod(invokeCounter, "invokeSlot", Qt::QueuedConnection); + }; + } else if (type == 5) { + invoke = [](InvokeCounter* invokeCounter) { + QMetaObject::invokeMethod(invokeCounter, &InvokeCounter::invokeSlot, Qt::QueuedConnection); + }; + } else if (type == 6) { + invoke = [](InvokeCounter* invokeCounter) { + QMetaObject::invokeMethod(invokeCounter, [invokeCounter]() { + invokeCounter->invokeSlot(); + }, Qt::QueuedConnection); + }; + } else { + QFAIL("unhandled data tag"); + } + QBENCHMARK { InvokeCounter invokeCounter; for(int i = 0; i < INVOKE_COUNT; ++i) { - QTimer::singleShot(0, &invokeCounter, SLOT(invokeSlot())); + invoke(&invokeCounter); } QTestEventLoop::instance().enterLoop(10); QVERIFY(!QTestEventLoop::instance().timeout()); } } -void qtimer_vs_qmetaobject::testQueuedInvokeMethod() +void qtimer_vs_qmetaobject::bench_data() { - QBENCHMARK { - InvokeCounter invokeCounter; - for(int i = 0; i < INVOKE_COUNT; ++i) { - QMetaObject::invokeMethod(&invokeCounter, "invokeSlot", Qt::QueuedConnection); - } - QTestEventLoop::instance().enterLoop(10); - QVERIFY(!QTestEventLoop::instance().timeout()); - } + QTest::addColumn("type"); + QTest::addRow("singleShot_slot") << 0; + QTest::addRow("singleShot_pmf") << 1; + QTest::addRow("singleShot_functor") << 2; + QTest::addRow("singleShot_functor_noctx") << 3; + QTest::addRow("invokeMethod_string") << 4; + QTest::addRow("invokeMethod_pmf") << 5; + QTest::addRow("invokeMethod_functor") << 6; } From 66e147309698d8cc5ce7da10d4cd2e1e216c3786 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 25 Mar 2019 15:29:17 +0100 Subject: [PATCH 118/292] Use move more consistently in QScopedValueRollback Use move on the existing value as well so the constructor makes more of a difference. Change-Id: Iee2080da7b7d2d88eb108f0448c61423c7256979 Reviewed-by: Richard Moe Gustavsen Reviewed-by: Thiago Macieira --- src/corelib/tools/qscopedvaluerollback.h | 14 +++++++------- .../tst_qscopedvaluerollback.cpp | 13 +++++++++++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/corelib/tools/qscopedvaluerollback.h b/src/corelib/tools/qscopedvaluerollback.h index 5f76269388..f904b8dfcb 100644 --- a/src/corelib/tools/qscopedvaluerollback.h +++ b/src/corelib/tools/qscopedvaluerollback.h @@ -48,20 +48,20 @@ template class QScopedValueRollback { public: - explicit QScopedValueRollback(T &var) : - varRef(var), oldValue(var) + explicit QScopedValueRollback(T &var) + : varRef(var), oldValue(var) { } - explicit QScopedValueRollback(T &var, T value) : - varRef(var), oldValue(var) + explicit QScopedValueRollback(T &var, T value) + : varRef(var), oldValue(std::move(var)) { - varRef = qMove(value); + varRef = std::move(value); } ~QScopedValueRollback() { - varRef = qMove(oldValue); + varRef = std::move(oldValue); } void commit() @@ -70,7 +70,7 @@ public: } private: - T& varRef; + T &varRef; T oldValue; Q_DISABLE_COPY(QScopedValueRollback) diff --git a/tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp b/tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp index 656dd6a6e3..9b607db608 100644 --- a/tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp +++ b/tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp @@ -46,6 +46,7 @@ private Q_SLOTS: void rollbackToPreviousCommit(); void exceptions(); void earlyExitScope(); + void moveOnly(); private: void earlyExitScope_helper(int exitpoint, int &member); }; @@ -190,5 +191,17 @@ void tst_QScopedValueRollback::earlyExitScope_helper(int exitpoint, int& member) r.commit(); } +void tst_QScopedValueRollback::moveOnly() +{ + std::unique_ptr uniquePtr; + std::unique_ptr newVal(new int(5)); + QVERIFY(!uniquePtr); + { + QScopedValueRollback> r(uniquePtr, std::move(newVal)); + QVERIFY(uniquePtr); + } + QVERIFY(!uniquePtr); +} + QTEST_MAIN(tst_QScopedValueRollback) #include "tst_qscopedvaluerollback.moc" From e75e89f9dedcdd4b9fe1caa04a2d8c5e759ea068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 26 Feb 2019 16:09:59 +0100 Subject: [PATCH 119/292] Test QTest's signal dumper It has been completely untested for a while and saw some breakage. So let's add a selftest for it. ('-vs' when running tests) Change-Id: Ibfb5ac0a2d741de7c3f519d91202d4977996045e Reviewed-by: Qt CI Bot Reviewed-by: Edward Welbourne --- src/testlib/qsignaldumper.cpp | 6 +- .../selftests/expected_signaldumper.lightxml | 578 +++++++++++++++++ .../selftests/expected_signaldumper.tap | 151 +++++ .../selftests/expected_signaldumper.teamcity | 61 ++ .../selftests/expected_signaldumper.txt | 149 +++++ .../selftests/expected_signaldumper.xml | 581 ++++++++++++++++++ .../selftests/expected_signaldumper.xunitxml | 284 +++++++++ .../selftests/generate_expected_output.py | 12 + tests/auto/testlib/selftests/selftests.pri | 1 + .../selftests/signaldumper/signaldumper.pro | 9 + .../signaldumper/tst_signaldumper.cpp | 417 +++++++++++++ .../auto/testlib/selftests/tst_selftests.cpp | 27 + 12 files changed, 2273 insertions(+), 3 deletions(-) create mode 100644 tests/auto/testlib/selftests/expected_signaldumper.lightxml create mode 100644 tests/auto/testlib/selftests/expected_signaldumper.tap create mode 100644 tests/auto/testlib/selftests/expected_signaldumper.teamcity create mode 100644 tests/auto/testlib/selftests/expected_signaldumper.txt create mode 100644 tests/auto/testlib/selftests/expected_signaldumper.xml create mode 100644 tests/auto/testlib/selftests/expected_signaldumper.xunitxml create mode 100644 tests/auto/testlib/selftests/signaldumper/signaldumper.pro create mode 100644 tests/auto/testlib/selftests/signaldumper/tst_signaldumper.cpp diff --git a/src/testlib/qsignaldumper.cpp b/src/testlib/qsignaldumper.cpp index b3360b4e6c..d0b6d0dd3f 100644 --- a/src/testlib/qsignaldumper.cpp +++ b/src/testlib/qsignaldumper.cpp @@ -87,7 +87,7 @@ static void qSignalDumperCallback(QObject *caller, int signal_index, void **argv str += objname.toLocal8Bit(); if (!objname.isEmpty()) str += ' '; - str += QByteArray::number(quintptr(caller), 16); + str += QByteArray::number(quintptr(caller), 16).rightJustified(8, '0'); str += ") "; str += member.name(); @@ -105,7 +105,7 @@ static void qSignalDumperCallback(QObject *caller, int signal_index, void **argv str += '@'; quintptr addr = quintptr(*reinterpret_cast(argv[i + 1])); - str.append(QByteArray::number(addr, 16)); + str.append(QByteArray::number(addr, 16).rightJustified(8, '0')); } else if (typeId != QMetaType::UnknownType) { Q_ASSERT(typeId != QMetaType::Void); // void parameter => metaobject is corrupt str.append(arg) @@ -144,7 +144,7 @@ static void qSignalDumperCallbackSlot(QObject *caller, int method_index, void ** str += objname.toLocal8Bit(); if (!objname.isEmpty()) str += ' '; - str += QByteArray::number(quintptr(caller), 16); + str += QByteArray::number(quintptr(caller), 16).rightJustified(8, '0'); str += ") "; str += member.methodSignature(); diff --git a/tests/auto/testlib/selftests/expected_signaldumper.lightxml b/tests/auto/testlib/selftests/expected_signaldumper.lightxml new file mode 100644 index 0000000000..f68834e1a2 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_signaldumper.lightxml @@ -0,0 +1,578 @@ + + @INSERT_QT_VERSION_HERE@ + + @INSERT_QT_VERSION_HERE@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ())]]> + + + ())]]> + + + &)@_POINTER_)]]> + + + ())]]> + + + *)_POINTER_)]]> + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/expected_signaldumper.tap b/tests/auto/testlib/selftests/expected_signaldumper.tap new file mode 100644 index 0000000000..04d7d94745 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_signaldumper.tap @@ -0,0 +1,151 @@ +TAP version 13 +# tst_Signaldumper +# Signal: QThread(_POINTER_) started () +ok 1 - initTestCase() +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +ok 2 - noConnections() +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +ok 3 - oneSlot(direct) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +ok 4 - oneSlot(queued) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Slot: SignalSlotClass(_POINTER_) slotWithoutParameters() +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Slot: SignalSlotClass(_POINTER_) slotWithoutParameters() +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +ok 5 - oneSlotOldSyntax(direct) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +ok 6 - oneSlotOldSyntax(queued) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +ok 7 - twoSlots(direct) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +ok 8 - twoSlots(queued) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Slot: SignalSlotClass(_POINTER_) slotWithoutParameters() +# Slot: SignalSlotClass(_POINTER_) slotWithoutParameters() +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char) +# Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Slot: SignalSlotClass(_POINTER_) slotWithoutParameters() +# Slot: SignalSlotClass(_POINTER_) slotWithoutParameters() +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +ok 9 - twoSlotsOldSyntax(direct) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +ok 10 - twoSlotsOldSyntax(queued) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Signal: SignalSlotClass(_POINTER_) nestedSignal () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: SignalSlotClass(_POINTER_) nestedSignal () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +ok 11 - signalForwarding(direct) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) nestedSignal () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m)) +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) nestedSignal () +ok 12 - signalForwarding(queued) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Slot: SignalSlotClass(_POINTER_) nestedSignal() +# Signal: SignalSlotClass(_POINTER_) nestedSignal () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Slot: SignalSlotClass(_POINTER_) nestedSignalWithParameters(int,char) +# Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Slot: SignalSlotClass(_POINTER_) nestedSignal() +# Signal: SignalSlotClass(_POINTER_) nestedSignal () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +ok 13 - signalForwardingOldSyntax(direct) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) nestedSignal () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m)) +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) nestedSignal () +ok 14 - signalForwardingOldSyntax(queued) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Signal: SignalSlotClass(_POINTER_) nestedSignal () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +ok 15 - slotEmittingSignal(direct) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) nestedSignal () +ok 16 - slotEmittingSignal(queued) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Slot: SignalSlotClass(_POINTER_) emitSecondSignal() +# Signal: SignalSlotClass(_POINTER_) nestedSignal () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +ok 17 - slotEmittingSignalOldSyntax(direct) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) nestedSignal () +ok 18 - slotEmittingSignalOldSyntax(queued) +# Signal: SignalSlotClass(_POINTER_) qStringSignal (QString(Test string)) +# Signal: SignalSlotClass(_POINTER_) qStringRefSignal ((QString&)@_POINTER_) +# Signal: SignalSlotClass(_POINTER_) qStringConstRefSignal (QString(Test string)) +# Signal: SignalSlotClass(_POINTER_) qByteArraySignal (QByteArray(Test bytearray)) +# Signal: SignalSlotClass(_POINTER_) qListSignal (QList()) +# Signal: SignalSlotClass(_POINTER_) qVectorSignal (QVector()) +# Signal: SignalSlotClass(_POINTER_) qVectorRefSignal ((QVector&)@_POINTER_) +# Signal: SignalSlotClass(_POINTER_) qVectorConstRefSignal (QVector()) +# Signal: SignalSlotClass(_POINTER_) qVectorConstPointerSignal ((const QVector*)_POINTER_) +# Signal: SignalSlotClass(_POINTER_) qVectorPointerConstSignal () +# Signal: SignalSlotClass(_POINTER_) qVariantSignal (QVariant()) +# Signal: SignalSlotClass(_POINTER_) qVariantSignal (QVariant()) +ok 19 - variousTypes() +ok 20 - cleanupTestCase() +# Signal: QThread(_POINTER_) finished () +1..20 +# tests 20 +# pass 20 +# fail 0 diff --git a/tests/auto/testlib/selftests/expected_signaldumper.teamcity b/tests/auto/testlib/selftests/expected_signaldumper.teamcity new file mode 100644 index 0000000000..3b8cf8c54f --- /dev/null +++ b/tests/auto/testlib/selftests/expected_signaldumper.teamcity @@ -0,0 +1,61 @@ +##teamcity[testSuiteStarted name='tst_Signaldumper' flowId='tst_Signaldumper'] +##teamcity[testStarted name='initTestCase()' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='initTestCase()' out='INFO: Signal: QThread(_POINTER_) started ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='initTestCase()' flowId='tst_Signaldumper'] +##teamcity[testStarted name='noConnections()' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='noConnections()' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))' flowId='tst_Signaldumper'] +##teamcity[testFinished name='noConnections()' flowId='tst_Signaldumper'] +##teamcity[testStarted name='oneSlot(direct)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='oneSlot(direct)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='oneSlot(direct)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='oneSlot(queued)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='oneSlot(queued)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='oneSlot(queued)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='oneSlotOldSyntax(direct)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='oneSlotOldSyntax(direct)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char)|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='oneSlotOldSyntax(direct)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='oneSlotOldSyntax(queued)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='oneSlotOldSyntax(queued)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='oneSlotOldSyntax(queued)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='twoSlots(direct)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='twoSlots(direct)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='twoSlots(direct)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='twoSlots(queued)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='twoSlots(queued)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='twoSlots(queued)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='twoSlotsOldSyntax(direct)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='twoSlotsOldSyntax(direct)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()|nINFO: Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char)|nINFO: Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char)|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()|nINFO: Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='twoSlotsOldSyntax(direct)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='twoSlotsOldSyntax(queued)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='twoSlotsOldSyntax(queued)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='twoSlotsOldSyntax(queued)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='signalForwarding(direct)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='signalForwarding(direct)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignal ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignal ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='signalForwarding(direct)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='signalForwarding(queued)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='signalForwarding(queued)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignal ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m))|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignal ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='signalForwarding(queued)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='signalForwardingOldSyntax(direct)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='signalForwardingOldSyntax(direct)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Slot: SignalSlotClass(_POINTER_) nestedSignal()|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignal ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Slot: SignalSlotClass(_POINTER_) nestedSignalWithParameters(int,char)|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Slot: SignalSlotClass(_POINTER_) nestedSignal()|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignal ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='signalForwardingOldSyntax(direct)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='signalForwardingOldSyntax(queued)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='signalForwardingOldSyntax(queued)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignal ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m))|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignal ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='signalForwardingOldSyntax(queued)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='slotEmittingSignal(direct)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='slotEmittingSignal(direct)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignal ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='slotEmittingSignal(direct)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='slotEmittingSignal(queued)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='slotEmittingSignal(queued)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignal ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='slotEmittingSignal(queued)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='slotEmittingSignalOldSyntax(direct)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='slotEmittingSignalOldSyntax(direct)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Slot: SignalSlotClass(_POINTER_) emitSecondSignal()|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignal ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='slotEmittingSignalOldSyntax(direct)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='slotEmittingSignalOldSyntax(queued)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='slotEmittingSignalOldSyntax(queued)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignal ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='slotEmittingSignalOldSyntax(queued)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='variousTypes()' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='variousTypes()' out='INFO: Signal: SignalSlotClass(_POINTER_) qStringSignal (QString(Test string))|nINFO: Signal: SignalSlotClass(_POINTER_) qStringRefSignal ((QString&)@_POINTER_)|nINFO: Signal: SignalSlotClass(_POINTER_) qStringConstRefSignal (QString(Test string))|nINFO: Signal: SignalSlotClass(_POINTER_) qByteArraySignal (QByteArray(Test bytearray))|nINFO: Signal: SignalSlotClass(_POINTER_) qListSignal (QList())|nINFO: Signal: SignalSlotClass(_POINTER_) qVectorSignal (QVector())|nINFO: Signal: SignalSlotClass(_POINTER_) qVectorRefSignal ((QVector&)@_POINTER_)|nINFO: Signal: SignalSlotClass(_POINTER_) qVectorConstRefSignal (QVector())|nINFO: Signal: SignalSlotClass(_POINTER_) qVectorConstPointerSignal ((const QVector*)_POINTER_)|nINFO: Signal: SignalSlotClass(_POINTER_) qVectorPointerConstSignal ()|nINFO: Signal: SignalSlotClass(_POINTER_) qVariantSignal (QVariant())|nINFO: Signal: SignalSlotClass(_POINTER_) qVariantSignal (QVariant())' flowId='tst_Signaldumper'] +##teamcity[testFinished name='variousTypes()' flowId='tst_Signaldumper'] +##teamcity[testStarted name='cleanupTestCase()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='cleanupTestCase()' flowId='tst_Signaldumper'] +##teamcity[testSuiteFinished name='tst_Signaldumper' flowId='tst_Signaldumper'] diff --git a/tests/auto/testlib/selftests/expected_signaldumper.txt b/tests/auto/testlib/selftests/expected_signaldumper.txt new file mode 100644 index 0000000000..f89c31afe5 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_signaldumper.txt @@ -0,0 +1,149 @@ +********* Start testing of tst_Signaldumper ********* +Config: Using QtTest library +INFO : tst_Signaldumper::initTestCase() Signal: QThread(_POINTER_) started () +PASS : tst_Signaldumper::initTestCase() +INFO : tst_Signaldumper::noConnections() Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::noConnections() Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +PASS : tst_Signaldumper::noConnections() +INFO : tst_Signaldumper::oneSlot(direct) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::oneSlot(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::oneSlot(direct) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::oneSlot(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::oneSlot(direct) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::oneSlot(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +PASS : tst_Signaldumper::oneSlot(direct) +INFO : tst_Signaldumper::oneSlot(queued) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::oneSlot(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::oneSlot(queued) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::oneSlot(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::oneSlot(queued) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::oneSlot(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +PASS : tst_Signaldumper::oneSlot(queued) +INFO : tst_Signaldumper::oneSlotOldSyntax(direct) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::oneSlotOldSyntax(direct) Slot: SignalSlotClass(_POINTER_) slotWithoutParameters() +INFO : tst_Signaldumper::oneSlotOldSyntax(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::oneSlotOldSyntax(direct) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::oneSlotOldSyntax(direct) Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char) +INFO : tst_Signaldumper::oneSlotOldSyntax(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::oneSlotOldSyntax(direct) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::oneSlotOldSyntax(direct) Slot: SignalSlotClass(_POINTER_) slotWithoutParameters() +INFO : tst_Signaldumper::oneSlotOldSyntax(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +PASS : tst_Signaldumper::oneSlotOldSyntax(direct) +INFO : tst_Signaldumper::oneSlotOldSyntax(queued) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::oneSlotOldSyntax(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::oneSlotOldSyntax(queued) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::oneSlotOldSyntax(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::oneSlotOldSyntax(queued) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::oneSlotOldSyntax(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +PASS : tst_Signaldumper::oneSlotOldSyntax(queued) +INFO : tst_Signaldumper::twoSlots(direct) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::twoSlots(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::twoSlots(direct) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::twoSlots(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::twoSlots(direct) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::twoSlots(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +PASS : tst_Signaldumper::twoSlots(direct) +INFO : tst_Signaldumper::twoSlots(queued) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::twoSlots(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::twoSlots(queued) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::twoSlots(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::twoSlots(queued) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::twoSlots(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +PASS : tst_Signaldumper::twoSlots(queued) +INFO : tst_Signaldumper::twoSlotsOldSyntax(direct) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::twoSlotsOldSyntax(direct) Slot: SignalSlotClass(_POINTER_) slotWithoutParameters() +INFO : tst_Signaldumper::twoSlotsOldSyntax(direct) Slot: SignalSlotClass(_POINTER_) slotWithoutParameters() +INFO : tst_Signaldumper::twoSlotsOldSyntax(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::twoSlotsOldSyntax(direct) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::twoSlotsOldSyntax(direct) Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char) +INFO : tst_Signaldumper::twoSlotsOldSyntax(direct) Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char) +INFO : tst_Signaldumper::twoSlotsOldSyntax(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::twoSlotsOldSyntax(direct) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::twoSlotsOldSyntax(direct) Slot: SignalSlotClass(_POINTER_) slotWithoutParameters() +INFO : tst_Signaldumper::twoSlotsOldSyntax(direct) Slot: SignalSlotClass(_POINTER_) slotWithoutParameters() +INFO : tst_Signaldumper::twoSlotsOldSyntax(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +PASS : tst_Signaldumper::twoSlotsOldSyntax(direct) +INFO : tst_Signaldumper::twoSlotsOldSyntax(queued) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::twoSlotsOldSyntax(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::twoSlotsOldSyntax(queued) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::twoSlotsOldSyntax(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::twoSlotsOldSyntax(queued) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::twoSlotsOldSyntax(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +PASS : tst_Signaldumper::twoSlotsOldSyntax(queued) +INFO : tst_Signaldumper::signalForwarding(direct) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::signalForwarding(direct) Signal: SignalSlotClass(_POINTER_) nestedSignal () +INFO : tst_Signaldumper::signalForwarding(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::signalForwarding(direct) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::signalForwarding(direct) Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::signalForwarding(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::signalForwarding(direct) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::signalForwarding(direct) Signal: SignalSlotClass(_POINTER_) nestedSignal () +INFO : tst_Signaldumper::signalForwarding(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +PASS : tst_Signaldumper::signalForwarding(direct) +INFO : tst_Signaldumper::signalForwarding(queued) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::signalForwarding(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::signalForwarding(queued) Signal: SignalSlotClass(_POINTER_) nestedSignal () +INFO : tst_Signaldumper::signalForwarding(queued) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::signalForwarding(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::signalForwarding(queued) Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::signalForwarding(queued) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::signalForwarding(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::signalForwarding(queued) Signal: SignalSlotClass(_POINTER_) nestedSignal () +PASS : tst_Signaldumper::signalForwarding(queued) +INFO : tst_Signaldumper::signalForwardingOldSyntax(direct) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::signalForwardingOldSyntax(direct) Slot: SignalSlotClass(_POINTER_) nestedSignal() +INFO : tst_Signaldumper::signalForwardingOldSyntax(direct) Signal: SignalSlotClass(_POINTER_) nestedSignal () +INFO : tst_Signaldumper::signalForwardingOldSyntax(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::signalForwardingOldSyntax(direct) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::signalForwardingOldSyntax(direct) Slot: SignalSlotClass(_POINTER_) nestedSignalWithParameters(int,char) +INFO : tst_Signaldumper::signalForwardingOldSyntax(direct) Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::signalForwardingOldSyntax(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::signalForwardingOldSyntax(direct) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::signalForwardingOldSyntax(direct) Slot: SignalSlotClass(_POINTER_) nestedSignal() +INFO : tst_Signaldumper::signalForwardingOldSyntax(direct) Signal: SignalSlotClass(_POINTER_) nestedSignal () +INFO : tst_Signaldumper::signalForwardingOldSyntax(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +PASS : tst_Signaldumper::signalForwardingOldSyntax(direct) +INFO : tst_Signaldumper::signalForwardingOldSyntax(queued) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::signalForwardingOldSyntax(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::signalForwardingOldSyntax(queued) Signal: SignalSlotClass(_POINTER_) nestedSignal () +INFO : tst_Signaldumper::signalForwardingOldSyntax(queued) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::signalForwardingOldSyntax(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::signalForwardingOldSyntax(queued) Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::signalForwardingOldSyntax(queued) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::signalForwardingOldSyntax(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::signalForwardingOldSyntax(queued) Signal: SignalSlotClass(_POINTER_) nestedSignal () +PASS : tst_Signaldumper::signalForwardingOldSyntax(queued) +INFO : tst_Signaldumper::slotEmittingSignal(direct) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::slotEmittingSignal(direct) Signal: SignalSlotClass(_POINTER_) nestedSignal () +INFO : tst_Signaldumper::slotEmittingSignal(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +PASS : tst_Signaldumper::slotEmittingSignal(direct) +INFO : tst_Signaldumper::slotEmittingSignal(queued) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::slotEmittingSignal(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::slotEmittingSignal(queued) Signal: SignalSlotClass(_POINTER_) nestedSignal () +PASS : tst_Signaldumper::slotEmittingSignal(queued) +INFO : tst_Signaldumper::slotEmittingSignalOldSyntax(direct) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::slotEmittingSignalOldSyntax(direct) Slot: SignalSlotClass(_POINTER_) emitSecondSignal() +INFO : tst_Signaldumper::slotEmittingSignalOldSyntax(direct) Signal: SignalSlotClass(_POINTER_) nestedSignal () +INFO : tst_Signaldumper::slotEmittingSignalOldSyntax(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +PASS : tst_Signaldumper::slotEmittingSignalOldSyntax(direct) +INFO : tst_Signaldumper::slotEmittingSignalOldSyntax(queued) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::slotEmittingSignalOldSyntax(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::slotEmittingSignalOldSyntax(queued) Signal: SignalSlotClass(_POINTER_) nestedSignal () +PASS : tst_Signaldumper::slotEmittingSignalOldSyntax(queued) +INFO : tst_Signaldumper::variousTypes() Signal: SignalSlotClass(_POINTER_) qStringSignal (QString(Test string)) +INFO : tst_Signaldumper::variousTypes() Signal: SignalSlotClass(_POINTER_) qStringRefSignal ((QString&)@_POINTER_) +INFO : tst_Signaldumper::variousTypes() Signal: SignalSlotClass(_POINTER_) qStringConstRefSignal (QString(Test string)) +INFO : tst_Signaldumper::variousTypes() Signal: SignalSlotClass(_POINTER_) qByteArraySignal (QByteArray(Test bytearray)) +INFO : tst_Signaldumper::variousTypes() Signal: SignalSlotClass(_POINTER_) qListSignal (QList()) +INFO : tst_Signaldumper::variousTypes() Signal: SignalSlotClass(_POINTER_) qVectorSignal (QVector()) +INFO : tst_Signaldumper::variousTypes() Signal: SignalSlotClass(_POINTER_) qVectorRefSignal ((QVector&)@_POINTER_) +INFO : tst_Signaldumper::variousTypes() Signal: SignalSlotClass(_POINTER_) qVectorConstRefSignal (QVector()) +INFO : tst_Signaldumper::variousTypes() Signal: SignalSlotClass(_POINTER_) qVectorConstPointerSignal ((const QVector*)_POINTER_) +INFO : tst_Signaldumper::variousTypes() Signal: SignalSlotClass(_POINTER_) qVectorPointerConstSignal () +INFO : tst_Signaldumper::variousTypes() Signal: SignalSlotClass(_POINTER_) qVariantSignal (QVariant()) +INFO : tst_Signaldumper::variousTypes() Signal: SignalSlotClass(_POINTER_) qVariantSignal (QVariant()) +PASS : tst_Signaldumper::variousTypes() +PASS : tst_Signaldumper::cleanupTestCase() +INFO : tst_Signaldumper::UnknownTestFunc() Signal: QThread(_POINTER_) finished () +Totals: 20 passed, 0 failed, 0 skipped, 0 blacklisted, 0ms +********* Finished testing of tst_Signaldumper ********* diff --git a/tests/auto/testlib/selftests/expected_signaldumper.xml b/tests/auto/testlib/selftests/expected_signaldumper.xml new file mode 100644 index 0000000000..82959c62df --- /dev/null +++ b/tests/auto/testlib/selftests/expected_signaldumper.xml @@ -0,0 +1,581 @@ + + + + @INSERT_QT_VERSION_HERE@ + + @INSERT_QT_VERSION_HERE@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ())]]> + + + ())]]> + + + &)@_POINTER_)]]> + + + ())]]> + + + *)_POINTER_)]]> + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/expected_signaldumper.xunitxml b/tests/auto/testlib/selftests/expected_signaldumper.xunitxml new file mode 100644 index 0000000000..930dc97262 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_signaldumper.xunitxml @@ -0,0 +1,284 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +())]]> +())]]> +&)@_POINTER_)]]> +())]]> +*)_POINTER_)]]> + + + + + + diff --git a/tests/auto/testlib/selftests/generate_expected_output.py b/tests/auto/testlib/selftests/generate_expected_output.py index 9ec87c8fc6..48ecbf0289 100755 --- a/tests/auto/testlib/selftests/generate_expected_output.py +++ b/tests/auto/testlib/selftests/generate_expected_output.py @@ -92,6 +92,17 @@ class Cleaner (object): (r'(Loc: \[[^[\]()]+)\(\d+\)', r'\1(0)'), # txt (r'(\[Loc: [^[\]()]+)\(\d+\)', r'\1(0)'), # teamcity (r'(<(?:Incident|Message)\b.*\bfile=.*\bline=)"\d+"', r'\1"0"'), # lightxml, xml + # Pointers printed by signal dumper: + (r'\(\b[a-f0-9]{8,}\b\)', r'(_POINTER_)'), + # Example/for reference: + # ((QString&)@55f5fbb8dd40) + # ((const QVector*)7ffd671d4558) + (r'\((\((?:const )?\w+(?:<[^>]+>)?[*&]*\)@?)\b[a-f\d]{8,}\b\)', r'(\1_POINTER_)'), + # For xml output there is no '<', '>' or '&', so we need an alternate version for that: + # ((QVector<int>&)@5608b455e640) + (r'\((\((?:const )?\w+(?:<(?:[^&]|&(?!gt;))*>)?(?:\*|&)?\)@?)[a-z\d]+\b\)', r'(\1_POINTER_)'), + # QEventDispatcher{Glib,Win32,etc.} + (r'\bQEventDispatcher\w+\b', r'QEventDispatcherPlatform'), ), precook = re.compile): """Private implementation details of __init__().""" @@ -296,6 +307,7 @@ def generateTestData(testname, clean, "benchlibcounting": "-eventcounter", "printdatatags": "-datatags", "printdatatagswithglobaltags": "-datatags", + "signaldumper": "-vs", "silent": "-silent", "verbose1": "-v1", "verbose2": "-v2", diff --git a/tests/auto/testlib/selftests/selftests.pri b/tests/auto/testlib/selftests/selftests.pri index b4568dd3e1..668eaeb6b5 100644 --- a/tests/auto/testlib/selftests/selftests.pri +++ b/tests/auto/testlib/selftests/selftests.pri @@ -37,6 +37,7 @@ SUBPROGRAMS = \ printdatatagswithglobaltags \ qexecstringlist \ silent \ + signaldumper \ singleskip \ skip \ skipcleanup \ diff --git a/tests/auto/testlib/selftests/signaldumper/signaldumper.pro b/tests/auto/testlib/selftests/signaldumper/signaldumper.pro new file mode 100644 index 0000000000..8780b18419 --- /dev/null +++ b/tests/auto/testlib/selftests/signaldumper/signaldumper.pro @@ -0,0 +1,9 @@ +SOURCES += tst_signaldumper.cpp +QT = core testlib-private + +macos:CONFIG -= app_bundle +CONFIG -= debug_and_release_target + +TARGET = signaldumper + +include($$QT_SOURCE_TREE/src/testlib/selfcover.pri) diff --git a/tests/auto/testlib/selftests/signaldumper/tst_signaldumper.cpp b/tests/auto/testlib/selftests/signaldumper/tst_signaldumper.cpp new file mode 100644 index 0000000000..f6cd0d510e --- /dev/null +++ b/tests/auto/testlib/selftests/signaldumper/tst_signaldumper.cpp @@ -0,0 +1,417 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** 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 +#include +#include + +class tst_Signaldumper : public QObject +{ + Q_OBJECT + + void addConnectionTypeData(); + +private slots: + void noConnections(); + void oneSlot_data(); + void oneSlot(); + void oneSlotOldSyntax_data(); + void oneSlotOldSyntax(); + void twoSlots_data(); + void twoSlots(); + void twoSlotsOldSyntax_data(); + void twoSlotsOldSyntax(); + void signalForwarding_data(); + void signalForwarding(); + void signalForwardingOldSyntax_data(); + void signalForwardingOldSyntax(); + void slotEmittingSignal_data(); + void slotEmittingSignal(); + void slotEmittingSignalOldSyntax_data(); + void slotEmittingSignalOldSyntax(); + + void variousTypes(); +}; + +void tst_Signaldumper::addConnectionTypeData() +{ + QTest::addColumn("connectionType"); + QTest::newRow("direct") << Qt::ConnectionType::DirectConnection; + QTest::newRow("queued") << Qt::ConnectionType::QueuedConnection; +} + +/* + Simple class to keep the slots and signals separate from the test +*/ +class SignalSlotClass : public QObject +{ + Q_OBJECT + +public: + SignalSlotClass(); + +public slots: + void slotWithoutParameters() {} + void slotWithParameters(int i, char c) { Q_UNUSED(i); Q_UNUSED(c); } + void emitSecondSignal() { emit nestedSignal(); } + +signals: + void signalWithoutParameters(); + void signalWithParameters(int i, char c); + + void nestedSignal(); + void nestedSignalWithParameters(int i, char c); + + // For the "variousTypes" test + void qStringSignal(QString string); + void qStringRefSignal(QString &string); + void qStringConstRefSignal(const QString &string); + void qByteArraySignal(QByteArray byteArray); + void qListSignal(QList list); + void qVectorSignal(QVector vector); + void qVectorRefSignal(QVector &vector); + void qVectorConstRefSignal(const QVector &vector); + void qVectorConstPointerSignal(const QVector *vector); + void qVectorPointerConstSignal(QVector *const vector); + void qVariantSignal(QVariant variant); +}; + +SignalSlotClass::SignalSlotClass() +{ + // For printing signal argument in "variousTypes" test + qRegisterMetaType>(); + qRegisterMetaType>(); +} + +void tst_Signaldumper::noConnections() +{ + SignalSlotClass signalSlotOwner; + + emit signalSlotOwner.signalWithoutParameters(); + emit signalSlotOwner.signalWithParameters(242, 'm'); +} + +void tst_Signaldumper::oneSlot_data() +{ + addConnectionTypeData(); +} + +void tst_Signaldumper::oneSlot() +{ + QFETCH(Qt::ConnectionType, connectionType); + + SignalSlotClass signalSlotOwner; + // parameterless to parameterless + auto connection = connect(&signalSlotOwner, &SignalSlotClass::signalWithoutParameters, + &signalSlotOwner, &SignalSlotClass::slotWithoutParameters, connectionType); + emit signalSlotOwner.signalWithoutParameters(); + + QCoreApplication::processEvents(); + disconnect(connection); + + // parameters to parameters + connection = connect(&signalSlotOwner, &SignalSlotClass::signalWithParameters, + &signalSlotOwner, &SignalSlotClass::slotWithParameters, connectionType); + emit signalSlotOwner.signalWithParameters(242, 'm'); + + QCoreApplication::processEvents(); + disconnect(connection); + + // parameters to no parameters + connection = connect(&signalSlotOwner, &SignalSlotClass::signalWithParameters, + &signalSlotOwner, &SignalSlotClass::slotWithoutParameters, connectionType); + emit signalSlotOwner.signalWithParameters(242, 'm'); + + QCoreApplication::processEvents(); + disconnect(connection); +} + +void tst_Signaldumper::oneSlotOldSyntax_data() +{ + addConnectionTypeData(); +} + +void tst_Signaldumper::oneSlotOldSyntax() +{ + QFETCH(Qt::ConnectionType, connectionType); + + SignalSlotClass signalSlotOwner; + // parameterless to parameterless + auto connection = connect(&signalSlotOwner, SIGNAL(signalWithoutParameters()), + &signalSlotOwner, SLOT(slotWithoutParameters()), connectionType); + emit signalSlotOwner.signalWithoutParameters(); + + QCoreApplication::processEvents(); + disconnect(connection); + + // parameters to parameters + connection = connect(&signalSlotOwner, SIGNAL(signalWithParameters(int, char)), + &signalSlotOwner, SLOT(slotWithParameters(int, char)), connectionType); + emit signalSlotOwner.signalWithParameters(242, 'm'); + + QCoreApplication::processEvents(); + disconnect(connection); + + // parameters to no parameters + connection = connect(&signalSlotOwner, SIGNAL(signalWithParameters(int, char)), + &signalSlotOwner, SLOT(slotWithoutParameters()), connectionType); + emit signalSlotOwner.signalWithParameters(242, 'm'); + + QCoreApplication::processEvents(); + disconnect(connection); +} + +void tst_Signaldumper::twoSlots_data() +{ + addConnectionTypeData(); +} + +void tst_Signaldumper::twoSlots() +{ + QFETCH(Qt::ConnectionType, connectionType); + + // Now, instead of creating two slots or two objects, we will just do the same connection twice. + // The same slot will then be invoked twice. + + SignalSlotClass signalSlotOwner; + // parameterless to parameterless + auto connection = connect(&signalSlotOwner, &SignalSlotClass::signalWithoutParameters, + &signalSlotOwner, &SignalSlotClass::slotWithoutParameters, connectionType); + auto connection2 = connect(&signalSlotOwner, &SignalSlotClass::signalWithoutParameters, + &signalSlotOwner, &SignalSlotClass::slotWithoutParameters, connectionType); + emit signalSlotOwner.signalWithoutParameters(); + + QCoreApplication::processEvents(); + disconnect(connection); + disconnect(connection2); + + // parameters to parameters + connection = connect(&signalSlotOwner, &SignalSlotClass::signalWithParameters, + &signalSlotOwner, &SignalSlotClass::slotWithParameters, connectionType); + connection2 = connect(&signalSlotOwner, &SignalSlotClass::signalWithParameters, + &signalSlotOwner, &SignalSlotClass::slotWithParameters, connectionType); + emit signalSlotOwner.signalWithParameters(242, 'm'); + + QCoreApplication::processEvents(); + disconnect(connection); + disconnect(connection2); + + // parameters to no parameters + connection = connect(&signalSlotOwner, &SignalSlotClass::signalWithParameters, + &signalSlotOwner, &SignalSlotClass::slotWithoutParameters, connectionType); + connection2 = connect(&signalSlotOwner, &SignalSlotClass::signalWithParameters, + &signalSlotOwner, &SignalSlotClass::slotWithoutParameters, connectionType); + emit signalSlotOwner.signalWithParameters(242, 'm'); + + QCoreApplication::processEvents(); + disconnect(connection); + disconnect(connection2); +} + +void tst_Signaldumper::twoSlotsOldSyntax_data() +{ + addConnectionTypeData(); +} + +void tst_Signaldumper::twoSlotsOldSyntax() +{ + QFETCH(Qt::ConnectionType, connectionType); + + // Now, instead of creating two slots or two objects, we will just do the same connection twice. + // The same slot will then be invoked twice. + + SignalSlotClass signalSlotOwner; + // parameterless to parameterless + auto connection = connect(&signalSlotOwner, SIGNAL(signalWithoutParameters()), + &signalSlotOwner, SLOT(slotWithoutParameters()), connectionType); + auto connection2 = connect(&signalSlotOwner, SIGNAL(signalWithoutParameters()), + &signalSlotOwner, SLOT(slotWithoutParameters()), connectionType); + emit signalSlotOwner.signalWithoutParameters(); + + QCoreApplication::processEvents(); + disconnect(connection); + disconnect(connection2); + + // parameters to parameters + connection = connect(&signalSlotOwner, SIGNAL(signalWithParameters(int, char)), + &signalSlotOwner, SLOT(slotWithParameters(int, char)), connectionType); + connection2 = connect(&signalSlotOwner, SIGNAL(signalWithParameters(int, char)), + &signalSlotOwner, SLOT(slotWithParameters(int, char)), connectionType); + emit signalSlotOwner.signalWithParameters(242, 'm'); + + QCoreApplication::processEvents(); + disconnect(connection); + disconnect(connection2); + + // parameters to no parameters + connection = connect(&signalSlotOwner, SIGNAL(signalWithParameters(int, char)), + &signalSlotOwner, SLOT(slotWithoutParameters()), connectionType); + connection2 = connect(&signalSlotOwner, SIGNAL(signalWithParameters(int, char)), + &signalSlotOwner, SLOT(slotWithoutParameters()), connectionType); + emit signalSlotOwner.signalWithParameters(242, 'm'); + + QCoreApplication::processEvents(); + disconnect(connection); + disconnect(connection2); +} + +void tst_Signaldumper::signalForwarding_data() +{ + addConnectionTypeData(); +} + +void tst_Signaldumper::signalForwarding() +{ + QFETCH(Qt::ConnectionType, connectionType); + + SignalSlotClass signalSlotOwner; + + // parameterless signal to parameterless signal + auto connection = connect(&signalSlotOwner, &SignalSlotClass::signalWithoutParameters, + &signalSlotOwner, &SignalSlotClass::nestedSignal, connectionType); + emit signalSlotOwner.signalWithoutParameters(); + + QCoreApplication::processEvents(); + disconnect(connection); + + // parameter(full) signal to parameter(full) signal + connection = connect(&signalSlotOwner, &SignalSlotClass::signalWithParameters, + &signalSlotOwner, &SignalSlotClass::nestedSignalWithParameters, connectionType); + emit signalSlotOwner.signalWithParameters(242, 'm'); + + QCoreApplication::processEvents(); + disconnect(connection); + + // parameter(full) signal to parameterless signal + connection = connect(&signalSlotOwner, &SignalSlotClass::signalWithParameters, + &signalSlotOwner, &SignalSlotClass::nestedSignal, connectionType); + emit signalSlotOwner.signalWithParameters(242, 'm'); + + QCoreApplication::processEvents(); + disconnect(connection); +} + +void tst_Signaldumper::signalForwardingOldSyntax_data() +{ + addConnectionTypeData(); +} + +void tst_Signaldumper::signalForwardingOldSyntax() +{ + QFETCH(Qt::ConnectionType, connectionType); + + SignalSlotClass signalSlotOwner; + + // parameterless signal to parameterless signal + auto connection = connect(&signalSlotOwner, SIGNAL(signalWithoutParameters()), + &signalSlotOwner, SIGNAL(nestedSignal()), connectionType); + emit signalSlotOwner.signalWithoutParameters(); + + QCoreApplication::processEvents(); + disconnect(connection); + + // parameter(full) signal to parameter(full) signal + connection = connect(&signalSlotOwner, SIGNAL(signalWithParameters(int, char)), + &signalSlotOwner, SIGNAL(nestedSignalWithParameters(int, char)), connectionType); + emit signalSlotOwner.signalWithParameters(242, 'm'); + + QCoreApplication::processEvents(); + disconnect(connection); + + // parameter(full) signal to parameterless signal + connection = connect(&signalSlotOwner, SIGNAL(signalWithParameters(int, char)), + &signalSlotOwner, SIGNAL(nestedSignal()), connectionType); + emit signalSlotOwner.signalWithParameters(242, 'm'); + + QCoreApplication::processEvents(); + disconnect(connection); +} + +void tst_Signaldumper::slotEmittingSignal_data() +{ + addConnectionTypeData(); +} + +void tst_Signaldumper::slotEmittingSignal() +{ + QFETCH(Qt::ConnectionType, connectionType); + + SignalSlotClass signalSlotOwner; + + auto connection = connect(&signalSlotOwner, &SignalSlotClass::signalWithoutParameters, + &signalSlotOwner, &SignalSlotClass::emitSecondSignal, connectionType); + emit signalSlotOwner.signalWithoutParameters(); + QCoreApplication::processEvents(); + disconnect(connection); +} + +void tst_Signaldumper::slotEmittingSignalOldSyntax_data() +{ + addConnectionTypeData(); +} + +void tst_Signaldumper::slotEmittingSignalOldSyntax() +{ + QFETCH(Qt::ConnectionType, connectionType); + + SignalSlotClass signalSlotOwner; + + auto connection = connect(&signalSlotOwner, SIGNAL(signalWithoutParameters()), + &signalSlotOwner, SLOT(emitSecondSignal()), connectionType); + emit signalSlotOwner.signalWithoutParameters(); + QCoreApplication::processEvents(); + disconnect(connection); +} + +void tst_Signaldumper::variousTypes() +{ + SignalSlotClass signalSlotOwner; + QString string = QString::fromLatin1("Test string"); + emit signalSlotOwner.qStringSignal(string); + emit signalSlotOwner.qStringRefSignal(string); + emit signalSlotOwner.qStringConstRefSignal(string); + emit signalSlotOwner.qByteArraySignal(QByteArray("Test bytearray")); + + QList list{1, 2, 3, 242}; + emit signalSlotOwner.qListSignal(list); + + QVector vector{1, 2, 3, 242}; + emit signalSlotOwner.qVectorSignal(vector); + emit signalSlotOwner.qVectorRefSignal(vector); + emit signalSlotOwner.qVectorConstRefSignal(vector); + emit signalSlotOwner.qVectorConstPointerSignal(&vector); + emit signalSlotOwner.qVectorPointerConstSignal(&vector); + + QVariant variant = 24; + emit signalSlotOwner.qVariantSignal(variant); + variant = QVariant(string); + emit signalSlotOwner.qVariantSignal(variant); +} + +QTEST_MAIN(tst_Signaldumper) +#include "tst_signaldumper.moc" diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index 3ef15b9261..7216c6a373 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -488,6 +488,7 @@ void tst_Selftests::runSubTest_data() << "printdatatags" << "printdatatagswithglobaltags" << "qexecstringlist" + << "signaldumper" << "silent" << "singleskip" << "skip" @@ -553,6 +554,9 @@ void tst_Selftests::runSubTest_data() else if (subtest == "printdatatagswithglobaltags") { arguments << "-datatags"; } + else if (subtest == "signaldumper") { + arguments << "-vs"; + } else if (subtest == "silent") { arguments << "-silent"; } @@ -953,6 +957,29 @@ bool tst_Selftests::compareLine(const QString &logger, const QString &subdir, if (actualLine.startsWith(QLatin1String("Totals:")) && expectedLine.startsWith(QLatin1String("Totals:"))) return true; + const QLatin1String pointerPlaceholder("_POINTER_"); + if (expectedLine.contains(pointerPlaceholder) + && (expectedLine.contains(QLatin1String("Signal: ")) + || expectedLine.contains(QLatin1String("Slot: ")))) { + QString actual = actualLine; + // We don't care about the pointer of the object to whom the signal belongs, so we + // replace it with _POINTER_, e.g.: + // Signal: SignalSlotClass(7ffd72245410) signalWithoutParameters () + // Signal: QThread(7ffd72245410) started () + // After this instance pointer we may have further pointers and + // references (with an @ prefix) as parameters of the signal or + // slot being invoked. + // Signal: SignalSlotClass(_POINTER_) qStringRefSignal ((QString&)@55f5fbb8dd40) + actual.replace(QRegularExpression("\\b[a-f0-9]{8,}\\b"), pointerPlaceholder); + // Also change QEventDispatcher{Glib,Win32,etc.} to QEventDispatcherPlatform + actual.replace(QRegularExpression("\\b(QEventDispatcher)\\w+\\b"), QLatin1String("\\1Platform")); + if (actual != expectedLine) { + *errorMessage = msgMismatch(actual, expectedLine); + return false; + } + return true; + } + *errorMessage = msgMismatch(actualLine, expectedLine); return false; } From 03ecdddb11ca71682d5d3b18bd4b74b9f9b2a3d6 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 26 Mar 2019 13:32:10 +0100 Subject: [PATCH 120/292] configure: Warn about redundant and contradictory options Configure will print notes in the following situations: - redundant options, e.g. -gui -gui - contradictory options, e.g. -gui -no-gui Fixes: QTBUG-53499 Change-Id: I6cf023e7730907069cf971f5982a41453f611c3c Reviewed-by: Kai Koehne --- mkspecs/features/qt_configure.prf | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mkspecs/features/qt_configure.prf b/mkspecs/features/qt_configure.prf index a9b1eef589..168a8e64f2 100644 --- a/mkspecs/features/qt_configure.prf +++ b/mkspecs/features/qt_configure.prf @@ -61,6 +61,13 @@ defineTest(qtConfCommandlineSetInput) { val = $${2} !isEmpty($${currentConfig}.commandline.options.$${arg}.name): \ arg = $$eval($${currentConfig}.commandline.options.$${arg}.name) + !isEmpty(config.input.$$arg) { + oldval = $$eval(config.input.$$arg) + equals(oldval, $$val): \ + qtConfAddNote("Option '$$arg' with value '$$val' was specified twice") + else: \ + qtConfAddNote("Overriding option '$$arg' with '$$val' (was: '$$oldval')") + } config.input.$$arg = $$val export(config.input.$$arg) From a868412a78c4a9c77beb7990177082eb2e9d17f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Tue, 26 Mar 2019 09:48:48 +0100 Subject: [PATCH 121/292] Cleanup widgets/kernel.pro after modularization QSound test lives in QtMultimedia. Change-Id: Id47b5744b9494c77eb2c2c0d1fe2f807d2dd2083 Reviewed-by: Friedemann Kleint --- tests/auto/widgets/kernel/kernel.pro | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/auto/widgets/kernel/kernel.pro b/tests/auto/widgets/kernel/kernel.pro index 73fd934502..af85a2bd13 100644 --- a/tests/auto/widgets/kernel/kernel.pro +++ b/tests/auto/widgets/kernel/kernel.pro @@ -22,5 +22,3 @@ SUBDIRS=\ darwin:SUBDIRS -= \ # Uses native recognizers qgesturerecognizer \ - -SUBDIRS -= qsound From 4a470101e4b4055eb0cac9143e2b06487f713dc3 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 25 Mar 2019 12:18:30 +0100 Subject: [PATCH 122/292] Stabilize auto test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't just wait for 300ms for the thread to finish, this can lead to faling tests esp. on slow hardware. Also fix a mem leak. Change-Id: Ifa90da5507fc6d65ef77e368d7c238271623ff53 Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Mårten Nordheim Reviewed-by: Jędrzej Nowacki --- tests/auto/other/qobjectrace/tst_qobjectrace.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/auto/other/qobjectrace/tst_qobjectrace.cpp b/tests/auto/other/qobjectrace/tst_qobjectrace.cpp index 0d656e223c..22782f6b09 100644 --- a/tests/auto/other/qobjectrace/tst_qobjectrace.cpp +++ b/tests/auto/other/qobjectrace/tst_qobjectrace.cpp @@ -378,6 +378,10 @@ public: connect(timer, &QTimer::timeout, this, &DeleteReceiverRaceReceiver::onTimeout); timer->start(1); } + ~DeleteReceiverRaceReceiver() + { + delete receiver; + } void onTimeout() { @@ -428,12 +432,12 @@ void tst_QObjectRace::disconnectRace() for (int i = 0; i < ThreadCount; ++i) { threads[i]->requestInterruption(); - QVERIFY(threads[i]->wait(300)); + QVERIFY(threads[i]->wait()); delete threads[i]; } senderThread->quit(); - QVERIFY(senderThread->wait(300)); + QVERIFY(senderThread->wait()); } QCOMPARE(countedStructObjectsCount.load(), 0u); @@ -453,11 +457,11 @@ void tst_QObjectRace::disconnectRace() QTest::qWait(TimeLimit); senderThread->requestInterruption(); - QVERIFY(senderThread->wait(300)); + QVERIFY(senderThread->wait()); for (int i = 0; i < ThreadCount; ++i) { threads[i]->quit(); - QVERIFY(threads[i]->wait(300)); + QVERIFY(threads[i]->wait()); delete threads[i]; } } From 369305a9be0eb96513be66a70611259d33842cfc Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 18 Jul 2017 18:43:56 +0200 Subject: [PATCH 123/292] Tidy up tst_globaldata to use better namings and document what it tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In particular, document the mis-behavior it takes for granted in one test. Renamed some variables so that they're visually distinct from one another and actually mean something intelligible. Renamed the sub-tests to say what's actually happening. Reading the test output now at least makes it possible to see what's wrong. I'll fix that in a later commit. Task-number: QTBUG-61774 Change-Id: I3e5f83b8baa3c6afbca9231b5bbc89d17f3e57e2 Reviewed-by: Jędrzej Nowacki --- .../selftests/expected_globaldata.lightxml | 126 +++++++++--------- .../testlib/selftests/expected_globaldata.tap | 62 ++++----- .../selftests/expected_globaldata.teamcity | 46 +++---- .../testlib/selftests/expected_globaldata.txt | 84 ++++++------ .../testlib/selftests/expected_globaldata.xml | 126 +++++++++--------- .../selftests/expected_globaldata.xunitxml | 112 ++++++++-------- .../selftests/globaldata/tst_globaldata.cpp | 41 +++--- 7 files changed, 299 insertions(+), 298 deletions(-) diff --git a/tests/auto/testlib/selftests/expected_globaldata.lightxml b/tests/auto/testlib/selftests/expected_globaldata.lightxml index f66c4c552d..e536031899 100644 --- a/tests/auto/testlib/selftests/expected_globaldata.lightxml +++ b/tests/auto/testlib/selftests/expected_globaldata.lightxml @@ -12,174 +12,174 @@ - - + + - + - + - - + + - + - - + + - + - + - - + + - + - - + + - + - + - - + + - + - - + + - + - + - - + + - + - + - - + + - + - - + + - - + + - + - - + + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - - + + - - + + - - + + - + - - + + - + diff --git a/tests/auto/testlib/selftests/expected_globaldata.tap b/tests/auto/testlib/selftests/expected_globaldata.tap index 580cf3a7a8..318299992f 100644 --- a/tests/auto/testlib/selftests/expected_globaldata.tap +++ b/tests/auto/testlib/selftests/expected_globaldata.tap @@ -2,48 +2,48 @@ TAP version 13 # tst_globaldata # initTestCase initTestCase (null) ok 1 - initTestCase() -# init testGlobal local 1 +# init testGlobal local=false # global: false # local: false -# cleanup testGlobal local 1 -ok 2 - testGlobal(1:local 1) -# init testGlobal local 2 +# cleanup testGlobal local=false +ok 2 - testGlobal(global=false:local=false) +# init testGlobal local=true # global: false # local: true -# cleanup testGlobal local 2 -ok 3 - testGlobal(1:local 2) -# init testGlobal local 1 +# cleanup testGlobal local=true +ok 3 - testGlobal(global=false:local=true) +# init testGlobal local=false # global: true # local: false -# cleanup testGlobal local 1 -ok 4 - testGlobal(2:local 1) -# init testGlobal local 2 +# cleanup testGlobal local=false +ok 4 - testGlobal(global=true:local=false) +# init testGlobal local=true # global: true # local: true -# cleanup testGlobal local 2 -ok 5 - testGlobal(2:local 2) -ok 6 - skip(1) # SKIP skipping -# init skipLocal local 1 -ok 7 - skipLocal(1:local 1) # SKIP skipping -# cleanup skipLocal local 1 -# init skipLocal local 2 -ok 8 - skipLocal(1:local 2) # SKIP skipping -# cleanup skipLocal local 2 -# init skipSingle local 1 +# cleanup testGlobal local=true +ok 5 - testGlobal(global=true:local=true) +ok 6 - skip(global=false) # SKIP skipping +# init skipLocal local=false +ok 7 - skipLocal(global=false:local=false) # SKIP skipping +# cleanup skipLocal local=false +# init skipLocal local=true +ok 8 - skipLocal(global=false:local=true) # SKIP skipping +# cleanup skipLocal local=true +# init skipSingle local=false # global: false local: false -# cleanup skipSingle local 1 -ok 9 - skipSingle(1:local 1) -# init skipSingle local 2 +# cleanup skipSingle local=false +ok 9 - skipSingle(global=false:local=false) +# init skipSingle local=true # global: false local: true -# cleanup skipSingle local 2 -ok 10 - skipSingle(1:local 2) -# init skipSingle local 1 -ok 11 - skipSingle(2:local 1) # SKIP skipping -# cleanup skipSingle local 1 -# init skipSingle local 2 +# cleanup skipSingle local=true +ok 10 - skipSingle(global=false:local=true) +# init skipSingle local=false +ok 11 - skipSingle(global=true:local=false) # SKIP Skipping +# cleanup skipSingle local=false +# init skipSingle local=true # global: true local: true -# cleanup skipSingle local 2 -ok 12 - skipSingle(2:local 2) +# cleanup skipSingle local=true +ok 12 - skipSingle(global=true:local=true) # cleanupTestCase cleanupTestCase (null) ok 13 - cleanupTestCase() 1..13 diff --git a/tests/auto/testlib/selftests/expected_globaldata.teamcity b/tests/auto/testlib/selftests/expected_globaldata.teamcity index 5d623a3285..2f9f97d912 100644 --- a/tests/auto/testlib/selftests/expected_globaldata.teamcity +++ b/tests/auto/testlib/selftests/expected_globaldata.teamcity @@ -2,30 +2,30 @@ ##teamcity[testStarted name='initTestCase()' flowId='tst_globaldata'] ##teamcity[testStdOut name='initTestCase()' out='QDEBUG: initTestCase initTestCase (null)' flowId='tst_globaldata'] ##teamcity[testFinished name='initTestCase()' flowId='tst_globaldata'] -##teamcity[testStarted name='testGlobal(local 1)' flowId='tst_globaldata'] -##teamcity[testStdOut name='testGlobal(local 1)' out='QDEBUG: init testGlobal local 1|nQDEBUG: global: false|nQDEBUG: local: false|nQDEBUG: cleanup testGlobal local 1' flowId='tst_globaldata'] -##teamcity[testFinished name='testGlobal(local 1)' flowId='tst_globaldata'] -##teamcity[testStarted name='testGlobal(local 2)' flowId='tst_globaldata'] -##teamcity[testStdOut name='testGlobal(local 2)' out='QDEBUG: init testGlobal local 2|nQDEBUG: global: false|nQDEBUG: local: true|nQDEBUG: cleanup testGlobal local 2' flowId='tst_globaldata'] -##teamcity[testFinished name='testGlobal(local 2)' flowId='tst_globaldata'] -##teamcity[testStarted name='testGlobal(local 1)' flowId='tst_globaldata'] -##teamcity[testStdOut name='testGlobal(local 1)' out='QDEBUG: init testGlobal local 1|nQDEBUG: global: true|nQDEBUG: local: false|nQDEBUG: cleanup testGlobal local 1' flowId='tst_globaldata'] -##teamcity[testFinished name='testGlobal(local 1)' flowId='tst_globaldata'] -##teamcity[testStarted name='testGlobal(local 2)' flowId='tst_globaldata'] -##teamcity[testStdOut name='testGlobal(local 2)' out='QDEBUG: init testGlobal local 2|nQDEBUG: global: true|nQDEBUG: local: true|nQDEBUG: cleanup testGlobal local 2' flowId='tst_globaldata'] -##teamcity[testFinished name='testGlobal(local 2)' flowId='tst_globaldata'] +##teamcity[testStarted name='testGlobal(local=false)' flowId='tst_globaldata'] +##teamcity[testStdOut name='testGlobal(local=false)' out='QDEBUG: init testGlobal local=false|nQDEBUG: global: false|nQDEBUG: local: false|nQDEBUG: cleanup testGlobal local=false' flowId='tst_globaldata'] +##teamcity[testFinished name='testGlobal(local=false)' flowId='tst_globaldata'] +##teamcity[testStarted name='testGlobal(local=true)' flowId='tst_globaldata'] +##teamcity[testStdOut name='testGlobal(local=true)' out='QDEBUG: init testGlobal local=true|nQDEBUG: global: false|nQDEBUG: local: true|nQDEBUG: cleanup testGlobal local=true' flowId='tst_globaldata'] +##teamcity[testFinished name='testGlobal(local=true)' flowId='tst_globaldata'] +##teamcity[testStarted name='testGlobal(local=false)' flowId='tst_globaldata'] +##teamcity[testStdOut name='testGlobal(local=false)' out='QDEBUG: init testGlobal local=false|nQDEBUG: global: true|nQDEBUG: local: false|nQDEBUG: cleanup testGlobal local=false' flowId='tst_globaldata'] +##teamcity[testFinished name='testGlobal(local=false)' flowId='tst_globaldata'] +##teamcity[testStarted name='testGlobal(local=true)' flowId='tst_globaldata'] +##teamcity[testStdOut name='testGlobal(local=true)' out='QDEBUG: init testGlobal local=true|nQDEBUG: global: true|nQDEBUG: local: true|nQDEBUG: cleanup testGlobal local=true' flowId='tst_globaldata'] +##teamcity[testFinished name='testGlobal(local=true)' flowId='tst_globaldata'] ##teamcity[testIgnored name='skip()' message='skipping |[Loc: qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)|]' flowId='tst_globaldata'] -##teamcity[testIgnored name='skipLocal(local 1)' message='skipping |[Loc: qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)|]' flowId='tst_globaldata'] -##teamcity[testIgnored name='skipLocal(local 2)' message='skipping |[Loc: qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)|]' flowId='tst_globaldata'] -##teamcity[testStarted name='skipSingle(local 1)' flowId='tst_globaldata'] -##teamcity[testStdOut name='skipSingle(local 1)' out='QDEBUG: init skipLocal local 1|nQDEBUG: cleanup skipLocal local 1|nQDEBUG: init skipLocal local 2|nQDEBUG: cleanup skipLocal local 2|nQDEBUG: init skipSingle local 1|nQDEBUG: global: false local: false|nQDEBUG: cleanup skipSingle local 1' flowId='tst_globaldata'] -##teamcity[testFinished name='skipSingle(local 1)' flowId='tst_globaldata'] -##teamcity[testStarted name='skipSingle(local 2)' flowId='tst_globaldata'] -##teamcity[testStdOut name='skipSingle(local 2)' out='QDEBUG: init skipSingle local 2|nQDEBUG: global: false local: true|nQDEBUG: cleanup skipSingle local 2' flowId='tst_globaldata'] -##teamcity[testFinished name='skipSingle(local 2)' flowId='tst_globaldata'] -##teamcity[testIgnored name='skipSingle(local 1)' message='skipping |[Loc: qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)|]' flowId='tst_globaldata'] -##teamcity[testStdOut name='skipSingle(local 2)' out='QDEBUG: init skipSingle local 1|nQDEBUG: cleanup skipSingle local 1|nQDEBUG: init skipSingle local 2|nQDEBUG: global: true local: true|nQDEBUG: cleanup skipSingle local 2' flowId='tst_globaldata'] -##teamcity[testFinished name='skipSingle(local 2)' flowId='tst_globaldata'] +##teamcity[testIgnored name='skipLocal(local=false)' message='skipping |[Loc: qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)|]' flowId='tst_globaldata'] +##teamcity[testIgnored name='skipLocal(local=true)' message='skipping |[Loc: qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)|]' flowId='tst_globaldata'] +##teamcity[testStarted name='skipSingle(local=false)' flowId='tst_globaldata'] +##teamcity[testStdOut name='skipSingle(local=false)' out='QDEBUG: init skipLocal local=false|nQDEBUG: cleanup skipLocal local=false|nQDEBUG: init skipLocal local=true|nQDEBUG: cleanup skipLocal local=true|nQDEBUG: init skipSingle local=false|nQDEBUG: global: false local: false|nQDEBUG: cleanup skipSingle local=false' flowId='tst_globaldata'] +##teamcity[testFinished name='skipSingle(local=false)' flowId='tst_globaldata'] +##teamcity[testStarted name='skipSingle(local=true)' flowId='tst_globaldata'] +##teamcity[testStdOut name='skipSingle(local=true)' out='QDEBUG: init skipSingle local=true|nQDEBUG: global: false local: true|nQDEBUG: cleanup skipSingle local=true' flowId='tst_globaldata'] +##teamcity[testFinished name='skipSingle(local=true)' flowId='tst_globaldata'] +##teamcity[testIgnored name='skipSingle(local=false)' message='Skipping |[Loc: qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)|]' flowId='tst_globaldata'] +##teamcity[testStdOut name='skipSingle(local=true)' out='QDEBUG: init skipSingle local=false|nQDEBUG: cleanup skipSingle local=false|nQDEBUG: init skipSingle local=true|nQDEBUG: global: true local: true|nQDEBUG: cleanup skipSingle local=true' flowId='tst_globaldata'] +##teamcity[testFinished name='skipSingle(local=true)' flowId='tst_globaldata'] ##teamcity[testStarted name='cleanupTestCase()' flowId='tst_globaldata'] ##teamcity[testStdOut name='cleanupTestCase()' out='QDEBUG: cleanupTestCase cleanupTestCase (null)' flowId='tst_globaldata'] ##teamcity[testFinished name='cleanupTestCase()' flowId='tst_globaldata'] diff --git a/tests/auto/testlib/selftests/expected_globaldata.txt b/tests/auto/testlib/selftests/expected_globaldata.txt index b12f4a2a69..b18568009a 100644 --- a/tests/auto/testlib/selftests/expected_globaldata.txt +++ b/tests/auto/testlib/selftests/expected_globaldata.txt @@ -2,52 +2,52 @@ Config: Using QtTest library QDEBUG : tst_globaldata::initTestCase() initTestCase initTestCase (null) PASS : tst_globaldata::initTestCase() -QDEBUG : tst_globaldata::testGlobal(1:local 1) init testGlobal local 1 -QDEBUG : tst_globaldata::testGlobal(1:local 1) global: false -QDEBUG : tst_globaldata::testGlobal(1:local 1) local: false -QDEBUG : tst_globaldata::testGlobal(1:local 1) cleanup testGlobal local 1 -PASS : tst_globaldata::testGlobal(1:local 1) -QDEBUG : tst_globaldata::testGlobal(1:local 2) init testGlobal local 2 -QDEBUG : tst_globaldata::testGlobal(1:local 2) global: false -QDEBUG : tst_globaldata::testGlobal(1:local 2) local: true -QDEBUG : tst_globaldata::testGlobal(1:local 2) cleanup testGlobal local 2 -PASS : tst_globaldata::testGlobal(1:local 2) -QDEBUG : tst_globaldata::testGlobal(2:local 1) init testGlobal local 1 -QDEBUG : tst_globaldata::testGlobal(2:local 1) global: true -QDEBUG : tst_globaldata::testGlobal(2:local 1) local: false -QDEBUG : tst_globaldata::testGlobal(2:local 1) cleanup testGlobal local 1 -PASS : tst_globaldata::testGlobal(2:local 1) -QDEBUG : tst_globaldata::testGlobal(2:local 2) init testGlobal local 2 -QDEBUG : tst_globaldata::testGlobal(2:local 2) global: true -QDEBUG : tst_globaldata::testGlobal(2:local 2) local: true -QDEBUG : tst_globaldata::testGlobal(2:local 2) cleanup testGlobal local 2 -PASS : tst_globaldata::testGlobal(2:local 2) -SKIP : tst_globaldata::skip(1) skipping +QDEBUG : tst_globaldata::testGlobal(global=false:local=false) init testGlobal local=false +QDEBUG : tst_globaldata::testGlobal(global=false:local=false) global: false +QDEBUG : tst_globaldata::testGlobal(global=false:local=false) local: false +QDEBUG : tst_globaldata::testGlobal(global=false:local=false) cleanup testGlobal local=false +PASS : tst_globaldata::testGlobal(global=false:local=false) +QDEBUG : tst_globaldata::testGlobal(global=false:local=true) init testGlobal local=true +QDEBUG : tst_globaldata::testGlobal(global=false:local=true) global: false +QDEBUG : tst_globaldata::testGlobal(global=false:local=true) local: true +QDEBUG : tst_globaldata::testGlobal(global=false:local=true) cleanup testGlobal local=true +PASS : tst_globaldata::testGlobal(global=false:local=true) +QDEBUG : tst_globaldata::testGlobal(global=true:local=false) init testGlobal local=false +QDEBUG : tst_globaldata::testGlobal(global=true:local=false) global: true +QDEBUG : tst_globaldata::testGlobal(global=true:local=false) local: false +QDEBUG : tst_globaldata::testGlobal(global=true:local=false) cleanup testGlobal local=false +PASS : tst_globaldata::testGlobal(global=true:local=false) +QDEBUG : tst_globaldata::testGlobal(global=true:local=true) init testGlobal local=true +QDEBUG : tst_globaldata::testGlobal(global=true:local=true) global: true +QDEBUG : tst_globaldata::testGlobal(global=true:local=true) local: true +QDEBUG : tst_globaldata::testGlobal(global=true:local=true) cleanup testGlobal local=true +PASS : tst_globaldata::testGlobal(global=true:local=true) +SKIP : tst_globaldata::skip(global=false) skipping Loc: [qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)] -QDEBUG : tst_globaldata::skipLocal(1:local 1) init skipLocal local 1 -SKIP : tst_globaldata::skipLocal(1:local 1) skipping +QDEBUG : tst_globaldata::skipLocal(global=false:local=false) init skipLocal local=false +SKIP : tst_globaldata::skipLocal(global=false:local=false) skipping Loc: [qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)] -QDEBUG : tst_globaldata::skipLocal(1:local 1) cleanup skipLocal local 1 -QDEBUG : tst_globaldata::skipLocal(1:local 2) init skipLocal local 2 -SKIP : tst_globaldata::skipLocal(1:local 2) skipping +QDEBUG : tst_globaldata::skipLocal(global=false:local=false) cleanup skipLocal local=false +QDEBUG : tst_globaldata::skipLocal(global=false:local=true) init skipLocal local=true +SKIP : tst_globaldata::skipLocal(global=false:local=true) skipping Loc: [qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)] -QDEBUG : tst_globaldata::skipLocal(1:local 2) cleanup skipLocal local 2 -QDEBUG : tst_globaldata::skipSingle(1:local 1) init skipSingle local 1 -QDEBUG : tst_globaldata::skipSingle(1:local 1) global: false local: false -QDEBUG : tst_globaldata::skipSingle(1:local 1) cleanup skipSingle local 1 -PASS : tst_globaldata::skipSingle(1:local 1) -QDEBUG : tst_globaldata::skipSingle(1:local 2) init skipSingle local 2 -QDEBUG : tst_globaldata::skipSingle(1:local 2) global: false local: true -QDEBUG : tst_globaldata::skipSingle(1:local 2) cleanup skipSingle local 2 -PASS : tst_globaldata::skipSingle(1:local 2) -QDEBUG : tst_globaldata::skipSingle(2:local 1) init skipSingle local 1 -SKIP : tst_globaldata::skipSingle(2:local 1) skipping +QDEBUG : tst_globaldata::skipLocal(global=false:local=true) cleanup skipLocal local=true +QDEBUG : tst_globaldata::skipSingle(global=false:local=false) init skipSingle local=false +QDEBUG : tst_globaldata::skipSingle(global=false:local=false) global: false local: false +QDEBUG : tst_globaldata::skipSingle(global=false:local=false) cleanup skipSingle local=false +PASS : tst_globaldata::skipSingle(global=false:local=false) +QDEBUG : tst_globaldata::skipSingle(global=false:local=true) init skipSingle local=true +QDEBUG : tst_globaldata::skipSingle(global=false:local=true) global: false local: true +QDEBUG : tst_globaldata::skipSingle(global=false:local=true) cleanup skipSingle local=true +PASS : tst_globaldata::skipSingle(global=false:local=true) +QDEBUG : tst_globaldata::skipSingle(global=true:local=false) init skipSingle local=false +SKIP : tst_globaldata::skipSingle(global=true:local=false) Skipping Loc: [qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)] -QDEBUG : tst_globaldata::skipSingle(2:local 1) cleanup skipSingle local 1 -QDEBUG : tst_globaldata::skipSingle(2:local 2) init skipSingle local 2 -QDEBUG : tst_globaldata::skipSingle(2:local 2) global: true local: true -QDEBUG : tst_globaldata::skipSingle(2:local 2) cleanup skipSingle local 2 -PASS : tst_globaldata::skipSingle(2:local 2) +QDEBUG : tst_globaldata::skipSingle(global=true:local=false) cleanup skipSingle local=false +QDEBUG : tst_globaldata::skipSingle(global=true:local=true) init skipSingle local=true +QDEBUG : tst_globaldata::skipSingle(global=true:local=true) global: true local: true +QDEBUG : tst_globaldata::skipSingle(global=true:local=true) cleanup skipSingle local=true +PASS : tst_globaldata::skipSingle(global=true:local=true) QDEBUG : tst_globaldata::cleanupTestCase() cleanupTestCase cleanupTestCase (null) PASS : tst_globaldata::cleanupTestCase() Totals: 9 passed, 0 failed, 4 skipped, 0 blacklisted, 0ms diff --git a/tests/auto/testlib/selftests/expected_globaldata.xml b/tests/auto/testlib/selftests/expected_globaldata.xml index 0f705ef352..b2f92016e5 100644 --- a/tests/auto/testlib/selftests/expected_globaldata.xml +++ b/tests/auto/testlib/selftests/expected_globaldata.xml @@ -14,174 +14,174 @@ - - + + - + - + - - + + - + - - + + - + - + - - + + - + - - + + - + - + - - + + - + - - + + - + - + - - + + - + - + - - + + - + - - + + - - + + - + - - + + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - - + + - - + + - - + + - + - - + + - + diff --git a/tests/auto/testlib/selftests/expected_globaldata.xunitxml b/tests/auto/testlib/selftests/expected_globaldata.xunitxml index bdd7e3f00a..b135240d26 100644 --- a/tests/auto/testlib/selftests/expected_globaldata.xunitxml +++ b/tests/auto/testlib/selftests/expected_globaldata.xunitxml @@ -9,88 +9,88 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + - - - - - - + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - + - - + + - - + + - - + + - + - + - - + + - - + + - - + + - - - - - + + + + + - + diff --git a/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp b/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp index 6c0ae1f43c..f425648ecc 100644 --- a/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp +++ b/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp @@ -66,9 +66,10 @@ void tst_globaldata::initTestCase() void tst_globaldata::initTestCase_data() { - QTest::addColumn("booli"); - QTest::newRow("1") << false; - QTest::newRow("2") << true; + // QFETCH_GLOBAL shall iterate these, for every test: + QTest::addColumn("global"); + QTest::newRow("global=false") << false; + QTest::newRow("global=true") << true; } void tst_globaldata::cleanupTestCase() @@ -94,41 +95,41 @@ void tst_globaldata::cleanup() void tst_globaldata::testGlobal_data() { - QTest::addColumn("booll"); - QTest::newRow("local 1") << false; - QTest::newRow("local 2") << true; + QTest::addColumn("local"); + QTest::newRow("local=false") << false; + QTest::newRow("local=true") << true; } void tst_globaldata::testGlobal() { - QFETCH_GLOBAL(bool, booli); - qDebug() << "global:" << booli; - QFETCH(bool, booll); - qDebug() << "local:" << booll; + QFETCH_GLOBAL(bool, global); + qDebug() << "global:" << global; + QFETCH(bool, local); + qDebug() << "local:" << local; } void tst_globaldata::skip_data() { - QTest::addColumn("booll"); - QTest::newRow("local 1") << false; - QTest::newRow("local 2") << true; - + testGlobal_data(); QSKIP("skipping"); } void tst_globaldata::skip() { - qDebug() << "this line should never be reached"; + // A skip in _data() causes the whole test to be skipped, for all global rows. + QVERIFY(!"This line should never be reached."); } void tst_globaldata::skipSingle() { - QFETCH_GLOBAL(bool, booli); - QFETCH(bool, booll); + QFETCH_GLOBAL(bool, global); + QFETCH(bool, local); - if (booli && !booll) - QSKIP("skipping"); - qDebug() << "global:" << booli << "local:" << booll; + // A skip in the last run of one global row suppresses the test in the next + // global row (where a skip in an earlier run of the first row does not). + if (global && !local) + QSKIP("Skipping"); + qDebug() << "global:" << global << "local:" << local; } void tst_globaldata::skipLocal() From 7d74404325118bb1551c38b3bae418b42db843a1 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 13 Mar 2019 19:15:27 +0100 Subject: [PATCH 124/292] Replace a misguided test with a valid one The code had min and max of an integral type and tested min + min / 2, which naturally overflowed, provoking a compiler warning. The test was meant to be testing min - min / 2; but min is even, so this is just min / 2; and doubling that won't overflow (which is what the test is about). As it happens, min + min / 2 is in fact max - max / 2, which *would* be a good value to test, since max is odd. So add a test for that and remove the broken test. Change-Id: Iec34acbf0d5d7993d41ff844875dc10480b8eb1f Reviewed-by: Qt CI Bot Reviewed-by: Thiago Macieira --- tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp index e567e465f7..0a84b1fdd8 100644 --- a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp +++ b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp @@ -508,13 +508,13 @@ template static void mulOverflow_template() QCOMPARE(mul_overflow(Int(max / 2), Int(3), &r), true); QCOMPARE(mul_overflow(mid1, Int(mid2 + 1), &r), true); QCOMPARE(mul_overflow(Int(max / 2 + 2), Int(2), &r), true); + QCOMPARE(mul_overflow(Int(max - max / 2), Int(2), &r), true); QCOMPARE(mul_overflow(Int(1ULL << (std::numeric_limits::digits - 1)), Int(2), &r), true); if (min) { QCOMPARE(mul_overflow(min, Int(2), &r), true); QCOMPARE(mul_overflow(Int(min / 2), Int(3), &r), true); QCOMPARE(mul_overflow(Int(min / 2 - 1), Int(2), &r), true); - QCOMPARE(mul_overflow(Int(min + min/2), Int(2), &r), true); } #endif } From 79f17db87932a6f1871e475a0610a248e941d9c2 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 26 Mar 2019 15:40:26 +0100 Subject: [PATCH 125/292] Suppress warnings about deprecated methods in their tests Fixed the other tests that used the methods, so that they now get the data from QLocale instead; and added the missing feature #if-ery, as these are textdate methods. Change-Id: I896f356bdf88037db23590c71d0aeb0b8722bfa7 Reviewed-by: Mitch Curtis --- tests/auto/corelib/tools/qdate/tst_qdate.cpp | 32 ++++++++++++-------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/tests/auto/corelib/tools/qdate/tst_qdate.cpp b/tests/auto/corelib/tools/qdate/tst_qdate.cpp index ce1e5730dd..c17af8741b 100644 --- a/tests/auto/corelib/tools/qdate/tst_qdate.cpp +++ b/tests/auto/corelib/tools/qdate/tst_qdate.cpp @@ -83,6 +83,7 @@ private slots: void negativeYear() const; void printNegativeYear() const; void roundtripGermanLocale() const; +#if QT_CONFIG(textdate) void shortDayName() const; void standaloneShortDayName() const; void longDayName() const; @@ -91,6 +92,7 @@ private slots: void standaloneShortMonthName() const; void longMonthName() const; void standaloneLongMonthName() const; +#endif // textdate void roundtrip() const; void qdebug() const; private: @@ -1038,18 +1040,18 @@ void tst_QDate::fromStringFormat_data() // Undo this (inline the C-locale versions) for ### Qt 6 // Get localized names: - QString january = QDate::longMonthName(1); - QString february = QDate::longMonthName(2); - QString march = QDate::longMonthName(3); - QString august = QDate::longMonthName(8); - QString mon = QDate::shortDayName(1); - QString monday = QDate::longDayName(1); - QString tuesday = QDate::longDayName(2); - QString wednesday = QDate::longDayName(3); - QString thursday = QDate::longDayName(4); - QString friday = QDate::longDayName(5); - QString saturday = QDate::longDayName(6); - QString sunday = QDate::longDayName(7); + QString january = QLocale::system().monthName(1, QLocale::LongFormat); + QString february = QLocale::system().monthName(2, QLocale::LongFormat); + QString march = QLocale::system().monthName(3, QLocale::LongFormat); + QString august = QLocale::system().monthName(8, QLocale::LongFormat); + QString mon = QLocale::system().dayName(1, QLocale::ShortFormat); + QString monday = QLocale::system().dayName(1, QLocale::LongFormat); + QString tuesday = QLocale::system().dayName(2, QLocale::LongFormat); + QString wednesday = QLocale::system().dayName(3, QLocale::LongFormat); + QString thursday = QLocale::system().dayName(4, QLocale::LongFormat); + QString friday = QLocale::system().dayName(5, QLocale::LongFormat); + QString saturday = QLocale::system().dayName(6, QLocale::LongFormat); + QString sunday = QLocale::system().dayName(7, QLocale::LongFormat); QTest::newRow("data0") << QString("") << QString("") << defDate(); QTest::newRow("data1") << QString(" ") << QString("") << invalidDate(); @@ -1305,6 +1307,10 @@ void tst_QDate::roundtripGermanLocale() const theDateTime.fromString(theDateTime.toString(Qt::TextDate), Qt::TextDate); } +#if QT_CONFIG(textdate) +QT_WARNING_PUSH // the methods tested here are all deprecated +QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations") + void tst_QDate::shortDayName() const { QCOMPARE(QDate::shortDayName(0), QString()); @@ -1432,6 +1438,8 @@ void tst_QDate::standaloneLongMonthName() const QCOMPARE(QDate::longMonthName(i, QDate::StandaloneFormat), locale.standaloneMonthName(i, QLocale::LongFormat)); } } +QT_WARNING_POP +#endif // textdate void tst_QDate::roundtrip() const { From a2fda801cc2e3558d8bcf7a002df6a824f9509fa Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Mon, 25 Mar 2019 12:47:14 +0100 Subject: [PATCH 126/292] tslib: initialize members in declaration Change-Id: I887d0c82a4819712ea3d908df745516186aa76f0 Reviewed-by: Laszlo Agocs --- src/platformsupport/input/tslib/qtslib.cpp | 4 +--- src/platformsupport/input/tslib/qtslib_p.h | 9 +++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/platformsupport/input/tslib/qtslib.cpp b/src/platformsupport/input/tslib/qtslib.cpp index 75ac3c50e0..20a9824969 100644 --- a/src/platformsupport/input/tslib/qtslib.cpp +++ b/src/platformsupport/input/tslib/qtslib.cpp @@ -57,7 +57,7 @@ QTsLibMouseHandler::QTsLibMouseHandler(const QString &key, const QString &specification, QObject *parent) : QObject(parent), - m_notify(0), m_x(0), m_y(0), m_pressed(0), m_rawMode(false) + m_rawMode(!key.compare(QLatin1String("TslibRaw"), Qt::CaseInsensitive)) { qCDebug(qLcTsLib) << "Initializing tslib plugin" << key << specification; setObjectName(QLatin1String("TSLib Mouse Handler")); @@ -79,8 +79,6 @@ QTsLibMouseHandler::QTsLibMouseHandler(const QString &key, if (ts_config(m_dev)) qErrnoWarning(errno, "ts_config() failed"); - m_rawMode = !key.compare(QLatin1String("TslibRaw"), Qt::CaseInsensitive); - int fd = ts_fd(m_dev); if (fd >= 0) { qCDebug(qLcTsLib) << "tslib device is" << device; diff --git a/src/platformsupport/input/tslib/qtslib_p.h b/src/platformsupport/input/tslib/qtslib_p.h index 0c08fb6a3d..ffd60cd0e3 100644 --- a/src/platformsupport/input/tslib/qtslib_p.h +++ b/src/platformsupport/input/tslib/qtslib_p.h @@ -71,11 +71,12 @@ private slots: void readMouseData(); private: - QSocketNotifier * m_notify; + QSocketNotifier * m_notify = nullptr; tsdev *m_dev; - int m_x, m_y; - bool m_pressed; - bool m_rawMode; + int m_x = 0; + int m_y = 0; + bool m_pressed = false; + const bool m_rawMode; }; QT_END_NAMESPACE From e2fdd7a9cbc6293c07b7c316b9ea3e9f4d6faf29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Thu, 28 Mar 2019 14:00:28 +0100 Subject: [PATCH 127/292] Remove commented test in testlib (alive) The test was added as commented in 2012, before it was not even mentioned in the pro file. I guess it was never run. Change-Id: Ib787c7811ab4f7f32a99869167cde2e12dbe3156 --- tests/auto/testlib/selftests/alive/.gitignore | 1 - tests/auto/testlib/selftests/alive/alive.pro | 10 -- .../testlib/selftests/alive/qtestalive.cpp | 147 ------------------ .../testlib/selftests/alive/tst_alive.cpp | 84 ---------- tests/auto/testlib/selftests/selftests.pri | 1 - .../auto/testlib/selftests/tst_selftests.cpp | 1 - 6 files changed, 244 deletions(-) delete mode 100644 tests/auto/testlib/selftests/alive/.gitignore delete mode 100644 tests/auto/testlib/selftests/alive/alive.pro delete mode 100644 tests/auto/testlib/selftests/alive/qtestalive.cpp delete mode 100644 tests/auto/testlib/selftests/alive/tst_alive.cpp diff --git a/tests/auto/testlib/selftests/alive/.gitignore b/tests/auto/testlib/selftests/alive/.gitignore deleted file mode 100644 index 561285c5d0..0000000000 --- a/tests/auto/testlib/selftests/alive/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_alive diff --git a/tests/auto/testlib/selftests/alive/alive.pro b/tests/auto/testlib/selftests/alive/alive.pro deleted file mode 100644 index bda0db2282..0000000000 --- a/tests/auto/testlib/selftests/alive/alive.pro +++ /dev/null @@ -1,10 +0,0 @@ -SOURCES += tst_alive.cpp -QT = core testlib - -mac:CONFIG -= app_bundle -CONFIG -= debug_and_release_target - - -TARGET = alive - -include($$QT_SOURCE_TREE/src/testlib/selfcover.pri) diff --git a/tests/auto/testlib/selftests/alive/qtestalive.cpp b/tests/auto/testlib/selftests/alive/qtestalive.cpp deleted file mode 100644 index 0200f2a563..0000000000 --- a/tests/auto/testlib/selftests/alive/qtestalive.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** 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 -#include -#include - -class QTestAliveEvent: public QEvent -{ -public: - - enum { AliveEventType = QEvent::User + 422 }; - - explicit inline QTestAliveEvent(int aSequenceId) - : QEvent(QEvent::Type(AliveEventType)), seqId(aSequenceId) - {} - inline int sequenceId() const { return seqId; } - -private: - int seqId; -}; - -class QTestAlivePinger: public QObject -{ -public: - QTestAlivePinger(QObject *receiver, QObject *parent = 0); - bool event(QEvent *e); - -protected: - void timerEvent(QTimerEvent *event); - -private: - QObject *rec; - int timerId; - int currentSequenceId; - int lastSequenceId; -}; - -QTestAlivePinger::QTestAlivePinger(QObject *receiver, QObject *parent) - : QObject(parent), rec(receiver), currentSequenceId(0), lastSequenceId(0) -{ - if (!rec) - qFatal("Null receiver object passed to QTestAlivePinger::QTestAlivePinger()"); - timerId = startTimer(850); -} - -bool QTestAlivePinger::event(QEvent *event) -{ - // pong received - if (int(event->type()) == QTestAliveEvent::AliveEventType) { - QTestAliveEvent *e = static_cast(event); - //qDebug("PONG %d received", e->sequenceId()); - // if the events are not delivered in order, we don't care. - if (e->sequenceId() > lastSequenceId) - lastSequenceId = e->sequenceId(); - return true; - } - return QObject::event(event); -} - -void QTestAlivePinger::timerEvent(QTimerEvent *event) -{ - if (event->timerId() != timerId) - return; - - if (lastSequenceId < currentSequenceId - 2) { - qWarning("TEST LAGS %d PINGS behind!", currentSequenceId - lastSequenceId); - } - ++currentSequenceId; - //qDebug("PING %d", currentSequenceId); - QCoreApplication::postEvent(rec, new QTestAliveEvent(currentSequenceId)); -} - -class QTestAlive: public QThread -{ -public: - QTestAlive(QObject *parent = 0); - ~QTestAlive(); - void run(); - - bool event(QEvent *e); - -private: - QTestAlivePinger *pinger; -}; - -QTestAlive::QTestAlive(QObject *parent) - : QThread(parent), pinger(0) -{ -} - -QTestAlive::~QTestAlive() -{ - quit(); - while (isRunning()); -} - -bool QTestAlive::event(QEvent *e) -{ - if (int(e->type()) == QTestAliveEvent::AliveEventType && pinger) { - // ping received, send back the pong - //qDebug("PONG %d", static_cast(e)->sequenceId()); - QCoreApplication::postEvent(pinger, - new QTestAliveEvent(static_cast(e)->sequenceId())); - return true; - } - return QThread::event(e); -} - -void QTestAlive::run() -{ - if (!QCoreApplication::instance()) - qFatal("QTestAlive::run(): Cannot start QTestAlive without a QCoreApplication instance."); - - QTestAlivePinger p(this); - pinger = &p; - exec(); - pinger = 0; -} - - diff --git a/tests/auto/testlib/selftests/alive/tst_alive.cpp b/tests/auto/testlib/selftests/alive/tst_alive.cpp deleted file mode 100644 index eeb77b18c0..0000000000 --- a/tests/auto/testlib/selftests/alive/tst_alive.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** 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 -#include - -#include "qtestalive.cpp" - -class tst_Alive: public QObject -{ - Q_OBJECT - -private slots: - void alive(); - void addMouseDClick() const; -}; - -void tst_Alive::alive() -{ - QTestAlive a; - a.start(); - - sleep(5); - QCoreApplication::processEvents(); - qDebug("CUT"); - sleep(5); -} - -void tst_Alive::addMouseDClick() const -{ - class DClickListener : public QWidget - { - public: - DClickListener() : isTested(false) - { - } - - bool isTested; - protected: - virtual void mouseDoubleClickEvent(QMouseEvent * event) - { - isTested = true; - QCOMPARE(event->type(), QEvent::MouseButtonDblClick); - } - }; - - DClickListener listener; - - QTestEventList list; - list.addMouseDClick(Qt::LeftButton); - - list.simulate(&listener); - /* Check that we have been called at all. */ - QVERIFY(listener.isTested); -} - -QTEST_MAIN(tst_Alive) -#include "tst_alive.moc" diff --git a/tests/auto/testlib/selftests/selftests.pri b/tests/auto/testlib/selftests/selftests.pri index b4568dd3e1..57b41bb5fc 100644 --- a/tests/auto/testlib/selftests/selftests.pri +++ b/tests/auto/testlib/selftests/selftests.pri @@ -1,5 +1,4 @@ SUBPROGRAMS = \ - #alive \ assert \ badxml \ benchlibcallgrind \ diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index 3ef15b9261..3a242d0493 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -439,7 +439,6 @@ void tst_Selftests::runSubTest_data() QTest::addColumn("crashes"); QStringList tests = QStringList() -// << "alive" // timer dependent #if !defined(Q_OS_WIN) // On windows, assert does nothing in release mode and blocks execution // with a popup window in debug mode. From 6e0b5dadc7e91be786411809f1f9667c239168e2 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 9 Jan 2019 19:12:46 +0100 Subject: [PATCH 128/292] Change cleanup mechanism for orphaned connections Put all connections that get disconnected into a singly linked orphaned list. Whenever the refcount on the connectionData drops down to one, this list can safely be cleared, even with the planned removal of locking in activate(). Use an id integer in the connection to acoid activating newly added connections. Fixes: QTBUG-72649 Change-Id: Ide3d116ae7fc9ca497598c1c2b71d43b4339c92d Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/kernel/qmetaobject_p.h | 2 +- src/corelib/kernel/qobject.cpp | 185 ++++++------------ src/corelib/kernel/qobject_p.h | 109 ++++++++++- .../corelib/kernel/qobject/tst_qobject.cpp | 7 +- 4 files changed, 167 insertions(+), 136 deletions(-) diff --git a/src/corelib/kernel/qmetaobject_p.h b/src/corelib/kernel/qmetaobject_p.h index 26d86fdf14..0cd9da2eac 100644 --- a/src/corelib/kernel/qmetaobject_p.h +++ b/src/corelib/kernel/qmetaobject_p.h @@ -232,7 +232,7 @@ struct QMetaObjectPrivate const QMetaObject *smeta, const QObject *receiver, int method_index, void **slot, DisconnectType = DisconnectAll); - static inline bool disconnectHelper(QObjectPrivate::Connection *c, + static inline bool disconnectHelper(QObjectPrivate::ConnectionData *connections, int signalIndex, const QObject *receiver, int method_index, void **slot, QBasicMutex *senderMutex, DisconnectType = DisconnectAll); #endif diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 268f3949fd..77e58abfa2 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Copyright (C) 2016 Intel Corporation. ** Copyright (C) 2013 Olivier Goffart ** Contact: https://www.qt.io/licensing/ @@ -332,14 +332,15 @@ void QObjectPrivate::addConnection(int signal, Connection *c) ConnectionList &connectionList = cd->connectionsForSignal(signal); if (connectionList.last) { + Q_ASSERT(connectionList.last->receiver); connectionList.last->nextConnectionList = c; } else { connectionList.first = c; } + c->id = ++cd->currentConnectionId; + c->prevConnectionList = connectionList.last; connectionList.last = c; - cleanConnectionLists(); - QObjectPrivate *rd = QObjectPrivate::get(c->receiver); rd->ensureConnectionData(); @@ -350,39 +351,27 @@ void QObjectPrivate::addConnection(int signal, Connection *c) c->next->prev = &c->next; } -void QObjectPrivate::cleanConnectionLists() +void QObjectPrivate::ConnectionData::cleanOrphanedConnectionsImpl(QObject *sender) { - ConnectionData *cd = connections.load(); - if (cd->dirty && cd->ref == 1) { - // remove broken connections - for (int signal = -1; signal < cd->signalVector.count(); ++signal) { - ConnectionList &connectionList = cd->connectionsForSignal(signal); + Connection *c = nullptr; + { + QBasicMutexLocker l(signalSlotLock(sender)); + if (ref > 1) + return; - // Set to the last entry in the connection list that was *not* - // deleted. This is needed to update the list's last pointer - // at the end of the cleanup. - QObjectPrivate::Connection *last = 0; - - QObjectPrivate::Connection **prev = &connectionList.first; - QObjectPrivate::Connection *c = *prev; - while (c) { - if (c->receiver) { - last = c; - prev = &c->nextConnectionList; - c = *prev; - } else { - QObjectPrivate::Connection *next = c->nextConnectionList; - *prev = next; - c->deref(); - c = next; - } - } - - // Correct the connection list's last pointer. - // As conectionList.last could equal last, this could be a noop - connectionList.last = last; - } - cd->dirty = false; + // Since ref == 1, no activate() is in process since we locked the mutex. That implies, + // that nothing can reference the orphaned connection objects anymore and they can + // be safely deleted + c = orphaned.load(); + orphaned.store(nullptr); + } + while (c) { + Q_ASSERT(!c->receiver); + Q_ASSERT(!c->prev); + QObjectPrivate::Connection *next = c->nextInOrphanList; + c->freeSlotObject(); + c->deref(); + c = next; } } @@ -905,47 +894,22 @@ QObject::~QObject() QObjectPrivate::ConnectionList &connectionList = cd->connectionsForSignal(signal); while (QObjectPrivate::Connection *c = connectionList.first) { - if (!c->receiver) { - connectionList.first = c->nextConnectionList; - c->deref(); - continue; - } + Q_ASSERT(c->receiver); QBasicMutex *m = signalSlotLock(c->receiver); bool needToUnlock = QOrderedMutexLocker::relock(signalSlotMutex, m); - if (c->receiver) { - *c->prev = c->next; - if (c->next) c->next->prev = c->prev; + cd->removeConnection(c); + Q_ASSERT(connectionList.first != c); } - c->receiver = 0; if (needToUnlock) m->unlock(); - - connectionList.first = c->nextConnectionList; - - // The destroy operation must happen outside the lock - if (c->isSlotObject) { - c->isSlotObject = false; - locker.unlock(); - c->slotObj->destroyIfLastRef(); - locker.relock(); - } - c->deref(); } } /* Disconnect all senders: - * This loop basically just does - * for (node = d->senders; node; node = node->next) { ... } - * - * We need to temporarily unlock the receiver mutex to destroy the functors or to lock the - * sender's mutex. And when the mutex is released, node->next might be destroyed by another - * thread. That's why we set node->prev to &node, that way, if node is destroyed, node will - * be updated. */ - QObjectPrivate::Connection *node = cd->senders; - while (node) { + while (QObjectPrivate::Connection *node = cd->senders) { Q_ASSERT(node->receiver); QObject *sender = node->sender; // Send disconnectNotify before removing the connection from sender's connection list. @@ -953,19 +917,17 @@ QObject::~QObject() // and not finish until we release it. sender->disconnectNotify(QMetaObjectPrivate::signal(sender->metaObject(), node->signal_index)); QBasicMutex *m = signalSlotLock(sender); - node->prev = &node; bool needToUnlock = QOrderedMutexLocker::relock(signalSlotMutex, m); //the node has maybe been removed while the mutex was unlocked in relock? - if (!node || node->sender != sender) { + if (node != cd->senders) { // We hold the wrong mutex Q_ASSERT(needToUnlock); m->unlock(); continue; } - node->receiver = 0; + QObjectPrivate::ConnectionData *senderData = sender->d_func()->connections.load(); - if (senderData) - senderData->dirty = true; + Q_ASSERT(senderData); QtPrivate::QSlotObjectBase *slotObj = nullptr; if (node->isSlotObject) { @@ -973,20 +935,20 @@ QObject::~QObject() node->isSlotObject = false; } - node = node->next; + senderData->removeConnection(node); if (needToUnlock) m->unlock(); if (slotObj) { - if (node) - node->prev = &node; locker.unlock(); slotObj->destroyIfLastRef(); locker.relock(); } } - cd->objectDeleted = true; + // invalidate all connections on the object and make sure + // activate() will skip them + cd->currentConnectionId.store(0); } if (cd && !cd->ref.deref()) delete cd; @@ -3333,16 +3295,19 @@ bool QMetaObject::disconnectOne(const QObject *sender, int signal_index, \internal Helper function to remove the connection from the senders list and setting the receivers to 0 */ -bool QMetaObjectPrivate::disconnectHelper(QObjectPrivate::Connection *c, +bool QMetaObjectPrivate::disconnectHelper(QObjectPrivate::ConnectionData *connections, int signalIndex, const QObject *receiver, int method_index, void **slot, QBasicMutex *senderMutex, DisconnectType disconnectType) { bool success = false; + + auto &connectionList = connections->connectionsForSignal(signalIndex); + auto *c = connectionList.first; while (c) { if (c->receiver - && (receiver == 0 || (c->receiver == receiver + && (receiver == nullptr || (c->receiver == receiver && (method_index < 0 || (!c->isSlotObject && c->method() == method_index)) - && (slot == 0 || (c->isSlotObject && c->slotObj->compare(slot)))))) { + && (slot == nullptr || (c->isSlotObject && c->slotObj->compare(slot)))))) { bool needToUnlock = false; QBasicMutex *receiverMutex = nullptr; if (c->receiver) { @@ -3350,24 +3315,12 @@ bool QMetaObjectPrivate::disconnectHelper(QObjectPrivate::Connection *c, // need to relock this receiver and sender in the correct order needToUnlock = QOrderedMutexLocker::relock(senderMutex, receiverMutex); } - if (c->receiver) { - *c->prev = c->next; - if (c->next) - c->next->prev = c->prev; - } + if (c->receiver) + connections->removeConnection(c); if (needToUnlock) receiverMutex->unlock(); - c->receiver = 0; - - if (c->isSlotObject) { - c->isSlotObject = false; - senderMutex->unlock(); - c->slotObj->destroyIfLastRef(); - senderMutex->lock(); - } - success = true; if (disconnectType == DisconnectOne) @@ -3407,23 +3360,19 @@ bool QMetaObjectPrivate::disconnect(const QObject *sender, if (signal_index < 0) { // remove from all connection lists for (int sig_index = -1; sig_index < scd->signalVector.count(); ++sig_index) { - QObjectPrivate::Connection *c = scd->connectionsForSignal(sig_index).first; - if (disconnectHelper(c, receiver, method_index, slot, senderMutex, disconnectType)) { + if (disconnectHelper(connections.data(), sig_index, receiver, method_index, slot, senderMutex, disconnectType)) success = true; - scd->dirty = true; - } } } else if (signal_index < scd->signalVector.count()) { - QObjectPrivate::Connection *c = scd->signalVector.at(signal_index).first; - if (disconnectHelper(c, receiver, method_index, slot, senderMutex, disconnectType)) { + if (disconnectHelper(connections.data(), signal_index, receiver, method_index, slot, senderMutex, disconnectType)) success = true; - scd->dirty = true; - } } } locker.unlock(); if (success) { + scd->cleanOrphanedConnections(s); + QMetaMethod smethod = QMetaObjectPrivate::signal(smeta, signal_index); if (smethod.isValid()) s->disconnectNotify(smethod); @@ -3630,6 +3579,7 @@ void doActivate(QObject *sender, int signal_index, void **argv) signal_spy_set->signal_begin_callback(sender, signal_index, argv); Q_TRACE(QMetaObject_activate_begin_signal, sender, signal_index); + bool senderDeleted = false; { QBasicMutexLocker locker(signalSlotLock(sender)); Q_ASSERT(sp->connections); @@ -3643,12 +3593,13 @@ void doActivate(QObject *sender, int signal_index, void **argv) Qt::HANDLE currentThreadId = QThread::currentThreadId(); + // We need to check against the highest connection id to ensure that signals added + // during the signal emission are not emitted in this emission. + uint highestConnectionId = connections->currentConnectionId.load(); do { QObjectPrivate::Connection *c = list->first; - if (!c) continue; - // We need to check against last here to ensure that signals added - // during the signal emission are not emitted in this emission. - QObjectPrivate::Connection *last = list->last; + if (!c) + continue; do { if (!c->receiver) @@ -3732,18 +3683,17 @@ void doActivate(QObject *sender, int signal_index, void **argv) locker.relock(); } + } while ((c = c->nextConnectionList) != 0 && c->id <= highestConnectionId); - if (connections->objectDeleted) - break; - } while (c != last && (c = c->nextConnectionList) != 0); - - if (connections->objectDeleted) - break; } while (list != &connections->allsignals && //start over for all signals; ((list = &connections->allsignals), true)); + if (connections->currentConnectionId.load() == 0) + senderDeleted = true; } + if (!senderDeleted) + sp->connections.load()->cleanOrphanedConnections(sender); if (callbacks_enabled && signal_spy_set->signal_end_callback != nullptr) signal_spy_set->signal_end_callback(sender, signal_index); @@ -4859,30 +4809,25 @@ bool QObject::disconnect(const QMetaObject::Connection &connection) { QObjectPrivate::Connection *c = static_cast(connection.d_ptr); - if (!c || !c->receiver) + if (!c) return false; QBasicMutex *senderMutex = signalSlotLock(c->sender); QBasicMutex *receiverMutex = signalSlotLock(c->receiver); + QObjectPrivate::ConnectionData *connections; { QOrderedMutexLocker locker(senderMutex, receiverMutex); - QObjectPrivate::ConnectionData *connections = QObjectPrivate::get(c->sender)->connections.load(); + if (!c->receiver) + return false; + + connections = QObjectPrivate::get(c->sender)->connections.load(); Q_ASSERT(connections); - connections->dirty = true; - - *c->prev = c->next; - if (c->next) - c->next->prev = c->prev; - c->receiver = nullptr; + connections->removeConnection(c); } - // destroy the QSlotObject, if possible - if (c->isSlotObject) { - c->slotObj->destroyIfLastRef(); - c->isSlotObject = false; - } + connections->cleanOrphanedConnections(c->sender); c->sender->disconnectNotify(QMetaObjectPrivate::signal(c->sender->metaObject(), c->signal_index)); diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 863689fddd..2c1502c2a0 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Copyright (C) 2013 Olivier Goffart ** Contact: https://www.qt.io/licensing/ ** @@ -126,22 +126,29 @@ public: typedef void (*StaticMetaCallFunction)(QObject *, QMetaObject::Call, int, void **); struct Connection { + union { + // linked list of orphaned connections that need cleaning up + Connection *nextInOrphanList; + // linked list of connections connected to slots in this object + Connection *next; + }; + Connection **prev; + // linked list of connections connected to signals in this object + Connection *nextConnectionList; + Connection *prevConnectionList; + QObject *sender; QObject *receiver; union { StaticMetaCallFunction callFunction; QtPrivate::QSlotObjectBase *slotObj; }; - // The next pointer for the singly-linked ConnectionList - Connection *nextConnectionList; - //senders linked list - Connection *next; - Connection **prev; QAtomicPointer argumentTypes; QAtomicInt ref_; + uint id = 0; ushort method_offset; ushort method_relative; - uint signal_index : 27; // In signal range (see QObjectPrivate::signalIndex()) + int signal_index : 27; // In signal range (see QObjectPrivate::signalIndex()) ushort connectionType : 3; // 0 == auto, 1 == direct, 2 == queued, 4 == blocking ushort isSlotObject : 1; ushort ownArgumentTypes : 1; @@ -151,9 +158,17 @@ public: ~Connection(); int method() const { Q_ASSERT(!isSlotObject); return method_offset + method_relative; } void ref() { ref_.ref(); } + void freeSlotObject() + { + if (isSlotObject) { + slotObj->destroyIfLastRef(); + isSlotObject = false; + } + } void deref() { if (!ref_.deref()) { Q_ASSERT(!receiver); + Q_ASSERT(!isSlotObject); delete this; } } @@ -210,7 +225,9 @@ public: linked list. */ struct ConnectionData { - bool objectDeleted = false; //the QObject owner of this vector has been destroyed while the vector was inUse + // the id below is used to avoid activating new connections. When the object gets + // deleted it's set to 0, so that signal emission stops + QAtomicInteger currentConnectionId; struct Ref { int _ref = 0; void ref() { ++_ref; } @@ -219,11 +236,84 @@ public: }; Ref ref; - bool dirty = false; //some Connection have been disconnected (their receiver is 0) but not removed from the list yet ConnectionList allsignals; QVector signalVector; Connection *senders = nullptr; Sender *currentSender = nullptr; // object currently activating the object + QAtomicPointer orphaned; + + ~ConnectionData() + { + Connection *c = orphaned.load(); + while (c) { + Q_ASSERT(!c->receiver); + QObjectPrivate::Connection *next = c->nextInOrphanList; + c->freeSlotObject(); + c->deref(); + c = next; + } + } + + // must be called on the senders connection data + // assumes the senders and receivers lock are held + void removeConnection(Connection *c) + { + Q_ASSERT(c->receiver); + ConnectionList &connections = connectionsForSignal(c->signal_index); + c->receiver = nullptr; + +#ifndef QT_NO_DEBUG + bool found = false; + for (Connection *cc = connections.first; cc; cc = cc->nextConnectionList) { + if (cc == c) { + found = true; + break; + } + } + Q_ASSERT(found); +#endif + + // remove from the senders linked list + *c->prev = c->next; + if (c->next) + c->next->prev = c->prev; + c->prev = nullptr; + + if (connections.first == c) + connections.first = c->nextConnectionList; + if (connections.last == c) + connections.last = c->prevConnectionList; + + // keep c->nextConnectionList intact, as it might still get accessed by activate + if (c->nextConnectionList) + c->nextConnectionList->prevConnectionList = c->prevConnectionList; + if (c->prevConnectionList) + c->prevConnectionList->nextConnectionList = c->nextConnectionList; + c->prevConnectionList = nullptr; + + Q_ASSERT(c != orphaned.load()); + // add c to orphanedConnections + c->nextInOrphanList = orphaned.load(); + orphaned.store(c); + +#ifndef QT_NO_DEBUG + found = false; + for (Connection *cc = connections.first; cc; cc = cc->nextConnectionList) { + if (cc == c) { + found = true; + break; + } + } + Q_ASSERT(!found); +#endif + + } + void cleanOrphanedConnections(QObject *sender) + { + if (orphaned.load() && ref == 1) + cleanOrphanedConnectionsImpl(sender); + } + void cleanOrphanedConnectionsImpl(QObject *sender); ConnectionList &connectionsForSignal(int signal) { @@ -245,7 +335,6 @@ public: QObjectList senderList() const; void addConnection(int signal, Connection *c); - void cleanConnectionLists(); static QObjectPrivate *get(QObject *o) { return o->d_func(); diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index b823ca2aab..f51fb9bf49 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -3411,12 +3411,11 @@ void tst_QObject::disconnectSelfInSlotAndDeleteAfterEmit() void tst_QObject::dumpObjectInfo() { QObject a, b; - QObject::connect(&a, SIGNAL(destroyed(QObject*)), &b, SLOT(deleteLater())); - a.disconnect(&b); + QObject::connect(&a, &QObject::destroyed, &b, &QObject::deleteLater); QTest::ignoreMessage(QtDebugMsg, "OBJECT QObject::unnamed"); QTest::ignoreMessage(QtDebugMsg, " SIGNALS OUT"); QTest::ignoreMessage(QtDebugMsg, " signal: destroyed(QObject*)"); - QTest::ignoreMessage(QtDebugMsg, " "); + QTest::ignoreMessage(QtDebugMsg, " "); QTest::ignoreMessage(QtDebugMsg, " SIGNALS IN"); QTest::ignoreMessage(QtDebugMsg, " "); a.dumpObjectInfo(); // should not crash @@ -7575,8 +7574,6 @@ void tst_QObject::functorReferencesConnection() // top-level + the one in the 3 others lambdas QCOMPARE(countedStructObjectsCount, 4); QObject::disconnect(*c2); - // the one in the c2's lambda is gone - QCOMPARE(countedStructObjectsCount, 3); slot1Called++; }); connect(&obj, &GetSenderObject::aSignal, [] {}); // just a dummy signal to fill the connection list From 999c26dd83ad37fcd7a2b2fc62c0281f38c8e6e0 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 1 Feb 2019 12:49:16 +0100 Subject: [PATCH 129/292] Add a QAbstractMetaCallEvent And use it to clean up the reimplementations in Qt DBus. Change-Id: I8e3fe35e8db6405cbcbfb45b42a8f2efecc1cef0 Reviewed-by: Thiago Macieira Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/kernel/qobject.cpp | 26 +++++++++++++++---------- src/corelib/kernel/qobject_p.h | 30 +++++++++++++++++++++-------- src/dbus/qdbusabstractinterface.cpp | 4 ++-- src/dbus/qdbusintegrator_p.h | 19 +++++++++--------- 4 files changed, 50 insertions(+), 29 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 77e58abfa2..a0e4450d28 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -420,6 +420,16 @@ bool QObjectPrivate::maybeSignalConnected(uint signalIndex) const return false; } +/*! + \internal + */ +QAbstractMetaCallEvent::~QAbstractMetaCallEvent() +{ +#if QT_CONFIG(thread) + if (semaphore_) + semaphore_->release(); +#endif +} /*! \internal @@ -427,8 +437,8 @@ bool QObjectPrivate::maybeSignalConnected(uint signalIndex) const QMetaCallEvent::QMetaCallEvent(ushort method_offset, ushort method_relative, QObjectPrivate::StaticMetaCallFunction callFunction, const QObject *sender, int signalId, int nargs, int *types, void **args, QSemaphore *semaphore) - : QEvent(MetaCall), slotObj_(0), sender_(sender), signalId_(signalId), - nargs_(nargs), types_(types), args_(args), semaphore_(semaphore), + : QAbstractMetaCallEvent(sender, signalId, semaphore), + slotObj_(nullptr), nargs_(nargs), types_(types), args_(args), callFunction_(callFunction), method_offset_(method_offset), method_relative_(method_relative) { } @@ -437,9 +447,9 @@ QMetaCallEvent::QMetaCallEvent(ushort method_offset, ushort method_relative, QOb */ QMetaCallEvent::QMetaCallEvent(QtPrivate::QSlotObjectBase *slotO, const QObject *sender, int signalId, int nargs, int *types, void **args, QSemaphore *semaphore) - : QEvent(MetaCall), slotObj_(slotO), sender_(sender), signalId_(signalId), - nargs_(nargs), types_(types), args_(args), semaphore_(semaphore), - callFunction_(0), method_offset_(0), method_relative_(ushort(-1)) + : QAbstractMetaCallEvent(sender, signalId, semaphore), + slotObj_(slotO), nargs_(nargs), types_(types), args_(args), + callFunction_(nullptr), method_offset_(0), method_relative_(ushort(-1)) { if (slotObj_) slotObj_->ref(); @@ -458,10 +468,6 @@ QMetaCallEvent::~QMetaCallEvent() free(types_); free(args_); } -#if QT_CONFIG(thread) - if (semaphore_) - semaphore_->release(); -#endif if (slotObj_) slotObj_->destroyIfLastRef(); } @@ -1179,7 +1185,7 @@ bool QObject::event(QEvent *e) case QEvent::MetaCall: { - QMetaCallEvent *mce = static_cast(e); + QAbstractMetaCallEvent *mce = static_cast(e); if (!d_func()->connections.load()) { QBasicMutexLocker locker(signalSlotLock(this)); diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 2c1502c2a0..da3d035087 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -485,7 +485,26 @@ Q_DECLARE_TYPEINFO(QObjectPrivate::Connection, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(QObjectPrivate::Sender, Q_MOVABLE_TYPE); class QSemaphore; -class Q_CORE_EXPORT QMetaCallEvent : public QEvent +class Q_CORE_EXPORT QAbstractMetaCallEvent : public QEvent +{ +public: + QAbstractMetaCallEvent(const QObject *sender, int signalId, QSemaphore *semaphore = nullptr) + : QEvent(MetaCall), signalId_(signalId), sender_(sender), semaphore_(semaphore) + {} + ~QAbstractMetaCallEvent(); + + virtual void placeMetaCall(QObject *object) = 0; + + inline const QObject *sender() const { return sender_; } + inline int signalId() const { return signalId_; } + +private: + int signalId_; + const QObject *sender_; + QSemaphore *semaphore_; +}; + +class Q_CORE_EXPORT QMetaCallEvent : public QAbstractMetaCallEvent { public: QMetaCallEvent(ushort method_offset, ushort method_relative, QObjectPrivate::StaticMetaCallFunction callFunction , const QObject *sender, int signalId, @@ -496,23 +515,18 @@ public: QMetaCallEvent(QtPrivate::QSlotObjectBase *slotObj, const QObject *sender, int signalId, int nargs = 0, int *types = nullptr, void **args = nullptr, QSemaphore *semaphore = nullptr); - ~QMetaCallEvent(); + ~QMetaCallEvent() override; inline int id() const { return method_offset_ + method_relative_; } - inline const QObject *sender() const { return sender_; } - inline int signalId() const { return signalId_; } inline void **args() const { return args_; } - virtual void placeMetaCall(QObject *object); + virtual void placeMetaCall(QObject *object) override; private: QtPrivate::QSlotObjectBase *slotObj_; - const QObject *sender_; - int signalId_; int nargs_; int *types_; void **args_; - QSemaphore *semaphore_; QObjectPrivate::StaticMetaCallFunction callFunction_; ushort method_offset_; ushort method_relative_; diff --git a/src/dbus/qdbusabstractinterface.cpp b/src/dbus/qdbusabstractinterface.cpp index 148bd54147..d49959d8e2 100644 --- a/src/dbus/qdbusabstractinterface.cpp +++ b/src/dbus/qdbusabstractinterface.cpp @@ -66,11 +66,11 @@ namespace { // of to QDBusAbstractInterface::customEvent. // See solution in Patch Set 1 of this change in the Qt Gerrit servers. // (https://codereview.qt-project.org/#/c/126384/1) -class DisconnectRelayEvent : public QMetaCallEvent +class DisconnectRelayEvent : public QAbstractMetaCallEvent { public: DisconnectRelayEvent(QObject *sender, const QMetaMethod &m) - : QMetaCallEvent(0, 0, nullptr, sender, m.methodIndex()) + : QAbstractMetaCallEvent(sender, m.methodIndex()) {} void placeMetaCall(QObject *object) override diff --git a/src/dbus/qdbusintegrator_p.h b/src/dbus/qdbusintegrator_p.h index 0f7e00fde0..44789b3317 100644 --- a/src/dbus/qdbusintegrator_p.h +++ b/src/dbus/qdbusintegrator_p.h @@ -101,36 +101,37 @@ struct QDBusSlotCache Q_DECLARE_SHARED(QDBusSlotCache::Data) Q_DECLARE_SHARED(QDBusSlotCache) -class QDBusCallDeliveryEvent: public QMetaCallEvent +class QDBusCallDeliveryEvent: public QAbstractMetaCallEvent { public: QDBusCallDeliveryEvent(const QDBusConnection &c, int id, QObject *sender, const QDBusMessage &msg, const QVector &types, int f = 0) - : QMetaCallEvent(0, id, nullptr, sender, -1), connection(c), message(msg), metaTypes(types), flags(f) + : QAbstractMetaCallEvent(sender, -1), connection(c), message(msg), metaTypes(types), id(id), flags(f) { } void placeMetaCall(QObject *object) override { - QDBusConnectionPrivate::d(connection)->deliverCall(object, flags, message, metaTypes, id()); + QDBusConnectionPrivate::d(connection)->deliverCall(object, flags, message, metaTypes, id); } private: QDBusConnection connection; // just for refcounting QDBusMessage message; QVector metaTypes; + int id; int flags; }; -class QDBusActivateObjectEvent: public QMetaCallEvent +class QDBusActivateObjectEvent: public QAbstractMetaCallEvent { public: QDBusActivateObjectEvent(const QDBusConnection &c, QObject *sender, const QDBusConnectionPrivate::ObjectTreeNode &n, int p, const QDBusMessage &m, QSemaphore *s = nullptr) - : QMetaCallEvent(0, ushort(-1), nullptr, sender, -1, 0, nullptr, nullptr, s), connection(c), node(n), + : QAbstractMetaCallEvent(sender, -1, s), connection(c), node(n), pathStartPos(p), message(m), handled(false) { } - ~QDBusActivateObjectEvent(); + ~QDBusActivateObjectEvent() override; void placeMetaCall(QObject *) override; @@ -142,15 +143,15 @@ private: bool handled; }; -class QDBusSpyCallEvent : public QMetaCallEvent +class QDBusSpyCallEvent : public QAbstractMetaCallEvent { public: typedef void (*Hook)(const QDBusMessage&); QDBusSpyCallEvent(QDBusConnectionPrivate *cp, const QDBusConnection &c, const QDBusMessage &msg, const Hook *hooks, int count) - : QMetaCallEvent(0, 0, nullptr, cp, 0), conn(c), msg(msg), hooks(hooks), hookCount(count) + : QAbstractMetaCallEvent(cp, 0), conn(c), msg(msg), hooks(hooks), hookCount(count) {} - ~QDBusSpyCallEvent(); + ~QDBusSpyCallEvent() override; void placeMetaCall(QObject *) override; static inline void invokeSpyHooks(const QDBusMessage &msg, const Hook *hooks, int hookCount); From 13ab090977439cf432c7b99dbdd2b1263b4d8cd4 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 9 Jan 2019 22:17:51 +0100 Subject: [PATCH 130/292] Add safe way to resize the signalVector Change-Id: Ib55da020f22e981bc379af3b4cf3431bf0fa0c20 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/kernel/qobject.cpp | 92 +++++++++++++++++++--------------- src/corelib/kernel/qobject_p.h | 85 +++++++++++++++++++++++++------ 2 files changed, 122 insertions(+), 55 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index a0e4450d28..158d92799c 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -265,8 +265,8 @@ bool QObjectPrivate::isSender(const QObject *receiver, const char *signal) const if (signal_index < 0 || !cd) return false; QBasicMutexLocker locker(signalSlotLock(q)); - if (signal_index < cd->signalVector.count()) { - const QObjectPrivate::Connection *c = cd->signalVector.at(signal_index).first; + if (signal_index < cd->signalVectorCount()) { + const QObjectPrivate::Connection *c = cd->signalVector->at(signal_index).first; while (c) { if (c->receiver == receiver) @@ -287,8 +287,8 @@ QObjectList QObjectPrivate::receiverList(const char *signal) const if (signal_index < 0 || !cd) return returnValue; QBasicMutexLocker locker(signalSlotLock(q)); - if (signal_index < cd->signalVector.count()) { - const QObjectPrivate::Connection *c = cd->signalVector.at(signal_index).first; + if (signal_index < cd->signalVectorCount()) { + const QObjectPrivate::Connection *c = cd->signalVector->at(signal_index).first; while (c) { if (c->receiver) @@ -327,8 +327,7 @@ void QObjectPrivate::addConnection(int signal, Connection *c) Q_ASSERT(c->sender == q_ptr); ensureConnectionData(); ConnectionData *cd = connections.load(); - if (signal >= cd->signalVector.count()) - cd->signalVector.resize(signal + 1); + cd->resizeSignalVector(signal + 1); ConnectionList &connectionList = cd->connectionsForSignal(signal); if (connectionList.last) { @@ -353,7 +352,7 @@ void QObjectPrivate::addConnection(int signal, Connection *c) void QObjectPrivate::ConnectionData::cleanOrphanedConnectionsImpl(QObject *sender) { - Connection *c = nullptr; + ConnectionOrSignalVector *c = nullptr; { QBasicMutexLocker l(signalSlotLock(sender)); if (ref > 1) @@ -365,13 +364,25 @@ void QObjectPrivate::ConnectionData::cleanOrphanedConnectionsImpl(QObject *sende c = orphaned.load(); orphaned.store(nullptr); } - while (c) { - Q_ASSERT(!c->receiver); - Q_ASSERT(!c->prev); - QObjectPrivate::Connection *next = c->nextInOrphanList; - c->freeSlotObject(); - c->deref(); - c = next; + deleteOrphaned(c); +} + +void QObjectPrivate::ConnectionData::deleteOrphaned(QObjectPrivate::ConnectionOrSignalVector *o) +{ + while (o) { + QObjectPrivate::ConnectionOrSignalVector *next = nullptr; + if (SignalVector *v = ConnectionOrSignalVector::asSignalVector(o)) { + next = v->nextInOrphanList; + free(v); + } else { + QObjectPrivate::Connection *c = static_cast(o); + next = c->nextInOrphanList; + Q_ASSERT(!c->receiver); + Q_ASSERT(!c->prev); + c->freeSlotObject(); + c->deref(); + } + o = next; } } @@ -387,14 +398,14 @@ bool QObjectPrivate::isSignalConnected(uint signalIndex, bool checkDeclarative) return true; ConnectionData *cd = connections.load(); - if (!cd) + if (!cd || !cd->signalVector) return false; - if (cd->allsignals.first) + if (cd->signalVector->at(-1).first) return true; - if (signalIndex < uint(cd->signalVector.count())) { - const QObjectPrivate::Connection *c = cd->signalVector.at(signalIndex).first; + if (signalIndex < uint(cd->signalVectorCount())) { + const QObjectPrivate::Connection *c = cd->signalVector->at(signalIndex).first; while (c) { if (c->receiver) return true; @@ -407,14 +418,14 @@ bool QObjectPrivate::isSignalConnected(uint signalIndex, bool checkDeclarative) bool QObjectPrivate::maybeSignalConnected(uint signalIndex) const { ConnectionData *cd = connections.load(); - if (!cd) + if (!cd || !cd->signalVector) return false; - if (cd->allsignals.first) + if (cd->signalVector->at(-1).first) return true; - if (signalIndex < uint(cd->signalVector.count())) { - const QObjectPrivate::Connection *c = cd->signalVector.at(signalIndex).first; + if (signalIndex < uint(cd->signalVectorCount())) { + const QObjectPrivate::Connection *c = cd->signalVector->at(signalIndex).first; return c != nullptr; } return false; @@ -895,7 +906,7 @@ QObject::~QObject() QBasicMutexLocker locker(signalSlotMutex); // disconnect all receivers - int receiverCount = cd->signalVector.count(); + int receiverCount = cd->signalVectorCount(); for (int signal = -1; signal < receiverCount; ++signal) { QObjectPrivate::ConnectionList &connectionList = cd->connectionsForSignal(signal); @@ -2416,9 +2427,8 @@ int QObject::receivers(const char *signal) const QObjectPrivate::ConnectionData *cd = d->connections.load(); QBasicMutexLocker locker(signalSlotLock(this)); - if (cd && signal_index < cd->signalVector.count()) { - const QObjectPrivate::Connection *c = - cd->signalVector.at(signal_index).first; + if (cd && signal_index < cd->signalVectorCount()) { + const QObjectPrivate::Connection *c = cd->signalVector->at(signal_index).first; while (c) { receivers += c->receiver ? 1 : 0; c = c->nextConnectionList; @@ -3232,8 +3242,8 @@ QObjectPrivate::Connection *QMetaObjectPrivate::connect(const QObject *sender, QObjectPrivate::ConnectionData *scd = QObjectPrivate::get(s)->connections.load(); if (type & Qt::UniqueConnection && scd) { - if (scd->signalVector.count() > signal_index) { - const QObjectPrivate::Connection *c2 = scd->signalVector.at(signal_index).first; + if (scd->signalVectorCount() > signal_index) { + const QObjectPrivate::Connection *c2 = scd->signalVector->at(signal_index).first; int method_index_absolute = method_index + method_offset; @@ -3365,11 +3375,11 @@ bool QMetaObjectPrivate::disconnect(const QObject *sender, if (signal_index < 0) { // remove from all connection lists - for (int sig_index = -1; sig_index < scd->signalVector.count(); ++sig_index) { + for (int sig_index = -1; sig_index < scd->signalVectorCount(); ++sig_index) { if (disconnectHelper(connections.data(), sig_index, receiver, method_index, slot, senderMutex, disconnectType)) success = true; } - } else if (signal_index < scd->signalVector.count()) { + } else if (signal_index < scd->signalVectorCount()) { if (disconnectHelper(connections.data(), signal_index, receiver, method_index, slot, senderMutex, disconnectType)) success = true; } @@ -3592,10 +3602,10 @@ void doActivate(QObject *sender, int signal_index, void **argv) QObjectPrivate::ConnectionDataPointer connections(sp->connections.load()); const QObjectPrivate::ConnectionList *list; - if (signal_index < connections->signalVector.count()) - list = &connections->signalVector.at(signal_index); + if (signal_index < connections->signalVector->count()) + list = &connections->signalVector->at(signal_index); else - list = &connections->allsignals; + list = &connections->signalVector->at(-1); Qt::HANDLE currentThreadId = QThread::currentThreadId(); @@ -3691,9 +3701,9 @@ void doActivate(QObject *sender, int signal_index, void **argv) } } while ((c = c->nextConnectionList) != 0 && c->id <= highestConnectionId); - } while (list != &connections->allsignals && + } while (list != &connections->signalVector->at(-1) && //start over for all signals; - ((list = &connections->allsignals), true)); + ((list = &connections->signalVector->at(-1)), true)); if (connections->currentConnectionId.load() == 0) senderDeleted = true; @@ -3994,13 +4004,15 @@ void QObject::dumpObjectInfo() const qDebug(" SIGNALS OUT"); QObjectPrivate::ConnectionData *cd = d->connections.load(); - if (cd && cd->signalVector.count()) { - for (int signal_index = 0; signal_index < cd->signalVector.count(); ++signal_index) { + if (cd && cd->signalVectorCount()) { + for (int signal_index = 0; signal_index < cd->signalVectorCount(); ++signal_index) { + const QObjectPrivate::Connection *c = cd->signalVector->at(signal_index).first; + if (!c) + continue; const QMetaMethod signal = QMetaObjectPrivate::signal(metaObject(), signal_index); qDebug(" signal: %s", signal.methodSignature().constData()); // receivers - const QObjectPrivate::Connection *c = cd->signalVector.at(signal_index).first; while (c) { if (!c->receiver) { qDebug(" "); @@ -4766,8 +4778,8 @@ QMetaObject::Connection QObjectPrivate::connectImpl(const QObject *sender, int s if (type & Qt::UniqueConnection && slot && QObjectPrivate::get(s)->connections.load()) { QObjectPrivate::ConnectionData *connections = QObjectPrivate::get(s)->connections.load(); - if (connections->signalVector.count() > signal_index) { - const QObjectPrivate::Connection *c2 = connections->signalVector.at(signal_index).first; + if (connections->signalVectorCount() > signal_index) { + const QObjectPrivate::Connection *c2 = connections->signalVector->at(signal_index).first; while (c2) { if (c2->receiver == receiver && c2->isSlotObject && c2->slotObj->compare(slot)) { diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index da3d035087..f01b709faa 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -124,14 +124,30 @@ public: }; typedef void (*StaticMetaCallFunction)(QObject *, QMetaObject::Call, int, void **); - struct Connection - { + struct Connection; + struct SignalVector; + + struct ConnectionOrSignalVector { union { // linked list of orphaned connections that need cleaning up - Connection *nextInOrphanList; + ConnectionOrSignalVector *nextInOrphanList; // linked list of connections connected to slots in this object Connection *next; }; + + static SignalVector *asSignalVector(ConnectionOrSignalVector *c) { + if (reinterpret_cast(c) & 1) + return reinterpret_cast(reinterpret_cast(c) & ~quintptr(1u)); + return nullptr; + } + static Connection *fromSignalVector(SignalVector *v) { + return reinterpret_cast(reinterpret_cast(v) | quintptr(1u)); + } + }; + + struct Connection : public ConnectionOrSignalVector + { + // linked list of connections connected to slots in this object, next is in base class Connection **prev; // linked list of connections connected to signals in this object Connection *nextConnectionList; @@ -210,6 +226,22 @@ public: int signal; }; + struct SignalVector : public ConnectionOrSignalVector { + quintptr allocated; + // ConnectionList signals[] + ConnectionList &at(int i) + { + return reinterpret_cast(this + 1)[i + 1]; + } + const ConnectionList &at(int i) const + { + return reinterpret_cast(this + 1)[i + 1]; + } + int count() { return static_cast(allocated); } + }; + + + /* This contains the all connections from and to an object. @@ -236,22 +268,16 @@ public: }; Ref ref; - ConnectionList allsignals; - QVector signalVector; + SignalVector *signalVector = nullptr; Connection *senders = nullptr; Sender *currentSender = nullptr; // object currently activating the object QAtomicPointer orphaned; ~ConnectionData() { - Connection *c = orphaned.load(); - while (c) { - Q_ASSERT(!c->receiver); - QObjectPrivate::Connection *next = c->nextInOrphanList; - c->freeSlotObject(); - c->deref(); - c = next; - } + deleteOrphaned(orphaned.load()); + if (signalVector) + free(signalVector); } // must be called on the senders connection data @@ -259,7 +285,7 @@ public: void removeConnection(Connection *c) { Q_ASSERT(c->receiver); - ConnectionList &connections = connectionsForSignal(c->signal_index); + ConnectionList &connections = signalVector->at(c->signal_index); c->receiver = nullptr; #ifndef QT_NO_DEBUG @@ -283,6 +309,8 @@ public: connections.first = c->nextConnectionList; if (connections.last == c) connections.last = c->prevConnectionList; + Q_ASSERT(signalVector->at(c->signal_index).first != c); + Q_ASSERT(signalVector->at(c->signal_index).last != c); // keep c->nextConnectionList intact, as it might still get accessed by activate if (c->nextConnectionList) @@ -317,8 +345,35 @@ public: ConnectionList &connectionsForSignal(int signal) { - return signal < 0 ? allsignals : signalVector[signal]; + return signalVector->at(signal); } + + void resizeSignalVector(uint size) { + if (signalVector && signalVector->allocated > size) + return; + size = (size + 7) & ~7; + SignalVector *v = reinterpret_cast(malloc(sizeof(SignalVector) + (size + 1) * sizeof(ConnectionList))); + int start = -1; + if (signalVector) { + memcpy(v, signalVector, sizeof(SignalVector) + (signalVector->allocated + 1) * sizeof(ConnectionList)); + start = signalVector->count(); + } + for (int i = start; i < int(size); ++i) + v->at(i) = ConnectionList(); + v->next = nullptr; + v->allocated = size; + + qSwap(v, signalVector); + if (v) { + v->next = orphaned.load(); + orphaned.store(ConnectionOrSignalVector::fromSignalVector(v)); + } + } + int signalVectorCount() const { + return signalVector ? signalVector->count() : -1; + } + + static void deleteOrphaned(ConnectionOrSignalVector *c); }; QObjectPrivate(int version = QObjectPrivateVersion); From 993b049adfa9aaa22324761ce41fe2569184079a Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 9 Jan 2019 22:23:23 +0100 Subject: [PATCH 131/292] Get rid of the locking in activate() Removing connections and resizing the signal vector now happens in a way that will not interfere with activate(), as the old objects won't get deleted if we are somewhere inside a signal emission. This means that we don't need to lock the senders mutex in activate anymore, as long as the reference counting on the ConnectionData is atomic and we are in the senders thread. This implies that we now need to lock the receivers mutex in queued_activate() abd blocking queued activation to ensure it hasn't been deleted while we are emitting. In addition, some precautions need to be taken to not read from the receiver without holding the lock, as it could get deleted while we're activating (if it's in a different thread). To make that possible store the receivers thread id in the connection data. Use atomic pointers for all variables that can get modified with the signalSlotLock() held and that are being read without the lock being held. This gives us a very nice additional speed improvement for signal emissions. without change with change string based connect: 3287 2436 pointer based connect: 3941 3265 not connected: 403 400 disconnected: 460 489 5 slots connected: 9112 4515 Change-Id: Ib7324bb74c389dcc3b6581a03c31469a6e589fc2 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/kernel/qobject.cpp | 313 ++++++++++++++++++++++----------- src/corelib/kernel/qobject_p.h | 114 +++--------- 2 files changed, 234 insertions(+), 193 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 158d92799c..45e88a2082 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -266,12 +266,12 @@ bool QObjectPrivate::isSender(const QObject *receiver, const char *signal) const return false; QBasicMutexLocker locker(signalSlotLock(q)); if (signal_index < cd->signalVectorCount()) { - const QObjectPrivate::Connection *c = cd->signalVector->at(signal_index).first; + const QObjectPrivate::Connection *c = cd->signalVector.load()->at(signal_index).first.load(); while (c) { - if (c->receiver == receiver) + if (c->receiver.load() == receiver) return true; - c = c->nextConnectionList; + c = c->nextConnectionList.load(); } } return false; @@ -280,20 +280,19 @@ bool QObjectPrivate::isSender(const QObject *receiver, const char *signal) const // Used by QAccessibleWidget QObjectList QObjectPrivate::receiverList(const char *signal) const { - Q_Q(const QObject); QObjectList returnValue; int signal_index = signalIndex(signal); ConnectionData *cd = connections.load(); if (signal_index < 0 || !cd) return returnValue; - QBasicMutexLocker locker(signalSlotLock(q)); if (signal_index < cd->signalVectorCount()) { - const QObjectPrivate::Connection *c = cd->signalVector->at(signal_index).first; + const QObjectPrivate::Connection *c = cd->signalVector.load()->at(signal_index).first.load(); while (c) { - if (c->receiver) - returnValue << c->receiver; - c = c->nextConnectionList; + QObject *r = c->receiver.load(); + if (r) + returnValue << r; + c = c->nextConnectionList.load(); } } return returnValue; @@ -330,17 +329,17 @@ void QObjectPrivate::addConnection(int signal, Connection *c) cd->resizeSignalVector(signal + 1); ConnectionList &connectionList = cd->connectionsForSignal(signal); - if (connectionList.last) { - Q_ASSERT(connectionList.last->receiver); - connectionList.last->nextConnectionList = c; + if (connectionList.last.load()) { + Q_ASSERT(connectionList.last.load()->receiver.load()); + connectionList.last.load()->nextConnectionList.store(c); } else { - connectionList.first = c; + connectionList.first.store(c); } c->id = ++cd->currentConnectionId; - c->prevConnectionList = connectionList.last; - connectionList.last = c; + c->prevConnectionList = connectionList.last.load(); + connectionList.last.store(c); - QObjectPrivate *rd = QObjectPrivate::get(c->receiver); + QObjectPrivate *rd = QObjectPrivate::get(c->receiver.load()); rd->ensureConnectionData(); c->prev = &(rd->connections.load()->senders); @@ -350,6 +349,66 @@ void QObjectPrivate::addConnection(int signal, Connection *c) c->next->prev = &c->next; } +void QObjectPrivate::ConnectionData::removeConnection(QObjectPrivate::Connection *c) +{ + Q_ASSERT(c->receiver.load()); + ConnectionList &connections = signalVector.load()->at(c->signal_index); + c->receiver.store(nullptr); + QThreadData *td = c->receiverThreadData.load(); + if (td) + td->deref(); + c->receiverThreadData.store(nullptr); + +#ifndef QT_NO_DEBUG + bool found = false; + for (Connection *cc = connections.first.load(); cc; cc = cc->nextConnectionList.load()) { + if (cc == c) { + found = true; + break; + } + } + Q_ASSERT(found); +#endif + + // remove from the senders linked list + *c->prev = c->next; + if (c->next) + c->next->prev = c->prev; + c->prev = nullptr; + + if (connections.first.load() == c) + connections.first.store(c->nextConnectionList.load()); + if (connections.last.load() == c) + connections.last.store(c->prevConnectionList); + Q_ASSERT(signalVector.load()->at(c->signal_index).first.load() != c); + Q_ASSERT(signalVector.load()->at(c->signal_index).last.load() != c); + + // keep c->nextConnectionList intact, as it might still get accessed by activate + Connection *n = c->nextConnectionList.load(); + if (n) + n->prevConnectionList = c->prevConnectionList; + if (c->prevConnectionList) + c->prevConnectionList->nextConnectionList.store(n); + c->prevConnectionList = nullptr; + + Q_ASSERT(c != orphaned.load()); + // add c to orphanedConnections + c->nextInOrphanList = orphaned.load(); + orphaned.store(c); + +#ifndef QT_NO_DEBUG + found = false; + for (Connection *cc = connections.first.load(); cc; cc = cc->nextConnectionList.load()) { + if (cc == c) { + found = true; + break; + } + } + Q_ASSERT(!found); +#endif + +} + void QObjectPrivate::ConnectionData::cleanOrphanedConnectionsImpl(QObject *sender) { ConnectionOrSignalVector *c = nullptr; @@ -377,7 +436,7 @@ void QObjectPrivate::ConnectionData::deleteOrphaned(QObjectPrivate::ConnectionOr } else { QObjectPrivate::Connection *c = static_cast(o); next = c->nextInOrphanList; - Q_ASSERT(!c->receiver); + Q_ASSERT(!c->receiver.load()); Q_ASSERT(!c->prev); c->freeSlotObject(); c->deref(); @@ -398,18 +457,21 @@ bool QObjectPrivate::isSignalConnected(uint signalIndex, bool checkDeclarative) return true; ConnectionData *cd = connections.load(); - if (!cd || !cd->signalVector) + if (!cd) + return false; + SignalVector *signalVector = cd->signalVector.load(); + if (!signalVector) return false; - if (cd->signalVector->at(-1).first) + if (signalVector->at(-1).first.load()) return true; if (signalIndex < uint(cd->signalVectorCount())) { - const QObjectPrivate::Connection *c = cd->signalVector->at(signalIndex).first; + const QObjectPrivate::Connection *c = signalVector->at(signalIndex).first.load(); while (c) { - if (c->receiver) + if (c->receiver.load()) return true; - c = c->nextConnectionList; + c = c->nextConnectionList.load(); } } return false; @@ -418,14 +480,17 @@ bool QObjectPrivate::isSignalConnected(uint signalIndex, bool checkDeclarative) bool QObjectPrivate::maybeSignalConnected(uint signalIndex) const { ConnectionData *cd = connections.load(); - if (!cd || !cd->signalVector) + if (!cd) + return false; + SignalVector *signalVector = cd->signalVector.load(); + if (!signalVector) return false; - if (cd->signalVector->at(-1).first) + if (signalVector->at(-1).first) return true; if (signalIndex < uint(cd->signalVectorCount())) { - const QObjectPrivate::Connection *c = cd->signalVector->at(signalIndex).first; + const QObjectPrivate::Connection *c = signalVector->at(signalIndex).first; return c != nullptr; } return false; @@ -910,14 +975,14 @@ QObject::~QObject() for (int signal = -1; signal < receiverCount; ++signal) { QObjectPrivate::ConnectionList &connectionList = cd->connectionsForSignal(signal); - while (QObjectPrivate::Connection *c = connectionList.first) { + while (QObjectPrivate::Connection *c = connectionList.first.load()) { Q_ASSERT(c->receiver); - QBasicMutex *m = signalSlotLock(c->receiver); + QBasicMutex *m = signalSlotLock(c->receiver.load()); bool needToUnlock = QOrderedMutexLocker::relock(signalSlotMutex, m); if (c->receiver) { cd->removeConnection(c); - Q_ASSERT(connectionList.first != c); + Q_ASSERT(connectionList.first.load() != c); } if (needToUnlock) m->unlock(); @@ -1457,6 +1522,9 @@ void QObject::moveToThread(QThread *targetThread) if (!targetData) targetData = new QThreadData(0); + // make sure nobody adds/removes connections to this object while we're moving it + QMutexLocker l(signalSlotLock(this)); + QOrderedMutexLocker locker(¤tData->postEventList.mutex, &targetData->postEventList.mutex); @@ -1507,9 +1575,29 @@ void QObjectPrivate::setThreadData_helper(QThreadData *currentData, QThreadData // the current emitting thread shouldn't restore currentSender after calling moveToThread() ConnectionData *cd = connections.load(); - if (cd && cd->currentSender) { - cd->currentSender->receiverDeleted(); - cd->currentSender = nullptr; + if (cd) { + if (cd->currentSender) { + cd->currentSender->receiverDeleted(); + cd->currentSender = nullptr; + } + + // adjust the receiverThreadId values in the Connections + if (cd) { + auto *c = cd->senders; + while (c) { + QObject *r = c->receiver.load(); + if (r) { + Q_ASSERT(r == q); + targetData->ref(); + QThreadData *old = c->receiverThreadData.load(); + if (old) + old->deref(); + c->receiverThreadData.store(targetData); + } + c = c->next; + } + } + } // set new thread data @@ -2428,10 +2516,10 @@ int QObject::receivers(const char *signal) const QObjectPrivate::ConnectionData *cd = d->connections.load(); QBasicMutexLocker locker(signalSlotLock(this)); if (cd && signal_index < cd->signalVectorCount()) { - const QObjectPrivate::Connection *c = cd->signalVector->at(signal_index).first; + const QObjectPrivate::Connection *c = cd->signalVector.load()->at(signal_index).first.load(); while (c) { - receivers += c->receiver ? 1 : 0; - c = c->nextConnectionList; + receivers += c->receiver.load() ? 1 : 0; + c = c->nextConnectionList.load(); } } } @@ -3243,14 +3331,14 @@ QObjectPrivate::Connection *QMetaObjectPrivate::connect(const QObject *sender, QObjectPrivate::ConnectionData *scd = QObjectPrivate::get(s)->connections.load(); if (type & Qt::UniqueConnection && scd) { if (scd->signalVectorCount() > signal_index) { - const QObjectPrivate::Connection *c2 = scd->signalVector->at(signal_index).first; + const QObjectPrivate::Connection *c2 = scd->signalVector.load()->at(signal_index).first.load(); int method_index_absolute = method_index + method_offset; while (c2) { - if (!c2->isSlotObject && c2->receiver == receiver && c2->method() == method_index_absolute) + if (!c2->isSlotObject && c2->receiver.load() == receiver && c2->method() == method_index_absolute) return nullptr; - c2 = c2->nextConnectionList; + c2 = c2->nextConnectionList.load(); } } type &= Qt::UniqueConnection - 1; @@ -3259,13 +3347,15 @@ QObjectPrivate::Connection *QMetaObjectPrivate::connect(const QObject *sender, QScopedPointer c(new QObjectPrivate::Connection); c->sender = s; c->signal_index = signal_index; - c->receiver = r; + c->receiver.store(r); + QThreadData *td = r->d_func()->threadData; + td->ref(); + c->receiverThreadData.store(td); c->method_relative = method_index; c->method_offset = method_offset; c->connectionType = type; c->isSlotObject = false; c->argumentTypes.store(types); - c->nextConnectionList = 0; c->callFunction = callFunction; QObjectPrivate::get(s)->addConnection(signal_index, c.data()); @@ -3318,20 +3408,20 @@ bool QMetaObjectPrivate::disconnectHelper(QObjectPrivate::ConnectionData *connec bool success = false; auto &connectionList = connections->connectionsForSignal(signalIndex); - auto *c = connectionList.first; + auto *c = connectionList.first.load(); while (c) { - if (c->receiver - && (receiver == nullptr || (c->receiver == receiver + QObject *r = c->receiver.load(); + if (r && (receiver == nullptr || (r == receiver && (method_index < 0 || (!c->isSlotObject && c->method() == method_index)) && (slot == nullptr || (c->isSlotObject && c->slotObj->compare(slot)))))) { bool needToUnlock = false; QBasicMutex *receiverMutex = nullptr; - if (c->receiver) { - receiverMutex = signalSlotLock(c->receiver); + if (r) { + receiverMutex = signalSlotLock(r); // need to relock this receiver and sender in the correct order needToUnlock = QOrderedMutexLocker::relock(senderMutex, receiverMutex); } - if (c->receiver) + if (c->receiver.load()) connections->removeConnection(c); if (needToUnlock) @@ -3342,7 +3432,7 @@ bool QMetaObjectPrivate::disconnectHelper(QObjectPrivate::ConnectionData *connec if (disconnectType == DisconnectOne) return success; } - c = c->nextConnectionList; + c = c->nextConnectionList.load(); } return success; } @@ -3504,8 +3594,7 @@ void QMetaObject::connectSlotsByName(QObject *o) \a signal must be in the signal index range (see QObjectPrivate::signalIndex()). */ -static void queued_activate(QObject *sender, int signal, QObjectPrivate::Connection *c, void **argv, - QBasicMutexLocker &locker) +static void queued_activate(QObject *sender, int signal, QObjectPrivate::Connection *c, void **argv) { const int *argumentTypes = c->argumentTypes.load(); if (!argumentTypes) { @@ -3535,27 +3624,25 @@ static void queued_activate(QObject *sender, int signal, QObjectPrivate::Connect for (int n = 1; n < nargs; ++n) types[n] = argumentTypes[n-1]; - locker.unlock(); for (int n = 1; n < nargs; ++n) args[n] = QMetaType::create(types[n], argv[n]); - locker.relock(); + } - if (!c->receiver) { - locker.unlock(); - // we have been disconnected while the mutex was unlocked - for (int n = 1; n < nargs; ++n) - QMetaType::destroy(types[n], args[n]); - free(types); - free(args); - locker.relock(); - return; - } + QBasicMutexLocker locker(signalSlotLock(c->receiver.load())); + if (!c->receiver.load()) { + // the connection has been disconnected before we got the lock + locker.unlock(); + for (int n = 1; n < nargs; ++n) + QMetaType::destroy(types[n], args[n]); + free(types); + free(args); + return; } QMetaCallEvent *ev = c->isSlotObject ? new QMetaCallEvent(c->slotObj, sender, signal, nargs, types, args) : new QMetaCallEvent(c->method_offset, c->method_relative, c->callFunction, sender, signal, nargs, types, args); - QCoreApplication::postEvent(c->receiver, ev); + QCoreApplication::postEvent(c->receiver.load(), ev); } template @@ -3597,38 +3684,51 @@ void doActivate(QObject *sender, int signal_index, void **argv) bool senderDeleted = false; { - QBasicMutexLocker locker(signalSlotLock(sender)); Q_ASSERT(sp->connections); QObjectPrivate::ConnectionDataPointer connections(sp->connections.load()); + QObjectPrivate::SignalVector *signalVector = connections->signalVector.load(); const QObjectPrivate::ConnectionList *list; - if (signal_index < connections->signalVector->count()) - list = &connections->signalVector->at(signal_index); + if (signal_index < signalVector->count()) + list = &signalVector->at(signal_index); else - list = &connections->signalVector->at(-1); + list = &signalVector->at(-1); Qt::HANDLE currentThreadId = QThread::currentThreadId(); + bool inSenderThread = currentThreadId == QObjectPrivate::get(sender)->threadData->threadId.load(); // We need to check against the highest connection id to ensure that signals added // during the signal emission are not emitted in this emission. uint highestConnectionId = connections->currentConnectionId.load(); do { - QObjectPrivate::Connection *c = list->first; + QObjectPrivate::Connection *c = list->first.load(); if (!c) continue; do { - if (!c->receiver) + QObject * const receiver = c->receiver.load(); + if (!receiver) continue; - QObject * const receiver = c->receiver; - const bool receiverInSameThread = currentThreadId == QObjectPrivate::get(receiver)->threadData->threadId.load(); + QThreadData *td = c->receiverThreadData.load(); + if (!td) + continue; + + bool receiverInSameThread; + if (inSenderThread) { + receiverInSameThread = currentThreadId == td->threadId.load(); + } else { + // need to lock before reading the threadId, because moveToThread() could interfere + QMutexLocker lock(signalSlotLock(receiver)); + receiverInSameThread = currentThreadId == td->threadId.load(); + } + // determine if this connection should be sent immediately or // put into the event queue if ((c->connectionType == Qt::AutoConnection && !receiverInSameThread) || (c->connectionType == Qt::QueuedConnection)) { - queued_activate(sender, signal_index, c, argv, locker); + queued_activate(sender, signal_index, c, argv); continue; #if QT_CONFIG(thread) } else if (c->connectionType == Qt::BlockingQueuedConnection) { @@ -3639,13 +3739,16 @@ void doActivate(QObject *sender, int signal_index, void **argv) receiver->metaObject()->className(), receiver); } QSemaphore semaphore; - QMetaCallEvent *ev = c->isSlotObject ? - new QMetaCallEvent(c->slotObj, sender, signal_index, 0, 0, argv, &semaphore) : - new QMetaCallEvent(c->method_offset, c->method_relative, c->callFunction, sender, signal_index, 0, 0, argv, &semaphore); - QCoreApplication::postEvent(receiver, ev); - locker.unlock(); + { + QBasicMutexLocker locker(signalSlotLock(sender)); + if (!c->receiver) + continue; + QMetaCallEvent *ev = c->isSlotObject ? + new QMetaCallEvent(c->slotObj, sender, signal_index, 0, 0, argv, &semaphore) : + new QMetaCallEvent(c->method_offset, c->method_relative, c->callFunction, sender, signal_index, 0, 0, argv, &semaphore); + QCoreApplication::postEvent(receiver, ev); + } semaphore.acquire(); - locker.relock(); continue; #endif } @@ -3655,22 +3758,13 @@ void doActivate(QObject *sender, int signal_index, void **argv) if (c->isSlotObject) { c->slotObj->ref(); QScopedPointer obj(c->slotObj); - locker.unlock(); Q_TRACE(QMetaObject_activate_begin_slot_functor, obj.data()); obj->call(receiver, argv); Q_TRACE(QMetaObject_activate_end_slot_functor, obj.data()); - - // Make sure the slot object gets destroyed before the mutex is locked again, as the - // destructor of the slot object might also lock a mutex from the signalSlotLock() mutex pool, - // and that would deadlock if the pool happens to return the same mutex. - obj.reset(); - - locker.relock(); } else if (c->callFunction && c->method_offset <= receiver->metaObject()->methodOffset()) { //we compare the vtable to make sure we are not in the destructor of the object. const int method_relative = c->method_relative; const auto callFunction = c->callFunction; - locker.unlock(); const int methodIndex = (Q_HAS_TRACEPOINTS || callbacks_enabled) ? c->method() : 0; if (callbacks_enabled && signal_spy_set->slot_begin_callback != nullptr) signal_spy_set->slot_begin_callback(receiver, methodIndex, argv); @@ -3681,10 +3775,8 @@ void doActivate(QObject *sender, int signal_index, void **argv) Q_TRACE(QMetaObject_activate_end_slot, receiver, methodIndex); if (callbacks_enabled && signal_spy_set->slot_end_callback != nullptr) signal_spy_set->slot_end_callback(receiver, methodIndex); - locker.relock(); } else { const int method = c->method_relative + c->method_offset; - locker.unlock(); if (callbacks_enabled && signal_spy_set->slot_begin_callback != nullptr) { signal_spy_set->slot_begin_callback(receiver, method, argv); @@ -3696,14 +3788,12 @@ void doActivate(QObject *sender, int signal_index, void **argv) Q_TRACE(QMetaObject_activate_end_slot, receiver, method); if (callbacks_enabled && signal_spy_set->slot_end_callback != nullptr) signal_spy_set->slot_end_callback(receiver, method); - - locker.relock(); } - } while ((c = c->nextConnectionList) != 0 && c->id <= highestConnectionId); + } while ((c = c->nextConnectionList.load()) != nullptr && c->id <= highestConnectionId); - } while (list != &connections->signalVector->at(-1) && + } while (list != &signalVector->at(-1) && //start over for all signals; - ((list = &connections->signalVector->at(-1)), true)); + ((list = &signalVector->at(-1)), true)); if (connections->currentConnectionId.load() == 0) senderDeleted = true; @@ -4005,8 +4095,9 @@ void QObject::dumpObjectInfo() const QObjectPrivate::ConnectionData *cd = d->connections.load(); if (cd && cd->signalVectorCount()) { - for (int signal_index = 0; signal_index < cd->signalVectorCount(); ++signal_index) { - const QObjectPrivate::Connection *c = cd->signalVector->at(signal_index).first; + QObjectPrivate::SignalVector *signalVector = cd->signalVector.load(); + for (int signal_index = 0; signal_index < signalVector->count(); ++signal_index) { + const QObjectPrivate::Connection *c = signalVector->at(signal_index).first.load(); if (!c) continue; const QMetaMethod signal = QMetaObjectPrivate::signal(metaObject(), signal_index); @@ -4014,23 +4105,23 @@ void QObject::dumpObjectInfo() const // receivers while (c) { - if (!c->receiver) { + if (!c->receiver.load()) { qDebug(" "); - c = c->nextConnectionList; + c = c->nextConnectionList.load(); continue; } if (c->isSlotObject) { qDebug(" "); - c = c->nextConnectionList; + c = c->nextConnectionList.load(); continue; } - const QMetaObject *receiverMetaObject = c->receiver->metaObject(); + const QMetaObject *receiverMetaObject = c->receiver.load()->metaObject(); const QMetaMethod method = receiverMetaObject->method(c->method()); qDebug(" --> %s::%s %s", receiverMetaObject->className(), - c->receiver->objectName().isEmpty() ? "unnamed" : qPrintable(c->receiver->objectName()), + c->receiver.load()->objectName().isEmpty() ? "unnamed" : qPrintable(c->receiver.load()->objectName()), method.methodSignature().constData()); - c = c->nextConnectionList; + c = c->nextConnectionList.load(); } } } else { @@ -4779,14 +4870,14 @@ QMetaObject::Connection QObjectPrivate::connectImpl(const QObject *sender, int s if (type & Qt::UniqueConnection && slot && QObjectPrivate::get(s)->connections.load()) { QObjectPrivate::ConnectionData *connections = QObjectPrivate::get(s)->connections.load(); if (connections->signalVectorCount() > signal_index) { - const QObjectPrivate::Connection *c2 = connections->signalVector->at(signal_index).first; + const QObjectPrivate::Connection *c2 = connections->signalVector.load()->at(signal_index).first.load(); while (c2) { - if (c2->receiver == receiver && c2->isSlotObject && c2->slotObj->compare(slot)) { + if (c2->receiver.load() == receiver && c2->isSlotObject && c2->slotObj->compare(slot)) { slotObj->destroyIfLastRef(); return QMetaObject::Connection(); } - c2 = c2->nextConnectionList; + c2 = c2->nextConnectionList.load(); } } type = static_cast(type ^ Qt::UniqueConnection); @@ -4795,7 +4886,10 @@ QMetaObject::Connection QObjectPrivate::connectImpl(const QObject *sender, int s QScopedPointer c(new QObjectPrivate::Connection); c->sender = s; c->signal_index = signal_index; - c->receiver = r; + QThreadData *td = r->d_func()->threadData; + td->ref(); + c->receiverThreadData.store(td); + c->receiver.store(r); c->slotObj = slotObj; c->connectionType = type; c->isSlotObject = true; @@ -4829,15 +4923,20 @@ bool QObject::disconnect(const QMetaObject::Connection &connection) if (!c) return false; + QObject *receiver = c->receiver.load(); + if (!receiver) + return false; QBasicMutex *senderMutex = signalSlotLock(c->sender); - QBasicMutex *receiverMutex = signalSlotLock(c->receiver); + QBasicMutex *receiverMutex = signalSlotLock(receiver); QObjectPrivate::ConnectionData *connections; { QOrderedMutexLocker locker(senderMutex, receiverMutex); - if (!c->receiver) + // load receiver once again and recheck to ensure nobody else has removed the connection in the meantime + receiver = c->receiver.load(); + if (!receiver) return false; connections = QObjectPrivate::get(c->sender)->connections.load(); @@ -5032,7 +5131,7 @@ bool QMetaObject::Connection::isConnected_helper() const Q_ASSERT(d_ptr); // we're only called from operator RestrictedBool() const QObjectPrivate::Connection *c = static_cast(d_ptr); - return c->receiver; + return c->receiver.load(); } diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index f01b709faa..2fb11ecc64 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -150,11 +150,12 @@ public: // linked list of connections connected to slots in this object, next is in base class Connection **prev; // linked list of connections connected to signals in this object - Connection *nextConnectionList; + QAtomicPointer nextConnectionList; Connection *prevConnectionList; QObject *sender; - QObject *receiver; + QAtomicPointer receiver; + QAtomicPointer receiverThreadData; union { StaticMetaCallFunction callFunction; QtPrivate::QSlotObjectBase *slotObj; @@ -168,7 +169,7 @@ public: ushort connectionType : 3; // 0 == auto, 1 == direct, 2 == queued, 4 == blocking ushort isSlotObject : 1; ushort ownArgumentTypes : 1; - Connection() : nextConnectionList(nullptr), ref_(2), ownArgumentTypes(true) { + Connection() : ref_(2), ownArgumentTypes(true) { //ref_ is 2 for the use in the internal lists, and for the use in QMetaObject::Connection } ~Connection(); @@ -183,7 +184,7 @@ public: } void deref() { if (!ref_.deref()) { - Q_ASSERT(!receiver); + Q_ASSERT(!receiver.load()); Q_ASSERT(!isSlotObject); delete this; } @@ -191,9 +192,8 @@ public: }; // ConnectionList is a singly-linked list struct ConnectionList { - ConnectionList() : first(nullptr), last(nullptr) {} - Connection *first; - Connection *last; + QAtomicPointer first; + QAtomicPointer last; }; struct Sender @@ -260,15 +260,8 @@ public: // the id below is used to avoid activating new connections. When the object gets // deleted it's set to 0, so that signal emission stops QAtomicInteger currentConnectionId; - struct Ref { - int _ref = 0; - void ref() { ++_ref; } - int deref() { return --_ref; } - operator int() const { return _ref; } - }; - - Ref ref; - SignalVector *signalVector = nullptr; + QAtomicInt ref; + QAtomicPointer signalVector; Connection *senders = nullptr; Sender *currentSender = nullptr; // object currently activating the object QAtomicPointer orphaned; @@ -276,66 +269,14 @@ public: ~ConnectionData() { deleteOrphaned(orphaned.load()); - if (signalVector) - free(signalVector); + SignalVector *v = signalVector.load(); + if (v) + free(v); } // must be called on the senders connection data // assumes the senders and receivers lock are held - void removeConnection(Connection *c) - { - Q_ASSERT(c->receiver); - ConnectionList &connections = signalVector->at(c->signal_index); - c->receiver = nullptr; - -#ifndef QT_NO_DEBUG - bool found = false; - for (Connection *cc = connections.first; cc; cc = cc->nextConnectionList) { - if (cc == c) { - found = true; - break; - } - } - Q_ASSERT(found); -#endif - - // remove from the senders linked list - *c->prev = c->next; - if (c->next) - c->next->prev = c->prev; - c->prev = nullptr; - - if (connections.first == c) - connections.first = c->nextConnectionList; - if (connections.last == c) - connections.last = c->prevConnectionList; - Q_ASSERT(signalVector->at(c->signal_index).first != c); - Q_ASSERT(signalVector->at(c->signal_index).last != c); - - // keep c->nextConnectionList intact, as it might still get accessed by activate - if (c->nextConnectionList) - c->nextConnectionList->prevConnectionList = c->prevConnectionList; - if (c->prevConnectionList) - c->prevConnectionList->nextConnectionList = c->nextConnectionList; - c->prevConnectionList = nullptr; - - Q_ASSERT(c != orphaned.load()); - // add c to orphanedConnections - c->nextInOrphanList = orphaned.load(); - orphaned.store(c); - -#ifndef QT_NO_DEBUG - found = false; - for (Connection *cc = connections.first; cc; cc = cc->nextConnectionList) { - if (cc == c) { - found = true; - break; - } - } - Q_ASSERT(!found); -#endif - - } + void removeConnection(Connection *c); void cleanOrphanedConnections(QObject *sender) { if (orphaned.load() && ref == 1) @@ -345,32 +286,33 @@ public: ConnectionList &connectionsForSignal(int signal) { - return signalVector->at(signal); + return signalVector.load()->at(signal); } void resizeSignalVector(uint size) { - if (signalVector && signalVector->allocated > size) + SignalVector *vector = this->signalVector.load(); + if (vector && vector->allocated > size) return; size = (size + 7) & ~7; - SignalVector *v = reinterpret_cast(malloc(sizeof(SignalVector) + (size + 1) * sizeof(ConnectionList))); + SignalVector *newVector = reinterpret_cast(malloc(sizeof(SignalVector) + (size + 1) * sizeof(ConnectionList))); int start = -1; - if (signalVector) { - memcpy(v, signalVector, sizeof(SignalVector) + (signalVector->allocated + 1) * sizeof(ConnectionList)); - start = signalVector->count(); + if (vector) { + memcpy(newVector, vector, sizeof(SignalVector) + (vector->allocated + 1) * sizeof(ConnectionList)); + start = vector->count(); } for (int i = start; i < int(size); ++i) - v->at(i) = ConnectionList(); - v->next = nullptr; - v->allocated = size; + newVector->at(i) = ConnectionList(); + newVector->next = nullptr; + newVector->allocated = size; - qSwap(v, signalVector); - if (v) { - v->next = orphaned.load(); - orphaned.store(ConnectionOrSignalVector::fromSignalVector(v)); + signalVector.store(newVector); + if (vector) { + vector->nextInOrphanList = orphaned.load(); + orphaned.store(ConnectionOrSignalVector::fromSignalVector(vector)); } } int signalVectorCount() const { - return signalVector ? signalVector->count() : -1; + return signalVector ? signalVector.load()->count() : -1; } static void deleteOrphaned(ConnectionOrSignalVector *c); From a9cd08c3f398b5721483a4c443944cc90a3c3902 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 25 Mar 2019 12:34:02 +0100 Subject: [PATCH 132/292] Fix memory leak in auto test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I2e8d8cc0f248122b06c7c8313d8effac887adaa8 Reviewed-by: Jędrzej Nowacki --- tests/auto/corelib/thread/qthread/tst_qthread.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp index d73dcc1b6d..f72b662c94 100644 --- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp +++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp @@ -1330,6 +1330,8 @@ void tst_QThread::quitLock() QCOMPARE(job->thread(), &thread); loop.exec(); QVERIFY(exitThreadCalled); + + delete job; } void tst_QThread::create() From bab398aba3019cbc6a947bef7708c41efc807777 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 25 Mar 2019 14:50:00 +0100 Subject: [PATCH 133/292] Fix memory leak in auto test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ie4412b8d8c67e9516225f6fe5b67afed91dcdad5 Reviewed-by: Jędrzej Nowacki --- tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp index 838431cd5a..27b49602fc 100644 --- a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp +++ b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp @@ -1322,6 +1322,7 @@ void tst_QThreadPool::waitForDoneAfterTake() QRunnable *runnable = createTask(emptyFunct); manager.start(runnable); QVERIFY(manager.tryTake(runnable)); + delete runnable; } // Add another runnable that will not be removed From b82b3f40673f2d3c8ec73c075b645890480b74b7 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 18 Jul 2017 11:57:02 +0200 Subject: [PATCH 134/292] Fix the skip-check in TestMethods::invokeTest() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TestMethods::invokeTest() has an outer loop on global data (albeit with a comment that said otherwise). On its first cycle, we run the test function's *_data() method, if it has one; there is an inner loop on the rows this created. If the *_data() QSKIP()s, we need to skip the whole test; otherwise, a QSKIP() in one sub-test should not lead to skipping the remaining sub-tests. Moved the check for *_data() QSKIP()ping to right after *_data() returns, inside the "first global cycle" block that runs it. Previously, this check was done before entering the loop on local data rows, but outside that "first global cycle" block: consequently, later global cycles would fall foul of this check (even though the *_data() hasn't been run in this cycle, much less QSKIP()ped in it) if the last sub-test of the previous global cycle had QSKIP()ped. When running a single test for one specific data row, if the test's *_data() QSKIP()ped, this misplaced check would also have lead to a misleading "Unknown testdata" warning. Changed testlib/selftests' tst_globaldata::skipSingle() to trigger the bug (by having its last local row of first global row skip, which caused the second global row to be omitted) to verify this is also fixed; and amended one of its comments to reflect what's now to be expected. Updated the test's expected output files. Task-number: QTBUG-61774 Change-Id: I99596b595c6d1184038f23383844c6ff51a0cd91 Reviewed-by: Jędrzej Nowacki --- src/testlib/qtestcase.cpp | 78 +++++++++---------- .../selftests/expected_globaldata.lightxml | 31 ++++++-- .../testlib/selftests/expected_globaldata.tap | 23 +++--- .../selftests/expected_globaldata.teamcity | 11 +-- .../testlib/selftests/expected_globaldata.txt | 14 +++- .../testlib/selftests/expected_globaldata.xml | 31 ++++++-- .../selftests/expected_globaldata.xunitxml | 18 ++++- .../selftests/globaldata/tst_globaldata.cpp | 7 +- 8 files changed, 141 insertions(+), 72 deletions(-) diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index d9f8dd7805..a202add2ae 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1095,7 +1095,7 @@ bool TestMethods::invokeTest(int index, const char *data, WatchDog *watchDog) co const int globalDataCount = gTable->dataCount(); int curGlobalDataIndex = 0; - /* For each test function that has a *_data() table/function, do: */ + /* For each entry in the global data table, do: */ do { if (!gTable->isEmpty()) QTestResult::setCurrentGlobalTestData(gTable->testData(curGlobalDataIndex)); @@ -1103,51 +1103,51 @@ bool TestMethods::invokeTest(int index, const char *data, WatchDog *watchDog) co if (curGlobalDataIndex == 0) { qsnprintf(member, 512, "%s_data()", name.constData()); invokeMethod(QTest::currentTestObject, member); + if (QTestResult::skipCurrentTest()) + break; } bool foundFunction = false; - if (!QTestResult::skipCurrentTest()) { - int curDataIndex = 0; - const int dataCount = table.dataCount(); + int curDataIndex = 0; + const int dataCount = table.dataCount(); - // Data tag requested but none available? - if (data && !dataCount) { - // Let empty data tag through. - if (!*data) - data = 0; - else { - fprintf(stderr, "Unknown testdata for function %s(): '%s'\n", name.constData(), data); - fprintf(stderr, "Function has no testdata.\n"); - return false; - } + // Data tag requested but none available? + if (data && !dataCount) { + // Let empty data tag through. + if (!*data) + data = 0; + else { + fprintf(stderr, "Unknown testdata for function %s(): '%s'\n", name.constData(), data); + fprintf(stderr, "Function has no testdata.\n"); + return false; } - - /* For each entry in the data table, do: */ - do { - QTestResult::setSkipCurrentTest(false); - QTestResult::setBlacklistCurrentTest(false); - if (!data || !qstrcmp(data, table.testData(curDataIndex)->dataTag())) { - foundFunction = true; - - QTestPrivate::checkBlackLists(name.constData(), dataCount ? table.testData(curDataIndex)->dataTag() : 0); - - QTestDataSetter s(curDataIndex >= dataCount ? static_cast(0) - : table.testData(curDataIndex)); - - QTestPrivate::qtestMouseButtons = Qt::NoButton; - if (watchDog) - watchDog->beginTest(); - invokeTestOnData(index); - if (watchDog) - watchDog->testFinished(); - - if (data) - break; - } - ++curDataIndex; - } while (curDataIndex < dataCount); } + /* For each entry in this test's data table, do: */ + do { + QTestResult::setSkipCurrentTest(false); + QTestResult::setBlacklistCurrentTest(false); + if (!data || !qstrcmp(data, table.testData(curDataIndex)->dataTag())) { + foundFunction = true; + + QTestPrivate::checkBlackLists(name.constData(), dataCount ? table.testData(curDataIndex)->dataTag() : 0); + + QTestDataSetter s(curDataIndex >= dataCount ? static_cast(0) + : table.testData(curDataIndex)); + + QTestPrivate::qtestMouseButtons = Qt::NoButton; + if (watchDog) + watchDog->beginTest(); + invokeTestOnData(index); + if (watchDog) + watchDog->testFinished(); + + if (data) + break; + } + ++curDataIndex; + } while (curDataIndex < dataCount); + if (data && !foundFunction) { fprintf(stderr, "Unknown testdata for function %s: '%s()'\n", name.constData(), data); fprintf(stderr, "Available testdata:\n"); diff --git a/tests/auto/testlib/selftests/expected_globaldata.lightxml b/tests/auto/testlib/selftests/expected_globaldata.lightxml index e536031899..1212e4b364 100644 --- a/tests/auto/testlib/selftests/expected_globaldata.lightxml +++ b/tests/auto/testlib/selftests/expected_globaldata.lightxml @@ -120,6 +120,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -143,17 +167,14 @@ - + - + - - - diff --git a/tests/auto/testlib/selftests/expected_globaldata.tap b/tests/auto/testlib/selftests/expected_globaldata.tap index 318299992f..4d61b7437b 100644 --- a/tests/auto/testlib/selftests/expected_globaldata.tap +++ b/tests/auto/testlib/selftests/expected_globaldata.tap @@ -29,24 +29,29 @@ ok 7 - skipLocal(global=false:local=false) # SKIP skipping # init skipLocal local=true ok 8 - skipLocal(global=false:local=true) # SKIP skipping # cleanup skipLocal local=true +# init skipLocal local=false +ok 9 - skipLocal(global=true:local=false) # SKIP skipping +# cleanup skipLocal local=false +# init skipLocal local=true +ok 10 - skipLocal(global=true:local=true) # SKIP skipping +# cleanup skipLocal local=true # init skipSingle local=false # global: false local: false # cleanup skipSingle local=false -ok 9 - skipSingle(global=false:local=false) +ok 11 - skipSingle(global=false:local=false) # init skipSingle local=true -# global: false local: true +ok 12 - skipSingle(global=false:local=true) # SKIP Skipping # cleanup skipSingle local=true -ok 10 - skipSingle(global=false:local=true) # init skipSingle local=false -ok 11 - skipSingle(global=true:local=false) # SKIP Skipping +ok 13 - skipSingle(global=true:local=false) # SKIP Skipping # cleanup skipSingle local=false # init skipSingle local=true # global: true local: true # cleanup skipSingle local=true -ok 12 - skipSingle(global=true:local=true) +ok 14 - skipSingle(global=true:local=true) # cleanupTestCase cleanupTestCase (null) -ok 13 - cleanupTestCase() -1..13 -# tests 13 -# pass 9 +ok 15 - cleanupTestCase() +1..15 +# tests 15 +# pass 8 # fail 0 diff --git a/tests/auto/testlib/selftests/expected_globaldata.teamcity b/tests/auto/testlib/selftests/expected_globaldata.teamcity index 2f9f97d912..f76f6090ba 100644 --- a/tests/auto/testlib/selftests/expected_globaldata.teamcity +++ b/tests/auto/testlib/selftests/expected_globaldata.teamcity @@ -17,14 +17,15 @@ ##teamcity[testIgnored name='skip()' message='skipping |[Loc: qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)|]' flowId='tst_globaldata'] ##teamcity[testIgnored name='skipLocal(local=false)' message='skipping |[Loc: qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)|]' flowId='tst_globaldata'] ##teamcity[testIgnored name='skipLocal(local=true)' message='skipping |[Loc: qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)|]' flowId='tst_globaldata'] +##teamcity[testIgnored name='skipLocal(local=false)' message='skipping |[Loc: qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)|]' flowId='tst_globaldata'] +##teamcity[testIgnored name='skipLocal(local=true)' message='skipping |[Loc: qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)|]' flowId='tst_globaldata'] ##teamcity[testStarted name='skipSingle(local=false)' flowId='tst_globaldata'] -##teamcity[testStdOut name='skipSingle(local=false)' out='QDEBUG: init skipLocal local=false|nQDEBUG: cleanup skipLocal local=false|nQDEBUG: init skipLocal local=true|nQDEBUG: cleanup skipLocal local=true|nQDEBUG: init skipSingle local=false|nQDEBUG: global: false local: false|nQDEBUG: cleanup skipSingle local=false' flowId='tst_globaldata'] +##teamcity[testStdOut name='skipSingle(local=false)' out='QDEBUG: init skipLocal local=false|nQDEBUG: cleanup skipLocal local=false|nQDEBUG: init skipLocal local=true|nQDEBUG: cleanup skipLocal local=true|nQDEBUG: init skipLocal local=false|nQDEBUG: cleanup skipLocal local=false|nQDEBUG: init skipLocal local=true|nQDEBUG: cleanup skipLocal local=true|nQDEBUG: init skipSingle local=false|nQDEBUG: global: false local: false|nQDEBUG: cleanup skipSingle local=false' flowId='tst_globaldata'] ##teamcity[testFinished name='skipSingle(local=false)' flowId='tst_globaldata'] -##teamcity[testStarted name='skipSingle(local=true)' flowId='tst_globaldata'] -##teamcity[testStdOut name='skipSingle(local=true)' out='QDEBUG: init skipSingle local=true|nQDEBUG: global: false local: true|nQDEBUG: cleanup skipSingle local=true' flowId='tst_globaldata'] -##teamcity[testFinished name='skipSingle(local=true)' flowId='tst_globaldata'] +##teamcity[testIgnored name='skipSingle(local=true)' message='Skipping |[Loc: qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)|]' flowId='tst_globaldata'] ##teamcity[testIgnored name='skipSingle(local=false)' message='Skipping |[Loc: qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)|]' flowId='tst_globaldata'] -##teamcity[testStdOut name='skipSingle(local=true)' out='QDEBUG: init skipSingle local=false|nQDEBUG: cleanup skipSingle local=false|nQDEBUG: init skipSingle local=true|nQDEBUG: global: true local: true|nQDEBUG: cleanup skipSingle local=true' flowId='tst_globaldata'] +##teamcity[testStarted name='skipSingle(local=true)' flowId='tst_globaldata'] +##teamcity[testStdOut name='skipSingle(local=true)' out='QDEBUG: init skipSingle local=true|nQDEBUG: cleanup skipSingle local=true|nQDEBUG: init skipSingle local=false|nQDEBUG: cleanup skipSingle local=false|nQDEBUG: init skipSingle local=true|nQDEBUG: global: true local: true|nQDEBUG: cleanup skipSingle local=true' flowId='tst_globaldata'] ##teamcity[testFinished name='skipSingle(local=true)' flowId='tst_globaldata'] ##teamcity[testStarted name='cleanupTestCase()' flowId='tst_globaldata'] ##teamcity[testStdOut name='cleanupTestCase()' out='QDEBUG: cleanupTestCase cleanupTestCase (null)' flowId='tst_globaldata'] diff --git a/tests/auto/testlib/selftests/expected_globaldata.txt b/tests/auto/testlib/selftests/expected_globaldata.txt index b18568009a..016b5e8299 100644 --- a/tests/auto/testlib/selftests/expected_globaldata.txt +++ b/tests/auto/testlib/selftests/expected_globaldata.txt @@ -32,14 +32,22 @@ QDEBUG : tst_globaldata::skipLocal(global=false:local=true) init skipLocal local SKIP : tst_globaldata::skipLocal(global=false:local=true) skipping Loc: [qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)] QDEBUG : tst_globaldata::skipLocal(global=false:local=true) cleanup skipLocal local=true +QDEBUG : tst_globaldata::skipLocal(global=true:local=false) init skipLocal local=false +SKIP : tst_globaldata::skipLocal(global=true:local=false) skipping + Loc: [qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)] +QDEBUG : tst_globaldata::skipLocal(global=true:local=false) cleanup skipLocal local=false +QDEBUG : tst_globaldata::skipLocal(global=true:local=true) init skipLocal local=true +SKIP : tst_globaldata::skipLocal(global=true:local=true) skipping + Loc: [qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)] +QDEBUG : tst_globaldata::skipLocal(global=true:local=true) cleanup skipLocal local=true QDEBUG : tst_globaldata::skipSingle(global=false:local=false) init skipSingle local=false QDEBUG : tst_globaldata::skipSingle(global=false:local=false) global: false local: false QDEBUG : tst_globaldata::skipSingle(global=false:local=false) cleanup skipSingle local=false PASS : tst_globaldata::skipSingle(global=false:local=false) QDEBUG : tst_globaldata::skipSingle(global=false:local=true) init skipSingle local=true -QDEBUG : tst_globaldata::skipSingle(global=false:local=true) global: false local: true +SKIP : tst_globaldata::skipSingle(global=false:local=true) Skipping + Loc: [qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)] QDEBUG : tst_globaldata::skipSingle(global=false:local=true) cleanup skipSingle local=true -PASS : tst_globaldata::skipSingle(global=false:local=true) QDEBUG : tst_globaldata::skipSingle(global=true:local=false) init skipSingle local=false SKIP : tst_globaldata::skipSingle(global=true:local=false) Skipping Loc: [qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)] @@ -50,5 +58,5 @@ QDEBUG : tst_globaldata::skipSingle(global=true:local=true) cleanup skipSingle l PASS : tst_globaldata::skipSingle(global=true:local=true) QDEBUG : tst_globaldata::cleanupTestCase() cleanupTestCase cleanupTestCase (null) PASS : tst_globaldata::cleanupTestCase() -Totals: 9 passed, 0 failed, 4 skipped, 0 blacklisted, 0ms +Totals: 8 passed, 0 failed, 7 skipped, 0 blacklisted, 0ms ********* Finished testing of tst_globaldata ********* diff --git a/tests/auto/testlib/selftests/expected_globaldata.xml b/tests/auto/testlib/selftests/expected_globaldata.xml index b2f92016e5..9aa48c8f16 100644 --- a/tests/auto/testlib/selftests/expected_globaldata.xml +++ b/tests/auto/testlib/selftests/expected_globaldata.xml @@ -122,6 +122,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -145,17 +169,14 @@ - + - + - - - diff --git a/tests/auto/testlib/selftests/expected_globaldata.xunitxml b/tests/auto/testlib/selftests/expected_globaldata.xunitxml index b135240d26..de184c2fdd 100644 --- a/tests/auto/testlib/selftests/expected_globaldata.xunitxml +++ b/tests/auto/testlib/selftests/expected_globaldata.xunitxml @@ -1,5 +1,5 @@ - + @@ -36,13 +36,19 @@ + + + + + + - + @@ -79,11 +85,17 @@ + + + + + + - + diff --git a/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp b/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp index f425648ecc..3c5c2c8f37 100644 --- a/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp +++ b/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp @@ -125,11 +125,12 @@ void tst_globaldata::skipSingle() QFETCH_GLOBAL(bool, global); QFETCH(bool, local); - // A skip in the last run of one global row suppresses the test in the next - // global row (where a skip in an earlier run of the first row does not). - if (global && !local) + // A skip in the last run of one global row used to suppress the test in the + // next global row (where a skip in an earlier run of the first row did not). + if (global ^ local) QSKIP("Skipping"); qDebug() << "global:" << global << "local:" << local; + QCOMPARE(global, local); } void tst_globaldata::skipLocal() From 6ed2ea86db63c72a38a60543da5a95d3543d39b1 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 27 Mar 2019 19:30:58 +0000 Subject: [PATCH 135/292] Doc-fixes in QRandomGenerator::bounded(int...) They return int, not quint32. Change-Id: I9879b58cccf9ea324ea1fc0c567a9d30b82fa44d Reviewed-by: Thiago Macieira --- src/corelib/global/qrandom.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp index 6195c324e7..90df8653a7 100644 --- a/src/corelib/global/qrandom.cpp +++ b/src/corelib/global/qrandom.cpp @@ -930,7 +930,7 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel */ /*! - \fn quint32 QRandomGenerator::bounded(int highest) + \fn int QRandomGenerator::bounded(int highest) \overload Generates one random 32-bit quantity in the range between 0 (inclusive) and @@ -957,7 +957,6 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel \snippet code/src_corelib_global_qrandom.cpp 14 - Note that this function cannot be used to obtain values in the full 32-bit range of quint32. Instead, use generate(). @@ -965,7 +964,7 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel */ /*! - \fn quint32 QRandomGenerator::bounded(int lowest, int highest) + \fn int QRandomGenerator::bounded(int lowest, int highest) \overload Generates one random 32-bit quantity in the range between \a lowest From 300940a6c9eb0f74cefda7d76a5d19f56ec50253 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Fri, 29 Mar 2019 10:11:27 +0100 Subject: [PATCH 136/292] Revert "Remove deprecated screen maintenance functions in QPlatformIntegration" This reverts commit 7a64ffb7738dc975b5008800901c8cd8ab238a0f. This change landed in 5.13 too early, so there is no baseline with both APIs in dev. This will be reverted later when the fixes for leaf modules landed. Task-number: QTBUG-74816 Change-Id: Ie5ee41fbf6be53b8fcb4289ac1ec3974e5bf6e42 Reviewed-by: Jesus Fernandez --- src/gui/kernel/qplatformintegration.cpp | 38 +++++++++++++++++++++++ src/gui/kernel/qplatformintegration.h | 10 ++++++ src/gui/kernel/qplatformscreen.cpp | 4 +++ src/gui/kernel/qscreen.cpp | 20 +++++------- src/gui/kernel/qwindowsysteminterface.cpp | 5 +++ 5 files changed, 64 insertions(+), 13 deletions(-) diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp index 490cfc6178..6ae6e4a528 100644 --- a/src/gui/kernel/qplatformintegration.cpp +++ b/src/gui/kernel/qplatformintegration.cpp @@ -462,6 +462,44 @@ QList QPlatformIntegration::possibleKeys(const QKeyEvent *) const return QList(); } +/*! + \deprecated Use QWindowSystemInterface::handleScreenAdded instead. +*/ +void QPlatformIntegration::screenAdded(QPlatformScreen *ps, bool isPrimary) +{ + QWindowSystemInterface::handleScreenAdded(ps, isPrimary); +} + +/*! + \deprecated Use QWindowSystemInterface::handleScreenRemoved instead. +*/ +void QPlatformIntegration::removeScreen(QScreen *screen) +{ + const bool wasPrimary = (!QGuiApplicationPrivate::screen_list.isEmpty() && QGuiApplicationPrivate::screen_list.at(0) == screen); + QGuiApplicationPrivate::screen_list.removeOne(screen); + + QGuiApplicationPrivate::resetCachedDevicePixelRatio(); + + if (wasPrimary && qGuiApp && !QGuiApplicationPrivate::screen_list.isEmpty()) + emit qGuiApp->primaryScreenChanged(QGuiApplicationPrivate::screen_list.at(0)); +} + +/*! + \deprecated Use QWindowSystemInterface::handleScreenRemoved instead. +*/ +void QPlatformIntegration::destroyScreen(QPlatformScreen *platformScreen) +{ + QWindowSystemInterface::handleScreenRemoved(platformScreen); +} + +/*! + \deprecated Use QWindowSystemInterface::handlePrimaryScreenChanged instead. +*/ +void QPlatformIntegration::setPrimaryScreen(QPlatformScreen *newPrimary) +{ + QWindowSystemInterface::handlePrimaryScreenChanged(newPrimary); +} + QStringList QPlatformIntegration::themeNames() const { return QStringList(); diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h index b764bd2617..048ea1139c 100644 --- a/src/gui/kernel/qplatformintegration.h +++ b/src/gui/kernel/qplatformintegration.h @@ -192,6 +192,10 @@ public: #endif virtual void setApplicationIcon(const QIcon &icon) const; +#if QT_DEPRECATED_SINCE(5, 12) + QT_DEPRECATED_X("Use QWindowSystemInterface::handleScreenRemoved") void removeScreen(QScreen *screen); +#endif + virtual void beep() const; #if QT_CONFIG(vulkan) || defined(Q_CLANG_QDOC) @@ -200,6 +204,12 @@ public: protected: QPlatformIntegration() = default; + +#if QT_DEPRECATED_SINCE(5, 12) + QT_DEPRECATED_X("Use QWindowSystemInterface::handleScreenAdded") void screenAdded(QPlatformScreen *screen, bool isPrimary = false); + QT_DEPRECATED_X("Use QWindowSystemInterface::handleScreenRemoved") void destroyScreen(QPlatformScreen *screen); + QT_DEPRECATED_X("Use QWindowSystemInterface::handlePrimaryScreenChanged") void setPrimaryScreen(QPlatformScreen *newPrimary); +#endif }; QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp index 9c5876550a..21ae75ba8f 100644 --- a/src/gui/kernel/qplatformscreen.cpp +++ b/src/gui/kernel/qplatformscreen.cpp @@ -62,6 +62,10 @@ QPlatformScreen::~QPlatformScreen() Q_D(QPlatformScreen); if (d->screen) { qWarning("Manually deleting a QPlatformScreen. Call QWindowSystemInterface::handleScreenRemoved instead."); +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED + QGuiApplicationPrivate::platformIntegration()->removeScreen(d->screen); +QT_WARNING_POP delete d->screen; } } diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index 952023dd1b..f208eb02be 100644 --- a/src/gui/kernel/qscreen.cpp +++ b/src/gui/kernel/qscreen.cpp @@ -106,18 +106,9 @@ void QScreenPrivate::setPlatformScreen(QPlatformScreen *screen) */ QScreen::~QScreen() { - // Remove screen - const bool wasPrimary = QGuiApplication::primaryScreen() == this; - QGuiApplicationPrivate::screen_list.removeOne(this); - QGuiApplicationPrivate::resetCachedDevicePixelRatio(); - - if (!qGuiApp) + if (!qApp) return; - QScreen *newPrimaryScreen = QGuiApplication::primaryScreen(); - if (wasPrimary && newPrimaryScreen) - emit qGuiApp->primaryScreenChanged(newPrimaryScreen); - // Allow clients to manage windows that are affected by the screen going // away, before we fall back to moving them to the primary screen. emit qApp->screenRemoved(this); @@ -125,8 +116,11 @@ QScreen::~QScreen() if (QGuiApplication::closingDown()) return; - bool movingFromVirtualSibling = newPrimaryScreen - && newPrimaryScreen->handle()->virtualSiblings().contains(handle()); + QScreen *primaryScreen = QGuiApplication::primaryScreen(); + if (this == primaryScreen) + return; + + bool movingFromVirtualSibling = primaryScreen && primaryScreen->handle()->virtualSiblings().contains(handle()); // Move any leftover windows to the primary screen const auto allWindows = QGuiApplication::allWindows(); @@ -135,7 +129,7 @@ QScreen::~QScreen() continue; const bool wasVisible = window->isVisible(); - window->setScreen(newPrimaryScreen); + window->setScreen(primaryScreen); // Re-show window if moved from a virtual sibling screen. Otherwise // leave it up to the application developer to show the window. diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 6f3edb10b4..2b40b2d4d0 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -818,6 +818,11 @@ void QWindowSystemInterface::handleScreenAdded(QPlatformScreen *ps, bool isPrima */ void QWindowSystemInterface::handleScreenRemoved(QPlatformScreen *platformScreen) { +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED + QGuiApplicationPrivate::platformIntegration()->removeScreen(platformScreen->screen()); +QT_WARNING_POP + // Important to keep this order since the QSceen doesn't own the platform screen delete platformScreen->screen(); delete platformScreen; From c19d556863d931f5fd04d9e27ee7a47aafeaca2a Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Thu, 21 Mar 2019 19:51:44 +0100 Subject: [PATCH 137/292] QVariant: deprecate qVariantFromValue/qVariantSetValue() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit qVariantFromValue/qVariantSetValue() was marked as obsolete since Qt4. Therefore mark them as deprecated with Qt5.14. Since QVariant::setValue/fromValue() were using the now deprecated functions move the implementation to them and let qVariantFromValue/qVariantSetValue() call QVariant::setValue/fromValue(). Fixes: QTBUG-74043 Change-Id: I46617cc4d5c1e8c162d0f1f7ae32e4cfe9ce915c Reviewed-by: Jędrzej Nowacki Reviewed-by: Edward Welbourne --- .../corelib/tools/doc/src/customtype.qdoc | 7 +- src/corelib/kernel/qvariant.cpp | 2 + src/corelib/kernel/qvariant.h | 68 +++++++++++-------- 3 files changed, 42 insertions(+), 35 deletions(-) diff --git a/examples/corelib/tools/doc/src/customtype.qdoc b/examples/corelib/tools/doc/src/customtype.qdoc index 91b814808a..7ccfc95c70 100644 --- a/examples/corelib/tools/doc/src/customtype.qdoc +++ b/examples/corelib/tools/doc/src/customtype.qdoc @@ -117,8 +117,8 @@ \snippet tools/customtype/main.cpp storing a custom value - Alternatively, the QVariant::fromValue() and qVariantSetValue() functions - can be used if you are using a compiler without support for member template + Alternatively, the QVariant::fromValue() function can be used if + you are using a compiler without support for member template functions. The value can be retrieved using the QVariant::value() member template @@ -126,9 +126,6 @@ \snippet tools/customtype/main.cpp retrieving a custom value - Alternatively, the qVariantValue() template function can be used if - you are using a compiler without support for member template functions. - \section1 Further Reading The custom \c Message type can also be used with direct signal-slot diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 77d2c8cbe1..cd4e233af0 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -4282,6 +4282,7 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p) \sa fromValue() */ +#if QT_DEPRECATED_SINCE(5, 14) /*! \fn template QVariant qVariantFromValue(const T &value) \relates QVariant @@ -4319,6 +4320,7 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p) \sa QVariant::setValue() */ +#endif /*! \fn template T qvariant_cast(const QVariant &value) diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index f95502e75f..90f5f5fc34 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -92,9 +92,6 @@ class QUrl; class QVariant; class QVariantComparisonHelper; -template -inline QVariant qVariantFromValue(const T &); - template inline T qvariant_cast(const QVariant &); @@ -365,7 +362,7 @@ class Q_CORE_EXPORT QVariant template static inline QVariant fromValue(const T &value) - { return qVariantFromValue(value); } + { return QVariant(qMetaTypeId(), &value, QTypeInfo::isPointer); } #if QT_HAS_INCLUDE() && __cplusplus >= 201703L template @@ -516,49 +513,60 @@ public: inline const DataPtr &data_ptr() const { return d; } }; +#if QT_DEPRECATED_SINCE(5, 14) template +QT_DEPRECATED_X("Use QVariant::fromValue() instead.") inline QVariant qVariantFromValue(const T &t) { - return QVariant(qMetaTypeId(), &t, QTypeInfo::isPointer); + return QVariant::fromValue(t); } -template <> -inline QVariant qVariantFromValue(const QVariant &t) { return t; } - -#if QT_HAS_INCLUDE() && __cplusplus >= 201703L -template <> -inline QVariant qVariantFromValue(const std::monostate &) { return QVariant(); } -#endif - template +QT_DEPRECATED_X("Use QVariant::setValue() instead.") inline void qVariantSetValue(QVariant &v, const T &t) { - //if possible we reuse the current QVariant private - const uint type = qMetaTypeId(); - QVariant::Private &d = v.data_ptr(); - if (v.isDetached() && (type == d.type || (type <= uint(QVariant::Char) && d.type <= uint(QVariant::Char)))) { - d.type = type; - d.is_null = false; - T *old = reinterpret_cast(d.is_shared ? d.data.shared->ptr : &d.data.ptr); - if (QTypeInfo::isComplex) - old->~T(); - new (old) T(t); //call the copy constructor - } else { - v = QVariant(type, &t, QTypeInfo::isPointer); - } + v.setValue(t); +} +#endif + +template<> +inline QVariant QVariant::fromValue(const QVariant &value) +{ + return value; } -template <> -inline void qVariantSetValue(QVariant &v, const QVariant &t) +#if QT_HAS_INCLUDE() && __cplusplus >= 201703L +template<> +inline QVariant QVariant::fromValue(const std::monostate &) { - v = t; + return QVariant(); } +#endif inline bool QVariant::isValid() const { return d.type != Invalid; } template inline void QVariant::setValue(const T &avalue) -{ qVariantSetValue(*this, avalue); } +{ + // If possible we reuse the current QVariant private. + const uint type = qMetaTypeId(); + if (isDetached() && (type == d.type || (type <= uint(QVariant::Char) && d.type <= uint(QVariant::Char)))) { + d.type = type; + d.is_null = false; + T *old = reinterpret_cast(d.is_shared ? d.data.shared->ptr : &d.data.ptr); + if (QTypeInfo::isComplex) + old->~T(); + new (old) T(avalue); // call the copy constructor + } else { + *this = QVariant(type, &avalue, QTypeInfo::isPointer); + } +} + +template<> +inline void QVariant::setValue(const QVariant &avalue) +{ + *this = avalue; +} #ifndef QT_NO_DATASTREAM Q_CORE_EXPORT QDataStream& operator>> (QDataStream& s, QVariant& p); From a49c5648919a0bd2d8206ae7fb5033c9f84e0a86 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 22 Feb 2019 08:19:01 +0100 Subject: [PATCH 138/292] Implement support for WA_MacNoClickThrough MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is done by adding a QWindowPrivate::allowsClickThrough() function, so this could easily be adapted later on if desired for other platforms. Fixes: QTBUG-41126 Change-Id: I1157e5e7e7667ff11d1a5d21b3ce8c4b13202272 Reviewed-by: Morten Johan Sørvig --- src/gui/kernel/qwindow_p.h | 2 + src/plugins/platforms/cocoa/qnsview_mouse.mm | 5 ++ src/widgets/kernel/qwidgetwindow.cpp | 7 +++ tests/manual/cocoa/noclickthrough/main.cpp | 48 +++++++++++++++++++ .../cocoa/noclickthrough/noclickthrough.pro | 4 ++ 5 files changed, 66 insertions(+) create mode 100644 tests/manual/cocoa/noclickthrough/main.cpp create mode 100644 tests/manual/cocoa/noclickthrough/noclickthrough.pro diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h index eb0b606598..cc1cc24525 100644 --- a/src/gui/kernel/qwindow_p.h +++ b/src/gui/kernel/qwindow_p.h @@ -164,6 +164,8 @@ public: static Qt::WindowState effectiveState(Qt::WindowStates); + virtual bool allowClickThrough(const QPoint &) const { return true; } + QWindow::SurfaceType surfaceType; Qt::WindowFlags windowFlags; QWindow *parentWindow; diff --git a/src/plugins/platforms/cocoa/qnsview_mouse.mm b/src/plugins/platforms/cocoa/qnsview_mouse.mm index 6e3cff2b48..0ab09b97d3 100644 --- a/src/plugins/platforms/cocoa/qnsview_mouse.mm +++ b/src/plugins/platforms/cocoa/qnsview_mouse.mm @@ -197,6 +197,11 @@ return NO; if ([self isTransparentForUserInput]) return NO; + QPointF windowPoint; + QPointF screenPoint; + [self convertFromScreen:[NSEvent mouseLocation] toWindowPoint: &windowPoint andScreenPoint: &screenPoint]; + if (!qt_window_private(m_platformWindow->window())->allowClickThrough(screenPoint.toPoint())) + return NO; return YES; } diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index c6f22aa21a..f44f63d71b 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -106,6 +106,7 @@ public: if (QWidget *widget = q->widget()) QWidgetPrivate::get(widget)->updateContentsRect(); } + bool allowClickThrough(const QPoint &) const override; }; QRectF QWidgetWindowPrivate::closestAcceptableGeometry(const QRectF &rect) const @@ -221,6 +222,12 @@ static inline bool shouldBePropagatedToWidget(QEvent *event) } } +bool QWidgetWindowPrivate::allowClickThrough(const QPoint &globalPos) const +{ + QWidget *w = QApplication::widgetAt(globalPos); + return w && !w->testAttribute(Qt::WA_MacNoClickThrough); +} + bool QWidgetWindow::event(QEvent *event) { if (!m_widget) diff --git a/tests/manual/cocoa/noclickthrough/main.cpp b/tests/manual/cocoa/noclickthrough/main.cpp new file mode 100644 index 0000000000..eee7729999 --- /dev/null +++ b/tests/manual/cocoa/noclickthrough/main.cpp @@ -0,0 +1,48 @@ +/**************************************************************************** + ** + ** Copyright (C) 2019 The Qt Company Ltd. + ** 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 + +int main(int argc, char **argv) +{ + QApplication a(argc, argv); + QWidget w; + QVBoxLayout *vbox = new QVBoxLayout; + QLabel *label = new QLabel("Make the window inactive, but visible.\n" + "Then click on the Two item.\n" + "The item should not be selected, but the window should be active."); + vbox->addWidget(label); + QListWidget *list = new QListWidget; + list->addItems(QStringList() << "One" << "Two" << "Three"); + list->selectionModel()->select(list->model()->index(0, 0), QItemSelectionModel::Select); + list->viewport()->setAttribute(Qt::WA_MacNoClickThrough); + vbox->addWidget(list); + w.setLayout(vbox); + w.show(); + return a.exec(); +} diff --git a/tests/manual/cocoa/noclickthrough/noclickthrough.pro b/tests/manual/cocoa/noclickthrough/noclickthrough.pro new file mode 100644 index 0000000000..a8e30cb146 --- /dev/null +++ b/tests/manual/cocoa/noclickthrough/noclickthrough.pro @@ -0,0 +1,4 @@ +QT += widgets +TEMPLATE = app +TARGET = noclickthrough +SOURCES += main.cpp From ad313595e0662fa2e91676feef65aad5b4525a86 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Sat, 30 Mar 2019 21:52:42 +0100 Subject: [PATCH 139/292] Revert "Revert "Remove deprecated screen maintenance functions in QPlatformIntegration"" This reverts commit 300940a6c9eb0f74cefda7d76a5d19f56ec50253. The fixes for leaf modules landed already. Task-number: QTBUG-74816 Change-Id: I1c7f0705c20d030419ceedca485106af73946b3c Reviewed-by: Jesus Fernandez --- src/gui/kernel/qplatformintegration.cpp | 38 ----------------------- src/gui/kernel/qplatformintegration.h | 10 ------ src/gui/kernel/qplatformscreen.cpp | 4 --- src/gui/kernel/qscreen.cpp | 20 +++++++----- src/gui/kernel/qwindowsysteminterface.cpp | 5 --- 5 files changed, 13 insertions(+), 64 deletions(-) diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp index 6ae6e4a528..490cfc6178 100644 --- a/src/gui/kernel/qplatformintegration.cpp +++ b/src/gui/kernel/qplatformintegration.cpp @@ -462,44 +462,6 @@ QList QPlatformIntegration::possibleKeys(const QKeyEvent *) const return QList(); } -/*! - \deprecated Use QWindowSystemInterface::handleScreenAdded instead. -*/ -void QPlatformIntegration::screenAdded(QPlatformScreen *ps, bool isPrimary) -{ - QWindowSystemInterface::handleScreenAdded(ps, isPrimary); -} - -/*! - \deprecated Use QWindowSystemInterface::handleScreenRemoved instead. -*/ -void QPlatformIntegration::removeScreen(QScreen *screen) -{ - const bool wasPrimary = (!QGuiApplicationPrivate::screen_list.isEmpty() && QGuiApplicationPrivate::screen_list.at(0) == screen); - QGuiApplicationPrivate::screen_list.removeOne(screen); - - QGuiApplicationPrivate::resetCachedDevicePixelRatio(); - - if (wasPrimary && qGuiApp && !QGuiApplicationPrivate::screen_list.isEmpty()) - emit qGuiApp->primaryScreenChanged(QGuiApplicationPrivate::screen_list.at(0)); -} - -/*! - \deprecated Use QWindowSystemInterface::handleScreenRemoved instead. -*/ -void QPlatformIntegration::destroyScreen(QPlatformScreen *platformScreen) -{ - QWindowSystemInterface::handleScreenRemoved(platformScreen); -} - -/*! - \deprecated Use QWindowSystemInterface::handlePrimaryScreenChanged instead. -*/ -void QPlatformIntegration::setPrimaryScreen(QPlatformScreen *newPrimary) -{ - QWindowSystemInterface::handlePrimaryScreenChanged(newPrimary); -} - QStringList QPlatformIntegration::themeNames() const { return QStringList(); diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h index 048ea1139c..b764bd2617 100644 --- a/src/gui/kernel/qplatformintegration.h +++ b/src/gui/kernel/qplatformintegration.h @@ -192,10 +192,6 @@ public: #endif virtual void setApplicationIcon(const QIcon &icon) const; -#if QT_DEPRECATED_SINCE(5, 12) - QT_DEPRECATED_X("Use QWindowSystemInterface::handleScreenRemoved") void removeScreen(QScreen *screen); -#endif - virtual void beep() const; #if QT_CONFIG(vulkan) || defined(Q_CLANG_QDOC) @@ -204,12 +200,6 @@ public: protected: QPlatformIntegration() = default; - -#if QT_DEPRECATED_SINCE(5, 12) - QT_DEPRECATED_X("Use QWindowSystemInterface::handleScreenAdded") void screenAdded(QPlatformScreen *screen, bool isPrimary = false); - QT_DEPRECATED_X("Use QWindowSystemInterface::handleScreenRemoved") void destroyScreen(QPlatformScreen *screen); - QT_DEPRECATED_X("Use QWindowSystemInterface::handlePrimaryScreenChanged") void setPrimaryScreen(QPlatformScreen *newPrimary); -#endif }; QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp index 21ae75ba8f..9c5876550a 100644 --- a/src/gui/kernel/qplatformscreen.cpp +++ b/src/gui/kernel/qplatformscreen.cpp @@ -62,10 +62,6 @@ QPlatformScreen::~QPlatformScreen() Q_D(QPlatformScreen); if (d->screen) { qWarning("Manually deleting a QPlatformScreen. Call QWindowSystemInterface::handleScreenRemoved instead."); -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED - QGuiApplicationPrivate::platformIntegration()->removeScreen(d->screen); -QT_WARNING_POP delete d->screen; } } diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index f208eb02be..952023dd1b 100644 --- a/src/gui/kernel/qscreen.cpp +++ b/src/gui/kernel/qscreen.cpp @@ -106,9 +106,18 @@ void QScreenPrivate::setPlatformScreen(QPlatformScreen *screen) */ QScreen::~QScreen() { - if (!qApp) + // Remove screen + const bool wasPrimary = QGuiApplication::primaryScreen() == this; + QGuiApplicationPrivate::screen_list.removeOne(this); + QGuiApplicationPrivate::resetCachedDevicePixelRatio(); + + if (!qGuiApp) return; + QScreen *newPrimaryScreen = QGuiApplication::primaryScreen(); + if (wasPrimary && newPrimaryScreen) + emit qGuiApp->primaryScreenChanged(newPrimaryScreen); + // Allow clients to manage windows that are affected by the screen going // away, before we fall back to moving them to the primary screen. emit qApp->screenRemoved(this); @@ -116,11 +125,8 @@ QScreen::~QScreen() if (QGuiApplication::closingDown()) return; - QScreen *primaryScreen = QGuiApplication::primaryScreen(); - if (this == primaryScreen) - return; - - bool movingFromVirtualSibling = primaryScreen && primaryScreen->handle()->virtualSiblings().contains(handle()); + bool movingFromVirtualSibling = newPrimaryScreen + && newPrimaryScreen->handle()->virtualSiblings().contains(handle()); // Move any leftover windows to the primary screen const auto allWindows = QGuiApplication::allWindows(); @@ -129,7 +135,7 @@ QScreen::~QScreen() continue; const bool wasVisible = window->isVisible(); - window->setScreen(primaryScreen); + window->setScreen(newPrimaryScreen); // Re-show window if moved from a virtual sibling screen. Otherwise // leave it up to the application developer to show the window. diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 2b40b2d4d0..6f3edb10b4 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -818,11 +818,6 @@ void QWindowSystemInterface::handleScreenAdded(QPlatformScreen *ps, bool isPrima */ void QWindowSystemInterface::handleScreenRemoved(QPlatformScreen *platformScreen) { -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED - QGuiApplicationPrivate::platformIntegration()->removeScreen(platformScreen->screen()); -QT_WARNING_POP - // Important to keep this order since the QSceen doesn't own the platform screen delete platformScreen->screen(); delete platformScreen; From f3002b6e205463305502600df95b1ae509e47a9b Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 26 Mar 2019 19:20:24 +0100 Subject: [PATCH 140/292] Use the QTime API less clumsily Various patterns seem to have been copied, notably counting time from QTime(0, 0) rather than using QTime::msecsSinceStartOfDay() and its setter. Unsuitable value types also put in an appearance, and QTime()'s parameters after the first two default to 0 anyway. Corrected a lie in QTime()'s default constructor doc; it does not work the same as QTime(0, 0) at all. Change-Id: Icf1a10052a049e68fd0f665958f36dbe75ac46d5 Reviewed-by: Thiago Macieira --- src/corelib/tools/qdatetime.cpp | 7 +++---- src/widgets/widgets/qabstractspinbox.cpp | 16 ++++++++-------- tests/auto/corelib/tools/qtime/tst_qtime.cpp | 5 +++-- .../access/qnetworkreply/tst_qnetworkreply.cpp | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 80d6dada60..d06b8a04d2 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -1464,9 +1464,8 @@ bool QDate::isLeapYear(int y) /*! \fn QTime::QTime() - Constructs a null time object. A null time can be a QTime(0, 0, 0, 0) - (i.e., midnight) object, except that isNull() returns \c true and isValid() - returns \c false. + Constructs a null time object. For a null time, isNull() returns \c true and + isValid() returns \c false. If you need a zero time, use QTime(0, 0). \sa isNull(), isValid() */ @@ -3143,7 +3142,7 @@ QDateTime::QDateTime() Q_DECL_NOEXCEPT_EXPR(Data::CanBeSmall) */ QDateTime::QDateTime(const QDate &date) - : d(QDateTimePrivate::create(date, QTime(0, 0, 0), Qt::LocalTime, 0)) + : d(QDateTimePrivate::create(date, QTime(0, 0), Qt::LocalTime, 0)) { } diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index 54caa26fb6..c617525c45 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -2030,8 +2030,8 @@ QVariant operator+(const QVariant &arg1, const QVariant &arg2) #if QT_CONFIG(datetimeparser) case QVariant::DateTime: { QDateTime a2 = arg2.toDateTime(); - QDateTime a1 = arg1.toDateTime().addDays(QDATETIMEEDIT_DATETIME_MIN.daysTo(a2)); - a1.setTime(a1.time().addMSecs(QTime().msecsTo(a2.time()))); + QDateTime a1 = arg1.toDateTime().addDays(QDATETIMEEDIT_DATE_MIN.daysTo(a2.date())); + a1.setTime(a1.time().addMSecs(a2.time().msecsSinceStartOfDay())); ret = QVariant(a1); break; } @@ -2093,11 +2093,11 @@ QVariant operator*(const QVariant &arg1, double multiplier) #if QT_CONFIG(datetimeparser) case QVariant::DateTime: { double days = QDATETIMEEDIT_DATE_MIN.daysTo(arg1.toDateTime().date()) * multiplier; - int daysInt = (int)days; + const qint64 daysInt = qint64(days); days -= daysInt; - long msecs = (long)((QDATETIMEEDIT_TIME_MIN.msecsTo(arg1.toDateTime().time()) * multiplier) - + (days * (24 * 3600 * 1000))); - ret = QDateTime(QDate().addDays(int(days)), QTime().addMSecs(msecs)); + qint64 msecs = qint64(arg1.toDateTime().time().msecsSinceStartOfDay() * multiplier + + days * (24 * 3600 * 1000)); + ret = QDateTime(QDATETIMEEDIT_DATE_MIN.addDays(daysInt), QTime::fromMSecsSinceStartOfDay(msecs)); break; } #endif // datetimeparser @@ -2127,8 +2127,8 @@ double operator/(const QVariant &arg1, const QVariant &arg2) case QVariant::DateTime: a1 = QDATETIMEEDIT_DATE_MIN.daysTo(arg1.toDate()); a2 = QDATETIMEEDIT_DATE_MIN.daysTo(arg2.toDate()); - a1 += (double)QDATETIMEEDIT_TIME_MIN.msecsTo(arg1.toDateTime().time()) / (long)(3600 * 24 * 1000); - a2 += (double)QDATETIMEEDIT_TIME_MIN.msecsTo(arg2.toDateTime().time()) / (long)(3600 * 24 * 1000); + a1 += arg1.toDateTime().time().msecsSinceStartOfDay() / (36e5 * 24); + a2 += arg2.toDateTime().time().msecsSinceStartOfDay() / (36e5 * 24); break; #endif // datetimeparser default: break; diff --git a/tests/auto/corelib/tools/qtime/tst_qtime.cpp b/tests/auto/corelib/tools/qtime/tst_qtime.cpp index 3e5724213e..3403c5bf7f 100644 --- a/tests/auto/corelib/tools/qtime/tst_qtime.cpp +++ b/tests/auto/corelib/tools/qtime/tst_qtime.cpp @@ -95,8 +95,9 @@ void tst_QTime::addSecs_data() QTest::newRow("Data0") << QTime(0,0,0) << 200 << QTime(0,3,20); QTest::newRow("Data1") << QTime(0,0,0) << 20 << QTime(0,0,20); - QTest::newRow("overflow") << QTime(0,0,0) << (INT_MAX / 1000 + 1) - << QTime(0,0,0).addSecs((INT_MAX / 1000 + 1) % 86400); + QTest::newRow("overflow") + << QTime(0,0,0) << (INT_MAX / 1000 + 1) + << QTime::fromMSecsSinceStartOfDay(((INT_MAX / 1000 + 1) % 86400) * 1000); } void tst_QTime::addSecs() diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 8627a37e12..eb956bec30 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -123,7 +123,7 @@ class tst_QNetworkReply: public QObject if (!seedCreated) { seedCreated = true; // not thread-safe, but who cares } - return QString::number(QTime(0, 0, 0).msecsTo(QTime::currentTime())) + return QString::number(QTime::currentTime().msecsSinceStartOfDay()) + QLatin1Char('-') + QString::number(QCoreApplication::applicationPid()) + QLatin1Char('-') + QString::number(QRandomGenerator::global()->generate()); } From 4690d4efa64f6b2c23acbebedfa5c8ec75e899ae Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 27 Mar 2019 18:59:47 +0000 Subject: [PATCH 141/292] Fix use of qrand/qsrand in an example Convert an example to use QRandomGenerator::global(). This saves the need for seeding. At the same time, use continuum random values rather than discrete ones, to better fit what the example using it is doing. Change-Id: I0adebaadb2e35832c629e314fda37e60b51f760d Reviewed-by: Thiago Macieira --- examples/vulkan/hellovulkancubes/renderer.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/vulkan/hellovulkancubes/renderer.cpp b/examples/vulkan/hellovulkancubes/renderer.cpp index 5ada79ce79..f104d79002 100644 --- a/examples/vulkan/hellovulkancubes/renderer.cpp +++ b/examples/vulkan/hellovulkancubes/renderer.cpp @@ -49,6 +49,7 @@ ****************************************************************************/ #include "renderer.h" +#include "qrandom.h" #include #include #include @@ -77,8 +78,6 @@ Renderer::Renderer(VulkanWindow *w, int initialCount) m_cam(QVector3D(0.0f, 0.0f, 20.0f)), // starting camera position m_instCount(initialCount) { - qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime())); - m_floorModel.translate(0, -5, 0); m_floorModel.rotate(-90, 1, 0, 0); m_floorModel.scale(20, 100, 1); @@ -793,7 +792,9 @@ void Renderer::ensureInstanceBuffer() qDebug("Preparing instances %d..%d", m_preparedInstCount, m_instCount - 1); char *p = m_instData.data(); p += m_preparedInstCount * PER_INSTANCE_DATA_SIZE; - auto gen = [](float a, float b) { return float((qrand() % int(b - a + 1)) + a); }; + auto gen = [](int a, int b) { + return float(QRandomGenerator::global()->bounded(double(b - a)) + a); + }; for (int i = m_preparedInstCount; i < m_instCount; ++i) { // Apply a random translation to each instance of the mesh. float t[] = { gen(-5, 5), gen(-4, 6), gen(-30, 5) }; From 758f47eb5d2aef2e52c43332fa09699180f63608 Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Fri, 5 Oct 2018 14:47:46 +0200 Subject: [PATCH 142/292] Fix -Wweak-vtables warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I0cb5916093edf08d72add93573b828021e86256a Reviewed-by: Mårten Nordheim Reviewed-by: Edward Welbourne Reviewed-by: Thiago Macieira --- .../network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp index 6c3443a735..45abb6aa05 100644 --- a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp +++ b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp @@ -60,12 +60,15 @@ private slots: class MyCookieJar: public QNetworkCookieJar { public: + ~MyCookieJar() override; inline QList allCookies() const { return QNetworkCookieJar::allCookies(); } inline void setAllCookies(const QList &cookieList) { QNetworkCookieJar::setAllCookies(cookieList); } }; +MyCookieJar::~MyCookieJar() = default; + void tst_QNetworkCookieJar::getterSetter() { MyCookieJar jar; From 9cd021f517e55abc31b3fd9e405ea94ce9eda44d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 15 Jan 2019 13:31:21 +0100 Subject: [PATCH 143/292] uic: Refactor reverse name lookup Add a helper routine to look up the dom classes by attribute name and change Driver::widgetByName() and Driver::actionByName() to use that as does Driver::actionGroupByName() (all these functions are called with names from the XML files). Remove the name normalization in WriteInitialization::findDeclaration() and refactor WriteInitialization::acceptActionRef() to call findOrInsert() to correctly use the unique name. Task-number: PYSIDE-797 Change-Id: I34058361964719c442182faf798f055f11b40412 Reviewed-by: Cristian Maureira-Fredes --- src/tools/uic/cpp/cppwriteinitialization.cpp | 39 ++++++++++---------- src/tools/uic/driver.cpp | 23 ++++++++---- src/tools/uic/driver.h | 3 ++ 3 files changed, 37 insertions(+), 28 deletions(-) diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 2fb3e502c5..881c48daea 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -1069,28 +1069,29 @@ void WriteInitialization::acceptActionRef(DomActionRef *node) } const QString varName = m_driver->findOrInsertWidget(m_widgetChain.top()); - const bool isSeparator = actionName == QLatin1String("separator"); - bool isMenu = false; - if (const DomWidget *w = m_driver->widgetByName(actionName)) { - isMenu = m_uic->isMenu(w->attributeClass()); - } else if (!(m_driver->actionByName(actionName) || isSeparator)) { - fprintf(stderr, "%s: Warning: action `%s' not declared\n", - qPrintable(m_option.messagePrefix()), - actionName.toLatin1().data()); - return; - } - - if (m_widgetChain.top() && isSeparator) { + if (m_widgetChain.top() && actionName == QLatin1String("separator")) { // separator is always reserved! m_actionOut << m_indent << varName << "->addSeparator();\n"; return; } - if (isMenu) - actionName += QLatin1String("->menuAction()"); + const DomWidget *domWidget = m_driver->widgetByName(actionName); + if (domWidget && m_uic->isMenu(domWidget->attributeClass())) { + m_actionOut << m_indent << varName << "->addAction(" + << m_driver->findOrInsertWidget(domWidget) << "->menuAction());\n"; + return; + } - m_actionOut << m_indent << varName << "->addAction(" << actionName << ");\n"; + const DomAction *domAction = m_driver->actionByName(actionName); + if (!domAction) { + fprintf(stderr, "%s: Warning: action `%s' not declared\n", + qPrintable(m_option.messagePrefix()), qPrintable(actionName)); + return; + } + + m_actionOut << m_indent << varName << "->addAction(" + << m_driver->findOrInsertAction(domAction) << ");\n"; } QString WriteInitialization::writeStringListProperty(const DomStringList *list) const @@ -2430,13 +2431,11 @@ QTextStream &WriteInitialization::autoTrOutput(const DomString *str, const QStri QString WriteInitialization::findDeclaration(const QString &name) { - const QString normalized = Driver::normalizedName(name); - - if (const DomWidget *widget = m_driver->widgetByName(normalized)) + if (const DomWidget *widget = m_driver->widgetByName(name)) return m_driver->findOrInsertWidget(widget); - if (const DomAction *action = m_driver->actionByName(normalized)) + if (const DomAction *action = m_driver->actionByName(name)) return m_driver->findOrInsertAction(action); - if (const DomButtonGroup *group = m_driver->findButtonGroup(normalized)) + if (const DomButtonGroup *group = m_driver->findButtonGroup(name)) return m_driver->findOrInsertButtonGroup(group); return QString(); } diff --git a/src/tools/uic/driver.cpp b/src/tools/uic/driver.cpp index 03fa1e17cf..7d690cd2fe 100644 --- a/src/tools/uic/driver.cpp +++ b/src/tools/uic/driver.cpp @@ -50,6 +50,17 @@ static inline QString actionGroupClass() { return QStringLiteral("QActionGroup") static inline QString actionClass() { return QStringLiteral("QAction"); } static inline QString buttonGroupClass() { return QStringLiteral("QButtonGroup"); } +template +const DomClass *Driver::findByAttributeName(const DomObjectHash &domHash, + const QString &name) const +{ + for (auto it = domHash.cbegin(), end = domHash.cend(); it != end; ++it) { + if (it.key()->attributeName() == name) + return it.key(); + } + return nullptr; +} + template QString Driver::findOrInsert(DomObjectHash *domHash, const DomClass *dom, const QString &className) @@ -111,11 +122,7 @@ QString Driver::findOrInsertButtonGroup(const DomButtonGroup *ui_group) // Find a group by its non-uniqified name const DomButtonGroup *Driver::findButtonGroup(const QString &attributeName) const { - for (auto it = m_buttonGroups.cbegin(), end = m_buttonGroups.cend(); it != end; ++it) { - if (it.key()->attributeName() == attributeName) - return it.key(); - } - return nullptr; + return findByAttributeName(m_buttonGroups, attributeName); } @@ -288,17 +295,17 @@ bool Driver::uic(const QString &fileName, QTextStream *out) const DomWidget *Driver::widgetByName(const QString &name) const { - return m_widgets.key(name); + return findByAttributeName(m_widgets, name); } const DomActionGroup *Driver::actionGroupByName(const QString &name) const { - return m_actionGroups.key(name); + return findByAttributeName(m_actionGroups, name); } const DomAction *Driver::actionByName(const QString &name) const { - return m_actions.key(name); + return findByAttributeName(m_actions, name); } QT_END_NAMESPACE diff --git a/src/tools/uic/driver.h b/src/tools/uic/driver.h index 69206e1608..1e50f78746 100644 --- a/src/tools/uic/driver.h +++ b/src/tools/uic/driver.h @@ -94,6 +94,9 @@ public: private: template using DomObjectHash = QHash; + template + const DomClass *findByAttributeName(const DomObjectHash &domHash, + const QString &name) const; template QString findOrInsert(DomObjectHash *domHash, const DomClass *dom, const QString &className); From b5f76eeb5310211f128ff312223f641711198af5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Fri, 29 Mar 2019 13:10:26 +0100 Subject: [PATCH 144/292] Add missing test to project file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test was never used or compiled, it has to be fine to add it :-) Change-Id: If210c19515a545a6dbaef18a16dc018c0348070d Reviewed-by: Mårten Nordheim --- tests/auto/corelib/tools/tools.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/corelib/tools/tools.pro b/tests/auto/corelib/tools/tools.pro index 2a975e67d1..c6da33cce0 100644 --- a/tests/auto/corelib/tools/tools.pro +++ b/tests/auto/corelib/tools/tools.pro @@ -46,6 +46,7 @@ SUBDIRS=\ qringbuffer \ qscopedpointer \ qscopedvaluerollback \ + qscopeguard \ qset \ qsharedpointer \ qsize \ From b91e6f6f40864d54903d707d7f19a9732188b670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Tue, 12 Mar 2019 09:22:15 +0100 Subject: [PATCH 145/292] Issue a warning about unused result of qScopeGuard and QScopeGuard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the result is unassigned then resulting QScopeGuard is destroyed immediately, we can warn about it, as it is definitely a bug. Change-Id: I627b05cecb3d0e62dbc24373e621f2be36d9b324 Reviewed-by: Qt CI Bot Reviewed-by: Mårten Nordheim --- src/corelib/tools/qscopeguard.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qscopeguard.h b/src/corelib/tools/qscopeguard.h index 31100fcabb..0f61996eb6 100644 --- a/src/corelib/tools/qscopeguard.h +++ b/src/corelib/tools/qscopeguard.h @@ -50,7 +50,12 @@ template class QScopeGuard; template QScopeGuard qScopeGuard(F f); template -class QScopeGuard +class +#ifndef __INTEL_COMPILER +// error #2621: attribute "__warn_unused_result__" does not apply here +Q_REQUIRED_RESULT +#endif +QScopeGuard { public: QScopeGuard(QScopeGuard &&other) Q_DECL_NOEXCEPT @@ -86,6 +91,10 @@ private: template +#ifndef __INTEL_COMPILER +// Causes "error #3058: GNU attributes on a template redeclaration have no effect" +Q_REQUIRED_RESULT +#endif QScopeGuard qScopeGuard(F f) { return QScopeGuard(std::move(f)); From 53abc0f664f349ed5573750df484593647f349b9 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 2 Apr 2019 11:07:43 +0200 Subject: [PATCH 146/292] Remove special NOTHROW handling We no longer have any MSVC support that wouldn't set Q_DECL_NOEXCEPT Change-Id: I3e2c74cb89b9c56ffaf17001004c87b88622da82 Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 345ab9e8ad..e47f284a42 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -110,12 +110,6 @@ # define Q_CC_INTEL __INTEL_COMPILER # endif -/* only defined for MSVC since that's the only compiler that actually optimizes for this */ -/* might get overridden further down when Q_COMPILER_NOEXCEPT is detected */ -# ifdef __cplusplus -# define Q_DECL_NOTHROW throw() -# endif - #elif defined(__BORLANDC__) || defined(__TURBOC__) # define Q_CC_BOR # define Q_INLINE_TEMPLATE @@ -1128,16 +1122,11 @@ #ifdef Q_COMPILER_NOEXCEPT # define Q_DECL_NOEXCEPT noexcept # define Q_DECL_NOEXCEPT_EXPR(x) noexcept(x) -# ifdef Q_DECL_NOTHROW -# undef Q_DECL_NOTHROW /* override with C++11 noexcept if available */ -# endif #else # define Q_DECL_NOEXCEPT # define Q_DECL_NOEXCEPT_EXPR(x) #endif -#ifndef Q_DECL_NOTHROW -# define Q_DECL_NOTHROW Q_DECL_NOEXCEPT -#endif +#define Q_DECL_NOTHROW Q_DECL_NOEXCEPT #if defined(Q_COMPILER_ALIGNOF) # undef Q_ALIGNOF From 6c761a0db11b7a2b0104dbf46607ca396ae7ee2d Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 2 Apr 2019 10:58:32 +0200 Subject: [PATCH 147/292] Replace Q_NULLPTR with nullptr in corelib Change-Id: I9cdb5b7015c62c50b35f8a6519ea4e777db97683 Reviewed-by: Thiago Macieira --- src/corelib/global/qflags.h | 2 +- src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp | 2 +- src/corelib/kernel/qtestsupport_core.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h index e9fee5f23e..6aa6850c69 100644 --- a/src/corelib/global/qflags.h +++ b/src/corelib/global/qflags.h @@ -118,7 +118,7 @@ public: Q_DECL_CONSTEXPR inline QFlags &operator=(const QFlags &other); #endif Q_DECL_CONSTEXPR inline QFlags(Enum flags) Q_DECL_NOTHROW : i(Int(flags)) {} - Q_DECL_CONSTEXPR inline QFlags(Zero = Q_NULLPTR) Q_DECL_NOTHROW : i(0) {} + Q_DECL_CONSTEXPR inline QFlags(Zero = nullptr) Q_DECL_NOTHROW : i(0) {} Q_DECL_CONSTEXPR inline QFlags(QFlag flag) Q_DECL_NOTHROW : i(flag) {} #ifdef Q_COMPILER_INITIALIZER_LISTS diff --git a/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp b/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp index a20024f468..0319d215a1 100644 --- a/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp +++ b/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp @@ -55,7 +55,7 @@ public: struct SourceModelForRowResult { - SourceModelForRowResult() : sourceModel(Q_NULLPTR), sourceRow(-1) {} + SourceModelForRowResult() : sourceModel(nullptr), sourceRow(-1) {} QAbstractItemModel *sourceModel; int sourceRow; }; diff --git a/src/corelib/kernel/qtestsupport_core.cpp b/src/corelib/kernel/qtestsupport_core.cpp index c54b933f94..7bd81ed498 100644 --- a/src/corelib/kernel/qtestsupport_core.cpp +++ b/src/corelib/kernel/qtestsupport_core.cpp @@ -102,7 +102,7 @@ Q_CORE_EXPORT void QTest::qWait(int ms) int remaining = ms; do { QCoreApplication::processEvents(QEventLoop::AllEvents, remaining); - QCoreApplication::sendPostedEvents(Q_NULLPTR, QEvent::DeferredDelete); + QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); remaining = timer.remainingTime(); if (remaining <= 0) break; From a1e62e7ba14b00ac7c361936a18e7bc42bf1286d Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 2 Apr 2019 10:54:54 +0200 Subject: [PATCH 148/292] Replace Q_DECL_NOEXCEPT with noexcept in corelib In preparation of Qt6 move away from pre-C++11 macros. Change-Id: I44126693c20c18eca5620caab4f7e746218e0ce3 Reviewed-by: Thiago Macieira --- src/corelib/codecs/qtextcodec.cpp | 2 +- src/corelib/codecs/qutfcodec.cpp | 4 +- src/corelib/codecs/qutfcodec_p.h | 2 +- src/corelib/global/qflags.h | 76 +-- src/corelib/global/qfloat16.cpp | 16 +- src/corelib/global/qfloat16.h | 82 +-- src/corelib/global/qglobal.cpp | 18 +- src/corelib/global/qglobal.h | 32 +- src/corelib/global/qglobalstatic.h | 2 +- src/corelib/global/qlibraryinfo.cpp | 4 +- src/corelib/global/qlibraryinfo.h | 4 +- src/corelib/global/qlogging.cpp | 6 +- src/corelib/global/qlogging.h | 4 +- src/corelib/global/qnamespace.h | 6 +- src/corelib/global/qnumeric_p.h | 6 +- src/corelib/global/qrandom.cpp | 20 +- src/corelib/global/qrandom.h | 6 +- src/corelib/io/qdebug.h | 2 +- src/corelib/io/qdir.h | 6 +- src/corelib/io/qfileinfo.h | 4 +- src/corelib/io/qprocess.h | 4 +- src/corelib/io/qstorageinfo.h | 4 +- src/corelib/io/qurl.cpp | 2 +- src/corelib/io/qurl.h | 10 +- src/corelib/io/qurlquery.cpp | 2 +- src/corelib/io/qurlquery.h | 8 +- src/corelib/io/qurlrecode.cpp | 2 +- src/corelib/itemmodels/qabstractitemmodel.h | 38 +- src/corelib/itemmodels/qitemselectionmodel.h | 8 +- src/corelib/kernel/qcore_unix_p.h | 2 +- src/corelib/kernel/qcoreapplication.cpp | 2 +- src/corelib/kernel/qcoreevent.cpp | 8 +- src/corelib/kernel/qcoreevent.h | 2 +- src/corelib/kernel/qdeadlinetimer.cpp | 24 +- src/corelib/kernel/qdeadlinetimer.h | 50 +- src/corelib/kernel/qelapsedtimer.cpp | 6 +- src/corelib/kernel/qelapsedtimer.h | 30 +- src/corelib/kernel/qelapsedtimer_generic.cpp | 22 +- src/corelib/kernel/qelapsedtimer_mac.cpp | 24 +- src/corelib/kernel/qelapsedtimer_unix.cpp | 24 +- src/corelib/kernel/qelapsedtimer_win.cpp | 22 +- src/corelib/kernel/qeventdispatcher_unix_p.h | 12 +- src/corelib/kernel/qfunctions_fake_env_p.h | 4 +- src/corelib/kernel/qmetaobject.cpp | 2 +- src/corelib/kernel/qmetatype.cpp | 2 +- src/corelib/kernel/qobject.cpp | 2 +- src/corelib/kernel/qobject.h | 32 +- src/corelib/kernel/qobjectdefs.h | 14 +- src/corelib/kernel/qobjectdefs_impl.h | 4 +- src/corelib/kernel/qtimer.h | 2 +- src/corelib/kernel/qvariant.h | 14 +- src/corelib/mimetypes/qmimeglobpattern_p.h | 2 +- src/corelib/mimetypes/qmimemagicrule_p.h | 2 +- .../mimetypes/qmimemagicrulematcher_p.h | 2 +- src/corelib/mimetypes/qmimetype.cpp | 2 +- src/corelib/mimetypes/qmimetype.h | 8 +- src/corelib/plugin/quuid.cpp | 16 +- src/corelib/plugin/quuid.h | 44 +- src/corelib/serialization/qjson_p.h | 12 +- src/corelib/serialization/qjsonarray.h | 6 +- src/corelib/serialization/qjsondocument.h | 6 +- src/corelib/serialization/qjsonobject.h | 6 +- src/corelib/serialization/qjsonvalue.h | 6 +- src/corelib/serialization/qtextstream.h | 4 +- src/corelib/serialization/qxmlstream.h | 24 +- src/corelib/statemachine/qstatemachine_p.h | 12 +- src/corelib/thread/qatomic.h | 18 +- src/corelib/thread/qatomic_bootstrap.h | 10 +- src/corelib/thread/qatomic_cxx11.h | 86 +-- src/corelib/thread/qatomic_msvc.h | 92 +-- src/corelib/thread/qbasicatomic.h | 194 +++--- src/corelib/thread/qfutex_p.h | 2 +- src/corelib/thread/qgenericatomic.h | 98 +-- src/corelib/thread/qmutex.cpp | 14 +- src/corelib/thread/qmutex.h | 54 +- src/corelib/thread/qmutex_linux.cpp | 8 +- src/corelib/thread/qmutex_mac.cpp | 2 +- src/corelib/thread/qmutex_p.h | 4 +- src/corelib/thread/qmutex_unix.cpp | 4 +- src/corelib/thread/qmutex_win.cpp | 2 +- src/corelib/thread/qorderedmutexlocker_p.h | 2 +- src/corelib/thread/qreadwritelock.h | 36 +- src/corelib/thread/qsemaphore.h | 14 +- src/corelib/thread/qthread.cpp | 4 +- src/corelib/thread/qthread.h | 4 +- src/corelib/thread/qthread_p.h | 4 +- src/corelib/thread/qthread_unix.cpp | 4 +- src/corelib/thread/qthread_win.cpp | 8 +- src/corelib/tools/qalgorithms.h | 62 +- src/corelib/tools/qarraydata.cpp | 6 +- src/corelib/tools/qarraydata.h | 10 +- src/corelib/tools/qarraydatapointer.h | 8 +- src/corelib/tools/qbitarray.h | 10 +- src/corelib/tools/qbytearray.cpp | 6 +- src/corelib/tools/qbytearray.h | 52 +- src/corelib/tools/qbytearraymatcher.cpp | 2 +- src/corelib/tools/qbytearraymatcher.h | 14 +- src/corelib/tools/qcache.h | 4 +- src/corelib/tools/qchar.cpp | 56 +- src/corelib/tools/qchar.h | 240 ++++---- src/corelib/tools/qcollator.h | 10 +- src/corelib/tools/qcommandlineoption.cpp | 4 +- src/corelib/tools/qcommandlineoption.h | 4 +- src/corelib/tools/qdatetime.cpp | 20 +- src/corelib/tools/qdatetime.h | 18 +- src/corelib/tools/qeasingcurve.h | 6 +- src/corelib/tools/qhash.cpp | 26 +- src/corelib/tools/qhash.h | 24 +- src/corelib/tools/qhashfunctions.h | 50 +- src/corelib/tools/qiterator.h | 4 +- src/corelib/tools/qlinkedlist.h | 44 +- src/corelib/tools/qlist.h | 98 +-- src/corelib/tools/qlocale.cpp | 8 +- src/corelib/tools/qlocale.h | 8 +- src/corelib/tools/qlocale_p.h | 6 +- src/corelib/tools/qmap.h | 18 +- src/corelib/tools/qmargins.h | 192 +++--- src/corelib/tools/qpoint.h | 6 +- src/corelib/tools/qqueue.h | 2 +- src/corelib/tools/qrect.cpp | 26 +- src/corelib/tools/qrect.h | 568 +++++++++--------- src/corelib/tools/qrefcount.h | 16 +- src/corelib/tools/qregexp.cpp | 4 +- src/corelib/tools/qregexp.h | 8 +- src/corelib/tools/qregularexpression.cpp | 2 +- src/corelib/tools/qregularexpression.h | 16 +- src/corelib/tools/qringbuffer_p.h | 14 +- src/corelib/tools/qscopedpointer.h | 36 +- src/corelib/tools/qscopeguard.h | 6 +- src/corelib/tools/qset.h | 28 +- src/corelib/tools/qshareddata.h | 24 +- src/corelib/tools/qsharedpointer_impl.h | 98 +-- src/corelib/tools/qsize.cpp | 8 +- src/corelib/tools/qsize.h | 230 +++---- src/corelib/tools/qstack.h | 2 +- src/corelib/tools/qstring.cpp | 100 +-- src/corelib/tools/qstring.h | 414 ++++++------- src/corelib/tools/qstringalgorithms.h | 44 +- src/corelib/tools/qstringbuilder.cpp | 2 +- src/corelib/tools/qstringbuilder.h | 6 +- src/corelib/tools/qstringlist.h | 6 +- src/corelib/tools/qstringliteral.h | 2 +- src/corelib/tools/qstringview.h | 82 +-- src/corelib/tools/qtimezone.cpp | 2 +- src/corelib/tools/qtimezone.h | 6 +- src/corelib/tools/qtimezoneprivate_p.h | 4 +- src/corelib/tools/qtimezoneprivate_tz.cpp | 2 +- src/corelib/tools/qtools_p.h | 14 +- src/corelib/tools/qunicodetables.cpp | 16 +- src/corelib/tools/qunicodetables_p.h | 20 +- src/corelib/tools/qvector.h | 40 +- src/corelib/tools/qversionnumber.cpp | 4 +- src/corelib/tools/qversionnumber.h | 42 +- 153 files changed, 2205 insertions(+), 2205 deletions(-) diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index e2598b7858..cac631d770 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -1061,7 +1061,7 @@ QString QTextDecoder::toUnicode(const char *chars, int len) } // in qstring.cpp: -void qt_from_latin1(ushort *dst, const char *str, size_t size) Q_DECL_NOTHROW; +void qt_from_latin1(ushort *dst, const char *str, size_t size) noexcept; /*! \overload diff --git a/src/corelib/codecs/qutfcodec.cpp b/src/corelib/codecs/qutfcodec.cpp index 643c8ee475..85736fdf02 100644 --- a/src/corelib/codecs/qutfcodec.cpp +++ b/src/corelib/codecs/qutfcodec.cpp @@ -54,7 +54,7 @@ static const uchar utf8bom[] = { 0xef, 0xbb, 0xbf }; #if (defined(__SSE2__) && defined(QT_COMPILER_SUPPORTS_SSE2)) \ || (defined(__ARM_NEON__) && defined(Q_PROCESSOR_ARM_64)) -static Q_ALWAYS_INLINE uint qBitScanReverse(unsigned v) Q_DECL_NOTHROW +static Q_ALWAYS_INLINE uint qBitScanReverse(unsigned v) noexcept { uint result = qCountLeadingZeroBits(v); // Now Invert the result: clz will count *down* from the msb to the lsb, so the msb index is 31 @@ -504,7 +504,7 @@ QString QUtf8::convertToUnicode(const char *chars, int len) This function never throws. */ -QChar *QUtf8::convertToUnicode(QChar *buffer, const char *chars, int len) Q_DECL_NOTHROW +QChar *QUtf8::convertToUnicode(QChar *buffer, const char *chars, int len) noexcept { ushort *dst = reinterpret_cast(buffer); const uchar *src = reinterpret_cast(chars); diff --git a/src/corelib/codecs/qutfcodec_p.h b/src/corelib/codecs/qutfcodec_p.h index b24283ac5e..083e16317a 100644 --- a/src/corelib/codecs/qutfcodec_p.h +++ b/src/corelib/codecs/qutfcodec_p.h @@ -291,7 +291,7 @@ enum DataEndianness struct QUtf8 { - static QChar *convertToUnicode(QChar *, const char *, int) Q_DECL_NOTHROW; + static QChar *convertToUnicode(QChar *, const char *, int) noexcept; static QString convertToUnicode(const char *, int); static QString convertToUnicode(const char *, int, QTextCodec::ConverterState *); static QByteArray convertFromUnicode(const QChar *, int); diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h index 6aa6850c69..65f4892472 100644 --- a/src/corelib/global/qflags.h +++ b/src/corelib/global/qflags.h @@ -54,21 +54,21 @@ class QFlag { int i; public: - Q_DECL_CONSTEXPR inline QFlag(int value) Q_DECL_NOTHROW : i(value) {} - Q_DECL_CONSTEXPR inline operator int() const Q_DECL_NOTHROW { return i; } + Q_DECL_CONSTEXPR inline QFlag(int value) noexcept : i(value) {} + Q_DECL_CONSTEXPR inline operator int() const noexcept { return i; } #if !defined(Q_CC_MSVC) // Microsoft Visual Studio has buggy behavior when it comes to // unsigned enums: even if the enum is unsigned, the enum tags are // always signed # if !defined(__LP64__) && !defined(Q_CLANG_QDOC) - Q_DECL_CONSTEXPR inline QFlag(long value) Q_DECL_NOTHROW : i(int(value)) {} - Q_DECL_CONSTEXPR inline QFlag(ulong value) Q_DECL_NOTHROW : i(int(long(value))) {} + Q_DECL_CONSTEXPR inline QFlag(long value) noexcept : i(int(value)) {} + Q_DECL_CONSTEXPR inline QFlag(ulong value) noexcept : i(int(long(value))) {} # endif - Q_DECL_CONSTEXPR inline QFlag(uint value) Q_DECL_NOTHROW : i(int(value)) {} - Q_DECL_CONSTEXPR inline QFlag(short value) Q_DECL_NOTHROW : i(int(value)) {} - Q_DECL_CONSTEXPR inline QFlag(ushort value) Q_DECL_NOTHROW : i(int(uint(value))) {} - Q_DECL_CONSTEXPR inline operator uint() const Q_DECL_NOTHROW { return uint(i); } + Q_DECL_CONSTEXPR inline QFlag(uint value) noexcept : i(int(value)) {} + Q_DECL_CONSTEXPR inline QFlag(short value) noexcept : i(int(value)) {} + Q_DECL_CONSTEXPR inline QFlag(ushort value) noexcept : i(int(uint(value))) {} + Q_DECL_CONSTEXPR inline operator uint() const noexcept { return uint(i); } #endif }; Q_DECLARE_TYPEINFO(QFlag, Q_PRIMITIVE_TYPE); @@ -77,12 +77,12 @@ class QIncompatibleFlag { int i; public: - Q_DECL_CONSTEXPR inline explicit QIncompatibleFlag(int i) Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline operator int() const Q_DECL_NOTHROW { return i; } + Q_DECL_CONSTEXPR inline explicit QIncompatibleFlag(int i) noexcept; + Q_DECL_CONSTEXPR inline operator int() const noexcept { return i; } }; Q_DECLARE_TYPEINFO(QIncompatibleFlag, Q_PRIMITIVE_TYPE); -Q_DECL_CONSTEXPR inline QIncompatibleFlag::QIncompatibleFlag(int value) Q_DECL_NOTHROW : i(value) {} +Q_DECL_CONSTEXPR inline QIncompatibleFlag::QIncompatibleFlag(int value) noexcept : i(value) {} #ifndef Q_NO_TYPESAFE_FLAGS @@ -117,38 +117,38 @@ public: Q_DECL_CONSTEXPR inline QFlags(const QFlags &other); Q_DECL_CONSTEXPR inline QFlags &operator=(const QFlags &other); #endif - Q_DECL_CONSTEXPR inline QFlags(Enum flags) Q_DECL_NOTHROW : i(Int(flags)) {} - Q_DECL_CONSTEXPR inline QFlags(Zero = nullptr) Q_DECL_NOTHROW : i(0) {} - Q_DECL_CONSTEXPR inline QFlags(QFlag flag) Q_DECL_NOTHROW : i(flag) {} + Q_DECL_CONSTEXPR inline QFlags(Enum flags) noexcept : i(Int(flags)) {} + Q_DECL_CONSTEXPR inline QFlags(Zero = nullptr) noexcept : i(0) {} + Q_DECL_CONSTEXPR inline QFlags(QFlag flag) noexcept : i(flag) {} #ifdef Q_COMPILER_INITIALIZER_LISTS - Q_DECL_CONSTEXPR inline QFlags(std::initializer_list flags) Q_DECL_NOTHROW + Q_DECL_CONSTEXPR inline QFlags(std::initializer_list flags) noexcept : i(initializer_list_helper(flags.begin(), flags.end())) {} #endif - Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator&=(int mask) Q_DECL_NOTHROW { i &= mask; return *this; } - Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator&=(uint mask) Q_DECL_NOTHROW { i &= mask; return *this; } - Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator&=(Enum mask) Q_DECL_NOTHROW { i &= Int(mask); return *this; } - Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator|=(QFlags other) Q_DECL_NOTHROW { i |= other.i; return *this; } - Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator|=(Enum other) Q_DECL_NOTHROW { i |= Int(other); return *this; } - Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator^=(QFlags other) Q_DECL_NOTHROW { i ^= other.i; return *this; } - Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator^=(Enum other) Q_DECL_NOTHROW { i ^= Int(other); return *this; } + Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator&=(int mask) noexcept { i &= mask; return *this; } + Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator&=(uint mask) noexcept { i &= mask; return *this; } + Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator&=(Enum mask) noexcept { i &= Int(mask); return *this; } + Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator|=(QFlags other) noexcept { i |= other.i; return *this; } + Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator|=(Enum other) noexcept { i |= Int(other); return *this; } + Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator^=(QFlags other) noexcept { i ^= other.i; return *this; } + Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator^=(Enum other) noexcept { i ^= Int(other); return *this; } - Q_DECL_CONSTEXPR inline operator Int() const Q_DECL_NOTHROW { return i; } + Q_DECL_CONSTEXPR inline operator Int() const noexcept { return i; } - Q_DECL_CONSTEXPR inline QFlags operator|(QFlags other) const Q_DECL_NOTHROW { return QFlags(QFlag(i | other.i)); } - Q_DECL_CONSTEXPR inline QFlags operator|(Enum other) const Q_DECL_NOTHROW { return QFlags(QFlag(i | Int(other))); } - Q_DECL_CONSTEXPR inline QFlags operator^(QFlags other) const Q_DECL_NOTHROW { return QFlags(QFlag(i ^ other.i)); } - Q_DECL_CONSTEXPR inline QFlags operator^(Enum other) const Q_DECL_NOTHROW { return QFlags(QFlag(i ^ Int(other))); } - Q_DECL_CONSTEXPR inline QFlags operator&(int mask) const Q_DECL_NOTHROW { return QFlags(QFlag(i & mask)); } - Q_DECL_CONSTEXPR inline QFlags operator&(uint mask) const Q_DECL_NOTHROW { return QFlags(QFlag(i & mask)); } - Q_DECL_CONSTEXPR inline QFlags operator&(Enum other) const Q_DECL_NOTHROW { return QFlags(QFlag(i & Int(other))); } - Q_DECL_CONSTEXPR inline QFlags operator~() const Q_DECL_NOTHROW { return QFlags(QFlag(~i)); } + Q_DECL_CONSTEXPR inline QFlags operator|(QFlags other) const noexcept { return QFlags(QFlag(i | other.i)); } + Q_DECL_CONSTEXPR inline QFlags operator|(Enum other) const noexcept { return QFlags(QFlag(i | Int(other))); } + Q_DECL_CONSTEXPR inline QFlags operator^(QFlags other) const noexcept { return QFlags(QFlag(i ^ other.i)); } + Q_DECL_CONSTEXPR inline QFlags operator^(Enum other) const noexcept { return QFlags(QFlag(i ^ Int(other))); } + Q_DECL_CONSTEXPR inline QFlags operator&(int mask) const noexcept { return QFlags(QFlag(i & mask)); } + Q_DECL_CONSTEXPR inline QFlags operator&(uint mask) const noexcept { return QFlags(QFlag(i & mask)); } + Q_DECL_CONSTEXPR inline QFlags operator&(Enum other) const noexcept { return QFlags(QFlag(i & Int(other))); } + Q_DECL_CONSTEXPR inline QFlags operator~() const noexcept { return QFlags(QFlag(~i)); } - Q_DECL_CONSTEXPR inline bool operator!() const Q_DECL_NOTHROW { return !i; } + Q_DECL_CONSTEXPR inline bool operator!() const noexcept { return !i; } - Q_DECL_CONSTEXPR inline bool testFlag(Enum flag) const Q_DECL_NOTHROW { return (i & Int(flag)) == Int(flag) && (Int(flag) != 0 || i == Int(flag) ); } - Q_DECL_RELAXED_CONSTEXPR inline QFlags &setFlag(Enum flag, bool on = true) Q_DECL_NOTHROW + Q_DECL_CONSTEXPR inline bool testFlag(Enum flag) const noexcept { return (i & Int(flag)) == Int(flag) && (Int(flag) != 0 || i == Int(flag) ); } + Q_DECL_RELAXED_CONSTEXPR inline QFlags &setFlag(Enum flag, bool on = true) noexcept { return on ? (*this |= flag) : (*this &= ~Int(flag)); } @@ -157,7 +157,7 @@ private: #ifdef Q_COMPILER_INITIALIZER_LISTS Q_DECL_CONSTEXPR static inline Int initializer_list_helper(typename std::initializer_list::const_iterator it, typename std::initializer_list::const_iterator end) - Q_DECL_NOTHROW + noexcept { return (it == end ? Int(0) : (Int(*it) | initializer_list_helper(it + 1, end))); } @@ -172,13 +172,13 @@ typedef QFlags Flags; #endif #define Q_DECLARE_INCOMPATIBLE_FLAGS(Flags) \ -Q_DECL_CONSTEXPR inline QIncompatibleFlag operator|(Flags::enum_type f1, int f2) Q_DECL_NOTHROW \ +Q_DECL_CONSTEXPR inline QIncompatibleFlag operator|(Flags::enum_type f1, int f2) noexcept \ { return QIncompatibleFlag(int(f1) | f2); } #define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags) \ -Q_DECL_CONSTEXPR inline QFlags operator|(Flags::enum_type f1, Flags::enum_type f2) Q_DECL_NOTHROW \ +Q_DECL_CONSTEXPR inline QFlags operator|(Flags::enum_type f1, Flags::enum_type f2) noexcept \ { return QFlags(f1) | f2; } \ -Q_DECL_CONSTEXPR inline QFlags operator|(Flags::enum_type f1, QFlags f2) Q_DECL_NOTHROW \ +Q_DECL_CONSTEXPR inline QFlags operator|(Flags::enum_type f1, QFlags f2) noexcept \ { return f2 | f1; } Q_DECLARE_INCOMPATIBLE_FLAGS(Flags) diff --git a/src/corelib/global/qfloat16.cpp b/src/corelib/global/qfloat16.cpp index 110d7c4d7c..680268c59b 100644 --- a/src/corelib/global/qfloat16.cpp +++ b/src/corelib/global/qfloat16.cpp @@ -132,8 +132,8 @@ extern "C" { # define f16cextern extern #endif -f16cextern void qFloatToFloat16_fast(quint16 *out, const float *in, qsizetype len) Q_DECL_NOTHROW; -f16cextern void qFloatFromFloat16_fast(float *out, const quint16 *in, qsizetype len) Q_DECL_NOTHROW; +f16cextern void qFloatToFloat16_fast(quint16 *out, const float *in, qsizetype len) noexcept; +f16cextern void qFloatFromFloat16_fast(float *out, const quint16 *in, qsizetype len) noexcept; #undef f16cextern } @@ -144,7 +144,7 @@ static inline bool hasFastF16() return true; } -static void qFloatToFloat16_fast(quint16 *out, const float *in, qsizetype len) Q_DECL_NOTHROW +static void qFloatToFloat16_fast(quint16 *out, const float *in, qsizetype len) noexcept { __fp16 *out_f16 = reinterpret_cast<__fp16 *>(out); qsizetype i = 0; @@ -154,7 +154,7 @@ static void qFloatToFloat16_fast(quint16 *out, const float *in, qsizetype len) Q out_f16[i] = __fp16(in[i]); } -static void qFloatFromFloat16_fast(float *out, const quint16 *in, qsizetype len) Q_DECL_NOTHROW +static void qFloatFromFloat16_fast(float *out, const quint16 *in, qsizetype len) noexcept { const __fp16 *in_f16 = reinterpret_cast(in); qsizetype i = 0; @@ -169,12 +169,12 @@ static inline bool hasFastF16() return false; } -static void qFloatToFloat16_fast(quint16 *, const float *, qsizetype) Q_DECL_NOTHROW +static void qFloatToFloat16_fast(quint16 *, const float *, qsizetype) noexcept { Q_UNREACHABLE(); } -static void qFloatFromFloat16_fast(float *, const quint16 *, qsizetype) Q_DECL_NOTHROW +static void qFloatFromFloat16_fast(float *, const quint16 *, qsizetype) noexcept { Q_UNREACHABLE(); } @@ -186,7 +186,7 @@ static void qFloatFromFloat16_fast(float *, const quint16 *, qsizetype) Q_DECL_N Converts \a len floats from \a in to qfloat16 and stores them in \a out. Both \a in and \a out must have \a len allocated entries. */ -Q_CORE_EXPORT void qFloatToFloat16(qfloat16 *out, const float *in, qsizetype len) Q_DECL_NOTHROW +Q_CORE_EXPORT void qFloatToFloat16(qfloat16 *out, const float *in, qsizetype len) noexcept { if (hasFastF16()) return qFloatToFloat16_fast(reinterpret_cast(out), in, len); @@ -202,7 +202,7 @@ Q_CORE_EXPORT void qFloatToFloat16(qfloat16 *out, const float *in, qsizetype len Converts \a len qfloat16 from \a in to floats and stores them in \a out. Both \a in and \a out must have \a len allocated entries. */ -Q_CORE_EXPORT void qFloatFromFloat16(float *out, const qfloat16 *in, qsizetype len) Q_DECL_NOTHROW +Q_CORE_EXPORT void qFloatFromFloat16(float *out, const qfloat16 *in, qsizetype len) noexcept { if (hasFastF16()) return qFloatFromFloat16_fast(out, reinterpret_cast(in), len); diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h index e823d0298b..243aea98be 100644 --- a/src/corelib/global/qfloat16.h +++ b/src/corelib/global/qfloat16.h @@ -67,14 +67,14 @@ QT_BEGIN_NAMESPACE class qfloat16 { public: - constexpr inline qfloat16() Q_DECL_NOTHROW : b16(0) {} - inline qfloat16(float f) Q_DECL_NOTHROW; - inline operator float() const Q_DECL_NOTHROW; + constexpr inline qfloat16() noexcept : b16(0) {} + inline qfloat16(float f) noexcept; + inline operator float() const noexcept; // Support for qIs{Inf,NaN,Finite}: - bool isInf() const Q_DECL_NOTHROW { return ((b16 >> 8) & 0x7e) == 0x7c; } - bool isNaN() const Q_DECL_NOTHROW { return ((b16 >> 8) & 0x7e) == 0x7e; } - bool isFinite() const Q_DECL_NOTHROW { return ((b16 >> 8) & 0x7c) != 0x7c; } + bool isInf() const noexcept { return ((b16 >> 8) & 0x7e) == 0x7c; } + bool isNaN() const noexcept { return ((b16 >> 8) & 0x7e) == 0x7e; } + bool isFinite() const noexcept { return ((b16 >> 8) & 0x7c) != 0x7c; } private: quint16 b16; @@ -84,29 +84,29 @@ private: Q_CORE_EXPORT static const quint32 basetable[]; Q_CORE_EXPORT static const quint32 shifttable[]; - friend bool qIsNull(qfloat16 f) Q_DECL_NOTHROW; - friend qfloat16 operator-(qfloat16 a) Q_DECL_NOTHROW; + friend bool qIsNull(qfloat16 f) noexcept; + friend qfloat16 operator-(qfloat16 a) noexcept; }; Q_DECLARE_TYPEINFO(qfloat16, Q_PRIMITIVE_TYPE); -Q_CORE_EXPORT void qFloatToFloat16(qfloat16 *, const float *, qsizetype length) Q_DECL_NOTHROW; -Q_CORE_EXPORT void qFloatFromFloat16(float *, const qfloat16 *, qsizetype length) Q_DECL_NOTHROW; +Q_CORE_EXPORT void qFloatToFloat16(qfloat16 *, const float *, qsizetype length) noexcept; +Q_CORE_EXPORT void qFloatFromFloat16(float *, const qfloat16 *, qsizetype length) noexcept; // Complement qnumeric.h: -Q_REQUIRED_RESULT inline bool qIsInf(qfloat16 f) Q_DECL_NOTHROW { return f.isInf(); } -Q_REQUIRED_RESULT inline bool qIsNaN(qfloat16 f) Q_DECL_NOTHROW { return f.isNaN(); } -Q_REQUIRED_RESULT inline bool qIsFinite(qfloat16 f) Q_DECL_NOTHROW { return f.isFinite(); } +Q_REQUIRED_RESULT inline bool qIsInf(qfloat16 f) noexcept { return f.isInf(); } +Q_REQUIRED_RESULT inline bool qIsNaN(qfloat16 f) noexcept { return f.isNaN(); } +Q_REQUIRED_RESULT inline bool qIsFinite(qfloat16 f) noexcept { return f.isFinite(); } // Q_REQUIRED_RESULT quint32 qFloatDistance(qfloat16 a, qfloat16 b); // The remainder of these utility functions complement qglobal.h -Q_REQUIRED_RESULT inline int qRound(qfloat16 d) Q_DECL_NOTHROW +Q_REQUIRED_RESULT inline int qRound(qfloat16 d) noexcept { return qRound(static_cast(d)); } -Q_REQUIRED_RESULT inline qint64 qRound64(qfloat16 d) Q_DECL_NOTHROW +Q_REQUIRED_RESULT inline qint64 qRound64(qfloat16 d) noexcept { return qRound64(static_cast(d)); } -Q_REQUIRED_RESULT inline bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) Q_DECL_NOTHROW +Q_REQUIRED_RESULT inline bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept { float f1 = static_cast(p1); float f2 = static_cast(p2); @@ -119,19 +119,19 @@ Q_REQUIRED_RESULT inline bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) Q_DECL_NOT return (qAbs(f1 - f2) * 102.5f <= qMin(qAbs(f1), qAbs(f2))); } -Q_REQUIRED_RESULT inline bool qIsNull(qfloat16 f) Q_DECL_NOTHROW +Q_REQUIRED_RESULT inline bool qIsNull(qfloat16 f) noexcept { return (f.b16 & static_cast(0x7fff)) == 0; } -inline int qIntCast(qfloat16 f) Q_DECL_NOTHROW +inline int qIntCast(qfloat16 f) noexcept { return int(static_cast(f)); } #ifndef Q_QDOC QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wc99-extensions") QT_WARNING_DISABLE_GCC("-Wold-style-cast") -inline qfloat16::qfloat16(float f) Q_DECL_NOTHROW +inline qfloat16::qfloat16(float f) noexcept { #if defined(QT_COMPILER_SUPPORTS_F16C) && defined(__F16C__) __m128 packsingle = _mm_set_ss(f); @@ -149,7 +149,7 @@ inline qfloat16::qfloat16(float f) Q_DECL_NOTHROW } QT_WARNING_POP -inline qfloat16::operator float() const Q_DECL_NOTHROW +inline qfloat16::operator float() const noexcept { #if defined(QT_COMPILER_SUPPORTS_F16C) && defined(__F16C__) __m128i packhalf = _mm_cvtsi32_si128(b16); @@ -169,23 +169,23 @@ inline qfloat16::operator float() const Q_DECL_NOTHROW } #endif -inline qfloat16 operator-(qfloat16 a) Q_DECL_NOTHROW +inline qfloat16 operator-(qfloat16 a) noexcept { qfloat16 f; f.b16 = a.b16 ^ quint16(0x8000); return f; } -inline qfloat16 operator+(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return qfloat16(static_cast(a) + static_cast(b)); } -inline qfloat16 operator-(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return qfloat16(static_cast(a) - static_cast(b)); } -inline qfloat16 operator*(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return qfloat16(static_cast(a) * static_cast(b)); } -inline qfloat16 operator/(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return qfloat16(static_cast(a) / static_cast(b)); } +inline qfloat16 operator+(qfloat16 a, qfloat16 b) noexcept { return qfloat16(static_cast(a) + static_cast(b)); } +inline qfloat16 operator-(qfloat16 a, qfloat16 b) noexcept { return qfloat16(static_cast(a) - static_cast(b)); } +inline qfloat16 operator*(qfloat16 a, qfloat16 b) noexcept { return qfloat16(static_cast(a) * static_cast(b)); } +inline qfloat16 operator/(qfloat16 a, qfloat16 b) noexcept { return qfloat16(static_cast(a) / static_cast(b)); } #define QF16_MAKE_ARITH_OP_FP(FP, OP) \ - inline FP operator OP(qfloat16 lhs, FP rhs) Q_DECL_NOTHROW { return static_cast(lhs) OP rhs; } \ - inline FP operator OP(FP lhs, qfloat16 rhs) Q_DECL_NOTHROW { return lhs OP static_cast(rhs); } + inline FP operator OP(qfloat16 lhs, FP rhs) noexcept { return static_cast(lhs) OP rhs; } \ + inline FP operator OP(FP lhs, qfloat16 rhs) noexcept { return lhs OP static_cast(rhs); } #define QF16_MAKE_ARITH_OP_EQ_FP(FP, OP_EQ, OP) \ - inline qfloat16& operator OP_EQ(qfloat16& lhs, FP rhs) Q_DECL_NOTHROW \ + inline qfloat16& operator OP_EQ(qfloat16& lhs, FP rhs) noexcept \ { lhs = qfloat16(float(static_cast(lhs) OP rhs)); return lhs; } #define QF16_MAKE_ARITH_OP(FP) \ QF16_MAKE_ARITH_OP_FP(FP, +) \ @@ -203,8 +203,8 @@ QF16_MAKE_ARITH_OP(float) #undef QF16_MAKE_ARITH_OP_FP #define QF16_MAKE_ARITH_OP_INT(OP) \ - inline double operator OP(qfloat16 lhs, int rhs) Q_DECL_NOTHROW { return static_cast(lhs) OP rhs; } \ - inline double operator OP(int lhs, qfloat16 rhs) Q_DECL_NOTHROW { return lhs OP static_cast(rhs); } + inline double operator OP(qfloat16 lhs, int rhs) noexcept { return static_cast(lhs) OP rhs; } \ + inline double operator OP(int lhs, qfloat16 rhs) noexcept { return lhs OP static_cast(rhs); } QF16_MAKE_ARITH_OP_INT(+) QF16_MAKE_ARITH_OP_INT(-) QF16_MAKE_ARITH_OP_INT(*) @@ -215,16 +215,16 @@ QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wfloat-equal") QT_WARNING_DISABLE_GCC("-Wfloat-equal") -inline bool operator>(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return static_cast(a) > static_cast(b); } -inline bool operator<(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return static_cast(a) < static_cast(b); } -inline bool operator>=(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return static_cast(a) >= static_cast(b); } -inline bool operator<=(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return static_cast(a) <= static_cast(b); } -inline bool operator==(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return static_cast(a) == static_cast(b); } -inline bool operator!=(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return static_cast(a) != static_cast(b); } +inline bool operator>(qfloat16 a, qfloat16 b) noexcept { return static_cast(a) > static_cast(b); } +inline bool operator<(qfloat16 a, qfloat16 b) noexcept { return static_cast(a) < static_cast(b); } +inline bool operator>=(qfloat16 a, qfloat16 b) noexcept { return static_cast(a) >= static_cast(b); } +inline bool operator<=(qfloat16 a, qfloat16 b) noexcept { return static_cast(a) <= static_cast(b); } +inline bool operator==(qfloat16 a, qfloat16 b) noexcept { return static_cast(a) == static_cast(b); } +inline bool operator!=(qfloat16 a, qfloat16 b) noexcept { return static_cast(a) != static_cast(b); } #define QF16_MAKE_BOOL_OP_FP(FP, OP) \ - inline bool operator OP(qfloat16 lhs, FP rhs) Q_DECL_NOTHROW { return static_cast(lhs) OP rhs; } \ - inline bool operator OP(FP lhs, qfloat16 rhs) Q_DECL_NOTHROW { return lhs OP static_cast(rhs); } + inline bool operator OP(qfloat16 lhs, FP rhs) noexcept { return static_cast(lhs) OP rhs; } \ + inline bool operator OP(FP lhs, qfloat16 rhs) noexcept { return lhs OP static_cast(rhs); } #define QF16_MAKE_BOOL_OP(FP) \ QF16_MAKE_BOOL_OP_FP(FP, <) \ QF16_MAKE_BOOL_OP_FP(FP, >) \ @@ -239,8 +239,8 @@ QF16_MAKE_BOOL_OP(float) #undef QF16_MAKE_BOOL_OP_FP #define QF16_MAKE_BOOL_OP_INT(OP) \ - inline bool operator OP(qfloat16 a, int b) Q_DECL_NOTHROW { return static_cast(a) OP b; } \ - inline bool operator OP(int a, qfloat16 b) Q_DECL_NOTHROW { return a OP static_cast(b); } + inline bool operator OP(qfloat16 a, int b) noexcept { return static_cast(a) OP b; } \ + inline bool operator OP(int a, qfloat16 b) noexcept { return a OP static_cast(b); } QF16_MAKE_BOOL_OP_INT(>) QF16_MAKE_BOOL_OP_INT(<) QF16_MAKE_BOOL_OP_INT(>=) @@ -254,7 +254,7 @@ QT_WARNING_POP /*! \internal */ -Q_REQUIRED_RESULT inline bool qFuzzyIsNull(qfloat16 f) Q_DECL_NOTHROW +Q_REQUIRED_RESULT inline bool qFuzzyIsNull(qfloat16 f) noexcept { return qAbs(static_cast(f)) <= 0.001f; } diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 7879109930..d95064af27 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1147,12 +1147,12 @@ Q_STATIC_ASSERT((std::is_same::value)); \sa QT_VERSION_STR, QLibraryInfo::version() */ -const char *qVersion() Q_DECL_NOTHROW +const char *qVersion() noexcept { return QT_VERSION_STR; } -bool qSharedBuild() Q_DECL_NOTHROW +bool qSharedBuild() noexcept { #ifdef QT_SHARED return true; @@ -3206,7 +3206,7 @@ QByteArray QSysInfo::bootUniqueId() The Q_CHECK_PTR macro calls this function if an allocation check fails. */ -void qt_check_pointer(const char *n, int l) Q_DECL_NOTHROW +void qt_check_pointer(const char *n, int l) noexcept { // make separate printing calls so that the first one may flush; // the second one could want to allocate memory (fputs prints a @@ -3233,7 +3233,7 @@ void qBadAlloc() Allows you to call std::terminate() without including . Called internally from QT_TERMINATE_ON_EXCEPTION */ -Q_NORETURN void qTerminate() Q_DECL_NOTHROW +Q_NORETURN void qTerminate() noexcept { std::terminate(); } @@ -3242,7 +3242,7 @@ Q_NORETURN void qTerminate() Q_DECL_NOTHROW /* The Q_ASSERT macro calls this function when the test fails. */ -void qt_assert(const char *assertion, const char *file, int line) Q_DECL_NOTHROW +void qt_assert(const char *assertion, const char *file, int line) noexcept { QMessageLogger(file, line, nullptr).fatal("ASSERT: \"%s\" in file %s, line %d", assertion, file, line); } @@ -3250,7 +3250,7 @@ void qt_assert(const char *assertion, const char *file, int line) Q_DECL_NOTHROW /* The Q_ASSERT_X macro calls this function when the test fails. */ -void qt_assert_x(const char *where, const char *what, const char *file, int line) Q_DECL_NOTHROW +void qt_assert_x(const char *where, const char *what, const char *file, int line) noexcept { QMessageLogger(file, line, nullptr).fatal("ASSERT failure in %s: \"%s\", file %s, line %d", where, what, file, line); } @@ -3457,7 +3457,7 @@ QString qEnvironmentVariable(const char *varName) \sa qgetenv(), qEnvironmentVariable(), qEnvironmentVariableIsSet() */ -bool qEnvironmentVariableIsEmpty(const char *varName) Q_DECL_NOEXCEPT +bool qEnvironmentVariableIsEmpty(const char *varName) noexcept { QMutexLocker locker(&environmentMutex); #ifdef Q_CC_MSVC @@ -3492,7 +3492,7 @@ bool qEnvironmentVariableIsEmpty(const char *varName) Q_DECL_NOEXCEPT \sa qgetenv(), qEnvironmentVariable(), qEnvironmentVariableIsSet() */ -int qEnvironmentVariableIntValue(const char *varName, bool *ok) Q_DECL_NOEXCEPT +int qEnvironmentVariableIntValue(const char *varName, bool *ok) noexcept { static const int NumBinaryDigitsPerOctalDigit = 3; static const int MaxDigitsForOctalInt = @@ -3561,7 +3561,7 @@ int qEnvironmentVariableIntValue(const char *varName, bool *ok) Q_DECL_NOEXCEPT \sa qgetenv(), qEnvironmentVariable(), qEnvironmentVariableIsEmpty() */ -bool qEnvironmentVariableIsSet(const char *varName) Q_DECL_NOEXCEPT +bool qEnvironmentVariableIsSet(const char *varName) noexcept { QMutexLocker locker(&environmentMutex); #ifdef Q_CC_MSVC diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 223ebbcabe..f62d078035 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -411,7 +411,7 @@ typedef double qreal; #if !defined(QT_NAMESPACE) && defined(__cplusplus) && !defined(Q_QDOC) extern "C" #endif -Q_CORE_EXPORT Q_DECL_CONST_FUNCTION const char *qVersion(void) Q_DECL_NOTHROW; +Q_CORE_EXPORT Q_DECL_CONST_FUNCTION const char *qVersion(void) Q_DECL_NOEXCEPT; #if defined(__cplusplus) @@ -730,7 +730,7 @@ inline void qt_noop(void) {} # define QT_CATCH(A) catch (A) # define QT_THROW(A) throw A # define QT_RETHROW throw -Q_NORETURN Q_DECL_COLD_FUNCTION Q_CORE_EXPORT void qTerminate() Q_DECL_NOTHROW; +Q_NORETURN Q_DECL_COLD_FUNCTION Q_CORE_EXPORT void qTerminate() noexcept; # ifdef Q_COMPILER_NOEXCEPT # define QT_TERMINATE_ON_EXCEPTION(expr) do { expr; } while (false) # else @@ -738,7 +738,7 @@ Q_NORETURN Q_DECL_COLD_FUNCTION Q_CORE_EXPORT void qTerminate() Q_DECL_NOTHROW; # endif #endif -Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qSharedBuild() Q_DECL_NOTHROW; +Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qSharedBuild() noexcept; #ifndef Q_OUTOFLINE_TEMPLATE # define Q_OUTOFLINE_TEMPLATE @@ -781,7 +781,7 @@ Q_CORE_EXPORT QString qt_error_string(int errorCode = -1); Q_NORETURN #endif Q_DECL_COLD_FUNCTION -Q_CORE_EXPORT void qt_assert(const char *assertion, const char *file, int line) Q_DECL_NOTHROW; +Q_CORE_EXPORT void qt_assert(const char *assertion, const char *file, int line) noexcept; #if !defined(Q_ASSERT) # if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) @@ -799,7 +799,7 @@ Q_CORE_EXPORT void qt_assert(const char *assertion, const char *file, int line) Q_NORETURN #endif Q_DECL_COLD_FUNCTION -Q_CORE_EXPORT void qt_assert_x(const char *where, const char *what, const char *file, int line) Q_DECL_NOTHROW; +Q_CORE_EXPORT void qt_assert_x(const char *where, const char *what, const char *file, int line) noexcept; #if !defined(Q_ASSERT_X) # if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) @@ -809,7 +809,7 @@ Q_CORE_EXPORT void qt_assert_x(const char *where, const char *what, const char * # endif #endif -Q_NORETURN Q_CORE_EXPORT void qt_check_pointer(const char *, int) Q_DECL_NOTHROW; +Q_NORETURN Q_CORE_EXPORT void qt_check_pointer(const char *, int) noexcept; Q_DECL_COLD_FUNCTION Q_CORE_EXPORT void qBadAlloc(); @@ -968,7 +968,7 @@ QT_WARNING_DISABLE_MSVC(4530) /* C++ exception handler used, but unwind semantic // this adds const to non-const objects (like std::as_const) template -Q_DECL_CONSTEXPR typename std::add_const::type &qAsConst(T &t) Q_DECL_NOTHROW { return t; } +Q_DECL_CONSTEXPR typename std::add_const::type &qAsConst(T &t) noexcept { return t; } // prevent rvalue arguments: template void qAsConst(const T &&) Q_DECL_EQ_DELETE; @@ -1130,11 +1130,11 @@ template struct QNonConstOverload { template - Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...)) const Q_DECL_NOTHROW -> decltype(ptr) + Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...)) const noexcept -> decltype(ptr) { return ptr; } template - static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...)) Q_DECL_NOTHROW -> decltype(ptr) + static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...)) noexcept -> decltype(ptr) { return ptr; } }; @@ -1142,11 +1142,11 @@ template struct QConstOverload { template - Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...) const) const Q_DECL_NOTHROW -> decltype(ptr) + Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...) const) const noexcept -> decltype(ptr) { return ptr; } template - static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...) const) Q_DECL_NOTHROW -> decltype(ptr) + static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...) const) noexcept -> decltype(ptr) { return ptr; } }; @@ -1159,11 +1159,11 @@ struct QOverload : QConstOverload, QNonConstOverload using QNonConstOverload::operator(); template - Q_DECL_CONSTEXPR auto operator()(R (*ptr)(Args...)) const Q_DECL_NOTHROW -> decltype(ptr) + Q_DECL_CONSTEXPR auto operator()(R (*ptr)(Args...)) const noexcept -> decltype(ptr) { return ptr; } template - static Q_DECL_CONSTEXPR auto of(R (*ptr)(Args...)) Q_DECL_NOTHROW -> decltype(ptr) + static Q_DECL_CONSTEXPR auto of(R (*ptr)(Args...)) noexcept -> decltype(ptr) { return ptr; } }; @@ -1184,9 +1184,9 @@ Q_CORE_EXPORT QString qEnvironmentVariable(const char *varName, const QString &d Q_CORE_EXPORT bool qputenv(const char *varName, const QByteArray& value); Q_CORE_EXPORT bool qunsetenv(const char *varName); -Q_CORE_EXPORT bool qEnvironmentVariableIsEmpty(const char *varName) Q_DECL_NOEXCEPT; -Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) Q_DECL_NOEXCEPT; -Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) Q_DECL_NOEXCEPT; +Q_CORE_EXPORT bool qEnvironmentVariableIsEmpty(const char *varName) noexcept; +Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) noexcept; +Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) noexcept; inline int qIntCast(double f) { return int(f); } inline int qIntCast(float f) { return int(f); } diff --git a/src/corelib/global/qglobalstatic.h b/src/corelib/global/qglobalstatic.h index 93d71cee57..6d27e3a984 100644 --- a/src/corelib/global/qglobalstatic.h +++ b/src/corelib/global/qglobalstatic.h @@ -79,7 +79,7 @@ enum GuardValues { Q_GLOBAL_STATIC_INTERNAL_DECORATION Type *innerFunction() \ { \ struct HolderBase { \ - ~HolderBase() Q_DECL_NOTHROW \ + ~HolderBase() noexcept \ { if (guard.load() == QtGlobalStatic::Initialized) \ guard.store(QtGlobalStatic::Destroyed); } \ }; \ diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 88cc5b0b01..c3eb469767 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -350,7 +350,7 @@ QLibraryInfo::buildDate() \since 5.3 */ -const char *QLibraryInfo::build() Q_DECL_NOTHROW +const char *QLibraryInfo::build() noexcept { return QT_BUILD_STR; } @@ -377,7 +377,7 @@ QLibraryInfo::isDebugBuild() \sa qVersion() */ -QVersionNumber QLibraryInfo::version() Q_DECL_NOTHROW +QVersionNumber QLibraryInfo::version() noexcept { return QVersionNumber(QT_VERSION_MAJOR, QT_VERSION_MINOR, QT_VERSION_PATCH); } diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h index 80fc5bd4fc..20fd3897f7 100644 --- a/src/corelib/global/qlibraryinfo.h +++ b/src/corelib/global/qlibraryinfo.h @@ -62,12 +62,12 @@ public: #endif // QT_DEPRECATED_SINCE(5, 5) #endif // datestring - static const char * build() Q_DECL_NOTHROW; + static const char * build() noexcept; static bool isDebugBuild(); #ifndef QT_BOOTSTRAPPED - static QVersionNumber version() Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; + static QVersionNumber version() noexcept Q_DECL_CONST_FUNCTION; #endif enum LibraryLocation diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index b2093101fa..a4d86e393b 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -346,7 +346,7 @@ using namespace QtPrivate; */ #if defined(Q_CC_MSVC) && defined(QT_DEBUG) && defined(_DEBUG) && defined(_CRT_ERROR) -static inline void convert_to_wchar_t_elided(wchar_t *d, size_t space, const char *s) Q_DECL_NOEXCEPT +static inline void convert_to_wchar_t_elided(wchar_t *d, size_t space, const char *s) noexcept { size_t len = qstrlen(s); if (len + 1 > space) { @@ -529,7 +529,7 @@ QDebug QMessageLogger::debug(QMessageLogger::CategoryFunction catFunc) const \sa QNoDebug, qDebug() */ -QNoDebug QMessageLogger::noDebug() const Q_DECL_NOTHROW +QNoDebug QMessageLogger::noDebug() const noexcept { return QNoDebug(); } @@ -875,7 +875,7 @@ QDebug QMessageLogger::critical(QMessageLogger::CategoryFunction catFunc) const \sa qFatal() */ -void QMessageLogger::fatal(const char *msg, ...) const Q_DECL_NOTHROW +void QMessageLogger::fatal(const char *msg, ...) const noexcept { QString message; diff --git a/src/corelib/global/qlogging.h b/src/corelib/global/qlogging.h index dded09999b..8f39780112 100644 --- a/src/corelib/global/qlogging.h +++ b/src/corelib/global/qlogging.h @@ -121,7 +121,7 @@ public: Q_NORETURN #endif Q_DECL_COLD_FUNCTION - void fatal(const char *msg, ...) const Q_DECL_NOTHROW Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); + void fatal(const char *msg, ...) const noexcept Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); #ifndef QT_NO_DEBUG_STREAM QDebug debug() const; @@ -137,7 +137,7 @@ public: QDebug critical(const QLoggingCategory &cat) const; QDebug critical(CategoryFunction catFunc) const; - QNoDebug noDebug() const Q_DECL_NOTHROW; + QNoDebug noDebug() const noexcept; #endif // QT_NO_DEBUG_STREAM private: diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 6488426e64..610d7e4db7 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -50,10 +50,10 @@ QT_BEGIN_NAMESPACE #if !defined(Q_QDOC) && !defined(Q_MOC_RUN) struct QMetaObject; -const QMetaObject *qt_getQtMetaObject() Q_DECL_NOEXCEPT; // defined in qobject.h (which can't be included here) +const QMetaObject *qt_getQtMetaObject() noexcept; // defined in qobject.h (which can't be included here) #define QT_Q_ENUM(ENUM) \ - inline const QMetaObject *qt_getEnumMetaObject(ENUM) Q_DECL_NOEXCEPT { return qt_getQtMetaObject(); } \ - inline Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) Q_DECL_NOEXCEPT { return #ENUM; } + inline const QMetaObject *qt_getEnumMetaObject(ENUM) noexcept { return qt_getQtMetaObject(); } \ + inline Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) noexcept { return #ENUM; } #define QT_Q_FLAG(ENUM) QT_Q_ENUM(ENUM) #else #define QT_Q_ENUM Q_ENUM diff --git a/src/corelib/global/qnumeric_p.h b/src/corelib/global/qnumeric_p.h index 56e670c477..21f9cfbef0 100644 --- a/src/corelib/global/qnumeric_p.h +++ b/src/corelib/global/qnumeric_p.h @@ -126,7 +126,7 @@ Q_DECL_CONST_FUNCTION static inline int fpclassify(float f) { return std::fpclas #endif } -Q_DECL_CONSTEXPR Q_DECL_CONST_FUNCTION static inline double qt_inf() Q_DECL_NOEXCEPT +Q_DECL_CONSTEXPR Q_DECL_CONST_FUNCTION static inline double qt_inf() noexcept { Q_STATIC_ASSERT_X(std::numeric_limits::has_infinity, "platform has no definition for infinity for type double"); @@ -134,7 +134,7 @@ Q_DECL_CONSTEXPR Q_DECL_CONST_FUNCTION static inline double qt_inf() Q_DECL_NOEX } // Signaling NaN -Q_DECL_CONSTEXPR Q_DECL_CONST_FUNCTION static inline double qt_snan() Q_DECL_NOEXCEPT +Q_DECL_CONSTEXPR Q_DECL_CONST_FUNCTION static inline double qt_snan() noexcept { Q_STATIC_ASSERT_X(std::numeric_limits::has_signaling_NaN, "platform has no definition for signaling NaN for type double"); @@ -142,7 +142,7 @@ Q_DECL_CONSTEXPR Q_DECL_CONST_FUNCTION static inline double qt_snan() Q_DECL_NOE } // Quiet NaN -Q_DECL_CONSTEXPR Q_DECL_CONST_FUNCTION static inline double qt_qnan() Q_DECL_NOEXCEPT +Q_DECL_CONSTEXPR Q_DECL_CONST_FUNCTION static inline double qt_qnan() noexcept { Q_STATIC_ASSERT_X(std::numeric_limits::has_quiet_NaN, "platform has no definition for quiet NaN for type double"); diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp index 90df8653a7..fbc4222763 100644 --- a/src/corelib/global/qrandom.cpp +++ b/src/corelib/global/qrandom.cpp @@ -91,7 +91,7 @@ DECLSPEC_IMPORT BOOLEAN WINAPI SystemFunction036(PVOID RandomBuffer, ULONG Rando QT_BEGIN_NAMESPACE #if defined(Q_PROCESSOR_X86) && QT_COMPILER_SUPPORTS_HERE(RDRND) -static qsizetype qt_random_cpu(void *buffer, qsizetype count) Q_DECL_NOTHROW; +static qsizetype qt_random_cpu(void *buffer, qsizetype count) noexcept; # ifdef Q_PROCESSOR_X86_64 # define _rdrandXX_step _rdrand64_step @@ -99,7 +99,7 @@ static qsizetype qt_random_cpu(void *buffer, qsizetype count) Q_DECL_NOTHROW; # define _rdrandXX_step _rdrand32_step # endif -static QT_FUNCTION_TARGET(RDRND) qsizetype qt_random_cpu(void *buffer, qsizetype count) Q_DECL_NOTHROW +static QT_FUNCTION_TARGET(RDRND) qsizetype qt_random_cpu(void *buffer, qsizetype count) noexcept { unsigned *ptr = reinterpret_cast(buffer); unsigned *end = ptr + count; @@ -134,7 +134,7 @@ enum { struct QRandomGenerator::SystemGenerator { #if QT_CONFIG(getentropy) - static qsizetype fillBuffer(void *buffer, qsizetype count) Q_DECL_NOTHROW + static qsizetype fillBuffer(void *buffer, qsizetype count) noexcept { // getentropy can read at most 256 bytes, so break the reading qsizetype read = 0; @@ -204,13 +204,13 @@ struct QRandomGenerator::SystemGenerator } #elif defined(Q_OS_WIN) && !defined(Q_OS_WINRT) - qsizetype fillBuffer(void *buffer, qsizetype count) Q_DECL_NOTHROW + qsizetype fillBuffer(void *buffer, qsizetype count) noexcept { auto RtlGenRandom = SystemFunction036; return RtlGenRandom(buffer, ULONG(count)) ? count: 0; } #elif defined(Q_OS_WINRT) - qsizetype fillBuffer(void *, qsizetype) Q_DECL_NOTHROW + qsizetype fillBuffer(void *, qsizetype) noexcept { // always use the fallback return 0; @@ -242,7 +242,7 @@ struct QRandomGenerator::SystemGenerator #if defined(Q_OS_WIN) static void fallback_update_seed(unsigned) {} -static void fallback_fill(quint32 *ptr, qsizetype left) Q_DECL_NOTHROW +static void fallback_fill(quint32 *ptr, qsizetype left) noexcept { // on Windows, rand_s is a high-quality random number generator // and it requires no seeding @@ -254,14 +254,14 @@ static void fallback_fill(quint32 *ptr, qsizetype left) Q_DECL_NOTHROW } #elif QT_CONFIG(getentropy) static void fallback_update_seed(unsigned) {} -static void fallback_fill(quint32 *, qsizetype) Q_DECL_NOTHROW +static void fallback_fill(quint32 *, qsizetype) noexcept { // no fallback necessary, getentropy cannot fail under normal circumstances Q_UNREACHABLE(); } #elif defined(Q_OS_BSD4) && !defined(__GLIBC__) static void fallback_update_seed(unsigned) {} -static void fallback_fill(quint32 *ptr, qsizetype left) Q_DECL_NOTHROW +static void fallback_fill(quint32 *ptr, qsizetype left) noexcept { // BSDs have arc4random(4) and these work even in chroot(2) arc4random_buf(ptr, left * sizeof(*ptr)); @@ -280,7 +280,7 @@ Q_NEVER_INLINE #ifdef Q_CC_GNU __attribute__((cold)) // this function is pretty big, so optimize for size #endif -static void fallback_fill(quint32 *ptr, qsizetype left) Q_DECL_NOTHROW +static void fallback_fill(quint32 *ptr, qsizetype left) noexcept { quint32 scratch[12]; // see element count below quint32 *end = scratch; @@ -1167,7 +1167,7 @@ QRandomGenerator &QRandomGenerator::operator=(const QRandomGenerator &other) return *this; } -QRandomGenerator::QRandomGenerator(std::seed_seq &sseq) Q_DECL_NOTHROW +QRandomGenerator::QRandomGenerator(std::seed_seq &sseq) noexcept : type(MersenneTwister) { Q_ASSERT(this != system()); diff --git a/src/corelib/global/qrandom.h b/src/corelib/global/qrandom.h index 46d3e0e152..2f72528266 100644 --- a/src/corelib/global/qrandom.h +++ b/src/corelib/global/qrandom.h @@ -68,7 +68,7 @@ public: QRandomGenerator(const quint32 *seedBuffer, qsizetype len) : QRandomGenerator(seedBuffer, seedBuffer + len) {} - Q_CORE_EXPORT QRandomGenerator(std::seed_seq &sseq) Q_DECL_NOTHROW; + Q_CORE_EXPORT QRandomGenerator(std::seed_seq &sseq) noexcept; Q_CORE_EXPORT QRandomGenerator(const quint32 *begin, const quint32 *end); // copy constructor & assignment operator (move unnecessary) @@ -165,7 +165,7 @@ public: typedef quint32 result_type; result_type operator()() { return generate(); } void seed(quint32 s = 1) { *this = { s }; } - void seed(std::seed_seq &sseq) Q_DECL_NOTHROW { *this = { sseq }; } + void seed(std::seed_seq &sseq) noexcept { *this = { sseq }; } Q_CORE_EXPORT void discard(unsigned long long z); static Q_DECL_CONSTEXPR result_type min() { return std::numeric_limits::min(); } static Q_DECL_CONSTEXPR result_type max() { return std::numeric_limits::max(); } @@ -228,7 +228,7 @@ public: QRandomGenerator64(const quint32 *seedBuffer, qsizetype len) : QRandomGenerator(seedBuffer, len) {} - QRandomGenerator64(std::seed_seq &sseq) Q_DECL_NOTHROW + QRandomGenerator64(std::seed_seq &sseq) noexcept : QRandomGenerator(sseq) {} QRandomGenerator64(const quint32 *begin, const quint32 *end) diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index 91fde75fa5..ea2d57370d 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -116,7 +116,7 @@ public: inline QDebug(const QDebug &o):stream(o.stream) { ++stream->ref; } inline QDebug &operator=(const QDebug &other); ~QDebug(); - inline void swap(QDebug &other) Q_DECL_NOTHROW { qSwap(stream, other.stream); } + inline void swap(QDebug &other) noexcept { qSwap(stream, other.stream); } QDebug &resetFormat(); diff --git a/src/corelib/io/qdir.h b/src/corelib/io/qdir.h index 9abb833ab1..547ac163c7 100644 --- a/src/corelib/io/qdir.h +++ b/src/corelib/io/qdir.h @@ -110,10 +110,10 @@ public: QDir &operator=(const QString &path); #endif #ifdef Q_COMPILER_RVALUE_REFS - QDir &operator=(QDir &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QDir &operator=(QDir &&other) noexcept { swap(other); return *this; } #endif - void swap(QDir &other) Q_DECL_NOTHROW + void swap(QDir &other) noexcept { qSwap(d_ptr, other.d_ptr); } void setPath(const QString &path); @@ -190,7 +190,7 @@ public: static QFileInfoList drives(); - Q_DECL_CONSTEXPR static inline QChar listSeparator() Q_DECL_NOTHROW + Q_DECL_CONSTEXPR static inline QChar listSeparator() noexcept { #if defined(Q_OS_WIN) return QLatin1Char(';'); diff --git a/src/corelib/io/qfileinfo.h b/src/corelib/io/qfileinfo.h index baea18fab1..bd9e1d216f 100644 --- a/src/corelib/io/qfileinfo.h +++ b/src/corelib/io/qfileinfo.h @@ -68,10 +68,10 @@ public: QFileInfo &operator=(const QFileInfo &fileinfo); #ifdef Q_COMPILER_RVALUE_REFS - QFileInfo &operator=(QFileInfo &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QFileInfo &operator=(QFileInfo &&other) noexcept { swap(other); return *this; } #endif - void swap(QFileInfo &other) Q_DECL_NOTHROW + void swap(QFileInfo &other) noexcept { qSwap(d_ptr, other.d_ptr); } bool operator==(const QFileInfo &fileinfo) const; diff --git a/src/corelib/io/qprocess.h b/src/corelib/io/qprocess.h index a2e3c01f7c..83b7138ff9 100644 --- a/src/corelib/io/qprocess.h +++ b/src/corelib/io/qprocess.h @@ -73,11 +73,11 @@ public: QProcessEnvironment(const QProcessEnvironment &other); ~QProcessEnvironment(); #ifdef Q_COMPILER_RVALUE_REFS - QProcessEnvironment &operator=(QProcessEnvironment && other) Q_DECL_NOTHROW { swap(other); return *this; } + QProcessEnvironment &operator=(QProcessEnvironment && other) noexcept { swap(other); return *this; } #endif QProcessEnvironment &operator=(const QProcessEnvironment &other); - void swap(QProcessEnvironment &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QProcessEnvironment &other) noexcept { qSwap(d, other.d); } bool operator==(const QProcessEnvironment &other) const; inline bool operator!=(const QProcessEnvironment &other) const diff --git a/src/corelib/io/qstorageinfo.h b/src/corelib/io/qstorageinfo.h index 4ab7a353ef..addcbb2990 100644 --- a/src/corelib/io/qstorageinfo.h +++ b/src/corelib/io/qstorageinfo.h @@ -63,10 +63,10 @@ public: QStorageInfo &operator=(const QStorageInfo &other); #ifdef Q_COMPILER_RVALUE_REFS - QStorageInfo &operator=(QStorageInfo &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QStorageInfo &operator=(QStorageInfo &&other) noexcept { swap(other); return *this; } #endif - inline void swap(QStorageInfo &other) Q_DECL_NOTHROW + inline void swap(QStorageInfo &other) noexcept { qSwap(d, other.d); } void setPath(const QString &path); diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 6d82981fd6..b4090f710e 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -4159,7 +4159,7 @@ QList QUrl::fromStringList(const QStringList &urls, ParsingMode mode) \relates QHash \since 5.0 */ -uint qHash(const QUrl &url, uint seed) Q_DECL_NOTHROW +uint qHash(const QUrl &url, uint seed) noexcept { if (!url.d) return qHash(-1, seed); // the hash of an unset port (-1) diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h index 5062ef7905..70e549c1a9 100644 --- a/src/corelib/io/qurl.h +++ b/src/corelib/io/qurl.h @@ -119,7 +119,7 @@ class QTypeInfo > : public QTypeInfoMerger fromStringList(const QStringList &uris, ParsingMode mode = TolerantMode); static void setIdnWhitelist(const QStringList &); - friend Q_CORE_EXPORT uint qHash(const QUrl &url, uint seed) Q_DECL_NOTHROW; + friend Q_CORE_EXPORT uint qHash(const QUrl &url, uint seed) noexcept; private: QUrlPrivate *d; diff --git a/src/corelib/io/qurlquery.cpp b/src/corelib/io/qurlquery.cpp index 10c3f836c8..d76107abfd 100644 --- a/src/corelib/io/qurlquery.cpp +++ b/src/corelib/io/qurlquery.cpp @@ -434,7 +434,7 @@ bool QUrlQuery::operator ==(const QUrlQuery &other) const Returns the hash value for \a key, using \a seed to seed the calculation. */ -uint qHash(const QUrlQuery &key, uint seed) Q_DECL_NOTHROW +uint qHash(const QUrlQuery &key, uint seed) noexcept { if (const QUrlQueryPrivate *d = key.d) { QtPrivate::QHashCombine hash; diff --git a/src/corelib/io/qurlquery.h b/src/corelib/io/qurlquery.h index e3688aae2c..2a497dc8da 100644 --- a/src/corelib/io/qurlquery.h +++ b/src/corelib/io/qurlquery.h @@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE -Q_CORE_EXPORT uint qHash(const QUrlQuery &key, uint seed = 0) Q_DECL_NOTHROW; +Q_CORE_EXPORT uint qHash(const QUrlQuery &key, uint seed = 0) noexcept; class QUrlQueryPrivate; class Q_CORE_EXPORT QUrlQuery @@ -71,7 +71,7 @@ public: QUrlQuery(const QUrlQuery &other); QUrlQuery &operator=(const QUrlQuery &other); #ifdef Q_COMPILER_RVALUE_REFS - QUrlQuery &operator=(QUrlQuery &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QUrlQuery &operator=(QUrlQuery &&other) noexcept { swap(other); return *this; } #endif ~QUrlQuery(); @@ -79,7 +79,7 @@ public: bool operator!=(const QUrlQuery &other) const { return !(*this == other); } - void swap(QUrlQuery &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QUrlQuery &other) noexcept { qSwap(d, other.d); } bool isEmpty() const; bool isDetached() const; @@ -111,7 +111,7 @@ public: private: friend class QUrl; - friend Q_CORE_EXPORT uint qHash(const QUrlQuery &key, uint seed) Q_DECL_NOTHROW; + friend Q_CORE_EXPORT uint qHash(const QUrlQuery &key, uint seed) noexcept; QSharedDataPointer d; public: typedef QSharedDataPointer DataPtr; diff --git a/src/corelib/io/qurlrecode.cpp b/src/corelib/io/qurlrecode.cpp index 443ae18b21..f23480c755 100644 --- a/src/corelib/io/qurlrecode.cpp +++ b/src/corelib/io/qurlrecode.cpp @@ -692,7 +692,7 @@ qt_urlRecode(QString &appendTo, const QChar *begin, const QChar *end, } // qstring.cpp -bool qt_is_ascii(const char *&ptr, const char *end) Q_DECL_NOTHROW; +bool qt_is_ascii(const char *&ptr, const char *end) noexcept; /*! \internal diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h index c34876d1d6..496f583c22 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.h +++ b/src/corelib/itemmodels/qabstractitemmodel.h @@ -57,12 +57,12 @@ class Q_CORE_EXPORT QModelIndex { friend class QAbstractItemModel; public: - Q_DECL_CONSTEXPR inline QModelIndex() Q_DECL_NOTHROW : r(-1), c(-1), i(0), m(nullptr) {} + Q_DECL_CONSTEXPR inline QModelIndex() noexcept : r(-1), c(-1), i(0), m(nullptr) {} // compiler-generated copy/move ctors/assignment operators are fine! - Q_DECL_CONSTEXPR inline int row() const Q_DECL_NOTHROW { return r; } - Q_DECL_CONSTEXPR inline int column() const Q_DECL_NOTHROW { return c; } - Q_DECL_CONSTEXPR inline quintptr internalId() const Q_DECL_NOTHROW { return i; } - inline void *internalPointer() const Q_DECL_NOTHROW { return reinterpret_cast(i); } + Q_DECL_CONSTEXPR inline int row() const noexcept { return r; } + Q_DECL_CONSTEXPR inline int column() const noexcept { return c; } + Q_DECL_CONSTEXPR inline quintptr internalId() const noexcept { return i; } + inline void *internalPointer() const noexcept { return reinterpret_cast(i); } inline QModelIndex parent() const; inline QModelIndex sibling(int row, int column) const; inline QModelIndex siblingAtColumn(int column) const; @@ -72,13 +72,13 @@ public: #endif inline QVariant data(int role = Qt::DisplayRole) const; inline Qt::ItemFlags flags() const; - Q_DECL_CONSTEXPR inline const QAbstractItemModel *model() const Q_DECL_NOTHROW { return m; } - Q_DECL_CONSTEXPR inline bool isValid() const Q_DECL_NOTHROW { return (r >= 0) && (c >= 0) && (m != nullptr); } - Q_DECL_CONSTEXPR inline bool operator==(const QModelIndex &other) const Q_DECL_NOTHROW + Q_DECL_CONSTEXPR inline const QAbstractItemModel *model() const noexcept { return m; } + Q_DECL_CONSTEXPR inline bool isValid() const noexcept { return (r >= 0) && (c >= 0) && (m != nullptr); } + Q_DECL_CONSTEXPR inline bool operator==(const QModelIndex &other) const noexcept { return (other.r == r) && (other.i == i) && (other.c == c) && (other.m == m); } - Q_DECL_CONSTEXPR inline bool operator!=(const QModelIndex &other) const Q_DECL_NOTHROW + Q_DECL_CONSTEXPR inline bool operator!=(const QModelIndex &other) const noexcept { return !(*this == other); } - Q_DECL_CONSTEXPR inline bool operator<(const QModelIndex &other) const Q_DECL_NOTHROW + Q_DECL_CONSTEXPR inline bool operator<(const QModelIndex &other) const noexcept { return r < other.r || (r == other.r && (c < other.c @@ -86,9 +86,9 @@ public: || (i == other.i && std::less()(m, other.m)))))); } private: - inline QModelIndex(int arow, int acolumn, void *ptr, const QAbstractItemModel *amodel) Q_DECL_NOTHROW + inline QModelIndex(int arow, int acolumn, void *ptr, const QAbstractItemModel *amodel) noexcept : r(arow), c(acolumn), i(reinterpret_cast(ptr)), m(amodel) {} - Q_DECL_CONSTEXPR inline QModelIndex(int arow, int acolumn, quintptr id, const QAbstractItemModel *amodel) Q_DECL_NOTHROW + Q_DECL_CONSTEXPR inline QModelIndex(int arow, int acolumn, quintptr id, const QAbstractItemModel *amodel) noexcept : r(arow), c(acolumn), i(id), m(amodel) {} int r, c; quintptr i; @@ -103,7 +103,7 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QModelIndex &); class QPersistentModelIndexData; // qHash is a friend, but we can't use default arguments for friends (§8.3.6.4) -uint qHash(const QPersistentModelIndex &index, uint seed = 0) Q_DECL_NOTHROW; +uint qHash(const QPersistentModelIndex &index, uint seed = 0) noexcept; class Q_CORE_EXPORT QPersistentModelIndex { @@ -118,12 +118,12 @@ public: { return !operator==(other); } QPersistentModelIndex &operator=(const QPersistentModelIndex &other); #ifdef Q_COMPILER_RVALUE_REFS - inline QPersistentModelIndex(QPersistentModelIndex &&other) Q_DECL_NOTHROW + inline QPersistentModelIndex(QPersistentModelIndex &&other) noexcept : d(other.d) { other.d = nullptr; } - inline QPersistentModelIndex &operator=(QPersistentModelIndex &&other) Q_DECL_NOTHROW + inline QPersistentModelIndex &operator=(QPersistentModelIndex &&other) noexcept { qSwap(d, other.d); return *this; } #endif - inline void swap(QPersistentModelIndex &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + inline void swap(QPersistentModelIndex &other) noexcept { qSwap(d, other.d); } bool operator==(const QModelIndex &other) const; bool operator!=(const QModelIndex &other) const; QPersistentModelIndex &operator=(const QModelIndex &other); @@ -143,14 +143,14 @@ public: bool isValid() const; private: QPersistentModelIndexData *d; - friend uint qHash(const QPersistentModelIndex &, uint seed) Q_DECL_NOTHROW; + friend uint qHash(const QPersistentModelIndex &, uint seed) noexcept; #ifndef QT_NO_DEBUG_STREAM friend Q_CORE_EXPORT QDebug operator<<(QDebug, const QPersistentModelIndex &); #endif }; Q_DECLARE_SHARED(QPersistentModelIndex) -inline uint qHash(const QPersistentModelIndex &index, uint seed) Q_DECL_NOTHROW +inline uint qHash(const QPersistentModelIndex &index, uint seed) noexcept { return qHash(index.d, seed); } @@ -464,7 +464,7 @@ inline QVariant QModelIndex::data(int arole) const inline Qt::ItemFlags QModelIndex::flags() const { return m ? m->flags(*this) : Qt::ItemFlags(); } -inline uint qHash(const QModelIndex &index) Q_DECL_NOTHROW +inline uint qHash(const QModelIndex &index) noexcept { return uint((uint(index.row()) << 4) + index.column() + index.internalId()); } QT_END_NAMESPACE diff --git a/src/corelib/itemmodels/qitemselectionmodel.h b/src/corelib/itemmodels/qitemselectionmodel.h index 1c924053a5..e5cd24817b 100644 --- a/src/corelib/itemmodels/qitemselectionmodel.h +++ b/src/corelib/itemmodels/qitemselectionmodel.h @@ -61,9 +61,9 @@ public: inline QItemSelectionRange(const QItemSelectionRange &other) : tl(other.tl), br(other.br) {} # ifdef Q_COMPILER_RVALUE_REFS - QItemSelectionRange(QItemSelectionRange &&other) Q_DECL_NOTHROW + QItemSelectionRange(QItemSelectionRange &&other) noexcept : tl(std::move(other.tl)), br(std::move(other.br)) {} - QItemSelectionRange &operator=(QItemSelectionRange &&other) Q_DECL_NOTHROW + QItemSelectionRange &operator=(QItemSelectionRange &&other) noexcept { tl = std::move(other.tl); br = std::move(other.br); return *this; } # endif QItemSelectionRange &operator=(const QItemSelectionRange &other) @@ -72,7 +72,7 @@ public: QItemSelectionRange(const QModelIndex &topL, const QModelIndex &bottomR) : tl(topL), br(bottomR) {} explicit QItemSelectionRange(const QModelIndex &index) : tl(index), br(tl) {} - void swap(QItemSelectionRange &other) Q_DECL_NOTHROW + void swap(QItemSelectionRange &other) noexcept { qSwap(tl, other.tl); qSwap(br, other.br); @@ -249,7 +249,7 @@ Q_TEMPLATE_EXTERN template class Q_CORE_EXPORT QList; class Q_CORE_EXPORT QItemSelection : public QList { public: - QItemSelection() Q_DECL_NOTHROW : QList() {} + QItemSelection() noexcept : QList() {} QItemSelection(const QModelIndex &topLeft, const QModelIndex &bottomRight); // reusing QList::swap() here is OK! diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h index 32ef6408c2..7f58813535 100644 --- a/src/corelib/kernel/qcore_unix_p.h +++ b/src/corelib/kernel/qcore_unix_p.h @@ -347,7 +347,7 @@ static inline pid_t qt_safe_waitpid(pid_t pid, int *status, int options) #endif // in qelapsedtimer_mac.cpp or qtimestamp_unix.cpp -timespec qt_gettime() Q_DECL_NOTHROW; +timespec qt_gettime() noexcept; void qt_nanosleep(timespec amount); QByteArray qt_readlink(const char *path); diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 5da33a5aae..038de264cb 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -369,7 +369,7 @@ uint QCoreApplicationPrivate::attribs = (1 << Qt::AA_SynthesizeMouseForUnhandledTabletEvents); struct QCoreApplicationData { - QCoreApplicationData() Q_DECL_NOTHROW { + QCoreApplicationData() noexcept { applicationNameSet = false; applicationVersionSet = false; } diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp index cacbb1e495..aabd32b4a8 100644 --- a/src/corelib/kernel/qcoreevent.cpp +++ b/src/corelib/kernel/qcoreevent.cpp @@ -421,7 +421,7 @@ struct QBasicAtomicBitField { QBasicAtomicInteger next; QBasicAtomicInteger data[NumInts]; - bool allocateSpecific(int which) Q_DECL_NOTHROW + bool allocateSpecific(int which) noexcept { QBasicAtomicInteger &entry = data[which / BitsPerInt]; const uint old = entry.load(); @@ -437,7 +437,7 @@ struct QBasicAtomicBitField { // loop. } - int allocateNext() Q_DECL_NOTHROW + int allocateNext() noexcept { // Unroll loop to iterate over ints, then bits? Would save // potentially a lot of cmpxchgs, because we can scan the @@ -463,7 +463,7 @@ typedef QBasicAtomicBitField UserEventTypeRe static UserEventTypeRegistry userEventTypeRegistry; -static inline int registerEventTypeZeroBased(int id) Q_DECL_NOTHROW +static inline int registerEventTypeZeroBased(int id) noexcept { // if the type hint hasn't been registered yet, take it: if (id < UserEventTypeRegistry::NumBits && id >= 0 && userEventTypeRegistry.allocateSpecific(id)) @@ -486,7 +486,7 @@ static inline int registerEventTypeZeroBased(int id) Q_DECL_NOTHROW Returns -1 if all available values are already taken or the program is shutting down. */ -int QEvent::registerEventType(int hint) Q_DECL_NOTHROW +int QEvent::registerEventType(int hint) noexcept { const int result = registerEventTypeZeroBased(QEvent::MaxUser - hint); return result < 0 ? -1 : QEvent::MaxUser - result ; diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h index ac974ba411..05af1a6132 100644 --- a/src/corelib/kernel/qcoreevent.h +++ b/src/corelib/kernel/qcoreevent.h @@ -307,7 +307,7 @@ public: inline void accept() { m_accept = true; } inline void ignore() { m_accept = false; } - static int registerEventType(int hint = -1) Q_DECL_NOTHROW; + static int registerEventType(int hint = -1) noexcept; protected: QEventPrivate *d; diff --git a/src/corelib/kernel/qdeadlinetimer.cpp b/src/corelib/kernel/qdeadlinetimer.cpp index 6aa886cfe1..e0d9d9de73 100644 --- a/src/corelib/kernel/qdeadlinetimer.cpp +++ b/src/corelib/kernel/qdeadlinetimer.cpp @@ -188,7 +188,7 @@ Q_DECL_CONST_FUNCTION static inline QPair toSecsAndNSecs(qint64 \sa hasExpired(), isForever(), remainingTime(), setRemainingTime() */ -QDeadlineTimer::QDeadlineTimer(qint64 msecs, Qt::TimerType type) Q_DECL_NOTHROW +QDeadlineTimer::QDeadlineTimer(qint64 msecs, Qt::TimerType type) noexcept : t2(0) { setRemainingTime(msecs, type); @@ -260,7 +260,7 @@ QDeadlineTimer::QDeadlineTimer(qint64 msecs, Qt::TimerType type) Q_DECL_NOTHROW \sa setPreciseRemainingTime(), hasExpired(), isForever(), remainingTime() */ -void QDeadlineTimer::setRemainingTime(qint64 msecs, Qt::TimerType timerType) Q_DECL_NOTHROW +void QDeadlineTimer::setRemainingTime(qint64 msecs, Qt::TimerType timerType) noexcept { if (msecs == -1) *this = QDeadlineTimer(Forever, timerType); @@ -279,7 +279,7 @@ void QDeadlineTimer::setRemainingTime(qint64 msecs, Qt::TimerType timerType) Q_D \sa setRemainingTime(), hasExpired(), isForever(), remainingTime() */ -void QDeadlineTimer::setPreciseRemainingTime(qint64 secs, qint64 nsecs, Qt::TimerType timerType) Q_DECL_NOTHROW +void QDeadlineTimer::setPreciseRemainingTime(qint64 secs, qint64 nsecs, Qt::TimerType timerType) noexcept { if (secs == -1) { *this = QDeadlineTimer(Forever, timerType); @@ -342,7 +342,7 @@ void QDeadlineTimer::setPreciseRemainingTime(qint64 secs, qint64 nsecs, Qt::Time \sa isForever(), remainingTime() */ -bool QDeadlineTimer::hasExpired() const Q_DECL_NOTHROW +bool QDeadlineTimer::hasExpired() const noexcept { if (isForever()) return false; @@ -389,7 +389,7 @@ void QDeadlineTimer::setTimerType(Qt::TimerType timerType) \sa remainingTimeNSecs(), isForever(), hasExpired() */ -qint64 QDeadlineTimer::remainingTime() const Q_DECL_NOTHROW +qint64 QDeadlineTimer::remainingTime() const noexcept { qint64 ns = remainingTimeNSecs(); return ns <= 0 ? ns : (ns + 999999) / (1000 * 1000); @@ -403,7 +403,7 @@ qint64 QDeadlineTimer::remainingTime() const Q_DECL_NOTHROW \sa remainingTime(), isForever(), hasExpired() */ -qint64 QDeadlineTimer::remainingTimeNSecs() const Q_DECL_NOTHROW +qint64 QDeadlineTimer::remainingTimeNSecs() const noexcept { if (isForever()) return -1; @@ -416,7 +416,7 @@ qint64 QDeadlineTimer::remainingTimeNSecs() const Q_DECL_NOTHROW Same as remainingTimeNSecs, but may return negative remaining times. Does not deal with Forever. */ -qint64 QDeadlineTimer::rawRemainingTimeNSecs() const Q_DECL_NOTHROW +qint64 QDeadlineTimer::rawRemainingTimeNSecs() const noexcept { QDeadlineTimer now = current(timerType()); if (QDeadlineTimerNanosecondsInT2) @@ -444,7 +444,7 @@ qint64 QDeadlineTimer::rawRemainingTimeNSecs() const Q_DECL_NOTHROW \sa remainingTime(), deadlineNSecs(), setDeadline() */ -qint64 QDeadlineTimer::deadline() const Q_DECL_NOTHROW +qint64 QDeadlineTimer::deadline() const noexcept { if (isForever()) return t1; @@ -471,7 +471,7 @@ qint64 QDeadlineTimer::deadline() const Q_DECL_NOTHROW \sa remainingTime(), deadlineNSecs() */ -qint64 QDeadlineTimer::deadlineNSecs() const Q_DECL_NOTHROW +qint64 QDeadlineTimer::deadlineNSecs() const noexcept { if (isForever()) return t1; @@ -492,7 +492,7 @@ qint64 QDeadlineTimer::deadlineNSecs() const Q_DECL_NOTHROW \sa setPreciseDeadline(), deadline(), deadlineNSecs(), setRemainingTime() */ -void QDeadlineTimer::setDeadline(qint64 msecs, Qt::TimerType timerType) Q_DECL_NOTHROW +void QDeadlineTimer::setDeadline(qint64 msecs, Qt::TimerType timerType) noexcept { if (msecs == (std::numeric_limits::max)()) { setPreciseDeadline(msecs, 0, timerType); // msecs == MAX implies Forever @@ -513,7 +513,7 @@ void QDeadlineTimer::setDeadline(qint64 msecs, Qt::TimerType timerType) Q_DECL_N \sa setDeadline(), deadline(), deadlineNSecs(), setRemainingTime() */ -void QDeadlineTimer::setPreciseDeadline(qint64 secs, qint64 nsecs, Qt::TimerType timerType) Q_DECL_NOTHROW +void QDeadlineTimer::setPreciseDeadline(qint64 secs, qint64 nsecs, Qt::TimerType timerType) noexcept { type = timerType; if (secs == (std::numeric_limits::max)() || nsecs == (std::numeric_limits::max)()) { @@ -534,7 +534,7 @@ void QDeadlineTimer::setPreciseDeadline(qint64 secs, qint64 nsecs, Qt::TimerType \note if \a dt was created as expired, its deadline is indeterminate and adding an amount of time may or may not cause it to become unexpired. */ -QDeadlineTimer QDeadlineTimer::addNSecs(QDeadlineTimer dt, qint64 nsecs) Q_DECL_NOTHROW +QDeadlineTimer QDeadlineTimer::addNSecs(QDeadlineTimer dt, qint64 nsecs) noexcept { if (dt.isForever() || nsecs == (std::numeric_limits::max)()) { dt = QDeadlineTimer(Forever, dt.timerType()); diff --git a/src/corelib/kernel/qdeadlinetimer.h b/src/corelib/kernel/qdeadlinetimer.h index 1a4ee04a96..8032ee9018 100644 --- a/src/corelib/kernel/qdeadlinetimer.h +++ b/src/corelib/kernel/qdeadlinetimer.h @@ -63,49 +63,49 @@ class Q_CORE_EXPORT QDeadlineTimer public: enum ForeverConstant { Forever }; - Q_DECL_CONSTEXPR QDeadlineTimer(Qt::TimerType type_ = Qt::CoarseTimer) Q_DECL_NOTHROW + Q_DECL_CONSTEXPR QDeadlineTimer(Qt::TimerType type_ = Qt::CoarseTimer) noexcept : t1(0), t2(0), type(type_) {} - Q_DECL_CONSTEXPR QDeadlineTimer(ForeverConstant, Qt::TimerType type_ = Qt::CoarseTimer) Q_DECL_NOTHROW + Q_DECL_CONSTEXPR QDeadlineTimer(ForeverConstant, Qt::TimerType type_ = Qt::CoarseTimer) noexcept : t1(std::numeric_limits::max()), t2(0), type(type_) {} - explicit QDeadlineTimer(qint64 msecs, Qt::TimerType type = Qt::CoarseTimer) Q_DECL_NOTHROW; + explicit QDeadlineTimer(qint64 msecs, Qt::TimerType type = Qt::CoarseTimer) noexcept; - void swap(QDeadlineTimer &other) Q_DECL_NOTHROW + void swap(QDeadlineTimer &other) noexcept { qSwap(t1, other.t1); qSwap(t2, other.t2); qSwap(type, other.type); } - Q_DECL_CONSTEXPR bool isForever() const Q_DECL_NOTHROW + Q_DECL_CONSTEXPR bool isForever() const noexcept { return t1 == (std::numeric_limits::max)(); } - bool hasExpired() const Q_DECL_NOTHROW; + bool hasExpired() const noexcept; - Qt::TimerType timerType() const Q_DECL_NOTHROW + Qt::TimerType timerType() const noexcept { return Qt::TimerType(type & 0xff); } void setTimerType(Qt::TimerType type); - qint64 remainingTime() const Q_DECL_NOTHROW; - qint64 remainingTimeNSecs() const Q_DECL_NOTHROW; - void setRemainingTime(qint64 msecs, Qt::TimerType type = Qt::CoarseTimer) Q_DECL_NOTHROW; + qint64 remainingTime() const noexcept; + qint64 remainingTimeNSecs() const noexcept; + void setRemainingTime(qint64 msecs, Qt::TimerType type = Qt::CoarseTimer) noexcept; void setPreciseRemainingTime(qint64 secs, qint64 nsecs = 0, - Qt::TimerType type = Qt::CoarseTimer) Q_DECL_NOTHROW; + Qt::TimerType type = Qt::CoarseTimer) noexcept; - qint64 deadline() const Q_DECL_NOTHROW Q_DECL_PURE_FUNCTION; - qint64 deadlineNSecs() const Q_DECL_NOTHROW Q_DECL_PURE_FUNCTION; - void setDeadline(qint64 msecs, Qt::TimerType timerType = Qt::CoarseTimer) Q_DECL_NOTHROW; + qint64 deadline() const noexcept Q_DECL_PURE_FUNCTION; + qint64 deadlineNSecs() const noexcept Q_DECL_PURE_FUNCTION; + void setDeadline(qint64 msecs, Qt::TimerType timerType = Qt::CoarseTimer) noexcept; void setPreciseDeadline(qint64 secs, qint64 nsecs = 0, - Qt::TimerType type = Qt::CoarseTimer) Q_DECL_NOTHROW; + Qt::TimerType type = Qt::CoarseTimer) noexcept; - static QDeadlineTimer addNSecs(QDeadlineTimer dt, qint64 nsecs) Q_DECL_NOTHROW Q_DECL_PURE_FUNCTION; - static QDeadlineTimer current(Qt::TimerType timerType = Qt::CoarseTimer) Q_DECL_NOTHROW; + static QDeadlineTimer addNSecs(QDeadlineTimer dt, qint64 nsecs) noexcept Q_DECL_PURE_FUNCTION; + static QDeadlineTimer current(Qt::TimerType timerType = Qt::CoarseTimer) noexcept; - friend bool operator==(QDeadlineTimer d1, QDeadlineTimer d2) Q_DECL_NOTHROW + friend bool operator==(QDeadlineTimer d1, QDeadlineTimer d2) noexcept { return d1.t1 == d2.t1 && d1.t2 == d2.t2; } - friend bool operator!=(QDeadlineTimer d1, QDeadlineTimer d2) Q_DECL_NOTHROW + friend bool operator!=(QDeadlineTimer d1, QDeadlineTimer d2) noexcept { return !(d1 == d2); } - friend bool operator<(QDeadlineTimer d1, QDeadlineTimer d2) Q_DECL_NOTHROW + friend bool operator<(QDeadlineTimer d1, QDeadlineTimer d2) noexcept { return d1.t1 < d2.t1 || (d1.t1 == d2.t1 && d1.t2 < d2.t2); } - friend bool operator<=(QDeadlineTimer d1, QDeadlineTimer d2) Q_DECL_NOTHROW + friend bool operator<=(QDeadlineTimer d1, QDeadlineTimer d2) noexcept { return d1 == d2 || d1 < d2; } - friend bool operator>(QDeadlineTimer d1, QDeadlineTimer d2) Q_DECL_NOTHROW + friend bool operator>(QDeadlineTimer d1, QDeadlineTimer d2) noexcept { return d2 < d1; } - friend bool operator>=(QDeadlineTimer d1, QDeadlineTimer d2) Q_DECL_NOTHROW + friend bool operator>=(QDeadlineTimer d1, QDeadlineTimer d2) noexcept { return !(d1 < d2); } friend QDeadlineTimer operator+(QDeadlineTimer dt, qint64 msecs) @@ -160,7 +160,7 @@ public: setPreciseRemainingTime(0, std::chrono::nanoseconds(remaining).count(), type_); } - std::chrono::nanoseconds remainingTimeAsDuration() const Q_DECL_NOTHROW + std::chrono::nanoseconds remainingTimeAsDuration() const noexcept { if (isForever()) return std::chrono::nanoseconds::max(); @@ -186,7 +186,7 @@ private: unsigned t2; unsigned type; - qint64 rawRemainingTimeNSecs() const Q_DECL_NOTHROW; + qint64 rawRemainingTimeNSecs() const noexcept; public: // This is not a public function, it's here only for Qt's internal convenience... diff --git a/src/corelib/kernel/qelapsedtimer.cpp b/src/corelib/kernel/qelapsedtimer.cpp index e578b5b8b3..adb554b624 100644 --- a/src/corelib/kernel/qelapsedtimer.cpp +++ b/src/corelib/kernel/qelapsedtimer.cpp @@ -236,7 +236,7 @@ static const qint64 invalidData = Q_INT64_C(0x8000000000000000); \sa isValid(), start(), restart() */ -void QElapsedTimer::invalidate() Q_DECL_NOTHROW +void QElapsedTimer::invalidate() noexcept { t1 = t2 = invalidData; } @@ -247,7 +247,7 @@ void QElapsedTimer::invalidate() Q_DECL_NOTHROW \sa invalidate(), start(), restart() */ -bool QElapsedTimer::isValid() const Q_DECL_NOTHROW +bool QElapsedTimer::isValid() const noexcept { return t1 != invalidData && t2 != invalidData; } @@ -260,7 +260,7 @@ bool QElapsedTimer::isValid() const Q_DECL_NOTHROW \sa elapsed(), QDeadlineTimer */ -bool QElapsedTimer::hasExpired(qint64 timeout) const Q_DECL_NOTHROW +bool QElapsedTimer::hasExpired(qint64 timeout) const noexcept { // if timeout is -1, quint64(timeout) is LLINT_MAX, so this will be // considered as never expired diff --git a/src/corelib/kernel/qelapsedtimer.h b/src/corelib/kernel/qelapsedtimer.h index 7954b41bf4..873847f6b6 100644 --- a/src/corelib/kernel/qelapsedtimer.h +++ b/src/corelib/kernel/qelapsedtimer.h @@ -62,28 +62,28 @@ public: { } - static ClockType clockType() Q_DECL_NOTHROW; - static bool isMonotonic() Q_DECL_NOTHROW; + static ClockType clockType() noexcept; + static bool isMonotonic() noexcept; - void start() Q_DECL_NOTHROW; - qint64 restart() Q_DECL_NOTHROW; - void invalidate() Q_DECL_NOTHROW; - bool isValid() const Q_DECL_NOTHROW; + void start() noexcept; + qint64 restart() noexcept; + void invalidate() noexcept; + bool isValid() const noexcept; - qint64 nsecsElapsed() const Q_DECL_NOTHROW; - qint64 elapsed() const Q_DECL_NOTHROW; - bool hasExpired(qint64 timeout) const Q_DECL_NOTHROW; + qint64 nsecsElapsed() const noexcept; + qint64 elapsed() const noexcept; + bool hasExpired(qint64 timeout) const noexcept; - qint64 msecsSinceReference() const Q_DECL_NOTHROW; - qint64 msecsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW; - qint64 secsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW; + qint64 msecsSinceReference() const noexcept; + qint64 msecsTo(const QElapsedTimer &other) const noexcept; + qint64 secsTo(const QElapsedTimer &other) const noexcept; - bool operator==(const QElapsedTimer &other) const Q_DECL_NOTHROW + bool operator==(const QElapsedTimer &other) const noexcept { return t1 == other.t1 && t2 == other.t2; } - bool operator!=(const QElapsedTimer &other) const Q_DECL_NOTHROW + bool operator!=(const QElapsedTimer &other) const noexcept { return !(*this == other); } - friend bool Q_CORE_EXPORT operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) Q_DECL_NOTHROW; + friend bool Q_CORE_EXPORT operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) noexcept; private: qint64 t1; diff --git a/src/corelib/kernel/qelapsedtimer_generic.cpp b/src/corelib/kernel/qelapsedtimer_generic.cpp index fdeb385188..fe959e3c94 100644 --- a/src/corelib/kernel/qelapsedtimer_generic.cpp +++ b/src/corelib/kernel/qelapsedtimer_generic.cpp @@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE \sa isMonotonic() */ -QElapsedTimer::ClockType QElapsedTimer::clockType() Q_DECL_NOTHROW +QElapsedTimer::ClockType QElapsedTimer::clockType() noexcept { return SystemTime; } @@ -60,7 +60,7 @@ QElapsedTimer::ClockType QElapsedTimer::clockType() Q_DECL_NOTHROW \sa clockType(), QElapsedTimer::ClockType */ -bool QElapsedTimer::isMonotonic() Q_DECL_NOTHROW +bool QElapsedTimer::isMonotonic() noexcept { return false; } @@ -75,7 +75,7 @@ bool QElapsedTimer::isMonotonic() Q_DECL_NOTHROW \sa restart(), invalidate(), elapsed() */ -void QElapsedTimer::start() Q_DECL_NOTHROW +void QElapsedTimer::start() noexcept { restart(); } @@ -97,7 +97,7 @@ void QElapsedTimer::start() Q_DECL_NOTHROW \sa start(), invalidate(), elapsed(), isValid() */ -qint64 QElapsedTimer::restart() Q_DECL_NOTHROW +qint64 QElapsedTimer::restart() noexcept { qint64 old = t1; t1 = QDateTime::currentMSecsSinceEpoch(); @@ -118,7 +118,7 @@ qint64 QElapsedTimer::restart() Q_DECL_NOTHROW \sa start(), restart(), hasExpired(), invalidate() */ -qint64 QElapsedTimer::nsecsElapsed() const Q_DECL_NOTHROW +qint64 QElapsedTimer::nsecsElapsed() const noexcept { return elapsed() * 1000000; } @@ -132,7 +132,7 @@ qint64 QElapsedTimer::nsecsElapsed() const Q_DECL_NOTHROW \sa start(), restart(), hasExpired(), isValid(), invalidate() */ -qint64 QElapsedTimer::elapsed() const Q_DECL_NOTHROW +qint64 QElapsedTimer::elapsed() const noexcept { return QDateTime::currentMSecsSinceEpoch() - t1; } @@ -152,7 +152,7 @@ qint64 QElapsedTimer::elapsed() const Q_DECL_NOTHROW \sa clockType(), elapsed() */ -qint64 QElapsedTimer::msecsSinceReference() const Q_DECL_NOTHROW +qint64 QElapsedTimer::msecsSinceReference() const noexcept { return t1; } @@ -167,7 +167,7 @@ qint64 QElapsedTimer::msecsSinceReference() const Q_DECL_NOTHROW \sa secsTo(), elapsed() */ -qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW +qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const noexcept { qint64 diff = other.t1 - t1; return diff; @@ -183,7 +183,7 @@ qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW \sa msecsTo(), elapsed() */ -qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW +qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const noexcept { return msecsTo(other) / 1000; } @@ -197,12 +197,12 @@ qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW and the other isn't. However, two invalid timers are equal and thus this function will return false. */ -bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) Q_DECL_NOTHROW +bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) noexcept { return v1.t1 < v2.t1; } -QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) Q_DECL_NOTHROW +QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) noexcept { QDeadlineTimer result; result.t1 = QDateTime::currentMSecsSinceEpoch() * 1000 * 1000; diff --git a/src/corelib/kernel/qelapsedtimer_mac.cpp b/src/corelib/kernel/qelapsedtimer_mac.cpp index 7490693991..5370cf7b3d 100644 --- a/src/corelib/kernel/qelapsedtimer_mac.cpp +++ b/src/corelib/kernel/qelapsedtimer_mac.cpp @@ -58,12 +58,12 @@ typedef __int128_t LargeInt; typedef qint64 LargeInt; #endif -QElapsedTimer::ClockType QElapsedTimer::clockType() Q_DECL_NOTHROW +QElapsedTimer::ClockType QElapsedTimer::clockType() noexcept { return MachAbsoluteTime; } -bool QElapsedTimer::isMonotonic() Q_DECL_NOTHROW +bool QElapsedTimer::isMonotonic() noexcept { return true; } @@ -87,7 +87,7 @@ static qint64 absoluteToMSecs(qint64 cpuTime) return absoluteToNSecs(cpuTime) / 1000000; } -timespec qt_gettime() Q_DECL_NOTHROW +timespec qt_gettime() noexcept { timespec tv; @@ -107,13 +107,13 @@ void qt_nanosleep(timespec amount) EINTR_LOOP(r, nanosleep(&amount, &amount)); } -void QElapsedTimer::start() Q_DECL_NOTHROW +void QElapsedTimer::start() noexcept { t1 = mach_absolute_time(); t2 = 0; } -qint64 QElapsedTimer::restart() Q_DECL_NOTHROW +qint64 QElapsedTimer::restart() noexcept { qint64 old = t1; t1 = mach_absolute_time(); @@ -122,39 +122,39 @@ qint64 QElapsedTimer::restart() Q_DECL_NOTHROW return absoluteToMSecs(t1 - old); } -qint64 QElapsedTimer::nsecsElapsed() const Q_DECL_NOTHROW +qint64 QElapsedTimer::nsecsElapsed() const noexcept { uint64_t cpu_time = mach_absolute_time(); return absoluteToNSecs(cpu_time - t1); } -qint64 QElapsedTimer::elapsed() const Q_DECL_NOTHROW +qint64 QElapsedTimer::elapsed() const noexcept { uint64_t cpu_time = mach_absolute_time(); return absoluteToMSecs(cpu_time - t1); } -qint64 QElapsedTimer::msecsSinceReference() const Q_DECL_NOTHROW +qint64 QElapsedTimer::msecsSinceReference() const noexcept { return absoluteToMSecs(t1); } -qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW +qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const noexcept { return absoluteToMSecs(other.t1 - t1); } -qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW +qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const noexcept { return msecsTo(other) / 1000; } -bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) Q_DECL_NOTHROW +bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) noexcept { return v1.t1 < v2.t1; } -QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) Q_DECL_NOTHROW +QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) noexcept { Q_STATIC_ASSERT(!QDeadlineTimerNanosecondsInT2); QDeadlineTimer result; diff --git a/src/corelib/kernel/qelapsedtimer_unix.cpp b/src/corelib/kernel/qelapsedtimer_unix.cpp index e166d4e3d2..ccc2eeafa3 100644 --- a/src/corelib/kernel/qelapsedtimer_unix.cpp +++ b/src/corelib/kernel/qelapsedtimer_unix.cpp @@ -150,12 +150,12 @@ static int unixCheckClockType() #endif } -bool QElapsedTimer::isMonotonic() Q_DECL_NOTHROW +bool QElapsedTimer::isMonotonic() noexcept { return clockType() == MonotonicClock; } -QElapsedTimer::ClockType QElapsedTimer::clockType() Q_DECL_NOTHROW +QElapsedTimer::ClockType QElapsedTimer::clockType() noexcept { return unixCheckClockType() == CLOCK_REALTIME ? SystemTime : MonotonicClock; } @@ -169,7 +169,7 @@ static inline void do_gettime(qint64 *sec, qint64 *frac) } // used in qcore_unix.cpp and qeventdispatcher_unix.cpp -struct timespec qt_gettime() Q_DECL_NOTHROW +struct timespec qt_gettime() noexcept { qint64 sec, frac; do_gettime(&sec, &frac); @@ -204,17 +204,17 @@ static qint64 elapsedAndRestart(qint64 sec, qint64 frac, return (sec * Q_INT64_C(1000000000) + frac) / Q_INT64_C(1000000); } -void QElapsedTimer::start() Q_DECL_NOTHROW +void QElapsedTimer::start() noexcept { do_gettime(&t1, &t2); } -qint64 QElapsedTimer::restart() Q_DECL_NOTHROW +qint64 QElapsedTimer::restart() noexcept { return elapsedAndRestart(t1, t2, &t1, &t2); } -qint64 QElapsedTimer::nsecsElapsed() const Q_DECL_NOTHROW +qint64 QElapsedTimer::nsecsElapsed() const noexcept { qint64 sec, frac; do_gettime(&sec, &frac); @@ -223,34 +223,34 @@ qint64 QElapsedTimer::nsecsElapsed() const Q_DECL_NOTHROW return sec * Q_INT64_C(1000000000) + frac; } -qint64 QElapsedTimer::elapsed() const Q_DECL_NOTHROW +qint64 QElapsedTimer::elapsed() const noexcept { return nsecsElapsed() / Q_INT64_C(1000000); } -qint64 QElapsedTimer::msecsSinceReference() const Q_DECL_NOTHROW +qint64 QElapsedTimer::msecsSinceReference() const noexcept { return t1 * Q_INT64_C(1000) + t2 / Q_INT64_C(1000000); } -qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW +qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const noexcept { qint64 secs = other.t1 - t1; qint64 fraction = other.t2 - t2; return (secs * Q_INT64_C(1000000000) + fraction) / Q_INT64_C(1000000); } -qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW +qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const noexcept { return other.t1 - t1; } -bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) Q_DECL_NOTHROW +bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) noexcept { return v1.t1 < v2.t1 || (v1.t1 == v2.t1 && v1.t2 < v2.t2); } -QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) Q_DECL_NOTHROW +QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) noexcept { Q_STATIC_ASSERT(QDeadlineTimerNanosecondsInT2); QDeadlineTimer result; diff --git a/src/corelib/kernel/qelapsedtimer_win.cpp b/src/corelib/kernel/qelapsedtimer_win.cpp index a63290d2f8..d8a50a8277 100644 --- a/src/corelib/kernel/qelapsedtimer_win.cpp +++ b/src/corelib/kernel/qelapsedtimer_win.cpp @@ -110,25 +110,25 @@ quint64 qt_msectime() return ticksToNanoseconds(getTickCount()) / 1000000; } -QElapsedTimer::ClockType QElapsedTimer::clockType() Q_DECL_NOTHROW +QElapsedTimer::ClockType QElapsedTimer::clockType() noexcept { resolveCounterFrequency(); return counterFrequency > 0 ? PerformanceCounter : TickCounter; } -bool QElapsedTimer::isMonotonic() Q_DECL_NOTHROW +bool QElapsedTimer::isMonotonic() noexcept { return true; } -void QElapsedTimer::start() Q_DECL_NOTHROW +void QElapsedTimer::start() noexcept { t1 = getTickCount(); t2 = 0; } -qint64 QElapsedTimer::restart() Q_DECL_NOTHROW +qint64 QElapsedTimer::restart() noexcept { qint64 oldt1 = t1; t1 = getTickCount(); @@ -136,40 +136,40 @@ qint64 QElapsedTimer::restart() Q_DECL_NOTHROW return ticksToNanoseconds(t1 - oldt1) / 1000000; } -qint64 QElapsedTimer::nsecsElapsed() const Q_DECL_NOTHROW +qint64 QElapsedTimer::nsecsElapsed() const noexcept { qint64 elapsed = getTickCount() - t1; return ticksToNanoseconds(elapsed); } -qint64 QElapsedTimer::elapsed() const Q_DECL_NOTHROW +qint64 QElapsedTimer::elapsed() const noexcept { qint64 elapsed = getTickCount() - t1; return ticksToNanoseconds(elapsed) / 1000000; } -qint64 QElapsedTimer::msecsSinceReference() const Q_DECL_NOTHROW +qint64 QElapsedTimer::msecsSinceReference() const noexcept { return ticksToNanoseconds(t1) / 1000000; } -qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW +qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const noexcept { qint64 difference = other.t1 - t1; return ticksToNanoseconds(difference) / 1000000; } -qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW +qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const noexcept { return msecsTo(other) / 1000; } -bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) Q_DECL_NOTHROW +bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) noexcept { return (v1.t1 - v2.t1) < 0; } -QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) Q_DECL_NOTHROW +QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) noexcept { Q_STATIC_ASSERT(!QDeadlineTimerNanosecondsInT2); QDeadlineTimer result; diff --git a/src/corelib/kernel/qeventdispatcher_unix_p.h b/src/corelib/kernel/qeventdispatcher_unix_p.h index 8cfa4bbdf7..f37edfc967 100644 --- a/src/corelib/kernel/qeventdispatcher_unix_p.h +++ b/src/corelib/kernel/qeventdispatcher_unix_p.h @@ -64,10 +64,10 @@ class QEventDispatcherUNIXPrivate; struct Q_CORE_EXPORT QSocketNotifierSetUNIX final { - inline QSocketNotifierSetUNIX() Q_DECL_NOTHROW; + inline QSocketNotifierSetUNIX() noexcept; - inline bool isEmpty() const Q_DECL_NOTHROW; - inline short events() const Q_DECL_NOTHROW; + inline bool isEmpty() const noexcept; + inline short events() const noexcept; QSocketNotifier *notifiers[3]; }; @@ -150,19 +150,19 @@ public: QAtomicInt interrupt; // bool }; -inline QSocketNotifierSetUNIX::QSocketNotifierSetUNIX() Q_DECL_NOTHROW +inline QSocketNotifierSetUNIX::QSocketNotifierSetUNIX() noexcept { notifiers[0] = nullptr; notifiers[1] = nullptr; notifiers[2] = nullptr; } -inline bool QSocketNotifierSetUNIX::isEmpty() const Q_DECL_NOTHROW +inline bool QSocketNotifierSetUNIX::isEmpty() const noexcept { return !notifiers[0] && !notifiers[1] && !notifiers[2]; } -inline short QSocketNotifierSetUNIX::events() const Q_DECL_NOTHROW +inline short QSocketNotifierSetUNIX::events() const noexcept { short result = 0; diff --git a/src/corelib/kernel/qfunctions_fake_env_p.h b/src/corelib/kernel/qfunctions_fake_env_p.h index 7010d2cf5d..68d17ed4a1 100644 --- a/src/corelib/kernel/qfunctions_fake_env_p.h +++ b/src/corelib/kernel/qfunctions_fake_env_p.h @@ -72,8 +72,8 @@ Q_DECLARE_TYPEINFO(Variable, Q_MOVABLE_TYPE); struct NameEquals { typedef bool result_type; const char *name; - explicit NameEquals(const char *name) Q_DECL_NOTHROW : name(name) {} - result_type operator()(const Variable &other) const Q_DECL_NOTHROW + explicit NameEquals(const char *name) noexcept : name(name) {} + result_type operator()(const Variable &other) const noexcept { return qstrcmp(other.name, name) == 0; } }; diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index c15a9f7b0f..ace3eac2ac 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -335,7 +335,7 @@ const char *QMetaObject::className() const \since 5.7 */ -bool QMetaObject::inherits(const QMetaObject *metaObject) const Q_DECL_NOEXCEPT +bool QMetaObject::inherits(const QMetaObject *metaObject) const noexcept { const QMetaObject *m = this; do { diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 45d0b5df6c..19bda7e8d6 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -915,7 +915,7 @@ template struct MetaTypeOffsetsblockSig; diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 63c5a9ad73..6d7b9521c2 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -142,8 +142,8 @@ public: inline bool isWidgetType() const { return d_ptr->isWidget; } inline bool isWindowType() const { return d_ptr->isWindow; } - inline bool signalsBlocked() const Q_DECL_NOTHROW { return d_ptr->blockSig; } - bool blockSignals(bool b) Q_DECL_NOTHROW; + inline bool signalsBlocked() const noexcept { return d_ptr->blockSig; } + bool blockSignals(bool b) noexcept; QThread *thread() const; void moveToThread(QThread *thread); @@ -436,7 +436,7 @@ protected: QScopedPointer d_ptr; static const QMetaObject staticQtMetaObject; - friend inline const QMetaObject *qt_getQtMetaObject() Q_DECL_NOEXCEPT; + friend inline const QMetaObject *qt_getQtMetaObject() noexcept; friend struct QMetaObject; friend struct QMetaObjectPrivate; @@ -467,7 +467,7 @@ inline QMetaObject::Connection QObject::connect(const QObject *asender, const ch const char *amember, Qt::ConnectionType atype) const { return connect(asender, asignal, this, amember, atype); } -inline const QMetaObject *qt_getQtMetaObject() Q_DECL_NOEXCEPT +inline const QMetaObject *qt_getQtMetaObject() noexcept { return &QObject::staticQtMetaObject; } #ifndef QT_NO_USERDATA @@ -540,17 +540,17 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QObject *); class QSignalBlocker { public: - inline explicit QSignalBlocker(QObject *o) Q_DECL_NOTHROW; - inline explicit QSignalBlocker(QObject &o) Q_DECL_NOTHROW; + inline explicit QSignalBlocker(QObject *o) noexcept; + inline explicit QSignalBlocker(QObject &o) noexcept; inline ~QSignalBlocker(); #ifdef Q_COMPILER_RVALUE_REFS - inline QSignalBlocker(QSignalBlocker &&other) Q_DECL_NOTHROW; - inline QSignalBlocker &operator=(QSignalBlocker &&other) Q_DECL_NOTHROW; + inline QSignalBlocker(QSignalBlocker &&other) noexcept; + inline QSignalBlocker &operator=(QSignalBlocker &&other) noexcept; #endif - inline void reblock() Q_DECL_NOTHROW; - inline void unblock() Q_DECL_NOTHROW; + inline void reblock() noexcept; + inline void unblock() noexcept; private: Q_DISABLE_COPY(QSignalBlocker) QObject * m_o; @@ -558,20 +558,20 @@ private: bool m_inhibited; }; -QSignalBlocker::QSignalBlocker(QObject *o) Q_DECL_NOTHROW +QSignalBlocker::QSignalBlocker(QObject *o) noexcept : m_o(o), m_blocked(o && o->blockSignals(true)), m_inhibited(false) {} -QSignalBlocker::QSignalBlocker(QObject &o) Q_DECL_NOTHROW +QSignalBlocker::QSignalBlocker(QObject &o) noexcept : m_o(&o), m_blocked(o.blockSignals(true)), m_inhibited(false) {} #ifdef Q_COMPILER_RVALUE_REFS -QSignalBlocker::QSignalBlocker(QSignalBlocker &&other) Q_DECL_NOTHROW +QSignalBlocker::QSignalBlocker(QSignalBlocker &&other) noexcept : m_o(other.m_o), m_blocked(other.m_blocked), m_inhibited(other.m_inhibited) @@ -579,7 +579,7 @@ QSignalBlocker::QSignalBlocker(QSignalBlocker &&other) Q_DECL_NOTHROW other.m_o = nullptr; } -QSignalBlocker &QSignalBlocker::operator=(QSignalBlocker &&other) Q_DECL_NOTHROW +QSignalBlocker &QSignalBlocker::operator=(QSignalBlocker &&other) noexcept { if (this != &other) { // if both *this and other block the same object's signals: @@ -602,13 +602,13 @@ QSignalBlocker::~QSignalBlocker() m_o->blockSignals(m_blocked); } -void QSignalBlocker::reblock() Q_DECL_NOTHROW +void QSignalBlocker::reblock() noexcept { if (m_o) m_o->blockSignals(true); m_inhibited = false; } -void QSignalBlocker::unblock() Q_DECL_NOTHROW +void QSignalBlocker::unblock() noexcept { if (m_o) m_o->blockSignals(m_blocked); m_inhibited = true; diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index d7ed2b0282..a437a994fd 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -119,13 +119,13 @@ class QString; #define Q_ENUMS(x) QT_ANNOTATE_CLASS(qt_enums, x) #define Q_FLAGS(x) QT_ANNOTATE_CLASS(qt_enums, x) #define Q_ENUM_IMPL(ENUM) \ - friend Q_DECL_CONSTEXPR const QMetaObject *qt_getEnumMetaObject(ENUM) Q_DECL_NOEXCEPT { return &staticMetaObject; } \ - friend Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) Q_DECL_NOEXCEPT { return #ENUM; } + friend Q_DECL_CONSTEXPR const QMetaObject *qt_getEnumMetaObject(ENUM) noexcept { return &staticMetaObject; } \ + friend Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) noexcept { return #ENUM; } #define Q_ENUM(x) Q_ENUMS(x) Q_ENUM_IMPL(x) #define Q_FLAG(x) Q_FLAGS(x) Q_ENUM_IMPL(x) #define Q_ENUM_NS_IMPL(ENUM) \ - inline Q_DECL_CONSTEXPR const QMetaObject *qt_getEnumMetaObject(ENUM) Q_DECL_NOEXCEPT { return &staticMetaObject; } \ - inline Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) Q_DECL_NOEXCEPT { return #ENUM; } + inline Q_DECL_CONSTEXPR const QMetaObject *qt_getEnumMetaObject(ENUM) noexcept { return &staticMetaObject; } \ + inline Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) noexcept { return #ENUM; } #define Q_ENUM_NS(x) Q_ENUMS(x) Q_ENUM_NS_IMPL(x) #define Q_FLAG_NS(x) Q_FLAGS(x) Q_ENUM_NS_IMPL(x) #define Q_SCRIPTABLE QT_ANNOTATE_FUNCTION(qt_scriptable) @@ -340,7 +340,7 @@ struct Q_CORE_EXPORT QMetaObject const char *className() const; const QMetaObject *superClass() const; - bool inherits(const QMetaObject *metaObject) const Q_DECL_NOEXCEPT; + bool inherits(const QMetaObject *metaObject) const noexcept; QObject *cast(QObject *obj) const; const QObject *cast(const QObject *obj) const; @@ -605,8 +605,8 @@ public: operator RestrictedBool() const { return d_ptr && isConnected_helper() ? &Connection::d_ptr : nullptr; } #endif - Connection(Connection &&o) Q_DECL_NOTHROW : d_ptr(o.d_ptr) { o.d_ptr = nullptr; } - Connection &operator=(Connection &&other) Q_DECL_NOTHROW + Connection(Connection &&o) noexcept : d_ptr(o.d_ptr) { o.d_ptr = nullptr; } + Connection &operator=(Connection &&other) noexcept { qSwap(d_ptr, other.d_ptr); return *this; } }; diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h index aa6bd84e95..31ecc8b20d 100644 --- a/src/corelib/kernel/qobjectdefs_impl.h +++ b/src/corelib/kernel/qobjectdefs_impl.h @@ -386,8 +386,8 @@ namespace QtPrivate { public: explicit QSlotObjectBase(ImplFn fn) : m_ref(1), m_impl(fn) {} - inline int ref() Q_DECL_NOTHROW { return m_ref.ref(); } - inline void destroyIfLastRef() Q_DECL_NOTHROW + inline int ref() noexcept { return m_ref.ref(); } + inline void destroyIfLastRef() noexcept { if (!m_ref.deref()) m_impl(Destroy, this, nullptr, nullptr, nullptr); } inline bool compare(void **a) { bool ret = false; m_impl(Compare, this, nullptr, a, &ret); return ret; } diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h index 66f317c567..ae5552f1c9 100644 --- a/src/corelib/kernel/qtimer.h +++ b/src/corelib/kernel/qtimer.h @@ -218,7 +218,7 @@ private: inline int startTimer(int){ return -1;} inline void killTimer(int){} - static Q_DECL_CONSTEXPR Qt::TimerType defaultTypeFor(int msecs) Q_DECL_NOTHROW + static Q_DECL_CONSTEXPR Qt::TimerType defaultTypeFor(int msecs) noexcept { return msecs >= 2000 ? Qt::CoarseTimer : Qt::PreciseTimer; } static void singleShotImpl(int msec, Qt::TimerType timerType, const QObject *receiver, QtPrivate::QSlotObjectBase *slotObj); diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 90f5f5fc34..6b35bfa9e9 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -201,7 +201,7 @@ class Q_CORE_EXPORT QVariant LastType = 0xffffffff // need this so that gcc >= 3.4 allocates 32 bits for Type }; - QVariant() Q_DECL_NOTHROW : d() {} + QVariant() noexcept : d() {} ~QVariant(); QVariant(Type type); QVariant(int typeId, const void *copy); @@ -268,13 +268,13 @@ class Q_CORE_EXPORT QVariant QVariant& operator=(const QVariant &other); #ifdef Q_COMPILER_RVALUE_REFS - inline QVariant(QVariant &&other) Q_DECL_NOTHROW : d(other.d) + inline QVariant(QVariant &&other) noexcept : d(other.d) { other.d = Private(); } - inline QVariant &operator=(QVariant &&other) Q_DECL_NOTHROW + inline QVariant &operator=(QVariant &&other) noexcept { qSwap(d, other.d); return *this; } #endif - inline void swap(QVariant &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + inline void swap(QVariant &other) noexcept { qSwap(d, other.d); } Type type() const; int userType() const; @@ -387,15 +387,15 @@ class Q_CORE_EXPORT QVariant }; struct Private { - inline Private() Q_DECL_NOTHROW : type(Invalid), is_shared(false), is_null(true) + inline Private() noexcept : type(Invalid), is_shared(false), is_null(true) { data.ptr = nullptr; } // Internal constructor for initialized variants. - explicit inline Private(uint variantType) Q_DECL_NOTHROW + explicit inline Private(uint variantType) noexcept : type(variantType), is_shared(false), is_null(false) {} - inline Private(const Private &other) Q_DECL_NOTHROW + inline Private(const Private &other) noexcept : data(other.data), type(other.type), is_shared(other.is_shared), is_null(other.is_null) {} diff --git a/src/corelib/mimetypes/qmimeglobpattern_p.h b/src/corelib/mimetypes/qmimeglobpattern_p.h index bb6f64320b..cf27d6ab30 100644 --- a/src/corelib/mimetypes/qmimeglobpattern_p.h +++ b/src/corelib/mimetypes/qmimeglobpattern_p.h @@ -88,7 +88,7 @@ public: { } - void swap(QMimeGlobPattern &other) Q_DECL_NOTHROW + void swap(QMimeGlobPattern &other) noexcept { qSwap(m_pattern, other.m_pattern); qSwap(m_mimeType, other.m_mimeType); diff --git a/src/corelib/mimetypes/qmimemagicrule_p.h b/src/corelib/mimetypes/qmimemagicrule_p.h index 6962a6ca59..5091d483b6 100644 --- a/src/corelib/mimetypes/qmimemagicrule_p.h +++ b/src/corelib/mimetypes/qmimemagicrule_p.h @@ -69,7 +69,7 @@ public: QMimeMagicRule(const QString &typeStr, const QByteArray &value, const QString &offsets, const QByteArray &mask, QString *errorString); - void swap(QMimeMagicRule &other) Q_DECL_NOTHROW + void swap(QMimeMagicRule &other) noexcept { qSwap(m_type, other.m_type); qSwap(m_value, other.m_value); diff --git a/src/corelib/mimetypes/qmimemagicrulematcher_p.h b/src/corelib/mimetypes/qmimemagicrulematcher_p.h index 5e74e2e3fc..fe714987e6 100644 --- a/src/corelib/mimetypes/qmimemagicrulematcher_p.h +++ b/src/corelib/mimetypes/qmimemagicrulematcher_p.h @@ -66,7 +66,7 @@ class QMimeMagicRuleMatcher public: explicit QMimeMagicRuleMatcher(const QString &mime, unsigned priority = 65535); - void swap(QMimeMagicRuleMatcher &other) Q_DECL_NOTHROW + void swap(QMimeMagicRuleMatcher &other) noexcept { qSwap(m_list, other.m_list); qSwap(m_priority, other.m_priority); diff --git a/src/corelib/mimetypes/qmimetype.cpp b/src/corelib/mimetypes/qmimetype.cpp index 55c7de0c87..cf01c9503b 100644 --- a/src/corelib/mimetypes/qmimetype.cpp +++ b/src/corelib/mimetypes/qmimetype.cpp @@ -192,7 +192,7 @@ bool QMimeType::operator==(const QMimeType &other) const Returns the hash value for \a key, using \a seed to seed the calculation. */ -uint qHash(const QMimeType &key, uint seed) Q_DECL_NOTHROW +uint qHash(const QMimeType &key, uint seed) noexcept { return qHash(key.d->name, seed); } diff --git a/src/corelib/mimetypes/qmimetype.h b/src/corelib/mimetypes/qmimetype.h index 8287f1434b..c496af7d58 100644 --- a/src/corelib/mimetypes/qmimetype.h +++ b/src/corelib/mimetypes/qmimetype.h @@ -55,7 +55,7 @@ class QMimeTypePrivate; class QStringList; class QMimeType; -Q_CORE_EXPORT uint qHash(const QMimeType &key, uint seed = 0) Q_DECL_NOTHROW; +Q_CORE_EXPORT uint qHash(const QMimeType &key, uint seed = 0) noexcept; class Q_CORE_EXPORT QMimeType { @@ -79,9 +79,9 @@ public: QMimeType(const QMimeType &other); QMimeType &operator=(const QMimeType &other); #ifdef Q_COMPILER_RVALUE_REFS - QMimeType &operator=(QMimeType &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QMimeType &operator=(QMimeType &&other) noexcept { swap(other); return *this; } #endif - void swap(QMimeType &other) Q_DECL_NOTHROW + void swap(QMimeType &other) noexcept { qSwap(d, other.d); } @@ -121,7 +121,7 @@ protected: friend class QMimeXMLProvider; friend class QMimeBinaryProvider; friend class QMimeTypePrivate; - friend Q_CORE_EXPORT uint qHash(const QMimeType &key, uint seed) Q_DECL_NOTHROW; + friend Q_CORE_EXPORT uint qHash(const QMimeType &key, uint seed) noexcept; QExplicitlySharedDataPointer d; }; diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index 8bb5e1463a..83873edf6f 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -397,7 +397,7 @@ QUuid::QUuid(const QString &text) \sa toString(), QUuid() */ -QUuid QUuid::fromString(QStringView text) Q_DECL_NOTHROW +QUuid QUuid::fromString(QStringView text) noexcept { if (text.size() > MaxStringUuidLength) text = text.left(MaxStringUuidLength); // text.truncate(MaxStringUuidLength); @@ -427,7 +427,7 @@ QUuid QUuid::fromString(QStringView text) Q_DECL_NOTHROW \sa toString(), QUuid() */ -QUuid QUuid::fromString(QLatin1String text) Q_DECL_NOTHROW +QUuid QUuid::fromString(QLatin1String text) noexcept { if (Q_UNLIKELY(text.size() < MaxStringUuidLength - 2 || (text.front() == QLatin1Char('{') && text.size() < MaxStringUuidLength - 1))) { @@ -864,7 +864,7 @@ QDataStream &operator>>(QDataStream &s, QUuid &id) Returns \c true if this is the null UUID {00000000-0000-0000-0000-000000000000}; otherwise returns \c false. */ -bool QUuid::isNull() const Q_DECL_NOTHROW +bool QUuid::isNull() const noexcept { return data4[0] == 0 && data4[1] == 0 && data4[2] == 0 && data4[3] == 0 && data4[4] == 0 && data4[5] == 0 && data4[6] == 0 && data4[7] == 0 && @@ -913,7 +913,7 @@ bool QUuid::isNull() const Q_DECL_NOTHROW \sa version() */ -QUuid::Variant QUuid::variant() const Q_DECL_NOTHROW +QUuid::Variant QUuid::variant() const noexcept { if (isNull()) return VarUnknown; @@ -934,7 +934,7 @@ QUuid::Variant QUuid::variant() const Q_DECL_NOTHROW \sa variant() */ -QUuid::Version QUuid::version() const Q_DECL_NOTHROW +QUuid::Version QUuid::version() const noexcept { // Check the 4 MSB of data3 Version ver = (Version)(data3>>12); @@ -957,7 +957,7 @@ QUuid::Version QUuid::version() const Q_DECL_NOTHROW \sa variant() */ -bool QUuid::operator<(const QUuid &other) const Q_DECL_NOTHROW +bool QUuid::operator<(const QUuid &other) const noexcept { if (variant() != other.variant()) return variant() < other.variant(); @@ -984,7 +984,7 @@ bool QUuid::operator<(const QUuid &other) const Q_DECL_NOTHROW \sa variant() */ -bool QUuid::operator>(const QUuid &other) const Q_DECL_NOTHROW +bool QUuid::operator>(const QUuid &other) const noexcept { return other < *this; } @@ -1089,7 +1089,7 @@ QDebug operator<<(QDebug dbg, const QUuid &id) \relates QUuid Returns a hash of the UUID \a uuid, using \a seed to seed the calculation. */ -uint qHash(const QUuid &uuid, uint seed) Q_DECL_NOTHROW +uint qHash(const QUuid &uuid, uint seed) noexcept { return uuid.data1 ^ uuid.data2 ^ (uuid.data3 << 16) ^ ((uuid.data4[0] << 24) | (uuid.data4[1] << 16) | (uuid.data4[2] << 8) | uuid.data4[3]) diff --git a/src/corelib/plugin/quuid.h b/src/corelib/plugin/quuid.h index 08a1843640..713ca070c8 100644 --- a/src/corelib/plugin/quuid.h +++ b/src/corelib/plugin/quuid.h @@ -93,13 +93,13 @@ public: #if defined(Q_COMPILER_UNIFORM_INIT) && !defined(Q_CLANG_QDOC) - Q_DECL_CONSTEXPR QUuid() Q_DECL_NOTHROW : data1(0), data2(0), data3(0), data4{0,0,0,0,0,0,0,0} {} + Q_DECL_CONSTEXPR QUuid() noexcept : data1(0), data2(0), data3(0), data4{0,0,0,0,0,0,0,0} {} Q_DECL_CONSTEXPR QUuid(uint l, ushort w1, ushort w2, uchar b1, uchar b2, uchar b3, - uchar b4, uchar b5, uchar b6, uchar b7, uchar b8) Q_DECL_NOTHROW + uchar b4, uchar b5, uchar b6, uchar b7, uchar b8) noexcept : data1(l), data2(w1), data3(w2), data4{b1, b2, b3, b4, b5, b6, b7, b8} {} #else - QUuid() Q_DECL_NOTHROW + QUuid() noexcept { data1 = 0; data2 = 0; @@ -107,7 +107,7 @@ public: for(int i = 0; i < 8; i++) data4[i] = 0; } - QUuid(uint l, ushort w1, ushort w2, uchar b1, uchar b2, uchar b3, uchar b4, uchar b5, uchar b6, uchar b7, uchar b8) Q_DECL_NOTHROW + QUuid(uint l, ushort w1, ushort w2, uchar b1, uchar b2, uchar b3, uchar b4, uchar b5, uchar b6, uchar b7, uchar b8) noexcept { data1 = l; data2 = w1; @@ -124,8 +124,8 @@ public: #endif QUuid(const QString &); - static QUuid fromString(QStringView string) Q_DECL_NOTHROW; - static QUuid fromString(QLatin1String string) Q_DECL_NOTHROW; + static QUuid fromString(QStringView string) noexcept; + static QUuid fromString(QLatin1String string) noexcept; QUuid(const char *); QString toString() const; QString toString(StringFormat mode) const; // ### Qt6: merge with previous @@ -134,9 +134,9 @@ public: QByteArray toByteArray(StringFormat mode) const; // ### Qt6: merge with previous QByteArray toRfc4122() const; static QUuid fromRfc4122(const QByteArray &); - bool isNull() const Q_DECL_NOTHROW; + bool isNull() const noexcept; - Q_DECL_RELAXED_CONSTEXPR bool operator==(const QUuid &orig) const Q_DECL_NOTHROW + Q_DECL_RELAXED_CONSTEXPR bool operator==(const QUuid &orig) const noexcept { if (data1 != orig.data1 || data2 != orig.data2 || data3 != orig.data3) @@ -149,24 +149,24 @@ public: return true; } - Q_DECL_RELAXED_CONSTEXPR bool operator!=(const QUuid &orig) const Q_DECL_NOTHROW + Q_DECL_RELAXED_CONSTEXPR bool operator!=(const QUuid &orig) const noexcept { return !(*this == orig); } - bool operator<(const QUuid &other) const Q_DECL_NOTHROW; - bool operator>(const QUuid &other) const Q_DECL_NOTHROW; + bool operator<(const QUuid &other) const noexcept; + bool operator>(const QUuid &other) const noexcept; #if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC) // On Windows we have a type GUID that is used by the platform API, so we // provide convenience operators to cast from and to this type. #if defined(Q_COMPILER_UNIFORM_INIT) && !defined(Q_CLANG_QDOC) - Q_DECL_CONSTEXPR QUuid(const GUID &guid) Q_DECL_NOTHROW + Q_DECL_CONSTEXPR QUuid(const GUID &guid) noexcept : data1(guid.Data1), data2(guid.Data2), data3(guid.Data3), data4{guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]} {} #else - QUuid(const GUID &guid) Q_DECL_NOTHROW + QUuid(const GUID &guid) noexcept { data1 = guid.Data1; data2 = guid.Data2; @@ -176,24 +176,24 @@ public: } #endif - Q_DECL_RELAXED_CONSTEXPR QUuid &operator=(const GUID &guid) Q_DECL_NOTHROW + Q_DECL_RELAXED_CONSTEXPR QUuid &operator=(const GUID &guid) noexcept { *this = QUuid(guid); return *this; } - Q_DECL_RELAXED_CONSTEXPR operator GUID() const Q_DECL_NOTHROW + Q_DECL_RELAXED_CONSTEXPR operator GUID() const noexcept { GUID guid = { data1, data2, data3, { data4[0], data4[1], data4[2], data4[3], data4[4], data4[5], data4[6], data4[7] } }; return guid; } - Q_DECL_RELAXED_CONSTEXPR bool operator==(const GUID &guid) const Q_DECL_NOTHROW + Q_DECL_RELAXED_CONSTEXPR bool operator==(const GUID &guid) const noexcept { return *this == QUuid(guid); } - Q_DECL_RELAXED_CONSTEXPR bool operator!=(const GUID &guid) const Q_DECL_NOTHROW + Q_DECL_RELAXED_CONSTEXPR bool operator!=(const GUID &guid) const noexcept { return !(*this == guid); } @@ -216,8 +216,8 @@ public: } - QUuid::Variant variant() const Q_DECL_NOTHROW; - QUuid::Version version() const Q_DECL_NOTHROW; + QUuid::Variant variant() const noexcept; + QUuid::Version version() const noexcept; #if defined(Q_OS_DARWIN) || defined(Q_CLANG_QDOC) static QUuid fromCFUUID(CFUUIDRef uuid); @@ -243,11 +243,11 @@ Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QUuid &); Q_CORE_EXPORT QDebug operator<<(QDebug, const QUuid &); #endif -Q_CORE_EXPORT uint qHash(const QUuid &uuid, uint seed = 0) Q_DECL_NOTHROW; +Q_CORE_EXPORT uint qHash(const QUuid &uuid, uint seed = 0) noexcept; -inline bool operator<=(const QUuid &lhs, const QUuid &rhs) Q_DECL_NOTHROW +inline bool operator<=(const QUuid &lhs, const QUuid &rhs) noexcept { return !(rhs < lhs); } -inline bool operator>=(const QUuid &lhs, const QUuid &rhs) Q_DECL_NOTHROW +inline bool operator>=(const QUuid &lhs, const QUuid &rhs) noexcept { return !(lhs < rhs); } QT_END_NAMESPACE diff --git a/src/corelib/serialization/qjson_p.h b/src/corelib/serialization/qjson_p.h index a9e7059cbe..85fb2a1254 100644 --- a/src/corelib/serialization/qjson_p.h +++ b/src/corelib/serialization/qjson_p.h @@ -304,7 +304,7 @@ public: return *this; } - QLatin1String toQLatin1String() const Q_DECL_NOTHROW { + QLatin1String toQLatin1String() const noexcept { return QLatin1String(d->latin1, d->length); } @@ -339,23 +339,23 @@ public: }; #define DEF_OP(op) \ - inline bool operator op(Latin1String lhs, Latin1String rhs) Q_DECL_NOTHROW \ + inline bool operator op(Latin1String lhs, Latin1String rhs) noexcept \ { \ return lhs.toQLatin1String() op rhs.toQLatin1String(); \ } \ - inline bool operator op(QLatin1String lhs, Latin1String rhs) Q_DECL_NOTHROW \ + inline bool operator op(QLatin1String lhs, Latin1String rhs) noexcept \ { \ return lhs op rhs.toQLatin1String(); \ } \ - inline bool operator op(Latin1String lhs, QLatin1String rhs) Q_DECL_NOTHROW \ + inline bool operator op(Latin1String lhs, QLatin1String rhs) noexcept \ { \ return lhs.toQLatin1String() op rhs; \ } \ - inline bool operator op(const QString &lhs, Latin1String rhs) Q_DECL_NOTHROW \ + inline bool operator op(const QString &lhs, Latin1String rhs) noexcept \ { \ return lhs op rhs.toQLatin1String(); \ } \ - inline bool operator op(Latin1String lhs, const QString &rhs) Q_DECL_NOTHROW \ + inline bool operator op(Latin1String lhs, const QString &rhs) noexcept \ { \ return lhs.toQLatin1String() op rhs; \ } \ diff --git a/src/corelib/serialization/qjsonarray.h b/src/corelib/serialization/qjsonarray.h index ba346fb848..86b7bf9d76 100644 --- a/src/corelib/serialization/qjsonarray.h +++ b/src/corelib/serialization/qjsonarray.h @@ -72,7 +72,7 @@ public: QJsonArray(const QJsonArray &other); QJsonArray &operator =(const QJsonArray &other); - QJsonArray(QJsonArray &&other) Q_DECL_NOTHROW + QJsonArray(QJsonArray &&other) noexcept : d(other.d), a(other.a) { @@ -80,7 +80,7 @@ public: other.a = nullptr; } - QJsonArray &operator =(QJsonArray &&other) Q_DECL_NOTHROW + QJsonArray &operator =(QJsonArray &&other) noexcept { swap(other); return *this; @@ -115,7 +115,7 @@ public: bool operator==(const QJsonArray &other) const; bool operator!=(const QJsonArray &other) const; - void swap(QJsonArray &other) Q_DECL_NOTHROW + void swap(QJsonArray &other) noexcept { qSwap(d, other.d); qSwap(a, other.a); diff --git a/src/corelib/serialization/qjsondocument.h b/src/corelib/serialization/qjsondocument.h index a749439b7d..a8006a6cc5 100644 --- a/src/corelib/serialization/qjsondocument.h +++ b/src/corelib/serialization/qjsondocument.h @@ -93,19 +93,19 @@ public: QJsonDocument(const QJsonDocument &other); QJsonDocument &operator =(const QJsonDocument &other); - QJsonDocument(QJsonDocument &&other) Q_DECL_NOTHROW + QJsonDocument(QJsonDocument &&other) noexcept : d(other.d) { other.d = nullptr; } - QJsonDocument &operator =(QJsonDocument &&other) Q_DECL_NOTHROW + QJsonDocument &operator =(QJsonDocument &&other) noexcept { swap(other); return *this; } - void swap(QJsonDocument &other) Q_DECL_NOTHROW + void swap(QJsonDocument &other) noexcept { qSwap(d, other.d); } diff --git a/src/corelib/serialization/qjsonobject.h b/src/corelib/serialization/qjsonobject.h index 80fe6b2f3f..92d45cc838 100644 --- a/src/corelib/serialization/qjsonobject.h +++ b/src/corelib/serialization/qjsonobject.h @@ -74,20 +74,20 @@ public: QJsonObject(const QJsonObject &other); QJsonObject &operator =(const QJsonObject &other); - QJsonObject(QJsonObject &&other) Q_DECL_NOTHROW + QJsonObject(QJsonObject &&other) noexcept : d(other.d), o(other.o) { other.d = nullptr; other.o = nullptr; } - QJsonObject &operator =(QJsonObject &&other) Q_DECL_NOTHROW + QJsonObject &operator =(QJsonObject &&other) noexcept { swap(other); return *this; } - void swap(QJsonObject &other) Q_DECL_NOTHROW + void swap(QJsonObject &other) noexcept { qSwap(d, other.d); qSwap(o, other.o); diff --git a/src/corelib/serialization/qjsonvalue.h b/src/corelib/serialization/qjsonvalue.h index 0339eb59f7..37d84f9e60 100644 --- a/src/corelib/serialization/qjsonvalue.h +++ b/src/corelib/serialization/qjsonvalue.h @@ -92,7 +92,7 @@ public: QJsonValue(const QJsonValue &other); QJsonValue &operator =(const QJsonValue &other); - QJsonValue(QJsonValue &&other) Q_DECL_NOTHROW + QJsonValue(QJsonValue &&other) noexcept : ui(other.ui), d(other.d), t(other.t) @@ -102,13 +102,13 @@ public: other.t = Null; } - QJsonValue &operator =(QJsonValue &&other) Q_DECL_NOTHROW + QJsonValue &operator =(QJsonValue &&other) noexcept { swap(other); return *this; } - void swap(QJsonValue &other) Q_DECL_NOTHROW + void swap(QJsonValue &other) noexcept { qSwap(ui, other.ui); qSwap(d, other.d); diff --git a/src/corelib/serialization/qtextstream.h b/src/corelib/serialization/qtextstream.h index 7673e5d87e..4efa84f1f1 100644 --- a/src/corelib/serialization/qtextstream.h +++ b/src/corelib/serialization/qtextstream.h @@ -213,8 +213,8 @@ typedef void (QTextStream::*QTSMFC)(QChar); // manipulator w/QChar argument class Q_CORE_EXPORT QTextStreamManipulator { public: - Q_DECL_CONSTEXPR QTextStreamManipulator(QTSMFI m, int a) Q_DECL_NOTHROW : mf(m), mc(nullptr), arg(a), ch() {} - Q_DECL_CONSTEXPR QTextStreamManipulator(QTSMFC m, QChar c) Q_DECL_NOTHROW : mf(nullptr), mc(m), arg(-1), ch(c) {} + Q_DECL_CONSTEXPR QTextStreamManipulator(QTSMFI m, int a) noexcept : mf(m), mc(nullptr), arg(a), ch() {} + Q_DECL_CONSTEXPR QTextStreamManipulator(QTSMFC m, QChar c) noexcept : mf(nullptr), mc(m), arg(-1), ch(c) {} void exec(QTextStream &s) { if (mf) { (s.*mf)(arg); } else { (s.*mc)(ch); } } private: diff --git a/src/corelib/serialization/qxmlstream.h b/src/corelib/serialization/qxmlstream.h index d30c6bc01f..fedd149fd0 100644 --- a/src/corelib/serialization/qxmlstream.h +++ b/src/corelib/serialization/qxmlstream.h @@ -60,16 +60,16 @@ public: :m_string(aString.string()?*aString.string():QString()), m_position(aString.position()), m_size(aString.size()){} QXmlStreamStringRef(const QString &aString) : m_string(aString), m_position(0), m_size(m_string.size()) {} #ifdef Q_COMPILER_RVALUE_REFS - QXmlStreamStringRef(QString &&aString) Q_DECL_NOTHROW : m_string(std::move(aString)), m_position(0), m_size(m_string.size()) {} + QXmlStreamStringRef(QString &&aString) noexcept : m_string(std::move(aString)), m_position(0), m_size(m_string.size()) {} #endif #if QT_VERSION < QT_VERSION_CHECK(6,0,0) QXmlStreamStringRef(const QXmlStreamStringRef &other) // = default : m_string(other.m_string), m_position(other.m_position), m_size(other.m_size) {} #ifdef Q_COMPILER_RVALUE_REFS - QXmlStreamStringRef(QXmlStreamStringRef &&other) Q_DECL_NOTHROW // = default + QXmlStreamStringRef(QXmlStreamStringRef &&other) noexcept // = default : m_string(std::move(other.m_string)), m_position(other.m_position), m_size(other.m_size) {} - QXmlStreamStringRef &operator=(QXmlStreamStringRef &&other) Q_DECL_NOTHROW // = default + QXmlStreamStringRef &operator=(QXmlStreamStringRef &&other) noexcept // = default { swap(other); return *this; } #endif QXmlStreamStringRef &operator=(const QXmlStreamStringRef &other) // = default @@ -79,7 +79,7 @@ public: // ### Qt 5, since that would change the way its passed to functions. In Qt 6, remove all. #endif // Qt < 6.0 - void swap(QXmlStreamStringRef &other) Q_DECL_NOTHROW + void swap(QXmlStreamStringRef &other) noexcept { qSwap(m_string, other.m_string); qSwap(m_position, other.m_position); @@ -112,7 +112,7 @@ public: QXmlStreamAttribute(const QString &namespaceUri, const QString &name, const QString &value); QXmlStreamAttribute(const QXmlStreamAttribute &); #ifdef Q_COMPILER_RVALUE_REFS - QXmlStreamAttribute(QXmlStreamAttribute &&other) Q_DECL_NOTHROW // = default; + QXmlStreamAttribute(QXmlStreamAttribute &&other) noexcept // = default; : m_name(std::move(other.m_name)), m_namespaceUri(std::move(other.m_namespaceUri)), m_qualifiedName(std::move(other.m_qualifiedName)), @@ -122,7 +122,7 @@ public: { other.reserved = nullptr; } - QXmlStreamAttribute &operator=(QXmlStreamAttribute &&other) Q_DECL_NOTHROW // = default; + QXmlStreamAttribute &operator=(QXmlStreamAttribute &&other) noexcept // = default; { m_name = std::move(other.m_name); m_namespaceUri = std::move(other.m_namespaceUri); @@ -199,14 +199,14 @@ public: QXmlStreamNamespaceDeclaration(); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QXmlStreamNamespaceDeclaration(const QXmlStreamNamespaceDeclaration &); - QXmlStreamNamespaceDeclaration(QXmlStreamNamespaceDeclaration &&other) Q_DECL_NOTHROW // = default + QXmlStreamNamespaceDeclaration(QXmlStreamNamespaceDeclaration &&other) noexcept // = default : m_prefix(std::move(other.m_prefix)), m_namespaceUri(std::move(other.m_namespaceUri)), reserved(other.reserved) { other.reserved = nullptr; } - QXmlStreamNamespaceDeclaration &operator=(QXmlStreamNamespaceDeclaration &&other) Q_DECL_NOTHROW // = default + QXmlStreamNamespaceDeclaration &operator=(QXmlStreamNamespaceDeclaration &&other) noexcept // = default { m_prefix = std::move(other.m_prefix); m_namespaceUri = std::move(other.m_namespaceUri); @@ -242,7 +242,7 @@ public: #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) ~QXmlStreamNotationDeclaration(); QXmlStreamNotationDeclaration(const QXmlStreamNotationDeclaration &); - QXmlStreamNotationDeclaration(QXmlStreamNotationDeclaration &&other) Q_DECL_NOTHROW // = default + QXmlStreamNotationDeclaration(QXmlStreamNotationDeclaration &&other) noexcept // = default : m_name(std::move(other.m_name)), m_systemId(std::move(other.m_systemId)), m_publicId(std::move(other.m_publicId)), @@ -251,7 +251,7 @@ public: other.reserved = nullptr; } QXmlStreamNotationDeclaration& operator=(const QXmlStreamNotationDeclaration &); - QXmlStreamNotationDeclaration &operator=(QXmlStreamNotationDeclaration &&other) Q_DECL_NOTHROW // = default + QXmlStreamNotationDeclaration &operator=(QXmlStreamNotationDeclaration &&other) noexcept // = default { m_name = std::move(other.m_name); m_systemId = std::move(other.m_systemId); @@ -287,7 +287,7 @@ public: #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) ~QXmlStreamEntityDeclaration(); QXmlStreamEntityDeclaration(const QXmlStreamEntityDeclaration &); - QXmlStreamEntityDeclaration(QXmlStreamEntityDeclaration &&other) Q_DECL_NOTHROW // = default + QXmlStreamEntityDeclaration(QXmlStreamEntityDeclaration &&other) noexcept // = default : m_name(std::move(other.m_name)), m_notationName(std::move(other.m_notationName)), m_systemId(std::move(other.m_systemId)), @@ -298,7 +298,7 @@ public: other.reserved = nullptr; } QXmlStreamEntityDeclaration& operator=(const QXmlStreamEntityDeclaration &); - QXmlStreamEntityDeclaration &operator=(QXmlStreamEntityDeclaration &&other) Q_DECL_NOTHROW // = default + QXmlStreamEntityDeclaration &operator=(QXmlStreamEntityDeclaration &&other) noexcept // = default { m_name = std::move(other.m_name); m_notationName = std::move(other.m_notationName); diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h index c66130b8ce..3d12477c87 100644 --- a/src/corelib/statemachine/qstatemachine_p.h +++ b/src/corelib/statemachine/qstatemachine_p.h @@ -222,14 +222,14 @@ public: { return qHash(qMakePair(key.obj, key.prop), seed); } friend uint qHash(const RestorableId &key) Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(key, 0U))) { return qHash(key, 0U); } - friend bool operator==(const RestorableId &lhs, const RestorableId &rhs) Q_DECL_NOTHROW + friend bool operator==(const RestorableId &lhs, const RestorableId &rhs) noexcept { return lhs.obj == rhs.obj && lhs.prop == rhs.prop; } - friend bool operator!=(const RestorableId &lhs, const RestorableId &rhs) Q_DECL_NOTHROW + friend bool operator!=(const RestorableId &lhs, const RestorableId &rhs) noexcept { return !operator==(lhs, rhs); } public: - explicit RestorableId(QObject *o, QByteArray p) Q_DECL_NOTHROW : guard(o), obj(o), prop(qMove(p)) {} - QObject *object() const Q_DECL_NOTHROW { return guard; } - QByteArray propertyName() const Q_DECL_NOTHROW { return prop; } + explicit RestorableId(QObject *o, QByteArray p) noexcept : guard(o), obj(o), prop(qMove(p)) {} + QObject *object() const noexcept { return guard; } + QByteArray propertyName() const noexcept { return prop; } }; QHash > registeredRestorablesForState; bool hasRestorable(QAbstractState *state, QObject *object, const QByteArray &propertyName) const; @@ -271,7 +271,7 @@ public: QList handledAnimations; QList localResetEndValues; - void swap(InitializeAnimationResult &other) Q_DECL_NOTHROW + void swap(InitializeAnimationResult &other) noexcept { qSwap(handledAnimations, other.handledAnimations); qSwap(localResetEndValues, other.localResetEndValues); diff --git a/src/corelib/thread/qatomic.h b/src/corelib/thread/qatomic.h index f842534c38..280ce96b76 100644 --- a/src/corelib/thread/qatomic.h +++ b/src/corelib/thread/qatomic.h @@ -57,15 +57,15 @@ class QAtomicInteger : public QBasicAtomicInteger public: // Non-atomic API #ifdef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS - constexpr QAtomicInteger(T value = 0) Q_DECL_NOTHROW : QBasicAtomicInteger(value) {} + constexpr QAtomicInteger(T value = 0) noexcept : QBasicAtomicInteger(value) {} #else - inline QAtomicInteger(T value = 0) Q_DECL_NOTHROW + inline QAtomicInteger(T value = 0) noexcept { this->_q_value = value; } #endif - inline QAtomicInteger(const QAtomicInteger &other) Q_DECL_NOTHROW + inline QAtomicInteger(const QAtomicInteger &other) noexcept #ifdef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS : QBasicAtomicInteger() #endif @@ -73,7 +73,7 @@ public: this->storeRelease(other.loadAcquire()); } - inline QAtomicInteger &operator=(const QAtomicInteger &other) Q_DECL_NOTHROW + inline QAtomicInteger &operator=(const QAtomicInteger &other) noexcept { this->storeRelease(other.loadAcquire()); return *this; @@ -159,7 +159,7 @@ public: #ifdef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS constexpr #endif - QAtomicInt(int value = 0) Q_DECL_NOTHROW : QAtomicInteger(value) {} + QAtomicInt(int value = 0) noexcept : QAtomicInteger(value) {} }; // High-level atomic pointer operations @@ -168,14 +168,14 @@ class QAtomicPointer : public QBasicAtomicPointer { public: #ifdef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS - constexpr QAtomicPointer(T *value = nullptr) Q_DECL_NOTHROW : QBasicAtomicPointer(value) {} + constexpr QAtomicPointer(T *value = nullptr) noexcept : QBasicAtomicPointer(value) {} #else - inline QAtomicPointer(T *value = nullptr) Q_DECL_NOTHROW + inline QAtomicPointer(T *value = nullptr) noexcept { this->store(value); } #endif - inline QAtomicPointer(const QAtomicPointer &other) Q_DECL_NOTHROW + inline QAtomicPointer(const QAtomicPointer &other) noexcept #ifdef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS : QBasicAtomicPointer() #endif @@ -183,7 +183,7 @@ public: this->storeRelease(other.loadAcquire()); } - inline QAtomicPointer &operator=(const QAtomicPointer &other) Q_DECL_NOTHROW + inline QAtomicPointer &operator=(const QAtomicPointer &other) noexcept { this->storeRelease(other.loadAcquire()); return *this; diff --git a/src/corelib/thread/qatomic_bootstrap.h b/src/corelib/thread/qatomic_bootstrap.h index 27a67fb2ee..c4279ee7b1 100644 --- a/src/corelib/thread/qatomic_bootstrap.h +++ b/src/corelib/thread/qatomic_bootstrap.h @@ -56,16 +56,16 @@ template struct QAtomicOps: QGenericAtomicOps > { typedef T Type; - static bool ref(T &_q_value) Q_DECL_NOTHROW + static bool ref(T &_q_value) noexcept { return ++_q_value != 0; } - static bool deref(T &_q_value) Q_DECL_NOTHROW + static bool deref(T &_q_value) noexcept { return --_q_value != 0; } - static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue = nullptr) Q_DECL_NOTHROW + static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue = nullptr) noexcept { if (currentValue) *currentValue = _q_value; @@ -76,7 +76,7 @@ template struct QAtomicOps: QGenericAtomicOps > return false; } - static T fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW + static T fetchAndStoreRelaxed(T &_q_value, T newValue) noexcept { T tmp = _q_value; _q_value = newValue; @@ -84,7 +84,7 @@ template struct QAtomicOps: QGenericAtomicOps > } template static - T fetchAndAddRelaxed(T &_q_value, AdditiveType valueToAdd) Q_DECL_NOTHROW + T fetchAndAddRelaxed(T &_q_value, AdditiveType valueToAdd) noexcept { T returnValue = _q_value; _q_value += valueToAdd; diff --git a/src/corelib/thread/qatomic_cxx11.h b/src/corelib/thread/qatomic_cxx11.h index 2fc0bf5419..32d27734fc 100644 --- a/src/corelib/thread/qatomic_cxx11.h +++ b/src/corelib/thread/qatomic_cxx11.h @@ -222,43 +222,43 @@ template struct QAtomicOps typedef std::atomic Type; template static inline - T load(const std::atomic &_q_value) Q_DECL_NOTHROW + T load(const std::atomic &_q_value) noexcept { return _q_value.load(std::memory_order_relaxed); } template static inline - T load(const volatile std::atomic &_q_value) Q_DECL_NOTHROW + T load(const volatile std::atomic &_q_value) noexcept { return _q_value.load(std::memory_order_relaxed); } template static inline - T loadAcquire(const std::atomic &_q_value) Q_DECL_NOTHROW + T loadAcquire(const std::atomic &_q_value) noexcept { return _q_value.load(std::memory_order_acquire); } template static inline - T loadAcquire(const volatile std::atomic &_q_value) Q_DECL_NOTHROW + T loadAcquire(const volatile std::atomic &_q_value) noexcept { return _q_value.load(std::memory_order_acquire); } template static inline - void store(std::atomic &_q_value, T newValue) Q_DECL_NOTHROW + void store(std::atomic &_q_value, T newValue) noexcept { _q_value.store(newValue, std::memory_order_relaxed); } template static inline - void storeRelease(std::atomic &_q_value, T newValue) Q_DECL_NOTHROW + void storeRelease(std::atomic &_q_value, T newValue) noexcept { _q_value.store(newValue, std::memory_order_release); } - static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW { return isTestAndSetNative(); } - static inline Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() Q_DECL_NOTHROW { return false; } + static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() noexcept { return isTestAndSetNative(); } + static inline Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() noexcept { return false; } template static inline bool ref(std::atomic &_q_value) { @@ -266,17 +266,17 @@ template struct QAtomicOps } template - static inline bool deref(std::atomic &_q_value) Q_DECL_NOTHROW + static inline bool deref(std::atomic &_q_value) noexcept { return --_q_value != 0; } - static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW + static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() noexcept { return QAtomicTraits::isLockFree(); } - static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; } + static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() noexcept { return false; } template - static bool testAndSetRelaxed(std::atomic &_q_value, T expectedValue, T newValue, T *currentValue = nullptr) Q_DECL_NOTHROW + static bool testAndSetRelaxed(std::atomic &_q_value, T expectedValue, T newValue, T *currentValue = nullptr) noexcept { bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_relaxed, std::memory_order_relaxed); if (currentValue) @@ -285,7 +285,7 @@ template struct QAtomicOps } template - static bool testAndSetAcquire(std::atomic &_q_value, T expectedValue, T newValue, T *currentValue = nullptr) Q_DECL_NOTHROW + static bool testAndSetAcquire(std::atomic &_q_value, T expectedValue, T newValue, T *currentValue = nullptr) noexcept { bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_acquire, std::memory_order_acquire); if (currentValue) @@ -294,7 +294,7 @@ template struct QAtomicOps } template - static bool testAndSetRelease(std::atomic &_q_value, T expectedValue, T newValue, T *currentValue = nullptr) Q_DECL_NOTHROW + static bool testAndSetRelease(std::atomic &_q_value, T expectedValue, T newValue, T *currentValue = nullptr) noexcept { bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_release, std::memory_order_relaxed); if (currentValue) @@ -303,7 +303,7 @@ template struct QAtomicOps } template - static bool testAndSetOrdered(std::atomic &_q_value, T expectedValue, T newValue, T *currentValue = nullptr) Q_DECL_NOTHROW + static bool testAndSetOrdered(std::atomic &_q_value, T expectedValue, T newValue, T *currentValue = nullptr) noexcept { bool tmp = _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_acq_rel, std::memory_order_acquire); if (currentValue) @@ -311,152 +311,152 @@ template struct QAtomicOps return tmp; } - static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return isTestAndSetNative(); } - static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return false; } + static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() noexcept { return isTestAndSetNative(); } + static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() noexcept { return false; } template - static T fetchAndStoreRelaxed(std::atomic &_q_value, T newValue) Q_DECL_NOTHROW + static T fetchAndStoreRelaxed(std::atomic &_q_value, T newValue) noexcept { return _q_value.exchange(newValue, std::memory_order_relaxed); } template - static T fetchAndStoreAcquire(std::atomic &_q_value, T newValue) Q_DECL_NOTHROW + static T fetchAndStoreAcquire(std::atomic &_q_value, T newValue) noexcept { return _q_value.exchange(newValue, std::memory_order_acquire); } template - static T fetchAndStoreRelease(std::atomic &_q_value, T newValue) Q_DECL_NOTHROW + static T fetchAndStoreRelease(std::atomic &_q_value, T newValue) noexcept { return _q_value.exchange(newValue, std::memory_order_release); } template - static T fetchAndStoreOrdered(std::atomic &_q_value, T newValue) Q_DECL_NOTHROW + static T fetchAndStoreOrdered(std::atomic &_q_value, T newValue) noexcept { return _q_value.exchange(newValue, std::memory_order_acq_rel); } - static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return isTestAndSetNative(); } - static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return false; } + static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() noexcept { return isTestAndSetNative(); } + static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() noexcept { return false; } template static inline - T fetchAndAddRelaxed(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndAddRelaxed(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_add(valueToAdd, std::memory_order_relaxed); } template static inline - T fetchAndAddAcquire(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndAddAcquire(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_add(valueToAdd, std::memory_order_acquire); } template static inline - T fetchAndAddRelease(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndAddRelease(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_add(valueToAdd, std::memory_order_release); } template static inline - T fetchAndAddOrdered(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndAddOrdered(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_add(valueToAdd, std::memory_order_acq_rel); } template static inline - T fetchAndSubRelaxed(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndSubRelaxed(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_sub(valueToAdd, std::memory_order_relaxed); } template static inline - T fetchAndSubAcquire(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndSubAcquire(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_sub(valueToAdd, std::memory_order_acquire); } template static inline - T fetchAndSubRelease(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndSubRelease(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_sub(valueToAdd, std::memory_order_release); } template static inline - T fetchAndSubOrdered(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndSubOrdered(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_sub(valueToAdd, std::memory_order_acq_rel); } template static inline - T fetchAndAndRelaxed(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndAndRelaxed(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_and(valueToAdd, std::memory_order_relaxed); } template static inline - T fetchAndAndAcquire(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndAndAcquire(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_and(valueToAdd, std::memory_order_acquire); } template static inline - T fetchAndAndRelease(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndAndRelease(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_and(valueToAdd, std::memory_order_release); } template static inline - T fetchAndAndOrdered(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndAndOrdered(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_and(valueToAdd, std::memory_order_acq_rel); } template static inline - T fetchAndOrRelaxed(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndOrRelaxed(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_or(valueToAdd, std::memory_order_relaxed); } template static inline - T fetchAndOrAcquire(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndOrAcquire(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_or(valueToAdd, std::memory_order_acquire); } template static inline - T fetchAndOrRelease(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndOrRelease(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_or(valueToAdd, std::memory_order_release); } template static inline - T fetchAndOrOrdered(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndOrOrdered(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_or(valueToAdd, std::memory_order_acq_rel); } template static inline - T fetchAndXorRelaxed(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndXorRelaxed(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_xor(valueToAdd, std::memory_order_relaxed); } template static inline - T fetchAndXorAcquire(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndXorAcquire(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_xor(valueToAdd, std::memory_order_acquire); } template static inline - T fetchAndXorRelease(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndXorRelease(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_xor(valueToAdd, std::memory_order_release); } template static inline - T fetchAndXorOrdered(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndXorOrdered(std::atomic &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return _q_value.fetch_xor(valueToAdd, std::memory_order_acq_rel); } diff --git a/src/corelib/thread/qatomic_msvc.h b/src/corelib/thread/qatomic_msvc.h index 5eae2bdc48..67b5224cd7 100644 --- a/src/corelib/thread/qatomic_msvc.h +++ b/src/corelib/thread/qatomic_msvc.h @@ -269,24 +269,24 @@ template <> struct QAtomicWindowsType<4> { typedef long Type; }; template struct QAtomicOpsBySize : QGenericAtomicOps > { - static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW { return true; } - static inline Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() Q_DECL_NOTHROW { return true; } - template static bool ref(T &_q_value) Q_DECL_NOTHROW; - template static bool deref(T &_q_value) Q_DECL_NOTHROW; + static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() noexcept { return true; } + static inline Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() noexcept { return true; } + template static bool ref(T &_q_value) noexcept; + template static bool deref(T &_q_value) noexcept; - static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return true; } - static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return true; } - template static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW; + static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() noexcept { return true; } + static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() noexcept { return true; } + template static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) noexcept; template - static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW; + static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) noexcept; - static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return true; } - static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return true; } - template static T fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW; + static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() noexcept { return true; } + static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() noexcept { return true; } + template static T fetchAndStoreRelaxed(T &_q_value, T newValue) noexcept; - static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return true; } - static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return true; } - template static T fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW; + static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() noexcept { return true; } + static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() noexcept { return true; } + template static T fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept; private: typedef typename QAtomicWindowsType::Type Type; @@ -303,76 +303,76 @@ struct QAtomicOps : QAtomicOpsBySize }; template<> template -inline bool QAtomicOpsBySize<4>::ref(T &_q_value) Q_DECL_NOTHROW +inline bool QAtomicOpsBySize<4>::ref(T &_q_value) noexcept { return QT_INTERLOCKED_FUNCTION(Increment)(atomic(&_q_value)) != 0; } template<> template -inline bool QAtomicOpsBySize<4>::deref(T &_q_value) Q_DECL_NOTHROW +inline bool QAtomicOpsBySize<4>::deref(T &_q_value) noexcept { return QT_INTERLOCKED_FUNCTION(Decrement)(atomic(&_q_value)) != 0; } template<> template -inline bool QAtomicOpsBySize<4>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW +inline bool QAtomicOpsBySize<4>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) noexcept { return QT_INTERLOCKED_FUNCTION(CompareExchange)(atomic(&_q_value), value(newValue), value(expectedValue)) == value(expectedValue); } template<> template -inline bool QAtomicOpsBySize<4>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW +inline bool QAtomicOpsBySize<4>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) noexcept { *currentValue = T(QT_INTERLOCKED_FUNCTION(CompareExchange)(atomic(&_q_value), newValue, expectedValue)); return *currentValue == expectedValue; } template<> template -inline T QAtomicOpsBySize<4>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW +inline T QAtomicOpsBySize<4>::fetchAndStoreRelaxed(T &_q_value, T newValue) noexcept { return QT_INTERLOCKED_FUNCTION(Exchange)(atomic(&_q_value), value(newValue)); } template<> template -inline T QAtomicOpsBySize<4>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW +inline T QAtomicOpsBySize<4>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return QT_INTERLOCKED_FUNCTION(ExchangeAdd)(atomic(&_q_value), value(valueToAdd * QAtomicAdditiveType::AddScale)); } #ifdef Q_ATOMIC_INT16_IS_SUPPORTED template<> template -inline bool QAtomicOpsBySize<2>::ref(T &_q_value) Q_DECL_NOTHROW +inline bool QAtomicOpsBySize<2>::ref(T &_q_value) noexcept { return QT_INTERLOCKED_FUNCTION(Increment16)(atomic(&_q_value)) != 0; } template<> template -inline bool QAtomicOpsBySize<2>::deref(T &_q_value) Q_DECL_NOTHROW +inline bool QAtomicOpsBySize<2>::deref(T &_q_value) noexcept { return QT_INTERLOCKED_FUNCTION(Decrement16)(atomic(&_q_value)) != 0; } template<> template -inline bool QAtomicOpsBySize<2>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW +inline bool QAtomicOpsBySize<2>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) noexcept { return QT_INTERLOCKED_FUNCTION(CompareExchange16)(atomic(&_q_value), value(newValue), value(expectedValue)) == value(expectedValue); } template<> template -inline bool QAtomicOpsBySize<2>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW +inline bool QAtomicOpsBySize<2>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) noexcept { *currentValue = T(QT_INTERLOCKED_FUNCTION(CompareExchange16)(atomic(&_q_value), newValue, expectedValue)); return *currentValue == expectedValue; } template<> template -inline T QAtomicOpsBySize<2>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW +inline T QAtomicOpsBySize<2>::fetchAndStoreRelaxed(T &_q_value, T newValue) noexcept { return QT_INTERLOCKED_FUNCTION(Exchange16)(atomic(&_q_value), value(newValue)); } template<> template -inline T QAtomicOpsBySize<2>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW +inline T QAtomicOpsBySize<2>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return QT_INTERLOCKED_FUNCTION(ExchangeAdd16)(atomic(&_q_value), value(valueToAdd * QAtomicAdditiveType::AddScale)); } @@ -380,38 +380,38 @@ inline T QAtomicOpsBySize<2>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAd #ifdef Q_ATOMIC_INT64_IS_SUPPORTED template<> template -inline bool QAtomicOpsBySize<8>::ref(T &_q_value) Q_DECL_NOTHROW +inline bool QAtomicOpsBySize<8>::ref(T &_q_value) noexcept { return QT_INTERLOCKED_FUNCTION(Increment64)(atomic(&_q_value)) != 0; } template<> template -inline bool QAtomicOpsBySize<8>::deref(T &_q_value) Q_DECL_NOTHROW +inline bool QAtomicOpsBySize<8>::deref(T &_q_value) noexcept { return QT_INTERLOCKED_FUNCTION(Decrement64)(atomic(&_q_value)) != 0; } template<> template -inline bool QAtomicOpsBySize<8>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW +inline bool QAtomicOpsBySize<8>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) noexcept { return QT_INTERLOCKED_FUNCTION(CompareExchange64)(atomic(&_q_value), value(newValue), value(expectedValue)) == value(expectedValue); } template<> template -inline bool QAtomicOpsBySize<8>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW +inline bool QAtomicOpsBySize<8>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) noexcept { *currentValue = T(QT_INTERLOCKED_FUNCTION(CompareExchange64)(atomic(&_q_value), newValue, expectedValue)); return *currentValue == expectedValue; } template<> template -inline T QAtomicOpsBySize<8>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW +inline T QAtomicOpsBySize<8>::fetchAndStoreRelaxed(T &_q_value, T newValue) noexcept { return QT_INTERLOCKED_FUNCTION(Exchange64)(atomic(&_q_value), value(newValue)); } template<> template -inline T QAtomicOpsBySize<8>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW +inline T QAtomicOpsBySize<8>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { return QT_INTERLOCKED_FUNCTION(ExchangeAdd64)(atomic(&_q_value), value(valueToAdd * QAtomicAdditiveType::AddScale)); } @@ -423,41 +423,41 @@ struct QAtomicOps : QGenericAtomicOps > { typedef T *Type; - static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return true; } - static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return true; } - static bool testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue) Q_DECL_NOTHROW; - static bool testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue, T **currentValue) Q_DECL_NOTHROW; + static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() noexcept { return true; } + static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() noexcept { return true; } + static bool testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue) noexcept; + static bool testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue, T **currentValue) noexcept; - static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return true; } - static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return true; } - static T *fetchAndStoreRelaxed(T *&_q_value, T *newValue) Q_DECL_NOTHROW; + static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() noexcept { return true; } + static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() noexcept { return true; } + static T *fetchAndStoreRelaxed(T *&_q_value, T *newValue) noexcept; - static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return true; } - static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return true; } - static T *fetchAndAddRelaxed(T *&_q_value, qptrdiff valueToAdd) Q_DECL_NOTHROW; + static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() noexcept { return true; } + static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() noexcept { return true; } + static T *fetchAndAddRelaxed(T *&_q_value, qptrdiff valueToAdd) noexcept; }; template -inline bool QAtomicOps::testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue) Q_DECL_NOTHROW +inline bool QAtomicOps::testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue) noexcept { return QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(&_q_value, newValue, expectedValue) == expectedValue; } template -inline bool QAtomicOps::testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue, T **currentValue) Q_DECL_NOTHROW +inline bool QAtomicOps::testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue, T **currentValue) noexcept { *currentValue = reinterpret_cast(QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(&_q_value, newValue, expectedValue)); return *currentValue == expectedValue; } template -inline T *QAtomicOps::fetchAndStoreRelaxed(T *&_q_value, T *newValue) Q_DECL_NOTHROW +inline T *QAtomicOps::fetchAndStoreRelaxed(T *&_q_value, T *newValue) noexcept { return reinterpret_cast(QT_INTERLOCKED_EXCHANGE_POINTER(&_q_value, newValue)); } template -inline T *QAtomicOps::fetchAndAddRelaxed(T *&_q_value, qptrdiff valueToAdd) Q_DECL_NOTHROW +inline T *QAtomicOps::fetchAndAddRelaxed(T *&_q_value, qptrdiff valueToAdd) noexcept { return reinterpret_cast(QT_INTERLOCKED_EXCHANGE_ADD_POINTER(&_q_value, valueToAdd * sizeof(T))); } diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h index a0304697b8..ad6cba04dd 100644 --- a/src/corelib/thread/qbasicatomic.h +++ b/src/corelib/thread/qbasicatomic.h @@ -100,125 +100,125 @@ public: // Everything below is either implemented in ../arch/qatomic_XXX.h or (as fallback) in qgenericatomic.h - T load() const Q_DECL_NOTHROW { return Ops::load(_q_value); } - void store(T newValue) Q_DECL_NOTHROW { Ops::store(_q_value, newValue); } + T load() const noexcept { return Ops::load(_q_value); } + void store(T newValue) noexcept { Ops::store(_q_value, newValue); } - T loadAcquire() const Q_DECL_NOTHROW { return Ops::loadAcquire(_q_value); } - void storeRelease(T newValue) Q_DECL_NOTHROW { Ops::storeRelease(_q_value, newValue); } - operator T() const Q_DECL_NOTHROW { return loadAcquire(); } - T operator=(T newValue) Q_DECL_NOTHROW { storeRelease(newValue); return newValue; } + T loadAcquire() const noexcept { return Ops::loadAcquire(_q_value); } + void storeRelease(T newValue) noexcept { Ops::storeRelease(_q_value, newValue); } + operator T() const noexcept { return loadAcquire(); } + T operator=(T newValue) noexcept { storeRelease(newValue); return newValue; } - static Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW { return Ops::isReferenceCountingNative(); } - static Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() Q_DECL_NOTHROW { return Ops::isReferenceCountingWaitFree(); } + static Q_DECL_CONSTEXPR bool isReferenceCountingNative() noexcept { return Ops::isReferenceCountingNative(); } + static Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() noexcept { return Ops::isReferenceCountingWaitFree(); } - bool ref() Q_DECL_NOTHROW { return Ops::ref(_q_value); } - bool deref() Q_DECL_NOTHROW { return Ops::deref(_q_value); } + bool ref() noexcept { return Ops::ref(_q_value); } + bool deref() noexcept { return Ops::deref(_q_value); } - static Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return Ops::isTestAndSetNative(); } - static Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return Ops::isTestAndSetWaitFree(); } + static Q_DECL_CONSTEXPR bool isTestAndSetNative() noexcept { return Ops::isTestAndSetNative(); } + static Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() noexcept { return Ops::isTestAndSetWaitFree(); } - bool testAndSetRelaxed(T expectedValue, T newValue) Q_DECL_NOTHROW + bool testAndSetRelaxed(T expectedValue, T newValue) noexcept { return Ops::testAndSetRelaxed(_q_value, expectedValue, newValue); } - bool testAndSetAcquire(T expectedValue, T newValue) Q_DECL_NOTHROW + bool testAndSetAcquire(T expectedValue, T newValue) noexcept { return Ops::testAndSetAcquire(_q_value, expectedValue, newValue); } - bool testAndSetRelease(T expectedValue, T newValue) Q_DECL_NOTHROW + bool testAndSetRelease(T expectedValue, T newValue) noexcept { return Ops::testAndSetRelease(_q_value, expectedValue, newValue); } - bool testAndSetOrdered(T expectedValue, T newValue) Q_DECL_NOTHROW + bool testAndSetOrdered(T expectedValue, T newValue) noexcept { return Ops::testAndSetOrdered(_q_value, expectedValue, newValue); } - bool testAndSetRelaxed(T expectedValue, T newValue, T ¤tValue) Q_DECL_NOTHROW + bool testAndSetRelaxed(T expectedValue, T newValue, T ¤tValue) noexcept { return Ops::testAndSetRelaxed(_q_value, expectedValue, newValue, ¤tValue); } - bool testAndSetAcquire(T expectedValue, T newValue, T ¤tValue) Q_DECL_NOTHROW + bool testAndSetAcquire(T expectedValue, T newValue, T ¤tValue) noexcept { return Ops::testAndSetAcquire(_q_value, expectedValue, newValue, ¤tValue); } - bool testAndSetRelease(T expectedValue, T newValue, T ¤tValue) Q_DECL_NOTHROW + bool testAndSetRelease(T expectedValue, T newValue, T ¤tValue) noexcept { return Ops::testAndSetRelease(_q_value, expectedValue, newValue, ¤tValue); } - bool testAndSetOrdered(T expectedValue, T newValue, T ¤tValue) Q_DECL_NOTHROW + bool testAndSetOrdered(T expectedValue, T newValue, T ¤tValue) noexcept { return Ops::testAndSetOrdered(_q_value, expectedValue, newValue, ¤tValue); } - static Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return Ops::isFetchAndStoreNative(); } - static Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return Ops::isFetchAndStoreWaitFree(); } + static Q_DECL_CONSTEXPR bool isFetchAndStoreNative() noexcept { return Ops::isFetchAndStoreNative(); } + static Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() noexcept { return Ops::isFetchAndStoreWaitFree(); } - T fetchAndStoreRelaxed(T newValue) Q_DECL_NOTHROW + T fetchAndStoreRelaxed(T newValue) noexcept { return Ops::fetchAndStoreRelaxed(_q_value, newValue); } - T fetchAndStoreAcquire(T newValue) Q_DECL_NOTHROW + T fetchAndStoreAcquire(T newValue) noexcept { return Ops::fetchAndStoreAcquire(_q_value, newValue); } - T fetchAndStoreRelease(T newValue) Q_DECL_NOTHROW + T fetchAndStoreRelease(T newValue) noexcept { return Ops::fetchAndStoreRelease(_q_value, newValue); } - T fetchAndStoreOrdered(T newValue) Q_DECL_NOTHROW + T fetchAndStoreOrdered(T newValue) noexcept { return Ops::fetchAndStoreOrdered(_q_value, newValue); } - static Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return Ops::isFetchAndAddNative(); } - static Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return Ops::isFetchAndAddWaitFree(); } + static Q_DECL_CONSTEXPR bool isFetchAndAddNative() noexcept { return Ops::isFetchAndAddNative(); } + static Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() noexcept { return Ops::isFetchAndAddWaitFree(); } - T fetchAndAddRelaxed(T valueToAdd) Q_DECL_NOTHROW + T fetchAndAddRelaxed(T valueToAdd) noexcept { return Ops::fetchAndAddRelaxed(_q_value, valueToAdd); } - T fetchAndAddAcquire(T valueToAdd) Q_DECL_NOTHROW + T fetchAndAddAcquire(T valueToAdd) noexcept { return Ops::fetchAndAddAcquire(_q_value, valueToAdd); } - T fetchAndAddRelease(T valueToAdd) Q_DECL_NOTHROW + T fetchAndAddRelease(T valueToAdd) noexcept { return Ops::fetchAndAddRelease(_q_value, valueToAdd); } - T fetchAndAddOrdered(T valueToAdd) Q_DECL_NOTHROW + T fetchAndAddOrdered(T valueToAdd) noexcept { return Ops::fetchAndAddOrdered(_q_value, valueToAdd); } - T fetchAndSubRelaxed(T valueToAdd) Q_DECL_NOTHROW + T fetchAndSubRelaxed(T valueToAdd) noexcept { return Ops::fetchAndSubRelaxed(_q_value, valueToAdd); } - T fetchAndSubAcquire(T valueToAdd) Q_DECL_NOTHROW + T fetchAndSubAcquire(T valueToAdd) noexcept { return Ops::fetchAndSubAcquire(_q_value, valueToAdd); } - T fetchAndSubRelease(T valueToAdd) Q_DECL_NOTHROW + T fetchAndSubRelease(T valueToAdd) noexcept { return Ops::fetchAndSubRelease(_q_value, valueToAdd); } - T fetchAndSubOrdered(T valueToAdd) Q_DECL_NOTHROW + T fetchAndSubOrdered(T valueToAdd) noexcept { return Ops::fetchAndSubOrdered(_q_value, valueToAdd); } - T fetchAndAndRelaxed(T valueToAdd) Q_DECL_NOTHROW + T fetchAndAndRelaxed(T valueToAdd) noexcept { return Ops::fetchAndAndRelaxed(_q_value, valueToAdd); } - T fetchAndAndAcquire(T valueToAdd) Q_DECL_NOTHROW + T fetchAndAndAcquire(T valueToAdd) noexcept { return Ops::fetchAndAndAcquire(_q_value, valueToAdd); } - T fetchAndAndRelease(T valueToAdd) Q_DECL_NOTHROW + T fetchAndAndRelease(T valueToAdd) noexcept { return Ops::fetchAndAndRelease(_q_value, valueToAdd); } - T fetchAndAndOrdered(T valueToAdd) Q_DECL_NOTHROW + T fetchAndAndOrdered(T valueToAdd) noexcept { return Ops::fetchAndAndOrdered(_q_value, valueToAdd); } - T fetchAndOrRelaxed(T valueToAdd) Q_DECL_NOTHROW + T fetchAndOrRelaxed(T valueToAdd) noexcept { return Ops::fetchAndOrRelaxed(_q_value, valueToAdd); } - T fetchAndOrAcquire(T valueToAdd) Q_DECL_NOTHROW + T fetchAndOrAcquire(T valueToAdd) noexcept { return Ops::fetchAndOrAcquire(_q_value, valueToAdd); } - T fetchAndOrRelease(T valueToAdd) Q_DECL_NOTHROW + T fetchAndOrRelease(T valueToAdd) noexcept { return Ops::fetchAndOrRelease(_q_value, valueToAdd); } - T fetchAndOrOrdered(T valueToAdd) Q_DECL_NOTHROW + T fetchAndOrOrdered(T valueToAdd) noexcept { return Ops::fetchAndOrOrdered(_q_value, valueToAdd); } - T fetchAndXorRelaxed(T valueToAdd) Q_DECL_NOTHROW + T fetchAndXorRelaxed(T valueToAdd) noexcept { return Ops::fetchAndXorRelaxed(_q_value, valueToAdd); } - T fetchAndXorAcquire(T valueToAdd) Q_DECL_NOTHROW + T fetchAndXorAcquire(T valueToAdd) noexcept { return Ops::fetchAndXorAcquire(_q_value, valueToAdd); } - T fetchAndXorRelease(T valueToAdd) Q_DECL_NOTHROW + T fetchAndXorRelease(T valueToAdd) noexcept { return Ops::fetchAndXorRelease(_q_value, valueToAdd); } - T fetchAndXorOrdered(T valueToAdd) Q_DECL_NOTHROW + T fetchAndXorOrdered(T valueToAdd) noexcept { return Ops::fetchAndXorOrdered(_q_value, valueToAdd); } - T operator++() Q_DECL_NOTHROW + T operator++() noexcept { return fetchAndAddOrdered(1) + 1; } - T operator++(int) Q_DECL_NOTHROW + T operator++(int) noexcept { return fetchAndAddOrdered(1); } - T operator--() Q_DECL_NOTHROW + T operator--() noexcept { return fetchAndSubOrdered(1) - 1; } - T operator--(int) Q_DECL_NOTHROW + T operator--(int) noexcept { return fetchAndSubOrdered(1); } - T operator+=(T v) Q_DECL_NOTHROW + T operator+=(T v) noexcept { return fetchAndAddOrdered(v) + v; } - T operator-=(T v) Q_DECL_NOTHROW + T operator-=(T v) noexcept { return fetchAndSubOrdered(v) - v; } - T operator&=(T v) Q_DECL_NOTHROW + T operator&=(T v) noexcept { return fetchAndAndOrdered(v) & v; } - T operator|=(T v) Q_DECL_NOTHROW + T operator|=(T v) noexcept { return fetchAndOrOrdered(v) | v; } - T operator^=(T v) Q_DECL_NOTHROW + T operator^=(T v) noexcept { return fetchAndXorOrdered(v) ^ v; } #ifdef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS QBasicAtomicInteger() = default; - constexpr QBasicAtomicInteger(T value) Q_DECL_NOTHROW : _q_value(value) {} + constexpr QBasicAtomicInteger(T value) noexcept : _q_value(value) {} QBasicAtomicInteger(const QBasicAtomicInteger &) = delete; QBasicAtomicInteger &operator=(const QBasicAtomicInteger &) = delete; QBasicAtomicInteger &operator=(const QBasicAtomicInteger &) volatile = delete; @@ -236,85 +236,85 @@ public: AtomicType _q_value; - Type load() const Q_DECL_NOTHROW { return Ops::load(_q_value); } - void store(Type newValue) Q_DECL_NOTHROW { Ops::store(_q_value, newValue); } - operator Type() const Q_DECL_NOTHROW { return loadAcquire(); } - Type operator=(Type newValue) Q_DECL_NOTHROW { storeRelease(newValue); return newValue; } + Type load() const noexcept { return Ops::load(_q_value); } + void store(Type newValue) noexcept { Ops::store(_q_value, newValue); } + operator Type() const noexcept { return loadAcquire(); } + Type operator=(Type newValue) noexcept { storeRelease(newValue); return newValue; } // Atomic API, implemented in qatomic_XXX.h - Type loadAcquire() const Q_DECL_NOTHROW { return Ops::loadAcquire(_q_value); } - void storeRelease(Type newValue) Q_DECL_NOTHROW { Ops::storeRelease(_q_value, newValue); } + Type loadAcquire() const noexcept { return Ops::loadAcquire(_q_value); } + void storeRelease(Type newValue) noexcept { Ops::storeRelease(_q_value, newValue); } - static Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return Ops::isTestAndSetNative(); } - static Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return Ops::isTestAndSetWaitFree(); } + static Q_DECL_CONSTEXPR bool isTestAndSetNative() noexcept { return Ops::isTestAndSetNative(); } + static Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() noexcept { return Ops::isTestAndSetWaitFree(); } - bool testAndSetRelaxed(Type expectedValue, Type newValue) Q_DECL_NOTHROW + bool testAndSetRelaxed(Type expectedValue, Type newValue) noexcept { return Ops::testAndSetRelaxed(_q_value, expectedValue, newValue); } - bool testAndSetAcquire(Type expectedValue, Type newValue) Q_DECL_NOTHROW + bool testAndSetAcquire(Type expectedValue, Type newValue) noexcept { return Ops::testAndSetAcquire(_q_value, expectedValue, newValue); } - bool testAndSetRelease(Type expectedValue, Type newValue) Q_DECL_NOTHROW + bool testAndSetRelease(Type expectedValue, Type newValue) noexcept { return Ops::testAndSetRelease(_q_value, expectedValue, newValue); } - bool testAndSetOrdered(Type expectedValue, Type newValue) Q_DECL_NOTHROW + bool testAndSetOrdered(Type expectedValue, Type newValue) noexcept { return Ops::testAndSetOrdered(_q_value, expectedValue, newValue); } - bool testAndSetRelaxed(Type expectedValue, Type newValue, Type ¤tValue) Q_DECL_NOTHROW + bool testAndSetRelaxed(Type expectedValue, Type newValue, Type ¤tValue) noexcept { return Ops::testAndSetRelaxed(_q_value, expectedValue, newValue, ¤tValue); } - bool testAndSetAcquire(Type expectedValue, Type newValue, Type ¤tValue) Q_DECL_NOTHROW + bool testAndSetAcquire(Type expectedValue, Type newValue, Type ¤tValue) noexcept { return Ops::testAndSetAcquire(_q_value, expectedValue, newValue, ¤tValue); } - bool testAndSetRelease(Type expectedValue, Type newValue, Type ¤tValue) Q_DECL_NOTHROW + bool testAndSetRelease(Type expectedValue, Type newValue, Type ¤tValue) noexcept { return Ops::testAndSetRelease(_q_value, expectedValue, newValue, ¤tValue); } - bool testAndSetOrdered(Type expectedValue, Type newValue, Type ¤tValue) Q_DECL_NOTHROW + bool testAndSetOrdered(Type expectedValue, Type newValue, Type ¤tValue) noexcept { return Ops::testAndSetOrdered(_q_value, expectedValue, newValue, ¤tValue); } - static Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return Ops::isFetchAndStoreNative(); } - static Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return Ops::isFetchAndStoreWaitFree(); } + static Q_DECL_CONSTEXPR bool isFetchAndStoreNative() noexcept { return Ops::isFetchAndStoreNative(); } + static Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() noexcept { return Ops::isFetchAndStoreWaitFree(); } - Type fetchAndStoreRelaxed(Type newValue) Q_DECL_NOTHROW + Type fetchAndStoreRelaxed(Type newValue) noexcept { return Ops::fetchAndStoreRelaxed(_q_value, newValue); } - Type fetchAndStoreAcquire(Type newValue) Q_DECL_NOTHROW + Type fetchAndStoreAcquire(Type newValue) noexcept { return Ops::fetchAndStoreAcquire(_q_value, newValue); } - Type fetchAndStoreRelease(Type newValue) Q_DECL_NOTHROW + Type fetchAndStoreRelease(Type newValue) noexcept { return Ops::fetchAndStoreRelease(_q_value, newValue); } - Type fetchAndStoreOrdered(Type newValue) Q_DECL_NOTHROW + Type fetchAndStoreOrdered(Type newValue) noexcept { return Ops::fetchAndStoreOrdered(_q_value, newValue); } - static Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return Ops::isFetchAndAddNative(); } - static Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return Ops::isFetchAndAddWaitFree(); } + static Q_DECL_CONSTEXPR bool isFetchAndAddNative() noexcept { return Ops::isFetchAndAddNative(); } + static Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() noexcept { return Ops::isFetchAndAddWaitFree(); } - Type fetchAndAddRelaxed(qptrdiff valueToAdd) Q_DECL_NOTHROW + Type fetchAndAddRelaxed(qptrdiff valueToAdd) noexcept { return Ops::fetchAndAddRelaxed(_q_value, valueToAdd); } - Type fetchAndAddAcquire(qptrdiff valueToAdd) Q_DECL_NOTHROW + Type fetchAndAddAcquire(qptrdiff valueToAdd) noexcept { return Ops::fetchAndAddAcquire(_q_value, valueToAdd); } - Type fetchAndAddRelease(qptrdiff valueToAdd) Q_DECL_NOTHROW + Type fetchAndAddRelease(qptrdiff valueToAdd) noexcept { return Ops::fetchAndAddRelease(_q_value, valueToAdd); } - Type fetchAndAddOrdered(qptrdiff valueToAdd) Q_DECL_NOTHROW + Type fetchAndAddOrdered(qptrdiff valueToAdd) noexcept { return Ops::fetchAndAddOrdered(_q_value, valueToAdd); } - Type fetchAndSubRelaxed(qptrdiff valueToAdd) Q_DECL_NOTHROW + Type fetchAndSubRelaxed(qptrdiff valueToAdd) noexcept { return Ops::fetchAndSubRelaxed(_q_value, valueToAdd); } - Type fetchAndSubAcquire(qptrdiff valueToAdd) Q_DECL_NOTHROW + Type fetchAndSubAcquire(qptrdiff valueToAdd) noexcept { return Ops::fetchAndSubAcquire(_q_value, valueToAdd); } - Type fetchAndSubRelease(qptrdiff valueToAdd) Q_DECL_NOTHROW + Type fetchAndSubRelease(qptrdiff valueToAdd) noexcept { return Ops::fetchAndSubRelease(_q_value, valueToAdd); } - Type fetchAndSubOrdered(qptrdiff valueToAdd) Q_DECL_NOTHROW + Type fetchAndSubOrdered(qptrdiff valueToAdd) noexcept { return Ops::fetchAndSubOrdered(_q_value, valueToAdd); } - Type operator++() Q_DECL_NOTHROW + Type operator++() noexcept { return fetchAndAddOrdered(1) + 1; } - Type operator++(int) Q_DECL_NOTHROW + Type operator++(int) noexcept { return fetchAndAddOrdered(1); } - Type operator--() Q_DECL_NOTHROW + Type operator--() noexcept { return fetchAndSubOrdered(1) - 1; } - Type operator--(int) Q_DECL_NOTHROW + Type operator--(int) noexcept { return fetchAndSubOrdered(1); } - Type operator+=(qptrdiff valueToAdd) Q_DECL_NOTHROW + Type operator+=(qptrdiff valueToAdd) noexcept { return fetchAndAddOrdered(valueToAdd) + valueToAdd; } - Type operator-=(qptrdiff valueToSub) Q_DECL_NOTHROW + Type operator-=(qptrdiff valueToSub) noexcept { return fetchAndSubOrdered(valueToSub) - valueToSub; } #ifdef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS QBasicAtomicPointer() = default; - constexpr QBasicAtomicPointer(Type value) Q_DECL_NOTHROW : _q_value(value) {} + constexpr QBasicAtomicPointer(Type value) noexcept : _q_value(value) {} QBasicAtomicPointer(const QBasicAtomicPointer &) = delete; QBasicAtomicPointer &operator=(const QBasicAtomicPointer &) = delete; QBasicAtomicPointer &operator=(const QBasicAtomicPointer &) volatile = delete; diff --git a/src/corelib/thread/qfutex_p.h b/src/corelib/thread/qfutex_p.h index 483664c783..136f6bca8c 100644 --- a/src/corelib/thread/qfutex_p.h +++ b/src/corelib/thread/qfutex_p.h @@ -85,7 +85,7 @@ QT_BEGIN_NAMESPACE namespace QtLinuxFutex { constexpr inline bool futexAvailable() { return true; } inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0, - int *addr2 = nullptr, int val3 = 0) Q_DECL_NOTHROW + int *addr2 = nullptr, int val3 = 0) noexcept { // we use __NR_futex because some libcs (like Android's bionic) don't // provide SYS_futex etc. diff --git a/src/corelib/thread/qgenericatomic.h b/src/corelib/thread/qgenericatomic.h index 89c4fe9a11..f8333e7de6 100644 --- a/src/corelib/thread/qgenericatomic.h +++ b/src/corelib/thread/qgenericatomic.h @@ -72,32 +72,32 @@ template struct QGenericAtomicOps { template struct AtomicType { typedef T Type; typedef T *PointerType; }; - template static void acquireMemoryFence(const T &_q_value) Q_DECL_NOTHROW + template static void acquireMemoryFence(const T &_q_value) noexcept { BaseClass::orderedMemoryFence(_q_value); } - template static void releaseMemoryFence(const T &_q_value) Q_DECL_NOTHROW + template static void releaseMemoryFence(const T &_q_value) noexcept { BaseClass::orderedMemoryFence(_q_value); } - template static void orderedMemoryFence(const T &) Q_DECL_NOTHROW + template static void orderedMemoryFence(const T &) noexcept { } template static Q_ALWAYS_INLINE - T load(const T &_q_value) Q_DECL_NOTHROW + T load(const T &_q_value) noexcept { return _q_value; } template static Q_ALWAYS_INLINE - void store(T &_q_value, X newValue) Q_DECL_NOTHROW + void store(T &_q_value, X newValue) noexcept { _q_value = newValue; } template static Q_ALWAYS_INLINE - T loadAcquire(const T &_q_value) Q_DECL_NOTHROW + T loadAcquire(const T &_q_value) noexcept { T tmp = *static_cast(&_q_value); BaseClass::acquireMemoryFence(_q_value); @@ -105,24 +105,24 @@ template struct QGenericAtomicOps } template static Q_ALWAYS_INLINE - void storeRelease(T &_q_value, X newValue) Q_DECL_NOTHROW + void storeRelease(T &_q_value, X newValue) noexcept { BaseClass::releaseMemoryFence(_q_value); *static_cast(&_q_value) = newValue; } - static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW + static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() noexcept { return BaseClass::isFetchAndAddNative(); } - static inline Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() Q_DECL_NOTHROW + static inline Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() noexcept { return BaseClass::isFetchAndAddWaitFree(); } template static Q_ALWAYS_INLINE - bool ref(T &_q_value) Q_DECL_NOTHROW + bool ref(T &_q_value) noexcept { return BaseClass::fetchAndAddRelaxed(_q_value, 1) != T(-1); } template static Q_ALWAYS_INLINE - bool deref(T &_q_value) Q_DECL_NOTHROW + bool deref(T &_q_value) noexcept { return BaseClass::fetchAndAddRelaxed(_q_value, -1) != 1; } @@ -130,16 +130,16 @@ template struct QGenericAtomicOps #if 0 // These functions have no default implementation // Archictectures must implement them - static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW; - static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW; + static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() noexcept; + static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() noexcept; template static inline - bool testAndSetRelaxed(T &_q_value, X expectedValue, X newValue) Q_DECL_NOTHROW; + bool testAndSetRelaxed(T &_q_value, X expectedValue, X newValue) noexcept; template static inline - bool testAndSetRelaxed(T &_q_value, X expectedValue, X newValue, X *currentValue) Q_DECL_NOTHROW; + bool testAndSetRelaxed(T &_q_value, X expectedValue, X newValue, X *currentValue) noexcept; #endif template static Q_ALWAYS_INLINE - bool testAndSetAcquire(T &_q_value, X expectedValue, X newValue) Q_DECL_NOTHROW + bool testAndSetAcquire(T &_q_value, X expectedValue, X newValue) noexcept { bool tmp = BaseClass::testAndSetRelaxed(_q_value, expectedValue, newValue); BaseClass::acquireMemoryFence(_q_value); @@ -147,21 +147,21 @@ template struct QGenericAtomicOps } template static Q_ALWAYS_INLINE - bool testAndSetRelease(T &_q_value, X expectedValue, X newValue) Q_DECL_NOTHROW + bool testAndSetRelease(T &_q_value, X expectedValue, X newValue) noexcept { BaseClass::releaseMemoryFence(_q_value); return BaseClass::testAndSetRelaxed(_q_value, expectedValue, newValue); } template static Q_ALWAYS_INLINE - bool testAndSetOrdered(T &_q_value, X expectedValue, X newValue) Q_DECL_NOTHROW + bool testAndSetOrdered(T &_q_value, X expectedValue, X newValue) noexcept { BaseClass::orderedMemoryFence(_q_value); return BaseClass::testAndSetRelaxed(_q_value, expectedValue, newValue); } template static Q_ALWAYS_INLINE - bool testAndSetAcquire(T &_q_value, X expectedValue, X newValue, X *currentValue) Q_DECL_NOTHROW + bool testAndSetAcquire(T &_q_value, X expectedValue, X newValue, X *currentValue) noexcept { bool tmp = BaseClass::testAndSetRelaxed(_q_value, expectedValue, newValue, currentValue); BaseClass::acquireMemoryFence(_q_value); @@ -169,24 +169,24 @@ template struct QGenericAtomicOps } template static Q_ALWAYS_INLINE - bool testAndSetRelease(T &_q_value, X expectedValue, X newValue, X *currentValue) Q_DECL_NOTHROW + bool testAndSetRelease(T &_q_value, X expectedValue, X newValue, X *currentValue) noexcept { BaseClass::releaseMemoryFence(_q_value); return BaseClass::testAndSetRelaxed(_q_value, expectedValue, newValue, currentValue); } template static Q_ALWAYS_INLINE - bool testAndSetOrdered(T &_q_value, X expectedValue, X newValue, X *currentValue) Q_DECL_NOTHROW + bool testAndSetOrdered(T &_q_value, X expectedValue, X newValue, X *currentValue) noexcept { BaseClass::orderedMemoryFence(_q_value); return BaseClass::testAndSetRelaxed(_q_value, expectedValue, newValue, currentValue); } - static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return false; } - static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return false; } + static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() noexcept { return false; } + static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() noexcept { return false; } template static Q_ALWAYS_INLINE - T fetchAndStoreRelaxed(T &_q_value, X newValue) Q_DECL_NOTHROW + T fetchAndStoreRelaxed(T &_q_value, X newValue) noexcept { // implement fetchAndStore on top of testAndSet Q_FOREVER { @@ -197,7 +197,7 @@ template struct QGenericAtomicOps } template static Q_ALWAYS_INLINE - T fetchAndStoreAcquire(T &_q_value, X newValue) Q_DECL_NOTHROW + T fetchAndStoreAcquire(T &_q_value, X newValue) noexcept { T tmp = BaseClass::fetchAndStoreRelaxed(_q_value, newValue); BaseClass::acquireMemoryFence(_q_value); @@ -205,23 +205,23 @@ template struct QGenericAtomicOps } template static Q_ALWAYS_INLINE - T fetchAndStoreRelease(T &_q_value, X newValue) Q_DECL_NOTHROW + T fetchAndStoreRelease(T &_q_value, X newValue) noexcept { BaseClass::releaseMemoryFence(_q_value); return BaseClass::fetchAndStoreRelaxed(_q_value, newValue); } template static Q_ALWAYS_INLINE - T fetchAndStoreOrdered(T &_q_value, X newValue) Q_DECL_NOTHROW + T fetchAndStoreOrdered(T &_q_value, X newValue) noexcept { BaseClass::orderedMemoryFence(_q_value); return BaseClass::fetchAndStoreRelaxed(_q_value, newValue); } - static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return false; } - static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return false; } + static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() noexcept { return false; } + static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() noexcept { return false; } template static Q_ALWAYS_INLINE - T fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { // implement fetchAndAdd on top of testAndSet Q_FOREVER { @@ -232,7 +232,7 @@ template struct QGenericAtomicOps } template static Q_ALWAYS_INLINE - T fetchAndAddAcquire(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndAddAcquire(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { T tmp = BaseClass::fetchAndAddRelaxed(_q_value, valueToAdd); BaseClass::acquireMemoryFence(_q_value); @@ -240,14 +240,14 @@ template struct QGenericAtomicOps } template static Q_ALWAYS_INLINE - T fetchAndAddRelease(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndAddRelease(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { BaseClass::releaseMemoryFence(_q_value); return BaseClass::fetchAndAddRelaxed(_q_value, valueToAdd); } template static Q_ALWAYS_INLINE - T fetchAndAddOrdered(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW + T fetchAndAddOrdered(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) noexcept { BaseClass::orderedMemoryFence(_q_value); return BaseClass::fetchAndAddRelaxed(_q_value, valueToAdd); @@ -256,7 +256,7 @@ template struct QGenericAtomicOps QT_WARNING_PUSH QT_WARNING_DISABLE_MSVC(4146) // unary minus operator applied to unsigned type, result still unsigned template static Q_ALWAYS_INLINE - T fetchAndSubRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT operand) Q_DECL_NOTHROW + T fetchAndSubRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT operand) noexcept { // implement fetchAndSub on top of fetchAndAdd return fetchAndAddRelaxed(_q_value, -operand); @@ -264,7 +264,7 @@ QT_WARNING_DISABLE_MSVC(4146) // unary minus operator applied to unsigned type QT_WARNING_POP template static Q_ALWAYS_INLINE - T fetchAndSubAcquire(T &_q_value, typename QAtomicAdditiveType::AdditiveT operand) Q_DECL_NOTHROW + T fetchAndSubAcquire(T &_q_value, typename QAtomicAdditiveType::AdditiveT operand) noexcept { T tmp = BaseClass::fetchAndSubRelaxed(_q_value, operand); BaseClass::acquireMemoryFence(_q_value); @@ -272,21 +272,21 @@ QT_WARNING_POP } template static Q_ALWAYS_INLINE - T fetchAndSubRelease(T &_q_value, typename QAtomicAdditiveType::AdditiveT operand) Q_DECL_NOTHROW + T fetchAndSubRelease(T &_q_value, typename QAtomicAdditiveType::AdditiveT operand) noexcept { BaseClass::releaseMemoryFence(_q_value); return BaseClass::fetchAndSubRelaxed(_q_value, operand); } template static Q_ALWAYS_INLINE - T fetchAndSubOrdered(T &_q_value, typename QAtomicAdditiveType::AdditiveT operand) Q_DECL_NOTHROW + T fetchAndSubOrdered(T &_q_value, typename QAtomicAdditiveType::AdditiveT operand) noexcept { BaseClass::orderedMemoryFence(_q_value); return BaseClass::fetchAndSubRelaxed(_q_value, operand); } template static Q_ALWAYS_INLINE - T fetchAndAndRelaxed(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW + T fetchAndAndRelaxed(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) noexcept { // implement fetchAndAnd on top of testAndSet T tmp = BaseClass::load(_q_value); @@ -297,7 +297,7 @@ QT_WARNING_POP } template static Q_ALWAYS_INLINE - T fetchAndAndAcquire(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW + T fetchAndAndAcquire(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) noexcept { T tmp = BaseClass::fetchAndAndRelaxed(_q_value, operand); BaseClass::acquireMemoryFence(_q_value); @@ -305,21 +305,21 @@ QT_WARNING_POP } template static Q_ALWAYS_INLINE - T fetchAndAndRelease(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW + T fetchAndAndRelease(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) noexcept { BaseClass::releaseMemoryFence(_q_value); return BaseClass::fetchAndAndRelaxed(_q_value, operand); } template static Q_ALWAYS_INLINE - T fetchAndAndOrdered(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW + T fetchAndAndOrdered(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) noexcept { BaseClass::orderedMemoryFence(_q_value); return BaseClass::fetchAndAndRelaxed(_q_value, operand); } template static Q_ALWAYS_INLINE - T fetchAndOrRelaxed(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW + T fetchAndOrRelaxed(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) noexcept { // implement fetchAndOr on top of testAndSet T tmp = BaseClass::load(_q_value); @@ -330,7 +330,7 @@ QT_WARNING_POP } template static Q_ALWAYS_INLINE - T fetchAndOrAcquire(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW + T fetchAndOrAcquire(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) noexcept { T tmp = BaseClass::fetchAndOrRelaxed(_q_value, operand); BaseClass::acquireMemoryFence(_q_value); @@ -338,21 +338,21 @@ QT_WARNING_POP } template static Q_ALWAYS_INLINE - T fetchAndOrRelease(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW + T fetchAndOrRelease(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) noexcept { BaseClass::releaseMemoryFence(_q_value); return BaseClass::fetchAndOrRelaxed(_q_value, operand); } template static Q_ALWAYS_INLINE - T fetchAndOrOrdered(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW + T fetchAndOrOrdered(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) noexcept { BaseClass::orderedMemoryFence(_q_value); return BaseClass::fetchAndOrRelaxed(_q_value, operand); } template static Q_ALWAYS_INLINE - T fetchAndXorRelaxed(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW + T fetchAndXorRelaxed(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) noexcept { // implement fetchAndXor on top of testAndSet T tmp = BaseClass::load(_q_value); @@ -363,7 +363,7 @@ QT_WARNING_POP } template static Q_ALWAYS_INLINE - T fetchAndXorAcquire(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW + T fetchAndXorAcquire(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) noexcept { T tmp = BaseClass::fetchAndXorRelaxed(_q_value, operand); BaseClass::acquireMemoryFence(_q_value); @@ -371,14 +371,14 @@ QT_WARNING_POP } template static Q_ALWAYS_INLINE - T fetchAndXorRelease(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW + T fetchAndXorRelease(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) noexcept { BaseClass::releaseMemoryFence(_q_value); return BaseClass::fetchAndXorRelaxed(_q_value, operand); } template static Q_ALWAYS_INLINE - T fetchAndXorOrdered(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) Q_DECL_NOTHROW + T fetchAndXorOrdered(T &_q_value, typename std::enable_if::isIntegral, T>::type operand) noexcept { BaseClass::orderedMemoryFence(_q_value); return BaseClass::fetchAndXorRelaxed(_q_value, operand); diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp index 3881ac017e..4f55e50fe5 100644 --- a/src/corelib/thread/qmutex.cpp +++ b/src/corelib/thread/qmutex.cpp @@ -82,7 +82,7 @@ public: QMutex mutex; bool lock(int timeout) QT_MUTEX_LOCK_NOEXCEPT; - void unlock() Q_DECL_NOTHROW; + void unlock() noexcept; }; /* @@ -329,7 +329,7 @@ bool QMutex::tryLock(int timeout) QT_MUTEX_LOCK_NOEXCEPT \sa lock() */ -void QMutex::unlock() Q_DECL_NOTHROW +void QMutex::unlock() noexcept { QMutexData *current; if (fastTryUnlock(current)) @@ -348,7 +348,7 @@ void QMutex::unlock() Q_DECL_NOTHROW Returns \c true if the mutex is recursive. */ -bool QBasicMutex::isRecursive() Q_DECL_NOTHROW +bool QBasicMutex::isRecursive() noexcept { return QT_PREPEND_NAMESPACE(isRecursive)(d_ptr.loadAcquire()); } @@ -358,7 +358,7 @@ bool QBasicMutex::isRecursive() Q_DECL_NOTHROW Returns \c true if the mutex is recursive. */ -bool QBasicMutex::isRecursive() const Q_DECL_NOTHROW +bool QBasicMutex::isRecursive() const noexcept { return QT_PREPEND_NAMESPACE(isRecursive)(d_ptr.loadAcquire()); } @@ -600,7 +600,7 @@ bool QBasicMutex::lockInternal(int timeout) QT_MUTEX_LOCK_NOEXCEPT /*! \internal */ -void QBasicMutex::unlockInternal() Q_DECL_NOTHROW +void QBasicMutex::unlockInternal() noexcept { QMutexData *copy = d_ptr.loadAcquire(); Q_ASSERT(copy); //we must be locked @@ -675,7 +675,7 @@ void QMutexPrivate::release() } // atomically subtract "value" to the waiters, and remove the QMutexPrivate::BigNumber flag -void QMutexPrivate::derefWaiters(int value) Q_DECL_NOTHROW +void QMutexPrivate::derefWaiters(int value) noexcept { int old_waiters; int new_waiters; @@ -716,7 +716,7 @@ inline bool QRecursiveMutexPrivate::lock(int timeout) QT_MUTEX_LOCK_NOEXCEPT /*! \internal */ -inline void QRecursiveMutexPrivate::unlock() Q_DECL_NOTHROW +inline void QRecursiveMutexPrivate::unlock() noexcept { if (count > 0) { count--; diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h index 837355a602..d7796092d1 100644 --- a/src/corelib/thread/qmutex.h +++ b/src/corelib/thread/qmutex.h @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE #if QT_CONFIG(thread) || defined(Q_CLANG_QDOC) #ifdef Q_OS_LINUX -# define QT_MUTEX_LOCK_NOEXCEPT Q_DECL_NOTHROW +# define QT_MUTEX_LOCK_NOEXCEPT noexcept #else # define QT_MUTEX_LOCK_NOEXCEPT #endif @@ -80,39 +80,39 @@ public: } // BasicLockable concept - inline void unlock() Q_DECL_NOTHROW { + inline void unlock() noexcept { Q_ASSERT(d_ptr.load()); //mutex must be locked if (!fastTryUnlock()) unlockInternal(); } - bool tryLock() Q_DECL_NOTHROW { + bool tryLock() noexcept { return fastTryLock(); } // Lockable concept - bool try_lock() Q_DECL_NOTHROW { return tryLock(); } + bool try_lock() noexcept { return tryLock(); } - bool isRecursive() Q_DECL_NOTHROW; //### Qt6: remove me - bool isRecursive() const Q_DECL_NOTHROW; + bool isRecursive() noexcept; //### Qt6: remove me + bool isRecursive() const noexcept; private: - inline bool fastTryLock() Q_DECL_NOTHROW { + inline bool fastTryLock() noexcept { return d_ptr.testAndSetAcquire(nullptr, dummyLocked()); } - inline bool fastTryUnlock() Q_DECL_NOTHROW { + inline bool fastTryUnlock() noexcept { return d_ptr.testAndSetRelease(dummyLocked(), nullptr); } - inline bool fastTryLock(QMutexData *¤t) Q_DECL_NOTHROW { + inline bool fastTryLock(QMutexData *¤t) noexcept { return d_ptr.testAndSetAcquire(nullptr, dummyLocked(), current); } - inline bool fastTryUnlock(QMutexData *¤t) Q_DECL_NOTHROW { + inline bool fastTryUnlock(QMutexData *¤t) noexcept { return d_ptr.testAndSetRelease(dummyLocked(), nullptr, current); } void lockInternal() QT_MUTEX_LOCK_NOEXCEPT; bool lockInternal(int timeout) QT_MUTEX_LOCK_NOEXCEPT; - void unlockInternal() Q_DECL_NOTHROW; + void unlockInternal() noexcept; QBasicAtomicPointer d_ptr; static inline QMutexData *dummyLocked() { @@ -134,7 +134,7 @@ public: void lock() QT_MUTEX_LOCK_NOEXCEPT; bool tryLock(int timeout = 0) QT_MUTEX_LOCK_NOEXCEPT; // BasicLockable concept - void unlock() Q_DECL_NOTHROW; + void unlock() noexcept; // Lockable concept bool try_lock() QT_MUTEX_LOCK_NOEXCEPT { return tryLock(); } @@ -158,7 +158,7 @@ public: } #endif - bool isRecursive() const Q_DECL_NOTHROW + bool isRecursive() const noexcept { return QBasicMutex::isRecursive(); } private: @@ -212,7 +212,7 @@ public: #endif inline ~QMutexLocker() { unlock(); } - inline void unlock() Q_DECL_NOTHROW + inline void unlock() noexcept { if ((val & quintptr(1u)) == quintptr(1u)) { val &= ~quintptr(1u); @@ -257,24 +257,24 @@ class Q_CORE_EXPORT QMutex public: enum RecursionMode { NonRecursive, Recursive }; - inline Q_DECL_CONSTEXPR explicit QMutex(RecursionMode = NonRecursive) Q_DECL_NOTHROW { } + inline Q_DECL_CONSTEXPR explicit QMutex(RecursionMode = NonRecursive) noexcept { } - inline void lock() Q_DECL_NOTHROW {} - inline bool tryLock(int timeout = 0) Q_DECL_NOTHROW { Q_UNUSED(timeout); return true; } - inline bool try_lock() Q_DECL_NOTHROW { return true; } - inline void unlock() Q_DECL_NOTHROW {} - inline bool isRecursive() const Q_DECL_NOTHROW { return true; } + inline void lock() noexcept {} + inline bool tryLock(int timeout = 0) noexcept { Q_UNUSED(timeout); return true; } + inline bool try_lock() noexcept { return true; } + inline void unlock() noexcept {} + inline bool isRecursive() const noexcept { return true; } #if QT_HAS_INCLUDE() template - inline bool try_lock_for(std::chrono::duration duration) Q_DECL_NOTHROW + inline bool try_lock_for(std::chrono::duration duration) noexcept { Q_UNUSED(duration); return true; } template - inline bool try_lock_until(std::chrono::time_point timePoint) Q_DECL_NOTHROW + inline bool try_lock_until(std::chrono::time_point timePoint) noexcept { Q_UNUSED(timePoint); return true; @@ -288,12 +288,12 @@ private: class Q_CORE_EXPORT QMutexLocker { public: - inline explicit QMutexLocker(QMutex *) Q_DECL_NOTHROW {} - inline ~QMutexLocker() Q_DECL_NOTHROW {} + inline explicit QMutexLocker(QMutex *) noexcept {} + inline ~QMutexLocker() noexcept {} - inline void unlock() Q_DECL_NOTHROW {} - void relock() Q_DECL_NOTHROW {} - inline QMutex *mutex() const Q_DECL_NOTHROW { return nullptr; } + inline void unlock() noexcept {} + void relock() noexcept {} + inline QMutex *mutex() const noexcept { return nullptr; } private: Q_DISABLE_COPY(QMutexLocker) diff --git a/src/corelib/thread/qmutex_linux.cpp b/src/corelib/thread/qmutex_linux.cpp index 507e72cb76..b006ff1033 100644 --- a/src/corelib/thread/qmutex_linux.cpp +++ b/src/corelib/thread/qmutex_linux.cpp @@ -106,7 +106,7 @@ static inline QMutexData *dummyFutexValue() } template static inline -bool lockInternal_helper(QBasicAtomicPointer &d_ptr, int timeout = -1, QElapsedTimer *elapsedTimer = 0) Q_DECL_NOTHROW +bool lockInternal_helper(QBasicAtomicPointer &d_ptr, int timeout = -1, QElapsedTimer *elapsedTimer = 0) noexcept { if (!IsTimed) timeout = -1; @@ -153,13 +153,13 @@ bool lockInternal_helper(QBasicAtomicPointer &d_ptr, int timeout = - return true; } -void QBasicMutex::lockInternal() Q_DECL_NOTHROW +void QBasicMutex::lockInternal() noexcept { Q_ASSERT(!isRecursive()); lockInternal_helper(d_ptr); } -bool QBasicMutex::lockInternal(int timeout) Q_DECL_NOTHROW +bool QBasicMutex::lockInternal(int timeout) noexcept { Q_ASSERT(!isRecursive()); QElapsedTimer elapsedTimer; @@ -167,7 +167,7 @@ bool QBasicMutex::lockInternal(int timeout) Q_DECL_NOTHROW return lockInternal_helper(d_ptr, timeout, &elapsedTimer); } -void QBasicMutex::unlockInternal() Q_DECL_NOTHROW +void QBasicMutex::unlockInternal() noexcept { QMutexData *d = d_ptr.load(); Q_ASSERT(d); //we must be locked diff --git a/src/corelib/thread/qmutex_mac.cpp b/src/corelib/thread/qmutex_mac.cpp index 9a8d9bc750..923f89f697 100644 --- a/src/corelib/thread/qmutex_mac.cpp +++ b/src/corelib/thread/qmutex_mac.cpp @@ -79,7 +79,7 @@ bool QMutexPrivate::wait(int timeout) return (r == KERN_SUCCESS); } -void QMutexPrivate::wakeUp() Q_DECL_NOTHROW +void QMutexPrivate::wakeUp() noexcept { semaphore_signal(mach_semaphore); } diff --git a/src/corelib/thread/qmutex_p.h b/src/corelib/thread/qmutex_p.h index ec9bfc1152..5025f836b9 100644 --- a/src/corelib/thread/qmutex_p.h +++ b/src/corelib/thread/qmutex_p.h @@ -92,7 +92,7 @@ public: QMutexPrivate(); bool wait(int timeout = -1); - void wakeUp() Q_DECL_NOTHROW; + void wakeUp() noexcept; // Control the lifetime of the privates QAtomicInt refCount; @@ -125,7 +125,7 @@ public: when the mutex is unlocked. */ enum { BigNumber = 0x100000 }; //Must be bigger than the possible number of waiters (number of threads) - void derefWaiters(int value) Q_DECL_NOTHROW; + void derefWaiters(int value) noexcept; //platform specific stuff #if defined(Q_OS_MAC) diff --git a/src/corelib/thread/qmutex_unix.cpp b/src/corelib/thread/qmutex_unix.cpp index 3ee24a292c..a92ac4f943 100644 --- a/src/corelib/thread/qmutex_unix.cpp +++ b/src/corelib/thread/qmutex_unix.cpp @@ -99,7 +99,7 @@ bool QMutexPrivate::wait(int timeout) return true; } -void QMutexPrivate::wakeUp() Q_DECL_NOTHROW +void QMutexPrivate::wakeUp() noexcept { report_error(sem_post(&semaphore), "QMutex::unlock", "sem_post"); } @@ -146,7 +146,7 @@ bool QMutexPrivate::wait(int timeout) return ret; } -void QMutexPrivate::wakeUp() Q_DECL_NOTHROW +void QMutexPrivate::wakeUp() noexcept { report_error(pthread_mutex_lock(&mutex), "QMutex::unlock", "mutex lock"); wakeup = true; diff --git a/src/corelib/thread/qmutex_win.cpp b/src/corelib/thread/qmutex_win.cpp index 3c314a4c0c..e221bc89cb 100644 --- a/src/corelib/thread/qmutex_win.cpp +++ b/src/corelib/thread/qmutex_win.cpp @@ -64,7 +64,7 @@ bool QMutexPrivate::wait(int timeout) return (WaitForSingleObjectEx(event, timeout < 0 ? INFINITE : timeout, FALSE) == WAIT_OBJECT_0); } -void QMutexPrivate::wakeUp() Q_DECL_NOTHROW +void QMutexPrivate::wakeUp() noexcept { SetEvent(event); } QT_END_NAMESPACE diff --git a/src/corelib/thread/qorderedmutexlocker_p.h b/src/corelib/thread/qorderedmutexlocker_p.h index 5b2c7ab112..e0a67388d4 100644 --- a/src/corelib/thread/qorderedmutexlocker_p.h +++ b/src/corelib/thread/qorderedmutexlocker_p.h @@ -129,7 +129,7 @@ public: } inline ~QBasicMutexLocker() { if (isLocked) unlock(); } - inline void unlock() Q_DECL_NOTHROW + inline void unlock() noexcept { isLocked = false; m->unlock(); diff --git a/src/corelib/thread/qreadwritelock.h b/src/corelib/thread/qreadwritelock.h index 65fa76fd6d..139fde9214 100644 --- a/src/corelib/thread/qreadwritelock.h +++ b/src/corelib/thread/qreadwritelock.h @@ -180,18 +180,18 @@ class Q_CORE_EXPORT QReadWriteLock { public: enum RecursionMode { NonRecursive, Recursive }; - inline explicit QReadWriteLock(RecursionMode = NonRecursive) Q_DECL_NOTHROW { } + inline explicit QReadWriteLock(RecursionMode = NonRecursive) noexcept { } inline ~QReadWriteLock() { } - static inline void lockForRead() Q_DECL_NOTHROW { } - static inline bool tryLockForRead() Q_DECL_NOTHROW { return true; } - static inline bool tryLockForRead(int timeout) Q_DECL_NOTHROW { Q_UNUSED(timeout); return true; } + static inline void lockForRead() noexcept { } + static inline bool tryLockForRead() noexcept { return true; } + static inline bool tryLockForRead(int timeout) noexcept { Q_UNUSED(timeout); return true; } - static inline void lockForWrite() Q_DECL_NOTHROW { } - static inline bool tryLockForWrite() Q_DECL_NOTHROW { return true; } - static inline bool tryLockForWrite(int timeout) Q_DECL_NOTHROW { Q_UNUSED(timeout); return true; } + static inline void lockForWrite() noexcept { } + static inline bool tryLockForWrite() noexcept { return true; } + static inline bool tryLockForWrite(int timeout) noexcept { Q_UNUSED(timeout); return true; } - static inline void unlock() Q_DECL_NOTHROW { } + static inline void unlock() noexcept { } private: Q_DISABLE_COPY(QReadWriteLock) @@ -200,12 +200,12 @@ private: class Q_CORE_EXPORT QReadLocker { public: - inline QReadLocker(QReadWriteLock *) Q_DECL_NOTHROW { } - inline ~QReadLocker() Q_DECL_NOTHROW { } + inline QReadLocker(QReadWriteLock *) noexcept { } + inline ~QReadLocker() noexcept { } - static inline void unlock() Q_DECL_NOTHROW { } - static inline void relock() Q_DECL_NOTHROW { } - static inline QReadWriteLock *readWriteLock() Q_DECL_NOTHROW { return nullptr; } + static inline void unlock() noexcept { } + static inline void relock() noexcept { } + static inline QReadWriteLock *readWriteLock() noexcept { return nullptr; } private: Q_DISABLE_COPY(QReadLocker) @@ -214,12 +214,12 @@ private: class Q_CORE_EXPORT QWriteLocker { public: - inline explicit QWriteLocker(QReadWriteLock *) Q_DECL_NOTHROW { } - inline ~QWriteLocker() Q_DECL_NOTHROW { } + inline explicit QWriteLocker(QReadWriteLock *) noexcept { } + inline ~QWriteLocker() noexcept { } - static inline void unlock() Q_DECL_NOTHROW { } - static inline void relock() Q_DECL_NOTHROW { } - static inline QReadWriteLock *readWriteLock() Q_DECL_NOTHROW { return nullptr; } + static inline void unlock() noexcept { } + static inline void relock() noexcept { } + static inline QReadWriteLock *readWriteLock() noexcept { return nullptr; } private: Q_DISABLE_COPY(QWriteLocker) diff --git a/src/corelib/thread/qsemaphore.h b/src/corelib/thread/qsemaphore.h index b830ff1bfd..58c12997ad 100644 --- a/src/corelib/thread/qsemaphore.h +++ b/src/corelib/thread/qsemaphore.h @@ -75,14 +75,14 @@ class QSemaphoreReleaser { public: QSemaphoreReleaser() = default; - explicit QSemaphoreReleaser(QSemaphore &sem, int n = 1) Q_DECL_NOTHROW + explicit QSemaphoreReleaser(QSemaphore &sem, int n = 1) noexcept : m_sem(&sem), m_n(n) {} - explicit QSemaphoreReleaser(QSemaphore *sem, int n = 1) Q_DECL_NOTHROW + explicit QSemaphoreReleaser(QSemaphore *sem, int n = 1) noexcept : m_sem(sem), m_n(n) {} - QSemaphoreReleaser(QSemaphoreReleaser &&other) Q_DECL_NOTHROW + QSemaphoreReleaser(QSemaphoreReleaser &&other) noexcept : m_sem(other.m_sem), m_n(other.m_n) { other.m_sem = nullptr; } - QSemaphoreReleaser &operator=(QSemaphoreReleaser &&other) Q_DECL_NOTHROW + QSemaphoreReleaser &operator=(QSemaphoreReleaser &&other) noexcept { QSemaphoreReleaser moved(std::move(other)); swap(moved); return *this; } ~QSemaphoreReleaser() @@ -91,16 +91,16 @@ public: m_sem->release(m_n); } - void swap(QSemaphoreReleaser &other) Q_DECL_NOTHROW + void swap(QSemaphoreReleaser &other) noexcept { qSwap(m_sem, other.m_sem); qSwap(m_n, other.m_n); } - QSemaphore *semaphore() const Q_DECL_NOTHROW + QSemaphore *semaphore() const noexcept { return m_sem; } - QSemaphore *cancel() Q_DECL_NOTHROW + QSemaphore *cancel() noexcept { QSemaphore *old = m_sem; m_sem = nullptr; diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index b023ae9ed2..170cd0dec4 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -839,7 +839,7 @@ bool QThread::event(QEvent* event) return QObject::event(event); } -Qt::HANDLE QThread::currentThreadId() Q_DECL_NOTHROW +Qt::HANDLE QThread::currentThreadId() noexcept { return Qt::HANDLE(currentThread()); } @@ -849,7 +849,7 @@ QThread *QThread::currentThread() return QThreadData::current()->thread; } -int QThread::idealThreadCount() Q_DECL_NOTHROW +int QThread::idealThreadCount() noexcept { return 1; } diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h index b6c5bf47d0..8e92d75401 100644 --- a/src/corelib/thread/qthread.h +++ b/src/corelib/thread/qthread.h @@ -70,9 +70,9 @@ class Q_CORE_EXPORT QThread : public QObject { Q_OBJECT public: - static Qt::HANDLE currentThreadId() Q_DECL_NOTHROW Q_DECL_PURE_FUNCTION; + static Qt::HANDLE currentThreadId() noexcept Q_DECL_PURE_FUNCTION; static QThread *currentThread(); - static int idealThreadCount() Q_DECL_NOTHROW; + static int idealThreadCount() noexcept; static void yieldCurrentThread(); explicit QThread(QObject *parent = nullptr); diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h index e614ddd004..209225de98 100644 --- a/src/corelib/thread/qthread_p.h +++ b/src/corelib/thread/qthread_p.h @@ -187,8 +187,8 @@ public: #endif // Q_OS_UNIX #ifdef Q_OS_WIN - static unsigned int __stdcall start(void *) Q_DECL_NOEXCEPT; - static void finish(void *, bool lockAnyway=true) Q_DECL_NOEXCEPT; + static unsigned int __stdcall start(void *) noexcept; + static void finish(void *, bool lockAnyway=true) noexcept; Qt::HANDLE handle; unsigned int id; diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index a13f8ca215..8328e514a8 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -443,7 +443,7 @@ void QThreadPrivate::finish(void *arg) ** QThread *************************************************************************/ -Qt::HANDLE QThread::currentThreadId() Q_DECL_NOTHROW +Qt::HANDLE QThread::currentThreadId() noexcept { // requires a C cast here otherwise we run into trouble on AIX return to_HANDLE(pthread_self()); @@ -454,7 +454,7 @@ Qt::HANDLE QThread::currentThreadId() Q_DECL_NOTHROW # define _SC_NPROCESSORS_ONLN 84 #endif -int QThread::idealThreadCount() Q_DECL_NOTHROW +int QThread::idealThreadCount() noexcept { int cores = 1; diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index e56fe2c6ae..ee73280707 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -372,7 +372,7 @@ QAbstractEventDispatcher *QThreadPrivate::createEventDispatcher(QThreadData *dat #if QT_CONFIG(thread) -unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(void *arg) Q_DECL_NOEXCEPT +unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(void *arg) noexcept { QThread *thr = reinterpret_cast(arg); QThreadData *data = QThreadData::get2(thr); @@ -406,7 +406,7 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi return 0; } -void QThreadPrivate::finish(void *arg, bool lockAnyway) Q_DECL_NOEXCEPT +void QThreadPrivate::finish(void *arg, bool lockAnyway) noexcept { QThread *thr = reinterpret_cast(arg); QThreadPrivate *d = thr->d_func(); @@ -447,12 +447,12 @@ void QThreadPrivate::finish(void *arg, bool lockAnyway) Q_DECL_NOEXCEPT ** QThread *************************************************************************/ -Qt::HANDLE QThread::currentThreadId() Q_DECL_NOTHROW +Qt::HANDLE QThread::currentThreadId() noexcept { return reinterpret_cast(quintptr(GetCurrentThreadId())); } -int QThread::idealThreadCount() Q_DECL_NOTHROW +int QThread::idealThreadCount() noexcept { SYSTEM_INFO sysinfo; #ifndef Q_OS_WINRT diff --git a/src/corelib/tools/qalgorithms.h b/src/corelib/tools/qalgorithms.h index 0146e22fa3..f1243b5c61 100644 --- a/src/corelib/tools/qalgorithms.h +++ b/src/corelib/tools/qalgorithms.h @@ -533,7 +533,7 @@ QT_DEPRECATED_X("Use std::binary_search") Q_OUTOFLINE_TEMPLATE RandomAccessItera #if defined QT_HAS_CONSTEXPR_BUILTINS #if defined(Q_CC_GNU) || defined(Q_CC_CLANG) # define QT_HAS_BUILTIN_CTZS -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctzs(quint16 v) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctzs(quint16 v) noexcept { # if QT_HAS_BUILTIN(__builtin_ctzs) return __builtin_ctzs(v); @@ -542,7 +542,7 @@ Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctzs(quint16 v) Q_DECL_NOTHROW # endif } #define QT_HAS_BUILTIN_CLZS -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clzs(quint16 v) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clzs(quint16 v) noexcept { # if QT_HAS_BUILTIN(__builtin_clzs) return __builtin_clzs(v); @@ -551,40 +551,40 @@ Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clzs(quint16 v) Q_DECL_NOTHROW # endif } #define QT_HAS_BUILTIN_CTZ -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctz(quint32 v) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctz(quint32 v) noexcept { return __builtin_ctz(v); } #define QT_HAS_BUILTIN_CLZ -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clz(quint32 v) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clz(quint32 v) noexcept { return __builtin_clz(v); } #define QT_HAS_BUILTIN_CTZLL -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctzll(quint64 v) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctzll(quint64 v) noexcept { return __builtin_ctzll(v); } #define QT_HAS_BUILTIN_CLZLL -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clzll(quint64 v) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clzll(quint64 v) noexcept { return __builtin_clzll(v); } #define QALGORITHMS_USE_BUILTIN_POPCOUNT -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint32 v) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint32 v) noexcept { return __builtin_popcount(v); } -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint8 v) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint8 v) noexcept { return __builtin_popcount(v); } -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint16 v) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint16 v) noexcept { return __builtin_popcount(v); } #define QALGORITHMS_USE_BUILTIN_POPCOUNTLL -Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcountll(quint64 v) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcountll(quint64 v) noexcept { return __builtin_popcountll(v); } @@ -630,12 +630,12 @@ Q_ALWAYS_INLINE unsigned long qt_builtin_clzll(quint64 val) } #endif // MSVC 64bit # define QT_HAS_BUILTIN_CTZS -Q_ALWAYS_INLINE uint qt_builtin_ctzs(quint16 v) Q_DECL_NOTHROW +Q_ALWAYS_INLINE uint qt_builtin_ctzs(quint16 v) noexcept { return qt_builtin_ctz(v); } #define QT_HAS_BUILTIN_CLZS -Q_ALWAYS_INLINE uint qt_builtin_clzs(quint16 v) Q_DECL_NOTHROW +Q_ALWAYS_INLINE uint qt_builtin_clzs(quint16 v) noexcept { return qt_builtin_clz(v) - 16U; } @@ -652,19 +652,19 @@ Q_ALWAYS_INLINE uint qt_builtin_clzs(quint16 v) Q_DECL_NOTHROW #if defined(__AVX__) || defined(__SSE4_2__) || defined(__POPCNT__) #define QALGORITHMS_USE_BUILTIN_POPCOUNT #define QALGORITHMS_USE_BUILTIN_POPCOUNTLL -Q_ALWAYS_INLINE uint qt_builtin_popcount(quint32 v) Q_DECL_NOTHROW +Q_ALWAYS_INLINE uint qt_builtin_popcount(quint32 v) noexcept { return __popcnt(v); } -Q_ALWAYS_INLINE uint qt_builtin_popcount(quint8 v) Q_DECL_NOTHROW +Q_ALWAYS_INLINE uint qt_builtin_popcount(quint8 v) noexcept { return __popcnt16(v); } -Q_ALWAYS_INLINE uint qt_builtin_popcount(quint16 v) Q_DECL_NOTHROW +Q_ALWAYS_INLINE uint qt_builtin_popcount(quint16 v) noexcept { return __popcnt16(v); } -Q_ALWAYS_INLINE uint qt_builtin_popcountll(quint64 v) Q_DECL_NOTHROW +Q_ALWAYS_INLINE uint qt_builtin_popcountll(quint64 v) noexcept { #if Q_PROCESSOR_WORDSIZE == 8 return __popcnt64(v); @@ -685,7 +685,7 @@ Q_ALWAYS_INLINE uint qt_builtin_popcountll(quint64 v) Q_DECL_NOTHROW } //namespace QAlgorithmsPrivate -Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(quint32 v) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(quint32 v) noexcept { #ifdef QALGORITHMS_USE_BUILTIN_POPCOUNT return QAlgorithmsPrivate::qt_builtin_popcount(v); @@ -698,7 +698,7 @@ Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(quint32 #endif } -Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(quint8 v) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(quint8 v) noexcept { #ifdef QALGORITHMS_USE_BUILTIN_POPCOUNT return QAlgorithmsPrivate::qt_builtin_popcount(v); @@ -708,7 +708,7 @@ Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(quint8 #endif } -Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(quint16 v) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(quint16 v) noexcept { #ifdef QALGORITHMS_USE_BUILTIN_POPCOUNT return QAlgorithmsPrivate::qt_builtin_popcount(v); @@ -719,7 +719,7 @@ Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(quint16 #endif } -Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(quint64 v) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(quint64 v) noexcept { #ifdef QALGORITHMS_USE_BUILTIN_POPCOUNTLL return QAlgorithmsPrivate::qt_builtin_popcountll(v); @@ -734,7 +734,7 @@ Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(quint64 #endif } -Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(long unsigned int v) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(long unsigned int v) noexcept { return qPopulationCount(static_cast(v)); } @@ -744,7 +744,7 @@ Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR inline uint qPopulationCount(long un #endif #undef QT_POPCOUNT_CONSTEXPR -Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint32 v) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint32 v) noexcept { #if defined(QT_HAS_BUILTIN_CTZ) return v ? QAlgorithmsPrivate::qt_builtin_ctz(v) : 32U; @@ -762,7 +762,7 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint32 v) Q_DECL_NO #endif } -Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint8 v) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint8 v) noexcept { #if defined(QT_HAS_BUILTIN_CTZ) return v ? QAlgorithmsPrivate::qt_builtin_ctz(v) : 8U; @@ -777,7 +777,7 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint8 v) Q_DECL_NOT #endif } -Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint16 v) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint16 v) noexcept { #if defined(QT_HAS_BUILTIN_CTZS) return v ? QAlgorithmsPrivate::qt_builtin_ctzs(v) : 16U; @@ -793,7 +793,7 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint16 v) Q_DECL_NO #endif } -Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint64 v) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint64 v) noexcept { #if defined(QT_HAS_BUILTIN_CTZLL) return v ? QAlgorithmsPrivate::qt_builtin_ctzll(v) : 64; @@ -804,12 +804,12 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint64 v) Q_DECL_NO #endif } -Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(unsigned long v) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(unsigned long v) noexcept { return qCountTrailingZeroBits(QIntegerForSizeof::Unsigned(v)); } -Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint32 v) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint32 v) noexcept { #if defined(QT_HAS_BUILTIN_CLZ) return v ? QAlgorithmsPrivate::qt_builtin_clz(v) : 32U; @@ -824,7 +824,7 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint32 v) Q_DECL_NOT #endif } -QT_POPCOUNT_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint8 v) Q_DECL_NOTHROW +QT_POPCOUNT_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint8 v) noexcept { #if defined(QT_HAS_BUILTIN_CLZ) return v ? QAlgorithmsPrivate::qt_builtin_clz(v)-24U : 8U; @@ -836,7 +836,7 @@ QT_POPCOUNT_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint8 v) Q_DECL #endif } -QT_POPCOUNT_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint16 v) Q_DECL_NOTHROW +QT_POPCOUNT_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint16 v) noexcept { #if defined(QT_HAS_BUILTIN_CLZS) return v ? QAlgorithmsPrivate::qt_builtin_clzs(v) : 16U; @@ -849,7 +849,7 @@ QT_POPCOUNT_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint16 v) Q_DEC #endif } -QT_POPCOUNT_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint64 v) Q_DECL_NOTHROW +QT_POPCOUNT_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint64 v) noexcept { #if defined(QT_HAS_BUILTIN_CLZLL) return v ? QAlgorithmsPrivate::qt_builtin_clzll(v) : 64U; @@ -864,7 +864,7 @@ QT_POPCOUNT_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint64 v) Q_DEC #endif } -QT_POPCOUNT_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(unsigned long v) Q_DECL_NOTHROW +QT_POPCOUNT_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(unsigned long v) noexcept { return qCountLeadingZeroBits(QIntegerForSizeof::Unsigned(v)); } diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp index a91d833e3b..bcc0688a91 100644 --- a/src/corelib/tools/qarraydata.cpp +++ b/src/corelib/tools/qarraydata.cpp @@ -87,7 +87,7 @@ static QArrayData *reallocateData(QArrayData *header, size_t allocSize, uint opt } QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment, - size_t capacity, AllocationOptions options) Q_DECL_NOTHROW + size_t capacity, AllocationOptions options) noexcept { // Alignment is a power of two Q_ASSERT(alignment >= Q_ALIGNOF(QArrayData) @@ -135,7 +135,7 @@ QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment, } QArrayData *QArrayData::reallocateUnaligned(QArrayData *data, size_t objectSize, size_t capacity, - AllocationOptions options) Q_DECL_NOTHROW + AllocationOptions options) noexcept { Q_ASSERT(data); Q_ASSERT(data->isMutable()); @@ -150,7 +150,7 @@ QArrayData *QArrayData::reallocateUnaligned(QArrayData *data, size_t objectSize, } void QArrayData::deallocate(QArrayData *data, size_t objectSize, - size_t alignment) Q_DECL_NOTHROW + size_t alignment) noexcept { // Alignment is a power of two Q_ASSERT(alignment >= Q_ALIGNOF(QArrayData) diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index a642fb9b39..f78b9be2db 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -113,14 +113,14 @@ struct Q_CORE_EXPORT QArrayData } Q_REQUIRED_RESULT static QArrayData *allocate(size_t objectSize, size_t alignment, - size_t capacity, AllocationOptions options = Default) Q_DECL_NOTHROW; + size_t capacity, AllocationOptions options = Default) noexcept; Q_REQUIRED_RESULT static QArrayData *reallocateUnaligned(QArrayData *data, size_t objectSize, - size_t newCapacity, AllocationOptions newOptions = Default) Q_DECL_NOTHROW; + size_t newCapacity, AllocationOptions newOptions = Default) noexcept; static void deallocate(QArrayData *data, size_t objectSize, - size_t alignment) Q_DECL_NOTHROW; + size_t alignment) noexcept; static const QArrayData shared_null[2]; - static QArrayData *sharedNull() Q_DECL_NOTHROW { return const_cast(shared_null); } + static QArrayData *sharedNull() noexcept { return const_cast(shared_null); } }; Q_DECLARE_OPERATORS_FOR_FLAGS(QArrayData::AllocationOptions) @@ -254,7 +254,7 @@ struct QTypedArrayData return result; } - static QTypedArrayData *sharedNull() Q_DECL_NOTHROW + static QTypedArrayData *sharedNull() noexcept { Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); return static_cast(QArrayData::sharedNull()); diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index 51cfa6e849..bce8fc8ddc 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -52,7 +52,7 @@ private: typedef QArrayDataOps DataOps; public: - QArrayDataPointer() Q_DECL_NOTHROW + QArrayDataPointer() noexcept : d(Data::sharedNull()) { } @@ -83,13 +83,13 @@ public: } #ifdef Q_COMPILER_RVALUE_REFS - QArrayDataPointer(QArrayDataPointer &&other) Q_DECL_NOTHROW + QArrayDataPointer(QArrayDataPointer &&other) noexcept : d(other.d) { other.d = Data::sharedNull(); } - QArrayDataPointer &operator=(QArrayDataPointer &&other) Q_DECL_NOTHROW + QArrayDataPointer &operator=(QArrayDataPointer &&other) noexcept { QArrayDataPointer moved(std::move(other)); this->swap(moved); @@ -150,7 +150,7 @@ public: bool isSharable() const { return d->isSharable(); } #endif - void swap(QArrayDataPointer &other) Q_DECL_NOTHROW + void swap(QArrayDataPointer &other) noexcept { qSwap(d, other.d); } diff --git a/src/corelib/tools/qbitarray.h b/src/corelib/tools/qbitarray.h index ff40bf5654..78beff0d42 100644 --- a/src/corelib/tools/qbitarray.h +++ b/src/corelib/tools/qbitarray.h @@ -50,21 +50,21 @@ class Q_CORE_EXPORT QBitArray { friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QBitArray &); friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QBitArray &); - friend Q_CORE_EXPORT uint qHash(const QBitArray &key, uint seed) Q_DECL_NOTHROW; + friend Q_CORE_EXPORT uint qHash(const QBitArray &key, uint seed) noexcept; QByteArray d; public: - inline QBitArray() Q_DECL_NOTHROW {} + inline QBitArray() noexcept {} explicit QBitArray(int size, bool val = false); QBitArray(const QBitArray &other) : d(other.d) {} inline QBitArray &operator=(const QBitArray &other) { d = other.d; return *this; } #ifdef Q_COMPILER_RVALUE_REFS - inline QBitArray(QBitArray &&other) Q_DECL_NOTHROW : d(std::move(other.d)) {} - inline QBitArray &operator=(QBitArray &&other) Q_DECL_NOTHROW + inline QBitArray(QBitArray &&other) noexcept : d(std::move(other.d)) {} + inline QBitArray &operator=(QBitArray &&other) noexcept { qSwap(d, other.d); return *this; } #endif - inline void swap(QBitArray &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + inline void swap(QBitArray &other) noexcept { qSwap(d, other.d); } inline int size() const { return (d.size() << 3) - *d.constData(); } inline int count() const { return (d.size() << 3) - *d.constData(); } diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index 8bf20350d6..a5a473acf4 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -165,7 +165,7 @@ int qFindByteArray( This function returns SIZE_MAX (~0) on overflow or if the memory block size would not fit an int. */ -size_t qCalculateBlockSize(size_t elementCount, size_t elementSize, size_t headerSize) Q_DECL_NOTHROW +size_t qCalculateBlockSize(size_t elementCount, size_t elementSize, size_t headerSize) noexcept { unsigned count = unsigned(elementCount); unsigned size = unsigned(elementSize); @@ -206,7 +206,7 @@ size_t qCalculateBlockSize(size_t elementCount, size_t elementSize, size_t heade needed. */ CalculateGrowingBlockSizeResult -qCalculateGrowingBlockSize(size_t elementCount, size_t elementSize, size_t headerSize) Q_DECL_NOTHROW +qCalculateGrowingBlockSize(size_t elementCount, size_t elementSize, size_t headerSize) noexcept { CalculateGrowingBlockSizeResult result = { std::numeric_limits::max(),std::numeric_limits::max() @@ -1281,7 +1281,7 @@ QByteArray qUncompress(const uchar* data, int nbytes) Assigns \a other to this byte array and returns a reference to this byte array. */ -QByteArray &QByteArray::operator=(const QByteArray & other) Q_DECL_NOTHROW +QByteArray &QByteArray::operator=(const QByteArray & other) noexcept { other.d->ref.ref(); if (!d->ref.deref()) diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h index 8ee3a29ecc..318d773eb6 100644 --- a/src/corelib/tools/qbytearray.h +++ b/src/corelib/tools/qbytearray.h @@ -168,22 +168,22 @@ public: }; Q_DECLARE_FLAGS(Base64Options, Base64Option) - inline QByteArray() Q_DECL_NOTHROW; + inline QByteArray() noexcept; QByteArray(const char *, int size = -1); QByteArray(int size, char c); QByteArray(int size, Qt::Initialization); - inline QByteArray(const QByteArray &) Q_DECL_NOTHROW; + inline QByteArray(const QByteArray &) noexcept; inline ~QByteArray(); - QByteArray &operator=(const QByteArray &) Q_DECL_NOTHROW; + QByteArray &operator=(const QByteArray &) noexcept; QByteArray &operator=(const char *str); #ifdef Q_COMPILER_RVALUE_REFS - inline QByteArray(QByteArray && other) Q_DECL_NOTHROW : d(other.d) { other.d = Data::sharedNull(); } - inline QByteArray &operator=(QByteArray &&other) Q_DECL_NOTHROW + inline QByteArray(QByteArray && other) noexcept : d(other.d) { other.d = Data::sharedNull(); } + inline QByteArray &operator=(QByteArray &&other) noexcept { qSwap(d, other.d); return *this; } #endif - inline void swap(QByteArray &other) Q_DECL_NOTHROW + inline void swap(QByteArray &other) noexcept { qSwap(d, other.d); } inline int size() const; @@ -472,7 +472,7 @@ public: Q_DECLARE_OPERATORS_FOR_FLAGS(QByteArray::Base64Options) -inline QByteArray::QByteArray() Q_DECL_NOTHROW : d(Data::sharedNull()) { } +inline QByteArray::QByteArray() noexcept : d(Data::sharedNull()) { } inline QByteArray::~QByteArray() { if (!d->ref.deref()) Data::deallocate(d); } inline int QByteArray::size() const { return d->size; } @@ -502,7 +502,7 @@ inline void QByteArray::detach() { if (d->ref.isShared() || (d->offset != sizeof(QByteArrayData))) reallocData(uint(d->size) + 1u, d->detachFlags()); } inline bool QByteArray::isDetached() const { return !d->ref.isShared(); } -inline QByteArray::QByteArray(const QByteArray &a) Q_DECL_NOTHROW : d(a.d) +inline QByteArray::QByteArray(const QByteArray &a) noexcept : d(a.d) { d->ref.ref(); } inline int QByteArray::capacity() const @@ -617,41 +617,41 @@ inline int QByteArray::compare(const QByteArray &a, Qt::CaseSensitivity cs) cons return cs == Qt::CaseSensitive ? qstrcmp(*this, a) : qstrnicmp(data(), size(), a.data(), a.size()); } -inline bool operator==(const QByteArray &a1, const QByteArray &a2) Q_DECL_NOTHROW +inline bool operator==(const QByteArray &a1, const QByteArray &a2) noexcept { return (a1.size() == a2.size()) && (memcmp(a1.constData(), a2.constData(), a1.size())==0); } -inline bool operator==(const QByteArray &a1, const char *a2) Q_DECL_NOTHROW +inline bool operator==(const QByteArray &a1, const char *a2) noexcept { return a2 ? qstrcmp(a1,a2) == 0 : a1.isEmpty(); } -inline bool operator==(const char *a1, const QByteArray &a2) Q_DECL_NOTHROW +inline bool operator==(const char *a1, const QByteArray &a2) noexcept { return a1 ? qstrcmp(a1,a2) == 0 : a2.isEmpty(); } -inline bool operator!=(const QByteArray &a1, const QByteArray &a2) Q_DECL_NOTHROW +inline bool operator!=(const QByteArray &a1, const QByteArray &a2) noexcept { return !(a1==a2); } -inline bool operator!=(const QByteArray &a1, const char *a2) Q_DECL_NOTHROW +inline bool operator!=(const QByteArray &a1, const char *a2) noexcept { return a2 ? qstrcmp(a1,a2) != 0 : !a1.isEmpty(); } -inline bool operator!=(const char *a1, const QByteArray &a2) Q_DECL_NOTHROW +inline bool operator!=(const char *a1, const QByteArray &a2) noexcept { return a1 ? qstrcmp(a1,a2) != 0 : !a2.isEmpty(); } -inline bool operator<(const QByteArray &a1, const QByteArray &a2) Q_DECL_NOTHROW +inline bool operator<(const QByteArray &a1, const QByteArray &a2) noexcept { return qstrcmp(a1, a2) < 0; } - inline bool operator<(const QByteArray &a1, const char *a2) Q_DECL_NOTHROW + inline bool operator<(const QByteArray &a1, const char *a2) noexcept { return qstrcmp(a1, a2) < 0; } -inline bool operator<(const char *a1, const QByteArray &a2) Q_DECL_NOTHROW +inline bool operator<(const char *a1, const QByteArray &a2) noexcept { return qstrcmp(a1, a2) < 0; } -inline bool operator<=(const QByteArray &a1, const QByteArray &a2) Q_DECL_NOTHROW +inline bool operator<=(const QByteArray &a1, const QByteArray &a2) noexcept { return qstrcmp(a1, a2) <= 0; } -inline bool operator<=(const QByteArray &a1, const char *a2) Q_DECL_NOTHROW +inline bool operator<=(const QByteArray &a1, const char *a2) noexcept { return qstrcmp(a1, a2) <= 0; } -inline bool operator<=(const char *a1, const QByteArray &a2) Q_DECL_NOTHROW +inline bool operator<=(const char *a1, const QByteArray &a2) noexcept { return qstrcmp(a1, a2) <= 0; } -inline bool operator>(const QByteArray &a1, const QByteArray &a2) Q_DECL_NOTHROW +inline bool operator>(const QByteArray &a1, const QByteArray &a2) noexcept { return qstrcmp(a1, a2) > 0; } -inline bool operator>(const QByteArray &a1, const char *a2) Q_DECL_NOTHROW +inline bool operator>(const QByteArray &a1, const char *a2) noexcept { return qstrcmp(a1, a2) > 0; } -inline bool operator>(const char *a1, const QByteArray &a2) Q_DECL_NOTHROW +inline bool operator>(const char *a1, const QByteArray &a2) noexcept { return qstrcmp(a1, a2) > 0; } -inline bool operator>=(const QByteArray &a1, const QByteArray &a2) Q_DECL_NOTHROW +inline bool operator>=(const QByteArray &a1, const QByteArray &a2) noexcept { return qstrcmp(a1, a2) >= 0; } -inline bool operator>=(const QByteArray &a1, const char *a2) Q_DECL_NOTHROW +inline bool operator>=(const QByteArray &a1, const char *a2) noexcept { return qstrcmp(a1, a2) >= 0; } -inline bool operator>=(const char *a1, const QByteArray &a2) Q_DECL_NOTHROW +inline bool operator>=(const char *a1, const QByteArray &a2) noexcept { return qstrcmp(a1, a2) >= 0; } #if !defined(QT_USE_QSTRINGBUILDER) inline const QByteArray operator+(const QByteArray &a1, const QByteArray &a2) diff --git a/src/corelib/tools/qbytearraymatcher.cpp b/src/corelib/tools/qbytearraymatcher.cpp index 72f0e0519d..d2eb4e0e3c 100644 --- a/src/corelib/tools/qbytearraymatcher.cpp +++ b/src/corelib/tools/qbytearraymatcher.cpp @@ -404,7 +404,7 @@ int qFindByteArray( /*! \internal */ -int QStaticByteArrayMatcherBase::indexOfIn(const char *needle, uint nlen, const char *haystack, int hlen, int from) const Q_DECL_NOTHROW +int QStaticByteArrayMatcherBase::indexOfIn(const char *needle, uint nlen, const char *haystack, int hlen, int from) const noexcept { if (from < 0) from = 0; diff --git a/src/corelib/tools/qbytearraymatcher.h b/src/corelib/tools/qbytearraymatcher.h index dafaea9c12..0eedfc1d20 100644 --- a/src/corelib/tools/qbytearraymatcher.h +++ b/src/corelib/tools/qbytearraymatcher.h @@ -90,15 +90,15 @@ class QStaticByteArrayMatcherBase uchar data[256]; } m_skiptable; protected: - explicit Q_DECL_RELAXED_CONSTEXPR QStaticByteArrayMatcherBase(const char *pattern, uint n) Q_DECL_NOTHROW + explicit Q_DECL_RELAXED_CONSTEXPR QStaticByteArrayMatcherBase(const char *pattern, uint n) noexcept : m_skiptable(generate(pattern, n)) {} // compiler-generated copy/more ctors/assignment operators are ok! // compiler-generated dtor is ok! - Q_CORE_EXPORT int indexOfIn(const char *needle, uint nlen, const char *haystack, int hlen, int from) const Q_DECL_NOTHROW; + Q_CORE_EXPORT int indexOfIn(const char *needle, uint nlen, const char *haystack, int hlen, int from) const noexcept; private: - static Q_DECL_RELAXED_CONSTEXPR Skiptable generate(const char *pattern, uint n) Q_DECL_NOTHROW + static Q_DECL_RELAXED_CONSTEXPR Skiptable generate(const char *pattern, uint n) noexcept { const auto uchar_max = (std::numeric_limits::max)(); uchar max = n > uchar_max ? uchar_max : n; @@ -140,23 +140,23 @@ class QStaticByteArrayMatcher : QStaticByteArrayMatcherBase char m_pattern[N]; Q_STATIC_ASSERT_X(N > 2, "QStaticByteArrayMatcher makes no sense for finding a single-char pattern"); public: - explicit Q_DECL_RELAXED_CONSTEXPR QStaticByteArrayMatcher(const char (&patternToMatch)[N]) Q_DECL_NOTHROW + explicit Q_DECL_RELAXED_CONSTEXPR QStaticByteArrayMatcher(const char (&patternToMatch)[N]) noexcept : QStaticByteArrayMatcherBase(patternToMatch, N - 1), m_pattern() { for (uint i = 0; i < N; ++i) m_pattern[i] = patternToMatch[i]; } - int indexIn(const QByteArray &haystack, int from = 0) const Q_DECL_NOTHROW + int indexIn(const QByteArray &haystack, int from = 0) const noexcept { return this->indexOfIn(m_pattern, N - 1, haystack.data(), haystack.size(), from); } - int indexIn(const char *haystack, int hlen, int from = 0) const Q_DECL_NOTHROW + int indexIn(const char *haystack, int hlen, int from = 0) const noexcept { return this->indexOfIn(m_pattern, N - 1, haystack, hlen, from); } QByteArray pattern() const { return QByteArray(m_pattern, int(N - 1)); } }; template -Q_DECL_RELAXED_CONSTEXPR QStaticByteArrayMatcher qMakeStaticByteArrayMatcher(const char (&pattern)[N]) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR QStaticByteArrayMatcher qMakeStaticByteArrayMatcher(const char (&pattern)[N]) noexcept { return QStaticByteArrayMatcher(pattern); } QT_END_NAMESPACE diff --git a/src/corelib/tools/qcache.h b/src/corelib/tools/qcache.h index b558a8358d..4fcde46fbc 100644 --- a/src/corelib/tools/qcache.h +++ b/src/corelib/tools/qcache.h @@ -89,7 +89,7 @@ class QCache Q_DISABLE_COPY(QCache) public: - inline explicit QCache(int maxCost = 100) Q_DECL_NOTHROW; + inline explicit QCache(int maxCost = 100) noexcept; inline ~QCache() { clear(); } inline int maxCost() const { return mx; } @@ -116,7 +116,7 @@ private: }; template -inline QCache::QCache(int amaxCost) Q_DECL_NOTHROW +inline QCache::QCache(int amaxCost) noexcept : f(nullptr), l(nullptr), mx(amaxCost), total(0) {} template diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp index 47c853084b..d6061defc3 100644 --- a/src/corelib/tools/qchar.cpp +++ b/src/corelib/tools/qchar.cpp @@ -733,7 +733,7 @@ QT_BEGIN_NAMESPACE Note that this gives no indication of whether the character is available in a particular font. */ -bool QChar::isPrint(uint ucs4) Q_DECL_NOTHROW +bool QChar::isPrint(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return false; @@ -766,7 +766,7 @@ bool QChar::isPrint(uint ucs4) Q_DECL_NOTHROW /*! \internal */ -bool QT_FASTCALL QChar::isSpace_helper(uint ucs4) Q_DECL_NOTHROW +bool QT_FASTCALL QChar::isSpace_helper(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return false; @@ -792,7 +792,7 @@ bool QT_FASTCALL QChar::isSpace_helper(uint ucs4) Q_DECL_NOTHROW Returns \c true if the UCS-4-encoded character specified by \a ucs4 is a mark (Mark_* categories); otherwise returns \c false. */ -bool QChar::isMark(uint ucs4) Q_DECL_NOTHROW +bool QChar::isMark(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return false; @@ -816,7 +816,7 @@ bool QChar::isMark(uint ucs4) Q_DECL_NOTHROW Returns \c true if the UCS-4-encoded character specified by \a ucs4 is a punctuation mark (Punctuation_* categories); otherwise returns \c false. */ -bool QChar::isPunct(uint ucs4) Q_DECL_NOTHROW +bool QChar::isPunct(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return false; @@ -844,7 +844,7 @@ bool QChar::isPunct(uint ucs4) Q_DECL_NOTHROW Returns \c true if the UCS-4-encoded character specified by \a ucs4 is a symbol (Symbol_* categories); otherwise returns \c false. */ -bool QChar::isSymbol(uint ucs4) Q_DECL_NOTHROW +bool QChar::isSymbol(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return false; @@ -874,7 +874,7 @@ bool QChar::isSymbol(uint ucs4) Q_DECL_NOTHROW /*! \internal */ -bool QT_FASTCALL QChar::isLetter_helper(uint ucs4) Q_DECL_NOTHROW +bool QT_FASTCALL QChar::isLetter_helper(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return false; @@ -909,7 +909,7 @@ bool QT_FASTCALL QChar::isLetter_helper(uint ucs4) Q_DECL_NOTHROW /*! \internal */ -bool QT_FASTCALL QChar::isNumber_helper(uint ucs4) Q_DECL_NOTHROW +bool QT_FASTCALL QChar::isNumber_helper(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return false; @@ -938,7 +938,7 @@ bool QT_FASTCALL QChar::isNumber_helper(uint ucs4) Q_DECL_NOTHROW /*! \internal */ -bool QT_FASTCALL QChar::isLetterOrNumber_helper(uint ucs4) Q_DECL_NOTHROW +bool QT_FASTCALL QChar::isLetterOrNumber_helper(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return false; @@ -1101,7 +1101,7 @@ bool QT_FASTCALL QChar::isLetterOrNumber_helper(uint ucs4) Q_DECL_NOTHROW Returns the numeric value of the digit specified by the UCS-4-encoded character, \a ucs4, or -1 if the character is not a digit. */ -int QChar::digitValue(uint ucs4) Q_DECL_NOTHROW +int QChar::digitValue(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return -1; @@ -1118,7 +1118,7 @@ int QChar::digitValue(uint ucs4) Q_DECL_NOTHROW \overload Returns the category of the UCS-4-encoded character specified by \a ucs4. */ -QChar::Category QChar::category(uint ucs4) Q_DECL_NOTHROW +QChar::Category QChar::category(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return QChar::Other_NotAssigned; @@ -1135,7 +1135,7 @@ QChar::Category QChar::category(uint ucs4) Q_DECL_NOTHROW \overload Returns the direction of the UCS-4-encoded character specified by \a ucs4. */ -QChar::Direction QChar::direction(uint ucs4) Q_DECL_NOTHROW +QChar::Direction QChar::direction(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return QChar::DirL; @@ -1158,7 +1158,7 @@ QChar::Direction QChar::direction(uint ucs4) Q_DECL_NOTHROW character specified by \a ucs4 (needed for certain languages such as Arabic or Syriac). */ -QChar::JoiningType QChar::joiningType(uint ucs4) Q_DECL_NOTHROW +QChar::JoiningType QChar::joiningType(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return QChar::Joining_None; @@ -1181,7 +1181,7 @@ QChar::JoiningType QChar::joiningType(uint ucs4) Q_DECL_NOTHROW Returns information about the joining properties of the UCS-4-encoded character specified by \a ucs4 (needed for certain languages such as Arabic). */ -QChar::Joining QChar::joining(uint ucs4) Q_DECL_NOTHROW +QChar::Joining QChar::joining(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return QChar::OtherJoining; @@ -1217,7 +1217,7 @@ QChar::Joining QChar::joining(uint ucs4) Q_DECL_NOTHROW \sa mirroredChar() */ -bool QChar::hasMirrored(uint ucs4) Q_DECL_NOTHROW +bool QChar::hasMirrored(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return false; @@ -1299,7 +1299,7 @@ bool QChar::hasMirrored(uint ucs4) Q_DECL_NOTHROW \sa hasMirrored() */ -uint QChar::mirroredChar(uint ucs4) Q_DECL_NOTHROW +uint QChar::mirroredChar(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return ucs4; @@ -1383,7 +1383,7 @@ QString QChar::decomposition(uint ucs4) Returns the tag defining the composition of the UCS-4-encoded character specified by \a ucs4. Returns QChar::NoDecomposition if no decomposition exists. */ -QChar::Decomposition QChar::decompositionTag(uint ucs4) Q_DECL_NOTHROW +QChar::Decomposition QChar::decompositionTag(uint ucs4) noexcept { if (ucs4 >= Hangul_SBase && ucs4 < Hangul_SBase + Hangul_SCount) return QChar::Canonical; @@ -1409,7 +1409,7 @@ QChar::Decomposition QChar::decompositionTag(uint ucs4) Q_DECL_NOTHROW Returns the combining class for the UCS-4-encoded character specified by \a ucs4, as defined in the Unicode standard. */ -unsigned char QChar::combiningClass(uint ucs4) Q_DECL_NOTHROW +unsigned char QChar::combiningClass(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return 0; @@ -1430,7 +1430,7 @@ unsigned char QChar::combiningClass(uint ucs4) Q_DECL_NOTHROW Returns the Unicode script property value for the character specified in its UCS-4-encoded form as \a ucs4. */ -QChar::Script QChar::script(uint ucs4) Q_DECL_NOTHROW +QChar::Script QChar::script(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return QChar::Script_Unknown; @@ -1448,7 +1448,7 @@ QChar::Script QChar::script(uint ucs4) Q_DECL_NOTHROW Returns the Unicode version that introduced the character specified in its UCS-4-encoded form as \a ucs4. */ -QChar::UnicodeVersion QChar::unicodeVersion(uint ucs4) Q_DECL_NOTHROW +QChar::UnicodeVersion QChar::unicodeVersion(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return QChar::Unicode_Unassigned; @@ -1458,14 +1458,14 @@ QChar::UnicodeVersion QChar::unicodeVersion(uint ucs4) Q_DECL_NOTHROW /*! Returns the most recent supported Unicode version. */ -QChar::UnicodeVersion QChar::currentUnicodeVersion() Q_DECL_NOTHROW +QChar::UnicodeVersion QChar::currentUnicodeVersion() noexcept { return UNICODE_DATA_VERSION; } template -Q_DECL_CONST_FUNCTION static inline T convertCase_helper(T uc) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION static inline T convertCase_helper(T uc) noexcept { const QUnicodeTables::Properties *prop = qGetProp(uc); @@ -1491,7 +1491,7 @@ Q_DECL_CONST_FUNCTION static inline T convertCase_helper(T uc) Q_DECL_NOTHROW by \a ucs4 if the character is uppercase or titlecase; otherwise returns the character itself. */ -uint QChar::toLower(uint ucs4) Q_DECL_NOTHROW +uint QChar::toLower(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return ucs4; @@ -1511,7 +1511,7 @@ uint QChar::toLower(uint ucs4) Q_DECL_NOTHROW by \a ucs4 if the character is lowercase or titlecase; otherwise returns the character itself. */ -uint QChar::toUpper(uint ucs4) Q_DECL_NOTHROW +uint QChar::toUpper(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return ucs4; @@ -1531,7 +1531,7 @@ uint QChar::toUpper(uint ucs4) Q_DECL_NOTHROW by \a ucs4 if the character is lowercase or uppercase; otherwise returns the character itself. */ -uint QChar::toTitleCase(uint ucs4) Q_DECL_NOTHROW +uint QChar::toTitleCase(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return ucs4; @@ -1546,7 +1546,7 @@ static inline uint foldCase(const ushort *ch, const ushort *start) return convertCase_helper(ucs4); } -static inline uint foldCase(uint ch, uint &last) Q_DECL_NOTHROW +static inline uint foldCase(uint ch, uint &last) noexcept { uint ucs4 = ch; if (QChar::isLowSurrogate(ucs4) && QChar::isHighSurrogate(last)) @@ -1555,12 +1555,12 @@ static inline uint foldCase(uint ch, uint &last) Q_DECL_NOTHROW return convertCase_helper(ucs4); } -static inline ushort foldCase(ushort ch) Q_DECL_NOTHROW +static inline ushort foldCase(ushort ch) noexcept { return convertCase_helper(ch); } -static inline QChar foldCase(QChar ch) Q_DECL_NOTHROW +static inline QChar foldCase(QChar ch) noexcept { return QChar(foldCase(ch.unicode())); } @@ -1577,7 +1577,7 @@ static inline QChar foldCase(QChar ch) Q_DECL_NOTHROW Returns the case folded equivalent of the UCS-4-encoded character specified by \a ucs4. For most Unicode characters this is the same as toLower(). */ -uint QChar::toCaseFolded(uint ucs4) Q_DECL_NOTHROW +uint QChar::toCaseFolded(uint ucs4) noexcept { if (ucs4 > LastValidCodePoint) return ucs4; diff --git a/src/corelib/tools/qchar.h b/src/corelib/tools/qchar.h index 8590b91ba3..be344838ed 100644 --- a/src/corelib/tools/qchar.h +++ b/src/corelib/tools/qchar.h @@ -50,9 +50,9 @@ class QString; struct QLatin1Char { public: - Q_DECL_CONSTEXPR inline explicit QLatin1Char(char c) Q_DECL_NOTHROW : ch(c) {} - Q_DECL_CONSTEXPR inline char toLatin1() const Q_DECL_NOTHROW { return ch; } - Q_DECL_CONSTEXPR inline ushort unicode() const Q_DECL_NOTHROW { return ushort(uchar(ch)); } + Q_DECL_CONSTEXPR inline explicit QLatin1Char(char c) noexcept : ch(c) {} + Q_DECL_CONSTEXPR inline char toLatin1() const noexcept { return ch; } + Q_DECL_CONSTEXPR inline ushort unicode() const noexcept { return ushort(uchar(ch)); } private: char ch; @@ -78,30 +78,30 @@ public: LastValidCodePoint = 0x10ffff }; - Q_DECL_CONSTEXPR QChar() Q_DECL_NOTHROW : ucs(0) {} - Q_DECL_CONSTEXPR QChar(ushort rc) Q_DECL_NOTHROW : ucs(rc) {} // implicit - Q_DECL_CONSTEXPR QChar(uchar c, uchar r) Q_DECL_NOTHROW : ucs(ushort((r << 8) | c)) {} - Q_DECL_CONSTEXPR QChar(short rc) Q_DECL_NOTHROW : ucs(ushort(rc)) {} // implicit - Q_DECL_CONSTEXPR QChar(uint rc) Q_DECL_NOTHROW : ucs(ushort(rc & 0xffff)) {} - Q_DECL_CONSTEXPR QChar(int rc) Q_DECL_NOTHROW : ucs(ushort(rc & 0xffff)) {} - Q_DECL_CONSTEXPR QChar(SpecialCharacter s) Q_DECL_NOTHROW : ucs(ushort(s)) {} // implicit - Q_DECL_CONSTEXPR QChar(QLatin1Char ch) Q_DECL_NOTHROW : ucs(ch.unicode()) {} // implicit + Q_DECL_CONSTEXPR QChar() noexcept : ucs(0) {} + Q_DECL_CONSTEXPR QChar(ushort rc) noexcept : ucs(rc) {} // implicit + Q_DECL_CONSTEXPR QChar(uchar c, uchar r) noexcept : ucs(ushort((r << 8) | c)) {} + Q_DECL_CONSTEXPR QChar(short rc) noexcept : ucs(ushort(rc)) {} // implicit + Q_DECL_CONSTEXPR QChar(uint rc) noexcept : ucs(ushort(rc & 0xffff)) {} + Q_DECL_CONSTEXPR QChar(int rc) noexcept : ucs(ushort(rc & 0xffff)) {} + Q_DECL_CONSTEXPR QChar(SpecialCharacter s) noexcept : ucs(ushort(s)) {} // implicit + Q_DECL_CONSTEXPR QChar(QLatin1Char ch) noexcept : ucs(ch.unicode()) {} // implicit #if defined(Q_COMPILER_UNICODE_STRINGS) - Q_DECL_CONSTEXPR QChar(char16_t ch) Q_DECL_NOTHROW : ucs(ushort(ch)) {} // implicit + Q_DECL_CONSTEXPR QChar(char16_t ch) noexcept : ucs(ushort(ch)) {} // implicit #endif #if defined(Q_OS_WIN) Q_STATIC_ASSERT(sizeof(wchar_t) == sizeof(ushort)); #endif #if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC) # if !defined(_WCHAR_T_DEFINED) || defined(_NATIVE_WCHAR_T_DEFINED) - Q_DECL_CONSTEXPR QChar(wchar_t ch) Q_DECL_NOTHROW : ucs(ushort(ch)) {} // implicit + Q_DECL_CONSTEXPR QChar(wchar_t ch) noexcept : ucs(ushort(ch)) {} // implicit # endif #endif #ifndef QT_NO_CAST_FROM_ASCII - QT_ASCII_CAST_WARN Q_DECL_CONSTEXPR explicit QChar(char c) Q_DECL_NOTHROW : ucs(uchar(c)) { } + QT_ASCII_CAST_WARN Q_DECL_CONSTEXPR explicit QChar(char c) noexcept : ucs(uchar(c)) { } #ifndef QT_RESTRICTED_CAST_FROM_ASCII - QT_ASCII_CAST_WARN Q_DECL_CONSTEXPR explicit QChar(uchar c) Q_DECL_NOTHROW : ucs(c) { } + QT_ASCII_CAST_WARN Q_DECL_CONSTEXPR explicit QChar(uchar c) noexcept : ucs(c) { } #endif #endif // Unicode information @@ -411,11 +411,11 @@ public: }; // ****** WHEN ADDING FUNCTIONS, CONSIDER ADDING TO QCharRef TOO - inline Category category() const Q_DECL_NOTHROW { return QChar::category(ucs); } - inline Direction direction() const Q_DECL_NOTHROW { return QChar::direction(ucs); } - inline JoiningType joiningType() const Q_DECL_NOTHROW { return QChar::joiningType(ucs); } + inline Category category() const noexcept { return QChar::category(ucs); } + inline Direction direction() const noexcept { return QChar::direction(ucs); } + inline JoiningType joiningType() const noexcept { return QChar::joiningType(ucs); } #if QT_DEPRECATED_SINCE(5, 3) - QT_DEPRECATED inline Joining joining() const Q_DECL_NOTHROW + QT_DEPRECATED inline Joining joining() const noexcept { switch (QChar::joiningType(ucs)) { case QChar::Joining_Causing: return QChar::Center; @@ -428,198 +428,198 @@ public: } } #endif - inline unsigned char combiningClass() const Q_DECL_NOTHROW { return QChar::combiningClass(ucs); } + inline unsigned char combiningClass() const noexcept { return QChar::combiningClass(ucs); } - inline QChar mirroredChar() const Q_DECL_NOTHROW { return QChar::mirroredChar(ucs); } - inline bool hasMirrored() const Q_DECL_NOTHROW { return QChar::hasMirrored(ucs); } + inline QChar mirroredChar() const noexcept { return QChar::mirroredChar(ucs); } + inline bool hasMirrored() const noexcept { return QChar::hasMirrored(ucs); } QString decomposition() const; - inline Decomposition decompositionTag() const Q_DECL_NOTHROW { return QChar::decompositionTag(ucs); } + inline Decomposition decompositionTag() const noexcept { return QChar::decompositionTag(ucs); } - inline int digitValue() const Q_DECL_NOTHROW { return QChar::digitValue(ucs); } - inline QChar toLower() const Q_DECL_NOTHROW { return QChar::toLower(ucs); } - inline QChar toUpper() const Q_DECL_NOTHROW { return QChar::toUpper(ucs); } - inline QChar toTitleCase() const Q_DECL_NOTHROW { return QChar::toTitleCase(ucs); } - inline QChar toCaseFolded() const Q_DECL_NOTHROW { return QChar::toCaseFolded(ucs); } + inline int digitValue() const noexcept { return QChar::digitValue(ucs); } + inline QChar toLower() const noexcept { return QChar::toLower(ucs); } + inline QChar toUpper() const noexcept { return QChar::toUpper(ucs); } + inline QChar toTitleCase() const noexcept { return QChar::toTitleCase(ucs); } + inline QChar toCaseFolded() const noexcept { return QChar::toCaseFolded(ucs); } - inline Script script() const Q_DECL_NOTHROW { return QChar::script(ucs); } + inline Script script() const noexcept { return QChar::script(ucs); } - inline UnicodeVersion unicodeVersion() const Q_DECL_NOTHROW { return QChar::unicodeVersion(ucs); } + inline UnicodeVersion unicodeVersion() const noexcept { return QChar::unicodeVersion(ucs); } #if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED Q_DECL_CONSTEXPR inline char toAscii() const Q_DECL_NOTHROW { return toLatin1(); } + QT_DEPRECATED Q_DECL_CONSTEXPR inline char toAscii() const noexcept { return toLatin1(); } #endif - Q_DECL_CONSTEXPR inline char toLatin1() const Q_DECL_NOTHROW { return ucs > 0xff ? '\0' : char(ucs); } - Q_DECL_CONSTEXPR inline ushort unicode() const Q_DECL_NOTHROW { return ucs; } - Q_DECL_RELAXED_CONSTEXPR inline ushort &unicode() Q_DECL_NOTHROW { return ucs; } + Q_DECL_CONSTEXPR inline char toLatin1() const noexcept { return ucs > 0xff ? '\0' : char(ucs); } + Q_DECL_CONSTEXPR inline ushort unicode() const noexcept { return ucs; } + Q_DECL_RELAXED_CONSTEXPR inline ushort &unicode() noexcept { return ucs; } #if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED static Q_DECL_CONSTEXPR inline QChar fromAscii(char c) Q_DECL_NOTHROW + QT_DEPRECATED static Q_DECL_CONSTEXPR inline QChar fromAscii(char c) noexcept { return fromLatin1(c); } #endif - static Q_DECL_CONSTEXPR inline QChar fromLatin1(char c) Q_DECL_NOTHROW { return QChar(ushort(uchar(c))); } + static Q_DECL_CONSTEXPR inline QChar fromLatin1(char c) noexcept { return QChar(ushort(uchar(c))); } - Q_DECL_CONSTEXPR inline bool isNull() const Q_DECL_NOTHROW { return ucs == 0; } + Q_DECL_CONSTEXPR inline bool isNull() const noexcept { return ucs == 0; } - inline bool isPrint() const Q_DECL_NOTHROW { return QChar::isPrint(ucs); } - Q_DECL_CONSTEXPR inline bool isSpace() const Q_DECL_NOTHROW { return QChar::isSpace(ucs); } - inline bool isMark() const Q_DECL_NOTHROW { return QChar::isMark(ucs); } - inline bool isPunct() const Q_DECL_NOTHROW { return QChar::isPunct(ucs); } - inline bool isSymbol() const Q_DECL_NOTHROW { return QChar::isSymbol(ucs); } - Q_DECL_CONSTEXPR inline bool isLetter() const Q_DECL_NOTHROW { return QChar::isLetter(ucs); } - Q_DECL_CONSTEXPR inline bool isNumber() const Q_DECL_NOTHROW { return QChar::isNumber(ucs); } - Q_DECL_CONSTEXPR inline bool isLetterOrNumber() const Q_DECL_NOTHROW { return QChar::isLetterOrNumber(ucs); } - Q_DECL_CONSTEXPR inline bool isDigit() const Q_DECL_NOTHROW { return QChar::isDigit(ucs); } - Q_DECL_CONSTEXPR inline bool isLower() const Q_DECL_NOTHROW { return QChar::isLower(ucs); } - Q_DECL_CONSTEXPR inline bool isUpper() const Q_DECL_NOTHROW { return QChar::isUpper(ucs); } - Q_DECL_CONSTEXPR inline bool isTitleCase() const Q_DECL_NOTHROW { return QChar::isTitleCase(ucs); } + inline bool isPrint() const noexcept { return QChar::isPrint(ucs); } + Q_DECL_CONSTEXPR inline bool isSpace() const noexcept { return QChar::isSpace(ucs); } + inline bool isMark() const noexcept { return QChar::isMark(ucs); } + inline bool isPunct() const noexcept { return QChar::isPunct(ucs); } + inline bool isSymbol() const noexcept { return QChar::isSymbol(ucs); } + Q_DECL_CONSTEXPR inline bool isLetter() const noexcept { return QChar::isLetter(ucs); } + Q_DECL_CONSTEXPR inline bool isNumber() const noexcept { return QChar::isNumber(ucs); } + Q_DECL_CONSTEXPR inline bool isLetterOrNumber() const noexcept { return QChar::isLetterOrNumber(ucs); } + Q_DECL_CONSTEXPR inline bool isDigit() const noexcept { return QChar::isDigit(ucs); } + Q_DECL_CONSTEXPR inline bool isLower() const noexcept { return QChar::isLower(ucs); } + Q_DECL_CONSTEXPR inline bool isUpper() const noexcept { return QChar::isUpper(ucs); } + Q_DECL_CONSTEXPR inline bool isTitleCase() const noexcept { return QChar::isTitleCase(ucs); } - Q_DECL_CONSTEXPR inline bool isNonCharacter() const Q_DECL_NOTHROW { return QChar::isNonCharacter(ucs); } - Q_DECL_CONSTEXPR inline bool isHighSurrogate() const Q_DECL_NOTHROW { return QChar::isHighSurrogate(ucs); } - Q_DECL_CONSTEXPR inline bool isLowSurrogate() const Q_DECL_NOTHROW { return QChar::isLowSurrogate(ucs); } - Q_DECL_CONSTEXPR inline bool isSurrogate() const Q_DECL_NOTHROW { return QChar::isSurrogate(ucs); } + Q_DECL_CONSTEXPR inline bool isNonCharacter() const noexcept { return QChar::isNonCharacter(ucs); } + Q_DECL_CONSTEXPR inline bool isHighSurrogate() const noexcept { return QChar::isHighSurrogate(ucs); } + Q_DECL_CONSTEXPR inline bool isLowSurrogate() const noexcept { return QChar::isLowSurrogate(ucs); } + Q_DECL_CONSTEXPR inline bool isSurrogate() const noexcept { return QChar::isSurrogate(ucs); } - Q_DECL_CONSTEXPR inline uchar cell() const Q_DECL_NOTHROW { return uchar(ucs & 0xff); } - Q_DECL_CONSTEXPR inline uchar row() const Q_DECL_NOTHROW { return uchar((ucs>>8)&0xff); } - Q_DECL_RELAXED_CONSTEXPR inline void setCell(uchar acell) Q_DECL_NOTHROW { ucs = ushort((ucs & 0xff00) + acell); } - Q_DECL_RELAXED_CONSTEXPR inline void setRow(uchar arow) Q_DECL_NOTHROW { ucs = ushort((ushort(arow)<<8) + (ucs&0xff)); } + Q_DECL_CONSTEXPR inline uchar cell() const noexcept { return uchar(ucs & 0xff); } + Q_DECL_CONSTEXPR inline uchar row() const noexcept { return uchar((ucs>>8)&0xff); } + Q_DECL_RELAXED_CONSTEXPR inline void setCell(uchar acell) noexcept { ucs = ushort((ucs & 0xff00) + acell); } + Q_DECL_RELAXED_CONSTEXPR inline void setRow(uchar arow) noexcept { ucs = ushort((ushort(arow)<<8) + (ucs&0xff)); } - static Q_DECL_CONSTEXPR inline bool isNonCharacter(uint ucs4) Q_DECL_NOTHROW + static Q_DECL_CONSTEXPR inline bool isNonCharacter(uint ucs4) noexcept { return ucs4 >= 0xfdd0 && (ucs4 <= 0xfdef || (ucs4 & 0xfffe) == 0xfffe); } - static Q_DECL_CONSTEXPR inline bool isHighSurrogate(uint ucs4) Q_DECL_NOTHROW + static Q_DECL_CONSTEXPR inline bool isHighSurrogate(uint ucs4) noexcept { return ((ucs4 & 0xfffffc00) == 0xd800); } - static Q_DECL_CONSTEXPR inline bool isLowSurrogate(uint ucs4) Q_DECL_NOTHROW + static Q_DECL_CONSTEXPR inline bool isLowSurrogate(uint ucs4) noexcept { return ((ucs4 & 0xfffffc00) == 0xdc00); } - static Q_DECL_CONSTEXPR inline bool isSurrogate(uint ucs4) Q_DECL_NOTHROW + static Q_DECL_CONSTEXPR inline bool isSurrogate(uint ucs4) noexcept { return (ucs4 - 0xd800u < 2048u); } - static Q_DECL_CONSTEXPR inline bool requiresSurrogates(uint ucs4) Q_DECL_NOTHROW + static Q_DECL_CONSTEXPR inline bool requiresSurrogates(uint ucs4) noexcept { return (ucs4 >= 0x10000); } - static Q_DECL_CONSTEXPR inline uint surrogateToUcs4(ushort high, ushort low) Q_DECL_NOTHROW + static Q_DECL_CONSTEXPR inline uint surrogateToUcs4(ushort high, ushort low) noexcept { return (uint(high)<<10) + low - 0x35fdc00; } - static Q_DECL_CONSTEXPR inline uint surrogateToUcs4(QChar high, QChar low) Q_DECL_NOTHROW + static Q_DECL_CONSTEXPR inline uint surrogateToUcs4(QChar high, QChar low) noexcept { return surrogateToUcs4(high.ucs, low.ucs); } - static Q_DECL_CONSTEXPR inline ushort highSurrogate(uint ucs4) Q_DECL_NOTHROW + static Q_DECL_CONSTEXPR inline ushort highSurrogate(uint ucs4) noexcept { return ushort((ucs4>>10) + 0xd7c0); } - static Q_DECL_CONSTEXPR inline ushort lowSurrogate(uint ucs4) Q_DECL_NOTHROW + static Q_DECL_CONSTEXPR inline ushort lowSurrogate(uint ucs4) noexcept { return ushort(ucs4%0x400 + 0xdc00); } - static Category QT_FASTCALL category(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; - static Direction QT_FASTCALL direction(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; - static JoiningType QT_FASTCALL joiningType(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; + static Category QT_FASTCALL category(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; + static Direction QT_FASTCALL direction(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; + static JoiningType QT_FASTCALL joiningType(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; #if QT_DEPRECATED_SINCE(5, 3) - QT_DEPRECATED static Joining QT_FASTCALL joining(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; + QT_DEPRECATED static Joining QT_FASTCALL joining(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; #endif - static unsigned char QT_FASTCALL combiningClass(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; + static unsigned char QT_FASTCALL combiningClass(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; - static uint QT_FASTCALL mirroredChar(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; - static bool QT_FASTCALL hasMirrored(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; + static uint QT_FASTCALL mirroredChar(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; + static bool QT_FASTCALL hasMirrored(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; static QString QT_FASTCALL decomposition(uint ucs4); - static Decomposition QT_FASTCALL decompositionTag(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; + static Decomposition QT_FASTCALL decompositionTag(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; - static int QT_FASTCALL digitValue(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; - static uint QT_FASTCALL toLower(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; - static uint QT_FASTCALL toUpper(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; - static uint QT_FASTCALL toTitleCase(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; - static uint QT_FASTCALL toCaseFolded(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; + static int QT_FASTCALL digitValue(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; + static uint QT_FASTCALL toLower(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; + static uint QT_FASTCALL toUpper(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; + static uint QT_FASTCALL toTitleCase(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; + static uint QT_FASTCALL toCaseFolded(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; - static Script QT_FASTCALL script(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; + static Script QT_FASTCALL script(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; - static UnicodeVersion QT_FASTCALL unicodeVersion(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; + static UnicodeVersion QT_FASTCALL unicodeVersion(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; - static UnicodeVersion QT_FASTCALL currentUnicodeVersion() Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; + static UnicodeVersion QT_FASTCALL currentUnicodeVersion() noexcept Q_DECL_CONST_FUNCTION; - static bool QT_FASTCALL isPrint(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; - static Q_DECL_CONSTEXPR inline bool isSpace(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION + static bool QT_FASTCALL isPrint(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; + static Q_DECL_CONSTEXPR inline bool isSpace(uint ucs4) noexcept Q_DECL_CONST_FUNCTION { // note that [0x09..0x0d] + 0x85 are exceptional Cc-s and must be handled explicitly return ucs4 == 0x20 || (ucs4 <= 0x0d && ucs4 >= 0x09) || (ucs4 > 127 && (ucs4 == 0x85 || ucs4 == 0xa0 || QChar::isSpace_helper(ucs4))); } - static bool QT_FASTCALL isMark(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; - static bool QT_FASTCALL isPunct(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; - static bool QT_FASTCALL isSymbol(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; - static Q_DECL_CONSTEXPR inline bool isLetter(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION + static bool QT_FASTCALL isMark(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; + static bool QT_FASTCALL isPunct(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; + static bool QT_FASTCALL isSymbol(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; + static Q_DECL_CONSTEXPR inline bool isLetter(uint ucs4) noexcept Q_DECL_CONST_FUNCTION { return (ucs4 >= 'A' && ucs4 <= 'z' && (ucs4 >= 'a' || ucs4 <= 'Z')) || (ucs4 > 127 && QChar::isLetter_helper(ucs4)); } - static Q_DECL_CONSTEXPR inline bool isNumber(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION + static Q_DECL_CONSTEXPR inline bool isNumber(uint ucs4) noexcept Q_DECL_CONST_FUNCTION { return (ucs4 <= '9' && ucs4 >= '0') || (ucs4 > 127 && QChar::isNumber_helper(ucs4)); } - static Q_DECL_CONSTEXPR inline bool isLetterOrNumber(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION + static Q_DECL_CONSTEXPR inline bool isLetterOrNumber(uint ucs4) noexcept Q_DECL_CONST_FUNCTION { return (ucs4 >= 'A' && ucs4 <= 'z' && (ucs4 >= 'a' || ucs4 <= 'Z')) || (ucs4 >= '0' && ucs4 <= '9') || (ucs4 > 127 && QChar::isLetterOrNumber_helper(ucs4)); } - static Q_DECL_CONSTEXPR inline bool isDigit(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION + static Q_DECL_CONSTEXPR inline bool isDigit(uint ucs4) noexcept Q_DECL_CONST_FUNCTION { return (ucs4 <= '9' && ucs4 >= '0') || (ucs4 > 127 && QChar::category(ucs4) == Number_DecimalDigit); } - static Q_DECL_CONSTEXPR inline bool isLower(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION + static Q_DECL_CONSTEXPR inline bool isLower(uint ucs4) noexcept Q_DECL_CONST_FUNCTION { return (ucs4 <= 'z' && ucs4 >= 'a') || (ucs4 > 127 && QChar::category(ucs4) == Letter_Lowercase); } - static Q_DECL_CONSTEXPR inline bool isUpper(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION + static Q_DECL_CONSTEXPR inline bool isUpper(uint ucs4) noexcept Q_DECL_CONST_FUNCTION { return (ucs4 <= 'Z' && ucs4 >= 'A') || (ucs4 > 127 && QChar::category(ucs4) == Letter_Uppercase); } - static Q_DECL_CONSTEXPR inline bool isTitleCase(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION + static Q_DECL_CONSTEXPR inline bool isTitleCase(uint ucs4) noexcept Q_DECL_CONST_FUNCTION { return ucs4 > 127 && QChar::category(ucs4) == Letter_Titlecase; } private: - static bool QT_FASTCALL isSpace_helper(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; - static bool QT_FASTCALL isLetter_helper(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; - static bool QT_FASTCALL isNumber_helper(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; - static bool QT_FASTCALL isLetterOrNumber_helper(uint ucs4) Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION; + static bool QT_FASTCALL isSpace_helper(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; + static bool QT_FASTCALL isLetter_helper(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; + static bool QT_FASTCALL isNumber_helper(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; + static bool QT_FASTCALL isLetterOrNumber_helper(uint ucs4) noexcept Q_DECL_CONST_FUNCTION; #ifdef QT_NO_CAST_FROM_ASCII - QChar(char c) Q_DECL_NOTHROW; - QChar(uchar c) Q_DECL_NOTHROW; + QChar(char c) noexcept; + QChar(uchar c) noexcept; #endif - friend Q_DECL_CONSTEXPR bool operator==(QChar, QChar) Q_DECL_NOTHROW; - friend Q_DECL_CONSTEXPR bool operator< (QChar, QChar) Q_DECL_NOTHROW; + friend Q_DECL_CONSTEXPR bool operator==(QChar, QChar) noexcept; + friend Q_DECL_CONSTEXPR bool operator< (QChar, QChar) noexcept; ushort ucs; }; Q_DECLARE_TYPEINFO(QChar, Q_MOVABLE_TYPE); -Q_DECL_CONSTEXPR inline bool operator==(QChar c1, QChar c2) Q_DECL_NOTHROW { return c1.ucs == c2.ucs; } -Q_DECL_CONSTEXPR inline bool operator< (QChar c1, QChar c2) Q_DECL_NOTHROW { return c1.ucs < c2.ucs; } +Q_DECL_CONSTEXPR inline bool operator==(QChar c1, QChar c2) noexcept { return c1.ucs == c2.ucs; } +Q_DECL_CONSTEXPR inline bool operator< (QChar c1, QChar c2) noexcept { return c1.ucs < c2.ucs; } -Q_DECL_CONSTEXPR inline bool operator!=(QChar c1, QChar c2) Q_DECL_NOTHROW { return !operator==(c1, c2); } -Q_DECL_CONSTEXPR inline bool operator>=(QChar c1, QChar c2) Q_DECL_NOTHROW { return !operator< (c1, c2); } -Q_DECL_CONSTEXPR inline bool operator> (QChar c1, QChar c2) Q_DECL_NOTHROW { return operator< (c2, c1); } -Q_DECL_CONSTEXPR inline bool operator<=(QChar c1, QChar c2) Q_DECL_NOTHROW { return !operator< (c2, c1); } +Q_DECL_CONSTEXPR inline bool operator!=(QChar c1, QChar c2) noexcept { return !operator==(c1, c2); } +Q_DECL_CONSTEXPR inline bool operator>=(QChar c1, QChar c2) noexcept { return !operator< (c1, c2); } +Q_DECL_CONSTEXPR inline bool operator> (QChar c1, QChar c2) noexcept { return operator< (c2, c1); } +Q_DECL_CONSTEXPR inline bool operator<=(QChar c1, QChar c2) noexcept { return !operator< (c2, c1); } -Q_DECL_CONSTEXPR inline bool operator==(QChar lhs, std::nullptr_t) Q_DECL_NOTHROW { return lhs.isNull(); } -Q_DECL_CONSTEXPR inline bool operator< (QChar, std::nullptr_t) Q_DECL_NOTHROW { return false; } -Q_DECL_CONSTEXPR inline bool operator==(std::nullptr_t, QChar rhs) Q_DECL_NOTHROW { return rhs.isNull(); } -Q_DECL_CONSTEXPR inline bool operator< (std::nullptr_t, QChar rhs) Q_DECL_NOTHROW { return !rhs.isNull(); } +Q_DECL_CONSTEXPR inline bool operator==(QChar lhs, std::nullptr_t) noexcept { return lhs.isNull(); } +Q_DECL_CONSTEXPR inline bool operator< (QChar, std::nullptr_t) noexcept { return false; } +Q_DECL_CONSTEXPR inline bool operator==(std::nullptr_t, QChar rhs) noexcept { return rhs.isNull(); } +Q_DECL_CONSTEXPR inline bool operator< (std::nullptr_t, QChar rhs) noexcept { return !rhs.isNull(); } -Q_DECL_CONSTEXPR inline bool operator!=(QChar lhs, std::nullptr_t) Q_DECL_NOTHROW { return !operator==(lhs, nullptr); } -Q_DECL_CONSTEXPR inline bool operator>=(QChar lhs, std::nullptr_t) Q_DECL_NOTHROW { return !operator< (lhs, nullptr); } -Q_DECL_CONSTEXPR inline bool operator> (QChar lhs, std::nullptr_t) Q_DECL_NOTHROW { return operator< (nullptr, lhs); } -Q_DECL_CONSTEXPR inline bool operator<=(QChar lhs, std::nullptr_t) Q_DECL_NOTHROW { return !operator< (nullptr, lhs); } +Q_DECL_CONSTEXPR inline bool operator!=(QChar lhs, std::nullptr_t) noexcept { return !operator==(lhs, nullptr); } +Q_DECL_CONSTEXPR inline bool operator>=(QChar lhs, std::nullptr_t) noexcept { return !operator< (lhs, nullptr); } +Q_DECL_CONSTEXPR inline bool operator> (QChar lhs, std::nullptr_t) noexcept { return operator< (nullptr, lhs); } +Q_DECL_CONSTEXPR inline bool operator<=(QChar lhs, std::nullptr_t) noexcept { return !operator< (nullptr, lhs); } -Q_DECL_CONSTEXPR inline bool operator!=(std::nullptr_t, QChar rhs) Q_DECL_NOTHROW { return !operator==(nullptr, rhs); } -Q_DECL_CONSTEXPR inline bool operator>=(std::nullptr_t, QChar rhs) Q_DECL_NOTHROW { return !operator< (nullptr, rhs); } -Q_DECL_CONSTEXPR inline bool operator> (std::nullptr_t, QChar rhs) Q_DECL_NOTHROW { return operator< (rhs, nullptr); } -Q_DECL_CONSTEXPR inline bool operator<=(std::nullptr_t, QChar rhs) Q_DECL_NOTHROW { return !operator< (rhs, nullptr); } +Q_DECL_CONSTEXPR inline bool operator!=(std::nullptr_t, QChar rhs) noexcept { return !operator==(nullptr, rhs); } +Q_DECL_CONSTEXPR inline bool operator>=(std::nullptr_t, QChar rhs) noexcept { return !operator< (nullptr, rhs); } +Q_DECL_CONSTEXPR inline bool operator> (std::nullptr_t, QChar rhs) noexcept { return operator< (rhs, nullptr); } +Q_DECL_CONSTEXPR inline bool operator<=(std::nullptr_t, QChar rhs) noexcept { return !operator< (rhs, nullptr); } #ifndef QT_NO_DATASTREAM Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, QChar); diff --git a/src/corelib/tools/qcollator.h b/src/corelib/tools/qcollator.h index 700de739bb..6c76ef038f 100644 --- a/src/corelib/tools/qcollator.h +++ b/src/corelib/tools/qcollator.h @@ -58,10 +58,10 @@ public: ~QCollatorSortKey(); QCollatorSortKey &operator=(const QCollatorSortKey &other); #ifdef Q_COMPILER_RVALUE_REFS - inline QCollatorSortKey &operator=(QCollatorSortKey &&other) Q_DECL_NOTHROW + inline QCollatorSortKey &operator=(QCollatorSortKey &&other) noexcept { swap(other); return *this; } #endif - void swap(QCollatorSortKey &other) Q_DECL_NOTHROW + void swap(QCollatorSortKey &other) noexcept { d.swap(other.d); } int compare(const QCollatorSortKey &key) const; @@ -88,13 +88,13 @@ public: ~QCollator(); QCollator &operator=(const QCollator &); #ifdef Q_COMPILER_RVALUE_REFS - QCollator(QCollator &&other) Q_DECL_NOTHROW + QCollator(QCollator &&other) noexcept : d(other.d) { other.d = nullptr; } - QCollator &operator=(QCollator &&other) Q_DECL_NOTHROW + QCollator &operator=(QCollator &&other) noexcept { swap(other); return *this; } #endif - void swap(QCollator &other) Q_DECL_NOTHROW + void swap(QCollator &other) noexcept { qSwap(d, other.d); } void setLocale(const QLocale &locale); diff --git a/src/corelib/tools/qcommandlineoption.cpp b/src/corelib/tools/qcommandlineoption.cpp index c2b86014ba..aff684fad2 100644 --- a/src/corelib/tools/qcommandlineoption.cpp +++ b/src/corelib/tools/qcommandlineoption.cpp @@ -254,7 +254,7 @@ namespace { typedef QString argument_type; Q_NEVER_INLINE - result_type operator()(const QString &name) const Q_DECL_NOEXCEPT + result_type operator()(const QString &name) const noexcept { if (Q_UNLIKELY(name.isEmpty())) return warn("be empty"); @@ -271,7 +271,7 @@ namespace { } Q_NEVER_INLINE - static bool warn(const char *what) Q_DECL_NOEXCEPT + static bool warn(const char *what) noexcept { qWarning("QCommandLineOption: Option names cannot %s", what); return true; diff --git a/src/corelib/tools/qcommandlineoption.h b/src/corelib/tools/qcommandlineoption.h index 276be042de..643427f6fb 100644 --- a/src/corelib/tools/qcommandlineoption.h +++ b/src/corelib/tools/qcommandlineoption.h @@ -72,10 +72,10 @@ public: QCommandLineOption &operator=(const QCommandLineOption &other); #ifdef Q_COMPILER_RVALUE_REFS - QCommandLineOption &operator=(QCommandLineOption &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QCommandLineOption &operator=(QCommandLineOption &&other) noexcept { swap(other); return *this; } #endif - void swap(QCommandLineOption &other) Q_DECL_NOTHROW + void swap(QCommandLineOption &other) noexcept { qSwap(d, other.d); } QStringList names() const; diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index d06b8a04d2..54e52c4cd1 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -256,7 +256,7 @@ static QString toOffsetString(Qt::DateFormat format, int offset) #if QT_CONFIG(datestring) // Parse offset in [+-]HH[[:]mm] format -static int fromOffsetString(const QStringRef &offsetString, bool *valid) Q_DECL_NOTHROW +static int fromOffsetString(const QStringRef &offsetString, bool *valid) noexcept { *valid = false; @@ -3210,7 +3210,7 @@ QDateTime::QDateTime(const QDate &date, const QTime &time, const QTimeZone &time /*! Constructs a copy of the \a other datetime. */ -QDateTime::QDateTime(const QDateTime &other) Q_DECL_NOTHROW +QDateTime::QDateTime(const QDateTime &other) noexcept : d(other.d) { } @@ -3220,7 +3220,7 @@ QDateTime::QDateTime(const QDateTime &other) Q_DECL_NOTHROW Moves the content of the temporary \a other datetime to this object and leaves \a other in an unspecified (but proper) state. */ -QDateTime::QDateTime(QDateTime &&other) Q_DECL_NOTHROW +QDateTime::QDateTime(QDateTime &&other) noexcept : d(std::move(other.d)) { } @@ -3237,7 +3237,7 @@ QDateTime::~QDateTime() copy. */ -QDateTime &QDateTime::operator=(const QDateTime &other) Q_DECL_NOTHROW +QDateTime &QDateTime::operator=(const QDateTime &other) noexcept { d = other.d; return *this; @@ -4465,7 +4465,7 @@ QDateTime QDateTime::currentDateTimeUtc() return QDateTime(d, t, Qt::UTC); } -qint64 QDateTime::currentMSecsSinceEpoch() Q_DECL_NOTHROW +qint64 QDateTime::currentMSecsSinceEpoch() noexcept { SYSTEMTIME st; memset(&st, 0, sizeof(SYSTEMTIME)); @@ -4476,7 +4476,7 @@ qint64 QDateTime::currentMSecsSinceEpoch() Q_DECL_NOTHROW - julianDayFromDate(1970, 1, 1)) * Q_INT64_C(86400000); } -qint64 QDateTime::currentSecsSinceEpoch() Q_DECL_NOTHROW +qint64 QDateTime::currentSecsSinceEpoch() noexcept { SYSTEMTIME st; memset(&st, 0, sizeof(SYSTEMTIME)); @@ -4508,7 +4508,7 @@ QDateTime QDateTime::currentDateTimeUtc() return fromMSecsSinceEpoch(currentMSecsSinceEpoch(), Qt::UTC); } -qint64 QDateTime::currentMSecsSinceEpoch() Q_DECL_NOTHROW +qint64 QDateTime::currentMSecsSinceEpoch() noexcept { // posix compliant system // we have milliseconds @@ -4517,7 +4517,7 @@ qint64 QDateTime::currentMSecsSinceEpoch() Q_DECL_NOTHROW return qint64(tv.tv_sec) * Q_INT64_C(1000) + tv.tv_usec / 1000; } -qint64 QDateTime::currentSecsSinceEpoch() Q_DECL_NOTHROW +qint64 QDateTime::currentSecsSinceEpoch() noexcept { struct timeval tv; gettimeofday(&tv, 0); @@ -5414,7 +5414,7 @@ uint qHash(const QDateTime &key, uint seed) Returns the hash value for the \a key, using \a seed to seed the calculation. */ -uint qHash(const QDate &key, uint seed) Q_DECL_NOTHROW +uint qHash(const QDate &key, uint seed) noexcept { return qHash(key.toJulianDay(), seed); } @@ -5425,7 +5425,7 @@ uint qHash(const QDate &key, uint seed) Q_DECL_NOTHROW Returns the hash value for the \a key, using \a seed to seed the calculation. */ -uint qHash(const QTime &key, uint seed) Q_DECL_NOTHROW +uint qHash(const QTime &key, uint seed) noexcept { return qHash(key.msecsSinceStartOfDay(), seed); } diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h index 43271b34ed..144fb9b28a 100644 --- a/src/corelib/tools/qdatetime.h +++ b/src/corelib/tools/qdatetime.h @@ -266,16 +266,16 @@ public: #if QT_CONFIG(timezone) QDateTime(const QDate &date, const QTime &time, const QTimeZone &timeZone); #endif // timezone - QDateTime(const QDateTime &other) Q_DECL_NOTHROW; - QDateTime(QDateTime &&other) Q_DECL_NOTHROW; + QDateTime(const QDateTime &other) noexcept; + QDateTime(QDateTime &&other) noexcept; ~QDateTime(); #ifdef Q_COMPILER_RVALUE_REFS - QDateTime &operator=(QDateTime &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QDateTime &operator=(QDateTime &&other) noexcept { swap(other); return *this; } #endif - QDateTime &operator=(const QDateTime &other) Q_DECL_NOTHROW; + QDateTime &operator=(const QDateTime &other) noexcept; - void swap(QDateTime &other) Q_DECL_NOTHROW { qSwap(d.d, other.d.d); } + void swap(QDateTime &other) noexcept { qSwap(d.d, other.d.d); } bool isNull() const; bool isValid() const; @@ -366,8 +366,8 @@ public: static QDateTime fromSecsSinceEpoch(qint64 secs, const QTimeZone &timeZone); #endif - static qint64 currentMSecsSinceEpoch() Q_DECL_NOTHROW; - static qint64 currentSecsSinceEpoch() Q_DECL_NOTHROW; + static qint64 currentMSecsSinceEpoch() noexcept; + static qint64 currentSecsSinceEpoch() noexcept; #if defined(Q_OS_DARWIN) || defined(Q_QDOC) static QDateTime fromCFDate(CFDateRef date); @@ -410,8 +410,8 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QDateTime &); // QDateTime is not noexcept for now -- to be revised once // timezone and calendaring support is added Q_CORE_EXPORT uint qHash(const QDateTime &key, uint seed = 0); -Q_CORE_EXPORT uint qHash(const QDate &key, uint seed = 0) Q_DECL_NOTHROW; -Q_CORE_EXPORT uint qHash(const QTime &key, uint seed = 0) Q_DECL_NOTHROW; +Q_CORE_EXPORT uint qHash(const QDate &key, uint seed = 0) noexcept; +Q_CORE_EXPORT uint qHash(const QTime &key, uint seed = 0) noexcept; QT_END_NAMESPACE diff --git a/src/corelib/tools/qeasingcurve.h b/src/corelib/tools/qeasingcurve.h index 74bde5825a..1791f19199 100644 --- a/src/corelib/tools/qeasingcurve.h +++ b/src/corelib/tools/qeasingcurve.h @@ -81,12 +81,12 @@ public: QEasingCurve &operator=(const QEasingCurve &other) { if ( this != &other ) { QEasingCurve copy(other); swap(copy); } return *this; } #ifdef Q_COMPILER_RVALUE_REFS - QEasingCurve(QEasingCurve &&other) Q_DECL_NOTHROW : d_ptr(other.d_ptr) { other.d_ptr = nullptr; } - QEasingCurve &operator=(QEasingCurve &&other) Q_DECL_NOTHROW + QEasingCurve(QEasingCurve &&other) noexcept : d_ptr(other.d_ptr) { other.d_ptr = nullptr; } + QEasingCurve &operator=(QEasingCurve &&other) noexcept { qSwap(d_ptr, other.d_ptr); return *this; } #endif - void swap(QEasingCurve &other) Q_DECL_NOTHROW { qSwap(d_ptr, other.d_ptr); } + void swap(QEasingCurve &other) noexcept { qSwap(d_ptr, other.d_ptr); } bool operator==(const QEasingCurve &other) const; inline bool operator!=(const QEasingCurve &other) const diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index 32e9a4269c..dd22a38be1 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -197,7 +197,7 @@ static uint crc32(...) } #endif -static inline uint hash(const uchar *p, size_t len, uint seed) Q_DECL_NOTHROW +static inline uint hash(const uchar *p, size_t len, uint seed) noexcept { uint h = seed; @@ -210,12 +210,12 @@ static inline uint hash(const uchar *p, size_t len, uint seed) Q_DECL_NOTHROW return h; } -uint qHashBits(const void *p, size_t len, uint seed) Q_DECL_NOTHROW +uint qHashBits(const void *p, size_t len, uint seed) noexcept { return hash(static_cast(p), int(len), seed); } -static inline uint hash(const QChar *p, size_t len, uint seed) Q_DECL_NOTHROW +static inline uint hash(const QChar *p, size_t len, uint seed) noexcept { uint h = seed; @@ -228,29 +228,29 @@ static inline uint hash(const QChar *p, size_t len, uint seed) Q_DECL_NOTHROW return h; } -uint qHash(const QByteArray &key, uint seed) Q_DECL_NOTHROW +uint qHash(const QByteArray &key, uint seed) noexcept { return hash(reinterpret_cast(key.constData()), size_t(key.size()), seed); } #if QT_STRINGVIEW_LEVEL < 2 -uint qHash(const QString &key, uint seed) Q_DECL_NOTHROW +uint qHash(const QString &key, uint seed) noexcept { return hash(key.unicode(), size_t(key.size()), seed); } -uint qHash(const QStringRef &key, uint seed) Q_DECL_NOTHROW +uint qHash(const QStringRef &key, uint seed) noexcept { return hash(key.unicode(), size_t(key.size()), seed); } #endif -uint qHash(QStringView key, uint seed) Q_DECL_NOTHROW +uint qHash(QStringView key, uint seed) noexcept { return hash(key.data(), key.size(), seed); } -uint qHash(const QBitArray &bitArray, uint seed) Q_DECL_NOTHROW +uint qHash(const QBitArray &bitArray, uint seed) noexcept { int m = bitArray.d.size() - 1; uint result = hash(reinterpret_cast(bitArray.d.constData()), @@ -264,7 +264,7 @@ uint qHash(const QBitArray &bitArray, uint seed) Q_DECL_NOTHROW return result; } -uint qHash(QLatin1String key, uint seed) Q_DECL_NOTHROW +uint qHash(QLatin1String key, uint seed) noexcept { return hash(reinterpret_cast(key.data()), size_t(key.size()), seed); } @@ -398,7 +398,7 @@ void qSetGlobalQHashSeed(int newSeed) This function can hash discontiguous memory by invoking it on each chunk, passing the previous's result in the next call's \a chained argument. */ -uint qt_hash(QStringView key, uint chained) Q_DECL_NOTHROW +uint qt_hash(QStringView key, uint chained) noexcept { auto n = key.size(); auto p = key.utf16(); @@ -938,7 +938,7 @@ void QHashData::checkSanity() Returns the hash value for the \a key, using \a seed to seed the calculation. */ -uint qHash(float key, uint seed) Q_DECL_NOTHROW +uint qHash(float key, uint seed) noexcept { return key != 0.0f ? hash(reinterpret_cast(&key), sizeof(key), seed) : seed ; } @@ -948,7 +948,7 @@ uint qHash(float key, uint seed) Q_DECL_NOTHROW Returns the hash value for the \a key, using \a seed to seed the calculation. */ -uint qHash(double key, uint seed) Q_DECL_NOTHROW +uint qHash(double key, uint seed) noexcept { return key != 0.0 ? hash(reinterpret_cast(&key), sizeof(key), seed) : seed ; } @@ -959,7 +959,7 @@ uint qHash(double key, uint seed) Q_DECL_NOTHROW Returns the hash value for the \a key, using \a seed to seed the calculation. */ -uint qHash(long double key, uint seed) Q_DECL_NOTHROW +uint qHash(long double key, uint seed) noexcept { return key != 0.0L ? hash(reinterpret_cast(&key), sizeof(key), seed) : seed ; } diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index a586ca5671..9a733180a5 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -240,7 +240,7 @@ class QHash static inline int alignOfNode() { return qMax(sizeof(void*), Q_ALIGNOF(Node)); } public: - inline QHash() Q_DECL_NOTHROW : d(const_cast(&QHashData::shared_null)) { } + inline QHash() noexcept : d(const_cast(&QHashData::shared_null)) { } #ifdef Q_COMPILER_INITIALIZER_LISTS inline QHash(std::initializer_list > list) : d(const_cast(&QHashData::shared_null)) @@ -255,11 +255,11 @@ public: QHash &operator=(const QHash &other); #ifdef Q_COMPILER_RVALUE_REFS - QHash(QHash &&other) Q_DECL_NOTHROW : d(other.d) { other.d = const_cast(&QHashData::shared_null); } - QHash &operator=(QHash &&other) Q_DECL_NOTHROW + QHash(QHash &&other) noexcept : d(other.d) { other.d = const_cast(&QHashData::shared_null); } + QHash &operator=(QHash &&other) noexcept { QHash moved(std::move(other)); swap(moved); return *this; } #endif - void swap(QHash &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QHash &other) noexcept { qSwap(d, other.d); } bool operator==(const QHash &other) const; bool operator!=(const QHash &other) const { return !(*this == other); } @@ -473,7 +473,7 @@ public: inline const_key_value_iterator constKeyValueEnd() const { return const_key_value_iterator(end()); } QPair equal_range(const Key &key); - QPair equal_range(const Key &key) const Q_DECL_NOTHROW; + QPair equal_range(const Key &key) const noexcept; iterator erase(iterator it) { return erase(const_iterator(it.i)); } iterator erase(const_iterator it); @@ -512,11 +512,11 @@ private: static void duplicateNode(QHashData::Node *originalNode, void *newNode); - bool isValidIterator(const iterator &it) const Q_DECL_NOTHROW + bool isValidIterator(const iterator &it) const noexcept { return isValidNode(it.i); } - bool isValidIterator(const const_iterator &it) const Q_DECL_NOTHROW + bool isValidIterator(const const_iterator &it) const noexcept { return isValidNode(it.i); } - bool isValidNode(QHashData::Node *node) const Q_DECL_NOTHROW + bool isValidNode(QHashData::Node *node) const noexcept { #if defined(QT_DEBUG) && !defined(Q_HASH_NO_ITERATOR_DEBUG) while (node->next) @@ -993,7 +993,7 @@ QPair::iterator, typename QHash::iterator> QHash< } template -QPair::const_iterator, typename QHash::const_iterator> QHash::equal_range(const Key &akey) const Q_DECL_NOTHROW +QPair::const_iterator, typename QHash::const_iterator> QHash::equal_range(const Key &akey) const noexcept { Node *node = *findNode(akey); const_iterator firstIt = const_iterator(node); @@ -1020,7 +1020,7 @@ template class QMultiHash : public QHash { public: - QMultiHash() Q_DECL_NOTHROW {} + QMultiHash() noexcept {} #ifdef Q_COMPILER_INITIALIZER_LISTS inline QMultiHash(std::initializer_list > list) { @@ -1034,9 +1034,9 @@ public: QMultiHash(const QHash &other) : QHash(other) {} #ifdef Q_COMPILER_RVALUE_REFS - QMultiHash(QHash &&other) Q_DECL_NOTHROW : QHash(std::move(other)) {} + QMultiHash(QHash &&other) noexcept : QHash(std::move(other)) {} #endif - void swap(QMultiHash &other) Q_DECL_NOTHROW { QHash::swap(other); } // prevent QMultiHash<->QHash swaps + void swap(QMultiHash &other) noexcept { QHash::swap(other); } // prevent QMultiHash<->QHash swaps inline typename QHash::iterator replace(const Key &key, const T &value) { return QHash::insert(key, value); } diff --git a/src/corelib/tools/qhashfunctions.h b/src/corelib/tools/qhashfunctions.h index d013c26d66..2d1ff01294 100644 --- a/src/corelib/tools/qhashfunctions.h +++ b/src/corelib/tools/qhashfunctions.h @@ -67,49 +67,49 @@ class QLatin1String; Q_CORE_EXPORT int qGlobalQHashSeed(); Q_CORE_EXPORT void qSetGlobalQHashSeed(int newSeed); -Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHashBits(const void *p, size_t size, uint seed = 0) Q_DECL_NOTHROW; +Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHashBits(const void *p, size_t size, uint seed = 0) noexcept; -Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(char key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; } -Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(uchar key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; } -Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(signed char key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; } -Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(ushort key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; } -Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(short key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; } -Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(uint key, uint seed = 0) Q_DECL_NOTHROW { return key ^ seed; } -Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(int key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; } -Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(ulong key, uint seed = 0) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(char key, uint seed = 0) noexcept { return uint(key) ^ seed; } +Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(uchar key, uint seed = 0) noexcept { return uint(key) ^ seed; } +Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(signed char key, uint seed = 0) noexcept { return uint(key) ^ seed; } +Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(ushort key, uint seed = 0) noexcept { return uint(key) ^ seed; } +Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(short key, uint seed = 0) noexcept { return uint(key) ^ seed; } +Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(uint key, uint seed = 0) noexcept { return key ^ seed; } +Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(int key, uint seed = 0) noexcept { return uint(key) ^ seed; } +Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(ulong key, uint seed = 0) noexcept { return (sizeof(ulong) > sizeof(uint)) ? (uint(((key >> (8 * sizeof(uint) - 1)) ^ key) & (~0U)) ^ seed) : (uint(key & (~0U)) ^ seed); } -Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(long key, uint seed = 0) Q_DECL_NOTHROW { return qHash(ulong(key), seed); } -Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(quint64 key, uint seed = 0) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(long key, uint seed = 0) noexcept { return qHash(ulong(key), seed); } +Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(quint64 key, uint seed = 0) noexcept { return uint(((key >> (8 * sizeof(uint) - 1)) ^ key) & (~0U)) ^ seed; } -Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(qint64 key, uint seed = 0) Q_DECL_NOTHROW { return qHash(quint64(key), seed); } -Q_CORE_EXPORT Q_DECL_CONST_FUNCTION uint qHash(float key, uint seed = 0) Q_DECL_NOTHROW; -Q_CORE_EXPORT Q_DECL_CONST_FUNCTION uint qHash(double key, uint seed = 0) Q_DECL_NOTHROW; +Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(qint64 key, uint seed = 0) noexcept { return qHash(quint64(key), seed); } +Q_CORE_EXPORT Q_DECL_CONST_FUNCTION uint qHash(float key, uint seed = 0) noexcept; +Q_CORE_EXPORT Q_DECL_CONST_FUNCTION uint qHash(double key, uint seed = 0) noexcept; #if !defined(Q_OS_DARWIN) || defined(Q_CLANG_QDOC) -Q_CORE_EXPORT Q_DECL_CONST_FUNCTION uint qHash(long double key, uint seed = 0) Q_DECL_NOTHROW; +Q_CORE_EXPORT Q_DECL_CONST_FUNCTION uint qHash(long double key, uint seed = 0) noexcept; #endif -Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(const QChar key, uint seed = 0) Q_DECL_NOTHROW { return qHash(key.unicode(), seed); } -Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QByteArray &key, uint seed = 0) Q_DECL_NOTHROW; +Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(const QChar key, uint seed = 0) noexcept { return qHash(key.unicode(), seed); } +Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QByteArray &key, uint seed = 0) noexcept; #if QT_STRINGVIEW_LEVEL < 2 -Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QString &key, uint seed = 0) Q_DECL_NOTHROW; -Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QStringRef &key, uint seed = 0) Q_DECL_NOTHROW; +Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QString &key, uint seed = 0) noexcept; +Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QStringRef &key, uint seed = 0) noexcept; #endif -Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(QStringView key, uint seed = 0) Q_DECL_NOTHROW; -Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QBitArray &key, uint seed = 0) Q_DECL_NOTHROW; -Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(QLatin1String key, uint seed = 0) Q_DECL_NOTHROW; -Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qt_hash(QStringView key, uint chained = 0) Q_DECL_NOTHROW; +Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(QStringView key, uint seed = 0) noexcept; +Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QBitArray &key, uint seed = 0) noexcept; +Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(QLatin1String key, uint seed = 0) noexcept; +Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qt_hash(QStringView key, uint chained = 0) noexcept; -Q_DECL_CONST_FUNCTION inline uint qHash(std::nullptr_t, uint seed = 0) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION inline uint qHash(std::nullptr_t, uint seed = 0) noexcept { return qHash(reinterpret_cast(nullptr), seed); } -template inline uint qHash(const T *key, uint seed = 0) Q_DECL_NOTHROW +template inline uint qHash(const T *key, uint seed = 0) noexcept { return qHash(reinterpret_cast(key), seed); } diff --git a/src/corelib/tools/qiterator.h b/src/corelib/tools/qiterator.h index 586d26cbad..90921af16e 100644 --- a/src/corelib/tools/qiterator.h +++ b/src/corelib/tools/qiterator.h @@ -197,8 +197,8 @@ public: return std::pair(i.key(), i.value()); } - friend bool operator==(QKeyValueIterator lhs, QKeyValueIterator rhs) Q_DECL_NOEXCEPT { return lhs.i == rhs.i; } - friend bool operator!=(QKeyValueIterator lhs, QKeyValueIterator rhs) Q_DECL_NOEXCEPT { return lhs.i != rhs.i; } + friend bool operator==(QKeyValueIterator lhs, QKeyValueIterator rhs) noexcept { return lhs.i == rhs.i; } + friend bool operator!=(QKeyValueIterator lhs, QKeyValueIterator rhs) noexcept { return lhs.i != rhs.i; } inline QKeyValueIterator &operator++() { ++i; return *this; } inline QKeyValueIterator operator++(int) { return QKeyValueIterator(i++);} diff --git a/src/corelib/tools/qlinkedlist.h b/src/corelib/tools/qlinkedlist.h index 1e6d4df474..91367a74b3 100644 --- a/src/corelib/tools/qlinkedlist.h +++ b/src/corelib/tools/qlinkedlist.h @@ -80,7 +80,7 @@ class QLinkedList union { QLinkedListData *d; QLinkedListNode *e; }; public: - inline QLinkedList() Q_DECL_NOTHROW : d(const_cast(&QLinkedListData::shared_null)) { } + inline QLinkedList() noexcept : d(const_cast(&QLinkedListData::shared_null)) { } inline QLinkedList(const QLinkedList &l) : d(l.d) { d->ref.ref(); if (!d->sharable) detach(); } #if defined(Q_COMPILER_INITIALIZER_LISTS) inline QLinkedList(std::initializer_list list) @@ -92,12 +92,12 @@ public: ~QLinkedList(); QLinkedList &operator=(const QLinkedList &); #ifdef Q_COMPILER_RVALUE_REFS - QLinkedList(QLinkedList &&other) Q_DECL_NOTHROW + QLinkedList(QLinkedList &&other) noexcept : d(other.d) { other.d = const_cast(&QLinkedListData::shared_null); } - QLinkedList &operator=(QLinkedList &&other) Q_DECL_NOTHROW + QLinkedList &operator=(QLinkedList &&other) noexcept { QLinkedList moved(std::move(other)); swap(moved); return *this; } #endif - inline void swap(QLinkedList &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + inline void swap(QLinkedList &other) noexcept { qSwap(d, other.d); } bool operator==(const QLinkedList &l) const; inline bool operator!=(const QLinkedList &l) const { return !(*this == l); } @@ -137,10 +137,10 @@ public: inline iterator() : i(nullptr) {} inline iterator(Node *n) : i(n) {} #if QT_VERSION < QT_VERSION_CHECK(6,0,0) - iterator(const iterator &other) Q_DECL_NOTHROW : i(other.i) {} - iterator &operator=(const iterator &other) Q_DECL_NOTHROW { i = other.i; return *this; } - iterator(iterator &&other) Q_DECL_NOTHROW : i(other.i) {} - iterator &operator=(iterator &&other) Q_DECL_NOTHROW { return *this = other; } + iterator(const iterator &other) noexcept : i(other.i) {} + iterator &operator=(const iterator &other) noexcept { i = other.i; return *this; } + iterator(iterator &&other) noexcept : i(other.i) {} + iterator &operator=(iterator &&other) noexcept { return *this = other; } #endif inline T &operator*() const { return i->t; } inline T *operator->() const { return &i->t; } @@ -176,10 +176,10 @@ public: inline const_iterator(Node *n) : i(n) {} inline const_iterator(iterator ci) : i(ci.i){} #if QT_VERSION < QT_VERSION_CHECK(6,0,0) - const_iterator(const const_iterator &other) Q_DECL_NOTHROW : i(other.i) {} - const_iterator &operator=(const const_iterator &other) Q_DECL_NOTHROW { i = other.i; return *this; } - const_iterator(const_iterator &&other) Q_DECL_NOTHROW : i(other.i) {} - const_iterator &operator=(const_iterator &&other) Q_DECL_NOTHROW { return *this = other; } + const_iterator(const const_iterator &other) noexcept : i(other.i) {} + const_iterator &operator=(const const_iterator &other) noexcept { i = other.i; return *this; } + const_iterator(const_iterator &&other) noexcept : i(other.i) {} + const_iterator &operator=(const_iterator &&other) noexcept { return *this = other; } #endif inline const T &operator*() const { return i->t; } inline const T *operator->() const { return &i->t; } @@ -203,20 +203,20 @@ public: typedef std::reverse_iterator const_reverse_iterator; inline iterator begin() { detach(); return e->n; } - inline const_iterator begin() const Q_DECL_NOTHROW { return e->n; } - inline const_iterator cbegin() const Q_DECL_NOTHROW { return e->n; } - inline const_iterator constBegin() const Q_DECL_NOTHROW { return e->n; } + inline const_iterator begin() const noexcept { return e->n; } + inline const_iterator cbegin() const noexcept { return e->n; } + inline const_iterator constBegin() const noexcept { return e->n; } inline iterator end() { detach(); return e; } - inline const_iterator end() const Q_DECL_NOTHROW { return e; } - inline const_iterator cend() const Q_DECL_NOTHROW { return e; } - inline const_iterator constEnd() const Q_DECL_NOTHROW { return e; } + inline const_iterator end() const noexcept { return e; } + inline const_iterator cend() const noexcept { return e; } + inline const_iterator constEnd() const noexcept { return e; } reverse_iterator rbegin() { return reverse_iterator(end()); } reverse_iterator rend() { return reverse_iterator(begin()); } - const_reverse_iterator rbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); } - const_reverse_iterator rend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); } - const_reverse_iterator crbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); } - const_reverse_iterator crend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); } + const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } + const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } + const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } + const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } iterator insert(iterator before, const T &t); iterator erase(iterator pos); diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 34577acaa5..3371920ffc 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -111,11 +111,11 @@ struct Q_CORE_EXPORT QListData { void remove(int i); void remove(int i, int n); void move(int from, int to); - inline int size() const Q_DECL_NOTHROW { return d->end - d->begin; } - inline bool isEmpty() const Q_DECL_NOTHROW { return d->end == d->begin; } - inline void **at(int i) const Q_DECL_NOTHROW { return d->array + d->begin + i; } - inline void **begin() const Q_DECL_NOTHROW { return d->array + d->begin; } - inline void **end() const Q_DECL_NOTHROW { return d->array + d->end; } + inline int size() const noexcept { return d->end - d->begin; } + inline bool isEmpty() const noexcept { return d->end == d->begin; } + inline void **at(int i) const noexcept { return d->array + d->begin + i; } + inline void **begin() const noexcept { return d->array + d->begin; } + inline void **end() const noexcept { return d->array + d->end; } }; namespace QtPrivate { @@ -156,17 +156,17 @@ private: union { QListData p; QListData::Data *d; }; public: - inline QList() Q_DECL_NOTHROW : d(const_cast(&QListData::shared_null)) { } + inline QList() noexcept : d(const_cast(&QListData::shared_null)) { } QList(const QList &l); ~QList(); QList &operator=(const QList &l); #ifdef Q_COMPILER_RVALUE_REFS - inline QList(QList &&other) Q_DECL_NOTHROW + inline QList(QList &&other) noexcept : d(other.d) { other.d = const_cast(&QListData::shared_null); } - inline QList &operator=(QList &&other) Q_DECL_NOTHROW + inline QList &operator=(QList &&other) noexcept { QList moved(std::move(other)); swap(moved); return *this; } #endif - inline void swap(QList &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + inline void swap(QList &other) noexcept { qSwap(d, other.d); } #ifdef Q_COMPILER_INITIALIZER_LISTS inline QList(std::initializer_list args) : d(const_cast(&QListData::shared_null)) @@ -175,7 +175,7 @@ public: bool operator==(const QList &l) const; inline bool operator!=(const QList &l) const { return !(*this == l); } - inline int size() const Q_DECL_NOTHROW { return p.size(); } + inline int size() const noexcept { return p.size(); } inline void detach() { if (d->ref.isShared()) detach_helper(); } @@ -198,9 +198,9 @@ public: d->ref.setSharable(sharable); } #endif - inline bool isSharedWith(const QList &other) const Q_DECL_NOTHROW { return d == other.d; } + inline bool isSharedWith(const QList &other) const noexcept { return d == other.d; } - inline bool isEmpty() const Q_DECL_NOTHROW { return p.isEmpty(); } + inline bool isEmpty() const noexcept { return p.isEmpty(); } void clear(); @@ -243,34 +243,34 @@ public: typedef T *pointer; typedef T &reference; - inline iterator() Q_DECL_NOTHROW : i(nullptr) {} - inline iterator(Node *n) Q_DECL_NOTHROW : i(n) {} + inline iterator() noexcept : i(nullptr) {} + inline iterator(Node *n) noexcept : i(n) {} #if QT_VERSION < QT_VERSION_CHECK(6,0,0) // can't remove it in Qt 5, since doing so would make the type trivial, // which changes the way it's passed to functions by value. - inline iterator(const iterator &o) Q_DECL_NOTHROW : i(o.i){} + inline iterator(const iterator &o) noexcept : i(o.i){} #endif inline T &operator*() const { return i->t(); } inline T *operator->() const { return &i->t(); } inline T &operator[](difference_type j) const { return i[j].t(); } - inline bool operator==(const iterator &o) const Q_DECL_NOTHROW { return i == o.i; } - inline bool operator!=(const iterator &o) const Q_DECL_NOTHROW { return i != o.i; } - inline bool operator<(const iterator& other) const Q_DECL_NOTHROW { return i < other.i; } - inline bool operator<=(const iterator& other) const Q_DECL_NOTHROW { return i <= other.i; } - inline bool operator>(const iterator& other) const Q_DECL_NOTHROW { return i > other.i; } - inline bool operator>=(const iterator& other) const Q_DECL_NOTHROW { return i >= other.i; } + inline bool operator==(const iterator &o) const noexcept { return i == o.i; } + inline bool operator!=(const iterator &o) const noexcept { return i != o.i; } + inline bool operator<(const iterator& other) const noexcept { return i < other.i; } + inline bool operator<=(const iterator& other) const noexcept { return i <= other.i; } + inline bool operator>(const iterator& other) const noexcept { return i > other.i; } + inline bool operator>=(const iterator& other) const noexcept { return i >= other.i; } #ifndef QT_STRICT_ITERATORS - inline bool operator==(const const_iterator &o) const Q_DECL_NOTHROW + inline bool operator==(const const_iterator &o) const noexcept { return i == o.i; } - inline bool operator!=(const const_iterator &o) const Q_DECL_NOTHROW + inline bool operator!=(const const_iterator &o) const noexcept { return i != o.i; } - inline bool operator<(const const_iterator& other) const Q_DECL_NOTHROW + inline bool operator<(const const_iterator& other) const noexcept { return i < other.i; } - inline bool operator<=(const const_iterator& other) const Q_DECL_NOTHROW + inline bool operator<=(const const_iterator& other) const noexcept { return i <= other.i; } - inline bool operator>(const const_iterator& other) const Q_DECL_NOTHROW + inline bool operator>(const const_iterator& other) const noexcept { return i > other.i; } - inline bool operator>=(const const_iterator& other) const Q_DECL_NOTHROW + inline bool operator>=(const const_iterator& other) const noexcept { return i >= other.i; } #endif inline iterator &operator++() { ++i; return *this; } @@ -296,27 +296,27 @@ public: typedef const T *pointer; typedef const T &reference; - inline const_iterator() Q_DECL_NOTHROW : i(nullptr) {} - inline const_iterator(Node *n) Q_DECL_NOTHROW : i(n) {} + inline const_iterator() noexcept : i(nullptr) {} + inline const_iterator(Node *n) noexcept : i(n) {} #if QT_VERSION < QT_VERSION_CHECK(6,0,0) // can't remove it in Qt 5, since doing so would make the type trivial, // which changes the way it's passed to functions by value. - inline const_iterator(const const_iterator &o) Q_DECL_NOTHROW : i(o.i) {} + inline const_iterator(const const_iterator &o) noexcept : i(o.i) {} #endif #ifdef QT_STRICT_ITERATORS - inline explicit const_iterator(const iterator &o) Q_DECL_NOTHROW : i(o.i) {} + inline explicit const_iterator(const iterator &o) noexcept : i(o.i) {} #else - inline const_iterator(const iterator &o) Q_DECL_NOTHROW : i(o.i) {} + inline const_iterator(const iterator &o) noexcept : i(o.i) {} #endif inline const T &operator*() const { return i->t(); } inline const T *operator->() const { return &i->t(); } inline const T &operator[](difference_type j) const { return i[j].t(); } - inline bool operator==(const const_iterator &o) const Q_DECL_NOTHROW { return i == o.i; } - inline bool operator!=(const const_iterator &o) const Q_DECL_NOTHROW { return i != o.i; } - inline bool operator<(const const_iterator& other) const Q_DECL_NOTHROW { return i < other.i; } - inline bool operator<=(const const_iterator& other) const Q_DECL_NOTHROW { return i <= other.i; } - inline bool operator>(const const_iterator& other) const Q_DECL_NOTHROW { return i > other.i; } - inline bool operator>=(const const_iterator& other) const Q_DECL_NOTHROW { return i >= other.i; } + inline bool operator==(const const_iterator &o) const noexcept { return i == o.i; } + inline bool operator!=(const const_iterator &o) const noexcept { return i != o.i; } + inline bool operator<(const const_iterator& other) const noexcept { return i < other.i; } + inline bool operator<=(const const_iterator& other) const noexcept { return i <= other.i; } + inline bool operator>(const const_iterator& other) const noexcept { return i > other.i; } + inline bool operator>=(const const_iterator& other) const noexcept { return i >= other.i; } inline const_iterator &operator++() { ++i; return *this; } inline const_iterator operator++(int) { Node *n = i; ++i; return n; } inline const_iterator &operator--() { i--; return *this; } @@ -334,19 +334,19 @@ public: typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; inline iterator begin() { detach(); return reinterpret_cast(p.begin()); } - inline const_iterator begin() const Q_DECL_NOTHROW { return reinterpret_cast(p.begin()); } - inline const_iterator cbegin() const Q_DECL_NOTHROW { return reinterpret_cast(p.begin()); } - inline const_iterator constBegin() const Q_DECL_NOTHROW { return reinterpret_cast(p.begin()); } + inline const_iterator begin() const noexcept { return reinterpret_cast(p.begin()); } + inline const_iterator cbegin() const noexcept { return reinterpret_cast(p.begin()); } + inline const_iterator constBegin() const noexcept { return reinterpret_cast(p.begin()); } inline iterator end() { detach(); return reinterpret_cast(p.end()); } - inline const_iterator end() const Q_DECL_NOTHROW { return reinterpret_cast(p.end()); } - inline const_iterator cend() const Q_DECL_NOTHROW { return reinterpret_cast(p.end()); } - inline const_iterator constEnd() const Q_DECL_NOTHROW { return reinterpret_cast(p.end()); } + inline const_iterator end() const noexcept { return reinterpret_cast(p.end()); } + inline const_iterator cend() const noexcept { return reinterpret_cast(p.end()); } + inline const_iterator constEnd() const noexcept { return reinterpret_cast(p.end()); } reverse_iterator rbegin() { return reverse_iterator(end()); } reverse_iterator rend() { return reverse_iterator(begin()); } - const_reverse_iterator rbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); } - const_reverse_iterator rend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); } - const_reverse_iterator crbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); } - const_reverse_iterator crend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); } + const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } + const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } + const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } + const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } iterator insert(iterator before, const T &t); iterator erase(iterator pos); iterator erase(iterator first, iterator last); @@ -423,7 +423,7 @@ private: void node_copy(Node *from, Node *to, Node *src); void node_destruct(Node *from, Node *to); - bool isValidIterator(const iterator &i) const Q_DECL_NOTHROW + bool isValidIterator(const iterator &i) const noexcept { const std::less less = {}; return !less(i.i, cbegin().i) && !less(cend().i, i.i); diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index ebb6c97975..9a3929c4a7 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -94,7 +94,7 @@ QT_BEGIN_INCLUDE_NAMESPACE #include "qlocale_data_p.h" QT_END_INCLUDE_NAMESPACE -QLocale::Language QLocalePrivate::codeToLanguage(QStringView code) Q_DECL_NOTHROW +QLocale::Language QLocalePrivate::codeToLanguage(QStringView code) noexcept { const auto len = code.size(); if (len != 2 && len != 3) @@ -138,7 +138,7 @@ QLocale::Language QLocalePrivate::codeToLanguage(QStringView code) Q_DECL_NOTHRO return QLocale::C; } -QLocale::Script QLocalePrivate::codeToScript(QStringView code) Q_DECL_NOTHROW +QLocale::Script QLocalePrivate::codeToScript(QStringView code) noexcept { const auto len = code.size(); if (len != 4) @@ -158,7 +158,7 @@ QLocale::Script QLocalePrivate::codeToScript(QStringView code) Q_DECL_NOTHROW return QLocale::AnyScript; } -QLocale::Country QLocalePrivate::codeToCountry(QStringView code) Q_DECL_NOTHROW +QLocale::Country QLocalePrivate::codeToCountry(QStringView code) noexcept { const auto len = code.size(); if (len != 2 && len != 3) @@ -982,7 +982,7 @@ bool QLocale::operator!=(const QLocale &other) const Returns the hash value for \a key, using \a seed to seed the calculation. */ -uint qHash(const QLocale &key, uint seed) Q_DECL_NOTHROW +uint qHash(const QLocale &key, uint seed) noexcept { QtPrivate::QHashCombine hash; seed = hash(seed, key.d->m_data); diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h index 2b4f131552..cb462db770 100644 --- a/src/corelib/tools/qlocale.h +++ b/src/corelib/tools/qlocale.h @@ -59,7 +59,7 @@ class QTextStreamPrivate; class QLocalePrivate; -Q_CORE_EXPORT uint qHash(const QLocale &key, uint seed = 0) Q_DECL_NOTHROW; +Q_CORE_EXPORT uint qHash(const QLocale &key, uint seed = 0) noexcept; class Q_CORE_EXPORT QLocale { @@ -940,12 +940,12 @@ public: QLocale(Language language, Script script, Country country); QLocale(const QLocale &other); #ifdef Q_COMPILER_RVALUE_REFS - QLocale &operator=(QLocale &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QLocale &operator=(QLocale &&other) noexcept { swap(other); return *this; } #endif QLocale &operator=(const QLocale &other); ~QLocale(); - void swap(QLocale &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QLocale &other) noexcept { qSwap(d, other.d); } Language language() const; Script script() const; @@ -1108,7 +1108,7 @@ private: QLocale(QLocalePrivate &dd); friend class QLocalePrivate; friend class QSystemLocale; - friend Q_CORE_EXPORT uint qHash(const QLocale &key, uint seed) Q_DECL_NOTHROW; + friend Q_CORE_EXPORT uint qHash(const QLocale &key, uint seed) noexcept; QSharedDataPointer d; }; diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index 5edeed1954..de973d5eac 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -365,9 +365,9 @@ public: static QLatin1String languageToCode(QLocale::Language language); static QLatin1String scriptToCode(QLocale::Script script); static QLatin1String countryToCode(QLocale::Country country); - static QLocale::Language codeToLanguage(QStringView code) Q_DECL_NOTHROW; - static QLocale::Script codeToScript(QStringView code) Q_DECL_NOTHROW; - static QLocale::Country codeToCountry(QStringView code) Q_DECL_NOTHROW; + static QLocale::Language codeToLanguage(QStringView code) noexcept; + static QLocale::Script codeToScript(QStringView code) noexcept; + static QLocale::Country codeToCountry(QStringView code) noexcept; static void getLangAndCountry(const QString &name, QLocale::Language &lang, QLocale::Script &script, QLocale::Country &cntry); diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index 1cf9299e26..103124f4ad 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -100,10 +100,10 @@ struct Q_CORE_EXPORT QMapNodeBase template static typename std::enable_if::isComplex>::type - callDestructorIfNecessary(T &t) Q_DECL_NOTHROW { Q_UNUSED(t); t.~T(); } // Q_UNUSED: silence MSVC unused 't' warning + callDestructorIfNecessary(T &t) noexcept { Q_UNUSED(t); t.~T(); } // Q_UNUSED: silence MSVC unused 't' warning template static typename std::enable_if::isComplex>::type - callDestructorIfNecessary(T &) Q_DECL_NOTHROW {} + callDestructorIfNecessary(T &) noexcept {} }; template @@ -325,7 +325,7 @@ class QMap QMapData *d; public: - inline QMap() Q_DECL_NOTHROW : d(static_cast *>(const_cast(&QMapDataBase::shared_null))) { } + inline QMap() noexcept : d(static_cast *>(const_cast(&QMapDataBase::shared_null))) { } #ifdef Q_COMPILER_INITIALIZER_LISTS inline QMap(std::initializer_list > list) : d(static_cast *>(const_cast(&QMapDataBase::shared_null))) @@ -340,17 +340,17 @@ public: QMap &operator=(const QMap &other); #ifdef Q_COMPILER_RVALUE_REFS - inline QMap(QMap &&other) Q_DECL_NOTHROW + inline QMap(QMap &&other) noexcept : d(other.d) { other.d = static_cast *>( const_cast(&QMapDataBase::shared_null)); } - inline QMap &operator=(QMap &&other) Q_DECL_NOTHROW + inline QMap &operator=(QMap &&other) noexcept { QMap moved(std::move(other)); swap(moved); return *this; } #endif - inline void swap(QMap &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + inline void swap(QMap &other) noexcept { qSwap(d, other.d); } explicit QMap(const typename std::map &other); std::map toStdMap() const; @@ -1187,7 +1187,7 @@ template class QMultiMap : public QMap { public: - QMultiMap() Q_DECL_NOTHROW {} + QMultiMap() noexcept {} #ifdef Q_COMPILER_INITIALIZER_LISTS inline QMultiMap(std::initializer_list > list) { @@ -1197,9 +1197,9 @@ public: #endif QMultiMap(const QMap &other) : QMap(other) {} #ifdef Q_COMPILER_RVALUE_REFS - QMultiMap(QMap &&other) Q_DECL_NOTHROW : QMap(std::move(other)) {} + QMultiMap(QMap &&other) noexcept : QMap(std::move(other)) {} #endif - void swap(QMultiMap &other) Q_DECL_NOTHROW { QMap::swap(other); } + void swap(QMultiMap &other) noexcept { QMap::swap(other); } inline typename QMap::iterator replace(const Key &key, const T &value) { return QMap::insert(key, value); } diff --git a/src/corelib/tools/qmargins.h b/src/corelib/tools/qmargins.h index 0c73235d26..447037daaa 100644 --- a/src/corelib/tools/qmargins.h +++ b/src/corelib/tools/qmargins.h @@ -51,28 +51,28 @@ QT_BEGIN_NAMESPACE class QMargins { public: - Q_DECL_CONSTEXPR QMargins() Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR QMargins(int left, int top, int right, int bottom) Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR QMargins() noexcept; + Q_DECL_CONSTEXPR QMargins(int left, int top, int right, int bottom) noexcept; - Q_DECL_CONSTEXPR bool isNull() const Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR bool isNull() const noexcept; - Q_DECL_CONSTEXPR int left() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR int top() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR int right() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR int bottom() const Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR int left() const noexcept; + Q_DECL_CONSTEXPR int top() const noexcept; + Q_DECL_CONSTEXPR int right() const noexcept; + Q_DECL_CONSTEXPR int bottom() const noexcept; - Q_DECL_RELAXED_CONSTEXPR void setLeft(int left) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR void setTop(int top) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR void setRight(int right) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR void setBottom(int bottom) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR void setLeft(int left) noexcept; + Q_DECL_RELAXED_CONSTEXPR void setTop(int top) noexcept; + Q_DECL_RELAXED_CONSTEXPR void setRight(int right) noexcept; + Q_DECL_RELAXED_CONSTEXPR void setBottom(int bottom) noexcept; - Q_DECL_RELAXED_CONSTEXPR QMargins &operator+=(const QMargins &margins) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR QMargins &operator-=(const QMargins &margins) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR QMargins &operator+=(int) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR QMargins &operator-=(int) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR QMargins &operator*=(int) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR QMargins &operator+=(const QMargins &margins) noexcept; + Q_DECL_RELAXED_CONSTEXPR QMargins &operator-=(const QMargins &margins) noexcept; + Q_DECL_RELAXED_CONSTEXPR QMargins &operator+=(int) noexcept; + Q_DECL_RELAXED_CONSTEXPR QMargins &operator-=(int) noexcept; + Q_DECL_RELAXED_CONSTEXPR QMargins &operator*=(int) noexcept; Q_DECL_RELAXED_CONSTEXPR QMargins &operator/=(int); - Q_DECL_RELAXED_CONSTEXPR QMargins &operator*=(qreal) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR QMargins &operator*=(qreal) noexcept; Q_DECL_RELAXED_CONSTEXPR QMargins &operator/=(qreal); private: @@ -81,8 +81,8 @@ private: int m_right; int m_bottom; - friend Q_DECL_CONSTEXPR inline bool operator==(const QMargins &, const QMargins &) Q_DECL_NOTHROW; - friend Q_DECL_CONSTEXPR inline bool operator!=(const QMargins &, const QMargins &) Q_DECL_NOTHROW; + friend Q_DECL_CONSTEXPR inline bool operator==(const QMargins &, const QMargins &) noexcept; + friend Q_DECL_CONSTEXPR inline bool operator!=(const QMargins &, const QMargins &) noexcept; }; Q_DECLARE_TYPEINFO(QMargins, Q_MOVABLE_TYPE); @@ -99,40 +99,40 @@ Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QMargins &); QMargins inline functions *****************************************************************************/ -Q_DECL_CONSTEXPR inline QMargins::QMargins() Q_DECL_NOTHROW : m_left(0), m_top(0), m_right(0), m_bottom(0) {} +Q_DECL_CONSTEXPR inline QMargins::QMargins() noexcept : m_left(0), m_top(0), m_right(0), m_bottom(0) {} -Q_DECL_CONSTEXPR inline QMargins::QMargins(int aleft, int atop, int aright, int abottom) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMargins::QMargins(int aleft, int atop, int aright, int abottom) noexcept : m_left(aleft), m_top(atop), m_right(aright), m_bottom(abottom) {} -Q_DECL_CONSTEXPR inline bool QMargins::isNull() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool QMargins::isNull() const noexcept { return m_left==0 && m_top==0 && m_right==0 && m_bottom==0; } -Q_DECL_CONSTEXPR inline int QMargins::left() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int QMargins::left() const noexcept { return m_left; } -Q_DECL_CONSTEXPR inline int QMargins::top() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int QMargins::top() const noexcept { return m_top; } -Q_DECL_CONSTEXPR inline int QMargins::right() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int QMargins::right() const noexcept { return m_right; } -Q_DECL_CONSTEXPR inline int QMargins::bottom() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int QMargins::bottom() const noexcept { return m_bottom; } -Q_DECL_RELAXED_CONSTEXPR inline void QMargins::setLeft(int aleft) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QMargins::setLeft(int aleft) noexcept { m_left = aleft; } -Q_DECL_RELAXED_CONSTEXPR inline void QMargins::setTop(int atop) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QMargins::setTop(int atop) noexcept { m_top = atop; } -Q_DECL_RELAXED_CONSTEXPR inline void QMargins::setRight(int aright) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QMargins::setRight(int aright) noexcept { m_right = aright; } -Q_DECL_RELAXED_CONSTEXPR inline void QMargins::setBottom(int abottom) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QMargins::setBottom(int abottom) noexcept { m_bottom = abottom; } -Q_DECL_CONSTEXPR inline bool operator==(const QMargins &m1, const QMargins &m2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator==(const QMargins &m1, const QMargins &m2) noexcept { return m1.m_left == m2.m_left && @@ -141,7 +141,7 @@ Q_DECL_CONSTEXPR inline bool operator==(const QMargins &m1, const QMargins &m2) m1.m_bottom == m2.m_bottom; } -Q_DECL_CONSTEXPR inline bool operator!=(const QMargins &m1, const QMargins &m2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator!=(const QMargins &m1, const QMargins &m2) noexcept { return m1.m_left != m2.m_left || @@ -150,55 +150,55 @@ Q_DECL_CONSTEXPR inline bool operator!=(const QMargins &m1, const QMargins &m2) m1.m_bottom != m2.m_bottom; } -Q_DECL_CONSTEXPR inline QMargins operator+(const QMargins &m1, const QMargins &m2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMargins operator+(const QMargins &m1, const QMargins &m2) noexcept { return QMargins(m1.left() + m2.left(), m1.top() + m2.top(), m1.right() + m2.right(), m1.bottom() + m2.bottom()); } -Q_DECL_CONSTEXPR inline QMargins operator-(const QMargins &m1, const QMargins &m2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMargins operator-(const QMargins &m1, const QMargins &m2) noexcept { return QMargins(m1.left() - m2.left(), m1.top() - m2.top(), m1.right() - m2.right(), m1.bottom() - m2.bottom()); } -Q_DECL_CONSTEXPR inline QMargins operator+(const QMargins &lhs, int rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMargins operator+(const QMargins &lhs, int rhs) noexcept { return QMargins(lhs.left() + rhs, lhs.top() + rhs, lhs.right() + rhs, lhs.bottom() + rhs); } -Q_DECL_CONSTEXPR inline QMargins operator+(int lhs, const QMargins &rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMargins operator+(int lhs, const QMargins &rhs) noexcept { return QMargins(rhs.left() + lhs, rhs.top() + lhs, rhs.right() + lhs, rhs.bottom() + lhs); } -Q_DECL_CONSTEXPR inline QMargins operator-(const QMargins &lhs, int rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMargins operator-(const QMargins &lhs, int rhs) noexcept { return QMargins(lhs.left() - rhs, lhs.top() - rhs, lhs.right() - rhs, lhs.bottom() - rhs); } -Q_DECL_CONSTEXPR inline QMargins operator*(const QMargins &margins, int factor) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMargins operator*(const QMargins &margins, int factor) noexcept { return QMargins(margins.left() * factor, margins.top() * factor, margins.right() * factor, margins.bottom() * factor); } -Q_DECL_CONSTEXPR inline QMargins operator*(int factor, const QMargins &margins) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMargins operator*(int factor, const QMargins &margins) noexcept { return QMargins(margins.left() * factor, margins.top() * factor, margins.right() * factor, margins.bottom() * factor); } -Q_DECL_CONSTEXPR inline QMargins operator*(const QMargins &margins, qreal factor) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMargins operator*(const QMargins &margins, qreal factor) noexcept { return QMargins(qRound(margins.left() * factor), qRound(margins.top() * factor), qRound(margins.right() * factor), qRound(margins.bottom() * factor)); } -Q_DECL_CONSTEXPR inline QMargins operator*(qreal factor, const QMargins &margins) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMargins operator*(qreal factor, const QMargins &margins) noexcept { return QMargins(qRound(margins.left() * factor), qRound(margins.top() * factor), qRound(margins.right() * factor), qRound(margins.bottom() * factor)); @@ -216,17 +216,17 @@ Q_DECL_CONSTEXPR inline QMargins operator/(const QMargins &margins, qreal diviso qRound(margins.right() / divisor), qRound(margins.bottom() / divisor)); } -Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator+=(const QMargins &margins) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator+=(const QMargins &margins) noexcept { return *this = *this + margins; } -Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator-=(const QMargins &margins) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator-=(const QMargins &margins) noexcept { return *this = *this - margins; } -Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator+=(int margin) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator+=(int margin) noexcept { m_left += margin; m_top += margin; @@ -235,7 +235,7 @@ Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator+=(int margin) Q_DEC return *this; } -Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator-=(int margin) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator-=(int margin) noexcept { m_left -= margin; m_top -= margin; @@ -244,7 +244,7 @@ Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator-=(int margin) Q_DEC return *this; } -Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator*=(int factor) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator*=(int factor) noexcept { return *this = *this * factor; } @@ -254,7 +254,7 @@ Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator/=(int divisor) return *this = *this / divisor; } -Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator*=(qreal factor) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator*=(qreal factor) noexcept { return *this = *this * factor; } @@ -264,12 +264,12 @@ Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator/=(qreal divisor) return *this = *this / divisor; } -Q_DECL_CONSTEXPR inline QMargins operator+(const QMargins &margins) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMargins operator+(const QMargins &margins) noexcept { return margins; } -Q_DECL_CONSTEXPR inline QMargins operator-(const QMargins &margins) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMargins operator-(const QMargins &margins) noexcept { return QMargins(-margins.left(), -margins.top(), -margins.right(), -margins.bottom()); } @@ -285,30 +285,30 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QMargins &); class QMarginsF { public: - Q_DECL_CONSTEXPR QMarginsF() Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR QMarginsF(qreal left, qreal top, qreal right, qreal bottom) Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR QMarginsF(const QMargins &margins) Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR QMarginsF() noexcept; + Q_DECL_CONSTEXPR QMarginsF(qreal left, qreal top, qreal right, qreal bottom) noexcept; + Q_DECL_CONSTEXPR QMarginsF(const QMargins &margins) noexcept; - Q_DECL_CONSTEXPR bool isNull() const Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR bool isNull() const noexcept; - Q_DECL_CONSTEXPR qreal left() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR qreal top() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR qreal right() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR qreal bottom() const Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR qreal left() const noexcept; + Q_DECL_CONSTEXPR qreal top() const noexcept; + Q_DECL_CONSTEXPR qreal right() const noexcept; + Q_DECL_CONSTEXPR qreal bottom() const noexcept; - Q_DECL_RELAXED_CONSTEXPR void setLeft(qreal left) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR void setTop(qreal top) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR void setRight(qreal right) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR void setBottom(qreal bottom) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR void setLeft(qreal left) noexcept; + Q_DECL_RELAXED_CONSTEXPR void setTop(qreal top) noexcept; + Q_DECL_RELAXED_CONSTEXPR void setRight(qreal right) noexcept; + Q_DECL_RELAXED_CONSTEXPR void setBottom(qreal bottom) noexcept; - Q_DECL_RELAXED_CONSTEXPR QMarginsF &operator+=(const QMarginsF &margins) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR QMarginsF &operator-=(const QMarginsF &margins) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR QMarginsF &operator+=(qreal addend) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR QMarginsF &operator-=(qreal subtrahend) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR QMarginsF &operator*=(qreal factor) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR QMarginsF &operator+=(const QMarginsF &margins) noexcept; + Q_DECL_RELAXED_CONSTEXPR QMarginsF &operator-=(const QMarginsF &margins) noexcept; + Q_DECL_RELAXED_CONSTEXPR QMarginsF &operator+=(qreal addend) noexcept; + Q_DECL_RELAXED_CONSTEXPR QMarginsF &operator-=(qreal subtrahend) noexcept; + Q_DECL_RELAXED_CONSTEXPR QMarginsF &operator*=(qreal factor) noexcept; Q_DECL_RELAXED_CONSTEXPR QMarginsF &operator/=(qreal divisor); - Q_DECL_CONSTEXPR inline QMargins toMargins() const Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline QMargins toMargins() const noexcept; private: qreal m_left; @@ -332,44 +332,44 @@ Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QMarginsF &); QMarginsF inline functions *****************************************************************************/ -Q_DECL_CONSTEXPR inline QMarginsF::QMarginsF() Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMarginsF::QMarginsF() noexcept : m_left(0), m_top(0), m_right(0), m_bottom(0) {} -Q_DECL_CONSTEXPR inline QMarginsF::QMarginsF(qreal aleft, qreal atop, qreal aright, qreal abottom) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMarginsF::QMarginsF(qreal aleft, qreal atop, qreal aright, qreal abottom) noexcept : m_left(aleft), m_top(atop), m_right(aright), m_bottom(abottom) {} -Q_DECL_CONSTEXPR inline QMarginsF::QMarginsF(const QMargins &margins) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMarginsF::QMarginsF(const QMargins &margins) noexcept : m_left(margins.left()), m_top(margins.top()), m_right(margins.right()), m_bottom(margins.bottom()) {} -Q_DECL_CONSTEXPR inline bool QMarginsF::isNull() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool QMarginsF::isNull() const noexcept { return qFuzzyIsNull(m_left) && qFuzzyIsNull(m_top) && qFuzzyIsNull(m_right) && qFuzzyIsNull(m_bottom); } -Q_DECL_CONSTEXPR inline qreal QMarginsF::left() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline qreal QMarginsF::left() const noexcept { return m_left; } -Q_DECL_CONSTEXPR inline qreal QMarginsF::top() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline qreal QMarginsF::top() const noexcept { return m_top; } -Q_DECL_CONSTEXPR inline qreal QMarginsF::right() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline qreal QMarginsF::right() const noexcept { return m_right; } -Q_DECL_CONSTEXPR inline qreal QMarginsF::bottom() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline qreal QMarginsF::bottom() const noexcept { return m_bottom; } -Q_DECL_RELAXED_CONSTEXPR inline void QMarginsF::setLeft(qreal aleft) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QMarginsF::setLeft(qreal aleft) noexcept { m_left = aleft; } -Q_DECL_RELAXED_CONSTEXPR inline void QMarginsF::setTop(qreal atop) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QMarginsF::setTop(qreal atop) noexcept { m_top = atop; } -Q_DECL_RELAXED_CONSTEXPR inline void QMarginsF::setRight(qreal aright) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QMarginsF::setRight(qreal aright) noexcept { m_right = aright; } -Q_DECL_RELAXED_CONSTEXPR inline void QMarginsF::setBottom(qreal abottom) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QMarginsF::setBottom(qreal abottom) noexcept { m_bottom = abottom; } -Q_DECL_CONSTEXPR inline bool operator==(const QMarginsF &lhs, const QMarginsF &rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator==(const QMarginsF &lhs, const QMarginsF &rhs) noexcept { return qFuzzyCompare(lhs.left(), rhs.left()) && qFuzzyCompare(lhs.top(), rhs.top()) @@ -377,48 +377,48 @@ Q_DECL_CONSTEXPR inline bool operator==(const QMarginsF &lhs, const QMarginsF &r && qFuzzyCompare(lhs.bottom(), rhs.bottom()); } -Q_DECL_CONSTEXPR inline bool operator!=(const QMarginsF &lhs, const QMarginsF &rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator!=(const QMarginsF &lhs, const QMarginsF &rhs) noexcept { return !operator==(lhs, rhs); } -Q_DECL_CONSTEXPR inline QMarginsF operator+(const QMarginsF &lhs, const QMarginsF &rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMarginsF operator+(const QMarginsF &lhs, const QMarginsF &rhs) noexcept { return QMarginsF(lhs.left() + rhs.left(), lhs.top() + rhs.top(), lhs.right() + rhs.right(), lhs.bottom() + rhs.bottom()); } -Q_DECL_CONSTEXPR inline QMarginsF operator-(const QMarginsF &lhs, const QMarginsF &rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMarginsF operator-(const QMarginsF &lhs, const QMarginsF &rhs) noexcept { return QMarginsF(lhs.left() - rhs.left(), lhs.top() - rhs.top(), lhs.right() - rhs.right(), lhs.bottom() - rhs.bottom()); } -Q_DECL_CONSTEXPR inline QMarginsF operator+(const QMarginsF &lhs, qreal rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMarginsF operator+(const QMarginsF &lhs, qreal rhs) noexcept { return QMarginsF(lhs.left() + rhs, lhs.top() + rhs, lhs.right() + rhs, lhs.bottom() + rhs); } -Q_DECL_CONSTEXPR inline QMarginsF operator+(qreal lhs, const QMarginsF &rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMarginsF operator+(qreal lhs, const QMarginsF &rhs) noexcept { return QMarginsF(rhs.left() + lhs, rhs.top() + lhs, rhs.right() + lhs, rhs.bottom() + lhs); } -Q_DECL_CONSTEXPR inline QMarginsF operator-(const QMarginsF &lhs, qreal rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMarginsF operator-(const QMarginsF &lhs, qreal rhs) noexcept { return QMarginsF(lhs.left() - rhs, lhs.top() - rhs, lhs.right() - rhs, lhs.bottom() - rhs); } -Q_DECL_CONSTEXPR inline QMarginsF operator*(const QMarginsF &lhs, qreal rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMarginsF operator*(const QMarginsF &lhs, qreal rhs) noexcept { return QMarginsF(lhs.left() * rhs, lhs.top() * rhs, lhs.right() * rhs, lhs.bottom() * rhs); } -Q_DECL_CONSTEXPR inline QMarginsF operator*(qreal lhs, const QMarginsF &rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMarginsF operator*(qreal lhs, const QMarginsF &rhs) noexcept { return QMarginsF(rhs.left() * lhs, rhs.top() * lhs, rhs.right() * lhs, rhs.bottom() * lhs); @@ -430,17 +430,17 @@ Q_DECL_CONSTEXPR inline QMarginsF operator/(const QMarginsF &lhs, qreal divisor) lhs.right() / divisor, lhs.bottom() / divisor); } -Q_DECL_RELAXED_CONSTEXPR inline QMarginsF &QMarginsF::operator+=(const QMarginsF &margins) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QMarginsF &QMarginsF::operator+=(const QMarginsF &margins) noexcept { return *this = *this + margins; } -Q_DECL_RELAXED_CONSTEXPR inline QMarginsF &QMarginsF::operator-=(const QMarginsF &margins) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QMarginsF &QMarginsF::operator-=(const QMarginsF &margins) noexcept { return *this = *this - margins; } -Q_DECL_RELAXED_CONSTEXPR inline QMarginsF &QMarginsF::operator+=(qreal addend) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QMarginsF &QMarginsF::operator+=(qreal addend) noexcept { m_left += addend; m_top += addend; @@ -449,7 +449,7 @@ Q_DECL_RELAXED_CONSTEXPR inline QMarginsF &QMarginsF::operator+=(qreal addend) Q return *this; } -Q_DECL_RELAXED_CONSTEXPR inline QMarginsF &QMarginsF::operator-=(qreal subtrahend) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QMarginsF &QMarginsF::operator-=(qreal subtrahend) noexcept { m_left -= subtrahend; m_top -= subtrahend; @@ -458,7 +458,7 @@ Q_DECL_RELAXED_CONSTEXPR inline QMarginsF &QMarginsF::operator-=(qreal subtrahen return *this; } -Q_DECL_RELAXED_CONSTEXPR inline QMarginsF &QMarginsF::operator*=(qreal factor) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QMarginsF &QMarginsF::operator*=(qreal factor) noexcept { return *this = *this * factor; } @@ -468,17 +468,17 @@ Q_DECL_RELAXED_CONSTEXPR inline QMarginsF &QMarginsF::operator/=(qreal divisor) return *this = *this / divisor; } -Q_DECL_CONSTEXPR inline QMarginsF operator+(const QMarginsF &margins) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMarginsF operator+(const QMarginsF &margins) noexcept { return margins; } -Q_DECL_CONSTEXPR inline QMarginsF operator-(const QMarginsF &margins) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMarginsF operator-(const QMarginsF &margins) noexcept { return QMarginsF(-margins.left(), -margins.top(), -margins.right(), -margins.bottom()); } -Q_DECL_CONSTEXPR inline QMargins QMarginsF::toMargins() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QMargins QMarginsF::toMargins() const noexcept { return QMargins(qRound(m_left), qRound(m_top), qRound(m_right), qRound(m_bottom)); } diff --git a/src/corelib/tools/qpoint.h b/src/corelib/tools/qpoint.h index d7323f7707..34df673b93 100644 --- a/src/corelib/tools/qpoint.h +++ b/src/corelib/tools/qpoint.h @@ -94,7 +94,7 @@ public: friend Q_DECL_CONSTEXPR inline const QPoint operator/(const QPoint &, qreal); #if defined(Q_OS_DARWIN) || defined(Q_QDOC) - Q_REQUIRED_RESULT CGPoint toCGPoint() const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT CGPoint toCGPoint() const noexcept; #endif private: @@ -256,8 +256,8 @@ public: Q_DECL_CONSTEXPR QPoint toPoint() const; #if defined(Q_OS_DARWIN) || defined(Q_QDOC) - Q_REQUIRED_RESULT static QPointF fromCGPoint(CGPoint point) Q_DECL_NOTHROW; - Q_REQUIRED_RESULT CGPoint toCGPoint() const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT static QPointF fromCGPoint(CGPoint point) noexcept; + Q_REQUIRED_RESULT CGPoint toCGPoint() const noexcept; #endif private: diff --git a/src/corelib/tools/qqueue.h b/src/corelib/tools/qqueue.h index b55f210577..16229759ee 100644 --- a/src/corelib/tools/qqueue.h +++ b/src/corelib/tools/qqueue.h @@ -50,7 +50,7 @@ class QQueue : public QList { public: // compiler-generated special member functions are fine! - inline void swap(QQueue &other) Q_DECL_NOTHROW { QList::swap(other); } // prevent QList<->QQueue swaps + inline void swap(QQueue &other) noexcept { QList::swap(other); } // prevent QList<->QQueue swaps #ifndef Q_QDOC // bring in QList::swap(int, int). We cannot say using QList::swap, // because we don't want to make swap(QList&) available. diff --git a/src/corelib/tools/qrect.cpp b/src/corelib/tools/qrect.cpp index 6e51deebea..d622f92530 100644 --- a/src/corelib/tools/qrect.cpp +++ b/src/corelib/tools/qrect.cpp @@ -300,7 +300,7 @@ QT_BEGIN_NAMESPACE \sa isValid(), isEmpty() */ -QRect QRect::normalized() const Q_DECL_NOTHROW +QRect QRect::normalized() const noexcept { QRect r; if (x2 < x1 - 1) { // swap bad x values @@ -820,7 +820,7 @@ QRect QRect::normalized() const Q_DECL_NOTHROW \sa intersects() */ -bool QRect::contains(const QPoint &p, bool proper) const Q_DECL_NOTHROW +bool QRect::contains(const QPoint &p, bool proper) const noexcept { int l, r; if (x2 < x1 - 1) { @@ -884,7 +884,7 @@ bool QRect::contains(const QPoint &p, bool proper) const Q_DECL_NOTHROW rectangle (not on the edge). */ -bool QRect::contains(const QRect &r, bool proper) const Q_DECL_NOTHROW +bool QRect::contains(const QRect &r, bool proper) const noexcept { if (isNull() || r.isNull()) return false; @@ -962,7 +962,7 @@ bool QRect::contains(const QRect &r, bool proper) const Q_DECL_NOTHROW \sa operator|=(), united() */ -QRect QRect::operator|(const QRect &r) const Q_DECL_NOTHROW +QRect QRect::operator|(const QRect &r) const noexcept { if (isNull()) return r; @@ -1033,7 +1033,7 @@ QRect QRect::operator|(const QRect &r) const Q_DECL_NOTHROW \sa operator&=(), intersected() */ -QRect QRect::operator&(const QRect &r) const Q_DECL_NOTHROW +QRect QRect::operator&(const QRect &r) const noexcept { if (isNull() || r.isNull()) return QRect(); @@ -1112,7 +1112,7 @@ QRect QRect::operator&(const QRect &r) const Q_DECL_NOTHROW \sa contains() */ -bool QRect::intersects(const QRect &r) const Q_DECL_NOTHROW +bool QRect::intersects(const QRect &r) const noexcept { if (isNull() || r.isNull()) return false; @@ -1540,7 +1540,7 @@ QDebug operator<<(QDebug dbg, const QRect &r) \sa isValid(), isEmpty() */ -QRectF QRectF::normalized() const Q_DECL_NOTHROW +QRectF QRectF::normalized() const noexcept { QRectF r = *this; if (r.w < 0) { @@ -1964,7 +1964,7 @@ QRectF QRectF::normalized() const Q_DECL_NOTHROW \sa intersects() */ -bool QRectF::contains(const QPointF &p) const Q_DECL_NOTHROW +bool QRectF::contains(const QPointF &p) const noexcept { qreal l = xp; qreal r = xp; @@ -2010,7 +2010,7 @@ bool QRectF::contains(const QPointF &p) const Q_DECL_NOTHROW otherwise returns \c false. */ -bool QRectF::contains(const QRectF &r) const Q_DECL_NOTHROW +bool QRectF::contains(const QRectF &r) const noexcept { qreal l1 = xp; qreal r1 = xp; @@ -2148,7 +2148,7 @@ bool QRectF::contains(const QRectF &r) const Q_DECL_NOTHROW \sa united(), operator|=() */ -QRectF QRectF::operator|(const QRectF &r) const Q_DECL_NOTHROW +QRectF QRectF::operator|(const QRectF &r) const noexcept { if (isNull()) return r; @@ -2217,7 +2217,7 @@ QRectF QRectF::operator|(const QRectF &r) const Q_DECL_NOTHROW \sa operator&=(), intersected() */ -QRectF QRectF::operator&(const QRectF &r) const Q_DECL_NOTHROW +QRectF QRectF::operator&(const QRectF &r) const noexcept { qreal l1 = xp; qreal r1 = xp; @@ -2302,7 +2302,7 @@ QRectF QRectF::operator&(const QRectF &r) const Q_DECL_NOTHROW \sa contains() */ -bool QRectF::intersects(const QRectF &r) const Q_DECL_NOTHROW +bool QRectF::intersects(const QRectF &r) const noexcept { qreal l1 = xp; qreal r1 = xp; @@ -2369,7 +2369,7 @@ bool QRectF::intersects(const QRectF &r) const Q_DECL_NOTHROW \sa toRect() */ -QRect QRectF::toAlignedRect() const Q_DECL_NOTHROW +QRect QRectF::toAlignedRect() const noexcept { int xmin = int(qFloor(xp)); int xmax = int(qCeil(xp + w)); diff --git a/src/corelib/tools/qrect.h b/src/corelib/tools/qrect.h index 3b40055b5a..7aa2312f38 100644 --- a/src/corelib/tools/qrect.h +++ b/src/corelib/tools/qrect.h @@ -57,104 +57,104 @@ QT_BEGIN_NAMESPACE class Q_CORE_EXPORT QRect { public: - Q_DECL_CONSTEXPR QRect() Q_DECL_NOTHROW : x1(0), y1(0), x2(-1), y2(-1) {} - Q_DECL_CONSTEXPR QRect(const QPoint &topleft, const QPoint &bottomright) Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR QRect(const QPoint &topleft, const QSize &size) Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR QRect(int left, int top, int width, int height) Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR QRect() noexcept : x1(0), y1(0), x2(-1), y2(-1) {} + Q_DECL_CONSTEXPR QRect(const QPoint &topleft, const QPoint &bottomright) noexcept; + Q_DECL_CONSTEXPR QRect(const QPoint &topleft, const QSize &size) noexcept; + Q_DECL_CONSTEXPR QRect(int left, int top, int width, int height) noexcept; - Q_DECL_CONSTEXPR inline bool isNull() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline bool isEmpty() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline bool isValid() const Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline bool isNull() const noexcept; + Q_DECL_CONSTEXPR inline bool isEmpty() const noexcept; + Q_DECL_CONSTEXPR inline bool isValid() const noexcept; - Q_DECL_CONSTEXPR inline int left() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline int top() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline int right() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline int bottom() const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT QRect normalized() const Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline int left() const noexcept; + Q_DECL_CONSTEXPR inline int top() const noexcept; + Q_DECL_CONSTEXPR inline int right() const noexcept; + Q_DECL_CONSTEXPR inline int bottom() const noexcept; + Q_REQUIRED_RESULT QRect normalized() const noexcept; - Q_DECL_CONSTEXPR inline int x() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline int y() const Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setLeft(int pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setTop(int pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setRight(int pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setBottom(int pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setX(int x) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setY(int y) Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline int x() const noexcept; + Q_DECL_CONSTEXPR inline int y() const noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setLeft(int pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setTop(int pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setRight(int pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setBottom(int pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setX(int x) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setY(int y) noexcept; - Q_DECL_RELAXED_CONSTEXPR inline void setTopLeft(const QPoint &p) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setBottomRight(const QPoint &p) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setTopRight(const QPoint &p) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setBottomLeft(const QPoint &p) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline void setTopLeft(const QPoint &p) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setBottomRight(const QPoint &p) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setTopRight(const QPoint &p) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setBottomLeft(const QPoint &p) noexcept; - Q_DECL_CONSTEXPR inline QPoint topLeft() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QPoint bottomRight() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QPoint topRight() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QPoint bottomLeft() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QPoint center() const Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline QPoint topLeft() const noexcept; + Q_DECL_CONSTEXPR inline QPoint bottomRight() const noexcept; + Q_DECL_CONSTEXPR inline QPoint topRight() const noexcept; + Q_DECL_CONSTEXPR inline QPoint bottomLeft() const noexcept; + Q_DECL_CONSTEXPR inline QPoint center() const noexcept; - Q_DECL_RELAXED_CONSTEXPR inline void moveLeft(int pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveTop(int pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveRight(int pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveBottom(int pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveTopLeft(const QPoint &p) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveBottomRight(const QPoint &p) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveTopRight(const QPoint &p) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveBottomLeft(const QPoint &p) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveCenter(const QPoint &p) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline void moveLeft(int pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveTop(int pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveRight(int pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveBottom(int pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveTopLeft(const QPoint &p) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveBottomRight(const QPoint &p) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveTopRight(const QPoint &p) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveBottomLeft(const QPoint &p) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveCenter(const QPoint &p) noexcept; - Q_DECL_RELAXED_CONSTEXPR inline void translate(int dx, int dy) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void translate(const QPoint &p) Q_DECL_NOTHROW; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect translated(int dx, int dy) const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect translated(const QPoint &p) const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect transposed() const Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline void translate(int dx, int dy) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void translate(const QPoint &p) noexcept; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect translated(int dx, int dy) const noexcept; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect translated(const QPoint &p) const noexcept; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect transposed() const noexcept; - Q_DECL_RELAXED_CONSTEXPR inline void moveTo(int x, int t) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveTo(const QPoint &p) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline void moveTo(int x, int t) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveTo(const QPoint &p) noexcept; - Q_DECL_RELAXED_CONSTEXPR inline void setRect(int x, int y, int w, int h) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline void setRect(int x, int y, int w, int h) noexcept; Q_DECL_RELAXED_CONSTEXPR inline void getRect(int *x, int *y, int *w, int *h) const; - Q_DECL_RELAXED_CONSTEXPR inline void setCoords(int x1, int y1, int x2, int y2) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline void setCoords(int x1, int y1, int x2, int y2) noexcept; Q_DECL_RELAXED_CONSTEXPR inline void getCoords(int *x1, int *y1, int *x2, int *y2) const; - Q_DECL_RELAXED_CONSTEXPR inline void adjust(int x1, int y1, int x2, int y2) Q_DECL_NOTHROW; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect adjusted(int x1, int y1, int x2, int y2) const Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline void adjust(int x1, int y1, int x2, int y2) noexcept; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect adjusted(int x1, int y1, int x2, int y2) const noexcept; - Q_DECL_CONSTEXPR inline QSize size() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline int width() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline int height() const Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setWidth(int w) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setHeight(int h) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setSize(const QSize &s) Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline QSize size() const noexcept; + Q_DECL_CONSTEXPR inline int width() const noexcept; + Q_DECL_CONSTEXPR inline int height() const noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setWidth(int w) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setHeight(int h) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setSize(const QSize &s) noexcept; - QRect operator|(const QRect &r) const Q_DECL_NOTHROW; - QRect operator&(const QRect &r) const Q_DECL_NOTHROW; - inline QRect& operator|=(const QRect &r) Q_DECL_NOTHROW; - inline QRect& operator&=(const QRect &r) Q_DECL_NOTHROW; + QRect operator|(const QRect &r) const noexcept; + QRect operator&(const QRect &r) const noexcept; + inline QRect& operator|=(const QRect &r) noexcept; + inline QRect& operator&=(const QRect &r) noexcept; - bool contains(const QRect &r, bool proper = false) const Q_DECL_NOTHROW; - bool contains(const QPoint &p, bool proper=false) const Q_DECL_NOTHROW; - inline bool contains(int x, int y) const Q_DECL_NOTHROW; - inline bool contains(int x, int y, bool proper) const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT inline QRect united(const QRect &other) const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT inline QRect intersected(const QRect &other) const Q_DECL_NOTHROW; - bool intersects(const QRect &r) const Q_DECL_NOTHROW; + bool contains(const QRect &r, bool proper = false) const noexcept; + bool contains(const QPoint &p, bool proper=false) const noexcept; + inline bool contains(int x, int y) const noexcept; + inline bool contains(int x, int y, bool proper) const noexcept; + Q_REQUIRED_RESULT inline QRect united(const QRect &other) const noexcept; + Q_REQUIRED_RESULT inline QRect intersected(const QRect &other) const noexcept; + bool intersects(const QRect &r) const noexcept; - Q_DECL_CONSTEXPR inline QRect marginsAdded(const QMargins &margins) const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QRect marginsRemoved(const QMargins &margins) const Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline QRect &operator+=(const QMargins &margins) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline QRect &operator-=(const QMargins &margins) Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline QRect marginsAdded(const QMargins &margins) const noexcept; + Q_DECL_CONSTEXPR inline QRect marginsRemoved(const QMargins &margins) const noexcept; + Q_DECL_RELAXED_CONSTEXPR inline QRect &operator+=(const QMargins &margins) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline QRect &operator-=(const QMargins &margins) noexcept; #if QT_DEPRECATED_SINCE(5, 0) - Q_REQUIRED_RESULT QT_DEPRECATED QRect unite(const QRect &r) const Q_DECL_NOTHROW { return united(r); } - Q_REQUIRED_RESULT QT_DEPRECATED QRect intersect(const QRect &r) const Q_DECL_NOTHROW { return intersected(r); } + Q_REQUIRED_RESULT QT_DEPRECATED QRect unite(const QRect &r) const noexcept { return united(r); } + Q_REQUIRED_RESULT QT_DEPRECATED QRect intersect(const QRect &r) const noexcept { return intersected(r); } #endif - friend Q_DECL_CONSTEXPR inline bool operator==(const QRect &, const QRect &) Q_DECL_NOTHROW; - friend Q_DECL_CONSTEXPR inline bool operator!=(const QRect &, const QRect &) Q_DECL_NOTHROW; + friend Q_DECL_CONSTEXPR inline bool operator==(const QRect &, const QRect &) noexcept; + friend Q_DECL_CONSTEXPR inline bool operator!=(const QRect &, const QRect &) noexcept; #if defined(Q_OS_DARWIN) || defined(Q_QDOC) - Q_REQUIRED_RESULT CGRect toCGRect() const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT CGRect toCGRect() const noexcept; #endif private: @@ -165,8 +165,8 @@ private: }; Q_DECLARE_TYPEINFO(QRect, Q_MOVABLE_TYPE); -Q_DECL_CONSTEXPR inline bool operator==(const QRect &, const QRect &) Q_DECL_NOTHROW; -Q_DECL_CONSTEXPR inline bool operator!=(const QRect &, const QRect &) Q_DECL_NOTHROW; +Q_DECL_CONSTEXPR inline bool operator==(const QRect &, const QRect &) noexcept; +Q_DECL_CONSTEXPR inline bool operator!=(const QRect &, const QRect &) noexcept; /***************************************************************************** @@ -181,97 +181,97 @@ Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QRect &); QRect inline member functions *****************************************************************************/ -Q_DECL_CONSTEXPR inline QRect::QRect(int aleft, int atop, int awidth, int aheight) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRect::QRect(int aleft, int atop, int awidth, int aheight) noexcept : x1(aleft), y1(atop), x2(aleft + awidth - 1), y2(atop + aheight - 1) {} -Q_DECL_CONSTEXPR inline QRect::QRect(const QPoint &atopLeft, const QPoint &abottomRight) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRect::QRect(const QPoint &atopLeft, const QPoint &abottomRight) noexcept : x1(atopLeft.x()), y1(atopLeft.y()), x2(abottomRight.x()), y2(abottomRight.y()) {} -Q_DECL_CONSTEXPR inline QRect::QRect(const QPoint &atopLeft, const QSize &asize) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRect::QRect(const QPoint &atopLeft, const QSize &asize) noexcept : x1(atopLeft.x()), y1(atopLeft.y()), x2(atopLeft.x()+asize.width() - 1), y2(atopLeft.y()+asize.height() - 1) {} -Q_DECL_CONSTEXPR inline bool QRect::isNull() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool QRect::isNull() const noexcept { return x2 == x1 - 1 && y2 == y1 - 1; } -Q_DECL_CONSTEXPR inline bool QRect::isEmpty() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool QRect::isEmpty() const noexcept { return x1 > x2 || y1 > y2; } -Q_DECL_CONSTEXPR inline bool QRect::isValid() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool QRect::isValid() const noexcept { return x1 <= x2 && y1 <= y2; } -Q_DECL_CONSTEXPR inline int QRect::left() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int QRect::left() const noexcept { return x1; } -Q_DECL_CONSTEXPR inline int QRect::top() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int QRect::top() const noexcept { return y1; } -Q_DECL_CONSTEXPR inline int QRect::right() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int QRect::right() const noexcept { return x2; } -Q_DECL_CONSTEXPR inline int QRect::bottom() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int QRect::bottom() const noexcept { return y2; } -Q_DECL_CONSTEXPR inline int QRect::x() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int QRect::x() const noexcept { return x1; } -Q_DECL_CONSTEXPR inline int QRect::y() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int QRect::y() const noexcept { return y1; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setLeft(int pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setLeft(int pos) noexcept { x1 = pos; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setTop(int pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setTop(int pos) noexcept { y1 = pos; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setRight(int pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setRight(int pos) noexcept { x2 = pos; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setBottom(int pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setBottom(int pos) noexcept { y2 = pos; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setTopLeft(const QPoint &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setTopLeft(const QPoint &p) noexcept { x1 = p.x(); y1 = p.y(); } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setBottomRight(const QPoint &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setBottomRight(const QPoint &p) noexcept { x2 = p.x(); y2 = p.y(); } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setTopRight(const QPoint &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setTopRight(const QPoint &p) noexcept { x2 = p.x(); y1 = p.y(); } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setBottomLeft(const QPoint &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setBottomLeft(const QPoint &p) noexcept { x1 = p.x(); y2 = p.y(); } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setX(int ax) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setX(int ax) noexcept { x1 = ax; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setY(int ay) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setY(int ay) noexcept { y1 = ay; } -Q_DECL_CONSTEXPR inline QPoint QRect::topLeft() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QPoint QRect::topLeft() const noexcept { return QPoint(x1, y1); } -Q_DECL_CONSTEXPR inline QPoint QRect::bottomRight() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QPoint QRect::bottomRight() const noexcept { return QPoint(x2, y2); } -Q_DECL_CONSTEXPR inline QPoint QRect::topRight() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QPoint QRect::topRight() const noexcept { return QPoint(x2, y1); } -Q_DECL_CONSTEXPR inline QPoint QRect::bottomLeft() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QPoint QRect::bottomLeft() const noexcept { return QPoint(x1, y2); } -Q_DECL_CONSTEXPR inline QPoint QRect::center() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QPoint QRect::center() const noexcept { return QPoint(int((qint64(x1)+x2)/2), int((qint64(y1)+y2)/2)); } // cast avoids overflow on addition -Q_DECL_CONSTEXPR inline int QRect::width() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int QRect::width() const noexcept { return x2 - x1 + 1; } -Q_DECL_CONSTEXPR inline int QRect::height() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int QRect::height() const noexcept { return y2 - y1 + 1; } -Q_DECL_CONSTEXPR inline QSize QRect::size() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QSize QRect::size() const noexcept { return QSize(width(), height()); } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::translate(int dx, int dy) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::translate(int dx, int dy) noexcept { x1 += dx; y1 += dy; @@ -279,7 +279,7 @@ Q_DECL_RELAXED_CONSTEXPR inline void QRect::translate(int dx, int dy) Q_DECL_NOT y2 += dy; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::translate(const QPoint &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::translate(const QPoint &p) noexcept { x1 += p.x(); y1 += p.y(); @@ -287,16 +287,16 @@ Q_DECL_RELAXED_CONSTEXPR inline void QRect::translate(const QPoint &p) Q_DECL_NO y2 += p.y(); } -Q_DECL_CONSTEXPR inline QRect QRect::translated(int dx, int dy) const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRect QRect::translated(int dx, int dy) const noexcept { return QRect(QPoint(x1 + dx, y1 + dy), QPoint(x2 + dx, y2 + dy)); } -Q_DECL_CONSTEXPR inline QRect QRect::translated(const QPoint &p) const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRect QRect::translated(const QPoint &p) const noexcept { return QRect(QPoint(x1 + p.x(), y1 + p.y()), QPoint(x2 + p.x(), y2 + p.y())); } -Q_DECL_CONSTEXPR inline QRect QRect::transposed() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRect QRect::transposed() const noexcept { return QRect(topLeft(), size().transposed()); } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveTo(int ax, int ay) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveTo(int ax, int ay) noexcept { x2 += ax - x1; y2 += ay - y1; @@ -304,7 +304,7 @@ Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveTo(int ax, int ay) Q_DECL_NOTHRO y1 = ay; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveTo(const QPoint &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveTo(const QPoint &p) noexcept { x2 += p.x() - x1; y2 += p.y() - y1; @@ -312,49 +312,49 @@ Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveTo(const QPoint &p) Q_DECL_NOTHR y1 = p.y(); } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveLeft(int pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveLeft(int pos) noexcept { x2 += (pos - x1); x1 = pos; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveTop(int pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveTop(int pos) noexcept { y2 += (pos - y1); y1 = pos; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveRight(int pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveRight(int pos) noexcept { x1 += (pos - x2); x2 = pos; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveBottom(int pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveBottom(int pos) noexcept { y1 += (pos - y2); y2 = pos; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveTopLeft(const QPoint &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveTopLeft(const QPoint &p) noexcept { moveLeft(p.x()); moveTop(p.y()); } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveBottomRight(const QPoint &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveBottomRight(const QPoint &p) noexcept { moveRight(p.x()); moveBottom(p.y()); } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveTopRight(const QPoint &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveTopRight(const QPoint &p) noexcept { moveRight(p.x()); moveTop(p.y()); } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveBottomLeft(const QPoint &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveBottomLeft(const QPoint &p) noexcept { moveLeft(p.x()); moveBottom(p.y()); } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveCenter(const QPoint &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveCenter(const QPoint &p) noexcept { int w = x2 - x1; int h = y2 - y1; @@ -372,7 +372,7 @@ Q_DECL_RELAXED_CONSTEXPR inline void QRect::getRect(int *ax, int *ay, int *aw, i *ah = y2 - y1 + 1; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setRect(int ax, int ay, int aw, int ah) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setRect(int ax, int ay, int aw, int ah) noexcept { x1 = ax; y1 = ay; @@ -388,7 +388,7 @@ Q_DECL_RELAXED_CONSTEXPR inline void QRect::getCoords(int *xp1, int *yp1, int *x *yp2 = y2; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setCoords(int xp1, int yp1, int xp2, int yp2) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setCoords(int xp1, int yp1, int xp2, int yp2) noexcept { x1 = xp1; y1 = yp1; @@ -396,10 +396,10 @@ Q_DECL_RELAXED_CONSTEXPR inline void QRect::setCoords(int xp1, int yp1, int xp2, y2 = yp2; } -Q_DECL_CONSTEXPR inline QRect QRect::adjusted(int xp1, int yp1, int xp2, int yp2) const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRect QRect::adjusted(int xp1, int yp1, int xp2, int yp2) const noexcept { return QRect(QPoint(x1 + xp1, y1 + yp1), QPoint(x2 + xp2, y2 + yp2)); } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::adjust(int dx1, int dy1, int dx2, int dy2) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::adjust(int dx1, int dy1, int dx2, int dy2) noexcept { x1 += dx1; y1 += dy1; @@ -407,97 +407,97 @@ Q_DECL_RELAXED_CONSTEXPR inline void QRect::adjust(int dx1, int dy1, int dx2, in y2 += dy2; } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setWidth(int w) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setWidth(int w) noexcept { x2 = (x1 + w - 1); } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setHeight(int h) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setHeight(int h) noexcept { y2 = (y1 + h - 1); } -Q_DECL_RELAXED_CONSTEXPR inline void QRect::setSize(const QSize &s) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRect::setSize(const QSize &s) noexcept { x2 = (s.width() + x1 - 1); y2 = (s.height() + y1 - 1); } -inline bool QRect::contains(int ax, int ay, bool aproper) const Q_DECL_NOTHROW +inline bool QRect::contains(int ax, int ay, bool aproper) const noexcept { return contains(QPoint(ax, ay), aproper); } -inline bool QRect::contains(int ax, int ay) const Q_DECL_NOTHROW +inline bool QRect::contains(int ax, int ay) const noexcept { return contains(QPoint(ax, ay), false); } -inline QRect& QRect::operator|=(const QRect &r) Q_DECL_NOTHROW +inline QRect& QRect::operator|=(const QRect &r) noexcept { *this = *this | r; return *this; } -inline QRect& QRect::operator&=(const QRect &r) Q_DECL_NOTHROW +inline QRect& QRect::operator&=(const QRect &r) noexcept { *this = *this & r; return *this; } -inline QRect QRect::intersected(const QRect &other) const Q_DECL_NOTHROW +inline QRect QRect::intersected(const QRect &other) const noexcept { return *this & other; } -inline QRect QRect::united(const QRect &r) const Q_DECL_NOTHROW +inline QRect QRect::united(const QRect &r) const noexcept { return *this | r; } -Q_DECL_CONSTEXPR inline bool operator==(const QRect &r1, const QRect &r2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator==(const QRect &r1, const QRect &r2) noexcept { return r1.x1==r2.x1 && r1.x2==r2.x2 && r1.y1==r2.y1 && r1.y2==r2.y2; } -Q_DECL_CONSTEXPR inline bool operator!=(const QRect &r1, const QRect &r2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator!=(const QRect &r1, const QRect &r2) noexcept { return r1.x1!=r2.x1 || r1.x2!=r2.x2 || r1.y1!=r2.y1 || r1.y2!=r2.y2; } -Q_DECL_CONSTEXPR inline QRect operator+(const QRect &rectangle, const QMargins &margins) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRect operator+(const QRect &rectangle, const QMargins &margins) noexcept { return QRect(QPoint(rectangle.left() - margins.left(), rectangle.top() - margins.top()), QPoint(rectangle.right() + margins.right(), rectangle.bottom() + margins.bottom())); } -Q_DECL_CONSTEXPR inline QRect operator+(const QMargins &margins, const QRect &rectangle) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRect operator+(const QMargins &margins, const QRect &rectangle) noexcept { return QRect(QPoint(rectangle.left() - margins.left(), rectangle.top() - margins.top()), QPoint(rectangle.right() + margins.right(), rectangle.bottom() + margins.bottom())); } -Q_DECL_CONSTEXPR inline QRect operator-(const QRect &lhs, const QMargins &rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRect operator-(const QRect &lhs, const QMargins &rhs) noexcept { return QRect(QPoint(lhs.left() + rhs.left(), lhs.top() + rhs.top()), QPoint(lhs.right() - rhs.right(), lhs.bottom() - rhs.bottom())); } -Q_DECL_CONSTEXPR inline QRect QRect::marginsAdded(const QMargins &margins) const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRect QRect::marginsAdded(const QMargins &margins) const noexcept { return QRect(QPoint(x1 - margins.left(), y1 - margins.top()), QPoint(x2 + margins.right(), y2 + margins.bottom())); } -Q_DECL_CONSTEXPR inline QRect QRect::marginsRemoved(const QMargins &margins) const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRect QRect::marginsRemoved(const QMargins &margins) const noexcept { return QRect(QPoint(x1 + margins.left(), y1 + margins.top()), QPoint(x2 - margins.right(), y2 - margins.bottom())); } -Q_DECL_RELAXED_CONSTEXPR inline QRect &QRect::operator+=(const QMargins &margins) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QRect &QRect::operator+=(const QMargins &margins) noexcept { *this = marginsAdded(margins); return *this; } -Q_DECL_RELAXED_CONSTEXPR inline QRect &QRect::operator-=(const QMargins &margins) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QRect &QRect::operator-=(const QMargins &margins) noexcept { *this = marginsRemoved(margins); return *this; @@ -511,110 +511,110 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QRect &); class Q_CORE_EXPORT QRectF { public: - Q_DECL_CONSTEXPR QRectF() Q_DECL_NOTHROW : xp(0.), yp(0.), w(0.), h(0.) {} - Q_DECL_CONSTEXPR QRectF(const QPointF &topleft, const QSizeF &size) Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR QRectF(const QPointF &topleft, const QPointF &bottomRight) Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR QRectF(qreal left, qreal top, qreal width, qreal height) Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR QRectF(const QRect &rect) Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR QRectF() noexcept : xp(0.), yp(0.), w(0.), h(0.) {} + Q_DECL_CONSTEXPR QRectF(const QPointF &topleft, const QSizeF &size) noexcept; + Q_DECL_CONSTEXPR QRectF(const QPointF &topleft, const QPointF &bottomRight) noexcept; + Q_DECL_CONSTEXPR QRectF(qreal left, qreal top, qreal width, qreal height) noexcept; + Q_DECL_CONSTEXPR QRectF(const QRect &rect) noexcept; - Q_DECL_CONSTEXPR inline bool isNull() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline bool isEmpty() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline bool isValid() const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT QRectF normalized() const Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline bool isNull() const noexcept; + Q_DECL_CONSTEXPR inline bool isEmpty() const noexcept; + Q_DECL_CONSTEXPR inline bool isValid() const noexcept; + Q_REQUIRED_RESULT QRectF normalized() const noexcept; - Q_DECL_CONSTEXPR inline qreal left() const Q_DECL_NOTHROW { return xp; } - Q_DECL_CONSTEXPR inline qreal top() const Q_DECL_NOTHROW { return yp; } - Q_DECL_CONSTEXPR inline qreal right() const Q_DECL_NOTHROW { return xp + w; } - Q_DECL_CONSTEXPR inline qreal bottom() const Q_DECL_NOTHROW { return yp + h; } + Q_DECL_CONSTEXPR inline qreal left() const noexcept { return xp; } + Q_DECL_CONSTEXPR inline qreal top() const noexcept { return yp; } + Q_DECL_CONSTEXPR inline qreal right() const noexcept { return xp + w; } + Q_DECL_CONSTEXPR inline qreal bottom() const noexcept { return yp + h; } - Q_DECL_CONSTEXPR inline qreal x() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline qreal y() const Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setLeft(qreal pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setTop(qreal pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setRight(qreal pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setBottom(qreal pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setX(qreal pos) Q_DECL_NOTHROW { setLeft(pos); } - Q_DECL_RELAXED_CONSTEXPR inline void setY(qreal pos) Q_DECL_NOTHROW { setTop(pos); } + Q_DECL_CONSTEXPR inline qreal x() const noexcept; + Q_DECL_CONSTEXPR inline qreal y() const noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setLeft(qreal pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setTop(qreal pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setRight(qreal pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setBottom(qreal pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setX(qreal pos) noexcept { setLeft(pos); } + Q_DECL_RELAXED_CONSTEXPR inline void setY(qreal pos) noexcept { setTop(pos); } - Q_DECL_CONSTEXPR inline QPointF topLeft() const Q_DECL_NOTHROW { return QPointF(xp, yp); } - Q_DECL_CONSTEXPR inline QPointF bottomRight() const Q_DECL_NOTHROW { return QPointF(xp+w, yp+h); } - Q_DECL_CONSTEXPR inline QPointF topRight() const Q_DECL_NOTHROW { return QPointF(xp+w, yp); } - Q_DECL_CONSTEXPR inline QPointF bottomLeft() const Q_DECL_NOTHROW { return QPointF(xp, yp+h); } - Q_DECL_CONSTEXPR inline QPointF center() const Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline QPointF topLeft() const noexcept { return QPointF(xp, yp); } + Q_DECL_CONSTEXPR inline QPointF bottomRight() const noexcept { return QPointF(xp+w, yp+h); } + Q_DECL_CONSTEXPR inline QPointF topRight() const noexcept { return QPointF(xp+w, yp); } + Q_DECL_CONSTEXPR inline QPointF bottomLeft() const noexcept { return QPointF(xp, yp+h); } + Q_DECL_CONSTEXPR inline QPointF center() const noexcept; - Q_DECL_RELAXED_CONSTEXPR inline void setTopLeft(const QPointF &p) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setBottomRight(const QPointF &p) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setTopRight(const QPointF &p) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setBottomLeft(const QPointF &p) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline void setTopLeft(const QPointF &p) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setBottomRight(const QPointF &p) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setTopRight(const QPointF &p) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setBottomLeft(const QPointF &p) noexcept; - Q_DECL_RELAXED_CONSTEXPR inline void moveLeft(qreal pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveTop(qreal pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveRight(qreal pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveBottom(qreal pos) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveTopLeft(const QPointF &p) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveBottomRight(const QPointF &p) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveTopRight(const QPointF &p) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveBottomLeft(const QPointF &p) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveCenter(const QPointF &p) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline void moveLeft(qreal pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveTop(qreal pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveRight(qreal pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveBottom(qreal pos) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveTopLeft(const QPointF &p) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveBottomRight(const QPointF &p) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveTopRight(const QPointF &p) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveBottomLeft(const QPointF &p) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveCenter(const QPointF &p) noexcept; - Q_DECL_RELAXED_CONSTEXPR inline void translate(qreal dx, qreal dy) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void translate(const QPointF &p) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline void translate(qreal dx, qreal dy) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void translate(const QPointF &p) noexcept; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF translated(qreal dx, qreal dy) const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF translated(const QPointF &p) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF translated(qreal dx, qreal dy) const noexcept; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF translated(const QPointF &p) const noexcept; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF transposed() const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF transposed() const noexcept; - Q_DECL_RELAXED_CONSTEXPR inline void moveTo(qreal x, qreal y) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void moveTo(const QPointF &p) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline void moveTo(qreal x, qreal y) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void moveTo(const QPointF &p) noexcept; - Q_DECL_RELAXED_CONSTEXPR inline void setRect(qreal x, qreal y, qreal w, qreal h) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline void setRect(qreal x, qreal y, qreal w, qreal h) noexcept; Q_DECL_RELAXED_CONSTEXPR inline void getRect(qreal *x, qreal *y, qreal *w, qreal *h) const; - Q_DECL_RELAXED_CONSTEXPR inline void setCoords(qreal x1, qreal y1, qreal x2, qreal y2) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline void setCoords(qreal x1, qreal y1, qreal x2, qreal y2) noexcept; Q_DECL_RELAXED_CONSTEXPR inline void getCoords(qreal *x1, qreal *y1, qreal *x2, qreal *y2) const; - Q_DECL_RELAXED_CONSTEXPR inline void adjust(qreal x1, qreal y1, qreal x2, qreal y2) Q_DECL_NOTHROW; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline void adjust(qreal x1, qreal y1, qreal x2, qreal y2) noexcept; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const noexcept; - Q_DECL_CONSTEXPR inline QSizeF size() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline qreal width() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline qreal height() const Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setWidth(qreal w) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setHeight(qreal h) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setSize(const QSizeF &s) Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline QSizeF size() const noexcept; + Q_DECL_CONSTEXPR inline qreal width() const noexcept; + Q_DECL_CONSTEXPR inline qreal height() const noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setWidth(qreal w) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setHeight(qreal h) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setSize(const QSizeF &s) noexcept; - QRectF operator|(const QRectF &r) const Q_DECL_NOTHROW; - QRectF operator&(const QRectF &r) const Q_DECL_NOTHROW; - inline QRectF& operator|=(const QRectF &r) Q_DECL_NOTHROW; - inline QRectF& operator&=(const QRectF &r) Q_DECL_NOTHROW; + QRectF operator|(const QRectF &r) const noexcept; + QRectF operator&(const QRectF &r) const noexcept; + inline QRectF& operator|=(const QRectF &r) noexcept; + inline QRectF& operator&=(const QRectF &r) noexcept; - bool contains(const QRectF &r) const Q_DECL_NOTHROW; - bool contains(const QPointF &p) const Q_DECL_NOTHROW; - inline bool contains(qreal x, qreal y) const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT inline QRectF united(const QRectF &other) const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT inline QRectF intersected(const QRectF &other) const Q_DECL_NOTHROW; - bool intersects(const QRectF &r) const Q_DECL_NOTHROW; + bool contains(const QRectF &r) const noexcept; + bool contains(const QPointF &p) const noexcept; + inline bool contains(qreal x, qreal y) const noexcept; + Q_REQUIRED_RESULT inline QRectF united(const QRectF &other) const noexcept; + Q_REQUIRED_RESULT inline QRectF intersected(const QRectF &other) const noexcept; + bool intersects(const QRectF &r) const noexcept; - Q_DECL_CONSTEXPR inline QRectF marginsAdded(const QMarginsF &margins) const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QRectF marginsRemoved(const QMarginsF &margins) const Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline QRectF &operator+=(const QMarginsF &margins) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline QRectF &operator-=(const QMarginsF &margins) Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline QRectF marginsAdded(const QMarginsF &margins) const noexcept; + Q_DECL_CONSTEXPR inline QRectF marginsRemoved(const QMarginsF &margins) const noexcept; + Q_DECL_RELAXED_CONSTEXPR inline QRectF &operator+=(const QMarginsF &margins) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline QRectF &operator-=(const QMarginsF &margins) noexcept; #if QT_DEPRECATED_SINCE(5, 0) - Q_REQUIRED_RESULT QT_DEPRECATED QRectF unite(const QRectF &r) const Q_DECL_NOTHROW { return united(r); } - Q_REQUIRED_RESULT QT_DEPRECATED QRectF intersect(const QRectF &r) const Q_DECL_NOTHROW { return intersected(r); } + Q_REQUIRED_RESULT QT_DEPRECATED QRectF unite(const QRectF &r) const noexcept { return united(r); } + Q_REQUIRED_RESULT QT_DEPRECATED QRectF intersect(const QRectF &r) const noexcept { return intersected(r); } #endif - friend Q_DECL_CONSTEXPR inline bool operator==(const QRectF &, const QRectF &) Q_DECL_NOTHROW; - friend Q_DECL_CONSTEXPR inline bool operator!=(const QRectF &, const QRectF &) Q_DECL_NOTHROW; + friend Q_DECL_CONSTEXPR inline bool operator==(const QRectF &, const QRectF &) noexcept; + friend Q_DECL_CONSTEXPR inline bool operator!=(const QRectF &, const QRectF &) noexcept; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect toRect() const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT QRect toAlignedRect() const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect toRect() const noexcept; + Q_REQUIRED_RESULT QRect toAlignedRect() const noexcept; #if defined(Q_OS_DARWIN) || defined(Q_QDOC) - Q_REQUIRED_RESULT static QRectF fromCGRect(CGRect rect) Q_DECL_NOTHROW; - Q_REQUIRED_RESULT CGRect toCGRect() const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT static QRectF fromCGRect(CGRect rect) noexcept; + Q_REQUIRED_RESULT CGRect toCGRect() const noexcept; #endif private: @@ -625,8 +625,8 @@ private: }; Q_DECLARE_TYPEINFO(QRectF, Q_MOVABLE_TYPE); -Q_DECL_CONSTEXPR inline bool operator==(const QRectF &, const QRectF &) Q_DECL_NOTHROW; -Q_DECL_CONSTEXPR inline bool operator!=(const QRectF &, const QRectF &) Q_DECL_NOTHROW; +Q_DECL_CONSTEXPR inline bool operator==(const QRectF &, const QRectF &) noexcept; +Q_DECL_CONSTEXPR inline bool operator!=(const QRectF &, const QRectF &) noexcept; /***************************************************************************** @@ -641,23 +641,23 @@ Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QRectF &); QRectF inline member functions *****************************************************************************/ -Q_DECL_CONSTEXPR inline QRectF::QRectF(qreal aleft, qreal atop, qreal awidth, qreal aheight) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRectF::QRectF(qreal aleft, qreal atop, qreal awidth, qreal aheight) noexcept : xp(aleft), yp(atop), w(awidth), h(aheight) { } -Q_DECL_CONSTEXPR inline QRectF::QRectF(const QPointF &atopLeft, const QSizeF &asize) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRectF::QRectF(const QPointF &atopLeft, const QSizeF &asize) noexcept : xp(atopLeft.x()), yp(atopLeft.y()), w(asize.width()), h(asize.height()) { } -Q_DECL_CONSTEXPR inline QRectF::QRectF(const QPointF &atopLeft, const QPointF &abottomRight) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRectF::QRectF(const QPointF &atopLeft, const QPointF &abottomRight) noexcept : xp(atopLeft.x()), yp(atopLeft.y()), w(abottomRight.x() - atopLeft.x()), h(abottomRight.y() - atopLeft.y()) { } -Q_DECL_CONSTEXPR inline QRectF::QRectF(const QRect &r) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRectF::QRectF(const QRect &r) noexcept : xp(r.x()), yp(r.y()), w(r.width()), h(r.height()) { } @@ -666,117 +666,117 @@ QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wfloat-equal") QT_WARNING_DISABLE_GCC("-Wfloat-equal") -Q_DECL_CONSTEXPR inline bool QRectF::isNull() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool QRectF::isNull() const noexcept { return w == 0. && h == 0.; } -Q_DECL_CONSTEXPR inline bool QRectF::isEmpty() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool QRectF::isEmpty() const noexcept { return w <= 0. || h <= 0.; } QT_WARNING_POP -Q_DECL_CONSTEXPR inline bool QRectF::isValid() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool QRectF::isValid() const noexcept { return w > 0. && h > 0.; } -Q_DECL_CONSTEXPR inline qreal QRectF::x() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline qreal QRectF::x() const noexcept { return xp; } -Q_DECL_CONSTEXPR inline qreal QRectF::y() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline qreal QRectF::y() const noexcept { return yp; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setLeft(qreal pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setLeft(qreal pos) noexcept { qreal diff = pos - xp; xp += diff; w -= diff; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setRight(qreal pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setRight(qreal pos) noexcept { w = pos - xp; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setTop(qreal pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setTop(qreal pos) noexcept { qreal diff = pos - yp; yp += diff; h -= diff; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setBottom(qreal pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setBottom(qreal pos) noexcept { h = pos - yp; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setTopLeft(const QPointF &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setTopLeft(const QPointF &p) noexcept { setLeft(p.x()); setTop(p.y()); } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setTopRight(const QPointF &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setTopRight(const QPointF &p) noexcept { setRight(p.x()); setTop(p.y()); } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setBottomLeft(const QPointF &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setBottomLeft(const QPointF &p) noexcept { setLeft(p.x()); setBottom(p.y()); } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setBottomRight(const QPointF &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setBottomRight(const QPointF &p) noexcept { setRight(p.x()); setBottom(p.y()); } -Q_DECL_CONSTEXPR inline QPointF QRectF::center() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QPointF QRectF::center() const noexcept { return QPointF(xp + w/2, yp + h/2); } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveLeft(qreal pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveLeft(qreal pos) noexcept { xp = pos; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveTop(qreal pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveTop(qreal pos) noexcept { yp = pos; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveRight(qreal pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveRight(qreal pos) noexcept { xp = pos - w; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveBottom(qreal pos) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveBottom(qreal pos) noexcept { yp = pos - h; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveTopLeft(const QPointF &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveTopLeft(const QPointF &p) noexcept { moveLeft(p.x()); moveTop(p.y()); } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveTopRight(const QPointF &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveTopRight(const QPointF &p) noexcept { moveRight(p.x()); moveTop(p.y()); } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveBottomLeft(const QPointF &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveBottomLeft(const QPointF &p) noexcept { moveLeft(p.x()); moveBottom(p.y()); } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveBottomRight(const QPointF &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveBottomRight(const QPointF &p) noexcept { moveRight(p.x()); moveBottom(p.y()); } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveCenter(const QPointF &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveCenter(const QPointF &p) noexcept { xp = p.x() - w/2; yp = p.y() - h/2; } -Q_DECL_CONSTEXPR inline qreal QRectF::width() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline qreal QRectF::width() const noexcept { return w; } -Q_DECL_CONSTEXPR inline qreal QRectF::height() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline qreal QRectF::height() const noexcept { return h; } -Q_DECL_CONSTEXPR inline QSizeF QRectF::size() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QSizeF QRectF::size() const noexcept { return QSizeF(w, h); } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::translate(qreal dx, qreal dy) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::translate(qreal dx, qreal dy) noexcept { xp += dx; yp += dy; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::translate(const QPointF &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::translate(const QPointF &p) noexcept { xp += p.x(); yp += p.y(); } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveTo(qreal ax, qreal ay) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveTo(qreal ax, qreal ay) noexcept { xp = ax; yp = ay; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveTo(const QPointF &p) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveTo(const QPointF &p) noexcept { xp = p.x(); yp = p.y(); } -Q_DECL_CONSTEXPR inline QRectF QRectF::translated(qreal dx, qreal dy) const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRectF QRectF::translated(qreal dx, qreal dy) const noexcept { return QRectF(xp + dx, yp + dy, w, h); } -Q_DECL_CONSTEXPR inline QRectF QRectF::translated(const QPointF &p) const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRectF QRectF::translated(const QPointF &p) const noexcept { return QRectF(xp + p.x(), yp + p.y(), w, h); } -Q_DECL_CONSTEXPR inline QRectF QRectF::transposed() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRectF QRectF::transposed() const noexcept { return QRectF(topLeft(), size().transposed()); } Q_DECL_RELAXED_CONSTEXPR inline void QRectF::getRect(qreal *ax, qreal *ay, qreal *aaw, qreal *aah) const @@ -787,7 +787,7 @@ Q_DECL_RELAXED_CONSTEXPR inline void QRectF::getRect(qreal *ax, qreal *ay, qreal *aah = this->h; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setRect(qreal ax, qreal ay, qreal aaw, qreal aah) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setRect(qreal ax, qreal ay, qreal aaw, qreal aah) noexcept { this->xp = ax; this->yp = ay; @@ -803,7 +803,7 @@ Q_DECL_RELAXED_CONSTEXPR inline void QRectF::getCoords(qreal *xp1, qreal *yp1, q *yp2 = yp + h; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setCoords(qreal xp1, qreal yp1, qreal xp2, qreal yp2) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setCoords(qreal xp1, qreal yp1, qreal xp2, qreal yp2) noexcept { xp = xp1; yp = yp1; @@ -811,105 +811,105 @@ Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setCoords(qreal xp1, qreal yp1, qre h = yp2 - yp1; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::adjust(qreal xp1, qreal yp1, qreal xp2, qreal yp2) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::adjust(qreal xp1, qreal yp1, qreal xp2, qreal yp2) noexcept { xp += xp1; yp += yp1; w += xp2 - xp1; h += yp2 - yp1; } -Q_DECL_CONSTEXPR inline QRectF QRectF::adjusted(qreal xp1, qreal yp1, qreal xp2, qreal yp2) const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRectF QRectF::adjusted(qreal xp1, qreal yp1, qreal xp2, qreal yp2) const noexcept { return QRectF(xp + xp1, yp + yp1, w + xp2 - xp1, h + yp2 - yp1); } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setWidth(qreal aw) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setWidth(qreal aw) noexcept { this->w = aw; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setHeight(qreal ah) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setHeight(qreal ah) noexcept { this->h = ah; } -Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setSize(const QSizeF &s) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setSize(const QSizeF &s) noexcept { w = s.width(); h = s.height(); } -inline bool QRectF::contains(qreal ax, qreal ay) const Q_DECL_NOTHROW +inline bool QRectF::contains(qreal ax, qreal ay) const noexcept { return contains(QPointF(ax, ay)); } -inline QRectF& QRectF::operator|=(const QRectF &r) Q_DECL_NOTHROW +inline QRectF& QRectF::operator|=(const QRectF &r) noexcept { *this = *this | r; return *this; } -inline QRectF& QRectF::operator&=(const QRectF &r) Q_DECL_NOTHROW +inline QRectF& QRectF::operator&=(const QRectF &r) noexcept { *this = *this & r; return *this; } -inline QRectF QRectF::intersected(const QRectF &r) const Q_DECL_NOTHROW +inline QRectF QRectF::intersected(const QRectF &r) const noexcept { return *this & r; } -inline QRectF QRectF::united(const QRectF &r) const Q_DECL_NOTHROW +inline QRectF QRectF::united(const QRectF &r) const noexcept { return *this | r; } -Q_DECL_CONSTEXPR inline bool operator==(const QRectF &r1, const QRectF &r2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator==(const QRectF &r1, const QRectF &r2) noexcept { return qFuzzyCompare(r1.xp, r2.xp) && qFuzzyCompare(r1.yp, r2.yp) && qFuzzyCompare(r1.w, r2.w) && qFuzzyCompare(r1.h, r2.h); } -Q_DECL_CONSTEXPR inline bool operator!=(const QRectF &r1, const QRectF &r2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator!=(const QRectF &r1, const QRectF &r2) noexcept { return !qFuzzyCompare(r1.xp, r2.xp) || !qFuzzyCompare(r1.yp, r2.yp) || !qFuzzyCompare(r1.w, r2.w) || !qFuzzyCompare(r1.h, r2.h); } -Q_DECL_CONSTEXPR inline QRect QRectF::toRect() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRect QRectF::toRect() const noexcept { return QRect(QPoint(qRound(xp), qRound(yp)), QPoint(qRound(xp + w) - 1, qRound(yp + h) - 1)); } -Q_DECL_CONSTEXPR inline QRectF operator+(const QRectF &lhs, const QMarginsF &rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRectF operator+(const QRectF &lhs, const QMarginsF &rhs) noexcept { return QRectF(QPointF(lhs.left() - rhs.left(), lhs.top() - rhs.top()), QSizeF(lhs.width() + rhs.left() + rhs.right(), lhs.height() + rhs.top() + rhs.bottom())); } -Q_DECL_CONSTEXPR inline QRectF operator+(const QMarginsF &lhs, const QRectF &rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRectF operator+(const QMarginsF &lhs, const QRectF &rhs) noexcept { return QRectF(QPointF(rhs.left() - lhs.left(), rhs.top() - lhs.top()), QSizeF(rhs.width() + lhs.left() + lhs.right(), rhs.height() + lhs.top() + lhs.bottom())); } -Q_DECL_CONSTEXPR inline QRectF operator-(const QRectF &lhs, const QMarginsF &rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRectF operator-(const QRectF &lhs, const QMarginsF &rhs) noexcept { return QRectF(QPointF(lhs.left() + rhs.left(), lhs.top() + rhs.top()), QSizeF(lhs.width() - rhs.left() - rhs.right(), lhs.height() - rhs.top() - rhs.bottom())); } -Q_DECL_CONSTEXPR inline QRectF QRectF::marginsAdded(const QMarginsF &margins) const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRectF QRectF::marginsAdded(const QMarginsF &margins) const noexcept { return QRectF(QPointF(xp - margins.left(), yp - margins.top()), QSizeF(w + margins.left() + margins.right(), h + margins.top() + margins.bottom())); } -Q_DECL_CONSTEXPR inline QRectF QRectF::marginsRemoved(const QMarginsF &margins) const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QRectF QRectF::marginsRemoved(const QMarginsF &margins) const noexcept { return QRectF(QPointF(xp + margins.left(), yp + margins.top()), QSizeF(w - margins.left() - margins.right(), h - margins.top() - margins.bottom())); } -Q_DECL_RELAXED_CONSTEXPR inline QRectF &QRectF::operator+=(const QMarginsF &margins) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QRectF &QRectF::operator+=(const QMarginsF &margins) noexcept { *this = marginsAdded(margins); return *this; } -Q_DECL_RELAXED_CONSTEXPR inline QRectF &QRectF::operator-=(const QMarginsF &margins) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QRectF &QRectF::operator-=(const QMarginsF &margins) noexcept { *this = marginsRemoved(margins); return *this; diff --git a/src/corelib/tools/qrefcount.h b/src/corelib/tools/qrefcount.h index 9586c3a79a..71adb41f28 100644 --- a/src/corelib/tools/qrefcount.h +++ b/src/corelib/tools/qrefcount.h @@ -51,7 +51,7 @@ namespace QtPrivate class RefCount { public: - inline bool ref() Q_DECL_NOTHROW { + inline bool ref() noexcept { int count = atomic.load(); #if !defined(QT_NO_UNSHARABLE_CONTAINERS) if (count == 0) // !isSharable @@ -62,7 +62,7 @@ public: return true; } - inline bool deref() Q_DECL_NOTHROW { + inline bool deref() noexcept { int count = atomic.load(); #if !defined(QT_NO_UNSHARABLE_CONTAINERS) if (count == 0) // !isSharable @@ -74,7 +74,7 @@ public: } #if !defined(QT_NO_UNSHARABLE_CONTAINERS) - bool setSharable(bool sharable) Q_DECL_NOTHROW + bool setSharable(bool sharable) noexcept { Q_ASSERT(!isShared()); if (sharable) @@ -83,27 +83,27 @@ public: return atomic.testAndSetRelaxed(1, 0); } - bool isSharable() const Q_DECL_NOTHROW + bool isSharable() const noexcept { // Sharable === Shared ownership. return atomic.load() != 0; } #endif - bool isStatic() const Q_DECL_NOTHROW + bool isStatic() const noexcept { // Persistent object, never deleted return atomic.load() == -1; } - bool isShared() const Q_DECL_NOTHROW + bool isShared() const noexcept { int count = atomic.load(); return (count != 1) && (count != 0); } - void initializeOwned() Q_DECL_NOTHROW { atomic.store(1); } - void initializeUnsharable() Q_DECL_NOTHROW { atomic.store(0); } + void initializeOwned() noexcept { atomic.store(1); } + void initializeUnsharable() noexcept { atomic.store(0); } QBasicAtomicInt atomic; }; diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp index 589eb74520..d970843dea 100644 --- a/src/corelib/tools/qregexp.cpp +++ b/src/corelib/tools/qregexp.cpp @@ -890,7 +890,7 @@ static bool operator==(const QRegExpEngineKey &key1, const QRegExpEngineKey &key && key1.cs == key2.cs; } -static uint qHash(const QRegExpEngineKey &key, uint seed = 0) Q_DECL_NOTHROW +static uint qHash(const QRegExpEngineKey &key, uint seed = 0) noexcept { QtPrivate::QHashCombine hash; seed = hash(seed, key.pattern); @@ -4046,7 +4046,7 @@ bool QRegExp::operator==(const QRegExp &rx) const Returns the hash value for \a key, using \a seed to seed the calculation. */ -uint qHash(const QRegExp &key, uint seed) Q_DECL_NOTHROW +uint qHash(const QRegExp &key, uint seed) noexcept { QtPrivate::QHashCombine hash; seed = hash(seed, key.priv->engineKey); diff --git a/src/corelib/tools/qregexp.h b/src/corelib/tools/qregexp.h index b3fa242168..c043a06496 100644 --- a/src/corelib/tools/qregexp.h +++ b/src/corelib/tools/qregexp.h @@ -53,7 +53,7 @@ struct QRegExpPrivate; class QStringList; class QRegExp; -Q_CORE_EXPORT uint qHash(const QRegExp &key, uint seed = 0) Q_DECL_NOTHROW; +Q_CORE_EXPORT uint qHash(const QRegExp &key, uint seed = 0) noexcept; class Q_CORE_EXPORT QRegExp { @@ -74,9 +74,9 @@ public: ~QRegExp(); QRegExp &operator=(const QRegExp &rx); #ifdef Q_COMPILER_RVALUE_REFS - QRegExp &operator=(QRegExp &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QRegExp &operator=(QRegExp &&other) noexcept { swap(other); return *this; } #endif - void swap(QRegExp &other) Q_DECL_NOTHROW { qSwap(priv, other.priv); } + void swap(QRegExp &other) noexcept { qSwap(priv, other.priv); } bool operator==(const QRegExp &rx) const; inline bool operator!=(const QRegExp &rx) const { return !operator==(rx); } @@ -112,7 +112,7 @@ public: static QString escape(const QString &str); - friend Q_CORE_EXPORT uint qHash(const QRegExp &key, uint seed) Q_DECL_NOTHROW; + friend Q_CORE_EXPORT uint qHash(const QRegExp &key, uint seed) noexcept; private: QRegExpPrivate *priv; diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp index bdaa2d3243..ca1a866842 100644 --- a/src/corelib/tools/qregularexpression.cpp +++ b/src/corelib/tools/qregularexpression.cpp @@ -1810,7 +1810,7 @@ bool QRegularExpression::operator==(const QRegularExpression &re) const Returns the hash value for \a key, using \a seed to seed the calculation. */ -uint qHash(const QRegularExpression &key, uint seed) Q_DECL_NOTHROW +uint qHash(const QRegularExpression &key, uint seed) noexcept { QtPrivate::QHashCombine hash; seed = hash(seed, key.d->pattern); diff --git a/src/corelib/tools/qregularexpression.h b/src/corelib/tools/qregularexpression.h index f9e7029550..f16b7e91be 100644 --- a/src/corelib/tools/qregularexpression.h +++ b/src/corelib/tools/qregularexpression.h @@ -59,7 +59,7 @@ class QRegularExpressionMatchIterator; struct QRegularExpressionPrivate; class QRegularExpression; -Q_CORE_EXPORT uint qHash(const QRegularExpression &key, uint seed = 0) Q_DECL_NOTHROW; +Q_CORE_EXPORT uint qHash(const QRegularExpression &key, uint seed = 0) noexcept; class Q_CORE_EXPORT QRegularExpression { @@ -88,11 +88,11 @@ public: QRegularExpression &operator=(const QRegularExpression &re); #ifdef Q_COMPILER_RVALUE_REFS - QRegularExpression &operator=(QRegularExpression &&re) Q_DECL_NOTHROW + QRegularExpression &operator=(QRegularExpression &&re) noexcept { d.swap(re.d); return *this; } #endif - void swap(QRegularExpression &other) Q_DECL_NOTHROW { d.swap(other.d); } + void swap(QRegularExpression &other) noexcept { d.swap(other.d); } QString pattern() const; void setPattern(const QString &pattern); @@ -157,7 +157,7 @@ private: friend class QRegularExpressionMatch; friend struct QRegularExpressionMatchPrivate; friend class QRegularExpressionMatchIterator; - friend Q_CORE_EXPORT uint qHash(const QRegularExpression &key, uint seed) Q_DECL_NOTHROW; + friend Q_CORE_EXPORT uint qHash(const QRegularExpression &key, uint seed) noexcept; QRegularExpression(QRegularExpressionPrivate &dd); QExplicitlySharedDataPointer d; @@ -188,10 +188,10 @@ public: QRegularExpressionMatch &operator=(const QRegularExpressionMatch &match); #ifdef Q_COMPILER_RVALUE_REFS - QRegularExpressionMatch &operator=(QRegularExpressionMatch &&match) Q_DECL_NOTHROW + QRegularExpressionMatch &operator=(QRegularExpressionMatch &&match) noexcept { d.swap(match.d); return *this; } #endif - void swap(QRegularExpressionMatch &other) Q_DECL_NOTHROW { d.swap(other.d); } + void swap(QRegularExpressionMatch &other) noexcept { d.swap(other.d); } QRegularExpression regularExpression() const; QRegularExpression::MatchType matchType() const; @@ -258,10 +258,10 @@ public: QRegularExpressionMatchIterator(const QRegularExpressionMatchIterator &iterator); QRegularExpressionMatchIterator &operator=(const QRegularExpressionMatchIterator &iterator); #ifdef Q_COMPILER_RVALUE_REFS - QRegularExpressionMatchIterator &operator=(QRegularExpressionMatchIterator &&iterator) Q_DECL_NOTHROW + QRegularExpressionMatchIterator &operator=(QRegularExpressionMatchIterator &&iterator) noexcept { d.swap(iterator.d); return *this; } #endif - void swap(QRegularExpressionMatchIterator &other) Q_DECL_NOTHROW { d.swap(other.d); } + void swap(QRegularExpressionMatchIterator &other) noexcept { d.swap(other.d); } bool isValid() const; diff --git a/src/corelib/tools/qringbuffer_p.h b/src/corelib/tools/qringbuffer_p.h index 76ab4a5b62..838cb31697 100644 --- a/src/corelib/tools/qringbuffer_p.h +++ b/src/corelib/tools/qringbuffer_p.h @@ -65,11 +65,11 @@ class QRingChunk { public: // initialization and cleanup - inline QRingChunk() Q_DECL_NOTHROW : + inline QRingChunk() noexcept : headOffset(0), tailOffset(0) { } - inline QRingChunk(const QRingChunk &other) Q_DECL_NOTHROW : + inline QRingChunk(const QRingChunk &other) noexcept : chunk(other.chunk), headOffset(other.headOffset), tailOffset(other.tailOffset) { } @@ -77,30 +77,30 @@ public: chunk(alloc, Qt::Uninitialized), headOffset(0), tailOffset(0) { } - explicit inline QRingChunk(const QByteArray &qba) Q_DECL_NOTHROW : + explicit inline QRingChunk(const QByteArray &qba) noexcept : chunk(qba), headOffset(0), tailOffset(qba.size()) { } - inline QRingChunk &operator=(const QRingChunk &other) Q_DECL_NOTHROW + inline QRingChunk &operator=(const QRingChunk &other) noexcept { chunk = other.chunk; headOffset = other.headOffset; tailOffset = other.tailOffset; return *this; } - inline QRingChunk(QRingChunk &&other) Q_DECL_NOTHROW : + inline QRingChunk(QRingChunk &&other) noexcept : chunk(other.chunk), headOffset(other.headOffset), tailOffset(other.tailOffset) { other.headOffset = other.tailOffset = 0; } - inline QRingChunk &operator=(QRingChunk &&other) Q_DECL_NOTHROW + inline QRingChunk &operator=(QRingChunk &&other) noexcept { swap(other); return *this; } - inline void swap(QRingChunk &other) Q_DECL_NOTHROW + inline void swap(QRingChunk &other) noexcept { chunk.swap(other.chunk); qSwap(headOffset, other.headOffset); diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h index 2a4083466b..756e0aec79 100644 --- a/src/corelib/tools/qscopedpointer.h +++ b/src/corelib/tools/qscopedpointer.h @@ -97,7 +97,7 @@ class QScopedPointer { typedef T *QScopedPointer:: *RestrictedBool; public: - explicit QScopedPointer(T *p = nullptr) Q_DECL_NOTHROW : d(p) + explicit QScopedPointer(T *p = nullptr) noexcept : d(p) { } @@ -113,12 +113,12 @@ public: return *d; } - T *operator->() const Q_DECL_NOTHROW + T *operator->() const noexcept { return d; } - bool operator!() const Q_DECL_NOTHROW + bool operator!() const noexcept { return !d; } @@ -129,23 +129,23 @@ public: return isNull() ? nullptr : &QScopedPointer::d; } #else - operator RestrictedBool() const Q_DECL_NOTHROW + operator RestrictedBool() const noexcept { return isNull() ? nullptr : &QScopedPointer::d; } #endif - T *data() const Q_DECL_NOTHROW + T *data() const noexcept { return d; } - T *get() const Q_DECL_NOTHROW + T *get() const noexcept { return d; } - bool isNull() const Q_DECL_NOTHROW + bool isNull() const noexcept { return !d; } @@ -159,14 +159,14 @@ public: Cleanup::cleanup(oldD); } - T *take() Q_DECL_NOTHROW + T *take() noexcept { T *oldD = d; d = nullptr; return oldD; } - void swap(QScopedPointer &other) Q_DECL_NOTHROW + void swap(QScopedPointer &other) noexcept { qSwap(d, other.d); } @@ -181,43 +181,43 @@ private: }; template -inline bool operator==(const QScopedPointer &lhs, const QScopedPointer &rhs) Q_DECL_NOTHROW +inline bool operator==(const QScopedPointer &lhs, const QScopedPointer &rhs) noexcept { return lhs.data() == rhs.data(); } template -inline bool operator!=(const QScopedPointer &lhs, const QScopedPointer &rhs) Q_DECL_NOTHROW +inline bool operator!=(const QScopedPointer &lhs, const QScopedPointer &rhs) noexcept { return lhs.data() != rhs.data(); } template -inline bool operator==(const QScopedPointer &lhs, std::nullptr_t) Q_DECL_NOTHROW +inline bool operator==(const QScopedPointer &lhs, std::nullptr_t) noexcept { return lhs.isNull(); } template -inline bool operator==(std::nullptr_t, const QScopedPointer &rhs) Q_DECL_NOTHROW +inline bool operator==(std::nullptr_t, const QScopedPointer &rhs) noexcept { return rhs.isNull(); } template -inline bool operator!=(const QScopedPointer &lhs, std::nullptr_t) Q_DECL_NOTHROW +inline bool operator!=(const QScopedPointer &lhs, std::nullptr_t) noexcept { return !lhs.isNull(); } template -inline bool operator!=(std::nullptr_t, const QScopedPointer &rhs) Q_DECL_NOTHROW +inline bool operator!=(std::nullptr_t, const QScopedPointer &rhs) noexcept { return !rhs.isNull(); } template -inline void swap(QScopedPointer &p1, QScopedPointer &p2) Q_DECL_NOTHROW +inline void swap(QScopedPointer &p1, QScopedPointer &p2) noexcept { p1.swap(p2); } template > @@ -244,7 +244,7 @@ public: return this->d[i]; } - void swap(QScopedArrayPointer &other) Q_DECL_NOTHROW // prevent QScopedPointer <->QScopedArrayPointer swaps + void swap(QScopedArrayPointer &other) noexcept // prevent QScopedPointer <->QScopedArrayPointer swaps { QScopedPointer::swap(other); } private: @@ -263,7 +263,7 @@ private: }; template -inline void swap(QScopedArrayPointer &lhs, QScopedArrayPointer &rhs) Q_DECL_NOTHROW +inline void swap(QScopedArrayPointer &lhs, QScopedArrayPointer &rhs) noexcept { lhs.swap(rhs); } QT_END_NAMESPACE diff --git a/src/corelib/tools/qscopeguard.h b/src/corelib/tools/qscopeguard.h index 0f61996eb6..41d0a6af68 100644 --- a/src/corelib/tools/qscopeguard.h +++ b/src/corelib/tools/qscopeguard.h @@ -58,7 +58,7 @@ Q_REQUIRED_RESULT QScopeGuard { public: - QScopeGuard(QScopeGuard &&other) Q_DECL_NOEXCEPT + QScopeGuard(QScopeGuard &&other) noexcept : m_func(std::move(other.m_func)) , m_invoke(other.m_invoke) { @@ -71,13 +71,13 @@ public: m_func(); } - void dismiss() Q_DECL_NOEXCEPT + void dismiss() noexcept { m_invoke = false; } private: - explicit QScopeGuard(F f) Q_DECL_NOEXCEPT + explicit QScopeGuard(F f) noexcept : m_func(std::move(f)) { } diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h index 6640c8486d..d7fbc12b99 100644 --- a/src/corelib/tools/qset.h +++ b/src/corelib/tools/qset.h @@ -56,7 +56,7 @@ class QSet typedef QHash Hash; public: - inline QSet() Q_DECL_NOTHROW {} + inline QSet() noexcept {} #ifdef Q_COMPILER_INITIALIZER_LISTS inline QSet(std::initializer_list list) { @@ -68,7 +68,7 @@ public: // compiler-generated copy/move ctor/assignment operators are fine! // compiler-generated destructor is fine! - inline void swap(QSet &other) Q_DECL_NOTHROW { q_hash.swap(other.q_hash); } + inline void swap(QSet &other) noexcept { q_hash.swap(other.q_hash); } inline bool operator==(const QSet &other) const { return q_hash == other.q_hash; } @@ -176,20 +176,20 @@ public: typedef std::reverse_iterator const_reverse_iterator; inline iterator begin() { return q_hash.begin(); } - inline const_iterator begin() const Q_DECL_NOTHROW { return q_hash.begin(); } - inline const_iterator cbegin() const Q_DECL_NOTHROW { return q_hash.begin(); } - inline const_iterator constBegin() const Q_DECL_NOTHROW { return q_hash.constBegin(); } + inline const_iterator begin() const noexcept { return q_hash.begin(); } + inline const_iterator cbegin() const noexcept { return q_hash.begin(); } + inline const_iterator constBegin() const noexcept { return q_hash.constBegin(); } inline iterator end() { return q_hash.end(); } - inline const_iterator end() const Q_DECL_NOTHROW { return q_hash.end(); } - inline const_iterator cend() const Q_DECL_NOTHROW { return q_hash.end(); } - inline const_iterator constEnd() const Q_DECL_NOTHROW { return q_hash.constEnd(); } + inline const_iterator end() const noexcept { return q_hash.end(); } + inline const_iterator cend() const noexcept { return q_hash.end(); } + inline const_iterator constEnd() const noexcept { return q_hash.constEnd(); } reverse_iterator rbegin() { return reverse_iterator(end()); } reverse_iterator rend() { return reverse_iterator(begin()); } - const_reverse_iterator rbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); } - const_reverse_iterator rend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); } - const_reverse_iterator crbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); } - const_reverse_iterator crend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); } + const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } + const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } + const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } + const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } iterator erase(iterator i) { return erase(m2c(i)); } @@ -252,14 +252,14 @@ public: private: Hash q_hash; - static const_iterator m2c(iterator it) Q_DECL_NOTHROW + static const_iterator m2c(iterator it) noexcept { return const_iterator(typename Hash::const_iterator(it.i.i)); } bool isValidIterator(const iterator &i) const { return q_hash.isValidIterator(reinterpret_cast(i)); } - bool isValidIterator(const const_iterator &i) const Q_DECL_NOTHROW + bool isValidIterator(const const_iterator &i) const noexcept { return q_hash.isValidIterator(reinterpret_cast(i)); } diff --git a/src/corelib/tools/qshareddata.h b/src/corelib/tools/qshareddata.h index 6930cb96a5..cbaa1aa3c4 100644 --- a/src/corelib/tools/qshareddata.h +++ b/src/corelib/tools/qshareddata.h @@ -88,7 +88,7 @@ public: inline QSharedDataPointer() { d = nullptr; } inline ~QSharedDataPointer() { if (d && !d->ref.deref()) delete d; } - explicit QSharedDataPointer(T *data) Q_DECL_NOTHROW; + explicit QSharedDataPointer(T *data) noexcept; inline QSharedDataPointer(const QSharedDataPointer &o) : d(o.d) { if (d) d->ref.ref(); } inline QSharedDataPointer & operator=(const QSharedDataPointer &o) { if (o.d != d) { @@ -113,8 +113,8 @@ public: return *this; } #ifdef Q_COMPILER_RVALUE_REFS - QSharedDataPointer(QSharedDataPointer &&o) Q_DECL_NOTHROW : d(o.d) { o.d = nullptr; } - inline QSharedDataPointer &operator=(QSharedDataPointer &&other) Q_DECL_NOTHROW + QSharedDataPointer(QSharedDataPointer &&o) noexcept : d(o.d) { o.d = nullptr; } + inline QSharedDataPointer &operator=(QSharedDataPointer &&other) noexcept { QSharedDataPointer moved(std::move(other)); swap(moved); @@ -124,7 +124,7 @@ public: inline bool operator!() const { return !d; } - inline void swap(QSharedDataPointer &other) Q_DECL_NOTHROW + inline void swap(QSharedDataPointer &other) noexcept { qSwap(d, other.d); } protected: @@ -181,7 +181,7 @@ public: inline QExplicitlySharedDataPointer() { d = nullptr; } inline ~QExplicitlySharedDataPointer() { if (d && !d->ref.deref()) delete d; } - explicit QExplicitlySharedDataPointer(T *data) Q_DECL_NOTHROW; + explicit QExplicitlySharedDataPointer(T *data) noexcept; inline QExplicitlySharedDataPointer(const QExplicitlySharedDataPointer &o) : d(o.d) { if (d) d->ref.ref(); } template @@ -219,8 +219,8 @@ public: return *this; } #ifdef Q_COMPILER_RVALUE_REFS - inline QExplicitlySharedDataPointer(QExplicitlySharedDataPointer &&o) Q_DECL_NOTHROW : d(o.d) { o.d = nullptr; } - inline QExplicitlySharedDataPointer &operator=(QExplicitlySharedDataPointer &&other) Q_DECL_NOTHROW + inline QExplicitlySharedDataPointer(QExplicitlySharedDataPointer &&o) noexcept : d(o.d) { o.d = nullptr; } + inline QExplicitlySharedDataPointer &operator=(QExplicitlySharedDataPointer &&other) noexcept { QExplicitlySharedDataPointer moved(std::move(other)); swap(moved); @@ -230,7 +230,7 @@ public: inline bool operator!() const { return !d; } - inline void swap(QExplicitlySharedDataPointer &other) Q_DECL_NOTHROW + inline void swap(QExplicitlySharedDataPointer &other) noexcept { qSwap(d, other.d); } protected: @@ -243,7 +243,7 @@ private: }; template -Q_INLINE_TEMPLATE QSharedDataPointer::QSharedDataPointer(T *adata) Q_DECL_NOTHROW +Q_INLINE_TEMPLATE QSharedDataPointer::QSharedDataPointer(T *adata) noexcept : d(adata) { if (d) d->ref.ref(); } @@ -280,7 +280,7 @@ Q_OUTOFLINE_TEMPLATE void QExplicitlySharedDataPointer::detach_helper() } template -Q_INLINE_TEMPLATE QExplicitlySharedDataPointer::QExplicitlySharedDataPointer(T *adata) Q_DECL_NOTHROW +Q_INLINE_TEMPLATE QExplicitlySharedDataPointer::QExplicitlySharedDataPointer(T *adata) noexcept : d(adata) { if (d) d->ref.ref(); } @@ -317,12 +317,12 @@ namespace std { QT_BEGIN_NAMESPACE template -Q_INLINE_TEMPLATE uint qHash(const QSharedDataPointer &ptr, uint seed = 0) Q_DECL_NOTHROW +Q_INLINE_TEMPLATE uint qHash(const QSharedDataPointer &ptr, uint seed = 0) noexcept { return qHash(ptr.data(), seed); } template -Q_INLINE_TEMPLATE uint qHash(const QExplicitlySharedDataPointer &ptr, uint seed = 0) Q_DECL_NOTHROW +Q_INLINE_TEMPLATE uint qHash(const QExplicitlySharedDataPointer &ptr, uint seed = 0) noexcept { return qHash(ptr.data(), seed); } diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index bccf8c5740..81d8dcd839 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -303,18 +303,18 @@ public: typedef const value_type &const_reference; typedef qptrdiff difference_type; - T *data() const Q_DECL_NOTHROW { return value; } - T *get() const Q_DECL_NOTHROW { return value; } - bool isNull() const Q_DECL_NOTHROW { return !data(); } - operator RestrictedBool() const Q_DECL_NOTHROW { return isNull() ? nullptr : &QSharedPointer::value; } - bool operator !() const Q_DECL_NOTHROW { return isNull(); } + T *data() const noexcept { return value; } + T *get() const noexcept { return value; } + bool isNull() const noexcept { return !data(); } + operator RestrictedBool() const noexcept { return isNull() ? nullptr : &QSharedPointer::value; } + bool operator !() const noexcept { return isNull(); } T &operator*() const { return *data(); } - T *operator->() const Q_DECL_NOTHROW { return data(); } + T *operator->() const noexcept { return data(); } - Q_DECL_CONSTEXPR QSharedPointer() Q_DECL_NOTHROW : value(nullptr), d(nullptr) { } + Q_DECL_CONSTEXPR QSharedPointer() noexcept : value(nullptr), d(nullptr) { } ~QSharedPointer() { deref(); } - Q_DECL_CONSTEXPR QSharedPointer(std::nullptr_t) Q_DECL_NOTHROW : value(nullptr), d(nullptr) { } + Q_DECL_CONSTEXPR QSharedPointer(std::nullptr_t) noexcept : value(nullptr), d(nullptr) { } template inline explicit QSharedPointer(X *ptr) : value(ptr) // noexcept @@ -327,22 +327,22 @@ public: template QSharedPointer(std::nullptr_t, Deleter) : value(nullptr), d(nullptr) { } - QSharedPointer(const QSharedPointer &other) Q_DECL_NOTHROW : value(other.value), d(other.d) + QSharedPointer(const QSharedPointer &other) noexcept : value(other.value), d(other.d) { if (d) ref(); } - QSharedPointer &operator=(const QSharedPointer &other) Q_DECL_NOTHROW + QSharedPointer &operator=(const QSharedPointer &other) noexcept { QSharedPointer copy(other); swap(copy); return *this; } #ifdef Q_COMPILER_RVALUE_REFS - QSharedPointer(QSharedPointer &&other) Q_DECL_NOTHROW + QSharedPointer(QSharedPointer &&other) noexcept : value(other.value), d(other.d) { other.d = nullptr; other.value = nullptr; } - QSharedPointer &operator=(QSharedPointer &&other) Q_DECL_NOTHROW + QSharedPointer &operator=(QSharedPointer &&other) noexcept { QSharedPointer moved(std::move(other)); swap(moved); @@ -350,7 +350,7 @@ public: } template - QSharedPointer(QSharedPointer &&other) Q_DECL_NOTHROW + QSharedPointer(QSharedPointer &&other) noexcept : value(other.value), d(other.d) { other.d = nullptr; @@ -358,7 +358,7 @@ public: } template - QSharedPointer &operator=(QSharedPointer &&other) Q_DECL_NOTHROW + QSharedPointer &operator=(QSharedPointer &&other) noexcept { QSharedPointer moved(std::move(other)); swap(moved); @@ -368,7 +368,7 @@ public: #endif template - QSharedPointer(const QSharedPointer &other) Q_DECL_NOTHROW : value(other.value), d(other.d) + QSharedPointer(const QSharedPointer &other) noexcept : value(other.value), d(other.d) { if (d) ref(); } template @@ -456,9 +456,9 @@ public: private: explicit QSharedPointer(Qt::Initialization) {} - void deref() Q_DECL_NOTHROW + void deref() noexcept { deref(d); } - static void deref(Data *dd) Q_DECL_NOTHROW + static void deref(Data *dd) noexcept { if (!dd) return; if (!dd->strongref.deref()) { @@ -499,7 +499,7 @@ private: enableSharedFromThis(ptr); } - void internalSwap(QSharedPointer &other) Q_DECL_NOTHROW + void internalSwap(QSharedPointer &other) noexcept { qSwap(d, other.d); qSwap(this->value, other.value); @@ -512,7 +512,7 @@ public: template friend class QWeakPointer; template friend QSharedPointer QtSharedPointer::copyAndSetPointer(X * ptr, const QSharedPointer &src); #endif - void ref() const Q_DECL_NOTHROW { d->weakref.ref(); d->strongref.ref(); } + void ref() const noexcept { d->weakref.ref(); d->strongref.ref(); } inline void internalSet(Data *o, T *actual) { @@ -563,12 +563,12 @@ public: typedef const value_type &const_reference; typedef qptrdiff difference_type; - bool isNull() const Q_DECL_NOTHROW { return d == nullptr || d->strongref.load() == 0 || value == nullptr; } - operator RestrictedBool() const Q_DECL_NOTHROW { return isNull() ? nullptr : &QWeakPointer::value; } - bool operator !() const Q_DECL_NOTHROW { return isNull(); } - T *data() const Q_DECL_NOTHROW { return d == nullptr || d->strongref.load() == 0 ? nullptr : value; } + bool isNull() const noexcept { return d == nullptr || d->strongref.load() == 0 || value == nullptr; } + operator RestrictedBool() const noexcept { return isNull() ? nullptr : &QWeakPointer::value; } + bool operator !() const noexcept { return isNull(); } + T *data() const noexcept { return d == nullptr || d->strongref.load() == 0 ? nullptr : value; } - inline QWeakPointer() Q_DECL_NOTHROW : d(nullptr), value(nullptr) { } + inline QWeakPointer() noexcept : d(nullptr), value(nullptr) { } inline ~QWeakPointer() { if (d && !d->weakref.deref()) delete d; } #ifndef QT_NO_QOBJECT @@ -586,26 +586,26 @@ public: { return *this = QWeakPointer(ptr); } #endif - QWeakPointer(const QWeakPointer &other) Q_DECL_NOTHROW : d(other.d), value(other.value) + QWeakPointer(const QWeakPointer &other) noexcept : d(other.d), value(other.value) { if (d) d->weakref.ref(); } #ifdef Q_COMPILER_RVALUE_REFS - QWeakPointer(QWeakPointer &&other) Q_DECL_NOTHROW + QWeakPointer(QWeakPointer &&other) noexcept : d(other.d), value(other.value) { other.d = nullptr; other.value = nullptr; } - QWeakPointer &operator=(QWeakPointer &&other) Q_DECL_NOTHROW + QWeakPointer &operator=(QWeakPointer &&other) noexcept { QWeakPointer moved(std::move(other)); swap(moved); return *this; } #endif - QWeakPointer &operator=(const QWeakPointer &other) Q_DECL_NOTHROW + QWeakPointer &operator=(const QWeakPointer &other) noexcept { QWeakPointer copy(other); swap(copy); return *this; } - void swap(QWeakPointer &other) Q_DECL_NOTHROW + void swap(QWeakPointer &other) noexcept { qSwap(this->d, other.d); qSwap(this->value, other.value); @@ -633,11 +633,11 @@ public: } template - bool operator==(const QWeakPointer &o) const Q_DECL_NOTHROW + bool operator==(const QWeakPointer &o) const noexcept { return d == o.d && value == static_cast(o.value); } template - bool operator!=(const QWeakPointer &o) const Q_DECL_NOTHROW + bool operator!=(const QWeakPointer &o) const noexcept { return !(*this == o); } template @@ -653,11 +653,11 @@ public: } template - bool operator==(const QSharedPointer &o) const Q_DECL_NOTHROW + bool operator==(const QSharedPointer &o) const noexcept { return d == o.d; } template - bool operator!=(const QSharedPointer &o) const Q_DECL_NOTHROW + bool operator!=(const QSharedPointer &o) const noexcept { return !(*this == o); } inline void clear() { *this = QWeakPointer(); } @@ -739,92 +739,92 @@ public: // operator== and operator!= // template -bool operator==(const QSharedPointer &ptr1, const QSharedPointer &ptr2) Q_DECL_NOTHROW +bool operator==(const QSharedPointer &ptr1, const QSharedPointer &ptr2) noexcept { return ptr1.data() == ptr2.data(); } template -bool operator!=(const QSharedPointer &ptr1, const QSharedPointer &ptr2) Q_DECL_NOTHROW +bool operator!=(const QSharedPointer &ptr1, const QSharedPointer &ptr2) noexcept { return ptr1.data() != ptr2.data(); } template -bool operator==(const QSharedPointer &ptr1, const X *ptr2) Q_DECL_NOTHROW +bool operator==(const QSharedPointer &ptr1, const X *ptr2) noexcept { return ptr1.data() == ptr2; } template -bool operator==(const T *ptr1, const QSharedPointer &ptr2) Q_DECL_NOTHROW +bool operator==(const T *ptr1, const QSharedPointer &ptr2) noexcept { return ptr1 == ptr2.data(); } template -bool operator!=(const QSharedPointer &ptr1, const X *ptr2) Q_DECL_NOTHROW +bool operator!=(const QSharedPointer &ptr1, const X *ptr2) noexcept { return !(ptr1 == ptr2); } template -bool operator!=(const T *ptr1, const QSharedPointer &ptr2) Q_DECL_NOTHROW +bool operator!=(const T *ptr1, const QSharedPointer &ptr2) noexcept { return !(ptr2 == ptr1); } template -bool operator==(const QSharedPointer &ptr1, const QWeakPointer &ptr2) Q_DECL_NOTHROW +bool operator==(const QSharedPointer &ptr1, const QWeakPointer &ptr2) noexcept { return ptr2 == ptr1; } template -bool operator!=(const QSharedPointer &ptr1, const QWeakPointer &ptr2) Q_DECL_NOTHROW +bool operator!=(const QSharedPointer &ptr1, const QWeakPointer &ptr2) noexcept { return ptr2 != ptr1; } template -inline bool operator==(const QSharedPointer &lhs, std::nullptr_t) Q_DECL_NOTHROW +inline bool operator==(const QSharedPointer &lhs, std::nullptr_t) noexcept { return lhs.isNull(); } template -inline bool operator!=(const QSharedPointer &lhs, std::nullptr_t) Q_DECL_NOTHROW +inline bool operator!=(const QSharedPointer &lhs, std::nullptr_t) noexcept { return !lhs.isNull(); } template -inline bool operator==(std::nullptr_t, const QSharedPointer &rhs) Q_DECL_NOTHROW +inline bool operator==(std::nullptr_t, const QSharedPointer &rhs) noexcept { return rhs.isNull(); } template -inline bool operator!=(std::nullptr_t, const QSharedPointer &rhs) Q_DECL_NOTHROW +inline bool operator!=(std::nullptr_t, const QSharedPointer &rhs) noexcept { return !rhs.isNull(); } template -inline bool operator==(const QWeakPointer &lhs, std::nullptr_t) Q_DECL_NOTHROW +inline bool operator==(const QWeakPointer &lhs, std::nullptr_t) noexcept { return lhs.isNull(); } template -inline bool operator!=(const QWeakPointer &lhs, std::nullptr_t) Q_DECL_NOTHROW +inline bool operator!=(const QWeakPointer &lhs, std::nullptr_t) noexcept { return !lhs.isNull(); } template -inline bool operator==(std::nullptr_t, const QWeakPointer &rhs) Q_DECL_NOTHROW +inline bool operator==(std::nullptr_t, const QWeakPointer &rhs) noexcept { return rhs.isNull(); } template -inline bool operator!=(std::nullptr_t, const QWeakPointer &rhs) Q_DECL_NOTHROW +inline bool operator!=(std::nullptr_t, const QWeakPointer &rhs) noexcept { return !rhs.isNull(); } diff --git a/src/corelib/tools/qsize.cpp b/src/corelib/tools/qsize.cpp index 3e97947ad2..fe508ad459 100644 --- a/src/corelib/tools/qsize.cpp +++ b/src/corelib/tools/qsize.cpp @@ -163,7 +163,7 @@ QT_BEGIN_NAMESPACE \sa setWidth(), setHeight(), transposed() */ -void QSize::transpose() Q_DECL_NOTHROW +void QSize::transpose() noexcept { qSwap(wd, ht); } @@ -222,7 +222,7 @@ void QSize::transpose() Q_DECL_NOTHROW Return a size scaled to a rectangle with the given size \a s, according to the specified \a mode. */ -QSize QSize::scaled(const QSize &s, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW +QSize QSize::scaled(const QSize &s, Qt::AspectRatioMode mode) const noexcept { if (mode == Qt::IgnoreAspectRatio || wd == 0 || ht == 0) { return s; @@ -594,7 +594,7 @@ QDebug operator<<(QDebug dbg, const QSize &s) \sa setWidth(), setHeight(), transposed() */ -void QSizeF::transpose() Q_DECL_NOTHROW +void QSizeF::transpose() noexcept { qSwap(wd, ht); } @@ -653,7 +653,7 @@ void QSizeF::transpose() Q_DECL_NOTHROW Returns a size scaled to a rectangle with the given size \a s, according to the specified \a mode. */ -QSizeF QSizeF::scaled(const QSizeF &s, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW +QSizeF QSizeF::scaled(const QSizeF &s, Qt::AspectRatioMode mode) const noexcept { if (mode == Qt::IgnoreAspectRatio || qIsNull(wd) || qIsNull(ht)) { return s; diff --git a/src/corelib/tools/qsize.h b/src/corelib/tools/qsize.h index bb29dca7c4..4114609856 100644 --- a/src/corelib/tools/qsize.h +++ b/src/corelib/tools/qsize.h @@ -52,46 +52,46 @@ QT_BEGIN_NAMESPACE class Q_CORE_EXPORT QSize { public: - Q_DECL_CONSTEXPR QSize() Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR QSize(int w, int h) Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR QSize() noexcept; + Q_DECL_CONSTEXPR QSize(int w, int h) noexcept; - Q_DECL_CONSTEXPR inline bool isNull() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline bool isEmpty() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline bool isValid() const Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline bool isNull() const noexcept; + Q_DECL_CONSTEXPR inline bool isEmpty() const noexcept; + Q_DECL_CONSTEXPR inline bool isValid() const noexcept; - Q_DECL_CONSTEXPR inline int width() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline int height() const Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setWidth(int w) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setHeight(int h) Q_DECL_NOTHROW; - void transpose() Q_DECL_NOTHROW; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSize transposed() const Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline int width() const noexcept; + Q_DECL_CONSTEXPR inline int height() const noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setWidth(int w) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setHeight(int h) noexcept; + void transpose() noexcept; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSize transposed() const noexcept; - inline void scale(int w, int h, Qt::AspectRatioMode mode) Q_DECL_NOTHROW; - inline void scale(const QSize &s, Qt::AspectRatioMode mode) Q_DECL_NOTHROW; - Q_REQUIRED_RESULT QSize scaled(int w, int h, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT QSize scaled(const QSize &s, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW; + inline void scale(int w, int h, Qt::AspectRatioMode mode) noexcept; + inline void scale(const QSize &s, Qt::AspectRatioMode mode) noexcept; + Q_REQUIRED_RESULT QSize scaled(int w, int h, Qt::AspectRatioMode mode) const noexcept; + Q_REQUIRED_RESULT QSize scaled(const QSize &s, Qt::AspectRatioMode mode) const noexcept; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSize expandedTo(const QSize &) const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSize boundedTo(const QSize &) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSize expandedTo(const QSize &) const noexcept; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSize boundedTo(const QSize &) const noexcept; - Q_DECL_RELAXED_CONSTEXPR inline int &rwidth() Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline int &rheight() Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline int &rwidth() noexcept; + Q_DECL_RELAXED_CONSTEXPR inline int &rheight() noexcept; - Q_DECL_RELAXED_CONSTEXPR inline QSize &operator+=(const QSize &) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline QSize &operator-=(const QSize &) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline QSize &operator*=(qreal c) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline QSize &operator+=(const QSize &) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline QSize &operator-=(const QSize &) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline QSize &operator*=(qreal c) noexcept; inline QSize &operator/=(qreal c); - friend inline Q_DECL_CONSTEXPR bool operator==(const QSize &, const QSize &) Q_DECL_NOTHROW; - friend inline Q_DECL_CONSTEXPR bool operator!=(const QSize &, const QSize &) Q_DECL_NOTHROW; - friend inline Q_DECL_CONSTEXPR const QSize operator+(const QSize &, const QSize &) Q_DECL_NOTHROW; - friend inline Q_DECL_CONSTEXPR const QSize operator-(const QSize &, const QSize &) Q_DECL_NOTHROW; - friend inline Q_DECL_CONSTEXPR const QSize operator*(const QSize &, qreal) Q_DECL_NOTHROW; - friend inline Q_DECL_CONSTEXPR const QSize operator*(qreal, const QSize &) Q_DECL_NOTHROW; + friend inline Q_DECL_CONSTEXPR bool operator==(const QSize &, const QSize &) noexcept; + friend inline Q_DECL_CONSTEXPR bool operator!=(const QSize &, const QSize &) noexcept; + friend inline Q_DECL_CONSTEXPR const QSize operator+(const QSize &, const QSize &) noexcept; + friend inline Q_DECL_CONSTEXPR const QSize operator-(const QSize &, const QSize &) noexcept; + friend inline Q_DECL_CONSTEXPR const QSize operator*(const QSize &, qreal) noexcept; + friend inline Q_DECL_CONSTEXPR const QSize operator*(qreal, const QSize &) noexcept; friend inline const QSize operator/(const QSize &, qreal); #if defined(Q_OS_DARWIN) || defined(Q_QDOC) - Q_REQUIRED_RESULT CGSize toCGSize() const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT CGSize toCGSize() const noexcept; #endif private: @@ -114,74 +114,74 @@ Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QSize &); QSize inline functions *****************************************************************************/ -Q_DECL_CONSTEXPR inline QSize::QSize() Q_DECL_NOTHROW : wd(-1), ht(-1) {} +Q_DECL_CONSTEXPR inline QSize::QSize() noexcept : wd(-1), ht(-1) {} -Q_DECL_CONSTEXPR inline QSize::QSize(int w, int h) Q_DECL_NOTHROW : wd(w), ht(h) {} +Q_DECL_CONSTEXPR inline QSize::QSize(int w, int h) noexcept : wd(w), ht(h) {} -Q_DECL_CONSTEXPR inline bool QSize::isNull() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool QSize::isNull() const noexcept { return wd==0 && ht==0; } -Q_DECL_CONSTEXPR inline bool QSize::isEmpty() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool QSize::isEmpty() const noexcept { return wd<1 || ht<1; } -Q_DECL_CONSTEXPR inline bool QSize::isValid() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool QSize::isValid() const noexcept { return wd>=0 && ht>=0; } -Q_DECL_CONSTEXPR inline int QSize::width() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int QSize::width() const noexcept { return wd; } -Q_DECL_CONSTEXPR inline int QSize::height() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int QSize::height() const noexcept { return ht; } -Q_DECL_RELAXED_CONSTEXPR inline void QSize::setWidth(int w) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QSize::setWidth(int w) noexcept { wd = w; } -Q_DECL_RELAXED_CONSTEXPR inline void QSize::setHeight(int h) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QSize::setHeight(int h) noexcept { ht = h; } -Q_DECL_CONSTEXPR inline QSize QSize::transposed() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QSize QSize::transposed() const noexcept { return QSize(ht, wd); } -inline void QSize::scale(int w, int h, Qt::AspectRatioMode mode) Q_DECL_NOTHROW +inline void QSize::scale(int w, int h, Qt::AspectRatioMode mode) noexcept { scale(QSize(w, h), mode); } -inline void QSize::scale(const QSize &s, Qt::AspectRatioMode mode) Q_DECL_NOTHROW +inline void QSize::scale(const QSize &s, Qt::AspectRatioMode mode) noexcept { *this = scaled(s, mode); } -inline QSize QSize::scaled(int w, int h, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW +inline QSize QSize::scaled(int w, int h, Qt::AspectRatioMode mode) const noexcept { return scaled(QSize(w, h), mode); } -Q_DECL_RELAXED_CONSTEXPR inline int &QSize::rwidth() Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline int &QSize::rwidth() noexcept { return wd; } -Q_DECL_RELAXED_CONSTEXPR inline int &QSize::rheight() Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline int &QSize::rheight() noexcept { return ht; } -Q_DECL_RELAXED_CONSTEXPR inline QSize &QSize::operator+=(const QSize &s) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QSize &QSize::operator+=(const QSize &s) noexcept { wd+=s.wd; ht+=s.ht; return *this; } -Q_DECL_RELAXED_CONSTEXPR inline QSize &QSize::operator-=(const QSize &s) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QSize &QSize::operator-=(const QSize &s) noexcept { wd-=s.wd; ht-=s.ht; return *this; } -Q_DECL_RELAXED_CONSTEXPR inline QSize &QSize::operator*=(qreal c) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QSize &QSize::operator*=(qreal c) noexcept { wd = qRound(wd*c); ht = qRound(ht*c); return *this; } -Q_DECL_CONSTEXPR inline bool operator==(const QSize &s1, const QSize &s2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator==(const QSize &s1, const QSize &s2) noexcept { return s1.wd == s2.wd && s1.ht == s2.ht; } -Q_DECL_CONSTEXPR inline bool operator!=(const QSize &s1, const QSize &s2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator!=(const QSize &s1, const QSize &s2) noexcept { return s1.wd != s2.wd || s1.ht != s2.ht; } -Q_DECL_CONSTEXPR inline const QSize operator+(const QSize & s1, const QSize & s2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline const QSize operator+(const QSize & s1, const QSize & s2) noexcept { return QSize(s1.wd+s2.wd, s1.ht+s2.ht); } -Q_DECL_CONSTEXPR inline const QSize operator-(const QSize &s1, const QSize &s2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline const QSize operator-(const QSize &s1, const QSize &s2) noexcept { return QSize(s1.wd-s2.wd, s1.ht-s2.ht); } -Q_DECL_CONSTEXPR inline const QSize operator*(const QSize &s, qreal c) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline const QSize operator*(const QSize &s, qreal c) noexcept { return QSize(qRound(s.wd*c), qRound(s.ht*c)); } -Q_DECL_CONSTEXPR inline const QSize operator*(qreal c, const QSize &s) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline const QSize operator*(qreal c, const QSize &s) noexcept { return QSize(qRound(s.wd*c), qRound(s.ht*c)); } inline QSize &QSize::operator/=(qreal c) @@ -197,12 +197,12 @@ inline const QSize operator/(const QSize &s, qreal c) return QSize(qRound(s.wd/c), qRound(s.ht/c)); } -Q_DECL_CONSTEXPR inline QSize QSize::expandedTo(const QSize & otherSize) const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QSize QSize::expandedTo(const QSize & otherSize) const noexcept { return QSize(qMax(wd,otherSize.wd), qMax(ht,otherSize.ht)); } -Q_DECL_CONSTEXPR inline QSize QSize::boundedTo(const QSize & otherSize) const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QSize QSize::boundedTo(const QSize & otherSize) const noexcept { return QSize(qMin(wd,otherSize.wd), qMin(ht,otherSize.ht)); } @@ -215,50 +215,50 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QSize &); class Q_CORE_EXPORT QSizeF { public: - Q_DECL_CONSTEXPR QSizeF() Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR QSizeF(const QSize &sz) Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR QSizeF(qreal w, qreal h) Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR QSizeF() noexcept; + Q_DECL_CONSTEXPR QSizeF(const QSize &sz) noexcept; + Q_DECL_CONSTEXPR QSizeF(qreal w, qreal h) noexcept; - inline bool isNull() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline bool isEmpty() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline bool isValid() const Q_DECL_NOTHROW; + inline bool isNull() const noexcept; + Q_DECL_CONSTEXPR inline bool isEmpty() const noexcept; + Q_DECL_CONSTEXPR inline bool isValid() const noexcept; - Q_DECL_CONSTEXPR inline qreal width() const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline qreal height() const Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setWidth(qreal w) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline void setHeight(qreal h) Q_DECL_NOTHROW; - void transpose() Q_DECL_NOTHROW; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSizeF transposed() const Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline qreal width() const noexcept; + Q_DECL_CONSTEXPR inline qreal height() const noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setWidth(qreal w) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline void setHeight(qreal h) noexcept; + void transpose() noexcept; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSizeF transposed() const noexcept; - inline void scale(qreal w, qreal h, Qt::AspectRatioMode mode) Q_DECL_NOTHROW; - inline void scale(const QSizeF &s, Qt::AspectRatioMode mode) Q_DECL_NOTHROW; - Q_REQUIRED_RESULT QSizeF scaled(qreal w, qreal h, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT QSizeF scaled(const QSizeF &s, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW; + inline void scale(qreal w, qreal h, Qt::AspectRatioMode mode) noexcept; + inline void scale(const QSizeF &s, Qt::AspectRatioMode mode) noexcept; + Q_REQUIRED_RESULT QSizeF scaled(qreal w, qreal h, Qt::AspectRatioMode mode) const noexcept; + Q_REQUIRED_RESULT QSizeF scaled(const QSizeF &s, Qt::AspectRatioMode mode) const noexcept; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSizeF expandedTo(const QSizeF &) const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSizeF boundedTo(const QSizeF &) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSizeF expandedTo(const QSizeF &) const noexcept; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSizeF boundedTo(const QSizeF &) const noexcept; - Q_DECL_RELAXED_CONSTEXPR inline qreal &rwidth() Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline qreal &rheight() Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline qreal &rwidth() noexcept; + Q_DECL_RELAXED_CONSTEXPR inline qreal &rheight() noexcept; - Q_DECL_RELAXED_CONSTEXPR inline QSizeF &operator+=(const QSizeF &) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline QSizeF &operator-=(const QSizeF &) Q_DECL_NOTHROW; - Q_DECL_RELAXED_CONSTEXPR inline QSizeF &operator*=(qreal c) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR inline QSizeF &operator+=(const QSizeF &) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline QSizeF &operator-=(const QSizeF &) noexcept; + Q_DECL_RELAXED_CONSTEXPR inline QSizeF &operator*=(qreal c) noexcept; inline QSizeF &operator/=(qreal c); - friend Q_DECL_CONSTEXPR inline bool operator==(const QSizeF &, const QSizeF &) Q_DECL_NOTHROW; - friend Q_DECL_CONSTEXPR inline bool operator!=(const QSizeF &, const QSizeF &) Q_DECL_NOTHROW; - friend Q_DECL_CONSTEXPR inline const QSizeF operator+(const QSizeF &, const QSizeF &) Q_DECL_NOTHROW; - friend Q_DECL_CONSTEXPR inline const QSizeF operator-(const QSizeF &, const QSizeF &) Q_DECL_NOTHROW; - friend Q_DECL_CONSTEXPR inline const QSizeF operator*(const QSizeF &, qreal) Q_DECL_NOTHROW; - friend Q_DECL_CONSTEXPR inline const QSizeF operator*(qreal, const QSizeF &) Q_DECL_NOTHROW; + friend Q_DECL_CONSTEXPR inline bool operator==(const QSizeF &, const QSizeF &) noexcept; + friend Q_DECL_CONSTEXPR inline bool operator!=(const QSizeF &, const QSizeF &) noexcept; + friend Q_DECL_CONSTEXPR inline const QSizeF operator+(const QSizeF &, const QSizeF &) noexcept; + friend Q_DECL_CONSTEXPR inline const QSizeF operator-(const QSizeF &, const QSizeF &) noexcept; + friend Q_DECL_CONSTEXPR inline const QSizeF operator*(const QSizeF &, qreal) noexcept; + friend Q_DECL_CONSTEXPR inline const QSizeF operator*(qreal, const QSizeF &) noexcept; friend inline const QSizeF operator/(const QSizeF &, qreal); - Q_DECL_CONSTEXPR inline QSize toSize() const Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR inline QSize toSize() const noexcept; #if defined(Q_OS_DARWIN) || defined(Q_QDOC) - Q_REQUIRED_RESULT static QSizeF fromCGSize(CGSize size) Q_DECL_NOTHROW; - Q_REQUIRED_RESULT CGSize toCGSize() const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT static QSizeF fromCGSize(CGSize size) noexcept; + Q_REQUIRED_RESULT CGSize toCGSize() const noexcept; #endif private: @@ -282,76 +282,76 @@ Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QSizeF &); QSizeF inline functions *****************************************************************************/ -Q_DECL_CONSTEXPR inline QSizeF::QSizeF() Q_DECL_NOTHROW : wd(-1.), ht(-1.) {} +Q_DECL_CONSTEXPR inline QSizeF::QSizeF() noexcept : wd(-1.), ht(-1.) {} -Q_DECL_CONSTEXPR inline QSizeF::QSizeF(const QSize &sz) Q_DECL_NOTHROW : wd(sz.width()), ht(sz.height()) {} +Q_DECL_CONSTEXPR inline QSizeF::QSizeF(const QSize &sz) noexcept : wd(sz.width()), ht(sz.height()) {} -Q_DECL_CONSTEXPR inline QSizeF::QSizeF(qreal w, qreal h) Q_DECL_NOTHROW : wd(w), ht(h) {} +Q_DECL_CONSTEXPR inline QSizeF::QSizeF(qreal w, qreal h) noexcept : wd(w), ht(h) {} -inline bool QSizeF::isNull() const Q_DECL_NOTHROW +inline bool QSizeF::isNull() const noexcept { return qIsNull(wd) && qIsNull(ht); } -Q_DECL_CONSTEXPR inline bool QSizeF::isEmpty() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool QSizeF::isEmpty() const noexcept { return wd <= 0. || ht <= 0.; } -Q_DECL_CONSTEXPR inline bool QSizeF::isValid() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool QSizeF::isValid() const noexcept { return wd >= 0. && ht >= 0.; } -Q_DECL_CONSTEXPR inline qreal QSizeF::width() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline qreal QSizeF::width() const noexcept { return wd; } -Q_DECL_CONSTEXPR inline qreal QSizeF::height() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline qreal QSizeF::height() const noexcept { return ht; } -Q_DECL_RELAXED_CONSTEXPR inline void QSizeF::setWidth(qreal w) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QSizeF::setWidth(qreal w) noexcept { wd = w; } -Q_DECL_RELAXED_CONSTEXPR inline void QSizeF::setHeight(qreal h) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline void QSizeF::setHeight(qreal h) noexcept { ht = h; } -Q_DECL_CONSTEXPR inline QSizeF QSizeF::transposed() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QSizeF QSizeF::transposed() const noexcept { return QSizeF(ht, wd); } -inline void QSizeF::scale(qreal w, qreal h, Qt::AspectRatioMode mode) Q_DECL_NOTHROW +inline void QSizeF::scale(qreal w, qreal h, Qt::AspectRatioMode mode) noexcept { scale(QSizeF(w, h), mode); } -inline void QSizeF::scale(const QSizeF &s, Qt::AspectRatioMode mode) Q_DECL_NOTHROW +inline void QSizeF::scale(const QSizeF &s, Qt::AspectRatioMode mode) noexcept { *this = scaled(s, mode); } -inline QSizeF QSizeF::scaled(qreal w, qreal h, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW +inline QSizeF QSizeF::scaled(qreal w, qreal h, Qt::AspectRatioMode mode) const noexcept { return scaled(QSizeF(w, h), mode); } -Q_DECL_RELAXED_CONSTEXPR inline qreal &QSizeF::rwidth() Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline qreal &QSizeF::rwidth() noexcept { return wd; } -Q_DECL_RELAXED_CONSTEXPR inline qreal &QSizeF::rheight() Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline qreal &QSizeF::rheight() noexcept { return ht; } -Q_DECL_RELAXED_CONSTEXPR inline QSizeF &QSizeF::operator+=(const QSizeF &s) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QSizeF &QSizeF::operator+=(const QSizeF &s) noexcept { wd += s.wd; ht += s.ht; return *this; } -Q_DECL_RELAXED_CONSTEXPR inline QSizeF &QSizeF::operator-=(const QSizeF &s) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QSizeF &QSizeF::operator-=(const QSizeF &s) noexcept { wd -= s.wd; ht -= s.ht; return *this; } -Q_DECL_RELAXED_CONSTEXPR inline QSizeF &QSizeF::operator*=(qreal c) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline QSizeF &QSizeF::operator*=(qreal c) noexcept { wd *= c; ht *= c; return *this; } -Q_DECL_CONSTEXPR inline bool operator==(const QSizeF &s1, const QSizeF &s2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator==(const QSizeF &s1, const QSizeF &s2) noexcept { return qFuzzyCompare(s1.wd, s2.wd) && qFuzzyCompare(s1.ht, s2.ht); } -Q_DECL_CONSTEXPR inline bool operator!=(const QSizeF &s1, const QSizeF &s2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator!=(const QSizeF &s1, const QSizeF &s2) noexcept { return !qFuzzyCompare(s1.wd, s2.wd) || !qFuzzyCompare(s1.ht, s2.ht); } -Q_DECL_CONSTEXPR inline const QSizeF operator+(const QSizeF & s1, const QSizeF & s2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline const QSizeF operator+(const QSizeF & s1, const QSizeF & s2) noexcept { return QSizeF(s1.wd+s2.wd, s1.ht+s2.ht); } -Q_DECL_CONSTEXPR inline const QSizeF operator-(const QSizeF &s1, const QSizeF &s2) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline const QSizeF operator-(const QSizeF &s1, const QSizeF &s2) noexcept { return QSizeF(s1.wd-s2.wd, s1.ht-s2.ht); } -Q_DECL_CONSTEXPR inline const QSizeF operator*(const QSizeF &s, qreal c) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline const QSizeF operator*(const QSizeF &s, qreal c) noexcept { return QSizeF(s.wd*c, s.ht*c); } -Q_DECL_CONSTEXPR inline const QSizeF operator*(qreal c, const QSizeF &s) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline const QSizeF operator*(qreal c, const QSizeF &s) noexcept { return QSizeF(s.wd*c, s.ht*c); } inline QSizeF &QSizeF::operator/=(qreal c) @@ -367,17 +367,17 @@ inline const QSizeF operator/(const QSizeF &s, qreal c) return QSizeF(s.wd/c, s.ht/c); } -Q_DECL_CONSTEXPR inline QSizeF QSizeF::expandedTo(const QSizeF & otherSize) const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QSizeF QSizeF::expandedTo(const QSizeF & otherSize) const noexcept { return QSizeF(qMax(wd,otherSize.wd), qMax(ht,otherSize.ht)); } -Q_DECL_CONSTEXPR inline QSizeF QSizeF::boundedTo(const QSizeF & otherSize) const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QSizeF QSizeF::boundedTo(const QSizeF & otherSize) const noexcept { return QSizeF(qMin(wd,otherSize.wd), qMin(ht,otherSize.ht)); } -Q_DECL_CONSTEXPR inline QSize QSizeF::toSize() const Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline QSize QSizeF::toSize() const noexcept { return QSize(qRound(wd), qRound(ht)); } diff --git a/src/corelib/tools/qstack.h b/src/corelib/tools/qstack.h index bf04935b50..e59212aa2a 100644 --- a/src/corelib/tools/qstack.h +++ b/src/corelib/tools/qstack.h @@ -50,7 +50,7 @@ class QStack : public QVector { public: // compiler-generated special member functions are fine! - inline void swap(QStack &other) Q_DECL_NOTHROW { QVector::swap(other); } // prevent QVector<->QStack swaps + inline void swap(QStack &other) noexcept { QVector::swap(other); } // prevent QVector<->QStack swaps inline void push(const T &t) { QVector::append(t); } T pop(); T &top(); diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 65519d1f98..74debd8cfa 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -155,7 +155,7 @@ static inline bool qt_ends_with(QStringView haystack, QStringView needle, Qt::Ca static inline bool qt_ends_with(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs); static inline bool qt_ends_with(QStringView haystack, QChar needle, Qt::CaseSensitivity cs); -qsizetype QtPrivate::qustrlen(const ushort *str) Q_DECL_NOTHROW +qsizetype QtPrivate::qustrlen(const ushort *str) noexcept { qsizetype result = 0; @@ -453,7 +453,7 @@ static Q_ALWAYS_INLINE __m128i mm_load8_zero_extend(const void *ptr) // Note: ptr on output may be off by one and point to a preceding US-ASCII // character. Usually harmless. -bool qt_is_ascii(const char *&ptr, const char *end) Q_DECL_NOTHROW +bool qt_is_ascii(const char *&ptr, const char *end) noexcept { #if defined(__SSE2__) // Testing for the high bit can be done efficiently with just PMOVMSKB @@ -509,7 +509,7 @@ bool qt_is_ascii(const char *&ptr, const char *end) Q_DECL_NOTHROW return true; } -bool QtPrivate::isAscii(QLatin1String s) Q_DECL_NOTHROW +bool QtPrivate::isAscii(QLatin1String s) noexcept { const char *ptr = s.begin(); const char *end = s.end(); @@ -536,7 +536,7 @@ static bool isAscii(const QChar *&ptr, const QChar *end) return true; } -bool QtPrivate::isAscii(QStringView s) Q_DECL_NOTHROW +bool QtPrivate::isAscii(QStringView s) noexcept { const QChar *ptr = s.begin(); const QChar *end = s.end(); @@ -544,7 +544,7 @@ bool QtPrivate::isAscii(QStringView s) Q_DECL_NOTHROW return isAscii(ptr, end); } -bool QtPrivate::isLatin1(QStringView s) Q_DECL_NOTHROW +bool QtPrivate::isLatin1(QStringView s) noexcept { const QChar *ptr = s.begin(); const QChar *end = s.end(); @@ -584,7 +584,7 @@ bool QtPrivate::isLatin1(QStringView s) Q_DECL_NOTHROW } // conversion between Latin 1 and UTF-16 -void qt_from_latin1(ushort *dst, const char *str, size_t size) Q_DECL_NOTHROW +void qt_from_latin1(ushort *dst, const char *str, size_t size) noexcept { /* SIMD: * Unpacking with SSE has been shown to improve performance on recent CPUs @@ -1141,7 +1141,7 @@ static int ucstrncmp(const QChar *a, const uchar *c, size_t l) } template -Q_DECL_CONSTEXPR int lencmp(Number lhs, Number rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR int lencmp(Number lhs, Number rhs) noexcept { return lhs == rhs ? 0 : lhs > rhs ? 1 : @@ -1165,7 +1165,7 @@ static int ucstrcmp(const QChar *a, size_t alen, const char *b, size_t blen) return cmp ? cmp : lencmp(alen, blen); } -static int qt_compare_strings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +static int qt_compare_strings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs) noexcept { if (cs == Qt::CaseSensitive) return ucstrcmp(lhs.begin(), lhs.size(), rhs.begin(), rhs.size()); @@ -1173,7 +1173,7 @@ static int qt_compare_strings(QStringView lhs, QStringView rhs, Qt::CaseSensitiv return ucstricmp(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); } -static int qt_compare_strings(QStringView lhs, QLatin1String rhs, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +static int qt_compare_strings(QStringView lhs, QLatin1String rhs, Qt::CaseSensitivity cs) noexcept { if (cs == Qt::CaseSensitive) return ucstrcmp(lhs.begin(), lhs.size(), rhs.begin(), rhs.size()); @@ -1181,12 +1181,12 @@ static int qt_compare_strings(QStringView lhs, QLatin1String rhs, Qt::CaseSensit return ucstricmp(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); } -static int qt_compare_strings(QLatin1String lhs, QStringView rhs, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +static int qt_compare_strings(QLatin1String lhs, QStringView rhs, Qt::CaseSensitivity cs) noexcept { return -qt_compare_strings(rhs, lhs, cs); } -static int qt_compare_strings(QLatin1String lhs, QLatin1String rhs, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +static int qt_compare_strings(QLatin1String lhs, QLatin1String rhs, Qt::CaseSensitivity cs) noexcept { if (cs == Qt::CaseInsensitive) return qstrnicmp(lhs.data(), lhs.size(), rhs.data(), rhs.size()); @@ -1211,7 +1211,7 @@ static int qt_compare_strings(QLatin1String lhs, QLatin1String rhs, Qt::CaseSens of the characters and is very fast, but is not what a human would expect. Consider sorting user-visible strings with QString::localeAwareCompare(). */ -int QtPrivate::compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +int QtPrivate::compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs) noexcept { return qt_compare_strings(lhs, rhs, cs); } @@ -1231,7 +1231,7 @@ int QtPrivate::compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitiv of the characters and is very fast, but is not what a human would expect. Consider sorting user-visible strings with QString::localeAwareCompare(). */ -int QtPrivate::compareStrings(QStringView lhs, QLatin1String rhs, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +int QtPrivate::compareStrings(QStringView lhs, QLatin1String rhs, Qt::CaseSensitivity cs) noexcept { return qt_compare_strings(lhs, rhs, cs); } @@ -1251,7 +1251,7 @@ int QtPrivate::compareStrings(QStringView lhs, QLatin1String rhs, Qt::CaseSensit of the characters and is very fast, but is not what a human would expect. Consider sorting user-visible strings with QString::localeAwareCompare(). */ -int QtPrivate::compareStrings(QLatin1String lhs, QStringView rhs, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +int QtPrivate::compareStrings(QLatin1String lhs, QStringView rhs, Qt::CaseSensitivity cs) noexcept { return qt_compare_strings(lhs, rhs, cs); } @@ -1271,7 +1271,7 @@ int QtPrivate::compareStrings(QLatin1String lhs, QStringView rhs, Qt::CaseSensit of the characters and is very fast, but is not what a human would expect. Consider sorting user-visible strings with QString::localeAwareCompare(). */ -int QtPrivate::compareStrings(QLatin1String lhs, QLatin1String rhs, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +int QtPrivate::compareStrings(QLatin1String lhs, QLatin1String rhs, Qt::CaseSensitivity cs) noexcept { return qt_compare_strings(lhs, rhs, cs); } @@ -2367,7 +2367,7 @@ void QString::expand(int i) string. */ -QString &QString::operator=(const QString &other) Q_DECL_NOTHROW +QString &QString::operator=(const QString &other) noexcept { other.d->ref.ref(); if (!d->ref.deref()) @@ -3353,7 +3353,7 @@ QString &QString::replace(QChar c, QLatin1String after, Qt::CaseSensitivity cs) expect. Consider sorting user-interface strings with localeAwareCompare(). */ -bool operator==(const QString &s1, const QString &s2) Q_DECL_NOTHROW +bool operator==(const QString &s1, const QString &s2) noexcept { if (s1.d->size != s2.d->size) return false; @@ -3366,7 +3366,7 @@ bool operator==(const QString &s1, const QString &s2) Q_DECL_NOTHROW Returns \c true if this string is equal to \a other; otherwise returns \c false. */ -bool QString::operator==(QLatin1String other) const Q_DECL_NOTHROW +bool QString::operator==(QLatin1String other) const noexcept { if (d->size != other.size()) return false; @@ -3418,7 +3418,7 @@ bool QString::operator==(QLatin1String other) const Q_DECL_NOTHROW expect. Consider sorting user-interface strings using the QString::localeAwareCompare() function. */ -bool operator<(const QString &s1, const QString &s2) Q_DECL_NOTHROW +bool operator<(const QString &s1, const QString &s2) noexcept { return qt_compare_strings(s1, s2, Qt::CaseSensitive) < 0; } @@ -3429,7 +3429,7 @@ bool operator<(const QString &s1, const QString &s2) Q_DECL_NOTHROW Returns \c true if this string is lexically less than the parameter string called \a other; otherwise returns \c false. */ -bool QString::operator<(QLatin1String other) const Q_DECL_NOTHROW +bool QString::operator<(QLatin1String other) const noexcept { return qt_compare_strings(*this, other, Qt::CaseSensitive) < 0; } @@ -3538,7 +3538,7 @@ bool QString::operator<(QLatin1String other) const Q_DECL_NOTHROW Returns \c true if this string is lexically greater than the parameter string \a other; otherwise returns \c false. */ -bool QString::operator>(QLatin1String other) const Q_DECL_NOTHROW +bool QString::operator>(QLatin1String other) const noexcept { return qt_compare_strings(*this, other, Qt::CaseSensitive) > 0; } @@ -5668,7 +5668,7 @@ QString QString::simplified_helper(QString &str) namespace { template - StringView qt_trimmed(StringView s) Q_DECL_NOTHROW + StringView qt_trimmed(StringView s) noexcept { auto begin = s.begin(); auto end = s.end(); @@ -5692,12 +5692,12 @@ namespace { \sa QString::trimmed(), QStringView::trimmed(), QLatin1String::trimmed() */ -QStringView QtPrivate::trimmed(QStringView s) Q_DECL_NOTHROW +QStringView QtPrivate::trimmed(QStringView s) noexcept { return qt_trimmed(s); } -QLatin1String QtPrivate::trimmed(QLatin1String s) Q_DECL_NOTHROW +QLatin1String QtPrivate::trimmed(QLatin1String s) noexcept { return qt_trimmed(s); } @@ -6235,7 +6235,7 @@ QString& QString::fill(QChar ch, int size) Same as compare(*this, \a other, \a cs). */ -int QString::compare(const QString &other, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW +int QString::compare(const QString &other, Qt::CaseSensitivity cs) const noexcept { return qt_compare_strings(*this, other, cs); } @@ -6246,7 +6246,7 @@ int QString::compare(const QString &other, Qt::CaseSensitivity cs) const Q_DECL_ \since 4.5 */ int QString::compare_helper(const QChar *data1, int length1, const QChar *data2, int length2, - Qt::CaseSensitivity cs) Q_DECL_NOTHROW + Qt::CaseSensitivity cs) noexcept { Q_ASSERT(length1 >= 0); Q_ASSERT(length2 >= 0); @@ -6261,7 +6261,7 @@ int QString::compare_helper(const QChar *data1, int length1, const QChar *data2, Same as compare(*this, \a other, \a cs). */ -int QString::compare(QLatin1String other, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW +int QString::compare(QLatin1String other, Qt::CaseSensitivity cs) const noexcept { return qt_compare_strings(*this, other, cs); } @@ -6307,7 +6307,7 @@ int QString::compare_helper(const QChar *data1, int length1, const char *data2, \since 4.5 */ int QString::compare_helper(const QChar *data1, int length1, QLatin1String s2, - Qt::CaseSensitivity cs) Q_DECL_NOTHROW + Qt::CaseSensitivity cs) noexcept { Q_ASSERT(length1 >= 0); Q_ASSERT(data1 || length1 == 0); @@ -6801,7 +6801,7 @@ static void append_utf8(QString &qs, const char *cs, int len) qs.resize(newEnd - qs.constData()); } -static uint parse_flag_characters(const char * &c) Q_DECL_NOTHROW +static uint parse_flag_characters(const char * &c) noexcept { uint flags = QLocaleData::ZeroPadExponent; while (true) { @@ -6838,7 +6838,7 @@ static int parse_field_width(const char * &c) enum LengthMod { lm_none, lm_hh, lm_h, lm_l, lm_ll, lm_L, lm_j, lm_z, lm_t }; -static inline bool can_consume(const char * &c, char ch) Q_DECL_NOTHROW +static inline bool can_consume(const char * &c, char ch) noexcept { if (*c == ch) { ++c; @@ -6847,7 +6847,7 @@ static inline bool can_consume(const char * &c, char ch) Q_DECL_NOTHROW return false; } -static LengthMod parse_length_modifier(const char * &c) Q_DECL_NOTHROW +static LengthMod parse_length_modifier(const char * &c) noexcept { switch (*c++) { case 'h': return can_consume(c, 'h') ? lm_hh : lm_h; @@ -8810,7 +8810,7 @@ namespace { struct Part { Part() : stringRef(), number(0) {} - Part(const QString &s, int pos, int len, int num = -1) Q_DECL_NOTHROW + Part(const QString &s, int pos, int len, int num = -1) noexcept : stringRef(&s, pos, len), number(num) {} QStringRef stringRef; @@ -10379,7 +10379,7 @@ QString QStringRef::toString() const { Returns \c true if string reference \a s1 is lexically equal to string reference \a s2; otherwise returns \c false. */ -bool operator==(const QStringRef &s1,const QStringRef &s2) Q_DECL_NOTHROW +bool operator==(const QStringRef &s1,const QStringRef &s2) noexcept { return s1.size() == s2.size() && qt_compare_strings(s1, s2, Qt::CaseSensitive) == 0; } @@ -10389,7 +10389,7 @@ bool operator==(const QStringRef &s1,const QStringRef &s2) Q_DECL_NOTHROW Returns \c true if string \a s1 is lexically equal to string reference \a s2; otherwise returns \c false. */ -bool operator==(const QString &s1,const QStringRef &s2) Q_DECL_NOTHROW +bool operator==(const QString &s1,const QStringRef &s2) noexcept { return s1.size() == s2.size() && qt_compare_strings(s1, s2, Qt::CaseSensitive) == 0; } @@ -10399,7 +10399,7 @@ bool operator==(const QString &s1,const QStringRef &s2) Q_DECL_NOTHROW Returns \c true if string \a s1 is lexically equal to string reference \a s2; otherwise returns \c false. */ -bool operator==(QLatin1String s1, const QStringRef &s2) Q_DECL_NOTHROW +bool operator==(QLatin1String s1, const QStringRef &s2) noexcept { if (s1.size() != s2.size()) return false; @@ -10418,7 +10418,7 @@ bool operator==(QLatin1String s1, const QStringRef &s2) Q_DECL_NOTHROW expect. Consider sorting user-interface strings using the QString::localeAwareCompare() function. */ -bool operator<(const QStringRef &s1,const QStringRef &s2) Q_DECL_NOTHROW +bool operator<(const QStringRef &s1,const QStringRef &s2) noexcept { return qt_compare_strings(s1, s2, Qt::CaseSensitive) < 0; } @@ -11553,7 +11553,7 @@ static inline qsizetype qt_string_count(QStringView haystack, QChar ch, } template -bool qt_starts_with_impl(Haystack haystack, Needle needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +bool qt_starts_with_impl(Haystack haystack, Needle needle, Qt::CaseSensitivity cs) noexcept { if (haystack.isNull()) return needle.isNull(); // historical behavior, consider changing in ### Qt 6. @@ -11605,28 +11605,28 @@ static inline bool qt_starts_with(QStringView haystack, QChar needle, Qt::CaseSe \sa QtPrivate::endsWith(), QString::endsWith(), QStringView::endsWith(), QLatin1String::endsWith() */ -bool QtPrivate::startsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +bool QtPrivate::startsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs) noexcept { return qt_starts_with_impl(haystack, needle, cs); } -bool QtPrivate::startsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +bool QtPrivate::startsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs) noexcept { return qt_starts_with_impl(haystack, needle, cs); } -bool QtPrivate::startsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +bool QtPrivate::startsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs) noexcept { return qt_starts_with_impl(haystack, needle, cs); } -bool QtPrivate::startsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +bool QtPrivate::startsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs) noexcept { return qt_starts_with_impl(haystack, needle, cs); } template -bool qt_ends_with_impl(Haystack haystack, Needle needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +bool qt_ends_with_impl(Haystack haystack, Needle needle, Qt::CaseSensitivity cs) noexcept { if (haystack.isNull()) return needle.isNull(); // historical behavior, consider changing in ### Qt 6. @@ -11678,22 +11678,22 @@ static inline bool qt_ends_with(QStringView haystack, QChar needle, Qt::CaseSens \sa QtPrivate::startsWith(), QString::endsWith(), QStringView::endsWith(), QLatin1String::endsWith() */ -bool QtPrivate::endsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +bool QtPrivate::endsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs) noexcept { return qt_ends_with_impl(haystack, needle, cs); } -bool QtPrivate::endsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +bool QtPrivate::endsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs) noexcept { return qt_ends_with_impl(haystack, needle, cs); } -bool QtPrivate::endsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +bool QtPrivate::endsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs) noexcept { return qt_ends_with_impl(haystack, needle, cs); } -bool QtPrivate::endsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +bool QtPrivate::endsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs) noexcept { return qt_ends_with_impl(haystack, needle, cs); } @@ -11707,7 +11707,7 @@ bool QtPrivate::endsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseS position \a from. Returns -1 if \a ch could not be found. */ -qsizetype QtPrivate::findChar(QStringView str, QChar ch, qsizetype from, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +qsizetype QtPrivate::findChar(QStringView str, QChar ch, qsizetype from, Qt::CaseSensitivity cs) noexcept { if (from < 0) from = qMax(from + str.size(), qsizetype(0)); @@ -11731,7 +11731,7 @@ qsizetype QtPrivate::findChar(QStringView str, QChar ch, qsizetype from, Qt::Cas return -1; } -qsizetype QtPrivate::findString(QStringView haystack0, qsizetype from, QStringView needle0, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +qsizetype QtPrivate::findString(QStringView haystack0, qsizetype from, QStringView needle0, Qt::CaseSensitivity cs) noexcept { const qsizetype l = haystack0.size(); const qsizetype sl = needle0.size(); @@ -11806,7 +11806,7 @@ qsizetype QtPrivate::findString(QStringView haystack0, qsizetype from, QStringVi return -1; } -qsizetype QtPrivate::findString(QStringView haystack, qsizetype from, QLatin1String needle, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +qsizetype QtPrivate::findString(QStringView haystack, qsizetype from, QLatin1String needle, Qt::CaseSensitivity cs) noexcept { if (haystack.size() < needle.size()) return -1; @@ -12271,7 +12271,7 @@ QString QString::toHtmlEscaped() const /*! \internal */ -void QAbstractConcatenable::appendLatin1To(const char *a, int len, QChar *out) Q_DECL_NOTHROW +void QAbstractConcatenable::appendLatin1To(const char *a, int len, QChar *out) noexcept { qt_from_latin1(reinterpret_cast(out), a, uint(len)); } diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index e9a205dfdf..a526a6537a 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -91,19 +91,19 @@ template class QVector; class QLatin1String { public: - Q_DECL_CONSTEXPR inline QLatin1String() Q_DECL_NOTHROW : m_size(0), m_data(nullptr) {} - Q_DECL_CONSTEXPR inline explicit QLatin1String(const char *s) Q_DECL_NOTHROW : m_size(s ? int(strlen(s)) : 0), m_data(s) {} + Q_DECL_CONSTEXPR inline QLatin1String() noexcept : m_size(0), m_data(nullptr) {} + Q_DECL_CONSTEXPR inline explicit QLatin1String(const char *s) noexcept : m_size(s ? int(strlen(s)) : 0), m_data(s) {} Q_DECL_CONSTEXPR explicit QLatin1String(const char *f, const char *l) : QLatin1String(f, int(l - f)) {} - Q_DECL_CONSTEXPR inline explicit QLatin1String(const char *s, int sz) Q_DECL_NOTHROW : m_size(sz), m_data(s) {} - inline explicit QLatin1String(const QByteArray &s) Q_DECL_NOTHROW : m_size(int(qstrnlen(s.constData(), s.size()))), m_data(s.constData()) {} + Q_DECL_CONSTEXPR inline explicit QLatin1String(const char *s, int sz) noexcept : m_size(sz), m_data(s) {} + inline explicit QLatin1String(const QByteArray &s) noexcept : m_size(int(qstrnlen(s.constData(), s.size()))), m_data(s.constData()) {} - Q_DECL_CONSTEXPR const char *latin1() const Q_DECL_NOTHROW { return m_data; } - Q_DECL_CONSTEXPR int size() const Q_DECL_NOTHROW { return m_size; } - Q_DECL_CONSTEXPR const char *data() const Q_DECL_NOTHROW { return m_data; } + Q_DECL_CONSTEXPR const char *latin1() const noexcept { return m_data; } + Q_DECL_CONSTEXPR int size() const noexcept { return m_size; } + Q_DECL_CONSTEXPR const char *data() const noexcept { return m_data; } - Q_DECL_CONSTEXPR bool isNull() const Q_DECL_NOTHROW { return !data(); } - Q_DECL_CONSTEXPR bool isEmpty() const Q_DECL_NOTHROW { return !size(); } + Q_DECL_CONSTEXPR bool isNull() const noexcept { return !data(); } + Q_DECL_CONSTEXPR bool isEmpty() const noexcept { return !size(); } Q_DECL_CONSTEXPR QLatin1Char at(int i) const { return Q_ASSERT(i >= 0), Q_ASSERT(i < size()), QLatin1Char(m_data[i]); } @@ -112,22 +112,22 @@ public: Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QLatin1Char front() const { return at(0); } Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QLatin1Char back() const { return at(size() - 1); } - Q_REQUIRED_RESULT bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::startsWith(*this, s, cs); } - Q_REQUIRED_RESULT bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::startsWith(*this, s, cs); } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR bool startsWith(QChar c) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR bool startsWith(QChar c) const noexcept { return !isEmpty() && front() == c; } - Q_REQUIRED_RESULT inline bool startsWith(QChar c, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT inline bool startsWith(QChar c, Qt::CaseSensitivity cs) const noexcept { return QtPrivate::startsWith(*this, QStringView(&c, 1), cs); } - Q_REQUIRED_RESULT bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::endsWith(*this, s, cs); } - Q_REQUIRED_RESULT bool endsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT bool endsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::endsWith(*this, s, cs); } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR bool endsWith(QChar c) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR bool endsWith(QChar c) const noexcept { return !isEmpty() && back() == c; } - Q_REQUIRED_RESULT inline bool endsWith(QChar c, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT inline bool endsWith(QChar c, Qt::CaseSensitivity cs) const noexcept { return QtPrivate::endsWith(*this, QStringView(&c, 1), cs); } using value_type = const char; @@ -138,18 +138,18 @@ public: using difference_type = int; // violates Container concept requirements using size_type = int; // violates Container concept requirements - Q_DECL_CONSTEXPR const_iterator begin() const Q_DECL_NOTHROW { return data(); } - Q_DECL_CONSTEXPR const_iterator cbegin() const Q_DECL_NOTHROW { return data(); } - Q_DECL_CONSTEXPR const_iterator end() const Q_DECL_NOTHROW { return data() + size(); } - Q_DECL_CONSTEXPR const_iterator cend() const Q_DECL_NOTHROW { return data() + size(); } + Q_DECL_CONSTEXPR const_iterator begin() const noexcept { return data(); } + Q_DECL_CONSTEXPR const_iterator cbegin() const noexcept { return data(); } + Q_DECL_CONSTEXPR const_iterator end() const noexcept { return data() + size(); } + Q_DECL_CONSTEXPR const_iterator cend() const noexcept { return data() + size(); } using reverse_iterator = std::reverse_iterator; using const_reverse_iterator = reverse_iterator; - const_reverse_iterator rbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); } - const_reverse_iterator crbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); } - const_reverse_iterator rend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); } - const_reverse_iterator crend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); } + const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } + const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } + const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } + const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } Q_DECL_CONSTEXPR QLatin1String mid(int pos) const { return Q_ASSERT(pos >= 0), Q_ASSERT(pos <= size()), QLatin1String(m_data + pos, m_size - pos); } @@ -167,14 +167,14 @@ public: Q_DECL_RELAXED_CONSTEXPR void truncate(int n) { Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); m_size = n; } - Q_REQUIRED_RESULT QLatin1String trimmed() const Q_DECL_NOTHROW { return QtPrivate::trimmed(*this); } + Q_REQUIRED_RESULT QLatin1String trimmed() const noexcept { return QtPrivate::trimmed(*this); } - inline bool operator==(const QString &s) const Q_DECL_NOTHROW; - inline bool operator!=(const QString &s) const Q_DECL_NOTHROW; - inline bool operator>(const QString &s) const Q_DECL_NOTHROW; - inline bool operator<(const QString &s) const Q_DECL_NOTHROW; - inline bool operator>=(const QString &s) const Q_DECL_NOTHROW; - inline bool operator<=(const QString &s) const Q_DECL_NOTHROW; + inline bool operator==(const QString &s) const noexcept; + inline bool operator!=(const QString &s) const noexcept; + inline bool operator>(const QString &s) const noexcept; + inline bool operator<(const QString &s) const noexcept; + inline bool operator>=(const QString &s) const noexcept; + inline bool operator<=(const QString &s) const noexcept; #if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII) inline QT_ASCII_CAST_WARN bool operator==(const char *s) const; @@ -204,15 +204,15 @@ typedef QLatin1String QLatin1Literal; // // QLatin1String inline implementations // -inline bool QtPrivate::isLatin1(QLatin1String) Q_DECL_NOTHROW +inline bool QtPrivate::isLatin1(QLatin1String) noexcept { return true; } // // QStringView members that require QLatin1String: // -bool QStringView::startsWith(QLatin1String s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW +bool QStringView::startsWith(QLatin1String s, Qt::CaseSensitivity cs) const noexcept { return QtPrivate::startsWith(*this, s, cs); } -bool QStringView::endsWith(QLatin1String s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW +bool QStringView::endsWith(QLatin1String s, Qt::CaseSensitivity cs) const noexcept { return QtPrivate::endsWith(*this, s, cs); } class Q_CORE_EXPORT QString @@ -220,22 +220,22 @@ class Q_CORE_EXPORT QString public: typedef QStringData Data; - inline QString() Q_DECL_NOTHROW; + inline QString() noexcept; explicit QString(const QChar *unicode, int size = -1); QString(QChar c); QString(int size, QChar c); inline QString(QLatin1String latin1); - inline QString(const QString &) Q_DECL_NOTHROW; + inline QString(const QString &) noexcept; inline ~QString(); QString &operator=(QChar c); - QString &operator=(const QString &) Q_DECL_NOTHROW; + QString &operator=(const QString &) noexcept; QString &operator=(QLatin1String latin1); #ifdef Q_COMPILER_RVALUE_REFS - inline QString(QString && other) Q_DECL_NOTHROW : d(other.d) { other.d = Data::sharedNull(); } - inline QString &operator=(QString &&other) Q_DECL_NOTHROW + inline QString(QString && other) noexcept : d(other.d) { other.d = Data::sharedNull(); } + inline QString &operator=(QString &&other) noexcept { qSwap(d, other.d); return *this; } #endif - inline void swap(QString &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + inline void swap(QString &other) noexcept { qSwap(d, other.d); } inline int size() const { return d->size; } inline int count() const { return d->size; } inline int length() const; @@ -399,7 +399,7 @@ public: bool startsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; bool startsWith(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; #endif - Q_REQUIRED_RESULT bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::startsWith(*this, s, cs); } bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; bool startsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; @@ -408,7 +408,7 @@ public: bool endsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; bool endsWith(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; #endif - Q_REQUIRED_RESULT bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::endsWith(*this, s, cs); } bool endsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; bool endsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; @@ -613,25 +613,25 @@ public: inline QString &setUtf16(const ushort *utf16, int size); #if QT_STRINGVIEW_LEVEL < 2 - int compare(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW; - inline int compare(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW; + int compare(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; + inline int compare(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; #endif - int compare(QLatin1String other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW; - inline int compare(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW; + int compare(QLatin1String other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; + inline int compare(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; static inline int compare(const QString &s1, const QString &s2, - Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW + Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept { return s1.compare(s2, cs); } static inline int compare(const QString &s1, QLatin1String s2, - Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW + Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept { return s1.compare(s2, cs); } static inline int compare(QLatin1String s1, const QString &s2, - Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW + Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept { return -s2.compare(s1, cs); } static int compare(const QString &s1, const QStringRef &s2, - Qt::CaseSensitivity = Qt::CaseSensitive) Q_DECL_NOTHROW; + Qt::CaseSensitivity = Qt::CaseSensitive) noexcept; int localeAwareCompare(const QString& s) const; static int localeAwareCompare(const QString& s1, const QString& s2) @@ -671,19 +671,19 @@ public: static QString number(qulonglong, int base=10); static QString number(double, char f='g', int prec=6); - friend Q_CORE_EXPORT bool operator==(const QString &s1, const QString &s2) Q_DECL_NOTHROW; - friend Q_CORE_EXPORT bool operator<(const QString &s1, const QString &s2) Q_DECL_NOTHROW; - friend inline bool operator>(const QString &s1, const QString &s2) Q_DECL_NOTHROW { return s2 < s1; } - friend inline bool operator!=(const QString &s1, const QString &s2) Q_DECL_NOTHROW { return !(s1 == s2); } - friend inline bool operator<=(const QString &s1, const QString &s2) Q_DECL_NOTHROW { return !(s1 > s2); } - friend inline bool operator>=(const QString &s1, const QString &s2) Q_DECL_NOTHROW { return !(s1 < s2); } + friend Q_CORE_EXPORT bool operator==(const QString &s1, const QString &s2) noexcept; + friend Q_CORE_EXPORT bool operator<(const QString &s1, const QString &s2) noexcept; + friend inline bool operator>(const QString &s1, const QString &s2) noexcept { return s2 < s1; } + friend inline bool operator!=(const QString &s1, const QString &s2) noexcept { return !(s1 == s2); } + friend inline bool operator<=(const QString &s1, const QString &s2) noexcept { return !(s1 > s2); } + friend inline bool operator>=(const QString &s1, const QString &s2) noexcept { return !(s1 < s2); } - bool operator==(QLatin1String s) const Q_DECL_NOTHROW; - bool operator<(QLatin1String s) const Q_DECL_NOTHROW; - bool operator>(QLatin1String s) const Q_DECL_NOTHROW; - inline bool operator!=(QLatin1String s) const Q_DECL_NOTHROW { return !operator==(s); } - inline bool operator<=(QLatin1String s) const Q_DECL_NOTHROW { return !operator>(s); } - inline bool operator>=(QLatin1String s) const Q_DECL_NOTHROW { return !operator<(s); } + bool operator==(QLatin1String s) const noexcept; + bool operator<(QLatin1String s) const noexcept; + bool operator>(QLatin1String s) const noexcept; + inline bool operator!=(QLatin1String s) const noexcept { return !operator==(s); } + inline bool operator<=(QLatin1String s) const noexcept { return !operator>(s); } + inline bool operator>=(QLatin1String s) const noexcept { return !operator<(s); } // ASCII compatibility #if defined(QT_RESTRICTED_CAST_FROM_ASCII) @@ -844,15 +844,15 @@ private: Data *d; - friend inline bool operator==(QChar, const QString &) Q_DECL_NOTHROW; - friend inline bool operator< (QChar, const QString &) Q_DECL_NOTHROW; - friend inline bool operator> (QChar, const QString &) Q_DECL_NOTHROW; - friend inline bool operator==(QChar, const QStringRef &) Q_DECL_NOTHROW; - friend inline bool operator< (QChar, const QStringRef &) Q_DECL_NOTHROW; - friend inline bool operator> (QChar, const QStringRef &) Q_DECL_NOTHROW; - friend inline bool operator==(QChar, QLatin1String) Q_DECL_NOTHROW; - friend inline bool operator< (QChar, QLatin1String) Q_DECL_NOTHROW; - friend inline bool operator> (QChar, QLatin1String) Q_DECL_NOTHROW; + friend inline bool operator==(QChar, const QString &) noexcept; + friend inline bool operator< (QChar, const QString &) noexcept; + friend inline bool operator> (QChar, const QString &) noexcept; + friend inline bool operator==(QChar, const QStringRef &) noexcept; + friend inline bool operator< (QChar, const QStringRef &) noexcept; + friend inline bool operator> (QChar, const QStringRef &) noexcept; + friend inline bool operator==(QChar, QLatin1String) noexcept; + friend inline bool operator< (QChar, QLatin1String) noexcept; + friend inline bool operator> (QChar, QLatin1String) noexcept; void reallocData(uint alloc, bool grow = false); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) @@ -861,13 +861,13 @@ private: QString multiArg(int numArgs, const QString **args) const; static int compare_helper(const QChar *data1, int length1, const QChar *data2, int length2, - Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; + Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; static int compare_helper(const QChar *data1, int length1, const char *data2, int length2, Qt::CaseSensitivity cs = Qt::CaseSensitive); static int compare_helper(const QChar *data1, int length1, QLatin1String s2, - Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; + Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; static int localeAwareCompare_helper(const QChar *data1, int length1, const QChar *data2, int length2); static QString toLower_helper(const QString &str); @@ -956,7 +956,7 @@ inline bool QString::isDetached() const { return !d->ref.isShared(); } inline void QString::clear() { if (!isNull()) *this = QString(); } -inline QString::QString(const QString &other) Q_DECL_NOTHROW : d(other.d) +inline QString::QString(const QString &other) noexcept : d(other.d) { Q_ASSERT(&other != this); d->ref.ref(); } inline int QString::capacity() const { return d->alloc ? d->alloc - 1 : 0; } @@ -1128,7 +1128,7 @@ inline void QCharRef::setRow(uchar arow) { QChar(*this).setRow(arow); } inline void QCharRef::setCell(uchar acell) { QChar(*this).setCell(acell); } -inline QString::QString() Q_DECL_NOTHROW : d(Data::sharedNull()) {} +inline QString::QString() noexcept : d(Data::sharedNull()) {} inline QString::~QString() { if (!d->ref.deref()) Data::deallocate(d); } inline void QString::reserve(int asize) @@ -1200,34 +1200,34 @@ QT_DEPRECATED_X("use !QString::isNull()") inline bool operator!=(const QString &s, QString::Null) { return !s.isNull(); } #endif -inline bool operator==(QLatin1String s1, QLatin1String s2) Q_DECL_NOTHROW +inline bool operator==(QLatin1String s1, QLatin1String s2) noexcept { return s1.size() == s2.size() && (!s1.size() || !memcmp(s1.latin1(), s2.latin1(), s1.size())); } -inline bool operator!=(QLatin1String s1, QLatin1String s2) Q_DECL_NOTHROW +inline bool operator!=(QLatin1String s1, QLatin1String s2) noexcept { return !operator==(s1, s2); } -inline bool operator<(QLatin1String s1, QLatin1String s2) Q_DECL_NOTHROW +inline bool operator<(QLatin1String s1, QLatin1String s2) noexcept { const int len = qMin(s1.size(), s2.size()); const int r = len ? memcmp(s1.latin1(), s2.latin1(), len) : 0; return r < 0 || (r == 0 && s1.size() < s2.size()); } -inline bool operator>(QLatin1String s1, QLatin1String s2) Q_DECL_NOTHROW +inline bool operator>(QLatin1String s1, QLatin1String s2) noexcept { return operator<(s2, s1); } -inline bool operator<=(QLatin1String s1, QLatin1String s2) Q_DECL_NOTHROW +inline bool operator<=(QLatin1String s1, QLatin1String s2) noexcept { return !operator>(s1, s2); } -inline bool operator>=(QLatin1String s1, QLatin1String s2) Q_DECL_NOTHROW +inline bool operator>=(QLatin1String s1, QLatin1String s2) noexcept { return !operator<(s1, s2); } -inline bool QLatin1String::operator==(const QString &s) const Q_DECL_NOTHROW +inline bool QLatin1String::operator==(const QString &s) const noexcept { return s == *this; } -inline bool QLatin1String::operator!=(const QString &s) const Q_DECL_NOTHROW +inline bool QLatin1String::operator!=(const QString &s) const noexcept { return s != *this; } -inline bool QLatin1String::operator>(const QString &s) const Q_DECL_NOTHROW +inline bool QLatin1String::operator>(const QString &s) const noexcept { return s < *this; } -inline bool QLatin1String::operator<(const QString &s) const Q_DECL_NOTHROW +inline bool QLatin1String::operator<(const QString &s) const noexcept { return s > *this; } -inline bool QLatin1String::operator>=(const QString &s) const Q_DECL_NOTHROW +inline bool QLatin1String::operator>=(const QString &s) const noexcept { return s <= *this; } -inline bool QLatin1String::operator<=(const QString &s) const Q_DECL_NOTHROW +inline bool QLatin1String::operator<=(const QString &s) const noexcept { return s >= *this; } #if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII) @@ -1434,14 +1434,14 @@ public: #if QT_VERSION < QT_VERSION_CHECK(6,0,0) // ### Qt 6: remove all of these, the implicit ones are fine - QStringRef(const QStringRef &other) Q_DECL_NOTHROW + QStringRef(const QStringRef &other) noexcept :m_string(other.m_string), m_position(other.m_position), m_size(other.m_size) {} #ifdef Q_COMPILER_RVALUE_REFS - QStringRef(QStringRef &&other) Q_DECL_NOTHROW : m_string(other.m_string), m_position(other.m_position), m_size(other.m_size) {} - QStringRef &operator=(QStringRef &&other) Q_DECL_NOTHROW { return *this = other; } + QStringRef(QStringRef &&other) noexcept : m_string(other.m_string), m_position(other.m_position), m_size(other.m_size) {} + QStringRef &operator=(QStringRef &&other) noexcept { return *this = other; } #endif - QStringRef &operator=(const QStringRef &other) Q_DECL_NOTHROW + QStringRef &operator=(const QStringRef &other) noexcept { m_string = other.m_string; m_position = other.m_position; m_size = other.m_size; return *this; @@ -1484,8 +1484,8 @@ public: Q_REQUIRED_RESULT QStringRef chopped(int n) const { Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); return left(size() - n); } - void truncate(int pos) Q_DECL_NOTHROW { m_size = qBound(0, pos, m_size); } - void chop(int n) Q_DECL_NOTHROW + void truncate(int pos) noexcept { m_size = qBound(0, pos, m_size); } + void chop(int n) noexcept { if (n >= m_size) m_size = 0; @@ -1495,7 +1495,7 @@ public: bool isRightToLeft() const; - Q_REQUIRED_RESULT bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::startsWith(*this, s, cs); } bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; bool startsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; @@ -1504,7 +1504,7 @@ public: bool startsWith(const QStringRef &c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; #endif - Q_REQUIRED_RESULT bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::endsWith(*this, s, cs); } bool endsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; bool endsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; @@ -1567,19 +1567,19 @@ public: inline QT_ASCII_CAST_WARN bool operator>=(const char *s) const; #endif - int compare(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW; - int compare(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW; - int compare(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW; + int compare(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; + int compare(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; + int compare(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; #if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII) int compare(const QByteArray &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return QString::compare_helper(unicode(), size(), s.data(), qstrnlen(s.data(), s.size()), cs); } #endif static int compare(const QStringRef &s1, const QString &s2, - Qt::CaseSensitivity = Qt::CaseSensitive) Q_DECL_NOTHROW; + Qt::CaseSensitivity = Qt::CaseSensitive) noexcept; static int compare(const QStringRef &s1, const QStringRef &s2, - Qt::CaseSensitivity = Qt::CaseSensitive) Q_DECL_NOTHROW; + Qt::CaseSensitivity = Qt::CaseSensitive) noexcept; static int compare(const QStringRef &s1, QLatin1String s2, - Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; + Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; int localeAwareCompare(const QString &s) const; int localeAwareCompare(const QStringRef &s) const; @@ -1610,162 +1610,162 @@ inline QStringRef::QStringRef(const QString *aString) :m_string(aString), m_position(0), m_size(aString?aString->size() : 0){} // QStringRef <> QStringRef -Q_CORE_EXPORT bool operator==(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHROW; -inline bool operator!=(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHROW +Q_CORE_EXPORT bool operator==(const QStringRef &s1, const QStringRef &s2) noexcept; +inline bool operator!=(const QStringRef &s1, const QStringRef &s2) noexcept { return !(s1 == s2); } -Q_CORE_EXPORT bool operator<(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHROW; -inline bool operator>(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHROW +Q_CORE_EXPORT bool operator<(const QStringRef &s1, const QStringRef &s2) noexcept; +inline bool operator>(const QStringRef &s1, const QStringRef &s2) noexcept { return s2 < s1; } -inline bool operator<=(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHROW +inline bool operator<=(const QStringRef &s1, const QStringRef &s2) noexcept { return !(s1 > s2); } -inline bool operator>=(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHROW +inline bool operator>=(const QStringRef &s1, const QStringRef &s2) noexcept { return !(s1 < s2); } // QString <> QStringRef -Q_CORE_EXPORT bool operator==(const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW; -inline bool operator!=(const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return lhs.compare(rhs) != 0; } -inline bool operator< (const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return lhs.compare(rhs) < 0; } -inline bool operator> (const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return lhs.compare(rhs) > 0; } -inline bool operator<=(const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return lhs.compare(rhs) <= 0; } -inline bool operator>=(const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return lhs.compare(rhs) >= 0; } +Q_CORE_EXPORT bool operator==(const QString &lhs, const QStringRef &rhs) noexcept; +inline bool operator!=(const QString &lhs, const QStringRef &rhs) noexcept { return lhs.compare(rhs) != 0; } +inline bool operator< (const QString &lhs, const QStringRef &rhs) noexcept { return lhs.compare(rhs) < 0; } +inline bool operator> (const QString &lhs, const QStringRef &rhs) noexcept { return lhs.compare(rhs) > 0; } +inline bool operator<=(const QString &lhs, const QStringRef &rhs) noexcept { return lhs.compare(rhs) <= 0; } +inline bool operator>=(const QString &lhs, const QStringRef &rhs) noexcept { return lhs.compare(rhs) >= 0; } -inline bool operator==(const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs == lhs; } -inline bool operator!=(const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs != lhs; } -inline bool operator< (const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs > lhs; } -inline bool operator> (const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs < lhs; } -inline bool operator<=(const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs >= lhs; } -inline bool operator>=(const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs <= lhs; } +inline bool operator==(const QStringRef &lhs, const QString &rhs) noexcept { return rhs == lhs; } +inline bool operator!=(const QStringRef &lhs, const QString &rhs) noexcept { return rhs != lhs; } +inline bool operator< (const QStringRef &lhs, const QString &rhs) noexcept { return rhs > lhs; } +inline bool operator> (const QStringRef &lhs, const QString &rhs) noexcept { return rhs < lhs; } +inline bool operator<=(const QStringRef &lhs, const QString &rhs) noexcept { return rhs >= lhs; } +inline bool operator>=(const QStringRef &lhs, const QString &rhs) noexcept { return rhs <= lhs; } #if QT_STRINGVIEW_LEVEL < 2 -inline int QString::compare(const QStringRef &s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW +inline int QString::compare(const QStringRef &s, Qt::CaseSensitivity cs) const noexcept { return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); } #endif -inline int QString::compare(QStringView s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW +inline int QString::compare(QStringView s, Qt::CaseSensitivity cs) const noexcept { return -s.compare(*this, cs); } -inline int QString::compare(const QString &s1, const QStringRef &s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +inline int QString::compare(const QString &s1, const QStringRef &s2, Qt::CaseSensitivity cs) noexcept { return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); } -inline int QStringRef::compare(const QString &s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW +inline int QStringRef::compare(const QString &s, Qt::CaseSensitivity cs) const noexcept { return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); } -inline int QStringRef::compare(const QStringRef &s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW +inline int QStringRef::compare(const QStringRef &s, Qt::CaseSensitivity cs) const noexcept { return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); } -inline int QStringRef::compare(QLatin1String s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW +inline int QStringRef::compare(QLatin1String s, Qt::CaseSensitivity cs) const noexcept { return QString::compare_helper(constData(), length(), s, cs); } -inline int QStringRef::compare(const QStringRef &s1, const QString &s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +inline int QStringRef::compare(const QStringRef &s1, const QString &s2, Qt::CaseSensitivity cs) noexcept { return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); } -inline int QStringRef::compare(const QStringRef &s1, const QStringRef &s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +inline int QStringRef::compare(const QStringRef &s1, const QStringRef &s2, Qt::CaseSensitivity cs) noexcept { return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); } -inline int QStringRef::compare(const QStringRef &s1, QLatin1String s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW +inline int QStringRef::compare(const QStringRef &s1, QLatin1String s2, Qt::CaseSensitivity cs) noexcept { return QString::compare_helper(s1.constData(), s1.length(), s2, cs); } // QLatin1String <> QStringRef -Q_CORE_EXPORT bool operator==(QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW; -inline bool operator!=(QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return rhs.compare(lhs) != 0; } -inline bool operator< (QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return rhs.compare(lhs) > 0; } -inline bool operator> (QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return rhs.compare(lhs) < 0; } -inline bool operator<=(QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return rhs.compare(lhs) >= 0; } -inline bool operator>=(QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return rhs.compare(lhs) <= 0; } +Q_CORE_EXPORT bool operator==(QLatin1String lhs, const QStringRef &rhs) noexcept; +inline bool operator!=(QLatin1String lhs, const QStringRef &rhs) noexcept { return rhs.compare(lhs) != 0; } +inline bool operator< (QLatin1String lhs, const QStringRef &rhs) noexcept { return rhs.compare(lhs) > 0; } +inline bool operator> (QLatin1String lhs, const QStringRef &rhs) noexcept { return rhs.compare(lhs) < 0; } +inline bool operator<=(QLatin1String lhs, const QStringRef &rhs) noexcept { return rhs.compare(lhs) >= 0; } +inline bool operator>=(QLatin1String lhs, const QStringRef &rhs) noexcept { return rhs.compare(lhs) <= 0; } -inline bool operator==(const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs == lhs; } -inline bool operator!=(const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs != lhs; } -inline bool operator< (const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs > lhs; } -inline bool operator> (const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs < lhs; } -inline bool operator<=(const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs >= lhs; } -inline bool operator>=(const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs <= lhs; } +inline bool operator==(const QStringRef &lhs, QLatin1String rhs) noexcept { return rhs == lhs; } +inline bool operator!=(const QStringRef &lhs, QLatin1String rhs) noexcept { return rhs != lhs; } +inline bool operator< (const QStringRef &lhs, QLatin1String rhs) noexcept { return rhs > lhs; } +inline bool operator> (const QStringRef &lhs, QLatin1String rhs) noexcept { return rhs < lhs; } +inline bool operator<=(const QStringRef &lhs, QLatin1String rhs) noexcept { return rhs >= lhs; } +inline bool operator>=(const QStringRef &lhs, QLatin1String rhs) noexcept { return rhs <= lhs; } // QChar <> QString -inline bool operator==(QChar lhs, const QString &rhs) Q_DECL_NOTHROW +inline bool operator==(QChar lhs, const QString &rhs) noexcept { return rhs.size() == 1 && lhs == rhs.front(); } -inline bool operator< (QChar lhs, const QString &rhs) Q_DECL_NOTHROW +inline bool operator< (QChar lhs, const QString &rhs) noexcept { return QString::compare_helper(&lhs, 1, rhs.data(), rhs.size()) < 0; } -inline bool operator> (QChar lhs, const QString &rhs) Q_DECL_NOTHROW +inline bool operator> (QChar lhs, const QString &rhs) noexcept { return QString::compare_helper(&lhs, 1, rhs.data(), rhs.size()) > 0; } -inline bool operator!=(QChar lhs, const QString &rhs) Q_DECL_NOTHROW { return !(lhs == rhs); } -inline bool operator<=(QChar lhs, const QString &rhs) Q_DECL_NOTHROW { return !(lhs > rhs); } -inline bool operator>=(QChar lhs, const QString &rhs) Q_DECL_NOTHROW { return !(lhs < rhs); } +inline bool operator!=(QChar lhs, const QString &rhs) noexcept { return !(lhs == rhs); } +inline bool operator<=(QChar lhs, const QString &rhs) noexcept { return !(lhs > rhs); } +inline bool operator>=(QChar lhs, const QString &rhs) noexcept { return !(lhs < rhs); } -inline bool operator==(const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs == lhs; } -inline bool operator!=(const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs == lhs); } -inline bool operator< (const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs > lhs; } -inline bool operator> (const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs < lhs; } -inline bool operator<=(const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs < lhs); } -inline bool operator>=(const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs > lhs); } +inline bool operator==(const QString &lhs, QChar rhs) noexcept { return rhs == lhs; } +inline bool operator!=(const QString &lhs, QChar rhs) noexcept { return !(rhs == lhs); } +inline bool operator< (const QString &lhs, QChar rhs) noexcept { return rhs > lhs; } +inline bool operator> (const QString &lhs, QChar rhs) noexcept { return rhs < lhs; } +inline bool operator<=(const QString &lhs, QChar rhs) noexcept { return !(rhs < lhs); } +inline bool operator>=(const QString &lhs, QChar rhs) noexcept { return !(rhs > lhs); } // QChar <> QStringRef -inline bool operator==(QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW +inline bool operator==(QChar lhs, const QStringRef &rhs) noexcept { return rhs.size() == 1 && lhs == rhs.front(); } -inline bool operator< (QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW +inline bool operator< (QChar lhs, const QStringRef &rhs) noexcept { return QString::compare_helper(&lhs, 1, rhs.data(), rhs.size()) < 0; } -inline bool operator> (QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW +inline bool operator> (QChar lhs, const QStringRef &rhs) noexcept { return QString::compare_helper(&lhs, 1, rhs.data(), rhs.size()) > 0; } -inline bool operator!=(QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return !(lhs == rhs); } -inline bool operator<=(QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return !(lhs > rhs); } -inline bool operator>=(QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return !(lhs < rhs); } +inline bool operator!=(QChar lhs, const QStringRef &rhs) noexcept { return !(lhs == rhs); } +inline bool operator<=(QChar lhs, const QStringRef &rhs) noexcept { return !(lhs > rhs); } +inline bool operator>=(QChar lhs, const QStringRef &rhs) noexcept { return !(lhs < rhs); } -inline bool operator==(const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs == lhs; } -inline bool operator!=(const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs == lhs); } -inline bool operator< (const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs > lhs; } -inline bool operator> (const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs < lhs; } -inline bool operator<=(const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs < lhs); } -inline bool operator>=(const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs > lhs); } +inline bool operator==(const QStringRef &lhs, QChar rhs) noexcept { return rhs == lhs; } +inline bool operator!=(const QStringRef &lhs, QChar rhs) noexcept { return !(rhs == lhs); } +inline bool operator< (const QStringRef &lhs, QChar rhs) noexcept { return rhs > lhs; } +inline bool operator> (const QStringRef &lhs, QChar rhs) noexcept { return rhs < lhs; } +inline bool operator<=(const QStringRef &lhs, QChar rhs) noexcept { return !(rhs < lhs); } +inline bool operator>=(const QStringRef &lhs, QChar rhs) noexcept { return !(rhs > lhs); } // QChar <> QLatin1String -inline bool operator==(QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW +inline bool operator==(QChar lhs, QLatin1String rhs) noexcept { return rhs.size() == 1 && lhs == rhs.front(); } -inline bool operator< (QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW +inline bool operator< (QChar lhs, QLatin1String rhs) noexcept { return QString::compare_helper(&lhs, 1, rhs) < 0; } -inline bool operator> (QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW +inline bool operator> (QChar lhs, QLatin1String rhs) noexcept { return QString::compare_helper(&lhs, 1, rhs) > 0; } -inline bool operator!=(QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW { return !(lhs == rhs); } -inline bool operator<=(QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW { return !(lhs > rhs); } -inline bool operator>=(QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW { return !(lhs < rhs); } +inline bool operator!=(QChar lhs, QLatin1String rhs) noexcept { return !(lhs == rhs); } +inline bool operator<=(QChar lhs, QLatin1String rhs) noexcept { return !(lhs > rhs); } +inline bool operator>=(QChar lhs, QLatin1String rhs) noexcept { return !(lhs < rhs); } -inline bool operator==(QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return rhs == lhs; } -inline bool operator!=(QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs == lhs); } -inline bool operator< (QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return rhs > lhs; } -inline bool operator> (QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return rhs < lhs; } -inline bool operator<=(QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs < lhs); } -inline bool operator>=(QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs > lhs); } +inline bool operator==(QLatin1String lhs, QChar rhs) noexcept { return rhs == lhs; } +inline bool operator!=(QLatin1String lhs, QChar rhs) noexcept { return !(rhs == lhs); } +inline bool operator< (QLatin1String lhs, QChar rhs) noexcept { return rhs > lhs; } +inline bool operator> (QLatin1String lhs, QChar rhs) noexcept { return rhs < lhs; } +inline bool operator<=(QLatin1String lhs, QChar rhs) noexcept { return !(rhs < lhs); } +inline bool operator>=(QLatin1String lhs, QChar rhs) noexcept { return !(rhs > lhs); } // QStringView <> QStringView -inline bool operator==(QStringView lhs, QStringView rhs) Q_DECL_NOTHROW { return lhs.size() == rhs.size() && QtPrivate::compareStrings(lhs, rhs) == 0; } -inline bool operator!=(QStringView lhs, QStringView rhs) Q_DECL_NOTHROW { return !(lhs == rhs); } -inline bool operator< (QStringView lhs, QStringView rhs) Q_DECL_NOTHROW { return QtPrivate::compareStrings(lhs, rhs) < 0; } -inline bool operator<=(QStringView lhs, QStringView rhs) Q_DECL_NOTHROW { return QtPrivate::compareStrings(lhs, rhs) <= 0; } -inline bool operator> (QStringView lhs, QStringView rhs) Q_DECL_NOTHROW { return QtPrivate::compareStrings(lhs, rhs) > 0; } -inline bool operator>=(QStringView lhs, QStringView rhs) Q_DECL_NOTHROW { return QtPrivate::compareStrings(lhs, rhs) >= 0; } +inline bool operator==(QStringView lhs, QStringView rhs) noexcept { return lhs.size() == rhs.size() && QtPrivate::compareStrings(lhs, rhs) == 0; } +inline bool operator!=(QStringView lhs, QStringView rhs) noexcept { return !(lhs == rhs); } +inline bool operator< (QStringView lhs, QStringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) < 0; } +inline bool operator<=(QStringView lhs, QStringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) <= 0; } +inline bool operator> (QStringView lhs, QStringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) > 0; } +inline bool operator>=(QStringView lhs, QStringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) >= 0; } // QStringView <> QChar -inline bool operator==(QStringView lhs, QChar rhs) Q_DECL_NOTHROW { return lhs == QStringView(&rhs, 1); } -inline bool operator!=(QStringView lhs, QChar rhs) Q_DECL_NOTHROW { return lhs != QStringView(&rhs, 1); } -inline bool operator< (QStringView lhs, QChar rhs) Q_DECL_NOTHROW { return lhs < QStringView(&rhs, 1); } -inline bool operator<=(QStringView lhs, QChar rhs) Q_DECL_NOTHROW { return lhs <= QStringView(&rhs, 1); } -inline bool operator> (QStringView lhs, QChar rhs) Q_DECL_NOTHROW { return lhs > QStringView(&rhs, 1); } -inline bool operator>=(QStringView lhs, QChar rhs) Q_DECL_NOTHROW { return lhs >= QStringView(&rhs, 1); } +inline bool operator==(QStringView lhs, QChar rhs) noexcept { return lhs == QStringView(&rhs, 1); } +inline bool operator!=(QStringView lhs, QChar rhs) noexcept { return lhs != QStringView(&rhs, 1); } +inline bool operator< (QStringView lhs, QChar rhs) noexcept { return lhs < QStringView(&rhs, 1); } +inline bool operator<=(QStringView lhs, QChar rhs) noexcept { return lhs <= QStringView(&rhs, 1); } +inline bool operator> (QStringView lhs, QChar rhs) noexcept { return lhs > QStringView(&rhs, 1); } +inline bool operator>=(QStringView lhs, QChar rhs) noexcept { return lhs >= QStringView(&rhs, 1); } -inline bool operator==(QChar lhs, QStringView rhs) Q_DECL_NOTHROW { return QStringView(&lhs, 1) == rhs; } -inline bool operator!=(QChar lhs, QStringView rhs) Q_DECL_NOTHROW { return QStringView(&lhs, 1) != rhs; } -inline bool operator< (QChar lhs, QStringView rhs) Q_DECL_NOTHROW { return QStringView(&lhs, 1) < rhs; } -inline bool operator<=(QChar lhs, QStringView rhs) Q_DECL_NOTHROW { return QStringView(&lhs, 1) <= rhs; } -inline bool operator> (QChar lhs, QStringView rhs) Q_DECL_NOTHROW { return QStringView(&lhs, 1) > rhs; } -inline bool operator>=(QChar lhs, QStringView rhs) Q_DECL_NOTHROW { return QStringView(&lhs, 1) >= rhs; } +inline bool operator==(QChar lhs, QStringView rhs) noexcept { return QStringView(&lhs, 1) == rhs; } +inline bool operator!=(QChar lhs, QStringView rhs) noexcept { return QStringView(&lhs, 1) != rhs; } +inline bool operator< (QChar lhs, QStringView rhs) noexcept { return QStringView(&lhs, 1) < rhs; } +inline bool operator<=(QChar lhs, QStringView rhs) noexcept { return QStringView(&lhs, 1) <= rhs; } +inline bool operator> (QChar lhs, QStringView rhs) noexcept { return QStringView(&lhs, 1) > rhs; } +inline bool operator>=(QChar lhs, QStringView rhs) noexcept { return QStringView(&lhs, 1) >= rhs; } // QStringView <> QLatin1String -inline bool operator==(QStringView lhs, QLatin1String rhs) Q_DECL_NOTHROW { return lhs.size() == rhs.size() && QtPrivate::compareStrings(lhs, rhs) == 0; } -inline bool operator!=(QStringView lhs, QLatin1String rhs) Q_DECL_NOTHROW { return !(lhs == rhs); } -inline bool operator< (QStringView lhs, QLatin1String rhs) Q_DECL_NOTHROW { return QtPrivate::compareStrings(lhs, rhs) < 0; } -inline bool operator<=(QStringView lhs, QLatin1String rhs) Q_DECL_NOTHROW { return QtPrivate::compareStrings(lhs, rhs) <= 0; } -inline bool operator> (QStringView lhs, QLatin1String rhs) Q_DECL_NOTHROW { return QtPrivate::compareStrings(lhs, rhs) > 0; } -inline bool operator>=(QStringView lhs, QLatin1String rhs) Q_DECL_NOTHROW { return QtPrivate::compareStrings(lhs, rhs) >= 0; } +inline bool operator==(QStringView lhs, QLatin1String rhs) noexcept { return lhs.size() == rhs.size() && QtPrivate::compareStrings(lhs, rhs) == 0; } +inline bool operator!=(QStringView lhs, QLatin1String rhs) noexcept { return !(lhs == rhs); } +inline bool operator< (QStringView lhs, QLatin1String rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) < 0; } +inline bool operator<=(QStringView lhs, QLatin1String rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) <= 0; } +inline bool operator> (QStringView lhs, QLatin1String rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) > 0; } +inline bool operator>=(QStringView lhs, QLatin1String rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) >= 0; } -inline bool operator==(QLatin1String lhs, QStringView rhs) Q_DECL_NOTHROW { return lhs.size() == rhs.size() && QtPrivate::compareStrings(lhs, rhs) == 0; } -inline bool operator!=(QLatin1String lhs, QStringView rhs) Q_DECL_NOTHROW { return !(lhs == rhs); } -inline bool operator< (QLatin1String lhs, QStringView rhs) Q_DECL_NOTHROW { return QtPrivate::compareStrings(lhs, rhs) < 0; } -inline bool operator<=(QLatin1String lhs, QStringView rhs) Q_DECL_NOTHROW { return QtPrivate::compareStrings(lhs, rhs) <= 0; } -inline bool operator> (QLatin1String lhs, QStringView rhs) Q_DECL_NOTHROW { return QtPrivate::compareStrings(lhs, rhs) > 0; } -inline bool operator>=(QLatin1String lhs, QStringView rhs) Q_DECL_NOTHROW { return QtPrivate::compareStrings(lhs, rhs) >= 0; } +inline bool operator==(QLatin1String lhs, QStringView rhs) noexcept { return lhs.size() == rhs.size() && QtPrivate::compareStrings(lhs, rhs) == 0; } +inline bool operator!=(QLatin1String lhs, QStringView rhs) noexcept { return !(lhs == rhs); } +inline bool operator< (QLatin1String lhs, QStringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) < 0; } +inline bool operator<=(QLatin1String lhs, QStringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) <= 0; } +inline bool operator> (QLatin1String lhs, QStringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) > 0; } +inline bool operator>=(QLatin1String lhs, QStringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) >= 0; } #if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII) // QStringRef <> QByteArray diff --git a/src/corelib/tools/qstringalgorithms.h b/src/corelib/tools/qstringalgorithms.h index e94f725598..8e7fc0af9b 100644 --- a/src/corelib/tools/qstringalgorithms.h +++ b/src/corelib/tools/qstringalgorithms.h @@ -56,31 +56,31 @@ template class QVector; namespace QtPrivate { -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype qustrlen(const ushort *str) Q_DECL_NOTHROW; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype qustrlen(const ushort *str) noexcept; Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION const ushort *qustrchr(QStringView str, ushort ch) noexcept; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QLatin1String rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QLatin1String lhs, QStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QLatin1String lhs, QLatin1String rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QLatin1String rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QLatin1String lhs, QStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QLatin1String lhs, QLatin1String rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findChar(QStringView str, QChar ch, qsizetype from, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findString(QStringView haystack, qsizetype from, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findString(QStringView haystack, qsizetype from, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findChar(QStringView str, QChar ch, qsizetype from, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findString(QStringView haystack, qsizetype from, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findString(QStringView haystack, qsizetype from, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION QStringView trimmed(QStringView s) Q_DECL_NOTHROW; -Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION QLatin1String trimmed(QLatin1String s) Q_DECL_NOTHROW; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION QStringView trimmed(QStringView s) noexcept; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION QLatin1String trimmed(QLatin1String s) noexcept; Q_REQUIRED_RESULT Q_CORE_EXPORT QByteArray convertToLatin1(QStringView str); Q_REQUIRED_RESULT Q_CORE_EXPORT QByteArray convertToUtf8(QStringView str); @@ -88,10 +88,10 @@ Q_REQUIRED_RESULT Q_CORE_EXPORT QByteArray convertToLocal8Bit(QStringView str); Q_REQUIRED_RESULT Q_CORE_EXPORT QVector convertToUcs4(QStringView str); Q_REQUIRED_RESULT Q_CORE_EXPORT bool isRightToLeft(QStringView string); -Q_REQUIRED_RESULT Q_CORE_EXPORT bool isAscii(QLatin1String s) Q_DECL_NOTHROW; -Q_REQUIRED_RESULT Q_CORE_EXPORT bool isAscii(QStringView s) Q_DECL_NOTHROW; -Q_REQUIRED_RESULT bool isLatin1(QLatin1String s) Q_DECL_NOTHROW; // in qstring.h -Q_REQUIRED_RESULT Q_CORE_EXPORT bool isLatin1(QStringView s) Q_DECL_NOTHROW; +Q_REQUIRED_RESULT Q_CORE_EXPORT bool isAscii(QLatin1String s) noexcept; +Q_REQUIRED_RESULT Q_CORE_EXPORT bool isAscii(QStringView s) noexcept; +Q_REQUIRED_RESULT bool isLatin1(QLatin1String s) noexcept; // in qstring.h +Q_REQUIRED_RESULT Q_CORE_EXPORT bool isLatin1(QStringView s) noexcept; } // namespace QtPRivate diff --git a/src/corelib/tools/qstringbuilder.cpp b/src/corelib/tools/qstringbuilder.cpp index 8afc83819b..cf443ec369 100644 --- a/src/corelib/tools/qstringbuilder.cpp +++ b/src/corelib/tools/qstringbuilder.cpp @@ -124,7 +124,7 @@ QT_BEGIN_NAMESPACE /*! \internal */ -void QAbstractConcatenable::convertFromAscii(const char *a, int len, QChar *&out) Q_DECL_NOTHROW +void QAbstractConcatenable::convertFromAscii(const char *a, int len, QChar *&out) noexcept { if (Q_UNLIKELY(len == -1)) { if (!a) diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h index 1d96d70637..79ed10c7a8 100644 --- a/src/corelib/tools/qstringbuilder.h +++ b/src/corelib/tools/qstringbuilder.h @@ -58,12 +58,12 @@ QT_BEGIN_NAMESPACE struct Q_CORE_EXPORT QAbstractConcatenable { protected: - static void convertFromAscii(const char *a, int len, QChar *&out) Q_DECL_NOTHROW; - static inline void convertFromAscii(char a, QChar *&out) Q_DECL_NOTHROW + static void convertFromAscii(const char *a, int len, QChar *&out) noexcept; + static inline void convertFromAscii(char a, QChar *&out) noexcept { *out++ = QLatin1Char(a); } - static void appendLatin1To(const char *a, int len, QChar *out) Q_DECL_NOTHROW; + static void appendLatin1To(const char *a, int len, QChar *out) noexcept; }; template struct QConcatenable {}; diff --git a/src/corelib/tools/qstringlist.h b/src/corelib/tools/qstringlist.h index b6c48488df..6387161269 100644 --- a/src/corelib/tools/qstringlist.h +++ b/src/corelib/tools/qstringlist.h @@ -100,11 +100,11 @@ class QStringList : public QList { #endif public: - inline QStringList() Q_DECL_NOTHROW { } + inline QStringList() noexcept { } inline explicit QStringList(const QString &i) { append(i); } inline QStringList(const QList &l) : QList(l) { } #ifdef Q_COMPILER_RVALUE_REFS - inline QStringList(QList &&l) Q_DECL_NOTHROW : QList(std::move(l)) { } + inline QStringList(QList &&l) noexcept : QList(std::move(l)) { } #endif #ifdef Q_COMPILER_INITIALIZER_LISTS inline QStringList(std::initializer_list args) : QList(args) { } @@ -113,7 +113,7 @@ public: QStringList &operator=(const QList &other) { QList::operator=(other); return *this; } #ifdef Q_COMPILER_RVALUE_REFS - QStringList &operator=(QList &&other) Q_DECL_NOTHROW + QStringList &operator=(QList &&other) noexcept { QList::operator=(std::move(other)); return *this; } #endif diff --git a/src/corelib/tools/qstringliteral.h b/src/corelib/tools/qstringliteral.h index 64296b89fc..603f19c0b4 100644 --- a/src/corelib/tools/qstringliteral.h +++ b/src/corelib/tools/qstringliteral.h @@ -63,7 +63,7 @@ Q_STATIC_ASSERT_X(sizeof(qunicodechar) == 2, #define QT_UNICODE_LITERAL(str) u"" str #define QStringLiteral(str) \ - ([]() Q_DECL_NOEXCEPT -> QString { \ + ([]() noexcept -> QString { \ enum { Size = sizeof(QT_UNICODE_LITERAL(str))/2 - 1 }; \ static const QStaticStringData qstring_literal = { \ Q_STATIC_STRING_DATA_HEADER_INITIALIZER(Size), \ diff --git a/src/corelib/tools/qstringview.h b/src/corelib/tools/qstringview.h index 4a900b5e89..5b6d63b71c 100644 --- a/src/corelib/tools/qstringview.h +++ b/src/corelib/tools/qstringview.h @@ -139,13 +139,13 @@ private: using if_compatible_qstring_like = typename std::enable_if::value || std::is_same::value, bool>::type; template - static Q_DECL_CONSTEXPR qsizetype lengthHelperArray(const Char (&)[N]) Q_DECL_NOTHROW + static Q_DECL_CONSTEXPR qsizetype lengthHelperArray(const Char (&)[N]) noexcept { return qsizetype(N - 1); } template - static qsizetype lengthHelperPointer(const Char *str) Q_DECL_NOTHROW + static qsizetype lengthHelperPointer(const Char *str) noexcept { #if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) if (__builtin_constant_p(*str)) { @@ -157,21 +157,21 @@ private: #endif return QtPrivate::qustrlen(reinterpret_cast(str)); } - static qsizetype lengthHelperPointer(const QChar *str) Q_DECL_NOTHROW + static qsizetype lengthHelperPointer(const QChar *str) noexcept { return QtPrivate::qustrlen(reinterpret_cast(str)); } template - static const storage_type *castHelper(const Char *str) Q_DECL_NOTHROW + static const storage_type *castHelper(const Char *str) noexcept { return reinterpret_cast(str); } - static Q_DECL_CONSTEXPR const storage_type *castHelper(const storage_type *str) Q_DECL_NOTHROW + static Q_DECL_CONSTEXPR const storage_type *castHelper(const storage_type *str) noexcept { return str; } public: - Q_DECL_CONSTEXPR QStringView() Q_DECL_NOTHROW + Q_DECL_CONSTEXPR QStringView() noexcept : m_size(0), m_data(nullptr) {} - Q_DECL_CONSTEXPR QStringView(std::nullptr_t) Q_DECL_NOTHROW + Q_DECL_CONSTEXPR QStringView(std::nullptr_t) noexcept : QStringView() {} template = true> @@ -185,38 +185,38 @@ public: #ifdef Q_CLANG_QDOC template - Q_DECL_CONSTEXPR QStringView(const Char (&array)[N]) Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR QStringView(const Char (&array)[N]) noexcept; template - Q_DECL_CONSTEXPR QStringView(const Char *str) Q_DECL_NOTHROW; + Q_DECL_CONSTEXPR QStringView(const Char *str) noexcept; #else template = true> - Q_DECL_CONSTEXPR QStringView(const Array &str) Q_DECL_NOTHROW + Q_DECL_CONSTEXPR QStringView(const Array &str) noexcept : QStringView(str, lengthHelperArray(str)) {} template = true> - Q_DECL_CONSTEXPR QStringView(const Pointer &str) Q_DECL_NOTHROW + Q_DECL_CONSTEXPR QStringView(const Pointer &str) noexcept : QStringView(str, str ? lengthHelperPointer(str) : 0) {} #endif #ifdef Q_CLANG_QDOC - QStringView(const QString &str) Q_DECL_NOTHROW; - QStringView(const QStringRef &str) Q_DECL_NOTHROW; + QStringView(const QString &str) noexcept; + QStringView(const QStringRef &str) noexcept; #else template = true> - QStringView(const String &str) Q_DECL_NOTHROW + QStringView(const String &str) noexcept : QStringView(str.isNull() ? nullptr : str.data(), qsizetype(str.size())) {} #endif template = true> - QStringView(const StdBasicString &str) Q_DECL_NOTHROW + QStringView(const StdBasicString &str) noexcept : QStringView(str.data(), qsizetype(str.size())) {} Q_REQUIRED_RESULT inline QString toString() const; // defined in qstring.h - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR qsizetype size() const Q_DECL_NOTHROW { return m_size; } - Q_REQUIRED_RESULT const_pointer data() const Q_DECL_NOTHROW { return reinterpret_cast(m_data); } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR const storage_type *utf16() const Q_DECL_NOTHROW { return m_data; } + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR qsizetype size() const noexcept { return m_size; } + Q_REQUIRED_RESULT const_pointer data() const noexcept { return reinterpret_cast(m_data); } + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR const storage_type *utf16() const noexcept { return m_data; } Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar operator[](qsizetype n) const { return Q_ASSERT(n >= 0), Q_ASSERT(n < size()), QChar(m_data[n]); } @@ -248,28 +248,28 @@ public: Q_DECL_RELAXED_CONSTEXPR void chop(qsizetype n) { Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); m_size -= n; } - Q_REQUIRED_RESULT QStringView trimmed() const Q_DECL_NOTHROW { return QtPrivate::trimmed(*this); } + Q_REQUIRED_RESULT QStringView trimmed() const noexcept { return QtPrivate::trimmed(*this); } - Q_REQUIRED_RESULT int compare(QStringView other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT int compare(QStringView other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::compareStrings(*this, other, cs); } - Q_REQUIRED_RESULT bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::startsWith(*this, s, cs); } - Q_REQUIRED_RESULT inline bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT bool startsWith(QChar c) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT inline bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; + Q_REQUIRED_RESULT bool startsWith(QChar c) const noexcept { return !empty() && front() == c; } - Q_REQUIRED_RESULT bool startsWith(QChar c, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT bool startsWith(QChar c, Qt::CaseSensitivity cs) const noexcept { return QtPrivate::startsWith(*this, QStringView(&c, 1), cs); } - Q_REQUIRED_RESULT bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::endsWith(*this, s, cs); } - Q_REQUIRED_RESULT inline bool endsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT bool endsWith(QChar c) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT inline bool endsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; + Q_REQUIRED_RESULT bool endsWith(QChar c) const noexcept { return !empty() && back() == c; } - Q_REQUIRED_RESULT bool endsWith(QChar c, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT bool endsWith(QChar c, Qt::CaseSensitivity cs) const noexcept { return QtPrivate::endsWith(*this, QStringView(&c, 1), cs); } - Q_REQUIRED_RESULT bool isRightToLeft() const Q_DECL_NOTHROW + Q_REQUIRED_RESULT bool isRightToLeft() const noexcept { return QtPrivate::isRightToLeft(*this); } Q_REQUIRED_RESULT Q_CORE_EXPORT int toWCharArray(wchar_t *array) const; @@ -277,24 +277,24 @@ public: // // STL compatibility API: // - Q_REQUIRED_RESULT const_iterator begin() const Q_DECL_NOTHROW { return data(); } - Q_REQUIRED_RESULT const_iterator end() const Q_DECL_NOTHROW { return data() + size(); } - Q_REQUIRED_RESULT const_iterator cbegin() const Q_DECL_NOTHROW { return begin(); } - Q_REQUIRED_RESULT const_iterator cend() const Q_DECL_NOTHROW { return end(); } - Q_REQUIRED_RESULT const_reverse_iterator rbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); } - Q_REQUIRED_RESULT const_reverse_iterator rend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); } - Q_REQUIRED_RESULT const_reverse_iterator crbegin() const Q_DECL_NOTHROW { return rbegin(); } - Q_REQUIRED_RESULT const_reverse_iterator crend() const Q_DECL_NOTHROW { return rend(); } + Q_REQUIRED_RESULT const_iterator begin() const noexcept { return data(); } + Q_REQUIRED_RESULT const_iterator end() const noexcept { return data() + size(); } + Q_REQUIRED_RESULT const_iterator cbegin() const noexcept { return begin(); } + Q_REQUIRED_RESULT const_iterator cend() const noexcept { return end(); } + Q_REQUIRED_RESULT const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } + Q_REQUIRED_RESULT const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } + Q_REQUIRED_RESULT const_reverse_iterator crbegin() const noexcept { return rbegin(); } + Q_REQUIRED_RESULT const_reverse_iterator crend() const noexcept { return rend(); } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR bool empty() const Q_DECL_NOTHROW { return size() == 0; } + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR bool empty() const noexcept { return size() == 0; } Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar front() const { return Q_ASSERT(!empty()), QChar(m_data[0]); } Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar back() const { return Q_ASSERT(!empty()), QChar(m_data[m_size - 1]); } // // Qt compatibility API: // - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR bool isNull() const Q_DECL_NOTHROW { return !m_data; } - Q_REQUIRED_RESULT Q_DECL_CONSTEXPR bool isEmpty() const Q_DECL_NOTHROW { return empty(); } + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR bool isNull() const noexcept { return !m_data; } + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR bool isEmpty() const noexcept { return empty(); } Q_REQUIRED_RESULT Q_DECL_CONSTEXPR int length() const /* not nothrow! */ { return Q_ASSERT(int(size()) == size()), int(size()); } Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QChar first() const { return front(); } @@ -308,7 +308,7 @@ Q_DECLARE_TYPEINFO(QStringView, Q_PRIMITIVE_TYPE); template ::value || std::is_same::value, bool>::type = true> -inline QStringView qToStringViewIgnoringNull(const QStringLike &s) Q_DECL_NOTHROW +inline QStringView qToStringViewIgnoringNull(const QStringLike &s) noexcept { return QStringView(s.data(), s.size()); } QT_END_NAMESPACE diff --git a/src/corelib/tools/qtimezone.cpp b/src/corelib/tools/qtimezone.cpp index cbc6b50c98..ef323de14a 100644 --- a/src/corelib/tools/qtimezone.cpp +++ b/src/corelib/tools/qtimezone.cpp @@ -317,7 +317,7 @@ Q_GLOBAL_STATIC(QTimeZoneSingleton, global_tz); Create a null/invalid time zone instance. */ -QTimeZone::QTimeZone() Q_DECL_NOTHROW +QTimeZone::QTimeZone() noexcept : d(0) { } diff --git a/src/corelib/tools/qtimezone.h b/src/corelib/tools/qtimezone.h index 29d8a4dbe5..ca98986ec1 100644 --- a/src/corelib/tools/qtimezone.h +++ b/src/corelib/tools/qtimezone.h @@ -89,7 +89,7 @@ public: }; typedef QVector OffsetDataList; - QTimeZone() Q_DECL_NOTHROW; + QTimeZone() noexcept; explicit QTimeZone(const QByteArray &ianaId); explicit QTimeZone(int offsetSeconds); /*implicit*/ QTimeZone(const QByteArray &zoneId, int offsetSeconds, const QString &name, @@ -100,10 +100,10 @@ public: QTimeZone &operator=(const QTimeZone &other); #ifdef Q_COMPILER_RVALUE_REFS - QTimeZone &operator=(QTimeZone &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QTimeZone &operator=(QTimeZone &&other) noexcept { swap(other); return *this; } #endif - void swap(QTimeZone &other) Q_DECL_NOTHROW + void swap(QTimeZone &other) noexcept { d.swap(other.d); } bool operator==(const QTimeZone &other) const; diff --git a/src/corelib/tools/qtimezoneprivate_p.h b/src/corelib/tools/qtimezoneprivate_p.h index 24a9a00f11..b5e9286f6a 100644 --- a/src/corelib/tools/qtimezoneprivate_p.h +++ b/src/corelib/tools/qtimezoneprivate_p.h @@ -282,9 +282,9 @@ struct QTzTransitionRule quint8 abbreviationIndex; }; Q_DECLARE_TYPEINFO(QTzTransitionRule, Q_PRIMITIVE_TYPE); -Q_DECL_CONSTEXPR inline bool operator==(const QTzTransitionRule &lhs, const QTzTransitionRule &rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator==(const QTzTransitionRule &lhs, const QTzTransitionRule &rhs) noexcept { return lhs.stdOffset == rhs.stdOffset && lhs.dstOffset == rhs.dstOffset && lhs.abbreviationIndex == rhs.abbreviationIndex; } -Q_DECL_CONSTEXPR inline bool operator!=(const QTzTransitionRule &lhs, const QTzTransitionRule &rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator!=(const QTzTransitionRule &lhs, const QTzTransitionRule &rhs) noexcept { return !operator==(lhs, rhs); } class Q_AUTOTEST_EXPORT QTzTimeZonePrivate final : public QTimeZonePrivate diff --git a/src/corelib/tools/qtimezoneprivate_tz.cpp b/src/corelib/tools/qtimezoneprivate_tz.cpp index f75a61977d..6105c93a23 100644 --- a/src/corelib/tools/qtimezoneprivate_tz.cpp +++ b/src/corelib/tools/qtimezoneprivate_tz.cpp @@ -467,7 +467,7 @@ struct PosixZone static PosixZone invalid() { return {QString(), InvalidOffset}; } static PosixZone parse(const char *&pos, const char *end); - bool hasValidOffset() const Q_DECL_NOTHROW { return offset != InvalidOffset; } + bool hasValidOffset() const noexcept { return offset != InvalidOffset; } }; } // unnamed namespace diff --git a/src/corelib/tools/qtools_p.h b/src/corelib/tools/qtools_p.h index 17d2ab852a..b239987871 100644 --- a/src/corelib/tools/qtools_p.h +++ b/src/corelib/tools/qtools_p.h @@ -57,17 +57,17 @@ QT_BEGIN_NAMESPACE namespace QtMiscUtils { -Q_DECL_CONSTEXPR inline char toHexUpper(uint value) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline char toHexUpper(uint value) noexcept { return "0123456789ABCDEF"[value & 0xF]; } -Q_DECL_CONSTEXPR inline char toHexLower(uint value) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline char toHexLower(uint value) noexcept { return "0123456789abcdef"[value & 0xF]; } -Q_DECL_CONSTEXPR inline int fromHex(uint c) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int fromHex(uint c) noexcept { return ((c >= '0') && (c <= '9')) ? int(c - '0') : ((c >= 'A') && (c <= 'F')) ? int(c - 'A' + 10) : @@ -75,12 +75,12 @@ Q_DECL_CONSTEXPR inline int fromHex(uint c) Q_DECL_NOTHROW /* otherwise */ -1; } -Q_DECL_CONSTEXPR inline char toOct(uint value) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline char toOct(uint value) noexcept { return '0' + char(value & 0x7); } -Q_DECL_CONSTEXPR inline int fromOct(uint c) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline int fromOct(uint c) noexcept { return ((c >= '0') && (c <= '7')) ? int(c - '0') : -1; } @@ -98,9 +98,9 @@ struct CalculateGrowingBlockSizeResult { // implemented in qbytearray.cpp size_t Q_CORE_EXPORT Q_DECL_CONST_FUNCTION -qCalculateBlockSize(size_t elementCount, size_t elementSize, size_t headerSize = 0) Q_DECL_NOTHROW; +qCalculateBlockSize(size_t elementCount, size_t elementSize, size_t headerSize = 0) noexcept; CalculateGrowingBlockSizeResult Q_CORE_EXPORT Q_DECL_CONST_FUNCTION -qCalculateGrowingBlockSize(size_t elementCount, size_t elementSize, size_t headerSize = 0) Q_DECL_NOTHROW ; +qCalculateGrowingBlockSize(size_t elementCount, size_t elementSize, size_t headerSize = 0) noexcept ; QT_END_NAMESPACE diff --git a/src/corelib/tools/qunicodetables.cpp b/src/corelib/tools/qunicodetables.cpp index 4c4821802d..d57b39ff1f 100644 --- a/src/corelib/tools/qunicodetables.cpp +++ b/src/corelib/tools/qunicodetables.cpp @@ -8803,42 +8803,42 @@ static const Properties uc_properties[] = { { 12, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 12, 0 } }; -Q_DECL_CONST_FUNCTION static inline const Properties *qGetProp(uint ucs4) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION static inline const Properties *qGetProp(uint ucs4) noexcept { return uc_properties + GET_PROP_INDEX(ucs4); } -Q_DECL_CONST_FUNCTION static inline const Properties *qGetProp(ushort ucs2) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION static inline const Properties *qGetProp(ushort ucs2) noexcept { return uc_properties + GET_PROP_INDEX_UCS2(ucs2); } -Q_DECL_CONST_FUNCTION Q_CORE_EXPORT const Properties * QT_FASTCALL properties(uint ucs4) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION Q_CORE_EXPORT const Properties * QT_FASTCALL properties(uint ucs4) noexcept { return qGetProp(ucs4); } -Q_DECL_CONST_FUNCTION Q_CORE_EXPORT const Properties * QT_FASTCALL properties(ushort ucs2) Q_DECL_NOTHROW +Q_DECL_CONST_FUNCTION Q_CORE_EXPORT const Properties * QT_FASTCALL properties(ushort ucs2) noexcept { return qGetProp(ucs2); } -Q_CORE_EXPORT GraphemeBreakClass QT_FASTCALL graphemeBreakClass(uint ucs4) Q_DECL_NOTHROW +Q_CORE_EXPORT GraphemeBreakClass QT_FASTCALL graphemeBreakClass(uint ucs4) noexcept { return static_cast(qGetProp(ucs4)->graphemeBreakClass); } -Q_CORE_EXPORT WordBreakClass QT_FASTCALL wordBreakClass(uint ucs4) Q_DECL_NOTHROW +Q_CORE_EXPORT WordBreakClass QT_FASTCALL wordBreakClass(uint ucs4) noexcept { return static_cast(qGetProp(ucs4)->wordBreakClass); } -Q_CORE_EXPORT SentenceBreakClass QT_FASTCALL sentenceBreakClass(uint ucs4) Q_DECL_NOTHROW +Q_CORE_EXPORT SentenceBreakClass QT_FASTCALL sentenceBreakClass(uint ucs4) noexcept { return static_cast(qGetProp(ucs4)->sentenceBreakClass); } -Q_CORE_EXPORT LineBreakClass QT_FASTCALL lineBreakClass(uint ucs4) Q_DECL_NOTHROW +Q_CORE_EXPORT LineBreakClass QT_FASTCALL lineBreakClass(uint ucs4) noexcept { return static_cast(qGetProp(ucs4)->lineBreakClass); } diff --git a/src/corelib/tools/qunicodetables_p.h b/src/corelib/tools/qunicodetables_p.h index 3f2e91a9b2..cb7a211cb6 100644 --- a/src/corelib/tools/qunicodetables_p.h +++ b/src/corelib/tools/qunicodetables_p.h @@ -93,8 +93,8 @@ struct Properties { ushort script : 8; }; -Q_CORE_EXPORT const Properties * QT_FASTCALL properties(uint ucs4) Q_DECL_NOTHROW; -Q_CORE_EXPORT const Properties * QT_FASTCALL properties(ushort ucs2) Q_DECL_NOTHROW; +Q_CORE_EXPORT const Properties * QT_FASTCALL properties(uint ucs4) noexcept; +Q_CORE_EXPORT const Properties * QT_FASTCALL properties(ushort ucs2) noexcept; struct LowercaseTraits { @@ -209,20 +209,20 @@ enum LineBreakClass { NumLineBreakClasses }; -Q_CORE_EXPORT GraphemeBreakClass QT_FASTCALL graphemeBreakClass(uint ucs4) Q_DECL_NOTHROW; -inline GraphemeBreakClass graphemeBreakClass(QChar ch) Q_DECL_NOTHROW +Q_CORE_EXPORT GraphemeBreakClass QT_FASTCALL graphemeBreakClass(uint ucs4) noexcept; +inline GraphemeBreakClass graphemeBreakClass(QChar ch) noexcept { return graphemeBreakClass(ch.unicode()); } -Q_CORE_EXPORT WordBreakClass QT_FASTCALL wordBreakClass(uint ucs4) Q_DECL_NOTHROW; -inline WordBreakClass wordBreakClass(QChar ch) Q_DECL_NOTHROW +Q_CORE_EXPORT WordBreakClass QT_FASTCALL wordBreakClass(uint ucs4) noexcept; +inline WordBreakClass wordBreakClass(QChar ch) noexcept { return wordBreakClass(ch.unicode()); } -Q_CORE_EXPORT SentenceBreakClass QT_FASTCALL sentenceBreakClass(uint ucs4) Q_DECL_NOTHROW; -inline SentenceBreakClass sentenceBreakClass(QChar ch) Q_DECL_NOTHROW +Q_CORE_EXPORT SentenceBreakClass QT_FASTCALL sentenceBreakClass(uint ucs4) noexcept; +inline SentenceBreakClass sentenceBreakClass(QChar ch) noexcept { return sentenceBreakClass(ch.unicode()); } -Q_CORE_EXPORT LineBreakClass QT_FASTCALL lineBreakClass(uint ucs4) Q_DECL_NOTHROW; -inline LineBreakClass lineBreakClass(QChar ch) Q_DECL_NOTHROW +Q_CORE_EXPORT LineBreakClass QT_FASTCALL lineBreakClass(uint ucs4) noexcept; +inline LineBreakClass lineBreakClass(QChar ch) noexcept { return lineBreakClass(ch.unicode()); } } // namespace QUnicodeTables diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 9762ec1b5b..2de21e92fa 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -65,18 +65,18 @@ class QVector Data *d; public: - inline QVector() Q_DECL_NOTHROW : d(Data::sharedNull()) { } + inline QVector() noexcept : d(Data::sharedNull()) { } explicit QVector(int size); QVector(int size, const T &t); inline QVector(const QVector &v); inline ~QVector() { if (!d->ref.deref()) freeData(d); } QVector &operator=(const QVector &v); #if defined(Q_COMPILER_RVALUE_REFS) || defined(Q_CLANG_QDOC) - QVector(QVector &&other) Q_DECL_NOTHROW : d(other.d) { other.d = Data::sharedNull(); } - QVector &operator=(QVector &&other) Q_DECL_NOTHROW + QVector(QVector &&other) noexcept : d(other.d) { other.d = Data::sharedNull(); } + QVector &operator=(QVector &&other) noexcept { QVector moved(std::move(other)); swap(moved); return *this; } #endif - void swap(QVector &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QVector &other) noexcept { qSwap(d, other.d); } #ifdef Q_COMPILER_INITIALIZER_LISTS inline QVector(std::initializer_list args); QVector &operator=(std::initializer_list args); @@ -209,29 +209,29 @@ public: typedef std::reverse_iterator const_reverse_iterator; #if !defined(QT_STRICT_ITERATORS) || defined(Q_CLANG_QDOC) inline iterator begin() { detach(); return d->begin(); } - inline const_iterator begin() const Q_DECL_NOTHROW { return d->constBegin(); } - inline const_iterator cbegin() const Q_DECL_NOTHROW { return d->constBegin(); } - inline const_iterator constBegin() const Q_DECL_NOTHROW { return d->constBegin(); } + inline const_iterator begin() const noexcept { return d->constBegin(); } + inline const_iterator cbegin() const noexcept { return d->constBegin(); } + inline const_iterator constBegin() const noexcept { return d->constBegin(); } inline iterator end() { detach(); return d->end(); } - inline const_iterator end() const Q_DECL_NOTHROW { return d->constEnd(); } - inline const_iterator cend() const Q_DECL_NOTHROW { return d->constEnd(); } - inline const_iterator constEnd() const Q_DECL_NOTHROW { return d->constEnd(); } + inline const_iterator end() const noexcept { return d->constEnd(); } + inline const_iterator cend() const noexcept { return d->constEnd(); } + inline const_iterator constEnd() const noexcept { return d->constEnd(); } #else inline iterator begin(iterator = iterator()) { detach(); return d->begin(); } - inline const_iterator begin(const_iterator = const_iterator()) const Q_DECL_NOTHROW { return d->constBegin(); } - inline const_iterator cbegin(const_iterator = const_iterator()) const Q_DECL_NOTHROW { return d->constBegin(); } - inline const_iterator constBegin(const_iterator = const_iterator()) const Q_DECL_NOTHROW { return d->constBegin(); } + inline const_iterator begin(const_iterator = const_iterator()) const noexcept { return d->constBegin(); } + inline const_iterator cbegin(const_iterator = const_iterator()) const noexcept { return d->constBegin(); } + inline const_iterator constBegin(const_iterator = const_iterator()) const noexcept { return d->constBegin(); } inline iterator end(iterator = iterator()) { detach(); return d->end(); } - inline const_iterator end(const_iterator = const_iterator()) const Q_DECL_NOTHROW { return d->constEnd(); } - inline const_iterator cend(const_iterator = const_iterator()) const Q_DECL_NOTHROW { return d->constEnd(); } - inline const_iterator constEnd(const_iterator = const_iterator()) const Q_DECL_NOTHROW { return d->constEnd(); } + inline const_iterator end(const_iterator = const_iterator()) const noexcept { return d->constEnd(); } + inline const_iterator cend(const_iterator = const_iterator()) const noexcept { return d->constEnd(); } + inline const_iterator constEnd(const_iterator = const_iterator()) const noexcept { return d->constEnd(); } #endif reverse_iterator rbegin() { return reverse_iterator(end()); } reverse_iterator rend() { return reverse_iterator(begin()); } - const_reverse_iterator rbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); } - const_reverse_iterator rend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); } - const_reverse_iterator crbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); } - const_reverse_iterator crend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); } + const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } + const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } + const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } + const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } iterator insert(iterator before, int n, const T &x); inline iterator insert(iterator before, const T &x) { return insert(before, 1, x); } inline iterator insert(iterator before, T &&x); diff --git a/src/corelib/tools/qversionnumber.cpp b/src/corelib/tools/qversionnumber.cpp index b96e48252e..6fcb9f50e9 100644 --- a/src/corelib/tools/qversionnumber.cpp +++ b/src/corelib/tools/qversionnumber.cpp @@ -235,7 +235,7 @@ QVersionNumber QVersionNumber::normalized() const \sa commonPrefix() */ -bool QVersionNumber::isPrefixOf(const QVersionNumber &other) const Q_DECL_NOTHROW +bool QVersionNumber::isPrefixOf(const QVersionNumber &other) const noexcept { if (segmentCount() > other.segmentCount()) return false; @@ -259,7 +259,7 @@ bool QVersionNumber::isPrefixOf(const QVersionNumber &other) const Q_DECL_NOTHRO \snippet qversionnumber/main.cpp 1 */ -int QVersionNumber::compare(const QVersionNumber &v1, const QVersionNumber &v2) Q_DECL_NOTHROW +int QVersionNumber::compare(const QVersionNumber &v1, const QVersionNumber &v2) noexcept { int commonlen; diff --git a/src/corelib/tools/qversionnumber.h b/src/corelib/tools/qversionnumber.h index 1bfb4aab39..d51947c091 100644 --- a/src/corelib/tools/qversionnumber.h +++ b/src/corelib/tools/qversionnumber.h @@ -87,7 +87,7 @@ class QVersionNumber }; // set the InlineSegmentMarker and set length to zero - SegmentStorage() Q_DECL_NOTHROW : dummy(1) {} + SegmentStorage() noexcept : dummy(1) {} SegmentStorage(const QVector &seg) { @@ -120,13 +120,13 @@ class QVersionNumber } #ifdef Q_COMPILER_RVALUE_REFS - SegmentStorage(SegmentStorage &&other) Q_DECL_NOTHROW + SegmentStorage(SegmentStorage &&other) noexcept : dummy(other.dummy) { other.dummy = 1; } - SegmentStorage &operator=(SegmentStorage &&other) Q_DECL_NOTHROW + SegmentStorage &operator=(SegmentStorage &&other) noexcept { qSwap(dummy, other.dummy); return *this; @@ -153,10 +153,10 @@ class QVersionNumber ~SegmentStorage() { if (isUsingPointer()) delete pointer_segments; } - bool isUsingPointer() const Q_DECL_NOTHROW + bool isUsingPointer() const noexcept { return (inline_segments[InlineSegmentMarker] & 1) == 0; } - int size() const Q_DECL_NOTHROW + int size() const noexcept { return isUsingPointer() ? pointer_segments->size() : (inline_segments[InlineSegmentMarker] >> 1); } void setInlineSize(int len) @@ -218,7 +218,7 @@ class QVersionNumber } m_segments; public: - inline QVersionNumber() Q_DECL_NOTHROW + inline QVersionNumber() noexcept : m_segments() {} inline explicit QVersionNumber(const QVector &seg) @@ -248,34 +248,34 @@ public: inline explicit QVersionNumber(int maj, int min, int mic) { m_segments.setSegments(3, maj, min, mic); } - Q_REQUIRED_RESULT inline bool isNull() const Q_DECL_NOTHROW + Q_REQUIRED_RESULT inline bool isNull() const noexcept { return segmentCount() == 0; } - Q_REQUIRED_RESULT inline bool isNormalized() const Q_DECL_NOTHROW + Q_REQUIRED_RESULT inline bool isNormalized() const noexcept { return isNull() || segmentAt(segmentCount() - 1) != 0; } - Q_REQUIRED_RESULT inline int majorVersion() const Q_DECL_NOTHROW + Q_REQUIRED_RESULT inline int majorVersion() const noexcept { return segmentAt(0); } - Q_REQUIRED_RESULT inline int minorVersion() const Q_DECL_NOTHROW + Q_REQUIRED_RESULT inline int minorVersion() const noexcept { return segmentAt(1); } - Q_REQUIRED_RESULT inline int microVersion() const Q_DECL_NOTHROW + Q_REQUIRED_RESULT inline int microVersion() const noexcept { return segmentAt(2); } Q_REQUIRED_RESULT Q_CORE_EXPORT QVersionNumber normalized() const; Q_REQUIRED_RESULT Q_CORE_EXPORT QVector segments() const; - Q_REQUIRED_RESULT inline int segmentAt(int index) const Q_DECL_NOTHROW + Q_REQUIRED_RESULT inline int segmentAt(int index) const noexcept { return (m_segments.size() > index) ? m_segments.at(index) : 0; } - Q_REQUIRED_RESULT inline int segmentCount() const Q_DECL_NOTHROW + Q_REQUIRED_RESULT inline int segmentCount() const noexcept { return m_segments.size(); } - Q_REQUIRED_RESULT Q_CORE_EXPORT bool isPrefixOf(const QVersionNumber &other) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT Q_CORE_EXPORT bool isPrefixOf(const QVersionNumber &other) const noexcept; - Q_REQUIRED_RESULT Q_CORE_EXPORT static int compare(const QVersionNumber &v1, const QVersionNumber &v2) Q_DECL_NOTHROW; + Q_REQUIRED_RESULT Q_CORE_EXPORT static int compare(const QVersionNumber &v1, const QVersionNumber &v2) noexcept; Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber commonPrefix(const QVersionNumber &v1, const QVersionNumber &v2); @@ -299,22 +299,22 @@ Q_DECLARE_TYPEINFO(QVersionNumber, Q_MOVABLE_TYPE); Q_CORE_EXPORT QDebug operator<<(QDebug, const QVersionNumber &version); #endif -Q_REQUIRED_RESULT inline bool operator> (const QVersionNumber &lhs, const QVersionNumber &rhs) Q_DECL_NOTHROW +Q_REQUIRED_RESULT inline bool operator> (const QVersionNumber &lhs, const QVersionNumber &rhs) noexcept { return QVersionNumber::compare(lhs, rhs) > 0; } -Q_REQUIRED_RESULT inline bool operator>=(const QVersionNumber &lhs, const QVersionNumber &rhs) Q_DECL_NOTHROW +Q_REQUIRED_RESULT inline bool operator>=(const QVersionNumber &lhs, const QVersionNumber &rhs) noexcept { return QVersionNumber::compare(lhs, rhs) >= 0; } -Q_REQUIRED_RESULT inline bool operator< (const QVersionNumber &lhs, const QVersionNumber &rhs) Q_DECL_NOTHROW +Q_REQUIRED_RESULT inline bool operator< (const QVersionNumber &lhs, const QVersionNumber &rhs) noexcept { return QVersionNumber::compare(lhs, rhs) < 0; } -Q_REQUIRED_RESULT inline bool operator<=(const QVersionNumber &lhs, const QVersionNumber &rhs) Q_DECL_NOTHROW +Q_REQUIRED_RESULT inline bool operator<=(const QVersionNumber &lhs, const QVersionNumber &rhs) noexcept { return QVersionNumber::compare(lhs, rhs) <= 0; } -Q_REQUIRED_RESULT inline bool operator==(const QVersionNumber &lhs, const QVersionNumber &rhs) Q_DECL_NOTHROW +Q_REQUIRED_RESULT inline bool operator==(const QVersionNumber &lhs, const QVersionNumber &rhs) noexcept { return QVersionNumber::compare(lhs, rhs) == 0; } -Q_REQUIRED_RESULT inline bool operator!=(const QVersionNumber &lhs, const QVersionNumber &rhs) Q_DECL_NOTHROW +Q_REQUIRED_RESULT inline bool operator!=(const QVersionNumber &lhs, const QVersionNumber &rhs) noexcept { return QVersionNumber::compare(lhs, rhs) != 0; } QT_END_NAMESPACE From 7ab84cfe74f8d525f8099c2739f80681c3c6a428 Mon Sep 17 00:00:00 2001 From: Miguel Costa Date: Wed, 13 Jun 2018 17:04:22 +0200 Subject: [PATCH 149/292] factorial example: Fix issue with WinRT console output Replaced the display of the calculation output, generated using fprintf(stdout, ...), with qInfo() << ... In WinRT, fprintf to stdout does not cause output to be generated. Task-number: QTBUG-67566 Change-Id: I3b95bbf888e863683cbaf54deb26c3821433a5b8 Reviewed-by: Andre de la Rocha Reviewed-by: Maurice Kalinowski --- examples/widgets/statemachine/factorial/main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/widgets/statemachine/factorial/main.cpp b/examples/widgets/statemachine/factorial/main.cpp index 2d25822828..e9431596fe 100644 --- a/examples/widgets/statemachine/factorial/main.cpp +++ b/examples/widgets/statemachine/factorial/main.cpp @@ -49,7 +49,6 @@ ****************************************************************************/ #include -#include //! [0] class Factorial : public QObject @@ -143,7 +142,7 @@ public: void onTransition(QEvent *) override { - fprintf(stdout, "%d\n", m_fact->property("fac").toInt()); + qInfo() << m_fact->property("fac").toInt(); } private: From 30e2bf8712596091c291615bcf9fdcbe58bf3504 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 27 Mar 2019 14:58:26 +0100 Subject: [PATCH 150/292] Remove unused *-mwerks scope The Metroworks mkspec was removed in 2003. Change-Id: I4bc56a20f3bda00bb76a2c3b73f277d238603d02 Reviewed-by: Lars Knoll --- src/widgets/kernel/mac.pri | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/widgets/kernel/mac.pri b/src/widgets/kernel/mac.pri index f7e7aa869a..d21e5d4a74 100644 --- a/src/widgets/kernel/mac.pri +++ b/src/widgets/kernel/mac.pri @@ -1,4 +1 @@ -macos { - LIBS_PRIVATE += -framework AppKit -lz - *-mwerks:INCLUDEPATH += compat -} +macos: LIBS_PRIVATE += -framework AppKit -lz From bcd2fa484a4fe93e77743195d7f72cce9e580d43 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 2 Apr 2019 15:33:16 +0200 Subject: [PATCH 151/292] Fix font matching of typographic families on Windows 9204b8c31ea1b5f0c05870c5b5d74c33b1a4f622 broke font matching on Windows. After this change, if you request a specific face of a family, such as "Arial Black", and Qt detects that its typographic/preferred name is "Arial", then it will be added as the single style of the Arial family, which will in turn be set as populated=true. So if you later request a regular font of "Arial" family, then it will see that the family has already been populated, skip this step, and then see that there is only one style available, i.e. "Arial Black". To work around this, we need to make sure the typographic family is properly populated the first time it is registered. [ChangeLog][Windows][Fonts] Fixed a bug where it would be impossible to request different faces of a font family after a specific type face has been in use. Task-number: QTBUG-74748 Change-Id: Ia0caace2b88a32e6114ff23ad10ee1ea8f5a3e03 Reviewed-by: Allan Sandfeld Jensen --- src/gui/text/qfontdatabase.cpp | 7 +++++++ src/gui/text/qplatformfontdatabase.cpp | 11 +++++++++++ src/gui/text/qplatformfontdatabase.h | 2 ++ .../windows/qwindowsfontdatabase.cpp | 17 ++++++++++++----- .../windows/qwindowsfontdatabase_p.h | 2 ++ 5 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index fa9573441a..a307539800 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -804,6 +804,13 @@ QString qt_resolveFontFamilyAlias(const QString &alias) return alias; } +bool qt_isFontFamilyPopulated(const QString &familyName) +{ + QFontDatabasePrivate *d = privateDb(); + QtFontFamily *f = d->family(familyName, QFontDatabasePrivate::RequestFamily); + return f != nullptr && f->populated; +} + /*! Returns a list of alternative fonts for the specified \a family and \a style and \a script using the \a styleHint given. diff --git a/src/gui/text/qplatformfontdatabase.cpp b/src/gui/text/qplatformfontdatabase.cpp index a911014a19..715b00d838 100644 --- a/src/gui/text/qplatformfontdatabase.cpp +++ b/src/gui/text/qplatformfontdatabase.cpp @@ -60,6 +60,7 @@ void qt_registerFont(const QString &familyname, const QString &stylename, void qt_registerFontFamily(const QString &familyName); void qt_registerAliasToFontFamily(const QString &familyName, const QString &alias); +bool qt_isFontFamilyPopulated(const QString &familyName); /*! Registers the pre-rendered QPF2 font contained in the given \a dataArray. @@ -665,6 +666,16 @@ void QPlatformFontDatabase::registerAliasToFontFamily(const QString &familyName, qt_registerAliasToFontFamily(familyName, alias); } +/*! + Helper function that returns true if the font family has already been registered and populated. + + \since 5.14 +*/ +bool QPlatformFontDatabase::isFamilyPopulated(const QString &familyName) +{ + return qt_isFontFamilyPopulated(familyName); +} + /*! \class QPlatformFontDatabase \since 5.0 diff --git a/src/gui/text/qplatformfontdatabase.h b/src/gui/text/qplatformfontdatabase.h index f4558129a7..38ba7f10b2 100644 --- a/src/gui/text/qplatformfontdatabase.h +++ b/src/gui/text/qplatformfontdatabase.h @@ -139,6 +139,8 @@ public: static void registerFontFamily(const QString &familyName); static void registerAliasToFontFamily(const QString &familyName, const QString &alias); + + static bool isFamilyPopulated(const QString &familyName); }; QT_END_NAMESPACE diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp index 10df85f68e..ff0efaac1a 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp @@ -1012,7 +1012,8 @@ static bool addFontToDatabase(QString familyName, const LOGFONT &logFont, const TEXTMETRIC *textmetric, const FONTSIGNATURE *signature, - int type) + int type, + QWindowsFontDatabase *db) { // the "@family" fonts are just the same as "family". Ignore them. if (familyName.isEmpty() || familyName.at(0) == QLatin1Char('@') || familyName.startsWith(QLatin1String("WST_"))) @@ -1092,6 +1093,12 @@ static bool addFontToDatabase(QString familyName, writingSystems.setSupported(ws); } + // We came here from populating a different font family, so we have + // to ensure the entire typographic family is populated before we + // mark it as such inside registerFont() + if (!subFamilyName.isEmpty() && familyName != subFamilyName && !QPlatformFontDatabase::isFamilyPopulated(familyName)) + db->populateFamily(familyName); + QPlatformFontDatabase::registerFont(familyName, styleName, foundryName, weight, style, stretch, antialias, scalable, size, fixed, writingSystems, createFontFile(faceName)); @@ -1118,7 +1125,7 @@ static bool addFontToDatabase(QString familyName, } static int QT_WIN_CALLBACK storeFont(const LOGFONT *logFont, const TEXTMETRIC *textmetric, - DWORD type, LPARAM) + DWORD type, LPARAM lParam) { const ENUMLOGFONTEX *f = reinterpret_cast(logFont); const QString familyName = QString::fromWCharArray(f->elfLogFont.lfFaceName); @@ -1130,7 +1137,7 @@ static int QT_WIN_CALLBACK storeFont(const LOGFONT *logFont, const TEXTMETRIC *t const FONTSIGNATURE *signature = nullptr; if (type & TRUETYPE_FONTTYPE) signature = &reinterpret_cast(textmetric)->ntmFontSig; - addFontToDatabase(familyName, styleName, *logFont, textmetric, signature, type); + addFontToDatabase(familyName, styleName, *logFont, textmetric, signature, type, reinterpret_cast(lParam)); // keep on enumerating return 1; @@ -1149,7 +1156,7 @@ void QWindowsFontDatabase::populateFamily(const QString &familyName) familyName.toWCharArray(lf.lfFaceName); lf.lfFaceName[familyName.size()] = 0; lf.lfPitchAndFamily = 0; - EnumFontFamiliesEx(dummy, &lf, storeFont, 0, 0); + EnumFontFamiliesEx(dummy, &lf, storeFont, reinterpret_cast(this), 0); ReleaseDC(0, dummy); } @@ -1590,7 +1597,7 @@ QStringList QWindowsFontDatabase::addApplicationFont(const QByteArray &fontData, GetTextMetrics(hdc, &textMetrics); addFontToDatabase(familyName, styleName, lf, &textMetrics, &signatures.at(j), - TRUETYPE_FONTTYPE); + TRUETYPE_FONTTYPE, this); SelectObject(hdc, oldobj); DeleteObject(hfont); diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_p.h b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_p.h index b85a2dceee..a1cab17a87 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_p.h +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_p.h @@ -96,6 +96,8 @@ public: QWindowsFontDatabase(); ~QWindowsFontDatabase() override; + void ensureFamilyPopulated(const QString &familyName); + void populateFontDatabase() override; void populateFamily(const QString &familyName) override; QFontEngine *fontEngine(const QFontDef &fontDef, void *handle) override; From 90c86d738e0f36eaa48c7f81f6f5cc035a339d6b Mon Sep 17 00:00:00 2001 From: David Faure Date: Thu, 4 Apr 2019 10:53:57 +0200 Subject: [PATCH 152/292] QCommandLineParser: warn if defining a duplicate option Fixes: QTBUG-74907 Change-Id: I3741a5241515dfaf4353458a9ef13ceaeb9fea0b Reviewed-by: Thiago Macieira --- src/corelib/tools/qcommandlineparser.cpp | 4 +++- .../qcommandlineparser/tst_qcommandlineparser.cpp | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qcommandlineparser.cpp b/src/corelib/tools/qcommandlineparser.cpp index 6817d73143..489724ac47 100644 --- a/src/corelib/tools/qcommandlineparser.cpp +++ b/src/corelib/tools/qcommandlineparser.cpp @@ -362,8 +362,10 @@ bool QCommandLineParser::addOption(const QCommandLineOption &option) if (!optionNames.isEmpty()) { for (const QString &name : optionNames) { - if (d->nameHash.contains(name)) + if (d->nameHash.contains(name)) { + qWarning() << "QCommandLineParser: already having an option named" << name; return false; + } } d->commandLineOptionList.append(option); diff --git a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp index 7980f1f8f4..811e9a0010 100644 --- a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp +++ b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp @@ -44,6 +44,7 @@ private slots: // In-process tests void testInvalidOptions(); + void testDuplicateOption(); void testPositionalArguments(); void testBooleanOption_data(); void testBooleanOption(); @@ -104,6 +105,15 @@ void tst_QCommandLineParser::testInvalidOptions() QVERIFY(!parser.addOption(QCommandLineOption(QStringLiteral("-v"), QStringLiteral("Displays version information.")))); } +void tst_QCommandLineParser::testDuplicateOption() +{ + QCoreApplication app(empty_argc, empty_argv); + QCommandLineParser parser; + QVERIFY(parser.addOption(QCommandLineOption(QStringLiteral("h"), QStringLiteral("Hostname."), QStringLiteral("hostname")))); + QTest::ignoreMessage(QtWarningMsg, "QCommandLineParser: already having an option named \"h\""); + parser.addHelpOption(); +} + void tst_QCommandLineParser::testPositionalArguments() { QCoreApplication app(empty_argc, empty_argv); From a334156e81ab2491b3f65ee3c7a8269912c26a0c Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 2 Apr 2019 15:44:01 +0200 Subject: [PATCH 153/292] Add QMetaProperty::relativePropertyIndex() Add a "sibling" function for QMetaProperty::propertyIndex() for the relative index. That way in QtQml we can avoid using propertyIndex() - metaObject.propertyOffset() where the latter traverses the parent chain. Change-Id: I113a956801b0e8d56a30a847b5b919da703824e2 Reviewed-by: Lars Knoll Reviewed-by: Thiago Macieira --- src/corelib/kernel/qmetaobject.cpp | 12 ++++++++++++ src/corelib/kernel/qmetaobject.h | 1 + 2 files changed, 13 insertions(+) diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index c15a9f7b0f..8309bd22c2 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -3016,6 +3016,18 @@ int QMetaProperty::propertyIndex() const return idx + mobj->propertyOffset(); } +/*! + \since 5.14 + + Returns this property's index relative within the enclosing meta object. +*/ +int QMetaProperty::relativePropertyIndex() const +{ + if (!mobj) + return -1; + return idx; +} + /*! Returns \c true if the property's type is an enumeration value that is used as a flag; otherwise returns \c false. diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h index 51ace3d5f7..6c5f78d208 100644 --- a/src/corelib/kernel/qmetaobject.h +++ b/src/corelib/kernel/qmetaobject.h @@ -253,6 +253,7 @@ public: QVariant::Type type() const; int userType() const; int propertyIndex() const; + int relativePropertyIndex() const; bool isReadable() const; bool isWritable() const; From d1bab5b1e3d28c0e2925ad3208cea785af755d54 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 2 Apr 2019 10:31:52 +0200 Subject: [PATCH 154/292] Allow word break wrapping in Korean text In Korean text, they typically can use both the "Western" style of word wrapping, i.e. breaking on spaces, as well as the East-Asian style of potentially breaking between all syllables. However, the Unicode Line Breaking Algorithm, TR14 defaults to breaks on syllables and specifies a possible tailoring where Hangul is mapped to the AL class instead: "When Korean uses SPACE for line breaking, the classes in rule LB26, as well as characters of class ID, are often tailored to AL" When using Qt, the user would expect the WordWrap wrap mode to break between words in Korean. If you want the syllable-based text layout, you would use WrapAnywhere, probably accompanied by line justification. To avoid breaking QTextBoundaryFinder and other potential clients of QUnicodeTools which depend on getting the precise Unicode data from the algorithm, we do this by passing a flag from QTextEngine when initializing the attributes. This way, it can also be made optional later on, if we decide there is a reason to add an additional wrap mode specifically to handle cases like this. [ChangeLog][Important Behavioral Change] WrapWord now correctly prefers line breaks between words in Korean text. WrapAnywhere can still be used to get breaks between syllables instead. Done-with: Alexey Turitsyn Task-number: QTBUG-47644 Change-Id: I37b45cea2995db7fc2b61e3a0cc681bbdc334678 Reviewed-by: Lars Knoll --- src/corelib/tools/qunicodetools.cpp | 29 +++++++++++++++++-- src/corelib/tools/qunicodetools_p.h | 1 + src/gui/text/qtextengine.cpp | 4 ++- .../gui/text/qtextlayout/tst_qtextlayout.cpp | 26 +++++++++++++++++ 4 files changed, 57 insertions(+), 3 deletions(-) diff --git a/src/corelib/tools/qunicodetools.cpp b/src/corelib/tools/qunicodetools.cpp index c9d0868fef..d14118abf7 100644 --- a/src/corelib/tools/qunicodetools.cpp +++ b/src/corelib/tools/qunicodetools.cpp @@ -542,7 +542,7 @@ static const uchar breakTable[QUnicodeTables::LineBreak_SA][QUnicodeTables::Line } // namespace LB -static void getLineBreaks(const ushort *string, quint32 len, QCharAttributes *attributes) +static void getLineBreaks(const ushort *string, quint32 len, QCharAttributes *attributes, QUnicodeTools::CharAttributeOptions options) { quint32 nestart = 0; LB::NS::Class nelast = LB::NS::XX; @@ -564,6 +564,31 @@ static void getLineBreaks(const ushort *string, quint32 len, QCharAttributes *at QUnicodeTables::LineBreakClass ncls = (QUnicodeTables::LineBreakClass) prop->lineBreakClass; QUnicodeTables::LineBreakClass tcls; + if (options & QUnicodeTools::HangulLineBreakTailoring) { + if (Q_UNLIKELY((ncls >= QUnicodeTables::LineBreak_H2 + && ncls <= QUnicodeTables::LineBreak_JT) + || (ucs4 >= 0x3130 && ucs4 <= 0x318F && ncls == QUnicodeTables::LineBreak_ID)) + ) { + // LB27: use SPACE for line breaking + // "When Korean uses SPACE for line breaking, the classes in rule LB26, + // as well as characters of class ID, are often tailored to AL; see Section 8, Customization." + // In case of Korean syllables: "3130..318F HANGUL COMPATIBILITY JAMO" + ncls = QUnicodeTables::LineBreak_AL; + } else { + if (Q_UNLIKELY(ncls == QUnicodeTables::LineBreak_SA)) { + // LB1: resolve SA to AL, except of those that have Category Mn or Mc be resolved to CM + static const int test = FLAG(QChar::Mark_NonSpacing) | FLAG(QChar::Mark_SpacingCombining); + if (FLAG(prop->category) & test) + ncls = QUnicodeTables::LineBreak_CM; + } + if (Q_UNLIKELY(ncls == QUnicodeTables::LineBreak_CM)) { + // LB10: treat CM that follows SP, BK, CR, LF, NL, or ZW as AL + if (lcls == QUnicodeTables::LineBreak_ZW || lcls >= QUnicodeTables::LineBreak_SP) + ncls = QUnicodeTables::LineBreak_AL; + } + } + } + if (Q_UNLIKELY(ncls == QUnicodeTables::LineBreak_SA)) { // LB1: resolve SA to AL, except of those that have Category Mn or Mc be resolved to CM static const int test = FLAG(QChar::Mark_NonSpacing) | FLAG(QChar::Mark_SpacingCombining); @@ -716,7 +741,7 @@ Q_CORE_EXPORT void initCharAttributes(const ushort *string, int length, if (options & SentenceBreaks) getSentenceBreaks(string, length, attributes); if (options & LineBreaks) - getLineBreaks(string, length, attributes); + getLineBreaks(string, length, attributes, options); if (options & WhiteSpaces) getWhiteSpaces(string, length, attributes); diff --git a/src/corelib/tools/qunicodetools_p.h b/src/corelib/tools/qunicodetools_p.h index 5e2d56a226..ed6fcb5d65 100644 --- a/src/corelib/tools/qunicodetools_p.h +++ b/src/corelib/tools/qunicodetools_p.h @@ -88,6 +88,7 @@ enum CharAttributeOption { SentenceBreaks = 0x04, LineBreaks = 0x08, WhiteSpaces = 0x10, + HangulLineBreakTailoring = 0x20, DefaultOptionsCompat = GraphemeBreaks | LineBreaks | WhiteSpaces, // ### remove DontClearAttributes = 0x1000 diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index a83ef95c79..130d506975 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1968,7 +1968,9 @@ const QCharAttributes *QTextEngine::attributes() const QUnicodeTools::initCharAttributes(reinterpret_cast(layoutData->string.constData()), layoutData->string.length(), scriptItems.data(), scriptItems.size(), - (QCharAttributes *)layoutData->memory); + (QCharAttributes *)layoutData->memory, + QUnicodeTools::CharAttributeOptions(QUnicodeTools::DefaultOptionsCompat + | QUnicodeTools::HangulLineBreakTailoring)); layoutData->haveCharAttributes = true; diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp index 9c477589f9..9610e5b830 100644 --- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp @@ -138,6 +138,7 @@ private slots: void noModificationOfInputString(); void superscriptCrash_qtbug53911(); void showLineAndParagraphSeparatorsCrash(); + void koreanWordWrap(); private: QFont testFont; @@ -2309,5 +2310,30 @@ void tst_QTextLayout::nbspWithFormat() QCOMPARE(layout.lineAt(1).textLength(), s2.length() + 1 + s3.length()); } +void tst_QTextLayout::koreanWordWrap() +{ + QString s = QString::fromUtf8("안녕하세요 여러분!"); + QTextLayout layout; + QTextOption option = layout.textOption(); + option.setWrapMode(QTextOption::WordWrap); + option.setFlags(QTextOption::Flag(QTextOption::IncludeTrailingSpaces)); + layout.setTextOption(option); + layout.setText(s); + + QFontMetrics metrics(layout.font()); + + layout.beginLayout(); + forever { + QTextLine line = layout.createLine(); + if (!line.isValid()) + break; + line.setLineWidth(metrics.width(s) * 0.8); + } + layout.endLayout(); + QCOMPARE(layout.lineCount(), 2); + QCOMPARE(layout.lineAt(0).textLength(), 6); + QCOMPARE(layout.lineAt(1).textLength(), 4); +} + QTEST_MAIN(tst_QTextLayout) #include "tst_qtextlayout.moc" From b6cf8cb794ae6e0f0f8c1c45e9f4c8d3910ff082 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 4 Apr 2019 17:08:53 +0200 Subject: [PATCH 155/292] Clang_cl: Use -O3 for full optimization Pass it through as a traditional clang argument instead of relying on what MSVC cl.exe can take. Change-Id: I94405ce6ab80d16b687e62c9aa4b2866ba84f0e2 Reviewed-by: Thiago Macieira --- mkspecs/win32-clang-msvc/qmake.conf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mkspecs/win32-clang-msvc/qmake.conf b/mkspecs/win32-clang-msvc/qmake.conf index e15c18b9e6..eb6fbee26d 100644 --- a/mkspecs/win32-clang-msvc/qmake.conf +++ b/mkspecs/win32-clang-msvc/qmake.conf @@ -46,7 +46,8 @@ QMAKE_CXXFLAGS_LTCG_FATOBJECTS = $$QMAKE_CFLAGS_LTCG_FATOBJECTS # Leave QMAKE_LFLAGS_LTCG empty because lld-link doesn't need any additional parameters QMAKE_LFLAGS_LTCG = -QMAKE_CFLAGS_OPTIMIZE_SIZE = -Xclang -Oz +QMAKE_CFLAGS_OPTIMIZE_SIZE = /clang:-Oz +QMAKE_CFLAGS_OPTIMIZE_FULL = /clang:-O3 QMAKE_LFLAGS_RELEASE += /OPT:REF,ICF,LBR From 8d7c97d428cdf89c3419a4e13b62a9849feefce9 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 4 Apr 2019 16:46:41 +0200 Subject: [PATCH 156/292] Remove remaining Q_DECL_NOEXCEPT/Q_DECL_NOTHROW usage Change-Id: I91ac9e714a465cab226b211812aa46e8fe5ff2ab Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal.h | 4 +- src/corelib/global/qglobalstatic.h | 2 +- src/corelib/global/qrandom.cpp | 4 +- src/corelib/global/qtypeinfo.h | 2 +- .../itemmodels/qitemselectionmodel.cpp | 4 +- src/corelib/kernel/qcore_mac_p.h | 2 +- src/corelib/statemachine/qstatemachine_p.h | 4 +- src/corelib/tools/qdatetime.cpp | 2 +- src/corelib/tools/qdatetime.h | 2 +- src/corelib/tools/qhash.h | 4 +- src/corelib/tools/qhashfunctions.h | 14 ++--- src/corelib/tools/qiterator.h | 2 +- src/corelib/tools/qlist.h | 10 ++-- src/corelib/tools/qpair.h | 30 +++++----- src/corelib/tools/qscopedpointer.h | 2 +- src/corelib/tools/qset.h | 2 +- src/corelib/tools/qvarlengtharray.h | 8 +-- src/corelib/tools/qvector.h | 10 ++-- src/dbus/qdbusargument.h | 6 +- src/dbus/qdbusconnection.h | 6 +- src/dbus/qdbuserror.h | 6 +- src/dbus/qdbusextratypes.h | 14 ++--- src/dbus/qdbusintegrator_p.h | 4 +- src/dbus/qdbusmessage.h | 4 +- src/dbus/qdbuspendingcall.h | 4 +- src/dbus/qdbusunixfiledescriptor.h | 4 +- src/network/access/qabstractnetworkcache.h | 4 +- src/network/access/qhstspolicy.h | 4 +- src/network/access/qhttpmultipart.h | 4 +- src/network/access/qnetworkcookie.h | 4 +- src/network/access/qnetworkrequest.h | 4 +- src/network/bearer/qnetworkconfiguration.h | 4 +- src/network/kernel/qdnslookup.h | 20 +++---- src/network/kernel/qhostaddress.cpp | 2 +- src/network/kernel/qhostaddress.h | 8 +-- src/network/kernel/qhostinfo.cpp | 4 +- src/network/kernel/qhostinfo.h | 4 +- src/network/kernel/qnetworkdatagram.h | 6 +- src/network/kernel/qnetworkinterface.h | 8 +-- src/network/kernel/qnetworkproxy.h | 8 +-- src/network/ssl/qocspresponse.cpp | 4 +- src/network/ssl/qocspresponse.h | 6 +- src/network/ssl/qsslcertificate.h | 8 +-- src/network/ssl/qsslcertificate_openssl.cpp | 2 +- src/network/ssl/qsslcertificate_qt.cpp | 2 +- src/network/ssl/qsslcertificateextension.h | 4 +- src/network/ssl/qsslcipher.h | 4 +- src/network/ssl/qsslconfiguration.h | 4 +- .../ssl/qssldiffiehellmanparameters.cpp | 12 ++-- src/network/ssl/qssldiffiehellmanparameters.h | 24 ++++---- src/network/ssl/qsslellipticcurve.h | 18 +++--- src/network/ssl/qsslellipticcurve_dummy.cpp | 2 +- src/network/ssl/qsslellipticcurve_openssl.cpp | 2 +- src/network/ssl/qsslerror.cpp | 2 +- src/network/ssl/qsslerror.h | 6 +- src/network/ssl/qsslkey.h | 4 +- .../ssl/qsslpresharedkeyauthenticator.h | 4 +- .../evdevkeyboard/qevdevkeyboardhandler.cpp | 2 +- .../evdevkeyboard/qevdevkeyboardhandler_p.h | 8 +-- .../platforms/windows/qwindowscursor.h | 2 +- .../platforms/xcb/nativepainting/qt_x11_p.h | 2 +- .../platforms/xcb/qxcbconnection_basic.h | 2 +- src/plugins/platforms/xcb/qxcbcursor.h | 2 +- .../dialogs/qprintdialog_unix.cpp | 10 ++-- src/printsupport/kernel/qcups.cpp | 4 +- src/sql/kernel/qsqlerror.h | 6 +- src/sql/models/qsqlrelationaltablemodel.h | 4 +- src/widgets/dialogs/qdialog_p.h | 10 ++-- src/widgets/kernel/qsizepolicy.cpp | 4 +- src/widgets/kernel/qsizepolicy.h | 56 +++++++++---------- src/widgets/widgets/qcalendarwidget.cpp | 12 ++-- src/xml/sax/qxml.h | 6 +- 72 files changed, 239 insertions(+), 239 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 223ebbcabe..6f51c25747 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -910,14 +910,14 @@ namespace SwapExceptionTester { // insulate users from the "using std::swap" bel using std::swap; // import std::swap template void checkSwap(T &t) - Q_DECL_NOEXCEPT_EXPR(noexcept(swap(t, t))); + noexcept(noexcept(swap(t, t))); // declared, but not implemented (only to be used in unevaluated contexts (noexcept operator)) } } // namespace QtPrivate template inline void qSwap(T &value1, T &value2) - Q_DECL_NOEXCEPT_EXPR(noexcept(QtPrivate::SwapExceptionTester::checkSwap(value1))) + noexcept(noexcept(QtPrivate::SwapExceptionTester::checkSwap(value1))) { using std::swap; swap(value1, value2); diff --git a/src/corelib/global/qglobalstatic.h b/src/corelib/global/qglobalstatic.h index 93d71cee57..f5c46e9392 100644 --- a/src/corelib/global/qglobalstatic.h +++ b/src/corelib/global/qglobalstatic.h @@ -86,7 +86,7 @@ enum GuardValues { static struct Holder : public HolderBase { \ Type value; \ Holder() \ - Q_DECL_NOEXCEPT_EXPR(noexcept(Type ARGS)) \ + noexcept(noexcept(Type ARGS)) \ : value ARGS \ { guard.store(QtGlobalStatic::Initialized); } \ } holder; \ diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp index 6195c324e7..6cc46bcf39 100644 --- a/src/corelib/global/qrandom.cpp +++ b/src/corelib/global/qrandom.cpp @@ -219,7 +219,7 @@ struct QRandomGenerator::SystemGenerator static SystemGenerator &self(); typedef quint32 result_type; - void generate(quint32 *begin, quint32 *end) Q_DECL_NOEXCEPT_EXPR(FillBufferNoexcept); + void generate(quint32 *begin, quint32 *end) noexcept(FillBufferNoexcept); // For std::mersenne_twister_engine implementations that use something // other than quint32 (unsigned int) to fill their buffers. @@ -354,7 +354,7 @@ static void fallback_fill(quint32 *ptr, qsizetype left) Q_DECL_NOTHROW #endif Q_NEVER_INLINE void QRandomGenerator::SystemGenerator::generate(quint32 *begin, quint32 *end) - Q_DECL_NOEXCEPT_EXPR(FillBufferNoexcept) + noexcept(FillBufferNoexcept) { quint32 *buffer = begin; qsizetype count = end - begin; diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h index 567ff5c08e..636dc24c07 100644 --- a/src/corelib/global/qtypeinfo.h +++ b/src/corelib/global/qtypeinfo.h @@ -308,7 +308,7 @@ Q_DECLARE_TYPEINFO_BODY(QFlags, Q_PRIMITIVE_TYPE); #define Q_DECLARE_SHARED_IMPL(TYPE, FLAGS) \ Q_DECLARE_TYPEINFO(TYPE, FLAGS); \ inline void swap(TYPE &value1, TYPE &value2) \ - Q_DECL_NOEXCEPT_EXPR(noexcept(value1.swap(value2))) \ + noexcept(noexcept(value1.swap(value2))) \ { value1.swap(value2); } #define Q_DECLARE_SHARED(TYPE) Q_DECLARE_SHARED_IMPL(TYPE, Q_MOVABLE_TYPE) #define Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(TYPE) \ diff --git a/src/corelib/itemmodels/qitemselectionmodel.cpp b/src/corelib/itemmodels/qitemselectionmodel.cpp index 1bacb63b17..c93a4d15b9 100644 --- a/src/corelib/itemmodels/qitemselectionmodel.cpp +++ b/src/corelib/itemmodels/qitemselectionmodel.cpp @@ -1273,10 +1273,10 @@ struct IsNotValid { typedef bool result_type; struct is_transparent : std::true_type {}; template - Q_DECL_CONSTEXPR bool operator()(T &t) const Q_DECL_NOEXCEPT_EXPR(noexcept(t.isValid())) + Q_DECL_CONSTEXPR bool operator()(T &t) const noexcept(noexcept(t.isValid())) { return !t.isValid(); } template - Q_DECL_CONSTEXPR bool operator()(T *t) const Q_DECL_NOEXCEPT_EXPR(noexcept(t->isValid())) + Q_DECL_CONSTEXPR bool operator()(T *t) const noexcept(noexcept(t->isValid())) { return !t->isValid(); } }; } diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h index f96e7358a2..920105ee9e 100644 --- a/src/corelib/kernel/qcore_mac_p.h +++ b/src/corelib/kernel/qcore_mac_p.h @@ -90,7 +90,7 @@ public: QAppleRefCounted(const QAppleRefCounted &other) : value(other.value) { if (value) RetainFunction(value); } ~QAppleRefCounted() { if (value) ReleaseFunction(value); } operator T() const { return value; } - void swap(QAppleRefCounted &other) Q_DECL_NOEXCEPT_EXPR(noexcept(qSwap(value, other.value))) + void swap(QAppleRefCounted &other) noexcept(noexcept(qSwap(value, other.value))) { qSwap(value, other.value); } QAppleRefCounted &operator=(const QAppleRefCounted &other) { QAppleRefCounted copy(other); swap(copy); return *this; } diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h index c66130b8ce..93756f0e66 100644 --- a/src/corelib/statemachine/qstatemachine_p.h +++ b/src/corelib/statemachine/qstatemachine_p.h @@ -218,9 +218,9 @@ public: QByteArray prop; // two overloads because friends can't have default arguments friend uint qHash(const RestorableId &key, uint seed) - Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(std::declval()))) + noexcept(noexcept(qHash(std::declval()))) { return qHash(qMakePair(key.obj, key.prop), seed); } - friend uint qHash(const RestorableId &key) Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(key, 0U))) + friend uint qHash(const RestorableId &key) noexcept(noexcept(qHash(key, 0U))) { return qHash(key, 0U); } friend bool operator==(const RestorableId &lhs, const RestorableId &rhs) Q_DECL_NOTHROW { return lhs.obj == rhs.obj && lhs.prop == rhs.prop; } diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 80d6dada60..fafe7731ce 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -3132,7 +3132,7 @@ inline qint64 QDateTimePrivate::zoneMSecsToEpochMSecs(qint64 zoneMSecs, const QT \sa isValid() */ -QDateTime::QDateTime() Q_DECL_NOEXCEPT_EXPR(Data::CanBeSmall) +QDateTime::QDateTime() noexcept(Data::CanBeSmall) { } diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h index 43271b34ed..66947881c8 100644 --- a/src/corelib/tools/qdatetime.h +++ b/src/corelib/tools/qdatetime.h @@ -258,7 +258,7 @@ class Q_CORE_EXPORT QDateTime }; public: - QDateTime() Q_DECL_NOEXCEPT_EXPR(Data::CanBeSmall); + QDateTime() noexcept(Data::CanBeSmall); explicit QDateTime(const QDate &); QDateTime(const QDate &, const QTime &, Qt::TimeSpec spec = Qt::LocalTime); // ### Qt 6: Merge with above with default offsetSeconds = 0 diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index a586ca5671..7e6506f796 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -1130,7 +1130,7 @@ Q_DECLARE_MUTABLE_ASSOCIATIVE_ITERATOR(Hash) template uint qHash(const QHash &key, uint seed = 0) - Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(std::declval())) && noexcept(qHash(std::declval()))) + noexcept(noexcept(qHash(std::declval())) && noexcept(qHash(std::declval()))) { QtPrivate::QHashCombineCommutative hash; for (auto it = key.begin(), end = key.end(); it != end; ++it) { @@ -1143,7 +1143,7 @@ uint qHash(const QHash &key, uint seed = 0) template inline uint qHash(const QMultiHash &key, uint seed = 0) - Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(std::declval())) && noexcept(qHash(std::declval()))) + noexcept(noexcept(qHash(std::declval())) && noexcept(qHash(std::declval()))) { const QHash &key2 = key; return qHash(key2, seed); diff --git a/src/corelib/tools/qhashfunctions.h b/src/corelib/tools/qhashfunctions.h index d013c26d66..1d30e71053 100644 --- a/src/corelib/tools/qhashfunctions.h +++ b/src/corelib/tools/qhashfunctions.h @@ -114,7 +114,7 @@ template inline uint qHash(const T *key, uint seed = 0) Q_DECL_NOTHROW return qHash(reinterpret_cast(key), seed); } template inline uint qHash(const T &t, uint seed) - Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(t))) + noexcept(noexcept(qHash(t))) { return qHash(t) ^ seed; } namespace QtPrivate { @@ -122,7 +122,7 @@ namespace QtPrivate { struct QHashCombine { typedef uint result_type; template - Q_DECL_CONSTEXPR result_type operator()(uint seed, const T &t) const Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(t))) + Q_DECL_CONSTEXPR result_type operator()(uint seed, const T &t) const noexcept(noexcept(qHash(t))) // combiner taken from N3876 / boost::hash_combine { return seed ^ (qHash(t) + 0x9e3779b9 + (seed << 6) + (seed >> 2)) ; } }; @@ -135,7 +135,7 @@ struct QHashCombineCommutative { // QHash). Therefore, provide a commutative combiner, too. typedef uint result_type; template - Q_DECL_CONSTEXPR result_type operator()(uint seed, const T &t) const Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(t))) + Q_DECL_CONSTEXPR result_type operator()(uint seed, const T &t) const noexcept(noexcept(qHash(t))) { return seed + qHash(t); } // don't use xor! }; @@ -143,20 +143,20 @@ struct QHashCombineCommutative { template inline uint qHashRange(InputIterator first, InputIterator last, uint seed = 0) - Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(*first))) // assume iterator operations don't throw + noexcept(noexcept(qHash(*first))) // assume iterator operations don't throw { return std::accumulate(first, last, seed, QtPrivate::QHashCombine()); } template inline uint qHashRangeCommutative(InputIterator first, InputIterator last, uint seed = 0) - Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(*first))) // assume iterator operations don't throw + noexcept(noexcept(qHash(*first))) // assume iterator operations don't throw { return std::accumulate(first, last, seed, QtPrivate::QHashCombineCommutative()); } template inline uint qHash(const QPair &key, uint seed = 0) - Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(key.first, seed)) && noexcept(qHash(key.second, seed))) + noexcept(noexcept(qHash(key.first, seed)) && noexcept(qHash(key.second, seed))) { uint h1 = qHash(key.first, seed); uint h2 = qHash(key.second, seed); @@ -164,7 +164,7 @@ template inline uint qHash(const QPair &key, } template inline uint qHash(const std::pair &key, uint seed = 0) - Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(key.first, seed)) && noexcept(qHash(key.second, seed))) + noexcept(noexcept(qHash(key.first, seed)) && noexcept(qHash(key.second, seed))) { QtPrivate::QHashCombine hash; seed = hash(seed, key.first); diff --git a/src/corelib/tools/qiterator.h b/src/corelib/tools/qiterator.h index 586d26cbad..f659e88b5e 100644 --- a/src/corelib/tools/qiterator.h +++ b/src/corelib/tools/qiterator.h @@ -190,7 +190,7 @@ public: typedef const value_type &reference; QKeyValueIterator() = default; - Q_DECL_CONSTEXPR explicit QKeyValueIterator(Iterator o) Q_DECL_NOEXCEPT_EXPR(std::is_nothrow_move_constructible::value) + Q_DECL_CONSTEXPR explicit QKeyValueIterator(Iterator o) noexcept(std::is_nothrow_move_constructible::value) : i(std::move(o)) {} std::pair operator*() const { diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 34577acaa5..7532997c93 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -1121,14 +1121,14 @@ Q_DECLARE_MUTABLE_SEQUENTIAL_ITERATOR(List) template uint qHash(const QList &key, uint seed = 0) - Q_DECL_NOEXCEPT_EXPR(noexcept(qHashRange(key.cbegin(), key.cend(), seed))) + noexcept(noexcept(qHashRange(key.cbegin(), key.cend(), seed))) { return qHashRange(key.cbegin(), key.cend(), seed); } template bool operator<(const QList &lhs, const QList &rhs) - Q_DECL_NOEXCEPT_EXPR(noexcept(std::lexicographical_compare(lhs.begin(), lhs.end(), + noexcept(noexcept(std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()))) { return std::lexicographical_compare(lhs.begin(), lhs.end(), @@ -1137,21 +1137,21 @@ bool operator<(const QList &lhs, const QList &rhs) template inline bool operator>(const QList &lhs, const QList &rhs) - Q_DECL_NOEXCEPT_EXPR(noexcept(lhs < rhs)) + noexcept(noexcept(lhs < rhs)) { return rhs < lhs; } template inline bool operator<=(const QList &lhs, const QList &rhs) - Q_DECL_NOEXCEPT_EXPR(noexcept(lhs < rhs)) + noexcept(noexcept(lhs < rhs)) { return !(lhs > rhs); } template inline bool operator>=(const QList &lhs, const QList &rhs) - Q_DECL_NOEXCEPT_EXPR(noexcept(lhs < rhs)) + noexcept(noexcept(lhs < rhs)) { return !(lhs < rhs); } diff --git a/src/corelib/tools/qpair.h b/src/corelib/tools/qpair.h index 1af43d0a68..6d1e67efb7 100644 --- a/src/corelib/tools/qpair.h +++ b/src/corelib/tools/qpair.h @@ -52,41 +52,41 @@ struct QPair typedef T2 second_type; Q_DECL_CONSTEXPR QPair() - Q_DECL_NOEXCEPT_EXPR((std::is_nothrow_default_constructible::value && + noexcept((std::is_nothrow_default_constructible::value && std::is_nothrow_default_constructible::value)) : first(), second() {} Q_DECL_CONSTEXPR QPair(const T1 &t1, const T2 &t2) - Q_DECL_NOEXCEPT_EXPR((std::is_nothrow_copy_constructible::value && + noexcept((std::is_nothrow_copy_constructible::value && std::is_nothrow_copy_constructible::value)) : first(t1), second(t2) {} // compiler-generated copy/move ctor/assignment operators are fine! template Q_DECL_CONSTEXPR QPair(const QPair &p) - Q_DECL_NOEXCEPT_EXPR((std::is_nothrow_constructible::value && + noexcept((std::is_nothrow_constructible::value && std::is_nothrow_constructible::value)) : first(p.first), second(p.second) {} template Q_DECL_RELAXED_CONSTEXPR QPair &operator=(const QPair &p) - Q_DECL_NOEXCEPT_EXPR((std::is_nothrow_assignable::value && + noexcept((std::is_nothrow_assignable::value && std::is_nothrow_assignable::value)) { first = p.first; second = p.second; return *this; } #ifdef Q_COMPILER_RVALUE_REFS template Q_DECL_CONSTEXPR QPair(QPair &&p) - Q_DECL_NOEXCEPT_EXPR((std::is_nothrow_constructible::value && + noexcept((std::is_nothrow_constructible::value && std::is_nothrow_constructible::value)) // can't use std::move here as it's not constexpr in C++11: : first(static_cast(p.first)), second(static_cast(p.second)) {} template Q_DECL_RELAXED_CONSTEXPR QPair &operator=(QPair &&p) - Q_DECL_NOEXCEPT_EXPR((std::is_nothrow_assignable::value && + noexcept((std::is_nothrow_assignable::value && std::is_nothrow_assignable::value)) { first = std::move(p.first); second = std::move(p.second); return *this; } #endif Q_DECL_RELAXED_CONSTEXPR void swap(QPair &other) - Q_DECL_NOEXCEPT_EXPR(noexcept(qSwap(other.first, other.first)) && noexcept(qSwap(other.second, other.second))) + noexcept(noexcept(qSwap(other.first, other.first)) && noexcept(qSwap(other.second, other.second))) { // use qSwap() to pick up ADL swaps automatically: qSwap(first, other.first); @@ -103,7 +103,7 @@ QPair(T1, T2) -> QPair; #endif template -void swap(QPair &lhs, QPair &rhs) Q_DECL_NOEXCEPT_EXPR(noexcept(lhs.swap(rhs))) +void swap(QPair &lhs, QPair &rhs) noexcept(noexcept(lhs.swap(rhs))) { lhs.swap(rhs); } // mark QPair as complex/movable/primitive depending on the @@ -113,45 +113,45 @@ class QTypeInfo > : public QTypeInfoMerger, T1, T2> template Q_DECL_CONSTEXPR Q_INLINE_TEMPLATE bool operator==(const QPair &p1, const QPair &p2) - Q_DECL_NOEXCEPT_EXPR(noexcept(p1.first == p2.first && p1.second == p2.second)) + noexcept(noexcept(p1.first == p2.first && p1.second == p2.second)) { return p1.first == p2.first && p1.second == p2.second; } template Q_DECL_CONSTEXPR Q_INLINE_TEMPLATE bool operator!=(const QPair &p1, const QPair &p2) - Q_DECL_NOEXCEPT_EXPR(noexcept(!(p1 == p2))) + noexcept(noexcept(!(p1 == p2))) { return !(p1 == p2); } template Q_DECL_CONSTEXPR Q_INLINE_TEMPLATE bool operator<(const QPair &p1, const QPair &p2) - Q_DECL_NOEXCEPT_EXPR(noexcept(p1.first < p2.first || (!(p2.first < p1.first) && p1.second < p2.second))) + noexcept(noexcept(p1.first < p2.first || (!(p2.first < p1.first) && p1.second < p2.second))) { return p1.first < p2.first || (!(p2.first < p1.first) && p1.second < p2.second); } template Q_DECL_CONSTEXPR Q_INLINE_TEMPLATE bool operator>(const QPair &p1, const QPair &p2) - Q_DECL_NOEXCEPT_EXPR(noexcept(p2 < p1)) + noexcept(noexcept(p2 < p1)) { return p2 < p1; } template Q_DECL_CONSTEXPR Q_INLINE_TEMPLATE bool operator<=(const QPair &p1, const QPair &p2) - Q_DECL_NOEXCEPT_EXPR(noexcept(!(p2 < p1))) + noexcept(noexcept(!(p2 < p1))) { return !(p2 < p1); } template Q_DECL_CONSTEXPR Q_INLINE_TEMPLATE bool operator>=(const QPair &p1, const QPair &p2) - Q_DECL_NOEXCEPT_EXPR(noexcept(!(p1 < p2))) + noexcept(noexcept(!(p1 < p2))) { return !(p1 < p2); } template Q_DECL_CONSTEXPR Q_OUTOFLINE_TEMPLATE QPair qMakePair(const T1 &x, const T2 &y) - Q_DECL_NOEXCEPT_EXPR(noexcept(QPair(x, y))) + noexcept(noexcept(QPair(x, y))) { return QPair(x, y); } diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h index 2a4083466b..a91043faba 100644 --- a/src/corelib/tools/qscopedpointer.h +++ b/src/corelib/tools/qscopedpointer.h @@ -150,7 +150,7 @@ public: return !d; } - void reset(T *other = nullptr) Q_DECL_NOEXCEPT_EXPR(noexcept(Cleanup::cleanup(std::declval()))) + void reset(T *other = nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval()))) { if (d == other) return; diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h index 6640c8486d..323942e1bf 100644 --- a/src/corelib/tools/qset.h +++ b/src/corelib/tools/qset.h @@ -267,7 +267,7 @@ private: template uint qHash(const QSet &key, uint seed = 0) -Q_DECL_NOEXCEPT_EXPR(noexcept(qHashRangeCommutative(key.begin(), key.end(), seed))) +noexcept(noexcept(qHashRangeCommutative(key.begin(), key.end(), seed))) { return qHashRangeCommutative(key.begin(), key.end(), seed); } diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index 597e7464cb..c03fbb2218 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -570,7 +570,7 @@ bool operator!=(const QVarLengthArray &l, const QVarLengthArray bool operator<(const QVarLengthArray &lhs, const QVarLengthArray &rhs) - Q_DECL_NOEXCEPT_EXPR(noexcept(std::lexicographical_compare(lhs.begin(), lhs.end(), + noexcept(noexcept(std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()))) { return std::lexicographical_compare(lhs.begin(), lhs.end(), @@ -579,21 +579,21 @@ bool operator<(const QVarLengthArray &lhs, const QVarLengthArray inline bool operator>(const QVarLengthArray &lhs, const QVarLengthArray &rhs) - Q_DECL_NOEXCEPT_EXPR(noexcept(lhs < rhs)) + noexcept(noexcept(lhs < rhs)) { return rhs < lhs; } template inline bool operator<=(const QVarLengthArray &lhs, const QVarLengthArray &rhs) - Q_DECL_NOEXCEPT_EXPR(noexcept(lhs < rhs)) + noexcept(noexcept(lhs < rhs)) { return !(lhs > rhs); } template inline bool operator>=(const QVarLengthArray &lhs, const QVarLengthArray &rhs) - Q_DECL_NOEXCEPT_EXPR(noexcept(lhs < rhs)) + noexcept(noexcept(lhs < rhs)) { return !(lhs < rhs); } diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 9762ec1b5b..a51b37d02d 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -1062,14 +1062,14 @@ Q_DECLARE_MUTABLE_SEQUENTIAL_ITERATOR(Vector) template uint qHash(const QVector &key, uint seed = 0) - Q_DECL_NOEXCEPT_EXPR(noexcept(qHashRange(key.cbegin(), key.cend(), seed))) + noexcept(noexcept(qHashRange(key.cbegin(), key.cend(), seed))) { return qHashRange(key.cbegin(), key.cend(), seed); } template bool operator<(const QVector &lhs, const QVector &rhs) - Q_DECL_NOEXCEPT_EXPR(noexcept(std::lexicographical_compare(lhs.begin(), lhs.end(), + noexcept(noexcept(std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()))) { return std::lexicographical_compare(lhs.begin(), lhs.end(), @@ -1078,21 +1078,21 @@ bool operator<(const QVector &lhs, const QVector &rhs) template inline bool operator>(const QVector &lhs, const QVector &rhs) - Q_DECL_NOEXCEPT_EXPR(noexcept(lhs < rhs)) + noexcept(noexcept(lhs < rhs)) { return rhs < lhs; } template inline bool operator<=(const QVector &lhs, const QVector &rhs) - Q_DECL_NOEXCEPT_EXPR(noexcept(lhs < rhs)) + noexcept(noexcept(lhs < rhs)) { return !(lhs > rhs); } template inline bool operator>=(const QVector &lhs, const QVector &rhs) - Q_DECL_NOEXCEPT_EXPR(noexcept(lhs < rhs)) + noexcept(noexcept(lhs < rhs)) { return !(lhs < rhs); } diff --git a/src/dbus/qdbusargument.h b/src/dbus/qdbusargument.h index 94a89a4e08..7f4bd269a9 100644 --- a/src/dbus/qdbusargument.h +++ b/src/dbus/qdbusargument.h @@ -77,13 +77,13 @@ public: QDBusArgument(); QDBusArgument(const QDBusArgument &other); #ifdef Q_COMPILER_RVALUE_REFS - QDBusArgument(QDBusArgument &&other) Q_DECL_NOTHROW : d(other.d) { other.d = nullptr; } - QDBusArgument &operator=(QDBusArgument &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QDBusArgument(QDBusArgument &&other) noexcept : d(other.d) { other.d = nullptr; } + QDBusArgument &operator=(QDBusArgument &&other) noexcept { swap(other); return *this; } #endif QDBusArgument &operator=(const QDBusArgument &other); ~QDBusArgument(); - void swap(QDBusArgument &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QDBusArgument &other) noexcept { qSwap(d, other.d); } // used for marshalling (Qt -> D-BUS) QDBusArgument &operator<<(uchar arg); diff --git a/src/dbus/qdbusconnection.h b/src/dbus/qdbusconnection.h index 3711981f78..a880a7a939 100644 --- a/src/dbus/qdbusconnection.h +++ b/src/dbus/qdbusconnection.h @@ -132,13 +132,13 @@ public: explicit QDBusConnection(const QString &name); QDBusConnection(const QDBusConnection &other); #ifdef Q_COMPILER_RVALUE_REFS - QDBusConnection(QDBusConnection &&other) Q_DECL_NOTHROW : d(other.d) { other.d = nullptr; } - QDBusConnection &operator=(QDBusConnection &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QDBusConnection(QDBusConnection &&other) noexcept : d(other.d) { other.d = nullptr; } + QDBusConnection &operator=(QDBusConnection &&other) noexcept { swap(other); return *this; } #endif QDBusConnection &operator=(const QDBusConnection &other); ~QDBusConnection(); - void swap(QDBusConnection &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QDBusConnection &other) noexcept { qSwap(d, other.d); } bool isConnected() const; QString baseService() const; diff --git a/src/dbus/qdbuserror.h b/src/dbus/qdbuserror.h index c264f62b7d..5a68a417c4 100644 --- a/src/dbus/qdbuserror.h +++ b/src/dbus/qdbuserror.h @@ -99,17 +99,17 @@ public: QDBusError(ErrorType error, const QString &message); QDBusError(const QDBusError &other); #ifdef Q_COMPILER_RVALUE_REFS - QDBusError(QDBusError &&other) Q_DECL_NOTHROW + QDBusError(QDBusError &&other) noexcept : code(other.code), msg(std::move(other.msg)), nm(std::move(other.nm)) {} - QDBusError &operator=(QDBusError &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QDBusError &operator=(QDBusError &&other) noexcept { swap(other); return *this; } #endif QDBusError &operator=(const QDBusError &other); #ifndef QT_BOOTSTRAPPED QDBusError &operator=(const QDBusMessage &msg); #endif - void swap(QDBusError &other) Q_DECL_NOTHROW + void swap(QDBusError &other) noexcept { qSwap(code, other.code); qSwap(msg, other.msg); diff --git a/src/dbus/qdbusextratypes.h b/src/dbus/qdbusextratypes.h index 12961e2702..e2430ad6f2 100644 --- a/src/dbus/qdbusextratypes.h +++ b/src/dbus/qdbusextratypes.h @@ -59,7 +59,7 @@ class Q_DBUS_EXPORT QDBusObjectPath { QString m_path; public: - QDBusObjectPath() Q_DECL_NOTHROW : m_path() {} + QDBusObjectPath() noexcept : m_path() {} // compiler-generated copy/move constructor/assignment operators are ok! // compiler-generated destructor is ok! @@ -70,7 +70,7 @@ public: explicit QDBusObjectPath(QString &&p) : m_path(std::move(p)) { doCheck(); } #endif - void swap(QDBusObjectPath &other) Q_DECL_NOTHROW { qSwap(m_path, other.m_path); } + void swap(QDBusObjectPath &other) noexcept { qSwap(m_path, other.m_path); } inline void setPath(const QString &path); @@ -114,7 +114,7 @@ class Q_DBUS_EXPORT QDBusSignature { QString m_signature; public: - QDBusSignature() Q_DECL_NOTHROW : m_signature() {} + QDBusSignature() noexcept : m_signature() {} // compiler-generated copy/move constructor/assignment operators are ok! // compiler-generated destructor is ok! @@ -125,7 +125,7 @@ public: explicit QDBusSignature(QString &&sig) : m_signature(std::move(sig)) { doCheck(); } #endif - void swap(QDBusSignature &other) Q_DECL_NOTHROW { qSwap(m_signature, other.m_signature); } + void swap(QDBusSignature &other) noexcept { qSwap(m_signature, other.m_signature); } inline void setSignature(const QString &signature); @@ -168,16 +168,16 @@ class QDBusVariant { QVariant m_variant; public: - QDBusVariant() Q_DECL_NOTHROW : m_variant() {} + QDBusVariant() noexcept : m_variant() {} // compiler-generated copy/move constructor/assignment operators are ok! // compiler-generated destructor is ok! inline explicit QDBusVariant(const QVariant &variant); #ifdef Q_COMPILER_RVALUE_REFS - explicit QDBusVariant(QVariant &&v) Q_DECL_NOTHROW : m_variant(std::move(v)) {} + explicit QDBusVariant(QVariant &&v) noexcept : m_variant(std::move(v)) {} #endif - void swap(QDBusVariant &other) Q_DECL_NOTHROW { qSwap(m_variant, other.m_variant); } + void swap(QDBusVariant &other) noexcept { qSwap(m_variant, other.m_variant); } inline void setVariant(const QVariant &variant); diff --git a/src/dbus/qdbusintegrator_p.h b/src/dbus/qdbusintegrator_p.h index 0f7e00fde0..a6f7651c73 100644 --- a/src/dbus/qdbusintegrator_p.h +++ b/src/dbus/qdbusintegrator_p.h @@ -86,7 +86,7 @@ struct QDBusSlotCache int slotIdx; QVector metaTypes; - void swap(Data &other) Q_DECL_NOTHROW + void swap(Data &other) noexcept { qSwap(flags, other.flags); qSwap(slotIdx, other.slotIdx); @@ -96,7 +96,7 @@ struct QDBusSlotCache typedef QMultiHash Hash; Hash hash; - void swap(QDBusSlotCache &other) Q_DECL_NOTHROW { qSwap(hash, other.hash); } + void swap(QDBusSlotCache &other) noexcept { qSwap(hash, other.hash); } }; Q_DECLARE_SHARED(QDBusSlotCache::Data) Q_DECLARE_SHARED(QDBusSlotCache) diff --git a/src/dbus/qdbusmessage.h b/src/dbus/qdbusmessage.h index 23e04045d8..3e73db70de 100644 --- a/src/dbus/qdbusmessage.h +++ b/src/dbus/qdbusmessage.h @@ -69,12 +69,12 @@ public: QDBusMessage(); QDBusMessage(const QDBusMessage &other); #ifdef Q_COMPILER_RVALUE_REFS - QDBusMessage &operator=(QDBusMessage &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QDBusMessage &operator=(QDBusMessage &&other) noexcept { swap(other); return *this; } #endif QDBusMessage &operator=(const QDBusMessage &other); ~QDBusMessage(); - void swap(QDBusMessage &other) Q_DECL_NOTHROW { qSwap(d_ptr, other.d_ptr); } + void swap(QDBusMessage &other) noexcept { qSwap(d_ptr, other.d_ptr); } static QDBusMessage createSignal(const QString &path, const QString &interface, const QString &name); diff --git a/src/dbus/qdbuspendingcall.h b/src/dbus/qdbuspendingcall.h index 24b1d6a7ca..c521b7d163 100644 --- a/src/dbus/qdbuspendingcall.h +++ b/src/dbus/qdbuspendingcall.h @@ -61,11 +61,11 @@ public: QDBusPendingCall(const QDBusPendingCall &other); ~QDBusPendingCall(); #ifdef Q_COMPILER_RVALUE_REFS - QDBusPendingCall &operator=(QDBusPendingCall &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QDBusPendingCall &operator=(QDBusPendingCall &&other) noexcept { swap(other); return *this; } #endif QDBusPendingCall &operator=(const QDBusPendingCall &other); - void swap(QDBusPendingCall &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QDBusPendingCall &other) noexcept { qSwap(d, other.d); } #ifndef Q_CLANG_QDOC // pretend that they aren't here diff --git a/src/dbus/qdbusunixfiledescriptor.h b/src/dbus/qdbusunixfiledescriptor.h index ed3209ceda..6b264a6b86 100644 --- a/src/dbus/qdbusunixfiledescriptor.h +++ b/src/dbus/qdbusunixfiledescriptor.h @@ -62,12 +62,12 @@ public: explicit QDBusUnixFileDescriptor(int fileDescriptor); QDBusUnixFileDescriptor(const QDBusUnixFileDescriptor &other); #if defined(Q_COMPILER_RVALUE_REFS) - QDBusUnixFileDescriptor &operator=(QDBusUnixFileDescriptor &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QDBusUnixFileDescriptor &operator=(QDBusUnixFileDescriptor &&other) noexcept { swap(other); return *this; } #endif QDBusUnixFileDescriptor &operator=(const QDBusUnixFileDescriptor &other); ~QDBusUnixFileDescriptor(); - void swap(QDBusUnixFileDescriptor &other) Q_DECL_NOTHROW + void swap(QDBusUnixFileDescriptor &other) noexcept { qSwap(d, other.d); } bool isValid() const; diff --git a/src/network/access/qabstractnetworkcache.h b/src/network/access/qabstractnetworkcache.h index 678bae2d6e..b604323c41 100644 --- a/src/network/access/qabstractnetworkcache.h +++ b/src/network/access/qabstractnetworkcache.h @@ -68,11 +68,11 @@ public: ~QNetworkCacheMetaData(); #ifdef Q_COMPILER_RVALUE_REFS - QNetworkCacheMetaData &operator=(QNetworkCacheMetaData &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QNetworkCacheMetaData &operator=(QNetworkCacheMetaData &&other) noexcept { swap(other); return *this; } #endif QNetworkCacheMetaData &operator=(const QNetworkCacheMetaData &other); - void swap(QNetworkCacheMetaData &other) Q_DECL_NOTHROW + void swap(QNetworkCacheMetaData &other) noexcept { qSwap(d, other.d); } bool operator==(const QNetworkCacheMetaData &other) const; diff --git a/src/network/access/qhstspolicy.h b/src/network/access/qhstspolicy.h index 176a8fa635..f1b2ee99e5 100644 --- a/src/network/access/qhstspolicy.h +++ b/src/network/access/qhstspolicy.h @@ -65,10 +65,10 @@ public: QUrl::ParsingMode mode = QUrl::DecodedMode); QHstsPolicy(const QHstsPolicy &rhs); QHstsPolicy &operator=(const QHstsPolicy &rhs); - QHstsPolicy &operator=(QHstsPolicy &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QHstsPolicy &operator=(QHstsPolicy &&other) noexcept { swap(other); return *this; } ~QHstsPolicy(); - void swap(QHstsPolicy &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QHstsPolicy &other) noexcept { qSwap(d, other.d); } void setHost(const QString &host, QUrl::ParsingMode mode = QUrl::DecodedMode); QString host(QUrl::ComponentFormattingOptions options = QUrl::FullyDecoded) const; diff --git a/src/network/access/qhttpmultipart.h b/src/network/access/qhttpmultipart.h index 78585a704d..f718d51d0c 100644 --- a/src/network/access/qhttpmultipart.h +++ b/src/network/access/qhttpmultipart.h @@ -61,11 +61,11 @@ public: QHttpPart(const QHttpPart &other); ~QHttpPart(); #ifdef Q_COMPILER_RVALUE_REFS - QHttpPart &operator=(QHttpPart &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QHttpPart &operator=(QHttpPart &&other) noexcept { swap(other); return *this; } #endif QHttpPart &operator=(const QHttpPart &other); - void swap(QHttpPart &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QHttpPart &other) noexcept { qSwap(d, other.d); } bool operator==(const QHttpPart &other) const; inline bool operator!=(const QHttpPart &other) const diff --git a/src/network/access/qnetworkcookie.h b/src/network/access/qnetworkcookie.h index e462b98555..58c504f9ae 100644 --- a/src/network/access/qnetworkcookie.h +++ b/src/network/access/qnetworkcookie.h @@ -67,11 +67,11 @@ public: QNetworkCookie(const QNetworkCookie &other); ~QNetworkCookie(); #ifdef Q_COMPILER_RVALUE_REFS - QNetworkCookie &operator=(QNetworkCookie &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QNetworkCookie &operator=(QNetworkCookie &&other) noexcept { swap(other); return *this; } #endif QNetworkCookie &operator=(const QNetworkCookie &other); - void swap(QNetworkCookie &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QNetworkCookie &other) noexcept { qSwap(d, other.d); } bool operator==(const QNetworkCookie &other) const; inline bool operator!=(const QNetworkCookie &other) const diff --git a/src/network/access/qnetworkrequest.h b/src/network/access/qnetworkrequest.h index efb9cbecba..2515ff6ead 100644 --- a/src/network/access/qnetworkrequest.h +++ b/src/network/access/qnetworkrequest.h @@ -131,11 +131,11 @@ public: QNetworkRequest(const QNetworkRequest &other); ~QNetworkRequest(); #ifdef Q_COMPILER_RVALUE_REFS - QNetworkRequest &operator=(QNetworkRequest &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QNetworkRequest &operator=(QNetworkRequest &&other) noexcept { swap(other); return *this; } #endif QNetworkRequest &operator=(const QNetworkRequest &other); - void swap(QNetworkRequest &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QNetworkRequest &other) noexcept { qSwap(d, other.d); } bool operator==(const QNetworkRequest &other) const; inline bool operator!=(const QNetworkRequest &other) const diff --git a/src/network/bearer/qnetworkconfiguration.h b/src/network/bearer/qnetworkconfiguration.h index e7b74034fc..41b6e6f020 100644 --- a/src/network/bearer/qnetworkconfiguration.h +++ b/src/network/bearer/qnetworkconfiguration.h @@ -56,12 +56,12 @@ public: QNetworkConfiguration(); QNetworkConfiguration(const QNetworkConfiguration& other); #ifdef Q_COMPILER_RVALUE_REFS - QNetworkConfiguration &operator=(QNetworkConfiguration &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QNetworkConfiguration &operator=(QNetworkConfiguration &&other) noexcept { swap(other); return *this; } #endif QNetworkConfiguration &operator=(const QNetworkConfiguration &other); ~QNetworkConfiguration(); - void swap(QNetworkConfiguration &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QNetworkConfiguration &other) noexcept { qSwap(d, other.d); } bool operator==(const QNetworkConfiguration &other) const; inline bool operator!=(const QNetworkConfiguration &other) const diff --git a/src/network/kernel/qdnslookup.h b/src/network/kernel/qdnslookup.h index eebd0abe66..79a476b98f 100644 --- a/src/network/kernel/qdnslookup.h +++ b/src/network/kernel/qdnslookup.h @@ -65,12 +65,12 @@ public: QDnsDomainNameRecord(); QDnsDomainNameRecord(const QDnsDomainNameRecord &other); #ifdef Q_COMPILER_RVALUE_REFS - QDnsDomainNameRecord &operator=(QDnsDomainNameRecord &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QDnsDomainNameRecord &operator=(QDnsDomainNameRecord &&other) noexcept { swap(other); return *this; } #endif QDnsDomainNameRecord &operator=(const QDnsDomainNameRecord &other); ~QDnsDomainNameRecord(); - void swap(QDnsDomainNameRecord &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QDnsDomainNameRecord &other) noexcept { qSwap(d, other.d); } QString name() const; quint32 timeToLive() const; @@ -89,12 +89,12 @@ public: QDnsHostAddressRecord(); QDnsHostAddressRecord(const QDnsHostAddressRecord &other); #ifdef Q_COMPILER_RVALUE_REFS - QDnsHostAddressRecord &operator=(QDnsHostAddressRecord &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QDnsHostAddressRecord &operator=(QDnsHostAddressRecord &&other) noexcept { swap(other); return *this; } #endif QDnsHostAddressRecord &operator=(const QDnsHostAddressRecord &other); ~QDnsHostAddressRecord(); - void swap(QDnsHostAddressRecord &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QDnsHostAddressRecord &other) noexcept { qSwap(d, other.d); } QString name() const; quint32 timeToLive() const; @@ -113,12 +113,12 @@ public: QDnsMailExchangeRecord(); QDnsMailExchangeRecord(const QDnsMailExchangeRecord &other); #ifdef Q_COMPILER_RVALUE_REFS - QDnsMailExchangeRecord &operator=(QDnsMailExchangeRecord &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QDnsMailExchangeRecord &operator=(QDnsMailExchangeRecord &&other) noexcept { swap(other); return *this; } #endif QDnsMailExchangeRecord &operator=(const QDnsMailExchangeRecord &other); ~QDnsMailExchangeRecord(); - void swap(QDnsMailExchangeRecord &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QDnsMailExchangeRecord &other) noexcept { qSwap(d, other.d); } QString exchange() const; QString name() const; @@ -138,12 +138,12 @@ public: QDnsServiceRecord(); QDnsServiceRecord(const QDnsServiceRecord &other); #ifdef Q_COMPILER_RVALUE_REFS - QDnsServiceRecord &operator=(QDnsServiceRecord &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QDnsServiceRecord &operator=(QDnsServiceRecord &&other) noexcept { swap(other); return *this; } #endif QDnsServiceRecord &operator=(const QDnsServiceRecord &other); ~QDnsServiceRecord(); - void swap(QDnsServiceRecord &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QDnsServiceRecord &other) noexcept { qSwap(d, other.d); } QString name() const; quint16 port() const; @@ -165,12 +165,12 @@ public: QDnsTextRecord(); QDnsTextRecord(const QDnsTextRecord &other); #ifdef Q_COMPILER_RVALUE_REFS - QDnsTextRecord &operator=(QDnsTextRecord &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QDnsTextRecord &operator=(QDnsTextRecord &&other) noexcept { swap(other); return *this; } #endif QDnsTextRecord &operator=(const QDnsTextRecord &other); ~QDnsTextRecord(); - void swap(QDnsTextRecord &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QDnsTextRecord &other) noexcept { qSwap(d, other.d); } QString name() const; quint32 timeToLive() const; diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index fba91c62c8..644f4336ca 100644 --- a/src/network/kernel/qhostaddress.cpp +++ b/src/network/kernel/qhostaddress.cpp @@ -1333,7 +1333,7 @@ QDebug operator<<(QDebug d, const QHostAddress &address) \relates QHostAddress Returns a hash of the host address \a key, using \a seed to seed the calculation. */ -uint qHash(const QHostAddress &key, uint seed) Q_DECL_NOTHROW +uint qHash(const QHostAddress &key, uint seed) noexcept { return qHashBits(key.d->a6.c, 16, seed); } diff --git a/src/network/kernel/qhostaddress.h b/src/network/kernel/qhostaddress.h index 00555f3d8e..f20da3304f 100644 --- a/src/network/kernel/qhostaddress.h +++ b/src/network/kernel/qhostaddress.h @@ -66,7 +66,7 @@ typedef QIPv6Address Q_IPV6ADDR; class QHostAddress; // qHash is a friend, but we can't use default arguments for friends (§8.3.6.4) -Q_NETWORK_EXPORT uint qHash(const QHostAddress &key, uint seed = 0) Q_DECL_NOTHROW; +Q_NETWORK_EXPORT uint qHash(const QHostAddress &key, uint seed = 0) noexcept; class Q_NETWORK_EXPORT QHostAddress { @@ -103,7 +103,7 @@ public: ~QHostAddress(); #ifdef Q_COMPILER_RVALUE_REFS - QHostAddress &operator=(QHostAddress &&other) Q_DECL_NOTHROW + QHostAddress &operator=(QHostAddress &&other) noexcept { swap(other); return *this; } #endif @@ -114,7 +114,7 @@ public: #endif QHostAddress &operator=(SpecialAddress address); - void swap(QHostAddress &other) Q_DECL_NOTHROW { d.swap(other.d); } + void swap(QHostAddress &other) noexcept { d.swap(other.d); } void setAddress(quint32 ip4Addr); void setAddress(quint8 *ip6Addr); // ### Qt 6: remove me @@ -157,7 +157,7 @@ public: static QPair parseSubnet(const QString &subnet); - friend Q_NETWORK_EXPORT uint qHash(const QHostAddress &key, uint seed) Q_DECL_NOTHROW; + friend Q_NETWORK_EXPORT uint qHash(const QHostAddress &key, uint seed) noexcept; protected: friend class QHostAddressPrivate; QExplicitlySharedDataPointer d; diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index 1c7a8da06d..71d1aae35a 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -64,8 +64,8 @@ Q_GLOBAL_STATIC(QHostInfoLookupManager, theHostInfoLookupManager) namespace { struct ToBeLookedUpEquals { typedef bool result_type; - explicit ToBeLookedUpEquals(const QString &toBeLookedUp) Q_DECL_NOTHROW : m_toBeLookedUp(toBeLookedUp) {} - result_type operator()(QHostInfoRunnable* lookup) const Q_DECL_NOTHROW + explicit ToBeLookedUpEquals(const QString &toBeLookedUp) noexcept : m_toBeLookedUp(toBeLookedUp) {} + result_type operator()(QHostInfoRunnable* lookup) const noexcept { return m_toBeLookedUp == lookup->toBeLookedUp; } diff --git a/src/network/kernel/qhostinfo.h b/src/network/kernel/qhostinfo.h index 49871ad470..dc31cc08e4 100644 --- a/src/network/kernel/qhostinfo.h +++ b/src/network/kernel/qhostinfo.h @@ -63,10 +63,10 @@ public: explicit QHostInfo(int lookupId = -1); QHostInfo(const QHostInfo &d); QHostInfo &operator=(const QHostInfo &d); - QHostInfo &operator=(QHostInfo &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QHostInfo &operator=(QHostInfo &&other) noexcept { swap(other); return *this; } ~QHostInfo(); - void swap(QHostInfo &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QHostInfo &other) noexcept { qSwap(d, other.d); } QString hostName() const; void setHostName(const QString &name); diff --git a/src/network/kernel/qnetworkdatagram.h b/src/network/kernel/qnetworkdatagram.h index 1acb44a1e0..70958fea42 100644 --- a/src/network/kernel/qnetworkdatagram.h +++ b/src/network/kernel/qnetworkdatagram.h @@ -61,13 +61,13 @@ public: ~QNetworkDatagram() { if (d) destroy(d); } - QNetworkDatagram(QNetworkDatagram &&other) Q_DECL_NOTHROW + QNetworkDatagram(QNetworkDatagram &&other) noexcept : d(other.d) { other.d = nullptr; } - QNetworkDatagram &operator=(QNetworkDatagram &&other) Q_DECL_NOTHROW + QNetworkDatagram &operator=(QNetworkDatagram &&other) noexcept { swap(other); return *this; } - void swap(QNetworkDatagram &other) Q_DECL_NOTHROW + void swap(QNetworkDatagram &other) noexcept { qSwap(d, other.d); } void clear(); diff --git a/src/network/kernel/qnetworkinterface.h b/src/network/kernel/qnetworkinterface.h index 148fd5e10d..1d3286118e 100644 --- a/src/network/kernel/qnetworkinterface.h +++ b/src/network/kernel/qnetworkinterface.h @@ -65,12 +65,12 @@ public: QNetworkAddressEntry(); QNetworkAddressEntry(const QNetworkAddressEntry &other); #ifdef Q_COMPILER_RVALUE_REFS - QNetworkAddressEntry &operator=(QNetworkAddressEntry &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QNetworkAddressEntry &operator=(QNetworkAddressEntry &&other) noexcept { swap(other); return *this; } #endif QNetworkAddressEntry &operator=(const QNetworkAddressEntry &other); ~QNetworkAddressEntry(); - void swap(QNetworkAddressEntry &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QNetworkAddressEntry &other) noexcept { qSwap(d, other.d); } bool operator==(const QNetworkAddressEntry &other) const; inline bool operator!=(const QNetworkAddressEntry &other) const @@ -143,12 +143,12 @@ public: QNetworkInterface(); QNetworkInterface(const QNetworkInterface &other); #ifdef Q_COMPILER_RVALUE_REFS - QNetworkInterface &operator=(QNetworkInterface &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QNetworkInterface &operator=(QNetworkInterface &&other) noexcept { swap(other); return *this; } #endif QNetworkInterface &operator=(const QNetworkInterface &other); ~QNetworkInterface(); - void swap(QNetworkInterface &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QNetworkInterface &other) noexcept { qSwap(d, other.d); } bool isValid() const; diff --git a/src/network/kernel/qnetworkproxy.h b/src/network/kernel/qnetworkproxy.h index 7e3e6906a8..0b1bc02695 100644 --- a/src/network/kernel/qnetworkproxy.h +++ b/src/network/kernel/qnetworkproxy.h @@ -90,12 +90,12 @@ public: #endif QNetworkProxyQuery(const QNetworkProxyQuery &other); #ifdef Q_COMPILER_RVALUE_REFS - QNetworkProxyQuery &operator=(QNetworkProxyQuery &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QNetworkProxyQuery &operator=(QNetworkProxyQuery &&other) noexcept { swap(other); return *this; } #endif QNetworkProxyQuery &operator=(const QNetworkProxyQuery &other); ~QNetworkProxyQuery(); - void swap(QNetworkProxyQuery &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QNetworkProxyQuery &other) noexcept { qSwap(d, other.d); } bool operator==(const QNetworkProxyQuery &other) const; inline bool operator!=(const QNetworkProxyQuery &other) const @@ -162,12 +162,12 @@ public: const QString &user = QString(), const QString &password = QString()); QNetworkProxy(const QNetworkProxy &other); #ifdef Q_COMPILER_RVALUE_REFS - QNetworkProxy &operator=(QNetworkProxy &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QNetworkProxy &operator=(QNetworkProxy &&other) noexcept { swap(other); return *this; } #endif QNetworkProxy &operator=(const QNetworkProxy &other); ~QNetworkProxy(); - void swap(QNetworkProxy &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QNetworkProxy &other) noexcept { qSwap(d, other.d); } bool operator==(const QNetworkProxy &other) const; inline bool operator!=(const QNetworkProxy &other) const diff --git a/src/network/ssl/qocspresponse.cpp b/src/network/ssl/qocspresponse.cpp index d564e817ca..79f0cfd1d4 100644 --- a/src/network/ssl/qocspresponse.cpp +++ b/src/network/ssl/qocspresponse.cpp @@ -133,7 +133,7 @@ QOcspResponse::QOcspResponse(const QOcspResponse &) = default; Move-constructs a QOcspResponse instance. */ -QOcspResponse::QOcspResponse(QOcspResponse &&) Q_DECL_NOTHROW = default; +QOcspResponse::QOcspResponse(QOcspResponse &&) noexcept = default; /*! \since 5.13 @@ -154,7 +154,7 @@ QOcspResponse &QOcspResponse::operator=(const QOcspResponse &) = default; Move-assigns to this QOcspResponse instance. */ -QOcspResponse &QOcspResponse::operator=(QOcspResponse &&) Q_DECL_NOTHROW = default; +QOcspResponse &QOcspResponse::operator=(QOcspResponse &&) noexcept = default; /*! \fn void QOcspResponse::swap(QOcspResponse &other) diff --git a/src/network/ssl/qocspresponse.h b/src/network/ssl/qocspresponse.h index 552a088ba5..0e134d236b 100644 --- a/src/network/ssl/qocspresponse.h +++ b/src/network/ssl/qocspresponse.h @@ -82,11 +82,11 @@ public: QOcspResponse(); QOcspResponse(const QOcspResponse &other); - QOcspResponse(QOcspResponse && other) Q_DECL_NOEXCEPT; + QOcspResponse(QOcspResponse && other) noexcept; ~QOcspResponse(); QOcspResponse &operator = (const QOcspResponse &other); - QOcspResponse &operator = (QOcspResponse &&other) Q_DECL_NOTHROW; + QOcspResponse &operator = (QOcspResponse &&other) noexcept; QOcspCertificateStatus certificateStatus() const; QOcspRevocationReason revocationReason() const; @@ -94,7 +94,7 @@ public: class QSslCertificate responder() const; QSslCertificate subject() const; - void swap(QOcspResponse &other) Q_DECL_NOTHROW { d.swap(other.d); } + void swap(QOcspResponse &other) noexcept { d.swap(other.d); } private: diff --git a/src/network/ssl/qsslcertificate.h b/src/network/ssl/qsslcertificate.h index 266fcdacb4..a6acfa2cc3 100644 --- a/src/network/ssl/qsslcertificate.h +++ b/src/network/ssl/qsslcertificate.h @@ -66,7 +66,7 @@ class QStringList; class QSslCertificate; // qHash is a friend, but we can't use default arguments for friends (§8.3.6.4) -Q_NETWORK_EXPORT uint qHash(const QSslCertificate &key, uint seed = 0) Q_DECL_NOTHROW; +Q_NETWORK_EXPORT uint qHash(const QSslCertificate &key, uint seed = 0) noexcept; class QSslCertificatePrivate; class Q_NETWORK_EXPORT QSslCertificate @@ -89,11 +89,11 @@ public: QSslCertificate(const QSslCertificate &other); ~QSslCertificate(); #ifdef Q_COMPILER_RVALUE_REFS - QSslCertificate &operator=(QSslCertificate &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QSslCertificate &operator=(QSslCertificate &&other) noexcept { swap(other); return *this; } #endif QSslCertificate &operator=(const QSslCertificate &other); - void swap(QSslCertificate &other) Q_DECL_NOTHROW + void swap(QSslCertificate &other) noexcept { qSwap(d, other.d); } bool operator==(const QSslCertificate &other) const; @@ -169,7 +169,7 @@ private: friend class QSslCertificatePrivate; friend class QSslSocketBackendPrivate; - friend Q_NETWORK_EXPORT uint qHash(const QSslCertificate &key, uint seed) Q_DECL_NOTHROW; + friend Q_NETWORK_EXPORT uint qHash(const QSslCertificate &key, uint seed) noexcept; }; Q_DECLARE_SHARED(QSslCertificate) diff --git a/src/network/ssl/qsslcertificate_openssl.cpp b/src/network/ssl/qsslcertificate_openssl.cpp index 899c8a0d2d..806c6426e4 100644 --- a/src/network/ssl/qsslcertificate_openssl.cpp +++ b/src/network/ssl/qsslcertificate_openssl.cpp @@ -65,7 +65,7 @@ bool QSslCertificate::operator==(const QSslCertificate &other) const return false; } -uint qHash(const QSslCertificate &key, uint seed) Q_DECL_NOTHROW +uint qHash(const QSslCertificate &key, uint seed) noexcept { if (X509 * const x509 = key.d->x509) { const EVP_MD *sha1 = q_EVP_sha1(); diff --git a/src/network/ssl/qsslcertificate_qt.cpp b/src/network/ssl/qsslcertificate_qt.cpp index cce59b5ef3..8b5035ad96 100644 --- a/src/network/ssl/qsslcertificate_qt.cpp +++ b/src/network/ssl/qsslcertificate_qt.cpp @@ -64,7 +64,7 @@ bool QSslCertificate::operator==(const QSslCertificate &other) const return d->derData == other.d->derData; } -uint qHash(const QSslCertificate &key, uint seed) Q_DECL_NOTHROW +uint qHash(const QSslCertificate &key, uint seed) noexcept { // DER is the native encoding here, so toDer() is just "return d->derData": return qHash(key.toDer(), seed); diff --git a/src/network/ssl/qsslcertificateextension.h b/src/network/ssl/qsslcertificateextension.h index c2910e1707..f862015312 100644 --- a/src/network/ssl/qsslcertificateextension.h +++ b/src/network/ssl/qsslcertificateextension.h @@ -56,12 +56,12 @@ public: QSslCertificateExtension(); QSslCertificateExtension(const QSslCertificateExtension &other); #ifdef Q_COMPILER_RVALUE_REFS - QSslCertificateExtension &operator=(QSslCertificateExtension &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QSslCertificateExtension &operator=(QSslCertificateExtension &&other) noexcept { swap(other); return *this; } #endif QSslCertificateExtension &operator=(const QSslCertificateExtension &other); ~QSslCertificateExtension(); - void swap(QSslCertificateExtension &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QSslCertificateExtension &other) noexcept { qSwap(d, other.d); } QString oid() const; QString name() const; diff --git a/src/network/ssl/qsslcipher.h b/src/network/ssl/qsslcipher.h index c6328e0169..430fe9aa7c 100644 --- a/src/network/ssl/qsslcipher.h +++ b/src/network/ssl/qsslcipher.h @@ -60,12 +60,12 @@ public: QSslCipher(const QString &name, QSsl::SslProtocol protocol); QSslCipher(const QSslCipher &other); #ifdef Q_COMPILER_RVALUE_REFS - QSslCipher &operator=(QSslCipher &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QSslCipher &operator=(QSslCipher &&other) noexcept { swap(other); return *this; } #endif QSslCipher &operator=(const QSslCipher &other); ~QSslCipher(); - void swap(QSslCipher &other) Q_DECL_NOTHROW + void swap(QSslCipher &other) noexcept { qSwap(d, other.d); } bool operator==(const QSslCipher &other) const; diff --git a/src/network/ssl/qsslconfiguration.h b/src/network/ssl/qsslconfiguration.h index 8f53e25a53..16704ba17b 100644 --- a/src/network/ssl/qsslconfiguration.h +++ b/src/network/ssl/qsslconfiguration.h @@ -86,11 +86,11 @@ public: QSslConfiguration(const QSslConfiguration &other); ~QSslConfiguration(); #ifdef Q_COMPILER_RVALUE_REFS - QSslConfiguration &operator=(QSslConfiguration &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QSslConfiguration &operator=(QSslConfiguration &&other) noexcept { swap(other); return *this; } #endif QSslConfiguration &operator=(const QSslConfiguration &other); - void swap(QSslConfiguration &other) Q_DECL_NOTHROW + void swap(QSslConfiguration &other) noexcept { qSwap(d, other.d); } bool operator==(const QSslConfiguration &other) const; diff --git a/src/network/ssl/qssldiffiehellmanparameters.cpp b/src/network/ssl/qssldiffiehellmanparameters.cpp index 65041d4456..7807afaa30 100644 --- a/src/network/ssl/qssldiffiehellmanparameters.cpp +++ b/src/network/ssl/qssldiffiehellmanparameters.cpp @@ -213,7 +213,7 @@ QSslDiffieHellmanParameters &QSslDiffieHellmanParameters::operator=(const QSslDi Setting an empty QSslDiffieHellmanParameters instance on a QSslSocket-based server will disable Diffie-Hellman key exchange. */ -bool QSslDiffieHellmanParameters::isEmpty() const Q_DECL_NOTHROW +bool QSslDiffieHellmanParameters::isEmpty() const noexcept { return d->derData.isNull() && d->error == QSslDiffieHellmanParameters::NoError; } @@ -229,7 +229,7 @@ bool QSslDiffieHellmanParameters::isEmpty() const Q_DECL_NOTHROW \sa error() */ -bool QSslDiffieHellmanParameters::isValid() const Q_DECL_NOTHROW +bool QSslDiffieHellmanParameters::isValid() const noexcept { return d->error == QSslDiffieHellmanParameters::NoError; } @@ -253,7 +253,7 @@ bool QSslDiffieHellmanParameters::isValid() const Q_DECL_NOTHROW Returns the error that caused the QSslDiffieHellmanParameters object to be invalid. */ -QSslDiffieHellmanParameters::Error QSslDiffieHellmanParameters::error() const Q_DECL_NOTHROW +QSslDiffieHellmanParameters::Error QSslDiffieHellmanParameters::error() const noexcept { return d->error; } @@ -262,7 +262,7 @@ QSslDiffieHellmanParameters::Error QSslDiffieHellmanParameters::error() const Q_ Returns a human-readable description of the error that caused the QSslDiffieHellmanParameters object to be invalid. */ -QString QSslDiffieHellmanParameters::errorString() const Q_DECL_NOTHROW +QString QSslDiffieHellmanParameters::errorString() const noexcept { switch (d->error) { case QSslDiffieHellmanParameters::NoError: @@ -283,7 +283,7 @@ QString QSslDiffieHellmanParameters::errorString() const Q_DECL_NOTHROW Returns \c true if \a lhs is equal to \a rhs; otherwise returns \c false. */ -bool operator==(const QSslDiffieHellmanParameters &lhs, const QSslDiffieHellmanParameters &rhs) Q_DECL_NOTHROW +bool operator==(const QSslDiffieHellmanParameters &lhs, const QSslDiffieHellmanParameters &rhs) noexcept { return lhs.d->derData == rhs.d->derData; } @@ -316,7 +316,7 @@ QDebug operator<<(QDebug debug, const QSslDiffieHellmanParameters &dhparam) Returns an hash value for \a dhparam, using \a seed to seed the calculation. */ -uint qHash(const QSslDiffieHellmanParameters &dhparam, uint seed) Q_DECL_NOTHROW +uint qHash(const QSslDiffieHellmanParameters &dhparam, uint seed) noexcept { return qHash(dhparam.d->derData, seed); } diff --git a/src/network/ssl/qssldiffiehellmanparameters.h b/src/network/ssl/qssldiffiehellmanparameters.h index 497d2bebfb..f62a3b8f44 100644 --- a/src/network/ssl/qssldiffiehellmanparameters.h +++ b/src/network/ssl/qssldiffiehellmanparameters.h @@ -56,16 +56,16 @@ class QSslDiffieHellmanParametersPrivate; class QSslDiffieHellmanParameters; // qHash is a friend, but we can't use default arguments for friends (§8.3.6.4) -Q_NETWORK_EXPORT uint qHash(const QSslDiffieHellmanParameters &dhparam, uint seed = 0) Q_DECL_NOTHROW; +Q_NETWORK_EXPORT uint qHash(const QSslDiffieHellmanParameters &dhparam, uint seed = 0) noexcept; #ifndef QT_NO_DEBUG_STREAM class QDebug; Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QSslDiffieHellmanParameters &dhparams); #endif -Q_NETWORK_EXPORT bool operator==(const QSslDiffieHellmanParameters &lhs, const QSslDiffieHellmanParameters &rhs) Q_DECL_NOTHROW; +Q_NETWORK_EXPORT bool operator==(const QSslDiffieHellmanParameters &lhs, const QSslDiffieHellmanParameters &rhs) noexcept; -inline bool operator!=(const QSslDiffieHellmanParameters &lhs, const QSslDiffieHellmanParameters &rhs) Q_DECL_NOTHROW +inline bool operator!=(const QSslDiffieHellmanParameters &lhs, const QSslDiffieHellmanParameters &rhs) noexcept { return !operator==(lhs, rhs); } @@ -83,30 +83,30 @@ public: Q_NETWORK_EXPORT QSslDiffieHellmanParameters(); Q_NETWORK_EXPORT QSslDiffieHellmanParameters(const QSslDiffieHellmanParameters &other); - QSslDiffieHellmanParameters(QSslDiffieHellmanParameters &&other) Q_DECL_NOTHROW : d(other.d) { other.d = nullptr; } + QSslDiffieHellmanParameters(QSslDiffieHellmanParameters &&other) noexcept : d(other.d) { other.d = nullptr; } Q_NETWORK_EXPORT ~QSslDiffieHellmanParameters(); Q_NETWORK_EXPORT QSslDiffieHellmanParameters &operator=(const QSslDiffieHellmanParameters &other); - QSslDiffieHellmanParameters &operator=(QSslDiffieHellmanParameters &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QSslDiffieHellmanParameters &operator=(QSslDiffieHellmanParameters &&other) noexcept { swap(other); return *this; } - void swap(QSslDiffieHellmanParameters &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QSslDiffieHellmanParameters &other) noexcept { qSwap(d, other.d); } Q_NETWORK_EXPORT static QSslDiffieHellmanParameters fromEncoded(const QByteArray &encoded, QSsl::EncodingFormat format = QSsl::Pem); Q_NETWORK_EXPORT static QSslDiffieHellmanParameters fromEncoded(QIODevice *device, QSsl::EncodingFormat format = QSsl::Pem); - Q_NETWORK_EXPORT bool isEmpty() const Q_DECL_NOTHROW; - Q_NETWORK_EXPORT bool isValid() const Q_DECL_NOTHROW; - Q_NETWORK_EXPORT Error error() const Q_DECL_NOTHROW; - Q_NETWORK_EXPORT QString errorString() const Q_DECL_NOTHROW; + Q_NETWORK_EXPORT bool isEmpty() const noexcept; + Q_NETWORK_EXPORT bool isValid() const noexcept; + Q_NETWORK_EXPORT Error error() const noexcept; + Q_NETWORK_EXPORT QString errorString() const noexcept; private: QSslDiffieHellmanParametersPrivate *d; friend class QSslContext; - friend Q_NETWORK_EXPORT bool operator==(const QSslDiffieHellmanParameters &lhs, const QSslDiffieHellmanParameters &rhs) Q_DECL_NOTHROW; + friend Q_NETWORK_EXPORT bool operator==(const QSslDiffieHellmanParameters &lhs, const QSslDiffieHellmanParameters &rhs) noexcept; #ifndef QT_NO_DEBUG_STREAM friend Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QSslDiffieHellmanParameters &dhparam); #endif - friend Q_NETWORK_EXPORT uint qHash(const QSslDiffieHellmanParameters &dhparam, uint seed) Q_DECL_NOTHROW; + friend Q_NETWORK_EXPORT uint qHash(const QSslDiffieHellmanParameters &dhparam, uint seed) noexcept; }; Q_DECLARE_SHARED(QSslDiffieHellmanParameters) diff --git a/src/network/ssl/qsslellipticcurve.h b/src/network/ssl/qsslellipticcurve.h index 57dda19bad..28de3a03b4 100644 --- a/src/network/ssl/qsslellipticcurve.h +++ b/src/network/ssl/qsslellipticcurve.h @@ -52,11 +52,11 @@ QT_BEGIN_NAMESPACE class QSslEllipticCurve; // qHash is a friend, but we can't use default arguments for friends (§8.3.6.4) -Q_DECL_CONSTEXPR uint qHash(QSslEllipticCurve curve, uint seed = 0) Q_DECL_NOTHROW; +Q_DECL_CONSTEXPR uint qHash(QSslEllipticCurve curve, uint seed = 0) noexcept; class QSslEllipticCurve { public: - Q_DECL_CONSTEXPR QSslEllipticCurve() Q_DECL_NOTHROW + Q_DECL_CONSTEXPR QSslEllipticCurve() noexcept : id(0) { } @@ -67,18 +67,18 @@ public: Q_REQUIRED_RESULT Q_NETWORK_EXPORT QString shortName() const; Q_REQUIRED_RESULT Q_NETWORK_EXPORT QString longName() const; - Q_DECL_CONSTEXPR bool isValid() const Q_DECL_NOTHROW + Q_DECL_CONSTEXPR bool isValid() const noexcept { return id != 0; } - Q_NETWORK_EXPORT bool isTlsNamedCurve() const Q_DECL_NOTHROW; + Q_NETWORK_EXPORT bool isTlsNamedCurve() const noexcept; private: int id; - friend Q_DECL_CONSTEXPR bool operator==(QSslEllipticCurve lhs, QSslEllipticCurve rhs) Q_DECL_NOTHROW; - friend Q_DECL_CONSTEXPR uint qHash(QSslEllipticCurve curve, uint seed) Q_DECL_NOTHROW; + friend Q_DECL_CONSTEXPR bool operator==(QSslEllipticCurve lhs, QSslEllipticCurve rhs) noexcept; + friend Q_DECL_CONSTEXPR uint qHash(QSslEllipticCurve curve, uint seed) noexcept; friend class QSslContext; friend class QSslSocketPrivate; @@ -87,13 +87,13 @@ private: Q_DECLARE_TYPEINFO(QSslEllipticCurve, Q_PRIMITIVE_TYPE); -Q_DECL_CONSTEXPR inline uint qHash(QSslEllipticCurve curve, uint seed) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline uint qHash(QSslEllipticCurve curve, uint seed) noexcept { return qHash(curve.id, seed); } -Q_DECL_CONSTEXPR inline bool operator==(QSslEllipticCurve lhs, QSslEllipticCurve rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator==(QSslEllipticCurve lhs, QSslEllipticCurve rhs) noexcept { return lhs.id == rhs.id; } -Q_DECL_CONSTEXPR inline bool operator!=(QSslEllipticCurve lhs, QSslEllipticCurve rhs) Q_DECL_NOTHROW +Q_DECL_CONSTEXPR inline bool operator!=(QSslEllipticCurve lhs, QSslEllipticCurve rhs) noexcept { return !operator==(lhs, rhs); } #ifndef QT_NO_DEBUG_STREAM diff --git a/src/network/ssl/qsslellipticcurve_dummy.cpp b/src/network/ssl/qsslellipticcurve_dummy.cpp index 93e081b9e0..1313e06875 100644 --- a/src/network/ssl/qsslellipticcurve_dummy.cpp +++ b/src/network/ssl/qsslellipticcurve_dummy.cpp @@ -63,7 +63,7 @@ QSslEllipticCurve QSslEllipticCurve::fromLongName(const QString &name) return QSslEllipticCurve(); } -bool QSslEllipticCurve::isTlsNamedCurve() const Q_DECL_NOTHROW +bool QSslEllipticCurve::isTlsNamedCurve() const noexcept { return false; } diff --git a/src/network/ssl/qsslellipticcurve_openssl.cpp b/src/network/ssl/qsslellipticcurve_openssl.cpp index 8cd14837f0..b5e38ada53 100644 --- a/src/network/ssl/qsslellipticcurve_openssl.cpp +++ b/src/network/ssl/qsslellipticcurve_openssl.cpp @@ -170,7 +170,7 @@ static const int tlsNamedCurveNIDs[] = { static const size_t tlsNamedCurveNIDCount = sizeof(tlsNamedCurveNIDs) / sizeof(tlsNamedCurveNIDs[0]); -bool QSslEllipticCurve::isTlsNamedCurve() const Q_DECL_NOTHROW +bool QSslEllipticCurve::isTlsNamedCurve() const noexcept { const int * const tlsNamedCurveNIDsEnd = tlsNamedCurveNIDs + tlsNamedCurveNIDCount; return std::find(tlsNamedCurveNIDs, tlsNamedCurveNIDsEnd, id) != tlsNamedCurveNIDsEnd; diff --git a/src/network/ssl/qsslerror.cpp b/src/network/ssl/qsslerror.cpp index 02dd16a58d..ff54c2ad20 100644 --- a/src/network/ssl/qsslerror.cpp +++ b/src/network/ssl/qsslerror.cpp @@ -361,7 +361,7 @@ QSslCertificate QSslError::certificate() const \since 5.4 \relates QHash */ -uint qHash(const QSslError &key, uint seed) Q_DECL_NOTHROW +uint qHash(const QSslError &key, uint seed) noexcept { // 2x boost::hash_combine inlined: seed ^= qHash(key.error()) + 0x9e3779b9 + (seed << 6) + (seed >> 2); diff --git a/src/network/ssl/qsslerror.h b/src/network/ssl/qsslerror.h index 513b8afd7f..a9c46c8571 100644 --- a/src/network/ssl/qsslerror.h +++ b/src/network/ssl/qsslerror.h @@ -103,12 +103,12 @@ public: QSslError(const QSslError &other); - void swap(QSslError &other) Q_DECL_NOTHROW + void swap(QSslError &other) noexcept { qSwap(d, other.d); } ~QSslError(); #ifdef Q_COMPILER_RVALUE_REFS - QSslError &operator=(QSslError &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QSslError &operator=(QSslError &&other) noexcept { swap(other); return *this; } #endif QSslError &operator=(const QSslError &other); bool operator==(const QSslError &other) const; @@ -124,7 +124,7 @@ private: }; Q_DECLARE_SHARED(QSslError) -Q_NETWORK_EXPORT uint qHash(const QSslError &key, uint seed = 0) Q_DECL_NOTHROW; +Q_NETWORK_EXPORT uint qHash(const QSslError &key, uint seed = 0) noexcept; #ifndef QT_NO_DEBUG_STREAM class QDebug; diff --git a/src/network/ssl/qsslkey.h b/src/network/ssl/qsslkey.h index 6de02b1e44..a865f20a51 100644 --- a/src/network/ssl/qsslkey.h +++ b/src/network/ssl/qsslkey.h @@ -72,12 +72,12 @@ public: explicit QSslKey(Qt::HANDLE handle, QSsl::KeyType type = QSsl::PrivateKey); QSslKey(const QSslKey &other); #ifdef Q_COMPILER_RVALUE_REFS - QSslKey &operator=(QSslKey &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QSslKey &operator=(QSslKey &&other) noexcept { swap(other); return *this; } #endif QSslKey &operator=(const QSslKey &other); ~QSslKey(); - void swap(QSslKey &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QSslKey &other) noexcept { qSwap(d, other.d); } bool isNull() const; void clear(); diff --git a/src/network/ssl/qsslpresharedkeyauthenticator.h b/src/network/ssl/qsslpresharedkeyauthenticator.h index 423f7731b4..29d647b121 100644 --- a/src/network/ssl/qsslpresharedkeyauthenticator.h +++ b/src/network/ssl/qsslpresharedkeyauthenticator.h @@ -60,10 +60,10 @@ public: Q_NETWORK_EXPORT QSslPreSharedKeyAuthenticator &operator=(const QSslPreSharedKeyAuthenticator &authenticator); #ifdef Q_COMPILER_RVALUE_REFS - QSslPreSharedKeyAuthenticator &operator=(QSslPreSharedKeyAuthenticator &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QSslPreSharedKeyAuthenticator &operator=(QSslPreSharedKeyAuthenticator &&other) noexcept { swap(other); return *this; } #endif - void swap(QSslPreSharedKeyAuthenticator &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QSslPreSharedKeyAuthenticator &other) noexcept { qSwap(d, other.d); } Q_NETWORK_EXPORT QByteArray identityHint() const; diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp index 666613f09d..02d6586fe8 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp @@ -66,7 +66,7 @@ Q_LOGGING_CATEGORY(qLcEvdevKeyMap, "qt.qpa.input.keymap") // simple builtin US keymap #include "qevdevkeyboard_defaultmap_p.h" -void QFdContainer::reset() Q_DECL_NOTHROW +void QFdContainer::reset() noexcept { if (m_fd >= 0) qt_safe_close(m_fd); diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h index 21e6d055a0..d154c30ed5 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h @@ -134,13 +134,13 @@ class QFdContainer int m_fd; Q_DISABLE_COPY_MOVE(QFdContainer); public: - explicit QFdContainer(int fd = -1) Q_DECL_NOTHROW : m_fd(fd) {} + explicit QFdContainer(int fd = -1) noexcept : m_fd(fd) {} ~QFdContainer() { reset(); } - int get() const Q_DECL_NOTHROW { return m_fd; } + int get() const noexcept { return m_fd; } - int release() Q_DECL_NOTHROW { int result = m_fd; m_fd = -1; return result; } - void reset() Q_DECL_NOTHROW; + int release() noexcept { int result = m_fd; m_fd = -1; return result; } + void reset() noexcept; }; class QEvdevKeyboardHandler : public QObject diff --git a/src/plugins/platforms/windows/qwindowscursor.h b/src/plugins/platforms/windows/qwindowscursor.h index 8495b51a5a..2e57c80def 100644 --- a/src/plugins/platforms/windows/qwindowscursor.h +++ b/src/plugins/platforms/windows/qwindowscursor.h @@ -61,7 +61,7 @@ inline bool operator==(const QWindowsPixmapCursorCacheKey &k1, const QWindowsPix return k1.bitmapCacheKey == k2.bitmapCacheKey && k1.maskCacheKey == k2.maskCacheKey; } -inline uint qHash(const QWindowsPixmapCursorCacheKey &k, uint seed) Q_DECL_NOTHROW +inline uint qHash(const QWindowsPixmapCursorCacheKey &k, uint seed) noexcept { return (uint(k.bitmapCacheKey) + uint(k.maskCacheKey)) ^ seed; } diff --git a/src/plugins/platforms/xcb/nativepainting/qt_x11_p.h b/src/plugins/platforms/xcb/nativepainting/qt_x11_p.h index a13a8f0483..1f7e7cf49b 100644 --- a/src/plugins/platforms/xcb/nativepainting/qt_x11_p.h +++ b/src/plugins/platforms/xcb/nativepainting/qt_x11_p.h @@ -190,7 +190,7 @@ struct QX11InfoData { }; template -Q_DECL_RELAXED_CONSTEXPR inline int lowest_bit(T v) Q_DECL_NOTHROW +Q_DECL_RELAXED_CONSTEXPR inline int lowest_bit(T v) noexcept { int result = qCountTrailingZeroBits(v); return ((result >> 3) == sizeof(T)) ? -1 : result; diff --git a/src/plugins/platforms/xcb/qxcbconnection_basic.h b/src/plugins/platforms/xcb/qxcbconnection_basic.h index 3691763398..b76aba2789 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_basic.h +++ b/src/plugins/platforms/xcb/qxcbconnection_basic.h @@ -162,7 +162,7 @@ private: #define Q_XCB_REPLY_CONNECTION_ARG(connection, ...) connection struct QStdFreeDeleter { - void operator()(void *p) const Q_DECL_NOTHROW { return std::free(p); } + void operator()(void *p) const noexcept { return std::free(p); } }; #define Q_XCB_REPLY(call, ...) \ diff --git a/src/plugins/platforms/xcb/qxcbcursor.h b/src/plugins/platforms/xcb/qxcbcursor.h index 488988cbe9..0b238823f0 100644 --- a/src/plugins/platforms/xcb/qxcbcursor.h +++ b/src/plugins/platforms/xcb/qxcbcursor.h @@ -65,7 +65,7 @@ inline bool operator==(const QXcbCursorCacheKey &k1, const QXcbCursorCacheKey &k return k1.shape == k2.shape && k1.bitmapCacheKey == k2.bitmapCacheKey && k1.maskCacheKey == k2.maskCacheKey; } -inline uint qHash(const QXcbCursorCacheKey &k, uint seed) Q_DECL_NOTHROW +inline uint qHash(const QXcbCursorCacheKey &k, uint seed) noexcept { return (uint(k.shape) + uint(k.bitmapCacheKey) + uint(k.maskCacheKey)) ^ seed; } diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp index 9fb9d6c55e..6eaf24adf9 100644 --- a/src/printsupport/dialogs/qprintdialog_unix.cpp +++ b/src/printsupport/dialogs/qprintdialog_unix.cpp @@ -398,12 +398,12 @@ static const char *ppdOriginallySelectedChoiceProperty = "_q_ppd_originally_sele // Used to store the warning label pointer for each QComboBox that represents an advanced option static const char *warningLabelProperty = "_q_warning_label"; -static bool isBlacklistedGroup(const ppd_group_t *group) Q_DECL_NOTHROW +static bool isBlacklistedGroup(const ppd_group_t *group) noexcept { return qstrcmp(group->name, "InstallableOptions") == 0; }; -static bool isBlacklistedOption(const char *keyword) Q_DECL_NOTHROW +static bool isBlacklistedOption(const char *keyword) noexcept { // We already let the user set these options elsewhere const char *cupsOptionBlacklist[] = { @@ -734,7 +734,7 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma } #if QT_CONFIG(cups) -static std::vector> pageRangesFromString(const QString &pagesString) Q_DECL_NOTHROW +static std::vector> pageRangesFromString(const QString &pagesString) noexcept { std::vector> result; const QStringList items = pagesString.split(','); @@ -788,7 +788,7 @@ static std::vector> pageRangesFromString(const QString &page return result; } -static QString stringFromPageRanges(const std::vector> &pageRanges) Q_DECL_NOTHROW +static QString stringFromPageRanges(const std::vector> &pageRanges) noexcept { QString result; @@ -805,7 +805,7 @@ static QString stringFromPageRanges(const std::vector> &page return result; } -static bool isValidPagesString(const QString &pagesString) Q_DECL_NOTHROW +static bool isValidPagesString(const QString &pagesString) noexcept { if (pagesString.isEmpty()) return false; diff --git a/src/printsupport/kernel/qcups.cpp b/src/printsupport/kernel/qcups.cpp index 8505e8356c..5236b8c8fa 100644 --- a/src/printsupport/kernel/qcups.cpp +++ b/src/printsupport/kernel/qcups.cpp @@ -44,12 +44,12 @@ QT_BEGIN_NAMESPACE -static QStringList cupsOptionsList(QPrinter *printer) Q_DECL_NOTHROW +static QStringList cupsOptionsList(QPrinter *printer) noexcept { return printer->printEngine()->property(PPK_CupsOptions).toStringList(); } -void setCupsOptions(QPrinter *printer, const QStringList &cupsOptions) Q_DECL_NOTHROW +void setCupsOptions(QPrinter *printer, const QStringList &cupsOptions) noexcept { printer->printEngine()->setProperty(PPK_CupsOptions, QVariant(cupsOptions)); } diff --git a/src/sql/kernel/qsqlerror.h b/src/sql/kernel/qsqlerror.h index 6dac47a7fe..7dfb6eb9ec 100644 --- a/src/sql/kernel/qsqlerror.h +++ b/src/sql/kernel/qsqlerror.h @@ -66,15 +66,15 @@ public: ErrorType type = NoError, const QString &errorCode = QString()); QSqlError(const QSqlError& other); - QSqlError(QSqlError &&other) Q_DECL_NOTHROW : d(other.d) { other.d = nullptr; } + QSqlError(QSqlError &&other) noexcept : d(other.d) { other.d = nullptr; } QSqlError& operator=(const QSqlError& other); - QSqlError &operator=(QSqlError &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QSqlError &operator=(QSqlError &&other) noexcept { swap(other); return *this; } bool operator==(const QSqlError& other) const; bool operator!=(const QSqlError& other) const; ~QSqlError(); - void swap(QSqlError &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QSqlError &other) noexcept { qSwap(d, other.d); } QString driverText() const; QString databaseText() const; diff --git a/src/sql/models/qsqlrelationaltablemodel.h b/src/sql/models/qsqlrelationaltablemodel.h index 555755009c..1929bd320a 100644 --- a/src/sql/models/qsqlrelationaltablemodel.h +++ b/src/sql/models/qsqlrelationaltablemodel.h @@ -58,7 +58,7 @@ public: const QString &displayCol) : tName(aTableName), iColumn(indexCol), dColumn(displayCol) {} - void swap(QSqlRelation &other) Q_DECL_NOTHROW + void swap(QSqlRelation &other) noexcept { qSwap(tName, other.tName); qSwap(iColumn, other.iColumn); @@ -71,7 +71,7 @@ public: { return iColumn; } inline QString displayColumn() const { return dColumn; } - bool isValid() const Q_DECL_NOTHROW + bool isValid() const noexcept { return !(tName.isEmpty() || iColumn.isEmpty() || dColumn.isEmpty()); } private: QString tName, iColumn, dColumn; diff --git a/src/widgets/dialogs/qdialog_p.h b/src/widgets/dialogs/qdialog_p.h index 77f9fae09a..74f775a0bd 100644 --- a/src/widgets/dialogs/qdialog_p.h +++ b/src/widgets/dialogs/qdialog_p.h @@ -140,14 +140,14 @@ class QAutoPointer { struct internal { void func() {} }; typedef void (internal::*RestrictedBool)(); public: - explicit QAutoPointer(T *t) Q_DECL_NOTHROW : o(t) {} + explicit QAutoPointer(T *t) noexcept : o(t) {} ~QAutoPointer() { delete o; } - T *operator->() const Q_DECL_NOTHROW { return get(); } - T *get() const Q_DECL_NOTHROW { return o; } + T *operator->() const noexcept { return get(); } + T *get() const noexcept { return o; } T &operator*() const { return *get(); } - operator RestrictedBool() const Q_DECL_NOTHROW { return o ? &internal::func : nullptr; } - bool operator!() const Q_DECL_NOTHROW { return !o; } + operator RestrictedBool() const noexcept { return o ? &internal::func : nullptr; } + bool operator!() const noexcept { return !o; } private: Q_DISABLE_COPY(QAutoPointer); }; diff --git a/src/widgets/kernel/qsizepolicy.cpp b/src/widgets/kernel/qsizepolicy.cpp index b5a0cd3940..54bf8fe0dc 100644 --- a/src/widgets/kernel/qsizepolicy.cpp +++ b/src/widgets/kernel/qsizepolicy.cpp @@ -232,7 +232,7 @@ QT_BEGIN_NAMESPACE Returns the control type associated with the widget for which this size policy applies. */ -QSizePolicy::ControlType QSizePolicy::controlType() const Q_DECL_NOTHROW +QSizePolicy::ControlType QSizePolicy::controlType() const noexcept { return QSizePolicy::ControlType(1 << bits.ctype); } @@ -253,7 +253,7 @@ QSizePolicy::ControlType QSizePolicy::controlType() const Q_DECL_NOTHROW \sa QStyle::layoutSpacing() */ -void QSizePolicy::setControlType(ControlType type) Q_DECL_NOTHROW +void QSizePolicy::setControlType(ControlType type) noexcept { bits.ctype = toControlTypeFieldValue(type); } diff --git a/src/widgets/kernel/qsizepolicy.h b/src/widgets/kernel/qsizepolicy.h index dba742dec5..f26923eeb0 100644 --- a/src/widgets/kernel/qsizepolicy.h +++ b/src/widgets/kernel/qsizepolicy.h @@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE class QVariant; class QSizePolicy; -Q_DECL_CONST_FUNCTION inline uint qHash(QSizePolicy key, uint seed = 0) Q_DECL_NOTHROW; +Q_DECL_CONST_FUNCTION inline uint qHash(QSizePolicy key, uint seed = 0) noexcept; class Q_WIDGETS_EXPORT QSizePolicy { @@ -110,60 +110,60 @@ public: Q_DECLARE_FLAGS(ControlTypes, ControlType) Q_FLAG(ControlTypes) - QT_SIZEPOLICY_CONSTEXPR QSizePolicy() Q_DECL_NOTHROW : data(0) { } + QT_SIZEPOLICY_CONSTEXPR QSizePolicy() noexcept : data(0) { } #if defined(Q_COMPILER_UNIFORM_INIT) && !defined(Q_QDOC) - QT_SIZEPOLICY_CONSTEXPR QSizePolicy(Policy horizontal, Policy vertical, ControlType type = DefaultType) Q_DECL_NOTHROW + QT_SIZEPOLICY_CONSTEXPR QSizePolicy(Policy horizontal, Policy vertical, ControlType type = DefaultType) noexcept : bits{0, 0, quint32(horizontal), quint32(vertical), type == DefaultType ? 0 : toControlTypeFieldValue(type), 0, 0, 0} {} #else - QSizePolicy(Policy horizontal, Policy vertical, ControlType type = DefaultType) Q_DECL_NOTHROW + QSizePolicy(Policy horizontal, Policy vertical, ControlType type = DefaultType) noexcept : data(0) { bits.horPolicy = horizontal; bits.verPolicy = vertical; setControlType(type); } #endif // uniform-init - QT_SIZEPOLICY_CONSTEXPR Policy horizontalPolicy() const Q_DECL_NOTHROW { return static_cast(bits.horPolicy); } - QT_SIZEPOLICY_CONSTEXPR Policy verticalPolicy() const Q_DECL_NOTHROW { return static_cast(bits.verPolicy); } - ControlType controlType() const Q_DECL_NOTHROW; + QT_SIZEPOLICY_CONSTEXPR Policy horizontalPolicy() const noexcept { return static_cast(bits.horPolicy); } + QT_SIZEPOLICY_CONSTEXPR Policy verticalPolicy() const noexcept { return static_cast(bits.verPolicy); } + ControlType controlType() const noexcept; - Q_DECL_RELAXED_CONSTEXPR void setHorizontalPolicy(Policy d) Q_DECL_NOTHROW { bits.horPolicy = d; } - Q_DECL_RELAXED_CONSTEXPR void setVerticalPolicy(Policy d) Q_DECL_NOTHROW { bits.verPolicy = d; } - void setControlType(ControlType type) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR void setHorizontalPolicy(Policy d) noexcept { bits.horPolicy = d; } + Q_DECL_RELAXED_CONSTEXPR void setVerticalPolicy(Policy d) noexcept { bits.verPolicy = d; } + void setControlType(ControlType type) noexcept; - QT_SIZEPOLICY_CONSTEXPR Qt::Orientations expandingDirections() const Q_DECL_NOTHROW { + QT_SIZEPOLICY_CONSTEXPR Qt::Orientations expandingDirections() const noexcept { return ( (verticalPolicy() & ExpandFlag) ? Qt::Vertical : Qt::Orientations() ) | ( (horizontalPolicy() & ExpandFlag) ? Qt::Horizontal : Qt::Orientations() ) ; } - Q_DECL_RELAXED_CONSTEXPR void setHeightForWidth(bool b) Q_DECL_NOTHROW { bits.hfw = b; } - QT_SIZEPOLICY_CONSTEXPR bool hasHeightForWidth() const Q_DECL_NOTHROW { return bits.hfw; } - Q_DECL_RELAXED_CONSTEXPR void setWidthForHeight(bool b) Q_DECL_NOTHROW { bits.wfh = b; } - QT_SIZEPOLICY_CONSTEXPR bool hasWidthForHeight() const Q_DECL_NOTHROW { return bits.wfh; } + Q_DECL_RELAXED_CONSTEXPR void setHeightForWidth(bool b) noexcept { bits.hfw = b; } + QT_SIZEPOLICY_CONSTEXPR bool hasHeightForWidth() const noexcept { return bits.hfw; } + Q_DECL_RELAXED_CONSTEXPR void setWidthForHeight(bool b) noexcept { bits.wfh = b; } + QT_SIZEPOLICY_CONSTEXPR bool hasWidthForHeight() const noexcept { return bits.wfh; } - QT_SIZEPOLICY_CONSTEXPR bool operator==(const QSizePolicy& s) const Q_DECL_NOTHROW { return data == s.data; } - QT_SIZEPOLICY_CONSTEXPR bool operator!=(const QSizePolicy& s) const Q_DECL_NOTHROW { return data != s.data; } + QT_SIZEPOLICY_CONSTEXPR bool operator==(const QSizePolicy& s) const noexcept { return data == s.data; } + QT_SIZEPOLICY_CONSTEXPR bool operator!=(const QSizePolicy& s) const noexcept { return data != s.data; } - friend Q_DECL_CONST_FUNCTION uint qHash(QSizePolicy key, uint seed) Q_DECL_NOTHROW { return qHash(key.data, seed); } + friend Q_DECL_CONST_FUNCTION uint qHash(QSizePolicy key, uint seed) noexcept { return qHash(key.data, seed); } operator QVariant() const; - QT_SIZEPOLICY_CONSTEXPR int horizontalStretch() const Q_DECL_NOTHROW { return static_cast(bits.horStretch); } - QT_SIZEPOLICY_CONSTEXPR int verticalStretch() const Q_DECL_NOTHROW { return static_cast(bits.verStretch); } + QT_SIZEPOLICY_CONSTEXPR int horizontalStretch() const noexcept { return static_cast(bits.horStretch); } + QT_SIZEPOLICY_CONSTEXPR int verticalStretch() const noexcept { return static_cast(bits.verStretch); } Q_DECL_RELAXED_CONSTEXPR void setHorizontalStretch(int stretchFactor) { bits.horStretch = static_cast(qBound(0, stretchFactor, 255)); } Q_DECL_RELAXED_CONSTEXPR void setVerticalStretch(int stretchFactor) { bits.verStretch = static_cast(qBound(0, stretchFactor, 255)); } - QT_SIZEPOLICY_CONSTEXPR bool retainSizeWhenHidden() const Q_DECL_NOTHROW { return bits.retainSizeWhenHidden; } - Q_DECL_RELAXED_CONSTEXPR void setRetainSizeWhenHidden(bool retainSize) Q_DECL_NOTHROW { bits.retainSizeWhenHidden = retainSize; } + QT_SIZEPOLICY_CONSTEXPR bool retainSizeWhenHidden() const noexcept { return bits.retainSizeWhenHidden; } + Q_DECL_RELAXED_CONSTEXPR void setRetainSizeWhenHidden(bool retainSize) noexcept { bits.retainSizeWhenHidden = retainSize; } - Q_DECL_RELAXED_CONSTEXPR void transpose() Q_DECL_NOTHROW { *this = transposed(); } + Q_DECL_RELAXED_CONSTEXPR void transpose() noexcept { *this = transposed(); } Q_REQUIRED_RESULT #ifndef Q_QDOC QT_SIZEPOLICY_CONSTEXPR_AND_UNIFORM_INIT #endif - QSizePolicy transposed() const Q_DECL_NOTHROW + QSizePolicy transposed() const noexcept { return QSizePolicy(bits.transposed()); } @@ -173,11 +173,11 @@ private: friend Q_WIDGETS_EXPORT QDataStream &operator<<(QDataStream &, const QSizePolicy &); friend Q_WIDGETS_EXPORT QDataStream &operator>>(QDataStream &, QSizePolicy &); #endif - QT_SIZEPOLICY_CONSTEXPR QSizePolicy(int i) Q_DECL_NOTHROW : data(i) { } + QT_SIZEPOLICY_CONSTEXPR QSizePolicy(int i) noexcept : data(i) { } struct Bits; - QT_SIZEPOLICY_CONSTEXPR explicit QSizePolicy(Bits b) Q_DECL_NOTHROW : bits(b) { } + QT_SIZEPOLICY_CONSTEXPR explicit QSizePolicy(Bits b) noexcept : bits(b) { } - static Q_DECL_RELAXED_CONSTEXPR quint32 toControlTypeFieldValue(ControlType type) Q_DECL_NOTHROW + static Q_DECL_RELAXED_CONSTEXPR quint32 toControlTypeFieldValue(ControlType type) noexcept { /* The control type is a flag type, with values 0x1, 0x2, 0x4, 0x8, 0x10, @@ -207,7 +207,7 @@ private: quint32 retainSizeWhenHidden : 1; QT_SIZEPOLICY_CONSTEXPR_AND_UNIFORM_INIT - Bits transposed() const Q_DECL_NOTHROW + Bits transposed() const noexcept { return {verStretch, // \ swap horStretch, // / diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp index 47c5267c73..510b34cb18 100644 --- a/src/widgets/widgets/qcalendarwidget.cpp +++ b/src/widgets/widgets/qcalendarwidget.cpp @@ -827,9 +827,9 @@ class StaticDayOfWeekAssociativeArray { bool contained[7]; T data[7]; - static Q_DECL_CONSTEXPR int day2idx(Qt::DayOfWeek day) Q_DECL_NOTHROW { return int(day) - 1; } // alt: day % 7 + static Q_DECL_CONSTEXPR int day2idx(Qt::DayOfWeek day) noexcept { return int(day) - 1; } // alt: day % 7 public: - Q_DECL_CONSTEXPR StaticDayOfWeekAssociativeArray() Q_DECL_NOEXCEPT_EXPR(noexcept(T())) + Q_DECL_CONSTEXPR StaticDayOfWeekAssociativeArray() noexcept(noexcept(T())) #ifdef Q_COMPILER_CONSTEXPR : contained{}, data{} // arrays require uniform initialization #else @@ -837,17 +837,17 @@ public: #endif {} - Q_DECL_CONSTEXPR bool contains(Qt::DayOfWeek day) const Q_DECL_NOTHROW { return contained[day2idx(day)]; } - Q_DECL_CONSTEXPR const T &value(Qt::DayOfWeek day) const Q_DECL_NOTHROW { return data[day2idx(day)]; } + Q_DECL_CONSTEXPR bool contains(Qt::DayOfWeek day) const noexcept { return contained[day2idx(day)]; } + Q_DECL_CONSTEXPR const T &value(Qt::DayOfWeek day) const noexcept { return data[day2idx(day)]; } - Q_DECL_RELAXED_CONSTEXPR T &operator[](Qt::DayOfWeek day) Q_DECL_NOTHROW + Q_DECL_RELAXED_CONSTEXPR T &operator[](Qt::DayOfWeek day) noexcept { const int idx = day2idx(day); contained[idx] = true; return data[idx]; } - Q_DECL_RELAXED_CONSTEXPR void insert(Qt::DayOfWeek day, T v) Q_DECL_NOTHROW + Q_DECL_RELAXED_CONSTEXPR void insert(Qt::DayOfWeek day, T v) noexcept { operator[](day).swap(v); } diff --git a/src/xml/sax/qxml.h b/src/xml/sax/qxml.h index 94dc8dfb8e..26b674c894 100644 --- a/src/xml/sax/qxml.h +++ b/src/xml/sax/qxml.h @@ -118,14 +118,14 @@ public: QXmlAttributes(); #ifdef Q_COMPILER_DEFAULT_MEMBERS QXmlAttributes(const QXmlAttributes &) = default; - QXmlAttributes(QXmlAttributes &&) Q_DECL_NOTHROW = default; + QXmlAttributes(QXmlAttributes &&) noexcept = default; QXmlAttributes &operator=(const QXmlAttributes &) = default; - QXmlAttributes &operator=(QXmlAttributes &&) Q_DECL_NOTHROW = default; + QXmlAttributes &operator=(QXmlAttributes &&) noexcept = default; #endif // default members QT6_NOT_VIRTUAL ~QXmlAttributes(); - void swap(QXmlAttributes &other) Q_DECL_NOTHROW + void swap(QXmlAttributes &other) noexcept { qSwap(attList, other.attList); qSwap(d, other.d); From 89120c4a76fed3c62c019514c12e7fb7c063b4b7 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 1 Nov 2018 11:11:12 +0100 Subject: [PATCH 157/292] uic: Refactor string constant formatting Refactor the fixString() helper, moving the code into a streamable class using a helper which can be used for different encodings. Task-number: PYSIDE-797 Change-Id: I0f82945b6b334da8524882dda2f104327eba79d4 Reviewed-by: Cristian Maureira-Fredes --- src/tools/uic/cpp/cppwriteinitialization.cpp | 136 +++++++++---------- src/tools/uic/shared/language.cpp | 127 +++++++++++++++++ src/tools/uic/shared/language.h | 31 +++++ src/tools/uic/utils.h | 49 ------- 4 files changed, 226 insertions(+), 117 deletions(-) diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 881c48daea..938d47f62d 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -506,7 +506,8 @@ void WriteInitialization::acceptUI(DomUI *node) continue; const QString varConn = connection + QLatin1String("Connection"); - m_output << m_indent << varConn << " = QSqlDatabase::database(" << fixString(connection, m_dindent) << ");\n"; + m_output << m_indent << varConn << " = QSqlDatabase::database(" + << language::charliteral(connection, m_dindent) << ");\n"; } acceptWidget(node->elementWidget()); @@ -1108,7 +1109,7 @@ QString WriteInitialization::writeStringListProperty(const DomStringList *list) str << '\n' << m_indent << " << " << trCall(values.at(i), comment); } else { for (int i = 0; i < values.size(); ++i) - str << " << QString::fromUtf8(" << fixString(values.at(i), m_dindent) << ')'; + str << " << " << language::qstring(values.at(i), m_dindent); } return propertyValue; } @@ -1140,8 +1141,8 @@ void WriteInitialization::writeProperties(const QString &varName, if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QAxWidget"))) { DomPropertyMap properties = propertyMap(lst); if (DomProperty *p = properties.value(QLatin1String("control"))) { - m_output << m_indent << varName << "->setControl(QString::fromUtf8(" - << fixString(toString(p->elementString()), m_dindent) << "));\n"; + m_output << m_indent << varName << "->setControl(" + << language::qstring(toString(p->elementString()), m_dindent) << ");\n"; } } @@ -1150,9 +1151,11 @@ void WriteInitialization::writeProperties(const QString &varName, indent = m_option.indent; m_output << m_indent << "if (" << varName << "->objectName().isEmpty())\n"; } - if (!(flags & WritePropertyIgnoreObjectName)) + if (!(flags & WritePropertyIgnoreObjectName)) { m_output << m_indent << indent << varName - << "->setObjectName(QString::fromUtf8(" << fixString(varName, m_dindent) << "));\n"; + << "->setObjectName(" << language::qstring(varName, m_dindent) + << ");\n"; + } int leftMargin, topMargin, rightMargin, bottomMargin; leftMargin = topMargin = rightMargin = bottomMargin = -1; @@ -1281,13 +1284,12 @@ void WriteInitialization::writeProperties(const QString &varName, Buddy buddy = { varName, p->elementCstring() }; m_buddies.append(std::move(buddy)); } else { - if (stdset) - propertyValue = fixString(p->elementCstring(), m_dindent); - else { - propertyValue = QLatin1String("QByteArray(") - + fixString(p->elementCstring(), m_dindent) - + QLatin1Char(')'); - } + QTextStream str(&propertyValue); + if (!stdset) + str << "QByteArray("; + str << language::charliteral(p->elementCstring(), m_dindent); + if (!stdset) + str << ')'; } break; case DomProperty::Cursor: @@ -1456,8 +1458,8 @@ void WriteInitialization::writeProperties(const QString &varName, case DomProperty::Url: { const DomUrl* u = p->elementUrl(); - propertyValue = QString::fromLatin1("QUrl(QString::fromUtf8(%1))") - .arg(fixString(u->elementString()->text(), m_dindent)); + QTextStream(&propertyValue) << "QUrl(" + << language::qstring(u->elementString()->text(), m_dindent) << ")"; break; } case DomProperty::Brush: @@ -1549,8 +1551,8 @@ QString WriteInitialization::writeFontProperties(const DomFont *f) m_output << m_indent << "QFont " << fontName << ";\n"; if (f->hasElementFamily() && !f->elementFamily().isEmpty()) { - m_output << m_indent << fontName << ".setFamily(QString::fromUtf8(" - << fixString(f->elementFamily(), m_dindent) << "));\n"; + m_output << m_indent << fontName << ".setFamily(" + << language::qstring(f->elementFamily(), m_dindent) << ");\n"; } if (f->hasElementPointSize() && f->elementPointSize() > 0) { m_output << m_indent << fontName << ".setPointSize(" << f->elementPointSize() @@ -1599,43 +1601,43 @@ static void writeResourceIcon(QTextStream &output, const DomResourceIcon *i) { if (i->hasElementNormalOff()) { - output << indent << iconName << ".addFile(QString::fromUtf8(" - << fixString(i->elementNormalOff()->text(), indent) - << "), QSize(), QIcon::Normal, QIcon::Off);\n"; + output << indent << iconName << ".addFile(" + << language::qstring(i->elementNormalOff()->text(), indent) + << ", QSize(), QIcon::Normal, QIcon::Off);\n"; } if (i->hasElementNormalOn()) { - output << indent << iconName << ".addFile(QString::fromUtf8(" - << fixString(i->elementNormalOn()->text(), indent) - << "), QSize(), QIcon::Normal, QIcon::On);\n"; + output << indent << iconName << ".addFile(" + << language::qstring(i->elementNormalOn()->text(), indent) + << ", QSize(), QIcon::Normal, QIcon::On);\n"; } if (i->hasElementDisabledOff()) { - output << indent << iconName << ".addFile(QString::fromUtf8(" - << fixString(i->elementDisabledOff()->text(), indent) - << "), QSize(), QIcon::Disabled, QIcon::Off);\n"; + output << indent << iconName << ".addFile(" + << language::qstring(i->elementDisabledOff()->text(), indent) + << ", QSize(), QIcon::Disabled, QIcon::Off);\n"; } if (i->hasElementDisabledOn()) { - output << indent << iconName << ".addFile(QString::fromUtf8(" - << fixString(i->elementDisabledOn()->text(), indent) - << "), QSize(), QIcon::Disabled, QIcon::On);\n"; + output << indent << iconName << ".addFile(" + << language::qstring(i->elementDisabledOn()->text(), indent) + << ", QSize(), QIcon::Disabled, QIcon::On);\n"; } if (i->hasElementActiveOff()) { - output << indent << iconName << ".addFile(QString::fromUtf8(" - << fixString(i->elementActiveOff()->text(), indent) - << "), QSize(), QIcon::Active, QIcon::Off);\n"; + output << indent << iconName << ".addFile(" + << language::qstring(i->elementActiveOff()->text(), indent) + << ", QSize(), QIcon::Active, QIcon::Off);\n"; } if (i->hasElementActiveOn()) { - output << indent << iconName << ".addFile(QString::fromUtf8(" - << fixString(i->elementActiveOn()->text(), indent) - << "), QSize(), QIcon::Active, QIcon::On);\n"; + output << indent << iconName << ".addFile(" + << language::qstring(i->elementActiveOn()->text(), indent) + << ", QSize(), QIcon::Active, QIcon::On);\n"; } if (i->hasElementSelectedOff()) { - output << indent << iconName << ".addFile(QString::fromUtf8(" - << fixString(i->elementSelectedOff()->text(), indent) - << "), QSize(), QIcon::Selected, QIcon::Off);\n"; + output << indent << iconName << ".addFile(" + << language::qstring(i->elementSelectedOff()->text(), indent) + << ", QSize(), QIcon::Selected, QIcon::Off);\n"; } if (i->hasElementSelectedOn()) { - output << indent << iconName << ".addFile(QString::fromUtf8(" - << fixString(i->elementSelectedOn()->text(), indent) + output << indent << iconName << ".addFile(" + << language::qstring(i->elementSelectedOn()->text(), indent) << "), QSize(), QIcon::Selected, QIcon::On);\n"; } } @@ -1709,7 +1711,6 @@ QString WriteInitialization::writeIconProperties(const DomResourceIcon *i) writePixmapFunctionIcon(m_output, iconName, m_indent, i); } else { // Theme: Generate code to check the theme and default to resource - const QString themeIconName = fixString(i->attributeTheme(), QString()); if (iconHasStatePixmaps(i)) { // Theme + default state pixmaps: // Generate code to check the theme and default to state pixmaps @@ -1721,8 +1722,8 @@ QString WriteInitialization::writeIconProperties(const DomResourceIcon *i) m_output << "QString "; m_firstThemeIcon = false; } - m_output << themeNameStringVariableC << " = QString::fromUtf8(" - << themeIconName << ");\n"; + m_output << themeNameStringVariableC << " = " + << language::qstring(i->attributeTheme()) << ";\n"; m_output << m_indent << "if (QIcon::hasThemeIcon(" << themeNameStringVariableC << ")) {\n" @@ -1735,9 +1736,8 @@ QString WriteInitialization::writeIconProperties(const DomResourceIcon *i) m_output << m_indent << "}\n"; } else { // Theme, but no state pixmaps: Construct from theme directly. - m_output << m_indent << "QIcon " << iconName - << "(QIcon::fromTheme(QString::fromUtf8(" - << themeIconName << ")));\n"; + m_output << m_indent << "QIcon " << iconName << "(QIcon::fromTheme(" + << language::qstring(i->attributeTheme()) << "));\n"; } // Theme, but not state } // >= 4.4 } else { // pre-4.4 legacy @@ -1969,15 +1969,14 @@ QString WriteInitialization::pixCall(const QString &t, const QString &text) cons return type; } + QTextStream str(&type); + str << '('; QString pixFunc = m_uic->pixmapFunction(); if (pixFunc.isEmpty()) - pixFunc = QLatin1String("QString::fromUtf8"); - - type += QLatin1Char('(') - + pixFunc - + QLatin1Char('(') - + fixString(text, m_dindent) - + QLatin1String("))"); + str << language::qstring(text, m_dindent); + else + str << pixFunc << '(' << language::charliteral(text, m_dindent) << ')'; + str << ')'; return type; } @@ -2343,28 +2342,29 @@ QString WriteInitialization::trCall(const QString &str, const QString &commentHi return QLatin1String("QString()"); QString result; - const QString comment = commentHint.isEmpty() ? QString(QLatin1String("nullptr")) : fixString(commentHint, m_dindent); + QTextStream ts(&result); const bool idBasedTranslations = m_driver->useIdBasedTranslations(); if (m_option.translateFunction.isEmpty()) { - if (idBasedTranslations || m_option.idBased) { - result += QLatin1String("qtTrId("); - } else { - result += QLatin1String("QCoreApplication::translate(\"") - + m_generatedClass - + QLatin1String("\", "); - } + if (idBasedTranslations || m_option.idBased) + ts << "qtTrId("; + else + ts << "QCoreApplication::translate(\"" << m_generatedClass << "\", "; } else { - result += m_option.translateFunction + QLatin1Char('('); + ts << m_option.translateFunction << '('; } - result += fixString(idBasedTranslations ? id : str, m_dindent); + ts << language::charliteral(idBasedTranslations ? id : str, m_dindent); if (!idBasedTranslations && !m_option.idBased) { - result += QLatin1String(", ") + comment; + ts << ", "; + if (commentHint.isEmpty()) + ts << "nullptr"; + else + ts << language::charliteral(commentHint, m_dindent); } - result += QLatin1Char(')'); + ts << ')'; return result; } @@ -2399,9 +2399,9 @@ QString WriteInitialization::noTrCall(DomString *str, const QString &defaultStri return QString(); if (str) value = str->text(); - QString ret = QLatin1String("QString::fromUtf8("); - ret += fixString(value, m_dindent); - ret += QLatin1Char(')'); + QString ret; + QTextStream ts(&ret); + ts << language::qstring(value, m_dindent); return ret; } diff --git a/src/tools/uic/shared/language.cpp b/src/tools/uic/shared/language.cpp index 730e1562bc..d0491b74e3 100644 --- a/src/tools/uic/shared/language.cpp +++ b/src/tools/uic/shared/language.cpp @@ -32,6 +32,8 @@ namespace language { +static Encoding encoding = Encoding::Utf8; + QTextStream &operator<<(QTextStream &str, const qtConfig &c) { str << "QT_CONFIG(" << c.parameter() << ')'; @@ -141,4 +143,129 @@ const char *paletteColorRole(int v) return lookupEnum(colorRoles, v); } +// Helpers for formatting a character sequences + +// Format a special character like '\x0a' +static int formatEscapedNumber(QTextStream &str, ushort value, int base, int width, + char prefix = 0) +{ + int length = 1 + width; + str << '\\'; + if (prefix) { + str << prefix; + ++length; + } + const auto oldPadChar = str.padChar(); + const auto oldFieldWidth = str.fieldWidth(); + const auto oldFieldAlignment = str.fieldAlignment(); + const auto oldIntegerBase = str.integerBase(); + str.setPadChar(QLatin1Char('0')); + str.setFieldWidth(width); + str.setFieldAlignment(QTextStream::AlignRight); + str.setIntegerBase(base); + str << value; + str.setIntegerBase(oldIntegerBase); + str.setFieldAlignment(oldFieldAlignment); + str.setFieldWidth(oldFieldWidth); + str.setPadChar(oldPadChar); + return length; +} + +static int formatSpecialCharacter(QTextStream &str, ushort value) +{ + int length = 0; + switch (value) { + case '\\': + str << "\\\\"; + length += 2; + break; + case '\"': + str << "\\\""; + length += 2; + break; + case '\n': + str << "\\n\"\n\""; + length += 5; + break; + default: + break; + } + return length; +} + +// Format a sequence of characters for C++ with special characters numerically +// escaped (non-raw string literals), wrappped at maxSegmentSize. FormattingTraits +// are used to transform characters into (unsigned) codes, which can be used +// for either normal escapes or Unicode code points as used in Unicode literals. + +enum : int { maxSegmentSize = 1024 }; + +template +struct FormattingTraits +{ +}; + +template <> +struct FormattingTraits +{ + static ushort code(char c) { return uchar(c); } +}; + +template <> +struct FormattingTraits +{ + static ushort code(QChar c) { return c.unicode(); } +}; + +template +static void formatStringSequence(QTextStream &str, Iterator it, Iterator end, + const QString &indent, + int escapeIntegerBase, int escapeWidth, + char escapePrefix = 0) +{ + str << '"'; + int length = 0; + while (it != end) { + const auto code = FormattingTraits::code(*it); + if (code >= 0x80) { + length += formatEscapedNumber(str, code, escapeIntegerBase, escapeWidth, escapePrefix); + } else if (const int l = formatSpecialCharacter(str, code)) { + length += l; + } else if (code != '\r') { + str << *it; + ++length; + } + ++it; + if (it != end && length > maxSegmentSize) { + str << "\"\n" << indent << indent << '"'; + length = 0; + } + } + str << '"'; +} + +void _formatString(QTextStream &str, const QString &value, const QString &indent, + bool qString) +{ + switch (encoding) { + // Special characters as 3 digit octal escapes (u8"\303\234mlaut") + case Encoding::Utf8: { + if (qString) + str << "QString::fromUtf8("; + const QByteArray utf8 = value.toUtf8(); + formatStringSequence(str, utf8.cbegin(), utf8.cend(), indent, + 8, 3); + if (qString) + str << ')'; + } + break; + // Special characters as 4 digit hex Unicode points (u8"\u00dcmlaut") + case Encoding::Unicode: + str << 'u'; // Python Unicode literal (would be UTF-16 in C++) + formatStringSequence(str, value.cbegin(), value.cend(), indent, + 16, 4, 'u'); + break; + } +} + } // namespace language diff --git a/src/tools/uic/shared/language.h b/src/tools/uic/shared/language.h index e7201b6529..04a3763e54 100644 --- a/src/tools/uic/shared/language.h +++ b/src/tools/uic/shared/language.h @@ -29,6 +29,7 @@ #ifndef LANGUAGE_H #define LANGUAGE_H +#include #include QT_FORWARD_DECLARE_CLASS(QTextStream) @@ -76,6 +77,36 @@ const char *sizePolicy(int v); const char *dockWidgetArea(int v); const char *paletteColorRole(int v); +enum class Encoding { Utf8, Unicode }; + +void _formatString(QTextStream &str, const QString &value, const QString &indent, + bool qString); + +template +class _string +{ +public: + explicit _string(const QString &value, const QString &indent = QString()) + : m_value(value), m_indent(indent) {} + + void format(QTextStream &str) const + { _formatString(str, m_value, m_indent, AsQString); } + +private: + const QString &m_value; + const QString &m_indent; +}; + +template +inline QTextStream &operator<<(QTextStream &str, const language::_string &s) +{ + s.format(str); + return str; +} + +using charliteral = _string; +using qstring = _string; + } // namespace language #endif // LANGUAGE_H diff --git a/src/tools/uic/utils.h b/src/tools/uic/utils.h index 3f32a532ca..34c4ab23d4 100644 --- a/src/tools/uic/utils.h +++ b/src/tools/uic/utils.h @@ -42,55 +42,6 @@ inline bool toBool(const QString &str) inline QString toString(const DomString *str) { return str ? str->text() : QString(); } -inline QString fixString(const QString &str, const QString &indent) -{ - QString cursegment; - QStringList result; - const QByteArray utf8 = str.toUtf8(); - const int utf8Length = utf8.length(); - - for (int i = 0; i < utf8Length; ++i) { - const uchar cbyte = utf8.at(i); - if (cbyte >= 0x80) { - cursegment += QLatin1Char('\\'); - cursegment += QString::number(cbyte, 8); - } else { - switch(cbyte) { - case '\\': - cursegment += QLatin1String("\\\\"); break; - case '\"': - cursegment += QLatin1String("\\\""); break; - case '\r': - break; - case '\n': - cursegment += QLatin1String("\\n\"\n\""); break; - default: - cursegment += QLatin1Char(cbyte); - } - } - - if (cursegment.length() > 1024) { - result << cursegment; - cursegment.clear(); - } - } - - if (!cursegment.isEmpty()) - result << cursegment; - - - QString joinstr = QLatin1String("\"\n"); - joinstr += indent; - joinstr += indent; - joinstr += QLatin1Char('"'); - - QString rc(QLatin1Char('"')); - rc += result.join(joinstr); - rc += QLatin1Char('"'); - - return rc; -} - inline QHash propertyMap(const QList &properties) { QHash map; From bc8633036cb38de3dd8c27eb1e1f6a3aa39f1190 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 20 Nov 2018 08:38:16 +0100 Subject: [PATCH 158/292] uic: Add python - Add command line option - Add import (include) handling - Add language helpers like streamable classes for Function definition, object instantiation - Implement header comment formatting Task-number: PYSIDE-797 Change-Id: I15041ab16504ea159f6665781a829cd548585af1 Reviewed-by: Cristian Maureira-Fredes --- src/tools/uic/cpp/cppwriteincludes.h | 4 + src/tools/uic/cpp/cppwriteinitialization.cpp | 74 ++++++----- src/tools/uic/main.cpp | 10 +- src/tools/uic/python/python.pri | 8 ++ .../uic/python/pythonwritedeclaration.cpp | 73 +++++++++++ src/tools/uic/python/pythonwritedeclaration.h | 62 +++++++++ src/tools/uic/python/pythonwriteimports.cpp | 92 ++++++++++++++ src/tools/uic/python/pythonwriteimports.h | 58 +++++++++ src/tools/uic/shared/language.cpp | 120 +++++++++++++++++- src/tools/uic/shared/language.h | 82 ++++++++++++ src/tools/uic/uic.cpp | 91 +++++++++++-- src/tools/uic/uic.h | 3 +- src/tools/uic/uic.pro | 1 + 13 files changed, 630 insertions(+), 48 deletions(-) create mode 100644 src/tools/uic/python/python.pri create mode 100644 src/tools/uic/python/pythonwritedeclaration.cpp create mode 100644 src/tools/uic/python/pythonwritedeclaration.h create mode 100644 src/tools/uic/python/pythonwriteimports.cpp create mode 100644 src/tools/uic/python/pythonwriteimports.h diff --git a/src/tools/uic/cpp/cppwriteincludes.h b/src/tools/uic/cpp/cppwriteincludes.h index e9247f4cc4..79cbd41014 100644 --- a/src/tools/uic/cpp/cppwriteincludes.h +++ b/src/tools/uic/cpp/cppwriteincludes.h @@ -40,6 +40,7 @@ QT_BEGIN_NAMESPACE class QTextStream; +class CustomWidgetsInfo; class Driver; class Uic; @@ -74,6 +75,9 @@ struct WriteIncludes : public TreeWalker void acceptIncludes(DomIncludes *node) override; void acceptInclude(DomInclude *node) override; +protected: + QTextStream &output() const { return m_output; } + private: void add(const QString &className, bool determineHeader = true, const QString &header = QString(), bool global = false); diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 938d47f62d..f5ac59df08 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -71,7 +71,7 @@ namespace { // Write a statement to create a spacer item. void writeSpacerItem(const DomSpacer *node, QTextStream &output) { const QHash properties = propertyMap(node->elementProperty()); - output << "new QSpacerItem("; + output << language::operatorNew << "QSpacerItem("; int w = 0; int h = 0; @@ -495,8 +495,9 @@ void WriteInitialization::acceptUI(DomUI *node) const QString widgetClassName = node->elementWidget()->attributeClass(); - m_output << m_option.indent << "void " << "setupUi(" << widgetClassName << " *" << varName << ")\n" - << m_option.indent << "{\n"; + const QString parameterType = widgetClassName + QLatin1String(" *"); + m_output << m_option.indent + << language::startFunctionDefinition1("setupUi", parameterType, varName, m_option.indent); const QStringList connections = m_uic->databaseInfo()->connections(); for (int i=0; icustomWidgetsInfo(); if (m_widgetChain.size() != 1) { - m_output << m_indent << varName << " = new " << cwi->realClassName(className) - << '(' << parentWidget << ");\n"; + m_output << m_indent << varName << " = " << language::operatorNew + << language::fixClassName(cwi->realClassName(className)) + << '(' << parentWidget << ')' << language::eol; } parentWidget = savedParentWidget; @@ -846,7 +848,8 @@ void WriteInitialization::addButtonGroup(const DomWidget *buttonNode, const QStr m_output << m_indent; if (createGroupOnTheFly) m_output << className << " *"; - m_output << groupName << " = new " << className << '(' << m_mainFormVarName << ");\n"; + m_output << groupName << " = " << language::operatorNew + << className << '(' << m_mainFormVarName << ')' << language::eol; m_buttonGroups.insert(groupName); writeProperties(groupName, className, group->elementProperty()); } @@ -863,7 +866,7 @@ void WriteInitialization::acceptLayout(DomLayout *node) bool isGroupBox = false; - m_output << m_indent << varName << " = new " << className << '('; + m_output << m_indent << varName << " = " << language::operatorNew << className << '('; if (!m_layoutChain.top() && !isGroupBox) m_output << m_driver->findOrInsertWidget(m_widgetChain.top()); @@ -1037,7 +1040,8 @@ void WriteInitialization::acceptActionGroup(DomActionGroup *node) if (m_actionGroupChain.top()) varName = m_driver->findOrInsertActionGroup(m_actionGroupChain.top()); - m_output << m_indent << actionName << " = new QActionGroup(" << varName << ");\n"; + m_output << m_indent << actionName << " = " << language::operatorNew + << "QActionGroup(" << varName << ");\n"; writeProperties(actionName, QLatin1String("QActionGroup"), node->elementProperty()); m_actionGroupChain.push(node); @@ -1057,7 +1061,8 @@ void WriteInitialization::acceptAction(DomAction *node) if (m_actionGroupChain.top()) varName = m_driver->findOrInsertActionGroup(m_actionGroupChain.top()); - m_output << m_indent << actionName << " = new QAction(" << varName << ");\n"; + m_output << m_indent << actionName << " = " << language::operatorNew + << "QAction(" << varName << ')' << language::eol; writeProperties(actionName, QLatin1String("QAction"), node->elementProperty()); } @@ -1322,8 +1327,8 @@ void WriteInitialization::writeProperties(const QString &varName, case DomProperty::Palette: { const DomPalette *pal = p->elementPalette(); const QString paletteName = m_driver->unique(QLatin1String("palette")); - m_output << m_indent << "QPalette " << paletteName << ";\n"; - + m_output << m_indent << language::stackVariable("QPalette", paletteName) + << language::eol; writeColorGroup(pal->elementActive(), QLatin1String("QPalette::Active"), paletteName); writeColorGroup(pal->elementInactive(), QLatin1String("QPalette::Inactive"), paletteName); writeColorGroup(pal->elementDisabled(), QLatin1String("QPalette::Disabled"), paletteName); @@ -1512,20 +1517,15 @@ QString WriteInitialization::writeSizePolicy(const DomSizePolicy *sp) const QString spName = m_driver->unique(QLatin1String("sizePolicy")); m_sizePolicyNameMap.insert(sizePolicyHandle, spName); - m_output << m_indent << "QSizePolicy " << spName; - do { - if (sp->hasElementHSizeType() && sp->hasElementVSizeType()) { - m_output << "(QSizePolicy::" << language::sizePolicy(sp->elementHSizeType()) - << ", QSizePolicy::" << language::sizePolicy(sp->elementVSizeType()) << ");\n"; - break; - } - if (sp->hasAttributeHSizeType() && sp->hasAttributeVSizeType()) { - m_output << "(QSizePolicy::" << sp->attributeHSizeType() << ", QSizePolicy::" - << sp->attributeVSizeType() << ");\n"; - break; - } - m_output << ";\n"; - } while (false); + m_output << m_indent << language::stackVariableWithInitParameters("QSizePolicy", spName); + if (sp->hasElementHSizeType() && sp->hasElementVSizeType()) { + m_output << "QSizePolicy" << language::qualifier << language::sizePolicy(sp->elementHSizeType()) + << ", QSizePolicy" << language::qualifier << language::sizePolicy(sp->elementVSizeType()); + } else if (sp->hasAttributeHSizeType() && sp->hasAttributeVSizeType()) { + m_output << "QSizePolicy::" << sp->attributeHSizeType() << ", QSizePolicy::" + << sp->attributeVSizeType(); + } + m_output << ')' << language::eol; m_output << m_indent << spName << ".setHorizontalStretch(" << sp->elementHorStretch() << ");\n"; @@ -1549,7 +1549,8 @@ QString WriteInitialization::writeFontProperties(const DomFont *f) const QString fontName = m_driver->unique(QLatin1String("font")); m_fontPropertiesNameMap.insert(FontHandle(f), fontName); - m_output << m_indent << "QFont " << fontName << ";\n"; + m_output << m_indent << language::stackVariable("QFont", fontName) + << language::eol; if (f->hasElementFamily() && !f->elementFamily().isEmpty()) { m_output << m_indent << fontName << ".setFamily(" << language::qstring(f->elementFamily(), m_dindent) << ");\n"; @@ -2512,7 +2513,8 @@ QString WriteInitialization::Item::writeSetupUi(const QString &parent, Item::Emp bool generateMultiDirective = false; if (emptyItemPolicy == Item::ConstructItemOnly && m_children.isEmpty()) { if (m_setupUiData.policy == ItemData::DontGenerate) { - m_setupUiStream << m_indent << "new " << m_itemClassName << '(' << parent << ");\n"; + m_setupUiStream << m_indent << language::operatorNew << m_itemClassName + << '(' << parent << ')' << language::eol; return QString(); } if (m_setupUiData.policy == ItemData::GenerateWithMultiDirective) @@ -2523,11 +2525,17 @@ QString WriteInitialization::Item::writeSetupUi(const QString &parent, Item::Emp generateMultiDirectiveBegin(m_setupUiStream, m_setupUiData.directives); const QString uniqueName = m_driver->unique(QLatin1String("__") + m_itemClassName.toLower()); - m_setupUiStream << m_indent << m_itemClassName << " *" << uniqueName << " = new " << m_itemClassName << '(' << parent << ");\n"; + m_setupUiStream << m_indent; + if (language::language() == Language::Cpp) + m_setupUiStream << m_itemClassName << " *"; + m_setupUiStream << uniqueName + << " = " << language::operatorNew << m_itemClassName << '(' << parent + << ')' << language::eol; if (generateMultiDirective) { m_setupUiStream << "#else\n"; - m_setupUiStream << m_indent << "new " << m_itemClassName << '(' << parent << ");\n"; + m_setupUiStream << m_indent << language::operatorNew << m_itemClassName + << '(' << parent << ')' << language::eol; generateMultiDirectiveEnd(m_setupUiStream, m_setupUiData.directives); } diff --git a/src/tools/uic/main.cpp b/src/tools/uic/main.cpp index 0516b854ff..166fe78ff7 100644 --- a/src/tools/uic/main.cpp +++ b/src/tools/uic/main.cpp @@ -29,6 +29,7 @@ #include "uic.h" #include "option.h" #include "driver.h" +#include #include #include @@ -96,7 +97,7 @@ int runUic(int argc, char *argv[]) QCommandLineOption generatorOption(QStringList() << QStringLiteral("g") << QStringLiteral("generator")); generatorOption.setDescription(QStringLiteral("Select generator.")); - generatorOption.setValueName(QStringLiteral("java|cpp")); + generatorOption.setValueName(QStringLiteral("python|cpp")); parser.addOption(generatorOption); QCommandLineOption idBasedOption(QStringLiteral("idbased")); @@ -116,6 +117,13 @@ int runUic(int argc, char *argv[]) driver.option().translateFunction = parser.value(translateOption); driver.option().includeFile = parser.value(includeOption); + Language language = Language::Cpp; + if (parser.isSet(generatorOption)) { + if (parser.value(generatorOption).compare(QLatin1String("python")) == 0) + language = Language::Python; + } + language::setLanguage(language); + if (parser.isSet(noStringLiteralOption)) fprintf(stderr, "The -s, --no-stringliteral option is deprecated and it won't take any effect.\n"); diff --git a/src/tools/uic/python/python.pri b/src/tools/uic/python/python.pri new file mode 100644 index 0000000000..4dd31160a1 --- /dev/null +++ b/src/tools/uic/python/python.pri @@ -0,0 +1,8 @@ +INCLUDEPATH += $$PWD + +# Input +HEADERS += $$PWD/pythonwritedeclaration.h \ + $$PWD/pythonwriteimports.h + +SOURCES += $$PWD/pythonwritedeclaration.cpp \ + $$PWD/pythonwriteimports.cpp diff --git a/src/tools/uic/python/pythonwritedeclaration.cpp b/src/tools/uic/python/pythonwritedeclaration.cpp new file mode 100644 index 0000000000..5122b18e23 --- /dev/null +++ b/src/tools/uic/python/pythonwritedeclaration.cpp @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "pythonwritedeclaration.h" +#include +#include +#include +#include +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +namespace Python { + +WriteDeclaration::WriteDeclaration(Uic *uic) : + m_uic(uic), + m_driver(uic->driver()), + m_output(uic->output()), + m_option(uic->option()) +{ +} + +void WriteDeclaration::acceptUI(DomUI *node) +{ + // remove any left-over C++ namespaces + const QString qualifiedClassName = QLatin1String("Ui_") + node->elementClass() + + m_option.postfix; + m_output << "class " << language::fixClassName(qualifiedClassName) << "(object):\n"; + + TreeWalker::acceptWidget(node->elementWidget()); + if (const DomButtonGroups *domButtonGroups = node->elementButtonGroups()) + acceptButtonGroups(domButtonGroups); + CPP::WriteInitialization(m_uic).acceptUI(node); +} + +// Register button groups to prevent the on-the-fly creation legacy +// feature from triggering +void WriteDeclaration::acceptButtonGroup(const DomButtonGroup *buttonGroup) +{ + m_driver->findOrInsertButtonGroup(buttonGroup); +} + +} // namespace Python + +QT_END_NAMESPACE diff --git a/src/tools/uic/python/pythonwritedeclaration.h b/src/tools/uic/python/pythonwritedeclaration.h new file mode 100644 index 0000000000..a8d50b6fbf --- /dev/null +++ b/src/tools/uic/python/pythonwritedeclaration.h @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef PYTHONWRITEDECLARATION_H +#define PYTHONWRITEDECLARATION_H + +#include + +QT_BEGIN_NAMESPACE + +class QTextStream; +class Driver; +class Uic; + +struct Option; + +namespace Python { + +struct WriteDeclaration : public TreeWalker +{ + WriteDeclaration(Uic *uic); + + void acceptUI(DomUI *node) override; + void acceptButtonGroup(const DomButtonGroup *buttonGroup) override; + +private: + Uic *m_uic; + Driver *m_driver; + QTextStream &m_output; + const Option &m_option; +}; + +} // namespace Python + +QT_END_NAMESPACE + +#endif // PYTHONWRITEDECLARATION_H diff --git a/src/tools/uic/python/pythonwriteimports.cpp b/src/tools/uic/python/pythonwriteimports.cpp new file mode 100644 index 0000000000..8e11981f37 --- /dev/null +++ b/src/tools/uic/python/pythonwriteimports.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "pythonwriteimports.h" + +#include +#include + +#include + +#include + +QT_BEGIN_NAMESPACE + +static const char *standardImports = +R"I(from PySide2.QtCore import (QCoreApplication, QMetaObject, QObject, QPoint, + QRect, QSize, QUrl, Qt) +from PySide2.QtGui import (QColor, QFont, QIcon, QPixmap) +from PySide2.QtWidgets import * +)I"; + +namespace Python { + +WriteImports::WriteImports(Uic *uic) : m_uic(uic) +{ +} + +void WriteImports::acceptUI(DomUI *node) +{ + auto &output = m_uic->output(); + output << standardImports << '\n'; + if (auto customWidgets = node->elementCustomWidgets()) { + TreeWalker::acceptCustomWidgets(customWidgets); + output << '\n'; + } +} + +QString WriteImports::qtModuleOf(const DomCustomWidget *node) const +{ + if (m_uic->customWidgetsInfo()->extends(node->elementClass(), QLatin1String("QAxWidget"))) + return QStringLiteral("QtAxContainer"); + if (const auto headerElement = node->elementHeader()) { + const auto &header = headerElement->text(); + if (header.startsWith(QLatin1String("Qt"))) { + const int slash = header.indexOf(QLatin1Char('/')); + if (slash != -1) + return header.left(slash); + } + } + return QString(); +} + +void WriteImports::acceptCustomWidget(DomCustomWidget *node) +{ + const auto &className = node->elementClass(); + if (className.contains(QLatin1String("::"))) + return; // Exclude namespaced names (just to make tests pass). + const QString &qtModule = qtModuleOf(node); + auto &output = m_uic->output(); + if (!qtModule.isEmpty()) + output << "from PySide2." << qtModule << ' '; + output << "import " << className << '\n'; +} + +} // namespace Python + +QT_END_NAMESPACE diff --git a/src/tools/uic/python/pythonwriteimports.h b/src/tools/uic/python/pythonwriteimports.h new file mode 100644 index 0000000000..427cbb48b1 --- /dev/null +++ b/src/tools/uic/python/pythonwriteimports.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef PYTHONWRITEIMPORTS_H +#define PYTHONWRITEIMPORTS_H + +#include + +QT_BEGIN_NAMESPACE + +class Uic; + +namespace Python { + +struct WriteImports : public TreeWalker +{ +public: + explicit WriteImports(Uic *uic); + + void acceptUI(DomUI *node) override; + void acceptCustomWidget(DomCustomWidget *node) override; + +private: + QString qtModuleOf(const DomCustomWidget *node) const; + + Uic *const m_uic; +}; + +} // namespace Python + +QT_END_NAMESPACE + +#endif // PYTHONWRITEIMPORTS_H diff --git a/src/tools/uic/shared/language.cpp b/src/tools/uic/shared/language.cpp index d0491b74e3..d05f3c935f 100644 --- a/src/tools/uic/shared/language.cpp +++ b/src/tools/uic/shared/language.cpp @@ -33,6 +33,48 @@ namespace language { static Encoding encoding = Encoding::Utf8; +static Language _language = Language::Cpp; + +Language language() { return _language; } + +void setLanguage(Language l) +{ + _language = l; + switch (_language) { + case Language::Cpp: + derefPointer = QLatin1String("->"); + nullPtr = QLatin1String("nullptr"); + operatorNew = QLatin1String("new "); + qtQualifier = QLatin1String("Qt::"); + qualifier = QLatin1String("::"); + self = QLatin1String(""); // for testing: change to "this->"; + eol = QLatin1String(";\n"); + encoding = Encoding::Utf8; + break; + case Language::Python: + derefPointer = QLatin1String("."); + nullPtr = QLatin1String("None"); + operatorNew = QLatin1String(""); + qtQualifier = QLatin1String("Qt."); + qualifier = QLatin1String("."); + self = QLatin1String("self."); + eol = QLatin1String("\n"); + encoding = Encoding::Unicode; + break; + } +} + +QString derefPointer; +QString nullPtr; +QString operatorNew; +QString qtQualifier; +QString qualifier; +QString self; +QString eol; + +QString cppQualifier = QLatin1String("::"); +QString cppTrue = QLatin1String("true"); +QString cppFalse = QLatin1String("false"); QTextStream &operator<<(QTextStream &str, const qtConfig &c) { @@ -71,6 +113,13 @@ const char *lookupEnum(const EnumLookup(&array)[N], int value, int defaultIndex return defaultValue; } +QString fixClassName(QString className) +{ + if (language() == Language::Python) + className.replace(cppQualifier, QLatin1String("_")); + return className; +} + const char *toolbarArea(int v) { static const EnumLookup toolBarAreas[] = @@ -250,12 +299,12 @@ void _formatString(QTextStream &str, const QString &value, const QString &indent switch (encoding) { // Special characters as 3 digit octal escapes (u8"\303\234mlaut") case Encoding::Utf8: { - if (qString) + if (qString && _language == Language::Cpp) str << "QString::fromUtf8("; const QByteArray utf8 = value.toUtf8(); formatStringSequence(str, utf8.cbegin(), utf8.cend(), indent, 8, 3); - if (qString) + if (qString && _language == Language::Cpp) str << ')'; } break; @@ -268,4 +317,71 @@ void _formatString(QTextStream &str, const QString &value, const QString &indent } } +QTextStream &operator<<(QTextStream &str, const repeat &r) +{ + for (int i = 0; i < r.m_count; ++i) + str << r.m_char; + return str; +} + +startFunctionDefinition1::startFunctionDefinition1(const char *name, const QString ¶meterType, + const QString ¶meterName, + const QString &indent, + const char *returnType) : + m_name(name), m_parameterType(parameterType), m_parameterName(parameterName), + m_indent(indent), m_return(returnType) +{ +} + +QTextStream &operator<<(QTextStream &str, const startFunctionDefinition1 &f) +{ + switch (language()) { + case Language::Cpp: + str << (f.m_return ? f.m_return : "void") << ' ' << f.m_name << '(' + << f.m_parameterType; + if (f.m_parameterType.cend()->isLetter()) + str << ' '; + str << f.m_parameterName << ')' << '\n' << f.m_indent << "{\n"; + break; + case Language::Python: + str << "def " << f.m_name << "(self, " << f.m_parameterName << "):\n"; + break; + } + return str; +} + +endFunctionDefinition::endFunctionDefinition(const char *name) : m_name(name) +{ +} + +QTextStream &operator<<(QTextStream &str, const endFunctionDefinition &f) +{ + switch (language()) { + case Language::Cpp: + str << "} // " << f.m_name << "\n\n"; + break; + case Language::Python: + str << "# " << f.m_name << "\n\n"; + break; + } + return str; +} + +void _formatStackVariable(QTextStream &str, const char *className, QStringView varName, + bool withInitParameters) +{ + switch (language()) { + case Language::Cpp: + str << className << ' ' << varName; + if (withInitParameters) + str << '('; + break; + case Language::Python: + str << varName << " = " << className << '('; + if (!withInitParameters) + str << ')'; + break; + } +} + } // namespace language diff --git a/src/tools/uic/shared/language.h b/src/tools/uic/shared/language.h index 04a3763e54..a1c871a549 100644 --- a/src/tools/uic/shared/language.h +++ b/src/tools/uic/shared/language.h @@ -34,8 +34,25 @@ QT_FORWARD_DECLARE_CLASS(QTextStream) +enum class Language { Cpp, Python }; + namespace language { +Language language(); +void setLanguage(Language); + +extern QString derefPointer; +extern QString nullPtr; +extern QString operatorNew; +extern QString qtQualifier; +extern QString qualifier; +extern QString self; +extern QString eol; + +extern QString cppQualifier; +extern QString cppTrue; +extern QString cppFalse; + // Base class for streamable objects with one QStringView parameter class StringViewStreamable { @@ -72,6 +89,8 @@ public: QTextStream &operator<<(QTextStream &, const closeQtConfig &c); +QString fixClassName(QString className); + const char *toolbarArea(int v); const char *sizePolicy(int v); const char *dockWidgetArea(int v); @@ -107,6 +126,69 @@ inline QTextStream &operator<<(QTextStream &str, const language::_string; using qstring = _string; +class repeat { +public: + explicit repeat(int count, char c) : m_count(count), m_char(c) {} + + friend QTextStream &operator<<(QTextStream &str, const repeat &r); + +private: + const int m_count; + const char m_char; +}; + +class startFunctionDefinition1 { +public: + explicit startFunctionDefinition1(const char *name, const QString ¶meterType, + const QString ¶meterName, + const QString &indent, + const char *returnType = nullptr); + + friend QTextStream &operator<<(QTextStream &str, const startFunctionDefinition1 &f); +private: + const char *m_name; + const QString &m_parameterType; + const QString &m_parameterName; + const QString &m_indent; + const char *m_return; +}; + +class endFunctionDefinition { +public: + explicit endFunctionDefinition(const char *name); + + friend QTextStream &operator<<(QTextStream &str, const endFunctionDefinition &f); +private: + const char *m_name; +}; + +void _formatStackVariable(QTextStream &str, const char *className, QStringView varName, bool withInitParameters); + +template +class _stackVariable { +public: + explicit _stackVariable(const char *className, QStringView varName) : + m_className(className), m_varName(varName) {} + + void format(QTextStream &str) const + { _formatStackVariable(str, m_className, m_varName, withInitParameters); } + +private: + const char *m_className; + QStringView m_varName; + QStringView m_parameters; +}; + +template +inline QTextStream &operator<<(QTextStream &str, const _stackVariable &s) +{ + s.format(str); + return str; +} + +using stackVariable = _stackVariable; +using stackVariableWithInitParameters = _stackVariable; + } // namespace language #endif // LANGUAGE_H diff --git a/src/tools/uic/uic.cpp b/src/tools/uic/uic.cpp index 225dc6aeb2..b95f1a784b 100644 --- a/src/tools/uic/uic.cpp +++ b/src/tools/uic/uic.cpp @@ -35,6 +35,10 @@ #include "cppwriteincludes.h" #include "cppwritedeclaration.h" +#include +#include + +#include #include #include @@ -103,7 +107,7 @@ bool Uic::printDependencies() return true; } -void Uic::writeCopyrightHeader(DomUI *ui) +void Uic::writeCopyrightHeaderCpp(const DomUI *ui) const { QString comment = ui->elementComment(); if (!comment.isEmpty()) @@ -118,6 +122,48 @@ void Uic::writeCopyrightHeader(DomUI *ui) out << "********************************************************************************/\n\n"; } +// Format existing UI file comments for Python with some smartness : Replace all +// leading C++ comment characters by '#' or prepend '#' if needed. + +static inline bool isCppCommentChar(QChar c) +{ + return c == QLatin1Char('/') || c == QLatin1Char('*'); +} + +static int leadingCppCommentCharCount(const QStringRef &s) +{ + int i = 0; + for (const int size = s.size(); i < size && isCppCommentChar(s.at(i)); ++i) { + } + return i; +} + +void Uic::writeCopyrightHeaderPython(const DomUI *ui) const +{ + QString comment = ui->elementComment(); + if (!comment.isEmpty()) { + const auto lines = comment.splitRef(QLatin1Char('\n')); + for (const auto &line : lines) { + if (const int leadingCommentChars = leadingCppCommentCharCount(line)) { + out << language::repeat(leadingCommentChars, '#') + << line.right(line.size() - leadingCommentChars); + } else { + if (!line.startsWith(QLatin1Char('#'))) + out << "# "; + out << line; + } + out << '\n'; + } + out << '\n'; + } + + out << language::repeat(80, '#') << "\n## Form generated from reading UI file '" + << QFileInfo(opt.inputFile).fileName() + << "'\n##\n## Created by: Qt User Interface Compiler version " << QT_VERSION_STR + << "\n##\n## WARNING! All changes made in this file will be lost when recompiling UI file!\n" + << language::repeat(80, '#') << "\n\n"; +} + // Check the version with a stream reader at the element. static double versionFromUiAttribute(QXmlStreamReader &reader) @@ -195,15 +241,26 @@ bool Uic::write(QIODevice *in) bool Uic::write(DomUI *ui) { - using namespace CPP; - if (!ui || !ui->elementWidget()) return false; - if (opt.copyrightHeader) - writeCopyrightHeader(ui); + const auto lang = language::language(); - if (opt.headerProtection) { + if (lang == Language::Python) + out << "# -*- coding: utf-8 -*-\n\n"; + + if (opt.copyrightHeader) { + switch (language::language()) { + case Language::Cpp: + writeCopyrightHeaderCpp(ui); + break; + case Language::Python: + writeCopyrightHeaderPython(ui); + break; + } + } + + if (opt.headerProtection && lang == Language::Cpp) { writeHeaderProtectionStart(); out << "\n"; } @@ -218,13 +275,25 @@ bool Uic::write(DomUI *ui) info.acceptUI(ui); cWidgetsInfo.acceptUI(ui); - WriteIncludes writeIncludes(this); - writeIncludes.acceptUI(ui); - Validator(this).acceptUI(ui); - WriteDeclaration(this).acceptUI(ui); + switch (language::language()) { + case Language::Cpp: { + CPP::WriteIncludes writeIncludes(this); + writeIncludes.acceptUI(ui); + Validator(this).acceptUI(ui); + CPP::WriteDeclaration(this).acceptUI(ui); + } + break; + case Language::Python: { + Python::WriteImports writeImports(this); + writeImports.acceptUI(ui); + Validator(this).acceptUI(ui); + Python::WriteDeclaration(this).acceptUI(ui); + } + break; + } - if (opt.headerProtection) + if (opt.headerProtection && lang == Language::Cpp) writeHeaderProtectionEnd(); return true; diff --git a/src/tools/uic/uic.h b/src/tools/uic/uic.h index af5f42c6db..f3dfd49149 100644 --- a/src/tools/uic/uic.h +++ b/src/tools/uic/uic.h @@ -91,7 +91,8 @@ public: private: // copyright header - void writeCopyrightHeader(DomUI *ui); + void writeCopyrightHeaderCpp(const DomUI *ui) const; + void writeCopyrightHeaderPython(const DomUI *ui) const; DomUI *parseUiFile(QXmlStreamReader &reader); // header protection diff --git a/src/tools/uic/uic.pro b/src/tools/uic/uic.pro index 4469ce50e5..1bf8ef8ad3 100644 --- a/src/tools/uic/uic.pro +++ b/src/tools/uic/uic.pro @@ -7,6 +7,7 @@ DEFINES += QT_UIC QT_NO_CAST_FROM_ASCII QT_NO_FOREACH include(uic.pri) include(shared/shared.pri) include(cpp/cpp.pri) +include(python/python.pri) HEADERS += uic.h From 5b8676578de276bf5db68d08ef8d7fb65c8ec8e0 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 28 Nov 2018 15:02:25 +0100 Subject: [PATCH 159/292] uic: Add qualification with "self." for Python Prepend "self." (this) to the name stored in the class Driver's hashes as specifying it is mandatory in Python. Task-number: PYSIDE-797 Change-Id: I1da110b84b2d1131ee6af915f9cc4ba21d7de710 Reviewed-by: Cristian Maureira-Fredes --- src/tools/uic/driver.cpp | 14 ++++++++++---- src/tools/uic/driver.h | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/tools/uic/driver.cpp b/src/tools/uic/driver.cpp index 7d690cd2fe..a0812932ce 100644 --- a/src/tools/uic/driver.cpp +++ b/src/tools/uic/driver.cpp @@ -30,6 +30,8 @@ #include "uic.h" #include "ui4.h" +#include + #include #include @@ -63,17 +65,21 @@ const DomClass *Driver::findByAttributeName(const DomObjectHash &domHa template QString Driver::findOrInsert(DomObjectHash *domHash, const DomClass *dom, - const QString &className) + const QString &className, bool isMember) { auto it = domHash->find(dom); - if (it == domHash->end()) - it = domHash->insert(dom, this->unique(dom->attributeName(), className)); + if (it == domHash->end()) { + const QString name = this->unique(dom->attributeName(), className); + it = domHash->insert(dom, isMember ? language::self + name : name); + } return it.value(); } QString Driver::findOrInsertWidget(const DomWidget *ui_widget) { - return findOrInsert(&m_widgets, ui_widget, ui_widget->attributeClass()); + // Top level is passed into setupUI(), everything else is a member variable + const bool isMember = !m_widgets.isEmpty(); + return findOrInsert(&m_widgets, ui_widget, ui_widget->attributeClass(), isMember); } QString Driver::findOrInsertSpacer(const DomSpacer *ui_spacer) diff --git a/src/tools/uic/driver.h b/src/tools/uic/driver.h index 1e50f78746..36336007b2 100644 --- a/src/tools/uic/driver.h +++ b/src/tools/uic/driver.h @@ -98,7 +98,8 @@ private: const DomClass *findByAttributeName(const DomObjectHash &domHash, const QString &name) const; template - QString findOrInsert(DomObjectHash *domHash, const DomClass *dom, const QString &className); + QString findOrInsert(DomObjectHash *domHash, const DomClass *dom, const QString &className, + bool isMember = true); Option m_option; QTextStream m_stdout; From 5a5a96560e36af6b5d7ab375651b8c622bb5a7c3 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 28 Nov 2018 11:30:41 +0100 Subject: [PATCH 160/292] uic: Adapt connection syntax to Python Extend WriteInitialization::findDeclaration() to return the class name (on this occasion preparing for generating Qt 5 connection syntax) and add a helper function for formatting the connection. Task-number: PYSIDE-797 Change-Id: I7507f604c8275c93d347b7a6a5d5b5a2a5f3ffd5 Reviewed-by: Cristian Maureira-Fredes --- src/tools/uic/cpp/cppwriteinitialization.cpp | 42 ++++++++++++-------- src/tools/uic/cpp/cppwriteinitialization.h | 8 +++- src/tools/uic/shared/language.cpp | 17 ++++++++ src/tools/uic/shared/language.h | 10 +++++ 4 files changed, 59 insertions(+), 18 deletions(-) diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index f5ac59df08..9986e7306d 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -2430,34 +2430,42 @@ QTextStream &WriteInitialization::autoTrOutput(const DomString *str, const QStri return m_output; } -QString WriteInitialization::findDeclaration(const QString &name) +WriteInitialization::Declaration WriteInitialization::findDeclaration(const QString &name) { if (const DomWidget *widget = m_driver->widgetByName(name)) - return m_driver->findOrInsertWidget(widget); + return {m_driver->findOrInsertWidget(widget), widget->attributeClass()}; if (const DomAction *action = m_driver->actionByName(name)) - return m_driver->findOrInsertAction(action); + return {m_driver->findOrInsertAction(action), QStringLiteral("QAction")}; if (const DomButtonGroup *group = m_driver->findButtonGroup(name)) - return m_driver->findOrInsertButtonGroup(group); - return QString(); + return {m_driver->findOrInsertButtonGroup(group), QStringLiteral("QButtonGroup")}; + return {}; } void WriteInitialization::acceptConnection(DomConnection *connection) { - const QString sender = findDeclaration(connection->elementSender()); - const QString receiver = findDeclaration(connection->elementReceiver()); + const QString senderName = connection->elementSender(); + const QString receiverName = connection->elementReceiver(); - if (sender.isEmpty() || receiver.isEmpty()) + const auto senderDecl = findDeclaration(senderName); + const auto receiverDecl = findDeclaration(receiverName); + + if (senderDecl.name.isEmpty() || receiverDecl.name.isEmpty()) { + QString message; + QTextStream(&message) << m_option.messagePrefix() + << ": Warning: Invalid signal/slot connection: \"" + << senderName << "\" -> \"" << receiverName << "\"."; + fprintf(stderr, "%s\n", qPrintable(message)); return; + } - m_output << m_indent << "QObject::connect(" - << sender - << ", " - << "SIGNAL("<elementSignal()<<')' - << ", " - << receiver - << ", " - << "SLOT("<elementSlot()<<')' - << ");\n"; + language::SignalSlot theSignal{senderDecl.name, connection->elementSignal(), + senderDecl.className}; + language::SignalSlot theSlot{receiverDecl.name, connection->elementSlot(), + receiverDecl.className}; + + m_output << m_indent; + language::formatConnection(m_output, theSignal, theSlot); + m_output << ";\n"; } static void generateMultiDirectiveBegin(QTextStream &outputStream, const QSet &directives) diff --git a/src/tools/uic/cpp/cppwriteinitialization.h b/src/tools/uic/cpp/cppwriteinitialization.h index c408c44b40..b90ffe00a7 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.h +++ b/src/tools/uic/cpp/cppwriteinitialization.h @@ -220,7 +220,13 @@ private: QString disableSorting(DomWidget *w, const QString &varName); void enableSorting(DomWidget *w, const QString &varName, const QString &tempName); - QString findDeclaration(const QString &name); + struct Declaration + { + QString name; + QString className; + }; + + Declaration findDeclaration(const QString &name); private: QString writeFontProperties(const DomFont *f); diff --git a/src/tools/uic/shared/language.cpp b/src/tools/uic/shared/language.cpp index d05f3c935f..fe44f95285 100644 --- a/src/tools/uic/shared/language.cpp +++ b/src/tools/uic/shared/language.cpp @@ -384,4 +384,21 @@ void _formatStackVariable(QTextStream &str, const char *className, QStringView v } } +void formatConnection(QTextStream &str, const SignalSlot &sender, const SignalSlot &receiver) +{ + switch (language()) { + case Language::Cpp: + str << "QObject::connect(" << sender.name << ", SIGNAL("<< sender.signature + << "), " << receiver.name << ", SLOT("<< receiver.signature << "))"; + break; + case Language::Python: + str << sender.name << '.' + << sender.signature.leftRef(sender.signature.indexOf(QLatin1Char('('))) + << ".connect(" << receiver.name << '.' + << receiver.signature.leftRef(receiver.signature.indexOf(QLatin1Char('('))) + << ')'; + break; + } +} + } // namespace language diff --git a/src/tools/uic/shared/language.h b/src/tools/uic/shared/language.h index a1c871a549..eb50a2db7f 100644 --- a/src/tools/uic/shared/language.h +++ b/src/tools/uic/shared/language.h @@ -31,6 +31,7 @@ #include #include +#include QT_FORWARD_DECLARE_CLASS(QTextStream) @@ -189,6 +190,15 @@ inline QTextStream &operator<<(QTextStream &str, const _stackVariable; using stackVariableWithInitParameters = _stackVariable; +struct SignalSlot +{ + QString name; + QString signature; + QString className; +}; + +void formatConnection(QTextStream &str, const SignalSlot &sender, const SignalSlot &receiver); + } // namespace language #endif // LANGUAGE_H From 7ac2263f30bf5649af00d1b800c1386015feba8f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 5 Apr 2019 09:50:28 +0200 Subject: [PATCH 161/292] Windows code: Replace deprecated QVariant API Task-number: QTBUG-74043 Change-Id: I6f5f47b74830597eec74e2582e24d2d7dd235a80 Reviewed-by: Christian Ehrlicher --- src/plugins/platforms/windows/qwindowsmenu.cpp | 2 +- src/plugins/platforms/windows/qwindowsnativeinterface.cpp | 2 +- src/widgets/dialogs/qwizard_win.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowsmenu.cpp b/src/plugins/platforms/windows/qwindowsmenu.cpp index 5a92a7cf90..17a1b94101 100644 --- a/src/plugins/platforms/windows/qwindowsmenu.cpp +++ b/src/plugins/platforms/windows/qwindowsmenu.cpp @@ -784,7 +784,7 @@ void QWindowsMenuBar::handleReparent(QWindow *newParentWindow) if (QPlatformWindow *platWin = newParentWindow->handle()) install(static_cast(platWin)); else // Store for later creation, see menuBarOf() - newParentWindow->setProperty(menuBarPropertyName, qVariantFromValue(this)); + newParentWindow->setProperty(menuBarPropertyName, QVariant::fromValue(this)); } QWindowsMenuBar *QWindowsMenuBar::menuBarOf(const QWindow *notYetCreatedWindow) diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp index 9003e94c56..b8ab7f8779 100644 --- a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp +++ b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp @@ -143,7 +143,7 @@ QVariant QWindowsNativeInterface::windowProperty(QPlatformWindow *window, const { QWindowsWindow *platformWindow = static_cast(window); if (name == QLatin1String(customMarginPropertyC)) - return qVariantFromValue(platformWindow->customMargins()); + return QVariant::fromValue(platformWindow->customMargins()); return QVariant(); } diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp index 62738f732c..4986bbc75f 100644 --- a/src/widgets/dialogs/qwizard_win.cpp +++ b/src/widgets/dialogs/qwizard_win.cpp @@ -172,7 +172,7 @@ void QVistaHelper::updateCustomMargins(bool vistaMargins) const QMargins customMarginsDp = vistaMargins ? QMargins(0, -titleBarSizeDp(), 0, 0) : QMargins(); - const QVariant customMarginsV = qVariantFromValue(customMarginsDp); + const QVariant customMarginsV = QVariant::fromValue(customMarginsDp); // The dynamic property takes effect when creating the platform window. window->setProperty("_q_windowsCustomMargins", customMarginsV); // If a platform window exists, change via native interface. From 6b66108c1ffc48ee1dc06c4e25d9210bf2d41084 Mon Sep 17 00:00:00 2001 From: Paolo Dastoli Date: Sat, 16 Feb 2019 15:23:31 +0100 Subject: [PATCH 162/292] Add serializer/deserializer for Enumeration Enum class are serialized using the declared size. [ChangeLog][QtCore][QDataStream] Enumerations can now be serialized through QDataStream without the need of manually defining streaming operators. Change-Id: Iae9a63eb62b5a5615b657766a3c4c66ba4d98d0e Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Paolo Dastoli Reviewed-by: Thiago Macieira --- src/corelib/serialization/qdatastream.cpp | 4 + src/corelib/serialization/qdatastream.h | 10 +++ .../qdatastream/tst_qdatastream.cpp | 86 +++++++++++++++++++ 3 files changed, 100 insertions(+) diff --git a/src/corelib/serialization/qdatastream.cpp b/src/corelib/serialization/qdatastream.cpp index 3ea518907b..b44d55cb8f 100644 --- a/src/corelib/serialization/qdatastream.cpp +++ b/src/corelib/serialization/qdatastream.cpp @@ -98,6 +98,10 @@ QT_BEGIN_NAMESPACE ensures that you get integers of the size you want and insulates you from compiler and platform differences. + Enumerations can be serialized through QDataStream without the + need of manually defining streaming operators. Enum classes are + serialized using the declared size. + To take one example, a \c{char *} string is written as a 32-bit integer equal to the length of the string including the '\\0' byte, followed by all the characters of the string including the diff --git a/src/corelib/serialization/qdatastream.h b/src/corelib/serialization/qdatastream.h index 6e358df02e..2acf7d8c4b 100644 --- a/src/corelib/serialization/qdatastream.h +++ b/src/corelib/serialization/qdatastream.h @@ -377,6 +377,16 @@ template inline QDataStream &operator>>(QDataStream &s, QFlags &e) { return s >> e.i; } +template +typename std::enable_if::value, QDataStream &>::type& +operator<<(QDataStream &s, const T &t) +{ return s << static_cast::type>(t); } + +template +typename std::enable_if::value, QDataStream &>::type& +operator>>(QDataStream &s, T &t) +{ return s >> reinterpret_cast::type &>(t); } + template inline QDataStream &operator>>(QDataStream &s, QList &l) { diff --git a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp index d204727bbd..19cdd42a74 100644 --- a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp @@ -181,6 +181,8 @@ private slots: void streamRealDataTypes(); + void enumTest(); + void floatingPointPrecision(); void compatibility_Qt3(); @@ -3409,6 +3411,90 @@ void tst_QDataStream::floatingPointNaN() } } +void tst_QDataStream::enumTest() +{ + QByteArray ba; + + enum class E1 : qint8 + { + A, + B, + C + }; + { + QDataStream stream(&ba, QIODevice::WriteOnly); + stream << E1::A; + QCOMPARE(ba.size(), int(sizeof(E1))); + } + { + QDataStream stream(ba); + E1 e; + stream >> e; + QCOMPARE(e, E1::A); + } + ba.clear(); + + enum class E2 : qint16 + { + A, + B, + C + }; + { + QDataStream stream(&ba, QIODevice::WriteOnly); + stream << E2::B; + QCOMPARE(ba.size(), int(sizeof(E2))); + } + { + QDataStream stream(ba); + E2 e; + stream >> e; + QCOMPARE(e, E2::B); + } + ba.clear(); + + enum class E4 : qint32 + { + A, + B, + C + }; + { + QDataStream stream(&ba, QIODevice::WriteOnly); + stream << E4::C; + QCOMPARE(ba.size(), int(sizeof(E4))); + } + { + QDataStream stream(ba); + E4 e; + stream >> e; + QCOMPARE(e, E4::C); + } + ba.clear(); + + + enum E + { + A, + B, + C, + D + }; + { + QDataStream stream(&ba, QIODevice::WriteOnly); + stream << E::D; + QCOMPARE(ba.size(), 4); + } + { + QDataStream stream(ba); + E e; + stream >> e; + QCOMPARE(e, E::D); + } + ba.clear(); + +} + void tst_QDataStream::floatingPointPrecision() { QByteArray ba; From dbf7706413bb8d624ac17b24398eaf4ef542ed6b Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 2 Apr 2019 10:59:52 +0200 Subject: [PATCH 163/292] Replace Q_DECL_NOEXCEPT with noexcept in QtGui Change-Id: I43803b88fea8083782d73ce157c466b022208740 Reviewed-by: Thiago Macieira --- src/gui/image/qbitmap.h | 2 +- src/gui/image/qicon.cpp | 2 +- src/gui/image/qicon.h | 8 +- src/gui/image/qimage.cpp | 8 +- src/gui/image/qimage.h | 14 +- src/gui/image/qpicture.h | 4 +- src/gui/image/qpixmap.h | 4 +- src/gui/image/qpixmapcache.cpp | 2 +- src/gui/image/qpixmapcache.h | 8 +- src/gui/kernel/qcursor.cpp | 2 +- src/gui/kernel/qcursor.h | 12 +- src/gui/kernel/qevent.cpp | 6 +- src/gui/kernel/qevent.h | 18 +-- src/gui/kernel/qkeysequence.cpp | 2 +- src/gui/kernel/qkeysequence.h | 8 +- src/gui/kernel/qpalette.h | 6 +- src/gui/kernel/qpixelformat.h | 64 ++++----- src/gui/opengl/qopengldebug.h | 4 +- src/gui/opengl/qopenglpixeltransferoptions.h | 4 +- src/gui/opengl/qopenglversionfunctions.h | 2 +- src/gui/painting/qbrush.h | 4 +- src/gui/painting/qcolor.cpp | 124 ++++++++-------- src/gui/painting/qcolor.h | 142 +++++++++---------- src/gui/painting/qmatrix.cpp | 6 +- src/gui/painting/qmatrix.h | 10 +- src/gui/painting/qpagelayout.h | 4 +- src/gui/painting/qpagesize.h | 4 +- src/gui/painting/qpaintdevice.cpp | 2 +- src/gui/painting/qpaintdevice.h | 2 +- src/gui/painting/qpainterpath.cpp | 2 +- src/gui/painting/qpainterpath.h | 6 +- src/gui/painting/qpen.cpp | 4 +- src/gui/painting/qpen.h | 10 +- src/gui/painting/qpolygon.h | 14 +- src/gui/painting/qregion.cpp | 12 +- src/gui/painting/qregion.h | 26 ++-- src/gui/painting/qtransform.cpp | 4 +- src/gui/painting/qtransform.h | 10 +- src/gui/text/qfont.cpp | 2 +- src/gui/text/qfont.h | 4 +- src/gui/text/qfont_p.h | 2 +- src/gui/text/qfontdatabase.cpp | 6 +- src/gui/text/qfontengine_p.h | 18 +-- src/gui/text/qfontmetrics.h | 4 +- src/gui/text/qglyphrun.h | 4 +- src/gui/text/qrawfont.cpp | 2 +- src/gui/text/qrawfont.h | 6 +- src/gui/text/qstatictext.h | 4 +- src/gui/text/qtextcursor.h | 4 +- src/gui/text/qtextengine_p.h | 4 +- src/gui/text/qtextobject.cpp | 4 +- src/gui/text/qtextobject.h | 8 +- src/gui/text/qzipreader_p.h | 4 +- src/gui/util/qshaderformat.cpp | 24 ++-- src/gui/util/qshaderformat_p.h | 26 ++-- src/gui/util/qshadergraph.cpp | 12 +- src/gui/util/qshadergraph_p.h | 16 +-- src/gui/util/qshadergraphloader.cpp | 14 +- src/gui/util/qshadergraphloader_p.h | 14 +- src/gui/util/qshadernode.cpp | 16 +-- src/gui/util/qshadernode_p.h | 18 +-- src/gui/util/qshadernodeport.cpp | 4 +- src/gui/util/qshadernodeport_p.h | 6 +- src/gui/util/qshadernodesloader.cpp | 10 +- src/gui/util/qshadernodesloader_p.h | 10 +- src/gui/vulkan/qvulkaninstance.h | 12 +- 66 files changed, 412 insertions(+), 412 deletions(-) diff --git a/src/gui/image/qbitmap.h b/src/gui/image/qbitmap.h index f7895bb1e0..3cc360f670 100644 --- a/src/gui/image/qbitmap.h +++ b/src/gui/image/qbitmap.h @@ -61,7 +61,7 @@ public: QBitmap(const QBitmap &other) : QPixmap(other) {} // QBitmap(QBitmap &&other) : QPixmap(std::move(other)) {} // QPixmap doesn't, yet, have a move ctor QBitmap &operator=(const QBitmap &other) { QPixmap::operator=(other); return *this; } - QBitmap &operator=(QBitmap &&other) Q_DECL_NOTHROW { QPixmap::operator=(std::move(other)); return *this; } + QBitmap &operator=(QBitmap &&other) noexcept { QPixmap::operator=(std::move(other)); return *this; } ~QBitmap(); #endif diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index c3c4b24678..892a686c89 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -663,7 +663,7 @@ QFactoryLoader *qt_iconEngineFactoryLoader() /*! Constructs a null icon. */ -QIcon::QIcon() Q_DECL_NOEXCEPT +QIcon::QIcon() noexcept : d(0) { } diff --git a/src/gui/image/qicon.h b/src/gui/image/qicon.h index 8870950982..0f834fc2cb 100644 --- a/src/gui/image/qicon.h +++ b/src/gui/image/qicon.h @@ -58,11 +58,11 @@ public: enum Mode { Normal, Disabled, Active, Selected }; enum State { On, Off }; - QIcon() Q_DECL_NOEXCEPT; + QIcon() noexcept; QIcon(const QPixmap &pixmap); QIcon(const QIcon &other); #ifdef Q_COMPILER_RVALUE_REFS - QIcon(QIcon &&other) Q_DECL_NOEXCEPT + QIcon(QIcon &&other) noexcept : d(other.d) { other.d = nullptr; } #endif @@ -71,10 +71,10 @@ public: ~QIcon(); QIcon &operator=(const QIcon &other); #ifdef Q_COMPILER_RVALUE_REFS - inline QIcon &operator=(QIcon &&other) Q_DECL_NOEXCEPT + inline QIcon &operator=(QIcon &&other) noexcept { swap(other); return *this; } #endif - inline void swap(QIcon &other) Q_DECL_NOEXCEPT + inline void swap(QIcon &other) noexcept { qSwap(d, other.d); } operator QVariant() const; diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 8b2db6d346..b49674644a 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -741,7 +741,7 @@ bool QImageData::checkForAlphaPixels() const \sa isNull() */ -QImage::QImage() Q_DECL_NOEXCEPT +QImage::QImage() noexcept : QPaintDevice() { d = 0; @@ -5552,7 +5552,7 @@ Q_STATIC_ASSERT(sizeof(pixelformats) / sizeof(*pixelformats) == QImage::NImageFo /*! Returns the QImage::Format as a QPixelFormat */ -QPixelFormat QImage::pixelFormat() const Q_DECL_NOTHROW +QPixelFormat QImage::pixelFormat() const noexcept { return toPixelFormat(format()); } @@ -5560,7 +5560,7 @@ QPixelFormat QImage::pixelFormat() const Q_DECL_NOTHROW /*! Converts \a format into a QPixelFormat */ -QPixelFormat QImage::toPixelFormat(QImage::Format format) Q_DECL_NOTHROW +QPixelFormat QImage::toPixelFormat(QImage::Format format) noexcept { Q_ASSERT(static_cast(format) < NImageFormats); return pixelformats[format]; @@ -5569,7 +5569,7 @@ QPixelFormat QImage::toPixelFormat(QImage::Format format) Q_DECL_NOTHROW /*! Converts \a format into a QImage::Format */ -QImage::Format QImage::toImageFormat(QPixelFormat format) Q_DECL_NOTHROW +QImage::Format QImage::toImageFormat(QPixelFormat format) noexcept { for (int i = 0; i < NImageFormats; i++) { if (format == pixelformats[i]) diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index af7e6988cb..a4ec7aa69b 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -137,7 +137,7 @@ public: }; Q_ENUM(Format) - QImage() Q_DECL_NOEXCEPT; + QImage() noexcept; QImage(const QSize &size, Format format); QImage(int width, int height, Format format); QImage(uchar *data, int width, int height, Format format, QImageCleanupFunction cleanupFunction = nullptr, void *cleanupInfo = nullptr); @@ -152,7 +152,7 @@ public: QImage(const QImage &); #ifdef Q_COMPILER_RVALUE_REFS - inline QImage(QImage &&other) Q_DECL_NOEXCEPT + inline QImage(QImage &&other) noexcept : QPaintDevice(), d(nullptr) { qSwap(d, other.d); } #endif @@ -160,10 +160,10 @@ public: QImage &operator=(const QImage &); #ifdef Q_COMPILER_RVALUE_REFS - inline QImage &operator=(QImage &&other) Q_DECL_NOEXCEPT + inline QImage &operator=(QImage &&other) noexcept { qSwap(d, other.d); return *this; } #endif - inline void swap(QImage &other) Q_DECL_NOEXCEPT + inline void swap(QImage &other) noexcept { qSwap(d, other.d); } bool isNull() const; @@ -341,9 +341,9 @@ public: QString text(const QString &key = QString()) const; void setText(const QString &key, const QString &value); - QPixelFormat pixelFormat() const Q_DECL_NOTHROW; - static QPixelFormat toPixelFormat(QImage::Format format) Q_DECL_NOTHROW; - static QImage::Format toImageFormat(QPixelFormat format) Q_DECL_NOTHROW; + QPixelFormat pixelFormat() const noexcept; + static QPixelFormat toPixelFormat(QImage::Format format) noexcept; + static QImage::Format toImageFormat(QPixelFormat format) noexcept; // Platform specific conversion functions #if defined(Q_OS_DARWIN) || defined(Q_QDOC) diff --git a/src/gui/image/qpicture.h b/src/gui/image/qpicture.h index ec7b4bd7e3..cac2ef5dfc 100644 --- a/src/gui/image/qpicture.h +++ b/src/gui/image/qpicture.h @@ -79,10 +79,10 @@ public: QPicture& operator=(const QPicture &p); #ifdef Q_COMPILER_RVALUE_REFS - inline QPicture &operator=(QPicture &&other) Q_DECL_NOEXCEPT + inline QPicture &operator=(QPicture &&other) noexcept { qSwap(d_ptr, other.d_ptr); return *this; } #endif - inline void swap(QPicture &other) Q_DECL_NOEXCEPT + inline void swap(QPicture &other) noexcept { d_ptr.swap(other.d_ptr); } void detach(); bool isDetached() const; diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index 13c81f18d0..2103fcc58c 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -74,10 +74,10 @@ public: QPixmap &operator=(const QPixmap &); #ifdef Q_COMPILER_RVALUE_REFS - inline QPixmap &operator=(QPixmap &&other) Q_DECL_NOEXCEPT + inline QPixmap &operator=(QPixmap &&other) noexcept { qSwap(data, other.data); return *this; } #endif - inline void swap(QPixmap &other) Q_DECL_NOEXCEPT + inline void swap(QPixmap &other) noexcept { qSwap(data, other.data); } operator QVariant() const; diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp index 66907bebd7..a41ec8f35c 100644 --- a/src/gui/image/qpixmapcache.cpp +++ b/src/gui/image/qpixmapcache.cpp @@ -176,7 +176,7 @@ bool QPixmapCache::Key::operator ==(const Key &key) const Otherwise, if pixmap was flushed, the key is no longer valid. \since 5.7 */ -bool QPixmapCache::Key::isValid() const Q_DECL_NOTHROW +bool QPixmapCache::Key::isValid() const noexcept { return d && d->isValid; } diff --git a/src/gui/image/qpixmapcache.h b/src/gui/image/qpixmapcache.h index 12d05b00f3..c5bedb27ab 100644 --- a/src/gui/image/qpixmapcache.h +++ b/src/gui/image/qpixmapcache.h @@ -56,8 +56,8 @@ public: Key(); Key(const Key &other); #ifdef Q_COMPILER_RVALUE_REFS - Key(Key &&other) Q_DECL_NOTHROW : d(other.d) { other.d = nullptr; } - Key &operator =(Key &&other) Q_DECL_NOTHROW { swap(other); return *this; } + Key(Key &&other) noexcept : d(other.d) { other.d = nullptr; } + Key &operator =(Key &&other) noexcept { swap(other); return *this; } #endif ~Key(); bool operator ==(const Key &key) const; @@ -65,8 +65,8 @@ public: { return !operator==(key); } Key &operator =(const Key &other); - void swap(Key &other) Q_DECL_NOTHROW { qSwap(d, other.d); } - bool isValid() const Q_DECL_NOTHROW; + void swap(Key &other) noexcept { qSwap(d, other.d); } + bool isValid() const noexcept; private: KeyData *d; diff --git a/src/gui/kernel/qcursor.cpp b/src/gui/kernel/qcursor.cpp index 9e4787589f..1ba8760a9d 100644 --- a/src/gui/kernel/qcursor.cpp +++ b/src/gui/kernel/qcursor.cpp @@ -494,7 +494,7 @@ QCursor::QCursor(Qt::CursorShape shape) \sa operator!=(const QCursor &lhs, const QCursor &rhs) */ -bool operator==(const QCursor &lhs, const QCursor &rhs) Q_DECL_NOTHROW +bool operator==(const QCursor &lhs, const QCursor &rhs) noexcept { if (lhs.d == rhs.d) return true; // Copy or same shape diff --git a/src/gui/kernel/qcursor.h b/src/gui/kernel/qcursor.h index d62ee7a053..ced166dc29 100644 --- a/src/gui/kernel/qcursor.h +++ b/src/gui/kernel/qcursor.h @@ -87,12 +87,12 @@ public: ~QCursor(); QCursor &operator=(const QCursor &cursor); #ifdef Q_COMPILER_RVALUE_REFS - QCursor(QCursor &&other) Q_DECL_NOTHROW : d(other.d) { other.d = nullptr; } - inline QCursor &operator=(QCursor &&other) Q_DECL_NOTHROW + QCursor(QCursor &&other) noexcept : d(other.d) { other.d = nullptr; } + inline QCursor &operator=(QCursor &&other) noexcept { swap(other); return *this; } #endif - void swap(QCursor &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QCursor &other) noexcept { qSwap(d, other.d); } operator QVariant() const; @@ -112,13 +112,13 @@ public: inline static void setPos(QScreen *screen, const QPoint &p) { setPos(screen, p.x(), p.y()); } private: - friend Q_GUI_EXPORT bool operator==(const QCursor &lhs, const QCursor &rhs) Q_DECL_NOTHROW; + friend Q_GUI_EXPORT bool operator==(const QCursor &lhs, const QCursor &rhs) noexcept; QCursorData *d; }; Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QCursor) -Q_GUI_EXPORT bool operator==(const QCursor &lhs, const QCursor &rhs) Q_DECL_NOTHROW; -inline bool operator!=(const QCursor &lhs, const QCursor &rhs) Q_DECL_NOTHROW { return !(lhs == rhs); } +Q_GUI_EXPORT bool operator==(const QCursor &lhs, const QCursor &rhs) noexcept; +inline bool operator!=(const QCursor &lhs, const QCursor &rhs) noexcept { return !(lhs == rhs); } /***************************************************************************** QCursor stream functions diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 7123c4d8ba..f6d1da45e3 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -5426,7 +5426,7 @@ QPointingDeviceUniqueId QPointingDeviceUniqueId::fromNumericId(qint64 id) \sa isValid() */ -qint64 QPointingDeviceUniqueId::numericId() const Q_DECL_NOTHROW +qint64 QPointingDeviceUniqueId::numericId() const noexcept { return m_numericId; } @@ -5438,7 +5438,7 @@ qint64 QPointingDeviceUniqueId::numericId() const Q_DECL_NOTHROW Returns whether the two unique pointer IDs \a lhs and \a rhs identify the same pointer (\c true) or not (\c false). */ -bool operator==(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) Q_DECL_NOTHROW +bool operator==(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) noexcept { return lhs.numericId() == rhs.numericId(); } @@ -5458,7 +5458,7 @@ bool operator==(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) Q_DECL Returns the hash value for \a key, using \a seed to seed the calculation. */ -uint qHash(QPointingDeviceUniqueId key, uint seed) Q_DECL_NOTHROW +uint qHash(QPointingDeviceUniqueId key, uint seed) noexcept { return qHash(key.numericId(), seed); } diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 2b1c6a6e31..de175bc334 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -811,14 +811,14 @@ class Q_GUI_EXPORT QPointingDeviceUniqueId Q_PROPERTY(qint64 numericId READ numericId CONSTANT) public: Q_ALWAYS_INLINE - Q_DECL_CONSTEXPR QPointingDeviceUniqueId() Q_DECL_NOTHROW : m_numericId(-1) {} + Q_DECL_CONSTEXPR QPointingDeviceUniqueId() noexcept : m_numericId(-1) {} // compiler-generated copy/move ctor/assignment operators are ok! // compiler-generated dtor is ok! static QPointingDeviceUniqueId fromNumericId(qint64 id); - Q_ALWAYS_INLINE Q_DECL_CONSTEXPR bool isValid() const Q_DECL_NOTHROW { return m_numericId != -1; } - qint64 numericId() const Q_DECL_NOTHROW; + Q_ALWAYS_INLINE Q_DECL_CONSTEXPR bool isValid() const noexcept { return m_numericId != -1; } + qint64 numericId() const noexcept; private: // TODO: for TUIO 2, or any other type of complex token ID, an internal @@ -829,10 +829,10 @@ private: Q_DECLARE_TYPEINFO(QPointingDeviceUniqueId, Q_MOVABLE_TYPE); template <> class QList {}; // to prevent instantiation: use QVector instead -Q_GUI_EXPORT bool operator==(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) Q_DECL_NOTHROW; -inline bool operator!=(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) Q_DECL_NOTHROW +Q_GUI_EXPORT bool operator==(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) noexcept; +inline bool operator!=(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) noexcept { return !operator==(lhs, rhs); } -Q_GUI_EXPORT uint qHash(QPointingDeviceUniqueId key, uint seed = 0) Q_DECL_NOTHROW; +Q_GUI_EXPORT uint qHash(QPointingDeviceUniqueId key, uint seed = 0) noexcept; @@ -856,10 +856,10 @@ public: explicit TouchPoint(int id = -1); TouchPoint(const TouchPoint &other); #ifdef Q_COMPILER_RVALUE_REFS - TouchPoint(TouchPoint &&other) Q_DECL_NOEXCEPT + TouchPoint(TouchPoint &&other) noexcept : d(nullptr) { qSwap(d, other.d); } - TouchPoint &operator=(TouchPoint &&other) Q_DECL_NOEXCEPT + TouchPoint &operator=(TouchPoint &&other) noexcept { qSwap(d, other.d); return *this; } #endif ~TouchPoint(); @@ -867,7 +867,7 @@ public: TouchPoint &operator=(const TouchPoint &other) { if ( d != other.d ) { TouchPoint copy(other); swap(copy); } return *this; } - void swap(TouchPoint &other) Q_DECL_NOEXCEPT + void swap(TouchPoint &other) noexcept { qSwap(d, other.d); } int id() const; diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index 74bf6e6b47..0fa3dcfbdb 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -1466,7 +1466,7 @@ bool QKeySequence::operator==(const QKeySequence &other) const Calculates the hash value of \a key, using \a seed to seed the calculation. */ -uint qHash(const QKeySequence &key, uint seed) Q_DECL_NOTHROW +uint qHash(const QKeySequence &key, uint seed) noexcept { return qHashRange(key.d->key, key.d->key + QKeySequencePrivate::MaxKeyCount, seed); } diff --git a/src/gui/kernel/qkeysequence.h b/src/gui/kernel/qkeysequence.h index 65f3a93d9c..5630bdda58 100644 --- a/src/gui/kernel/qkeysequence.h +++ b/src/gui/kernel/qkeysequence.h @@ -66,7 +66,7 @@ void qt_set_sequence_auto_mnemonic(bool b); class QVariant; class QKeySequencePrivate; -Q_GUI_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QKeySequence &key, uint seed = 0) Q_DECL_NOTHROW; +Q_GUI_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QKeySequence &key, uint seed = 0) noexcept; class Q_GUI_EXPORT QKeySequence { @@ -187,9 +187,9 @@ public: int operator[](uint i) const; QKeySequence &operator=(const QKeySequence &other); #ifdef Q_COMPILER_RVALUE_REFS - QKeySequence &operator=(QKeySequence &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QKeySequence &operator=(QKeySequence &&other) noexcept { swap(other); return *this; } #endif - void swap(QKeySequence &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QKeySequence &other) noexcept { qSwap(d, other.d); } bool operator==(const QKeySequence &other) const; inline bool operator!= (const QKeySequence &other) const @@ -214,7 +214,7 @@ private: friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QKeySequence &ks); friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QKeySequence &ks); - friend Q_GUI_EXPORT uint qHash(const QKeySequence &key, uint seed) Q_DECL_NOTHROW; + friend Q_GUI_EXPORT uint qHash(const QKeySequence &key, uint seed) noexcept; friend class QShortcutMap; friend class QShortcut; diff --git a/src/gui/kernel/qpalette.h b/src/gui/kernel/qpalette.h index e931e01480..a463245d4d 100644 --- a/src/gui/kernel/qpalette.h +++ b/src/gui/kernel/qpalette.h @@ -68,17 +68,17 @@ public: ~QPalette(); QPalette &operator=(const QPalette &palette); #ifdef Q_COMPILER_RVALUE_REFS - QPalette(QPalette &&other) Q_DECL_NOTHROW + QPalette(QPalette &&other) noexcept : d(other.d), data(other.data) { other.d = nullptr; } - inline QPalette &operator=(QPalette &&other) Q_DECL_NOEXCEPT + inline QPalette &operator=(QPalette &&other) noexcept { for_faster_swapping_dont_use = other.for_faster_swapping_dont_use; qSwap(d, other.d); return *this; } #endif - void swap(QPalette &other) Q_DECL_NOEXCEPT + void swap(QPalette &other) noexcept { qSwap(d, other.d); qSwap(for_faster_swapping_dont_use, other.for_faster_swapping_dont_use); diff --git a/src/gui/kernel/qpixelformat.h b/src/gui/kernel/qpixelformat.h index 6b2d6a6ac7..a041a39fc1 100644 --- a/src/gui/kernel/qpixelformat.h +++ b/src/gui/kernel/qpixelformat.h @@ -95,7 +95,7 @@ class QPixelFormat Q_STATIC_ASSERT(uint(TotalFieldWidthByWidths) == uint(TotalFieldWidthByOffsets)); Q_STATIC_ASSERT(uint(TotalFieldWidthByWidths) == 8 * sizeof(quint64)); - Q_DECL_CONSTEXPR inline uchar get(Field offset, FieldWidth width) const Q_DECL_NOTHROW + Q_DECL_CONSTEXPR inline uchar get(Field offset, FieldWidth width) const noexcept { return uchar((data >> uint(offset)) & ((Q_UINT64_C(1) << uint(width)) - Q_UINT64_C(1))); } Q_DECL_CONSTEXPR static inline quint64 set(Field offset, FieldWidth width, uchar value) { return (quint64(value) & ((Q_UINT64_C(1) << uint(width)) - Q_UINT64_C(1))) << uint(offset); } @@ -160,7 +160,7 @@ public: CurrentSystemEndian }; - Q_DECL_CONSTEXPR inline QPixelFormat() Q_DECL_NOTHROW : data(0) {} + Q_DECL_CONSTEXPR inline QPixelFormat() noexcept : data(0) {} Q_DECL_CONSTEXPR inline QPixelFormat(ColorModel colorModel, uchar firstSize, uchar secondSize, @@ -173,47 +173,47 @@ public: AlphaPremultiplied premultiplied, TypeInterpretation typeInterpretation, ByteOrder byteOrder = CurrentSystemEndian, - uchar subEnum = 0) Q_DECL_NOTHROW; + uchar subEnum = 0) noexcept; - Q_DECL_CONSTEXPR inline ColorModel colorModel() const Q_DECL_NOTHROW { return ColorModel(get(ModelField, ModelFieldWidth)); } - Q_DECL_CONSTEXPR inline uchar channelCount() const Q_DECL_NOTHROW { return (get(FirstField, FirstFieldWidth) > 0) + + Q_DECL_CONSTEXPR inline ColorModel colorModel() const noexcept { return ColorModel(get(ModelField, ModelFieldWidth)); } + Q_DECL_CONSTEXPR inline uchar channelCount() const noexcept { return (get(FirstField, FirstFieldWidth) > 0) + (get(SecondField, SecondFieldWidth) > 0) + (get(ThirdField, ThirdFieldWidth) > 0) + (get(FourthField, FourthFieldWidth) > 0) + (get(FifthField, FifthFieldWidth) > 0) + (get(AlphaField, AlphaFieldWidth) > 0); } - Q_DECL_CONSTEXPR inline uchar redSize() const Q_DECL_NOTHROW { return get(FirstField, FirstFieldWidth); } - Q_DECL_CONSTEXPR inline uchar greenSize() const Q_DECL_NOTHROW { return get(SecondField, SecondFieldWidth); } - Q_DECL_CONSTEXPR inline uchar blueSize() const Q_DECL_NOTHROW { return get(ThirdField, ThirdFieldWidth); } + Q_DECL_CONSTEXPR inline uchar redSize() const noexcept { return get(FirstField, FirstFieldWidth); } + Q_DECL_CONSTEXPR inline uchar greenSize() const noexcept { return get(SecondField, SecondFieldWidth); } + Q_DECL_CONSTEXPR inline uchar blueSize() const noexcept { return get(ThirdField, ThirdFieldWidth); } - Q_DECL_CONSTEXPR inline uchar cyanSize() const Q_DECL_NOTHROW { return get(FirstField, FirstFieldWidth); } - Q_DECL_CONSTEXPR inline uchar magentaSize() const Q_DECL_NOTHROW { return get(SecondField, SecondFieldWidth); } - Q_DECL_CONSTEXPR inline uchar yellowSize() const Q_DECL_NOTHROW { return get(ThirdField, ThirdFieldWidth); } - Q_DECL_CONSTEXPR inline uchar blackSize() const Q_DECL_NOTHROW { return get(FourthField, FourthFieldWidth); } + Q_DECL_CONSTEXPR inline uchar cyanSize() const noexcept { return get(FirstField, FirstFieldWidth); } + Q_DECL_CONSTEXPR inline uchar magentaSize() const noexcept { return get(SecondField, SecondFieldWidth); } + Q_DECL_CONSTEXPR inline uchar yellowSize() const noexcept { return get(ThirdField, ThirdFieldWidth); } + Q_DECL_CONSTEXPR inline uchar blackSize() const noexcept { return get(FourthField, FourthFieldWidth); } - Q_DECL_CONSTEXPR inline uchar hueSize() const Q_DECL_NOTHROW { return get(FirstField, FirstFieldWidth); } - Q_DECL_CONSTEXPR inline uchar saturationSize() const Q_DECL_NOTHROW { return get(SecondField, SecondFieldWidth); } - Q_DECL_CONSTEXPR inline uchar lightnessSize() const Q_DECL_NOTHROW { return get(ThirdField, ThirdFieldWidth); } - Q_DECL_CONSTEXPR inline uchar brightnessSize() const Q_DECL_NOTHROW { return get(ThirdField, ThirdFieldWidth); } + Q_DECL_CONSTEXPR inline uchar hueSize() const noexcept { return get(FirstField, FirstFieldWidth); } + Q_DECL_CONSTEXPR inline uchar saturationSize() const noexcept { return get(SecondField, SecondFieldWidth); } + Q_DECL_CONSTEXPR inline uchar lightnessSize() const noexcept { return get(ThirdField, ThirdFieldWidth); } + Q_DECL_CONSTEXPR inline uchar brightnessSize() const noexcept { return get(ThirdField, ThirdFieldWidth); } - Q_DECL_CONSTEXPR inline uchar alphaSize() const Q_DECL_NOTHROW { return get(AlphaField, AlphaFieldWidth); } + Q_DECL_CONSTEXPR inline uchar alphaSize() const noexcept { return get(AlphaField, AlphaFieldWidth); } - Q_DECL_CONSTEXPR inline uchar bitsPerPixel() const Q_DECL_NOTHROW { return get(FirstField, FirstFieldWidth) + + Q_DECL_CONSTEXPR inline uchar bitsPerPixel() const noexcept { return get(FirstField, FirstFieldWidth) + get(SecondField, SecondFieldWidth) + get(ThirdField, ThirdFieldWidth) + get(FourthField, FourthFieldWidth) + get(FifthField, FifthFieldWidth) + get(AlphaField, AlphaFieldWidth); } - Q_DECL_CONSTEXPR inline AlphaUsage alphaUsage() const Q_DECL_NOTHROW { return AlphaUsage(get(AlphaUsageField, AlphaUsageFieldWidth)); } - Q_DECL_CONSTEXPR inline AlphaPosition alphaPosition() const Q_DECL_NOTHROW { return AlphaPosition(get(AlphaPositionField, AlphaPositionFieldWidth)); } - Q_DECL_CONSTEXPR inline AlphaPremultiplied premultiplied() const Q_DECL_NOTHROW { return AlphaPremultiplied(get(PremulField, PremulFieldWidth)); } - Q_DECL_CONSTEXPR inline TypeInterpretation typeInterpretation() const Q_DECL_NOTHROW { return TypeInterpretation(get(TypeInterpretationField, TypeInterpretationFieldWidth)); } - Q_DECL_CONSTEXPR inline ByteOrder byteOrder() const Q_DECL_NOTHROW { return ByteOrder(get(ByteOrderField, ByteOrderFieldWidth)); } + Q_DECL_CONSTEXPR inline AlphaUsage alphaUsage() const noexcept { return AlphaUsage(get(AlphaUsageField, AlphaUsageFieldWidth)); } + Q_DECL_CONSTEXPR inline AlphaPosition alphaPosition() const noexcept { return AlphaPosition(get(AlphaPositionField, AlphaPositionFieldWidth)); } + Q_DECL_CONSTEXPR inline AlphaPremultiplied premultiplied() const noexcept { return AlphaPremultiplied(get(PremulField, PremulFieldWidth)); } + Q_DECL_CONSTEXPR inline TypeInterpretation typeInterpretation() const noexcept { return TypeInterpretation(get(TypeInterpretationField, TypeInterpretationFieldWidth)); } + Q_DECL_CONSTEXPR inline ByteOrder byteOrder() const noexcept { return ByteOrder(get(ByteOrderField, ByteOrderFieldWidth)); } - Q_DECL_CONSTEXPR inline YUVLayout yuvLayout() const Q_DECL_NOTHROW { return YUVLayout(get(SubEnumField, SubEnumFieldWidth)); } - Q_DECL_CONSTEXPR inline uchar subEnum() const Q_DECL_NOTHROW { return get(SubEnumField, SubEnumFieldWidth); } + Q_DECL_CONSTEXPR inline YUVLayout yuvLayout() const noexcept { return YUVLayout(get(SubEnumField, SubEnumFieldWidth)); } + Q_DECL_CONSTEXPR inline uchar subEnum() const noexcept { return get(SubEnumField, SubEnumFieldWidth); } private: Q_DECL_CONSTEXPR static inline ByteOrder resolveByteOrder(ByteOrder bo) @@ -255,7 +255,7 @@ QPixelFormat::QPixelFormat(ColorModel mdl, AlphaPremultiplied premult, TypeInterpretation typeInterp, ByteOrder b_order, - uchar s_enum) Q_DECL_NOTHROW + uchar s_enum) noexcept : data(set(ModelField, ModelFieldWidth, uchar(mdl)) | set(FirstField, FirstFieldWidth, firstSize) | set(SecondField, SecondFieldWidth, secondSize) | @@ -280,7 +280,7 @@ Q_DECL_CONSTEXPR inline QPixelFormat qPixelFormatRgba(uchar red, QPixelFormat::AlphaUsage usage, QPixelFormat::AlphaPosition position, QPixelFormat::AlphaPremultiplied pmul=QPixelFormat::NotPremultiplied, - QPixelFormat::TypeInterpretation typeInt=QPixelFormat::UnsignedInteger) Q_DECL_NOTHROW + QPixelFormat::TypeInterpretation typeInt=QPixelFormat::UnsignedInteger) noexcept { return QPixelFormat(QPixelFormat::RGB, red, @@ -296,7 +296,7 @@ Q_DECL_CONSTEXPR inline QPixelFormat qPixelFormatRgba(uchar red, } Q_DECL_CONSTEXPR inline QPixelFormat qPixelFormatGrayscale(uchar channelSize, - QPixelFormat::TypeInterpretation typeInt=QPixelFormat::UnsignedInteger) Q_DECL_NOTHROW + QPixelFormat::TypeInterpretation typeInt=QPixelFormat::UnsignedInteger) noexcept { return QPixelFormat(QPixelFormat::Grayscale, channelSize, @@ -312,7 +312,7 @@ Q_DECL_CONSTEXPR inline QPixelFormat qPixelFormatGrayscale(uchar channelSize, } Q_DECL_CONSTEXPR inline QPixelFormat qPixelFormatAlpha(uchar channelSize, - QPixelFormat::TypeInterpretation typeInt=QPixelFormat::UnsignedInteger) Q_DECL_NOTHROW + QPixelFormat::TypeInterpretation typeInt=QPixelFormat::UnsignedInteger) noexcept { return QPixelFormat(QPixelFormat::Alpha, 0, @@ -331,7 +331,7 @@ Q_DECL_CONSTEXPR inline QPixelFormat qPixelFormatCmyk(uchar channelSize, uchar alfa=0, QPixelFormat::AlphaUsage usage=QPixelFormat::IgnoresAlpha, QPixelFormat::AlphaPosition position=QPixelFormat::AtBeginning, - QPixelFormat::TypeInterpretation typeInt=QPixelFormat::UnsignedInteger) Q_DECL_NOTHROW + QPixelFormat::TypeInterpretation typeInt=QPixelFormat::UnsignedInteger) noexcept { return QPixelFormat(QPixelFormat::CMYK, channelSize, @@ -350,7 +350,7 @@ Q_DECL_CONSTEXPR inline QPixelFormat qPixelFormatHsl(uchar channelSize, uchar alfa=0, QPixelFormat::AlphaUsage usage=QPixelFormat::IgnoresAlpha, QPixelFormat::AlphaPosition position=QPixelFormat::AtBeginning, - QPixelFormat::TypeInterpretation typeInt=QPixelFormat::FloatingPoint) Q_DECL_NOTHROW + QPixelFormat::TypeInterpretation typeInt=QPixelFormat::FloatingPoint) noexcept { return QPixelFormat(QPixelFormat::HSL, channelSize, @@ -369,7 +369,7 @@ Q_DECL_CONSTEXPR inline QPixelFormat qPixelFormatHsv(uchar channelSize, uchar alfa=0, QPixelFormat::AlphaUsage usage=QPixelFormat::IgnoresAlpha, QPixelFormat::AlphaPosition position=QPixelFormat::AtBeginning, - QPixelFormat::TypeInterpretation typeInt=QPixelFormat::FloatingPoint) Q_DECL_NOTHROW + QPixelFormat::TypeInterpretation typeInt=QPixelFormat::FloatingPoint) noexcept { return QPixelFormat(QPixelFormat::HSV, channelSize, diff --git a/src/gui/opengl/qopengldebug.h b/src/gui/opengl/qopengldebug.h index 556ec175e1..1ba3ef91ac 100644 --- a/src/gui/opengl/qopengldebug.h +++ b/src/gui/opengl/qopengldebug.h @@ -111,11 +111,11 @@ public: QOpenGLDebugMessage &operator=(const QOpenGLDebugMessage &debugMessage); #ifdef Q_COMPILER_RVALUE_REFS - QOpenGLDebugMessage &operator=(QOpenGLDebugMessage &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QOpenGLDebugMessage &operator=(QOpenGLDebugMessage &&other) noexcept { swap(other); return *this; } #endif ~QOpenGLDebugMessage(); - void swap(QOpenGLDebugMessage &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QOpenGLDebugMessage &other) noexcept { qSwap(d, other.d); } Source source() const; Type type() const; diff --git a/src/gui/opengl/qopenglpixeltransferoptions.h b/src/gui/opengl/qopenglpixeltransferoptions.h index 2fc52b82d8..be60e66e71 100644 --- a/src/gui/opengl/qopenglpixeltransferoptions.h +++ b/src/gui/opengl/qopenglpixeltransferoptions.h @@ -56,13 +56,13 @@ public: QOpenGLPixelTransferOptions(); QOpenGLPixelTransferOptions(const QOpenGLPixelTransferOptions &); #ifdef Q_COMPILER_RVALUE_REFS - QOpenGLPixelTransferOptions &operator=(QOpenGLPixelTransferOptions &&other) Q_DECL_NOTHROW + QOpenGLPixelTransferOptions &operator=(QOpenGLPixelTransferOptions &&other) noexcept { swap(other); return *this; } #endif QOpenGLPixelTransferOptions &operator=(const QOpenGLPixelTransferOptions &); ~QOpenGLPixelTransferOptions(); - void swap(QOpenGLPixelTransferOptions &other) Q_DECL_NOTHROW + void swap(QOpenGLPixelTransferOptions &other) noexcept { data.swap(other.data); } void setAlignment(int alignment); diff --git a/src/gui/opengl/qopenglversionfunctions.h b/src/gui/opengl/qopenglversionfunctions.h index f828e5668b..aa6e49b9ae 100644 --- a/src/gui/opengl/qopenglversionfunctions.h +++ b/src/gui/opengl/qopenglversionfunctions.h @@ -97,7 +97,7 @@ struct QOpenGLVersionStatus OpenGLStatus status; }; -inline uint qHash(const QOpenGLVersionStatus &v, uint seed = 0) Q_DECL_NOTHROW +inline uint qHash(const QOpenGLVersionStatus &v, uint seed = 0) noexcept { return qHash(static_cast(v.status * 1000) + v.version.first * 100 + v.version.second * 10, seed); diff --git a/src/gui/painting/qbrush.h b/src/gui/painting/qbrush.h index aee51c526d..27d710eca6 100644 --- a/src/gui/painting/qbrush.h +++ b/src/gui/painting/qbrush.h @@ -80,10 +80,10 @@ public: ~QBrush(); QBrush &operator=(const QBrush &brush); #ifdef Q_COMPILER_RVALUE_REFS - inline QBrush &operator=(QBrush &&other) Q_DECL_NOEXCEPT + inline QBrush &operator=(QBrush &&other) noexcept { qSwap(d, other.d); return *this; } #endif - inline void swap(QBrush &other) Q_DECL_NOEXCEPT + inline void swap(QBrush &other) noexcept { qSwap(d, other.d); } operator QVariant() const; diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 07202f5b1c..bb42660cf2 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -653,7 +653,7 @@ static QStringList get_colornames() \sa isValid(), {QColor#Predefined Colors}{Predefined Colors} */ -QColor::QColor(Qt::GlobalColor color) Q_DECL_NOTHROW +QColor::QColor(Qt::GlobalColor color) noexcept { #define QRGB(r, g, b) \ QRgb(((0xffu << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff))) @@ -728,7 +728,7 @@ QColor::QColor(Qt::GlobalColor color) Q_DECL_NOTHROW \sa fromRgb(), isValid() */ -QColor::QColor(QRgb color) Q_DECL_NOTHROW +QColor::QColor(QRgb color) noexcept { cspec = Rgb; ct.argb.alpha = 0xffff; @@ -746,7 +746,7 @@ QColor::QColor(QRgb color) Q_DECL_NOTHROW \sa fromRgba64() */ -QColor::QColor(QRgba64 rgba64) Q_DECL_NOTHROW +QColor::QColor(QRgba64 rgba64) noexcept { setRgba64(rgba64); } @@ -760,7 +760,7 @@ QColor::QColor(QRgba64 rgba64) Q_DECL_NOTHROW becomes a valid color by accident. */ -QColor::QColor(Spec spec) Q_DECL_NOTHROW +QColor::QColor(Spec spec) noexcept { switch (spec) { case Invalid: @@ -933,7 +933,7 @@ bool QColor::isValidColor(const QString &name) \overload \since 5.10 */ -bool QColor::isValidColor(QStringView name) Q_DECL_NOTHROW +bool QColor::isValidColor(QStringView name) noexcept { return name.size() && QColor().setColorFromString(name); } @@ -942,7 +942,7 @@ bool QColor::isValidColor(QStringView name) Q_DECL_NOTHROW \overload \since 5.8 */ -bool QColor::isValidColor(QLatin1String name) Q_DECL_NOTHROW +bool QColor::isValidColor(QLatin1String name) noexcept { return name.size() && QColor().setColorFromString(name); } @@ -1330,7 +1330,7 @@ void QColor::setRgb(int r, int g, int b, int a) \sa setRgba(), rgb(), rgba64() */ -QRgb QColor::rgba() const Q_DECL_NOTHROW +QRgb QColor::rgba() const noexcept { if (cspec != Invalid && cspec != Rgb) return toRgb().rgba(); @@ -1342,7 +1342,7 @@ QRgb QColor::rgba() const Q_DECL_NOTHROW \sa rgba(), rgb(), setRgba64() */ -void QColor::setRgba(QRgb rgba) Q_DECL_NOTHROW +void QColor::setRgba(QRgb rgba) noexcept { cspec = Rgb; ct.argb.alpha = qAlpha(rgba) * 0x101; @@ -1362,7 +1362,7 @@ void QColor::setRgba(QRgb rgba) Q_DECL_NOTHROW \sa setRgba64(), rgba(), rgb() */ -QRgba64 QColor::rgba64() const Q_DECL_NOTHROW +QRgba64 QColor::rgba64() const noexcept { if (cspec != Invalid && cspec != Rgb) return toRgb().rgba64(); @@ -1376,7 +1376,7 @@ QRgba64 QColor::rgba64() const Q_DECL_NOTHROW \sa setRgba(), rgba64() */ -void QColor::setRgba64(QRgba64 rgba) Q_DECL_NOTHROW +void QColor::setRgba64(QRgba64 rgba) noexcept { cspec = Rgb; ct.argb.alpha = rgba.alpha(); @@ -1393,7 +1393,7 @@ void QColor::setRgba64(QRgba64 rgba) Q_DECL_NOTHROW \sa getRgb(), rgba() */ -QRgb QColor::rgb() const Q_DECL_NOTHROW +QRgb QColor::rgb() const noexcept { if (cspec != Invalid && cspec != Rgb) return toRgb().rgb(); @@ -1405,7 +1405,7 @@ QRgb QColor::rgb() const Q_DECL_NOTHROW Sets the RGB value to \a rgb. The alpha value is set to opaque. */ -void QColor::setRgb(QRgb rgb) Q_DECL_NOTHROW +void QColor::setRgb(QRgb rgb) noexcept { cspec = Rgb; ct.argb.alpha = 0xffff; @@ -1420,7 +1420,7 @@ void QColor::setRgb(QRgb rgb) Q_DECL_NOTHROW \sa setAlpha(), alphaF(), {QColor#Alpha-Blended Drawing}{Alpha-Blended Drawing} */ -int QColor::alpha() const Q_DECL_NOTHROW +int QColor::alpha() const noexcept { return ct.argb.alpha >> 8; } @@ -1442,7 +1442,7 @@ void QColor::setAlpha(int alpha) \sa setAlphaF(), alpha(), {QColor#Alpha-Blended Drawing}{Alpha-Blended Drawing} */ -qreal QColor::alphaF() const Q_DECL_NOTHROW +qreal QColor::alphaF() const noexcept { return ct.argb.alpha / qreal(USHRT_MAX); } /*! @@ -1465,7 +1465,7 @@ void QColor::setAlphaF(qreal alpha) \sa setRed(), redF(), getRgb() */ -int QColor::red() const Q_DECL_NOTHROW +int QColor::red() const noexcept { if (cspec != Invalid && cspec != Rgb) return toRgb().red(); @@ -1492,7 +1492,7 @@ void QColor::setRed(int red) \sa setGreen(), greenF(), getRgb() */ -int QColor::green() const Q_DECL_NOTHROW +int QColor::green() const noexcept { if (cspec != Invalid && cspec != Rgb) return toRgb().green(); @@ -1520,7 +1520,7 @@ void QColor::setGreen(int green) \sa setBlue(), blueF(), getRgb() */ -int QColor::blue() const Q_DECL_NOTHROW +int QColor::blue() const noexcept { if (cspec != Invalid && cspec != Rgb) return toRgb().blue(); @@ -1548,7 +1548,7 @@ void QColor::setBlue(int blue) \sa setRedF(), red(), getRgbF() */ -qreal QColor::redF() const Q_DECL_NOTHROW +qreal QColor::redF() const noexcept { if (cspec != Invalid && cspec != Rgb) return toRgb().redF(); @@ -1576,7 +1576,7 @@ void QColor::setRedF(qreal red) \sa setGreenF(), green(), getRgbF() */ -qreal QColor::greenF() const Q_DECL_NOTHROW +qreal QColor::greenF() const noexcept { if (cspec != Invalid && cspec != Rgb) return toRgb().greenF(); @@ -1604,7 +1604,7 @@ void QColor::setGreenF(qreal green) \sa setBlueF(), blue(), getRgbF() */ -qreal QColor::blueF() const Q_DECL_NOTHROW +qreal QColor::blueF() const noexcept { if (cspec != Invalid && cspec != Rgb) return toRgb().blueF(); @@ -1634,7 +1634,7 @@ void QColor::setBlueF(qreal blue) \sa hsvHue(), hslHue(), hueF(), getHsv(), {QColor#The HSV Color Model}{The HSV Color Model} */ -int QColor::hue() const Q_DECL_NOTHROW +int QColor::hue() const noexcept { return hsvHue(); } @@ -1644,7 +1644,7 @@ int QColor::hue() const Q_DECL_NOTHROW \sa hueF(), hslHue(), getHsv(), {QColor#The HSV Color Model}{The HSV Color Model} */ -int QColor::hsvHue() const Q_DECL_NOTHROW +int QColor::hsvHue() const noexcept { if (cspec != Invalid && cspec != Hsv) return toHsv().hue(); @@ -1660,7 +1660,7 @@ int QColor::hsvHue() const Q_DECL_NOTHROW Model} */ -int QColor::saturation() const Q_DECL_NOTHROW +int QColor::saturation() const noexcept { return hsvSaturation(); } @@ -1670,7 +1670,7 @@ int QColor::saturation() const Q_DECL_NOTHROW \sa saturationF(), hslSaturation(), getHsv(), {QColor#The HSV Color Model}{The HSV Color Model} */ -int QColor::hsvSaturation() const Q_DECL_NOTHROW +int QColor::hsvSaturation() const noexcept { if (cspec != Invalid && cspec != Hsv) return toHsv().saturation(); @@ -1682,7 +1682,7 @@ int QColor::hsvSaturation() const Q_DECL_NOTHROW \sa valueF(), getHsv(), {QColor#The HSV Color Model}{The HSV Color Model} */ -int QColor::value() const Q_DECL_NOTHROW +int QColor::value() const noexcept { if (cspec != Invalid && cspec != Hsv) return toHsv().value(); @@ -1696,7 +1696,7 @@ int QColor::value() const Q_DECL_NOTHROW \sa hsvHueF(), hslHueF(), hue(), getHsvF(), {QColor#The HSV Color Model}{The HSV Color Model} */ -qreal QColor::hueF() const Q_DECL_NOTHROW +qreal QColor::hueF() const noexcept { return hsvHueF(); } @@ -1707,7 +1707,7 @@ qreal QColor::hueF() const Q_DECL_NOTHROW \sa hue(), hslHueF(), getHsvF(), {QColor#The HSV Color Model}{The HSV Color Model} */ -qreal QColor::hsvHueF() const Q_DECL_NOTHROW +qreal QColor::hsvHueF() const noexcept { if (cspec != Invalid && cspec != Hsv) return toHsv().hueF(); @@ -1722,7 +1722,7 @@ qreal QColor::hsvHueF() const Q_DECL_NOTHROW \sa hsvSaturationF(), hslSaturationF(), saturation(), getHsvF(), {QColor#The HSV Color Model}{The HSV Color Model} */ -qreal QColor::saturationF() const Q_DECL_NOTHROW +qreal QColor::saturationF() const noexcept { return hsvSaturationF(); } @@ -1732,7 +1732,7 @@ qreal QColor::saturationF() const Q_DECL_NOTHROW \sa saturation(), hslSaturationF(), getHsvF(), {QColor#The HSV Color Model}{The HSV Color Model} */ -qreal QColor::hsvSaturationF() const Q_DECL_NOTHROW +qreal QColor::hsvSaturationF() const noexcept { if (cspec != Invalid && cspec != Hsv) return toHsv().saturationF(); @@ -1744,7 +1744,7 @@ qreal QColor::hsvSaturationF() const Q_DECL_NOTHROW \sa value(), getHsvF(), {QColor#The HSV Color Model}{The HSV Color Model} */ -qreal QColor::valueF() const Q_DECL_NOTHROW +qreal QColor::valueF() const noexcept { if (cspec != Invalid && cspec != Hsv) return toHsv().valueF(); @@ -1758,7 +1758,7 @@ qreal QColor::valueF() const Q_DECL_NOTHROW \sa hslHueF(), hsvHue(), getHsl(), {QColor#The HSL Color Model}{The HSL Color Model} */ -int QColor::hslHue() const Q_DECL_NOTHROW +int QColor::hslHue() const noexcept { if (cspec != Invalid && cspec != Hsl) return toHsl().hslHue(); @@ -1772,7 +1772,7 @@ int QColor::hslHue() const Q_DECL_NOTHROW \sa hslSaturationF(), hsvSaturation(), getHsl(), {QColor#The HSL Color Model}{The HSL Color Model} */ -int QColor::hslSaturation() const Q_DECL_NOTHROW +int QColor::hslSaturation() const noexcept { if (cspec != Invalid && cspec != Hsl) return toHsl().hslSaturation(); @@ -1786,7 +1786,7 @@ int QColor::hslSaturation() const Q_DECL_NOTHROW \sa lightnessF(), getHsl() */ -int QColor::lightness() const Q_DECL_NOTHROW +int QColor::lightness() const noexcept { if (cspec != Invalid && cspec != Hsl) return toHsl().lightness(); @@ -1800,7 +1800,7 @@ int QColor::lightness() const Q_DECL_NOTHROW \sa hslHue(), hsvHueF(), getHslF() */ -qreal QColor::hslHueF() const Q_DECL_NOTHROW +qreal QColor::hslHueF() const noexcept { if (cspec != Invalid && cspec != Hsl) return toHsl().hslHueF(); @@ -1814,7 +1814,7 @@ qreal QColor::hslHueF() const Q_DECL_NOTHROW \sa hslSaturation(), hsvSaturationF(), getHslF(), {QColor#The HSL Color Model}{The HSL Color Model} */ -qreal QColor::hslSaturationF() const Q_DECL_NOTHROW +qreal QColor::hslSaturationF() const noexcept { if (cspec != Invalid && cspec != Hsl) return toHsl().hslSaturationF(); @@ -1828,7 +1828,7 @@ qreal QColor::hslSaturationF() const Q_DECL_NOTHROW \sa value(), getHslF() */ -qreal QColor::lightnessF() const Q_DECL_NOTHROW +qreal QColor::lightnessF() const noexcept { if (cspec != Invalid && cspec != Hsl) return toHsl().lightnessF(); @@ -1840,7 +1840,7 @@ qreal QColor::lightnessF() const Q_DECL_NOTHROW \sa cyanF(), getCmyk(), {QColor#The CMYK Color Model}{The CMYK Color Model} */ -int QColor::cyan() const Q_DECL_NOTHROW +int QColor::cyan() const noexcept { if (cspec != Invalid && cspec != Cmyk) return toCmyk().cyan(); @@ -1852,7 +1852,7 @@ int QColor::cyan() const Q_DECL_NOTHROW \sa magentaF(), getCmyk(), {QColor#The CMYK Color Model}{The CMYK Color Model} */ -int QColor::magenta() const Q_DECL_NOTHROW +int QColor::magenta() const noexcept { if (cspec != Invalid && cspec != Cmyk) return toCmyk().magenta(); @@ -1864,7 +1864,7 @@ int QColor::magenta() const Q_DECL_NOTHROW \sa yellowF(), getCmyk(), {QColor#The CMYK Color Model}{The CMYK Color Model} */ -int QColor::yellow() const Q_DECL_NOTHROW +int QColor::yellow() const noexcept { if (cspec != Invalid && cspec != Cmyk) return toCmyk().yellow(); @@ -1877,7 +1877,7 @@ int QColor::yellow() const Q_DECL_NOTHROW \sa blackF(), getCmyk(), {QColor#The CMYK Color Model}{The CMYK Color Model} */ -int QColor::black() const Q_DECL_NOTHROW +int QColor::black() const noexcept { if (cspec != Invalid && cspec != Cmyk) return toCmyk().black(); @@ -1889,7 +1889,7 @@ int QColor::black() const Q_DECL_NOTHROW \sa cyan(), getCmykF(), {QColor#The CMYK Color Model}{The CMYK Color Model} */ -qreal QColor::cyanF() const Q_DECL_NOTHROW +qreal QColor::cyanF() const noexcept { if (cspec != Invalid && cspec != Cmyk) return toCmyk().cyanF(); @@ -1901,7 +1901,7 @@ qreal QColor::cyanF() const Q_DECL_NOTHROW \sa magenta(), getCmykF(), {QColor#The CMYK Color Model}{The CMYK Color Model} */ -qreal QColor::magentaF() const Q_DECL_NOTHROW +qreal QColor::magentaF() const noexcept { if (cspec != Invalid && cspec != Cmyk) return toCmyk().magentaF(); @@ -1913,7 +1913,7 @@ qreal QColor::magentaF() const Q_DECL_NOTHROW \sa yellow(), getCmykF(), {QColor#The CMYK Color Model}{The CMYK Color Model} */ -qreal QColor::yellowF() const Q_DECL_NOTHROW +qreal QColor::yellowF() const noexcept { if (cspec != Invalid && cspec != Cmyk) return toCmyk().yellowF(); @@ -1925,7 +1925,7 @@ qreal QColor::yellowF() const Q_DECL_NOTHROW \sa black(), getCmykF(), {QColor#The CMYK Color Model}{The CMYK Color Model} */ -qreal QColor::blackF() const Q_DECL_NOTHROW +qreal QColor::blackF() const noexcept { if (cspec != Invalid && cspec != Cmyk) return toCmyk().blackF(); @@ -1937,7 +1937,7 @@ qreal QColor::blackF() const Q_DECL_NOTHROW \sa fromRgb(), convertTo(), isValid() */ -QColor QColor::toRgb() const Q_DECL_NOTHROW +QColor QColor::toRgb() const noexcept { if (!isValid() || cspec == Rgb) return *this; @@ -2083,7 +2083,7 @@ QColor QColor::toRgb() const Q_DECL_NOTHROW \sa fromHsv(), convertTo(), isValid(), {QColor#The HSV Color Model}{The HSV Color Model} */ -QColor QColor::toHsv() const Q_DECL_NOTHROW +QColor QColor::toHsv() const noexcept { if (!isValid() || cspec == Hsv) return *this; @@ -2134,7 +2134,7 @@ QColor QColor::toHsv() const Q_DECL_NOTHROW \sa fromHsl(), convertTo(), isValid(), {QColor#The HSL Color Model}{The HSL Color Model} */ -QColor QColor::toHsl() const Q_DECL_NOTHROW +QColor QColor::toHsl() const noexcept { if (!isValid() || cspec == Hsl) return *this; @@ -2190,7 +2190,7 @@ QColor QColor::toHsl() const Q_DECL_NOTHROW \sa fromCmyk(), convertTo(), isValid(), {QColor#The CMYK Color Model}{The CMYK Color Model} */ -QColor QColor::toCmyk() const Q_DECL_NOTHROW +QColor QColor::toCmyk() const noexcept { if (!isValid() || cspec == Cmyk) return *this; @@ -2231,7 +2231,7 @@ QColor QColor::toCmyk() const Q_DECL_NOTHROW return color; } -QColor QColor::convertTo(QColor::Spec colorSpec) const Q_DECL_NOTHROW +QColor QColor::convertTo(QColor::Spec colorSpec) const noexcept { if (colorSpec == cspec) return *this; @@ -2262,7 +2262,7 @@ QColor QColor::convertTo(QColor::Spec colorSpec) const Q_DECL_NOTHROW \sa fromRgba(), fromRgbF(), toRgb(), isValid() */ -QColor QColor::fromRgb(QRgb rgb) Q_DECL_NOTHROW +QColor QColor::fromRgb(QRgb rgb) noexcept { return fromRgb(qRed(rgb), qGreen(rgb), qBlue(rgb)); } @@ -2278,7 +2278,7 @@ QColor QColor::fromRgb(QRgb rgb) Q_DECL_NOTHROW \sa fromRgb(), fromRgba64(), isValid() */ -QColor QColor::fromRgba(QRgb rgba) Q_DECL_NOTHROW +QColor QColor::fromRgba(QRgb rgba) noexcept { return fromRgb(qRed(rgba), qGreen(rgba), qBlue(rgba), qAlpha(rgba)); } @@ -2351,7 +2351,7 @@ QColor QColor::fromRgbF(qreal r, qreal g, qreal b, qreal a) \sa fromRgb(), fromRgbF(), toRgb(), isValid() */ -QColor QColor::fromRgba64(ushort r, ushort g, ushort b, ushort a) Q_DECL_NOTHROW +QColor QColor::fromRgba64(ushort r, ushort g, ushort b, ushort a) noexcept { QColor color; color.setRgba64(qRgba64(r, g, b, a)); @@ -2366,7 +2366,7 @@ QColor QColor::fromRgba64(ushort r, ushort g, ushort b, ushort a) Q_DECL_NOTHROW \sa fromRgb(), fromRgbF(), toRgb(), isValid() */ -QColor QColor::fromRgba64(QRgba64 rgba64) Q_DECL_NOTHROW +QColor QColor::fromRgba64(QRgba64 rgba64) noexcept { QColor color; color.setRgba64(rgba64); @@ -2714,7 +2714,7 @@ QColor QColor::fromCmykF(qreal c, qreal m, qreal y, qreal k, qreal a) \sa darker(), isValid() */ -QColor QColor::lighter(int factor) const Q_DECL_NOTHROW +QColor QColor::lighter(int factor) const noexcept { if (factor <= 0) // invalid lightness factor return *this; @@ -2759,7 +2759,7 @@ QColor QColor::lighter(int factor) const Q_DECL_NOTHROW \sa lighter(), isValid() */ -QColor QColor::darker(int factor) const Q_DECL_NOTHROW +QColor QColor::darker(int factor) const noexcept { if (factor <= 0) // invalid darkness factor return *this; @@ -2779,7 +2779,7 @@ QColor QColor::darker(int factor) const Q_DECL_NOTHROW Use lighter(\a factor) instead. */ -QColor QColor::light(int factor) const Q_DECL_NOTHROW +QColor QColor::light(int factor) const noexcept { return lighter(factor); } @@ -2789,7 +2789,7 @@ QColor QColor::light(int factor) const Q_DECL_NOTHROW Use darker(\a factor) instead. */ -QColor QColor::dark(int factor) const Q_DECL_NOTHROW +QColor QColor::dark(int factor) const noexcept { return darker(factor); } @@ -2799,7 +2799,7 @@ QColor QColor::dark(int factor) const Q_DECL_NOTHROW /*! Assigns a copy of \a color to this color, and returns a reference to it. */ -QColor &QColor::operator=(const QColor &color) Q_DECL_NOTHROW +QColor &QColor::operator=(const QColor &color) noexcept { cspec = color.cspec; ct.argb = color.ct.argb; @@ -2810,7 +2810,7 @@ QColor &QColor::operator=(const QColor &color) Q_DECL_NOTHROW /*! \overload Assigns a copy of \a color and returns a reference to this color. */ -QColor &QColor::operator=(Qt::GlobalColor color) Q_DECL_NOTHROW +QColor &QColor::operator=(Qt::GlobalColor color) noexcept { return operator=(QColor(color)); } @@ -2819,7 +2819,7 @@ QColor &QColor::operator=(Qt::GlobalColor color) Q_DECL_NOTHROW Returns \c true if this color has the same RGB and alpha values as \a color; otherwise returns \c false. */ -bool QColor::operator==(const QColor &color) const Q_DECL_NOTHROW +bool QColor::operator==(const QColor &color) const noexcept { if (cspec == Hsl && cspec == color.cspec) { return (ct.argb.alpha == color.ct.argb.alpha @@ -2846,7 +2846,7 @@ bool QColor::operator==(const QColor &color) const Q_DECL_NOTHROW Returns \c true if this color has a different RGB and alpha values from \a color; otherwise returns \c false. */ -bool QColor::operator!=(const QColor &color) const Q_DECL_NOTHROW +bool QColor::operator!=(const QColor &color) const noexcept { return !operator==(color); } @@ -2863,7 +2863,7 @@ QColor::operator QVariant() const Marks the color as invalid and sets all components to zero (alpha is set to fully opaque for compatibility with Qt 3). */ -void QColor::invalidate() Q_DECL_NOTHROW +void QColor::invalidate() noexcept { cspec = Invalid; ct.argb.alpha = USHRT_MAX; diff --git a/src/gui/painting/qcolor.h b/src/gui/painting/qcolor.h index 4822612cf8..cbc8b98f9c 100644 --- a/src/gui/painting/qcolor.h +++ b/src/gui/painting/qcolor.h @@ -67,32 +67,32 @@ public: enum Spec { Invalid, Rgb, Hsv, Cmyk, Hsl }; enum NameFormat { HexRgb, HexArgb }; - inline QColor() Q_DECL_NOTHROW; - QColor(Qt::GlobalColor color) Q_DECL_NOTHROW; + inline QColor() noexcept; + QColor(Qt::GlobalColor color) noexcept; inline QColor(int r, int g, int b, int a = 255); - QColor(QRgb rgb) Q_DECL_NOTHROW; - QColor(QRgba64 rgba64) Q_DECL_NOTHROW; + QColor(QRgb rgb) noexcept; + QColor(QRgba64 rgba64) noexcept; #if QT_STRINGVIEW_LEVEL < 2 inline QColor(const QString& name); #endif explicit inline QColor(QStringView name); inline QColor(const char *aname) : QColor(QLatin1String(aname)) {} inline QColor(QLatin1String name); - QColor(Spec spec) Q_DECL_NOTHROW; + QColor(Spec spec) noexcept; #if QT_VERSION < QT_VERSION_CHECK(6,0,0) - inline QColor(const QColor &color) Q_DECL_NOTHROW; // ### Qt 6: remove all of these, the trivial ones are fine. + inline QColor(const QColor &color) noexcept; // ### Qt 6: remove all of these, the trivial ones are fine. # ifdef Q_COMPILER_RVALUE_REFS - QColor(QColor &&other) Q_DECL_NOTHROW : cspec(other.cspec), ct(other.ct) {} - QColor &operator=(QColor &&other) Q_DECL_NOTHROW + QColor(QColor &&other) noexcept : cspec(other.cspec), ct(other.ct) {} + QColor &operator=(QColor &&other) noexcept { cspec = other.cspec; ct = other.ct; return *this; } # endif - QColor &operator=(const QColor &) Q_DECL_NOTHROW; + QColor &operator=(const QColor &) noexcept; #endif // Qt < 6 - QColor &operator=(Qt::GlobalColor color) Q_DECL_NOTHROW; + QColor &operator=(Qt::GlobalColor color) noexcept; - bool isValid() const Q_DECL_NOTHROW; + bool isValid() const noexcept; // ### Qt 6: merge overloads QString name() const; @@ -106,25 +106,25 @@ public: static QStringList colorNames(); - inline Spec spec() const Q_DECL_NOTHROW + inline Spec spec() const noexcept { return cspec; } - int alpha() const Q_DECL_NOTHROW; + int alpha() const noexcept; void setAlpha(int alpha); - qreal alphaF() const Q_DECL_NOTHROW; + qreal alphaF() const noexcept; void setAlphaF(qreal alpha); - int red() const Q_DECL_NOTHROW; - int green() const Q_DECL_NOTHROW; - int blue() const Q_DECL_NOTHROW; + int red() const noexcept; + int green() const noexcept; + int blue() const noexcept; void setRed(int red); void setGreen(int green); void setBlue(int blue); - qreal redF() const Q_DECL_NOTHROW; - qreal greenF() const Q_DECL_NOTHROW; - qreal blueF() const Q_DECL_NOTHROW; + qreal redF() const noexcept; + qreal greenF() const noexcept; + qreal blueF() const noexcept; void setRedF(qreal red); void setGreenF(qreal green); void setBlueF(qreal blue); @@ -135,26 +135,26 @@ public: void getRgbF(qreal *r, qreal *g, qreal *b, qreal *a = nullptr) const; void setRgbF(qreal r, qreal g, qreal b, qreal a = 1.0); - QRgba64 rgba64() const Q_DECL_NOTHROW; - void setRgba64(QRgba64 rgba) Q_DECL_NOTHROW; + QRgba64 rgba64() const noexcept; + void setRgba64(QRgba64 rgba) noexcept; - QRgb rgba() const Q_DECL_NOTHROW; - void setRgba(QRgb rgba) Q_DECL_NOTHROW; + QRgb rgba() const noexcept; + void setRgba(QRgb rgba) noexcept; - QRgb rgb() const Q_DECL_NOTHROW; - void setRgb(QRgb rgb) Q_DECL_NOTHROW; + QRgb rgb() const noexcept; + void setRgb(QRgb rgb) noexcept; - int hue() const Q_DECL_NOTHROW; // 0 <= hue < 360 - int saturation() const Q_DECL_NOTHROW; - int hsvHue() const Q_DECL_NOTHROW; // 0 <= hue < 360 - int hsvSaturation() const Q_DECL_NOTHROW; - int value() const Q_DECL_NOTHROW; + int hue() const noexcept; // 0 <= hue < 360 + int saturation() const noexcept; + int hsvHue() const noexcept; // 0 <= hue < 360 + int hsvSaturation() const noexcept; + int value() const noexcept; - qreal hueF() const Q_DECL_NOTHROW; // 0.0 <= hueF < 360.0 - qreal saturationF() const Q_DECL_NOTHROW; - qreal hsvHueF() const Q_DECL_NOTHROW; // 0.0 <= hueF < 360.0 - qreal hsvSaturationF() const Q_DECL_NOTHROW; - qreal valueF() const Q_DECL_NOTHROW; + qreal hueF() const noexcept; // 0.0 <= hueF < 360.0 + qreal saturationF() const noexcept; + qreal hsvHueF() const noexcept; // 0.0 <= hueF < 360.0 + qreal hsvSaturationF() const noexcept; + qreal valueF() const noexcept; void getHsv(int *h, int *s, int *v, int *a = nullptr) const; void setHsv(int h, int s, int v, int a = 255); @@ -162,15 +162,15 @@ public: void getHsvF(qreal *h, qreal *s, qreal *v, qreal *a = nullptr) const; void setHsvF(qreal h, qreal s, qreal v, qreal a = 1.0); - int cyan() const Q_DECL_NOTHROW; - int magenta() const Q_DECL_NOTHROW; - int yellow() const Q_DECL_NOTHROW; - int black() const Q_DECL_NOTHROW; + int cyan() const noexcept; + int magenta() const noexcept; + int yellow() const noexcept; + int black() const noexcept; - qreal cyanF() const Q_DECL_NOTHROW; - qreal magentaF() const Q_DECL_NOTHROW; - qreal yellowF() const Q_DECL_NOTHROW; - qreal blackF() const Q_DECL_NOTHROW; + qreal cyanF() const noexcept; + qreal magentaF() const noexcept; + qreal yellowF() const noexcept; + qreal blackF() const noexcept; void getCmyk(int *c, int *m, int *y, int *k, int *a = nullptr); // ### Qt 6: remove void getCmyk(int *c, int *m, int *y, int *k, int *a = nullptr) const; @@ -180,13 +180,13 @@ public: void getCmykF(qreal *c, qreal *m, qreal *y, qreal *k, qreal *a = nullptr) const; void setCmykF(qreal c, qreal m, qreal y, qreal k, qreal a = 1.0); - int hslHue() const Q_DECL_NOTHROW; // 0 <= hue < 360 - int hslSaturation() const Q_DECL_NOTHROW; - int lightness() const Q_DECL_NOTHROW; + int hslHue() const noexcept; // 0 <= hue < 360 + int hslSaturation() const noexcept; + int lightness() const noexcept; - qreal hslHueF() const Q_DECL_NOTHROW; // 0.0 <= hueF < 360.0 - qreal hslSaturationF() const Q_DECL_NOTHROW; - qreal lightnessF() const Q_DECL_NOTHROW; + qreal hslHueF() const noexcept; // 0.0 <= hueF < 360.0 + qreal hslSaturationF() const noexcept; + qreal lightnessF() const noexcept; void getHsl(int *h, int *s, int *l, int *a = nullptr) const; void setHsl(int h, int s, int l, int a = 255); @@ -194,21 +194,21 @@ public: void getHslF(qreal *h, qreal *s, qreal *l, qreal *a = nullptr) const; void setHslF(qreal h, qreal s, qreal l, qreal a = 1.0); - QColor toRgb() const Q_DECL_NOTHROW; - QColor toHsv() const Q_DECL_NOTHROW; - QColor toCmyk() const Q_DECL_NOTHROW; - QColor toHsl() const Q_DECL_NOTHROW; + QColor toRgb() const noexcept; + QColor toHsv() const noexcept; + QColor toCmyk() const noexcept; + QColor toHsl() const noexcept; - Q_REQUIRED_RESULT QColor convertTo(Spec colorSpec) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT QColor convertTo(Spec colorSpec) const noexcept; - static QColor fromRgb(QRgb rgb) Q_DECL_NOTHROW; - static QColor fromRgba(QRgb rgba) Q_DECL_NOTHROW; + static QColor fromRgb(QRgb rgb) noexcept; + static QColor fromRgba(QRgb rgba) noexcept; static QColor fromRgb(int r, int g, int b, int a = 255); static QColor fromRgbF(qreal r, qreal g, qreal b, qreal a = 1.0); - static QColor fromRgba64(ushort r, ushort g, ushort b, ushort a = USHRT_MAX) Q_DECL_NOTHROW; - static QColor fromRgba64(QRgba64 rgba) Q_DECL_NOTHROW; + static QColor fromRgba64(ushort r, ushort g, ushort b, ushort a = USHRT_MAX) noexcept; + static QColor fromRgba64(QRgba64 rgba) noexcept; static QColor fromHsv(int h, int s, int v, int a = 255); static QColor fromHsvF(qreal h, qreal s, qreal v, qreal a = 1.0); @@ -221,27 +221,27 @@ public: #if QT_DEPRECATED_SINCE(5, 13) QT_DEPRECATED_X("Use QColor::lighter() instead") - Q_REQUIRED_RESULT QColor light(int f = 150) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT QColor light(int f = 150) const noexcept; QT_DEPRECATED_X("Use QColor::darker() instead") - Q_REQUIRED_RESULT QColor dark(int f = 200) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT QColor dark(int f = 200) const noexcept; #endif - Q_REQUIRED_RESULT QColor lighter(int f = 150) const Q_DECL_NOTHROW; - Q_REQUIRED_RESULT QColor darker(int f = 200) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT QColor lighter(int f = 150) const noexcept; + Q_REQUIRED_RESULT QColor darker(int f = 200) const noexcept; - bool operator==(const QColor &c) const Q_DECL_NOTHROW; - bool operator!=(const QColor &c) const Q_DECL_NOTHROW; + bool operator==(const QColor &c) const noexcept; + bool operator!=(const QColor &c) const noexcept; operator QVariant() const; #if QT_STRINGVIEW_LEVEL < 2 static bool isValidColor(const QString &name); #endif - static bool isValidColor(QStringView) Q_DECL_NOTHROW; - static bool isValidColor(QLatin1String) Q_DECL_NOTHROW; + static bool isValidColor(QStringView) noexcept; + static bool isValidColor(QLatin1String) noexcept; private: - void invalidate() Q_DECL_NOTHROW; + void invalidate() noexcept; template bool setColorFromString(String name); @@ -286,7 +286,7 @@ private: }; Q_DECLARE_TYPEINFO(QColor, QT_VERSION >= QT_VERSION_CHECK(6,0,0) ? Q_MOVABLE_TYPE : Q_RELOCATABLE_TYPE); -inline QColor::QColor() Q_DECL_NOTHROW +inline QColor::QColor() noexcept { invalidate(); } inline QColor::QColor(int r, int g, int b, int a) @@ -304,12 +304,12 @@ inline QColor::QColor(const QString& aname) #endif #if QT_VERSION < QT_VERSION_CHECK(6,0,0) -inline QColor::QColor(const QColor &acolor) Q_DECL_NOTHROW +inline QColor::QColor(const QColor &acolor) noexcept : cspec(acolor.cspec) { ct.argb = acolor.ct.argb; } #endif -inline bool QColor::isValid() const Q_DECL_NOTHROW +inline bool QColor::isValid() const noexcept { return cspec != Invalid; } QT_END_NAMESPACE diff --git a/src/gui/painting/qmatrix.cpp b/src/gui/painting/qmatrix.cpp index 24b33243da..b1f01332b6 100644 --- a/src/gui/painting/qmatrix.cpp +++ b/src/gui/painting/qmatrix.cpp @@ -248,7 +248,7 @@ QMatrix::QMatrix(qreal m11, qreal m12, qreal m21, qreal m22, qreal dx, qreal dy) /*! Constructs a matrix that is a copy of the given \a matrix. */ -QMatrix::QMatrix(const QMatrix &matrix) Q_DECL_NOTHROW +QMatrix::QMatrix(const QMatrix &matrix) noexcept : _m11(matrix._m11) , _m12(matrix._m12) , _m21(matrix._m21) @@ -989,7 +989,7 @@ bool QMatrix::operator==(const QMatrix &m) const Returns the hash value for \a key, using \a seed to seed the calculation. */ -uint qHash(const QMatrix &key, uint seed) Q_DECL_NOTHROW +uint qHash(const QMatrix &key, uint seed) noexcept { QtPrivate::QHashCombine hash; seed = hash(seed, key.m11()); @@ -1068,7 +1068,7 @@ QMatrix QMatrix::operator *(const QMatrix &m) const /*! Assigns the given \a matrix's values to this matrix. */ -QMatrix &QMatrix::operator=(const QMatrix &matrix) Q_DECL_NOTHROW +QMatrix &QMatrix::operator=(const QMatrix &matrix) noexcept { _m11 = matrix._m11; _m12 = matrix._m12; diff --git a/src/gui/painting/qmatrix.h b/src/gui/painting/qmatrix.h index d8a4fcfb1c..a167260ade 100644 --- a/src/gui/painting/qmatrix.h +++ b/src/gui/painting/qmatrix.h @@ -64,12 +64,12 @@ public: #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove; the compiler-generated ones are fine! - QMatrix &operator=(QMatrix &&other) Q_DECL_NOTHROW // = default + QMatrix &operator=(QMatrix &&other) noexcept // = default { memcpy(static_cast(this), static_cast(&other), sizeof(QMatrix)); return *this; } - QMatrix &operator=(const QMatrix &) Q_DECL_NOTHROW; // = default - QMatrix(QMatrix &&other) Q_DECL_NOTHROW // = default + QMatrix &operator=(const QMatrix &) noexcept; // = default + QMatrix(QMatrix &&other) noexcept // = default { memcpy(static_cast(this), static_cast(&other), sizeof(QMatrix)); } - QMatrix(const QMatrix &other) Q_DECL_NOTHROW; // = default + QMatrix(const QMatrix &other) noexcept; // = default #endif void setMatrix(qreal m11, qreal m12, qreal m21, qreal m22, @@ -140,7 +140,7 @@ private: }; Q_DECLARE_TYPEINFO(QMatrix, Q_MOVABLE_TYPE); -Q_GUI_EXPORT Q_DECL_CONST_FUNCTION uint qHash(const QMatrix &key, uint seed = 0) Q_DECL_NOTHROW; +Q_GUI_EXPORT Q_DECL_CONST_FUNCTION uint qHash(const QMatrix &key, uint seed = 0) noexcept; // mathematical semantics inline QPoint operator*(const QPoint &p, const QMatrix &m) diff --git a/src/gui/painting/qpagelayout.h b/src/gui/painting/qpagelayout.h index b41689d33b..faf0827c1a 100644 --- a/src/gui/painting/qpagelayout.h +++ b/src/gui/painting/qpagelayout.h @@ -83,12 +83,12 @@ public: const QMarginsF &minMargins = QMarginsF(0, 0, 0, 0)); QPageLayout(const QPageLayout &other); #ifdef Q_COMPILER_RVALUE_REFS - QPageLayout &operator=(QPageLayout &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QPageLayout &operator=(QPageLayout &&other) noexcept { swap(other); return *this; } #endif QPageLayout &operator=(const QPageLayout &other); ~QPageLayout(); - void swap(QPageLayout &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QPageLayout &other) noexcept { qSwap(d, other.d); } friend Q_GUI_EXPORT bool operator==(const QPageLayout &lhs, const QPageLayout &rhs); bool isEquivalentTo(const QPageLayout &other) const; diff --git a/src/gui/painting/qpagesize.h b/src/gui/painting/qpagesize.h index 82054824b4..a2ea691677 100644 --- a/src/gui/painting/qpagesize.h +++ b/src/gui/painting/qpagesize.h @@ -237,13 +237,13 @@ public: SizeMatchPolicy matchPolicy = FuzzyMatch); QPageSize(const QPageSize &other); #ifdef Q_COMPILER_RVALUE_REFS - QPageSize &operator=(QPageSize &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QPageSize &operator=(QPageSize &&other) noexcept { swap(other); return *this; } #endif QPageSize &operator=(const QPageSize &other); ~QPageSize(); - void swap(QPageSize &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QPageSize &other) noexcept { qSwap(d, other.d); } friend Q_GUI_EXPORT bool operator==(const QPageSize &lhs, const QPageSize &rhs); bool isEquivalentTo(const QPageSize &other) const; diff --git a/src/gui/painting/qpaintdevice.cpp b/src/gui/painting/qpaintdevice.cpp index faaa316085..0ddfba6ee9 100644 --- a/src/gui/painting/qpaintdevice.cpp +++ b/src/gui/painting/qpaintdevice.cpp @@ -41,7 +41,7 @@ QT_BEGIN_NAMESPACE -QPaintDevice::QPaintDevice() Q_DECL_NOEXCEPT +QPaintDevice::QPaintDevice() noexcept { reserved = 0; painters = 0; diff --git a/src/gui/painting/qpaintdevice.h b/src/gui/painting/qpaintdevice.h index 9458b4ba9a..5f8dad205d 100644 --- a/src/gui/painting/qpaintdevice.h +++ b/src/gui/painting/qpaintdevice.h @@ -90,7 +90,7 @@ public: static inline qreal devicePixelRatioFScale() { return 0x10000; } protected: - QPaintDevice() Q_DECL_NOEXCEPT; + QPaintDevice() noexcept; virtual int metric(PaintDeviceMetric metric) const; virtual void initPainter(QPainter *painter) const; virtual QPaintDevice *redirected(QPoint *offset) const; diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index 42f94d038f..649cfd554b 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -527,7 +527,7 @@ void QPainterPath::setElementPositionAt(int i, qreal x, qreal y) /*! Constructs an empty QPainterPath object. */ -QPainterPath::QPainterPath() Q_DECL_NOEXCEPT +QPainterPath::QPainterPath() noexcept : d_ptr(0) { } diff --git a/src/gui/painting/qpainterpath.h b/src/gui/painting/qpainterpath.h index a69a192767..2785669260 100644 --- a/src/gui/painting/qpainterpath.h +++ b/src/gui/painting/qpainterpath.h @@ -88,17 +88,17 @@ public: inline bool operator!=(const Element &e) const { return !operator==(e); } }; - QPainterPath() Q_DECL_NOEXCEPT; + QPainterPath() noexcept; explicit QPainterPath(const QPointF &startPoint); QPainterPath(const QPainterPath &other); QPainterPath &operator=(const QPainterPath &other); #ifdef Q_COMPILER_RVALUE_REFS - inline QPainterPath &operator=(QPainterPath &&other) Q_DECL_NOEXCEPT + inline QPainterPath &operator=(QPainterPath &&other) noexcept { qSwap(d_ptr, other.d_ptr); return *this; } #endif ~QPainterPath(); - inline void swap(QPainterPath &other) Q_DECL_NOEXCEPT { d_ptr.swap(other.d_ptr); } + inline void swap(QPainterPath &other) noexcept { d_ptr.swap(other.d_ptr); } void clear(); void reserve(int size); diff --git a/src/gui/painting/qpen.cpp b/src/gui/painting/qpen.cpp index 778c770b82..58a1716037 100644 --- a/src/gui/painting/qpen.cpp +++ b/src/gui/painting/qpen.cpp @@ -322,7 +322,7 @@ QPen::QPen(const QBrush &brush, qreal width, Qt::PenStyle s, Qt::PenCapStyle c, Constructs a pen that is a copy of the given \a pen. */ -QPen::QPen(const QPen &p) Q_DECL_NOTHROW +QPen::QPen(const QPen &p) noexcept { d = p.d; if (d) @@ -381,7 +381,7 @@ void QPen::detach() this pen. */ -QPen &QPen::operator=(const QPen &p) Q_DECL_NOTHROW +QPen &QPen::operator=(const QPen &p) noexcept { QPen(p).swap(*this); return *this; diff --git a/src/gui/painting/qpen.h b/src/gui/painting/qpen.h index 03abfb3d7d..884ec8cdfa 100644 --- a/src/gui/painting/qpen.h +++ b/src/gui/painting/qpen.h @@ -65,18 +65,18 @@ public: QPen(const QColor &color); QPen(const QBrush &brush, qreal width, Qt::PenStyle s = Qt::SolidLine, Qt::PenCapStyle c = Qt::SquareCap, Qt::PenJoinStyle j = Qt::BevelJoin); - QPen(const QPen &pen) Q_DECL_NOTHROW; + QPen(const QPen &pen) noexcept; ~QPen(); - QPen &operator=(const QPen &pen) Q_DECL_NOTHROW; + QPen &operator=(const QPen &pen) noexcept; #ifdef Q_COMPILER_RVALUE_REFS - QPen(QPen &&other) Q_DECL_NOTHROW + QPen(QPen &&other) noexcept : d(other.d) { other.d = nullptr; } - QPen &operator=(QPen &&other) Q_DECL_NOTHROW + QPen &operator=(QPen &&other) noexcept { qSwap(d, other.d); return *this; } #endif - void swap(QPen &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QPen &other) noexcept { qSwap(d, other.d); } Qt::PenStyle style() const; void setStyle(Qt::PenStyle); diff --git a/src/gui/painting/qpolygon.h b/src/gui/painting/qpolygon.h index 8e74a499fd..118861c0f2 100644 --- a/src/gui/painting/qpolygon.h +++ b/src/gui/painting/qpolygon.h @@ -61,17 +61,17 @@ public: inline explicit QPolygon(int size); inline /*implicit*/ QPolygon(const QVector &v) : QVector(v) {} #ifdef Q_COMPILER_RVALUE_REFS - /*implicit*/ QPolygon(QVector &&v) Q_DECL_NOTHROW : QVector(std::move(v)) {} + /*implicit*/ QPolygon(QVector &&v) noexcept : QVector(std::move(v)) {} #endif QPolygon(const QRect &r, bool closed=false); QPolygon(int nPoints, const int *points); QPolygon(const QPolygon &other) : QVector(other) {} #ifdef Q_COMPILER_RVALUE_REFS - QPolygon(QPolygon &&other) Q_DECL_NOTHROW : QVector(std::move(other)) {} - QPolygon &operator=(QPolygon &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QPolygon(QPolygon &&other) noexcept : QVector(std::move(other)) {} + QPolygon &operator=(QPolygon &&other) noexcept { swap(other); return *this; } #endif QPolygon &operator=(const QPolygon &other) { QVector::operator=(other); return *this; } - void swap(QPolygon &other) Q_DECL_NOTHROW { QVector::swap(other); } // prevent QVector<->QPolygon swaps + void swap(QPolygon &other) noexcept { QVector::swap(other); } // prevent QVector<->QPolygon swaps operator QVariant() const; @@ -146,14 +146,14 @@ public: inline explicit QPolygonF(int size); inline /*implicit*/ QPolygonF(const QVector &v) : QVector(v) {} #ifdef Q_COMPILER_RVALUE_REFS - /* implicit */ QPolygonF(QVector &&v) Q_DECL_NOTHROW : QVector(std::move(v)) {} + /* implicit */ QPolygonF(QVector &&v) noexcept : QVector(std::move(v)) {} #endif QPolygonF(const QRectF &r); /*implicit*/ QPolygonF(const QPolygon &a); inline QPolygonF(const QPolygonF &a) : QVector(a) {} #ifdef Q_COMPILER_RVALUE_REFS - QPolygonF(QPolygonF &&other) Q_DECL_NOTHROW : QVector(std::move(other)) {} - QPolygonF &operator=(QPolygonF &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QPolygonF(QPolygonF &&other) noexcept : QVector(std::move(other)) {} + QPolygonF &operator=(QPolygonF &&other) noexcept { swap(other); return *this; } #endif QPolygonF &operator=(const QPolygonF &other) { QVector::operator=(other); return *this; } inline void swap(QPolygonF &other) { QVector::swap(other); } // prevent QVector<->QPolygonF swaps diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index 77718ce747..51eed962f0 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -1287,10 +1287,10 @@ struct QRegionPrivate { } } - const QRect *begin() const Q_DECL_NOTHROW + const QRect *begin() const noexcept { return numRects == 1 ? &extents : rects.data(); } // avoid vectorize() - const QRect *end() const Q_DECL_NOTHROW + const QRect *end() const noexcept { return begin() + numRects; } inline void append(const QRect *r); @@ -4321,7 +4321,7 @@ QRegion QRegion::xored(const QRegion &r) const } } -QRect QRegion::boundingRect() const Q_DECL_NOTHROW +QRect QRegion::boundingRect() const noexcept { if (isEmpty()) return QRect(); @@ -4379,12 +4379,12 @@ QVector QRegion::rects() const } #endif -QRegion::const_iterator QRegion::begin() const Q_DECL_NOTHROW +QRegion::const_iterator QRegion::begin() const noexcept { return d->qt_rgn ? d->qt_rgn->begin() : nullptr; } -QRegion::const_iterator QRegion::end() const Q_DECL_NOTHROW +QRegion::const_iterator QRegion::end() const noexcept { return d->qt_rgn ? d->qt_rgn->end() : nullptr; } @@ -4421,7 +4421,7 @@ void QRegion::setRects(const QRect *rects, int num) } } -int QRegion::rectCount() const Q_DECL_NOTHROW +int QRegion::rectCount() const noexcept { return (d->qt_rgn ? d->qt_rgn->numRects : 0); } diff --git a/src/gui/painting/qregion.h b/src/gui/painting/qregion.h index 9fe6ed5675..9b6b25d743 100644 --- a/src/gui/painting/qregion.h +++ b/src/gui/painting/qregion.h @@ -69,30 +69,30 @@ public: QRegion(const QRect &r, RegionType t = Rectangle); QRegion(const QPolygon &pa, Qt::FillRule fillRule = Qt::OddEvenFill); QRegion(const QRegion ®ion); - QRegion(QRegion &&other) Q_DECL_NOTHROW + QRegion(QRegion &&other) noexcept : d(other.d) { other.d = const_cast(&shared_empty); } QRegion(const QBitmap &bitmap); ~QRegion(); QRegion &operator=(const QRegion &); #ifdef Q_COMPILER_RVALUE_REFS - inline QRegion &operator=(QRegion &&other) Q_DECL_NOEXCEPT + inline QRegion &operator=(QRegion &&other) noexcept { qSwap(d, other.d); return *this; } #endif - inline void swap(QRegion &other) Q_DECL_NOEXCEPT { qSwap(d, other.d); } + inline void swap(QRegion &other) noexcept { qSwap(d, other.d); } bool isEmpty() const; bool isNull() const; typedef const QRect *const_iterator; typedef std::reverse_iterator const_reverse_iterator; - const_iterator begin() const Q_DECL_NOTHROW; - const_iterator cbegin() const Q_DECL_NOTHROW { return begin(); } - const_iterator end() const Q_DECL_NOTHROW; - const_iterator cend() const Q_DECL_NOTHROW { return end(); } - const_reverse_iterator rbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); } - const_reverse_iterator crbegin() const Q_DECL_NOTHROW { return rbegin(); } - const_reverse_iterator rend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); } - const_reverse_iterator crend() const Q_DECL_NOTHROW { return rend(); } + const_iterator begin() const noexcept; + const_iterator cbegin() const noexcept { return begin(); } + const_iterator end() const noexcept; + const_iterator cend() const noexcept { return end(); } + const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } + const_reverse_iterator crbegin() const noexcept { return rbegin(); } + const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } + const_reverse_iterator crend() const noexcept { return rend(); } bool contains(const QPoint &p) const; bool contains(const QRect &r) const; @@ -121,13 +121,13 @@ public: bool intersects(const QRegion &r) const; bool intersects(const QRect &r) const; - QRect boundingRect() const Q_DECL_NOTHROW; + QRect boundingRect() const noexcept; #if QT_DEPRECATED_SINCE(5, 11) QT_DEPRECATED_X("Use begin()/end() instead") QVector rects() const; #endif void setRects(const QRect *rect, int num); - int rectCount() const Q_DECL_NOTHROW; + int rectCount() const noexcept; #ifdef Q_COMPILER_MANGLES_RETURN_TYPE // ### Qt 6: remove these, they're kept for MSVC compat const QRegion operator|(const QRegion &r) const; diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index 816514a695..6110a548fd 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -795,7 +795,7 @@ bool QTransform::operator==(const QTransform &o) const Returns the hash value for \a key, using \a seed to seed the calculation. */ -uint qHash(const QTransform &key, uint seed) Q_DECL_NOTHROW +uint qHash(const QTransform &key, uint seed) noexcept { QtPrivate::QHashCombine hash; seed = hash(seed, key.m11()); @@ -1021,7 +1021,7 @@ QTransform QTransform::operator*(const QTransform &m) const /*! Assigns the given \a matrix's values to this matrix. */ -QTransform & QTransform::operator=(const QTransform &matrix) Q_DECL_NOTHROW +QTransform & QTransform::operator=(const QTransform &matrix) noexcept { affine._m11 = matrix.affine._m11; affine._m12 = matrix.affine._m12; diff --git a/src/gui/painting/qtransform.h b/src/gui/painting/qtransform.h index 1e322d435a..18c53f4a6f 100644 --- a/src/gui/painting/qtransform.h +++ b/src/gui/painting/qtransform.h @@ -77,13 +77,13 @@ public: #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove; the compiler-generated ones are fine! - QTransform &operator=(QTransform &&other) Q_DECL_NOTHROW // = default + QTransform &operator=(QTransform &&other) noexcept // = default { memcpy(static_cast(this), static_cast(&other), sizeof(QTransform)); return *this; } - QTransform &operator=(const QTransform &) Q_DECL_NOTHROW; // = default - QTransform(QTransform &&other) Q_DECL_NOTHROW // = default + QTransform &operator=(const QTransform &) noexcept; // = default + QTransform(QTransform &&other) noexcept // = default : affine(Qt::Uninitialized) { memcpy(static_cast(this), static_cast(&other), sizeof(QTransform)); } - QTransform(const QTransform &other) Q_DECL_NOTHROW // = default + QTransform(const QTransform &other) noexcept // = default : affine(Qt::Uninitialized) { memcpy(static_cast(this), static_cast(&other), sizeof(QTransform)); } #endif @@ -202,7 +202,7 @@ private: }; Q_DECLARE_TYPEINFO(QTransform, Q_MOVABLE_TYPE); -Q_GUI_EXPORT Q_DECL_CONST_FUNCTION uint qHash(const QTransform &key, uint seed = 0) Q_DECL_NOTHROW; +Q_GUI_EXPORT Q_DECL_CONST_FUNCTION uint qHash(const QTransform &key, uint seed = 0) noexcept; /******* inlines *****/ inline QTransform::TransformationType QTransform::inline_type() const diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index d54fa22990..164a2f60ab 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -2083,7 +2083,7 @@ QString QFont::toString() const \relates QFont \since 5.3 */ -uint qHash(const QFont &font, uint seed) Q_DECL_NOTHROW +uint qHash(const QFont &font, uint seed) noexcept { return qHash(QFontPrivate::get(font)->request, seed); } diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h index 35ef798275..16685ed9e8 100644 --- a/src/gui/text/qfont.h +++ b/src/gui/text/qfont.h @@ -262,7 +262,7 @@ public: operator QVariant() const; bool isCopyOf(const QFont &) const; #ifdef Q_COMPILER_RVALUE_REFS - inline QFont &operator=(QFont &&other) Q_DECL_NOEXCEPT + inline QFont &operator=(QFont &&other) noexcept { qSwap(d, other.d); qSwap(resolve_mask, other.resolve_mask); return *this; } #endif @@ -347,7 +347,7 @@ private: Q_DECLARE_SHARED(QFont) -Q_GUI_EXPORT uint qHash(const QFont &font, uint seed = 0) Q_DECL_NOTHROW; +Q_GUI_EXPORT uint qHash(const QFont &font, uint seed = 0) noexcept; inline bool QFont::bold() const { return weight() > Medium; } diff --git a/src/gui/text/qfont_p.h b/src/gui/text/qfont_p.h index 6156faa788..db74ab0b65 100644 --- a/src/gui/text/qfont_p.h +++ b/src/gui/text/qfont_p.h @@ -136,7 +136,7 @@ struct QFontDef } }; -inline uint qHash(const QFontDef &fd, uint seed = 0) Q_DECL_NOTHROW +inline uint qHash(const QFontDef &fd, uint seed = 0) noexcept { return qHash(qRound64(fd.pixelSize*10000)) // use only 4 fractional digits ^ qHash(fd.weight) diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index a307539800..ee37a84f5f 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -434,7 +434,7 @@ struct FallbacksCacheKey { QChar::Script script; }; -inline bool operator==(const FallbacksCacheKey &lhs, const FallbacksCacheKey &rhs) Q_DECL_NOTHROW +inline bool operator==(const FallbacksCacheKey &lhs, const FallbacksCacheKey &rhs) noexcept { return lhs.script == rhs.script && lhs.styleHint == rhs.styleHint && @@ -442,12 +442,12 @@ inline bool operator==(const FallbacksCacheKey &lhs, const FallbacksCacheKey &rh lhs.family == rhs.family; } -inline bool operator!=(const FallbacksCacheKey &lhs, const FallbacksCacheKey &rhs) Q_DECL_NOTHROW +inline bool operator!=(const FallbacksCacheKey &lhs, const FallbacksCacheKey &rhs) noexcept { return !operator==(lhs, rhs); } -inline uint qHash(const FallbacksCacheKey &key, uint seed = 0) Q_DECL_NOTHROW +inline uint qHash(const FallbacksCacheKey &key, uint seed = 0) noexcept { QtPrivate::QHashCombine hash; seed = hash(seed, key.family); diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index 05c6746185..b922d50b4c 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -292,33 +292,33 @@ public: Holder() : ptr(nullptr), destroy_func(nullptr) {} explicit Holder(void *p, qt_destroy_func_t d) : ptr(p), destroy_func(d) {} ~Holder() { if (ptr && destroy_func) destroy_func(ptr); } - Holder(Holder &&other) Q_DECL_NOTHROW + Holder(Holder &&other) noexcept : ptr(other.ptr), destroy_func(other.destroy_func) { other.ptr = nullptr; other.destroy_func = nullptr; } - Holder &operator=(Holder &&other) Q_DECL_NOTHROW + Holder &operator=(Holder &&other) noexcept { swap(other); return *this; } - void swap(Holder &other) Q_DECL_NOTHROW + void swap(Holder &other) noexcept { qSwap(ptr, other.ptr); qSwap(destroy_func, other.destroy_func); } - void *get() const Q_DECL_NOTHROW { return ptr; } - void *release() Q_DECL_NOTHROW { + void *get() const noexcept { return ptr; } + void *release() noexcept { void *result = ptr; ptr = nullptr; destroy_func = nullptr; return result; } - void reset() Q_DECL_NOTHROW { Holder().swap(*this); } - qt_destroy_func_t get_deleter() const Q_DECL_NOTHROW { return destroy_func; } + void reset() noexcept { Holder().swap(*this); } + qt_destroy_func_t get_deleter() const noexcept { return destroy_func; } - bool operator!() const Q_DECL_NOTHROW { return !ptr; } + bool operator!() const noexcept { return !ptr; } }; mutable Holder font_; // \ NOTE: Declared before m_glyphCaches, so font_, face_ @@ -390,7 +390,7 @@ inline bool operator ==(const QFontEngine::FaceId &f1, const QFontEngine::FaceId } inline uint qHash(const QFontEngine::FaceId &f, uint seed = 0) - Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(f.filename))) + noexcept(noexcept(qHash(f.filename))) { QtPrivate::QHashCombine hash; seed = hash(seed, f.filename); diff --git a/src/gui/text/qfontmetrics.h b/src/gui/text/qfontmetrics.h index 61931fa9bc..761cadde47 100644 --- a/src/gui/text/qfontmetrics.h +++ b/src/gui/text/qfontmetrics.h @@ -77,11 +77,11 @@ public: QFontMetrics &operator=(const QFontMetrics &); #ifdef Q_COMPILER_RVALUE_REFS - inline QFontMetrics &operator=(QFontMetrics &&other) Q_DECL_NOEXCEPT + inline QFontMetrics &operator=(QFontMetrics &&other) noexcept { qSwap(d, other.d); return *this; } #endif - void swap(QFontMetrics &other) Q_DECL_NOEXCEPT + void swap(QFontMetrics &other) noexcept { qSwap(d, other.d); } int ascent() const; diff --git a/src/gui/text/qglyphrun.h b/src/gui/text/qglyphrun.h index 6182c4f749..9bb1d3c820 100644 --- a/src/gui/text/qglyphrun.h +++ b/src/gui/text/qglyphrun.h @@ -67,12 +67,12 @@ public: QGlyphRun(); QGlyphRun(const QGlyphRun &other); #ifdef Q_COMPILER_RVALUE_REFS - QGlyphRun &operator=(QGlyphRun &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QGlyphRun &operator=(QGlyphRun &&other) noexcept { swap(other); return *this; } #endif QGlyphRun &operator=(const QGlyphRun &other); ~QGlyphRun(); - void swap(QGlyphRun &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QGlyphRun &other) noexcept { qSwap(d, other.d); } QRawFont rawFont() const; void setRawFont(const QRawFont &rawFont); diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp index b2d8bf01af..a060448924 100644 --- a/src/gui/text/qrawfont.cpp +++ b/src/gui/text/qrawfont.cpp @@ -322,7 +322,7 @@ bool QRawFont::operator==(const QRawFont &other) const \relates QRawFont \since 5.8 */ -uint qHash(const QRawFont &font, uint seed) Q_DECL_NOTHROW +uint qHash(const QRawFont &font, uint seed) noexcept { return qHash(QRawFontPrivate::get(font)->fontEngine, seed); } diff --git a/src/gui/text/qrawfont.h b/src/gui/text/qrawfont.h index 470f2694e4..3b84f642d3 100644 --- a/src/gui/text/qrawfont.h +++ b/src/gui/text/qrawfont.h @@ -80,12 +80,12 @@ public: QFont::HintingPreference hintingPreference = QFont::PreferDefaultHinting); QRawFont(const QRawFont &other); #ifdef Q_COMPILER_RVALUE_REFS - QRawFont &operator=(QRawFont &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QRawFont &operator=(QRawFont &&other) noexcept { swap(other); return *this; } #endif QRawFont &operator=(const QRawFont &other); ~QRawFont(); - void swap(QRawFont &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QRawFont &other) noexcept { qSwap(d, other.d); } bool isValid() const; @@ -158,7 +158,7 @@ Q_DECLARE_SHARED(QRawFont) Q_DECLARE_OPERATORS_FOR_FLAGS(QRawFont::LayoutFlags) -Q_GUI_EXPORT uint qHash(const QRawFont &font, uint seed = 0) Q_DECL_NOTHROW; +Q_GUI_EXPORT uint qHash(const QRawFont &font, uint seed = 0) noexcept; inline QVector QRawFont::advancesForGlyphIndexes(const QVector &glyphIndexes, QRawFont::LayoutFlags layoutFlags) const { diff --git a/src/gui/text/qstatictext.h b/src/gui/text/qstatictext.h index ada0456b8f..c6a0d158c1 100644 --- a/src/gui/text/qstatictext.h +++ b/src/gui/text/qstatictext.h @@ -65,12 +65,12 @@ public: explicit QStaticText(const QString &text); QStaticText(const QStaticText &other); #ifdef Q_COMPILER_RVALUE_REFS - QStaticText &operator=(QStaticText &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QStaticText &operator=(QStaticText &&other) noexcept { swap(other); return *this; } #endif QStaticText &operator=(const QStaticText &); ~QStaticText(); - void swap(QStaticText &other) Q_DECL_NOTHROW { qSwap(data, other.data); } + void swap(QStaticText &other) noexcept { qSwap(data, other.data); } void setText(const QString &text); QString text() const; diff --git a/src/gui/text/qtextcursor.h b/src/gui/text/qtextcursor.h index 1a00b753ad..4a9c614887 100644 --- a/src/gui/text/qtextcursor.h +++ b/src/gui/text/qtextcursor.h @@ -74,12 +74,12 @@ public: explicit QTextCursor(const QTextBlock &block); QTextCursor(const QTextCursor &cursor); #ifdef Q_COMPILER_RVALUE_REFS - QTextCursor &operator=(QTextCursor &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QTextCursor &operator=(QTextCursor &&other) noexcept { swap(other); return *this; } #endif QTextCursor &operator=(const QTextCursor &other); ~QTextCursor(); - void swap(QTextCursor &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QTextCursor &other) noexcept { qSwap(d, other.d); } bool isNull() const; diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index fb2e812183..fddda7f2f8 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -335,7 +335,7 @@ public: struct QScriptItem { - Q_DECL_CONSTEXPR QScriptItem(int p, QScriptAnalysis a) Q_DECL_NOTHROW + Q_DECL_CONSTEXPR QScriptItem(int p, QScriptAnalysis a) noexcept : position(p), analysis(a), num_glyphs(0), descent(-1), ascent(-1), leading(-1), width(-1), glyph_data_offset(0) {} @@ -348,7 +348,7 @@ struct QScriptItem QFixed leading; QFixed width; int glyph_data_offset; - Q_DECL_CONSTEXPR QFixed height() const Q_DECL_NOTHROW { return ascent + descent; } + Q_DECL_CONSTEXPR QFixed height() const noexcept { return ascent + descent; } private: friend class QVector; QScriptItem() {}; // for QVector, don't use diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp index 18c5a4f3dd..9156ee6af4 100644 --- a/src/gui/text/qtextobject.cpp +++ b/src/gui/text/qtextobject.cpp @@ -678,7 +678,7 @@ QTextFrame::iterator::iterator(QTextFrame *frame, int block, int begin, int end) /*! Copy constructor. Constructs a copy of the \a other iterator. */ -QTextFrame::iterator::iterator(const iterator &other) Q_DECL_NOTHROW +QTextFrame::iterator::iterator(const iterator &other) noexcept { f = other.f; b = other.b; @@ -691,7 +691,7 @@ QTextFrame::iterator::iterator(const iterator &other) Q_DECL_NOTHROW Assigns \a other to this iterator and returns a reference to this iterator. */ -QTextFrame::iterator &QTextFrame::iterator::operator=(const iterator &other) Q_DECL_NOTHROW +QTextFrame::iterator &QTextFrame::iterator::operator=(const iterator &other) noexcept { f = other.f; b = other.b; diff --git a/src/gui/text/qtextobject.h b/src/gui/text/qtextobject.h index 067f8473ea..586a593dd2 100644 --- a/src/gui/text/qtextobject.h +++ b/src/gui/text/qtextobject.h @@ -151,11 +151,11 @@ public: public: iterator(); // ### Qt 6: inline #if QT_VERSION < QT_VERSION_CHECK(6,0,0) - iterator(const iterator &o) Q_DECL_NOTHROW; // = default - iterator &operator=(const iterator &o) Q_DECL_NOTHROW; // = default - iterator(iterator &&other) Q_DECL_NOTHROW // = default + iterator(const iterator &o) noexcept; // = default + iterator &operator=(const iterator &o) noexcept; // = default + iterator(iterator &&other) noexcept // = default { memcpy(static_cast(this), static_cast(&other), sizeof(iterator)); } - iterator &operator=(iterator &&other) Q_DECL_NOTHROW // = default + iterator &operator=(iterator &&other) noexcept // = default { memcpy(static_cast(this), static_cast(&other), sizeof(iterator)); return *this; } #endif diff --git a/src/gui/text/qzipreader_p.h b/src/gui/text/qzipreader_p.h index 378072b366..6fec8d7719 100644 --- a/src/gui/text/qzipreader_p.h +++ b/src/gui/text/qzipreader_p.h @@ -79,11 +79,11 @@ public: struct FileInfo { - FileInfo() Q_DECL_NOTHROW + FileInfo() noexcept : isDir(false), isFile(false), isSymLink(false), crc(0), size(0) {} - bool isValid() const Q_DECL_NOTHROW { return isDir || isFile || isSymLink; } + bool isValid() const noexcept { return isDir || isFile || isSymLink; } QString filePath; uint isDir : 1; diff --git a/src/gui/util/qshaderformat.cpp b/src/gui/util/qshaderformat.cpp index 373bfb9e7e..324d84ffe1 100644 --- a/src/gui/util/qshaderformat.cpp +++ b/src/gui/util/qshaderformat.cpp @@ -41,58 +41,58 @@ QT_BEGIN_NAMESPACE -QShaderFormat::QShaderFormat() Q_DECL_NOTHROW +QShaderFormat::QShaderFormat() noexcept : m_api(NoApi) { } -QShaderFormat::Api QShaderFormat::api() const Q_DECL_NOTHROW +QShaderFormat::Api QShaderFormat::api() const noexcept { return m_api; } -void QShaderFormat::setApi(QShaderFormat::Api api) Q_DECL_NOTHROW +void QShaderFormat::setApi(QShaderFormat::Api api) noexcept { m_api = api; } -QVersionNumber QShaderFormat::version() const Q_DECL_NOTHROW +QVersionNumber QShaderFormat::version() const noexcept { return m_version; } -void QShaderFormat::setVersion(const QVersionNumber &version) Q_DECL_NOTHROW +void QShaderFormat::setVersion(const QVersionNumber &version) noexcept { m_version = version; } -QStringList QShaderFormat::extensions() const Q_DECL_NOTHROW +QStringList QShaderFormat::extensions() const noexcept { return m_extensions; } -void QShaderFormat::setExtensions(const QStringList &extensions) Q_DECL_NOTHROW +void QShaderFormat::setExtensions(const QStringList &extensions) noexcept { m_extensions = extensions; m_extensions.sort(); } -QString QShaderFormat::vendor() const Q_DECL_NOTHROW +QString QShaderFormat::vendor() const noexcept { return m_vendor; } -void QShaderFormat::setVendor(const QString &vendor) Q_DECL_NOTHROW +void QShaderFormat::setVendor(const QString &vendor) noexcept { m_vendor = vendor; } -bool QShaderFormat::isValid() const Q_DECL_NOTHROW +bool QShaderFormat::isValid() const noexcept { return m_api != NoApi && m_version.majorVersion() > 0; } -bool QShaderFormat::supports(const QShaderFormat &other) const Q_DECL_NOTHROW +bool QShaderFormat::supports(const QShaderFormat &other) const noexcept { if (!isValid() || !other.isValid()) return false; @@ -119,7 +119,7 @@ bool QShaderFormat::supports(const QShaderFormat &other) const Q_DECL_NOTHROW return true; } -bool operator==(const QShaderFormat &lhs, const QShaderFormat &rhs) Q_DECL_NOTHROW +bool operator==(const QShaderFormat &lhs, const QShaderFormat &rhs) noexcept { return lhs.api() == rhs.api() && lhs.version() == rhs.version() diff --git a/src/gui/util/qshaderformat_p.h b/src/gui/util/qshaderformat_p.h index 064c2364a7..84bf71fdb6 100644 --- a/src/gui/util/qshaderformat_p.h +++ b/src/gui/util/qshaderformat_p.h @@ -69,22 +69,22 @@ public: OpenGLES }; - Q_GUI_EXPORT QShaderFormat() Q_DECL_NOTHROW; + Q_GUI_EXPORT QShaderFormat() noexcept; - Q_GUI_EXPORT Api api() const Q_DECL_NOTHROW; - Q_GUI_EXPORT void setApi(Api api) Q_DECL_NOTHROW; + Q_GUI_EXPORT Api api() const noexcept; + Q_GUI_EXPORT void setApi(Api api) noexcept; - Q_GUI_EXPORT QVersionNumber version() const Q_DECL_NOTHROW; - Q_GUI_EXPORT void setVersion(const QVersionNumber &version) Q_DECL_NOTHROW; + Q_GUI_EXPORT QVersionNumber version() const noexcept; + Q_GUI_EXPORT void setVersion(const QVersionNumber &version) noexcept; - Q_GUI_EXPORT QStringList extensions() const Q_DECL_NOTHROW; - Q_GUI_EXPORT void setExtensions(const QStringList &extensions) Q_DECL_NOTHROW; + Q_GUI_EXPORT QStringList extensions() const noexcept; + Q_GUI_EXPORT void setExtensions(const QStringList &extensions) noexcept; - Q_GUI_EXPORT QString vendor() const Q_DECL_NOTHROW; - Q_GUI_EXPORT void setVendor(const QString &vendor) Q_DECL_NOTHROW; + Q_GUI_EXPORT QString vendor() const noexcept; + Q_GUI_EXPORT void setVendor(const QString &vendor) noexcept; - Q_GUI_EXPORT bool isValid() const Q_DECL_NOTHROW; - Q_GUI_EXPORT bool supports(const QShaderFormat &other) const Q_DECL_NOTHROW; + Q_GUI_EXPORT bool isValid() const noexcept; + Q_GUI_EXPORT bool supports(const QShaderFormat &other) const noexcept; private: Api m_api; @@ -93,9 +93,9 @@ private: QString m_vendor; }; -Q_GUI_EXPORT bool operator==(const QShaderFormat &lhs, const QShaderFormat &rhs) Q_DECL_NOTHROW; +Q_GUI_EXPORT bool operator==(const QShaderFormat &lhs, const QShaderFormat &rhs) noexcept; -inline bool operator!=(const QShaderFormat &lhs, const QShaderFormat &rhs) Q_DECL_NOTHROW +inline bool operator!=(const QShaderFormat &lhs, const QShaderFormat &rhs) noexcept { return !(lhs == rhs); } diff --git a/src/gui/util/qshadergraph.cpp b/src/gui/util/qshadergraph.cpp index 828c709a12..7485c179db 100644 --- a/src/gui/util/qshadergraph.cpp +++ b/src/gui/util/qshadergraph.cpp @@ -118,12 +118,12 @@ namespace } } -QUuid QShaderGraph::Statement::uuid() const Q_DECL_NOTHROW +QUuid QShaderGraph::Statement::uuid() const noexcept { return node.uuid(); } -int QShaderGraph::Statement::portIndex(QShaderNodePort::Direction direction, const QString &portName) const Q_DECL_NOTHROW +int QShaderGraph::Statement::portIndex(QShaderNodePort::Direction direction, const QString &portName) const noexcept { const auto ports = node.ports(); int index = 0; @@ -150,7 +150,7 @@ void QShaderGraph::removeNode(const QShaderNode &node) m_nodes.erase(it); } -QVector QShaderGraph::nodes() const Q_DECL_NOTHROW +QVector QShaderGraph::nodes() const noexcept { return m_nodes; } @@ -167,7 +167,7 @@ void QShaderGraph::removeEdge(const QShaderGraph::Edge &edge) m_edges.removeAll(edge); } -QVector QShaderGraph::edges() const Q_DECL_NOTHROW +QVector QShaderGraph::edges() const noexcept { return m_edges; } @@ -244,7 +244,7 @@ QVector QShaderGraph::createStatements(const QStringLis return result; } -bool operator==(const QShaderGraph::Edge &lhs, const QShaderGraph::Edge &rhs) Q_DECL_NOTHROW +bool operator==(const QShaderGraph::Edge &lhs, const QShaderGraph::Edge &rhs) noexcept { return lhs.sourceNodeUuid == rhs.sourceNodeUuid && lhs.sourcePortName == rhs.sourcePortName @@ -252,7 +252,7 @@ bool operator==(const QShaderGraph::Edge &lhs, const QShaderGraph::Edge &rhs) Q_ && lhs.targetPortName == rhs.targetPortName; } -bool operator==(const QShaderGraph::Statement &lhs, const QShaderGraph::Statement &rhs) Q_DECL_NOTHROW +bool operator==(const QShaderGraph::Statement &lhs, const QShaderGraph::Statement &rhs) noexcept { return lhs.inputs == rhs.inputs && lhs.outputs == rhs.outputs diff --git a/src/gui/util/qshadergraph_p.h b/src/gui/util/qshadergraph_p.h index 756e1b2da2..9367a3783c 100644 --- a/src/gui/util/qshadergraph_p.h +++ b/src/gui/util/qshadergraph_p.h @@ -73,8 +73,8 @@ public: class Statement { public: - Q_GUI_EXPORT QUuid uuid() const Q_DECL_NOTHROW; - Q_GUI_EXPORT int portIndex(QShaderNodePort::Direction direction, const QString &portName) const Q_DECL_NOTHROW; + Q_GUI_EXPORT QUuid uuid() const noexcept; + Q_GUI_EXPORT int portIndex(QShaderNodePort::Direction direction, const QString &portName) const noexcept; QShaderNode node; QVector inputs; @@ -83,11 +83,11 @@ public: Q_GUI_EXPORT void addNode(const QShaderNode &node); Q_GUI_EXPORT void removeNode(const QShaderNode &node); - Q_GUI_EXPORT QVector nodes() const Q_DECL_NOTHROW; + Q_GUI_EXPORT QVector nodes() const noexcept; Q_GUI_EXPORT void addEdge(const Edge &edge); Q_GUI_EXPORT void removeEdge(const Edge &edge); - Q_GUI_EXPORT QVector edges() const Q_DECL_NOTHROW; + Q_GUI_EXPORT QVector edges() const noexcept; Q_GUI_EXPORT QVector createStatements(const QStringList &enabledLayers = QStringList()) const; @@ -96,16 +96,16 @@ private: QVector m_edges; }; -Q_GUI_EXPORT bool operator==(const QShaderGraph::Edge &lhs, const QShaderGraph::Edge &rhs) Q_DECL_NOTHROW; +Q_GUI_EXPORT bool operator==(const QShaderGraph::Edge &lhs, const QShaderGraph::Edge &rhs) noexcept; -inline bool operator!=(const QShaderGraph::Edge &lhs, const QShaderGraph::Edge &rhs) Q_DECL_NOTHROW +inline bool operator!=(const QShaderGraph::Edge &lhs, const QShaderGraph::Edge &rhs) noexcept { return !(lhs == rhs); } -Q_GUI_EXPORT bool operator==(const QShaderGraph::Statement &lhs, const QShaderGraph::Statement &rhs) Q_DECL_NOTHROW; +Q_GUI_EXPORT bool operator==(const QShaderGraph::Statement &lhs, const QShaderGraph::Statement &rhs) noexcept; -inline bool operator!=(const QShaderGraph::Statement &lhs, const QShaderGraph::Statement &rhs) Q_DECL_NOTHROW +inline bool operator!=(const QShaderGraph::Statement &lhs, const QShaderGraph::Statement &rhs) noexcept { return !(lhs == rhs); } diff --git a/src/gui/util/qshadergraphloader.cpp b/src/gui/util/qshadergraphloader.cpp index 99a9f7869e..7a047f35e9 100644 --- a/src/gui/util/qshadergraphloader.cpp +++ b/src/gui/util/qshadergraphloader.cpp @@ -52,29 +52,29 @@ QT_BEGIN_NAMESPACE void qt_register_ShaderLanguage_enums(); -QShaderGraphLoader::QShaderGraphLoader() Q_DECL_NOTHROW +QShaderGraphLoader::QShaderGraphLoader() noexcept : m_status(Null), m_device(nullptr) { qt_register_ShaderLanguage_enums(); } -QShaderGraphLoader::Status QShaderGraphLoader::status() const Q_DECL_NOTHROW +QShaderGraphLoader::Status QShaderGraphLoader::status() const noexcept { return m_status; } -QShaderGraph QShaderGraphLoader::graph() const Q_DECL_NOTHROW +QShaderGraph QShaderGraphLoader::graph() const noexcept { return m_graph; } -QIODevice *QShaderGraphLoader::device() const Q_DECL_NOTHROW +QIODevice *QShaderGraphLoader::device() const noexcept { return m_device; } -void QShaderGraphLoader::setDevice(QIODevice *device) Q_DECL_NOTHROW +void QShaderGraphLoader::setDevice(QIODevice *device) noexcept { m_device = device; m_graph = QShaderGraph(); @@ -83,12 +83,12 @@ void QShaderGraphLoader::setDevice(QIODevice *device) Q_DECL_NOTHROW : Error; } -QHash QShaderGraphLoader::prototypes() const Q_DECL_NOTHROW +QHash QShaderGraphLoader::prototypes() const noexcept { return m_prototypes; } -void QShaderGraphLoader::setPrototypes(const QHash &prototypes) Q_DECL_NOTHROW +void QShaderGraphLoader::setPrototypes(const QHash &prototypes) noexcept { m_prototypes = prototypes; } diff --git a/src/gui/util/qshadergraphloader_p.h b/src/gui/util/qshadergraphloader_p.h index 97cbd8d18c..e7aa19fa2d 100644 --- a/src/gui/util/qshadergraphloader_p.h +++ b/src/gui/util/qshadergraphloader_p.h @@ -69,16 +69,16 @@ public: Error }; - Q_GUI_EXPORT QShaderGraphLoader() Q_DECL_NOTHROW; + Q_GUI_EXPORT QShaderGraphLoader() noexcept; - Q_GUI_EXPORT Status status() const Q_DECL_NOTHROW; - Q_GUI_EXPORT QShaderGraph graph() const Q_DECL_NOTHROW; + Q_GUI_EXPORT Status status() const noexcept; + Q_GUI_EXPORT QShaderGraph graph() const noexcept; - Q_GUI_EXPORT QIODevice *device() const Q_DECL_NOTHROW; - Q_GUI_EXPORT void setDevice(QIODevice *device) Q_DECL_NOTHROW; + Q_GUI_EXPORT QIODevice *device() const noexcept; + Q_GUI_EXPORT void setDevice(QIODevice *device) noexcept; - Q_GUI_EXPORT QHash prototypes() const Q_DECL_NOTHROW; - Q_GUI_EXPORT void setPrototypes(const QHash &prototypes) Q_DECL_NOTHROW; + Q_GUI_EXPORT QHash prototypes() const noexcept; + Q_GUI_EXPORT void setPrototypes(const QHash &prototypes) noexcept; Q_GUI_EXPORT void load(); diff --git a/src/gui/util/qshadernode.cpp b/src/gui/util/qshadernode.cpp index e570880d1d..547e5c51a8 100644 --- a/src/gui/util/qshadernode.cpp +++ b/src/gui/util/qshadernode.cpp @@ -41,7 +41,7 @@ QT_BEGIN_NAMESPACE -QShaderNode::Type QShaderNode::type() const Q_DECL_NOTHROW +QShaderNode::Type QShaderNode::type() const noexcept { int inputCount = 0; int outputCount = 0; @@ -62,27 +62,27 @@ QShaderNode::Type QShaderNode::type() const Q_DECL_NOTHROW : Function; } -QUuid QShaderNode::uuid() const Q_DECL_NOTHROW +QUuid QShaderNode::uuid() const noexcept { return m_uuid; } -void QShaderNode::setUuid(const QUuid &uuid) Q_DECL_NOTHROW +void QShaderNode::setUuid(const QUuid &uuid) noexcept { m_uuid = uuid; } -QStringList QShaderNode::layers() const Q_DECL_NOTHROW +QStringList QShaderNode::layers() const noexcept { return m_layers; } -void QShaderNode::setLayers(const QStringList &layers) Q_DECL_NOTHROW +void QShaderNode::setLayers(const QStringList &layers) noexcept { m_layers = layers; } -QVector QShaderNode::ports() const Q_DECL_NOTHROW +QVector QShaderNode::ports() const noexcept { return m_ports; } @@ -157,13 +157,13 @@ QShaderNode::Rule QShaderNode::rule(const QShaderFormat &format) const return it != m_rules.crend() ? it->second : Rule(); } -QShaderNode::Rule::Rule(const QByteArray &subs, const QByteArrayList &snippets) Q_DECL_NOTHROW +QShaderNode::Rule::Rule(const QByteArray &subs, const QByteArrayList &snippets) noexcept : substitution(subs), headerSnippets(snippets) { } -bool operator==(const QShaderNode::Rule &lhs, const QShaderNode::Rule &rhs) Q_DECL_NOTHROW +bool operator==(const QShaderNode::Rule &lhs, const QShaderNode::Rule &rhs) noexcept { return lhs.substitution == rhs.substitution && lhs.headerSnippets == rhs.headerSnippets; diff --git a/src/gui/util/qshadernode_p.h b/src/gui/util/qshadernode_p.h index 12ff9b2a2c..c3d149d8a5 100644 --- a/src/gui/util/qshadernode_p.h +++ b/src/gui/util/qshadernode_p.h @@ -73,21 +73,21 @@ public: class Rule { public: - Q_GUI_EXPORT Rule(const QByteArray &substitution = QByteArray(), const QByteArrayList &headerSnippets = QByteArrayList()) Q_DECL_NOTHROW; + Q_GUI_EXPORT Rule(const QByteArray &substitution = QByteArray(), const QByteArrayList &headerSnippets = QByteArrayList()) noexcept; QByteArray substitution; QByteArrayList headerSnippets; }; - Q_GUI_EXPORT Type type() const Q_DECL_NOTHROW; + Q_GUI_EXPORT Type type() const noexcept; - Q_GUI_EXPORT QUuid uuid() const Q_DECL_NOTHROW; - Q_GUI_EXPORT void setUuid(const QUuid &uuid) Q_DECL_NOTHROW; + Q_GUI_EXPORT QUuid uuid() const noexcept; + Q_GUI_EXPORT void setUuid(const QUuid &uuid) noexcept; - Q_GUI_EXPORT QStringList layers() const Q_DECL_NOTHROW; - Q_GUI_EXPORT void setLayers(const QStringList &layers) Q_DECL_NOTHROW; + Q_GUI_EXPORT QStringList layers() const noexcept; + Q_GUI_EXPORT void setLayers(const QStringList &layers) noexcept; - Q_GUI_EXPORT QVector ports() const Q_DECL_NOTHROW; + Q_GUI_EXPORT QVector ports() const noexcept; Q_GUI_EXPORT void addPort(const QShaderNodePort &port); Q_GUI_EXPORT void removePort(const QShaderNodePort &port); @@ -110,9 +110,9 @@ private: QVector> m_rules; }; -Q_GUI_EXPORT bool operator==(const QShaderNode::Rule &lhs, const QShaderNode::Rule &rhs) Q_DECL_NOTHROW; +Q_GUI_EXPORT bool operator==(const QShaderNode::Rule &lhs, const QShaderNode::Rule &rhs) noexcept; -inline bool operator!=(const QShaderNode::Rule &lhs, const QShaderNode::Rule &rhs) Q_DECL_NOTHROW +inline bool operator!=(const QShaderNode::Rule &lhs, const QShaderNode::Rule &rhs) noexcept { return !(lhs == rhs); } diff --git a/src/gui/util/qshadernodeport.cpp b/src/gui/util/qshadernodeport.cpp index 03646a9467..15dbc4160e 100644 --- a/src/gui/util/qshadernodeport.cpp +++ b/src/gui/util/qshadernodeport.cpp @@ -41,12 +41,12 @@ QT_BEGIN_NAMESPACE -QShaderNodePort::QShaderNodePort() Q_DECL_NOTHROW +QShaderNodePort::QShaderNodePort() noexcept : direction(Output) { } -bool operator==(const QShaderNodePort &lhs, const QShaderNodePort &rhs) Q_DECL_NOTHROW +bool operator==(const QShaderNodePort &lhs, const QShaderNodePort &rhs) noexcept { return lhs.direction == rhs.direction && lhs.name == rhs.name; diff --git a/src/gui/util/qshadernodeport_p.h b/src/gui/util/qshadernodeport_p.h index cfdaf05017..c69ba23a3f 100644 --- a/src/gui/util/qshadernodeport_p.h +++ b/src/gui/util/qshadernodeport_p.h @@ -66,15 +66,15 @@ public: Output }; - Q_GUI_EXPORT QShaderNodePort() Q_DECL_NOTHROW; + Q_GUI_EXPORT QShaderNodePort() noexcept; QShaderNodePort::Direction direction; QString name; }; -Q_GUI_EXPORT bool operator==(const QShaderNodePort &lhs, const QShaderNodePort &rhs) Q_DECL_NOTHROW; +Q_GUI_EXPORT bool operator==(const QShaderNodePort &lhs, const QShaderNodePort &rhs) noexcept; -inline bool operator!=(const QShaderNodePort &lhs, const QShaderNodePort &rhs) Q_DECL_NOTHROW +inline bool operator!=(const QShaderNodePort &lhs, const QShaderNodePort &rhs) noexcept { return !(lhs == rhs); } diff --git a/src/gui/util/qshadernodesloader.cpp b/src/gui/util/qshadernodesloader.cpp index 692653ee44..0b5294faf8 100644 --- a/src/gui/util/qshadernodesloader.cpp +++ b/src/gui/util/qshadernodesloader.cpp @@ -48,28 +48,28 @@ QT_BEGIN_NAMESPACE -QShaderNodesLoader::QShaderNodesLoader() Q_DECL_NOTHROW +QShaderNodesLoader::QShaderNodesLoader() noexcept : m_status(Null), m_device(nullptr) { } -QShaderNodesLoader::Status QShaderNodesLoader::status() const Q_DECL_NOTHROW +QShaderNodesLoader::Status QShaderNodesLoader::status() const noexcept { return m_status; } -QHash QShaderNodesLoader::nodes() const Q_DECL_NOTHROW +QHash QShaderNodesLoader::nodes() const noexcept { return m_nodes; } -QIODevice *QShaderNodesLoader::device() const Q_DECL_NOTHROW +QIODevice *QShaderNodesLoader::device() const noexcept { return m_device; } -void QShaderNodesLoader::setDevice(QIODevice *device) Q_DECL_NOTHROW +void QShaderNodesLoader::setDevice(QIODevice *device) noexcept { m_device = device; m_nodes.clear(); diff --git a/src/gui/util/qshadernodesloader_p.h b/src/gui/util/qshadernodesloader_p.h index 0bec871857..432d7d4494 100644 --- a/src/gui/util/qshadernodesloader_p.h +++ b/src/gui/util/qshadernodesloader_p.h @@ -69,13 +69,13 @@ public: Error }; - Q_GUI_EXPORT QShaderNodesLoader() Q_DECL_NOTHROW; + Q_GUI_EXPORT QShaderNodesLoader() noexcept; - Q_GUI_EXPORT Status status() const Q_DECL_NOTHROW; - Q_GUI_EXPORT QHash nodes() const Q_DECL_NOTHROW; + Q_GUI_EXPORT Status status() const noexcept; + Q_GUI_EXPORT QHash nodes() const noexcept; - Q_GUI_EXPORT QIODevice *device() const Q_DECL_NOTHROW; - Q_GUI_EXPORT void setDevice(QIODevice *device) Q_DECL_NOTHROW; + Q_GUI_EXPORT QIODevice *device() const noexcept; + Q_GUI_EXPORT void setDevice(QIODevice *device) noexcept; Q_GUI_EXPORT void load(); Q_GUI_EXPORT void load(const QJsonObject &prototypesObject); diff --git a/src/gui/vulkan/qvulkaninstance.h b/src/gui/vulkan/qvulkaninstance.h index 57459e458c..f28975f911 100644 --- a/src/gui/vulkan/qvulkaninstance.h +++ b/src/gui/vulkan/qvulkaninstance.h @@ -84,14 +84,14 @@ struct QVulkanLayer }; Q_DECLARE_TYPEINFO(QVulkanLayer, Q_MOVABLE_TYPE); -inline bool operator==(const QVulkanLayer &lhs, const QVulkanLayer &rhs) Q_DECL_NOTHROW +inline bool operator==(const QVulkanLayer &lhs, const QVulkanLayer &rhs) noexcept { return lhs.name == rhs.name && lhs.version == rhs.version && lhs.specVersion == rhs.specVersion; } -inline bool operator!=(const QVulkanLayer &lhs, const QVulkanLayer &rhs) Q_DECL_NOTHROW +inline bool operator!=(const QVulkanLayer &lhs, const QVulkanLayer &rhs) noexcept { return !(lhs == rhs); } -inline uint qHash(const QVulkanLayer &key, uint seed = 0) Q_DECL_NOTHROW +inline uint qHash(const QVulkanLayer &key, uint seed = 0) noexcept { QtPrivate::QHashCombine hash; seed = hash(seed, key.name); @@ -107,14 +107,14 @@ struct QVulkanExtension }; Q_DECLARE_TYPEINFO(QVulkanExtension, Q_MOVABLE_TYPE); -inline bool operator==(const QVulkanExtension &lhs, const QVulkanExtension &rhs) Q_DECL_NOTHROW +inline bool operator==(const QVulkanExtension &lhs, const QVulkanExtension &rhs) noexcept { return lhs.name == rhs.name && lhs.version == rhs.version; } -inline bool operator!=(const QVulkanExtension &lhs, const QVulkanExtension &rhs) Q_DECL_NOTHROW +inline bool operator!=(const QVulkanExtension &lhs, const QVulkanExtension &rhs) noexcept { return !(lhs == rhs); } -inline uint qHash(const QVulkanExtension &key, uint seed = 0) Q_DECL_NOTHROW +inline uint qHash(const QVulkanExtension &key, uint seed = 0) noexcept { QtPrivate::QHashCombine hash; seed = hash(seed, key.name); From 1ef274fb947f86731d062df2128718cc8a0cf643 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 2 Apr 2019 11:51:14 +0200 Subject: [PATCH 164/292] Replace qMove with std::move Change-Id: I67df3ae6b5db0a158f86e75b99f422bd13853bc9 Reviewed-by: Thiago Macieira Reviewed-by: Joerg Bornemann --- src/corelib/io/qfilesystemwatcher_fsevents.mm | 4 ++-- src/corelib/io/qnoncontiguousbytedevice.cpp | 2 +- src/corelib/statemachine/qstatemachine_p.h | 2 +- src/corelib/tools/qbytearray.cpp | 4 ++-- src/corelib/tools/qringbuffer.cpp | 2 +- src/corelib/tools/qstring.cpp | 12 ++++++------ src/corelib/tools/qstringalgorithms_p.h | 4 ++-- src/corelib/tools/qvector.h | 4 ++-- src/corelib/tools/qversionnumber.cpp | 2 +- src/dbus/qdbusabstractinterface.cpp | 2 +- src/dbus/qdbusintegrator.cpp | 2 +- src/gui/image/qimage.cpp | 4 ++-- src/gui/image/qimage.h | 4 ++-- src/gui/kernel/qevent.h | 2 +- src/gui/opengl/qopenglgradientcache_p.h | 2 +- src/gui/painting/qbrush.cpp | 4 ++-- src/gui/painting/qpaintengine_raster.cpp | 2 +- src/gui/painting/qtextureglyphcache.cpp | 4 ++-- src/network/access/qhttpnetworkconnection.cpp | 6 +++--- src/network/access/qhttpthreaddelegate.cpp | 2 +- .../windows/qwindowsfontdatabase.cpp | 2 +- src/testlib/qteamcitylogger.cpp | 2 +- src/testlib/qtestcase.cpp | 2 +- src/widgets/dialogs/qerrormessage.cpp | 4 ++-- src/widgets/styles/qstylesheetstyle.cpp | 2 +- .../qstringlistmodel/tst_qstringlistmodel.cpp | 2 +- .../thread/qatomicinteger/tst_qatomicinteger.cpp | 8 ++++---- .../tools/collections/tst_collections.cpp | 2 +- .../corelib/tools/qbytearray/tst_qbytearray.cpp | 16 ++++++++-------- .../tools/qbytearraylist/tst_qbytearraylist.cpp | 10 +++++----- .../qcontiguouscache/tst_qcontiguouscache.cpp | 2 +- .../tools/qsharedpointer/tst_qsharedpointer.cpp | 4 ++-- tests/auto/corelib/tools/qstring/tst_qstring.cpp | 16 ++++++++-------- .../tools/qversionnumber/tst_qversionnumber.cpp | 12 ++++++------ tests/auto/gui/image/qimage/tst_qimage.cpp | 2 +- tests/auto/gui/kernel/qpalette/tst_qpalette.cpp | 4 ++-- tests/auto/gui/painting/qpen/tst_qpen.cpp | 8 ++++---- .../qnetworkdatagram/tst_qnetworkdatagram.cpp | 2 +- .../qprogressdialog/tst_qprogressdialog.cpp | 4 ++-- .../qimageconversion/tst_qimageconversion.cpp | 4 ++-- 40 files changed, 89 insertions(+), 89 deletions(-) diff --git a/src/corelib/io/qfilesystemwatcher_fsevents.mm b/src/corelib/io/qfilesystemwatcher_fsevents.mm index f594fad803..fb3b6f86fd 100644 --- a/src/corelib/io/qfilesystemwatcher_fsevents.mm +++ b/src/corelib/io/qfilesystemwatcher_fsevents.mm @@ -407,7 +407,7 @@ QStringList QFseventsFileSystemWatcherEngine::addPaths(const QStringList &paths, stopStream(); if (!startStream()) { // ok, something went wrong, let's try to restore the previous state - watchingState = qMove(oldState); + watchingState = std::move(oldState); // and because we don't know which path caused the issue (if any), fail on all of them p = paths; @@ -474,7 +474,7 @@ QStringList QFseventsFileSystemWatcherEngine::removePaths(const QStringList &pat if (needsRestart) { if (!restartStream()) { - watchingState = qMove(oldState); + watchingState = std::move(oldState); startStream(); } } diff --git a/src/corelib/io/qnoncontiguousbytedevice.cpp b/src/corelib/io/qnoncontiguousbytedevice.cpp index beca6ccbf7..d1806aa12b 100644 --- a/src/corelib/io/qnoncontiguousbytedevice.cpp +++ b/src/corelib/io/qnoncontiguousbytedevice.cpp @@ -534,7 +534,7 @@ QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QSharedPointer */ QSharedPointer QNonContiguousByteDeviceFactory::createShared(QSharedPointer ringBuffer) { - return QSharedPointer::create(qMove(ringBuffer)); + return QSharedPointer::create(std::move(ringBuffer)); } /*! diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h index 3dc48a1c58..d6fdd72dc1 100644 --- a/src/corelib/statemachine/qstatemachine_p.h +++ b/src/corelib/statemachine/qstatemachine_p.h @@ -227,7 +227,7 @@ public: friend bool operator!=(const RestorableId &lhs, const RestorableId &rhs) noexcept { return !operator==(lhs, rhs); } public: - explicit RestorableId(QObject *o, QByteArray p) noexcept : guard(o), obj(o), prop(qMove(p)) {} + explicit RestorableId(QObject *o, QByteArray p) noexcept : guard(o), obj(o), prop(std::move(p)) {} QObject *object() const noexcept { return guard; } QByteArray propertyName() const noexcept { return prop; } }; diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index a5a473acf4..5f5302107b 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -3282,10 +3282,10 @@ static QByteArray toCase_template(T &input, const uchar * table) } if (firstBad == e) - return qMove(input); + return std::move(input); // transform the rest - QByteArray s = qMove(input); // will copy if T is const QByteArray + QByteArray s = std::move(input); // will copy if T is const QByteArray char *b = s.begin(); // will detach if necessary char *p = b + (firstBad - orig_begin); e = b + s.size(); diff --git a/src/corelib/tools/qringbuffer.cpp b/src/corelib/tools/qringbuffer.cpp index 59650ed2f7..67cce57d01 100644 --- a/src/corelib/tools/qringbuffer.cpp +++ b/src/corelib/tools/qringbuffer.cpp @@ -59,7 +59,7 @@ void QRingChunk::detach() const int chunkSize = size(); QByteArray x(chunkSize, Qt::Uninitialized); ::memcpy(x.data(), chunk.constData() + headOffset, chunkSize); - chunk = qMove(x); + chunk = std::move(x); headOffset = 0; tailOffset = chunkSize; } diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 74debd8cfa..4c5d95d1a1 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -4458,7 +4458,7 @@ int QString::indexOf(const QRegularExpression &re, int from, QRegularExpressionM if (match.hasMatch()) { const int ret = match.capturedStart(); if (rmatch) - *rmatch = qMove(match); + *rmatch = std::move(match); return ret; } @@ -4514,7 +4514,7 @@ int QString::lastIndexOf(const QRegularExpression &re, int from, QRegularExpress if (start < endpos) { lastIndex = start; if (rmatch) - *rmatch = qMove(match); + *rmatch = std::move(match); } else { break; } @@ -4557,7 +4557,7 @@ bool QString::contains(const QRegularExpression &re, QRegularExpressionMatch *ma QRegularExpressionMatch m = re.match(*this); bool hasMatch = m.hasMatch(); if (hasMatch && match) - *match = qMove(m); + *match = std::move(m); return hasMatch; } @@ -4717,7 +4717,7 @@ QString QString::section(const QString &sep, int start, int end, SectionFlags fl class qt_section_chunk { public: qt_section_chunk() {} - qt_section_chunk(int l, QStringRef s) : length(l), string(qMove(s)) {} + qt_section_chunk(int l, QStringRef s) : length(l), string(std::move(s)) {} int length; QStringRef string; }; @@ -6609,7 +6609,7 @@ Q_NEVER_INLINE static QString detachAndConvertCase(T &str, QStringIterator it) { Q_ASSERT(!str.isEmpty()); - QString s = qMove(str); // will copy if T is const QString + QString s = std::move(str); // will copy if T is const QString QChar *pp = s.begin() + it.index(); // will detach if necessary do { @@ -6667,7 +6667,7 @@ static QString convertCase(T &str) return detachAndConvertCase(str, it); } } - return qMove(str); + return std::move(str); } } // namespace QUnicodeTables diff --git a/src/corelib/tools/qstringalgorithms_p.h b/src/corelib/tools/qstringalgorithms_p.h index 4bcf697f78..64d9f2e676 100644 --- a/src/corelib/tools/qstringalgorithms_p.h +++ b/src/corelib/tools/qstringalgorithms_p.h @@ -77,7 +77,7 @@ template struct QStringAlgorithms if (begin != data) memmove(data, begin, (end - begin) * sizeof(Char)); str.resize(end - begin); - return qMove(str); + return std::move(str); } static inline StringType trimmed_helper_inplace(const NakedStringType &, const Char *, const Char *) @@ -118,7 +118,7 @@ template struct QStringAlgorithms const Char *end = str.cend(); NakedStringType result = isConst || !str.isDetached() ? StringType(str.size(), Qt::Uninitialized) : - qMove(str); + std::move(str); Char *dst = const_cast(result.cbegin()); Char *ptr = dst; diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 8aa78ccb1e..096c369e51 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -773,9 +773,9 @@ void QVector::append(const T &t) realloc(isTooSmall ? d->size + 1 : d->alloc, opt); if (QTypeInfo::isComplex) - new (d->end()) T(qMove(copy)); + new (d->end()) T(std::move(copy)); else - *d->end() = qMove(copy); + *d->end() = std::move(copy); } else { if (QTypeInfo::isComplex) diff --git a/src/corelib/tools/qversionnumber.cpp b/src/corelib/tools/qversionnumber.cpp index 6fcb9f50e9..58e3c15560 100644 --- a/src/corelib/tools/qversionnumber.cpp +++ b/src/corelib/tools/qversionnumber.cpp @@ -482,7 +482,7 @@ QVersionNumber QVersionNumber::fromString(QLatin1String string, int *suffixIndex if (suffixIndex) *suffixIndex = int(lastGoodEnd - string.begin()); - return QVersionNumber(qMove(seg)); + return QVersionNumber(std::move(seg)); } void QVersionNumber::SegmentStorage::setVector(int len, int maj, int min, int mic) diff --git a/src/dbus/qdbusabstractinterface.cpp b/src/dbus/qdbusabstractinterface.cpp index d49959d8e2..220223d74d 100644 --- a/src/dbus/qdbusabstractinterface.cpp +++ b/src/dbus/qdbusabstractinterface.cpp @@ -185,7 +185,7 @@ bool QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp, void *retu if (reply.signature() != QLatin1String("v")) { QString errmsg = QLatin1String("Invalid signature `%1' in return from call to " DBUS_INTERFACE_PROPERTIES); - lastError = QDBusError(QDBusError::InvalidSignature, qMove(errmsg).arg(reply.signature())); + lastError = QDBusError(QDBusError::InvalidSignature, std::move(errmsg).arg(reply.signature())); return false; } diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 1125480447..16020aabb1 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1196,7 +1196,7 @@ void QDBusConnectionPrivate::doDispatch() PendingMessageList::Iterator end = pendingMessages.end(); for ( ; it != end; ++it) { qDBusDebug() << this << "dequeueing message" << *it; - handleMessage(qMove(*it)); + handleMessage(std::move(*it)); } pendingMessages.clear(); } diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index c85a51e082..64e24fce44 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -1396,7 +1396,7 @@ void QImage::setColorTable(const QVector colors) #if QT_VERSION >= QT_VERSION_CHECK(6,0,0) d->colortable = colors; #else - d->colortable = qMove(const_cast&>(colors)); + d->colortable = std::move(const_cast&>(colors)); #endif d->has_alpha_clut = false; for (int i = 0; i < d->colortable.size(); ++i) { @@ -5587,7 +5587,7 @@ Q_GUI_EXPORT void qt_imageTransform(QImage &src, QImageIOHandler::Transformation if (orient == QImageIOHandler::TransformationRotate270) { src = rotated270(src); } else { - src = qMove(src).mirrored(orient & QImageIOHandler::TransformationMirror, + src = std::move(src).mirrored(orient & QImageIOHandler::TransformationMirror, orient & QImageIOHandler::TransformationFlip); if (orient & QImageIOHandler::TransformationRotate90) src = rotated90(src); diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index a4ec7aa69b..9d177142d9 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -291,11 +291,11 @@ public: QImage mirrored(bool horizontally = false, bool vertically = true) const & { return mirrored_helper(horizontally, vertically); } QImage &&mirrored(bool horizontally = false, bool vertically = true) && - { mirrored_inplace(horizontally, vertically); return qMove(*this); } + { mirrored_inplace(horizontally, vertically); return std::move(*this); } QImage rgbSwapped() const & { return rgbSwapped_helper(); } QImage &&rgbSwapped() && - { rgbSwapped_inplace(); return qMove(*this); } + { rgbSwapped_inplace(); return std::move(*this); } #else QImage mirrored(bool horizontally = false, bool vertically = true) const; QImage rgbSwapped() const; diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index de175bc334..aeefb53819 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -549,7 +549,7 @@ public: }; class Attribute { public: - Attribute(AttributeType typ, int s, int l, QVariant val) : type(typ), start(s), length(l), value(qMove(val)) {} + Attribute(AttributeType typ, int s, int l, QVariant val) : type(typ), start(s), length(l), value(std::move(val)) {} Attribute(AttributeType typ, int s, int l) : type(typ), start(s), length(l), value() {} AttributeType type; diff --git a/src/gui/opengl/qopenglgradientcache_p.h b/src/gui/opengl/qopenglgradientcache_p.h index cbdbbb0c54..1d34223bdd 100644 --- a/src/gui/opengl/qopenglgradientcache_p.h +++ b/src/gui/opengl/qopenglgradientcache_p.h @@ -66,7 +66,7 @@ class QOpenGL2GradientCache : public QOpenGLSharedResource struct CacheInfo { inline CacheInfo(QGradientStops s, qreal op, QGradient::InterpolationMode mode) : - stops(qMove(s)), opacity(op), interpolationMode(mode) {} + stops(std::move(s)), opacity(op), interpolationMode(mode) {} GLuint texId; QGradientStops stops; diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp index ed575abf54..1aa0ee14be 100644 --- a/src/gui/painting/qbrush.cpp +++ b/src/gui/painting/qbrush.cpp @@ -1140,11 +1140,11 @@ QDataStream &operator>>(QDataStream &s, QBrush &b) if (s.version() >= QDataStream::Qt_5_5) { QImage img; s >> img; - b.setTextureImage(qMove(img)); + b.setTextureImage(std::move(img)); } else { QPixmap pm; s >> pm; - b.setTexture(qMove(pm)); + b.setTexture(std::move(pm)); } } else if (style == Qt::LinearGradientPattern || style == Qt::RadialGradientPattern diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index afa540380f..2c99671d0b 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -4244,7 +4244,7 @@ public: struct CacheInfo : QSpanData::Pinnable { inline CacheInfo(QGradientStops s, int op, QGradient::InterpolationMode mode) : - stops(qMove(s)), opacity(op), interpolationMode(mode) {} + stops(std::move(s)), opacity(op), interpolationMode(mode) {} QRgba64 buffer64[GRADIENT_STOPTABLE_SIZE]; QRgb buffer32[GRADIENT_STOPTABLE_SIZE]; QGradientStops stops; diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index 99b04aaba6..c21f2cdda4 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -73,7 +73,7 @@ int QTextureGlyphCache::calculateSubPixelPositionCount(glyph_t glyph) const if (path.isEmpty()) break; - images[numImages++] = qMove(img); + images[numImages++] = std::move(img); } else { bool found = false; for (int j = 0; j < numImages; ++j) { @@ -83,7 +83,7 @@ int QTextureGlyphCache::calculateSubPixelPositionCount(glyph_t glyph) const } } if (!found) - images[numImages++] = qMove(img); + images[numImages++] = std::move(img); } } diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index ee1e3cfb8f..0a37122fc6 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -1318,7 +1318,7 @@ QHttpNetworkConnection::QHttpNetworkConnection(const QString &hostName, quint16 : QObject(*(new QHttpNetworkConnectionPrivate(hostName, port, encrypt, connectionType)), parent) { Q_D(QHttpNetworkConnection); - d->networkSession = qMove(networkSession); + d->networkSession = std::move(networkSession); d->init(); } @@ -1330,7 +1330,7 @@ QHttpNetworkConnection::QHttpNetworkConnection(quint16 connectionCount, const QS connectionType)), parent) { Q_D(QHttpNetworkConnection); - d->networkSession = qMove(networkSession); + d->networkSession = std::move(networkSession); d->init(); } #else @@ -1477,7 +1477,7 @@ QSharedPointer QHttpNetworkConnection::sslContext() void QHttpNetworkConnection::setSslContext(QSharedPointer context) { Q_D(QHttpNetworkConnection); - d->sslContext = qMove(context); + d->sslContext = std::move(context); } void QHttpNetworkConnection::ignoreSslErrors(int channel) diff --git a/src/network/access/qhttpthreaddelegate.cpp b/src/network/access/qhttpthreaddelegate.cpp index 1fdf28df9d..6fb4710d77 100644 --- a/src/network/access/qhttpthreaddelegate.cpp +++ b/src/network/access/qhttpthreaddelegate.cpp @@ -189,7 +189,7 @@ public: QHttpNetworkConnection::ConnectionType connectionType, QSharedPointer networkSession) : QHttpNetworkConnection(hostName, port, encrypt, connectionType, /*parent=*/0, - qMove(networkSession)) + std::move(networkSession)) #endif { setExpires(true); diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp index ff0efaac1a..702cfbdc62 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp @@ -1512,7 +1512,7 @@ static void getFamiliesAndSignatures(const QByteArray &fontData, if (names.name.isEmpty()) continue; - families->append(qMove(names)); + families->append(std::move(names)); if (values || signatures) getFontTable(data, font, MAKE_TAG('O', 'S', '/', '2'), &table, &length); diff --git a/src/testlib/qteamcitylogger.cpp b/src/testlib/qteamcitylogger.cpp index 577c8e70cd..88c83d1269 100644 --- a/src/testlib/qteamcitylogger.cpp +++ b/src/testlib/qteamcitylogger.cpp @@ -251,7 +251,7 @@ QString QTeamCityLogger::tcEscapedString(const QString &str) const } } - return qMove(formattedString).simplified(); + return std::move(formattedString).simplified(); } QString QTeamCityLogger::escapedTestFuncName() const diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index a202add2ae..db44b3860a 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -2148,7 +2148,7 @@ QSharedPointer QTest::qExtractTestData(const QString &dirName) } } - result = qMove(tempDir); + result = std::move(tempDir); return result; } diff --git a/src/widgets/dialogs/qerrormessage.cpp b/src/widgets/dialogs/qerrormessage.cpp index fd68f19680..51a3e080bf 100644 --- a/src/widgets/dialogs/qerrormessage.cpp +++ b/src/widgets/dialogs/qerrormessage.cpp @@ -322,8 +322,8 @@ bool QErrorMessagePrivate::nextPending() #else errors->setPlainText(message); #endif - currentMessage = qMove(message); - currentType = qMove(type); + currentMessage = std::move(message); + currentType = std::move(type); return true; } } diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index f5a3724100..956c2be3a9 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -851,7 +851,7 @@ QHash QStyleSheetStyle::titleBarLayout(const QWidget info.rule = subRule; info.offset = offsets[where]; info.where = where; - infos.append(qMove(info)); + infos.append(std::move(info)); offsets[where] += info.width; } diff --git a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp index 0b8686560c..3919472b96 100644 --- a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp +++ b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp @@ -333,7 +333,7 @@ template C sorted(C c) { std::sort(c.begin(), c.end()); - return qMove(c); + return std::move(c); } void tst_QStringListModel::setData_emits_both_roles() diff --git a/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp b/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp index 32e5b8ee56..3a98732f9d 100644 --- a/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp +++ b/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp @@ -291,10 +291,10 @@ void tst_QAtomicIntegerXX::copy() QCOMPARE(copy2.load(), atomic.load()); // move - QAtomicInteger copy3(qMove(copy)); + QAtomicInteger copy3(std::move(copy)); QCOMPARE(copy3.load(), atomic.load()); - QAtomicInteger copy4 = qMove(copy2); + QAtomicInteger copy4 = std::move(copy2); QCOMPARE(copy4.load(), atomic.load()); } @@ -317,11 +317,11 @@ void tst_QAtomicIntegerXX::assign() // move QAtomicInteger copy3; - copy3 = qMove(copy); + copy3 = std::move(copy); QCOMPARE(copy3.load(), atomic.load()); QAtomicInteger copy4; - copy4 = qMove(copy2); + copy4 = std::move(copy2); QCOMPARE(copy4.load(), atomic.load()); } diff --git a/tests/auto/corelib/tools/collections/tst_collections.cpp b/tests/auto/corelib/tools/collections/tst_collections.cpp index b40b1f0624..104de4d783 100644 --- a/tests/auto/corelib/tools/collections/tst_collections.cpp +++ b/tests/auto/corelib/tools/collections/tst_collections.cpp @@ -2425,7 +2425,7 @@ void testContainer() c1 = newInstance(); QVERIFY(c1.size() == 4); QVERIFY(c1 == newInstance()); - Container c2 = qMove(c1); + Container c2 = std::move(c1); QVERIFY(c2.size() == 4); QVERIFY(c2 == newInstance()); } diff --git a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp index d9e03439b8..2dbf86c2f5 100644 --- a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp @@ -2245,28 +2245,28 @@ void tst_QByteArray::toUpperLower() QCOMPARE(input.toLower(), lower); QByteArray copy = input; - QCOMPARE(qMove(copy).toUpper(), upper); + QCOMPARE(std::move(copy).toUpper(), upper); copy = input; copy.detach(); - QCOMPARE(qMove(copy).toUpper(), upper); + QCOMPARE(std::move(copy).toUpper(), upper); copy = input; - QCOMPARE(qMove(copy).toLower(), lower); + QCOMPARE(std::move(copy).toLower(), lower); copy = input; copy.detach(); - QCOMPARE(qMove(copy).toLower(), lower); + QCOMPARE(std::move(copy).toLower(), lower); copy = lower; - QCOMPARE(qMove(copy).toLower(), lower); + QCOMPARE(std::move(copy).toLower(), lower); copy = lower; copy.detach(); - QCOMPARE(qMove(copy).toLower(), lower); + QCOMPARE(std::move(copy).toLower(), lower); copy = upper; - QCOMPARE(qMove(copy).toUpper(), upper); + QCOMPARE(std::move(copy).toUpper(), upper); copy = upper; copy.detach(); - QCOMPARE(qMove(copy).toUpper(), upper); + QCOMPARE(std::move(copy).toUpper(), upper); } void tst_QByteArray::isUpper() diff --git a/tests/auto/corelib/tools/qbytearraylist/tst_qbytearraylist.cpp b/tests/auto/corelib/tools/qbytearraylist/tst_qbytearraylist.cpp index 2d2c536453..a28bbc12c8 100644 --- a/tests/auto/corelib/tools/qbytearraylist/tst_qbytearraylist.cpp +++ b/tests/auto/corelib/tools/qbytearraylist/tst_qbytearraylist.cpp @@ -194,22 +194,22 @@ void tst_QByteArrayList::operator_plus() const { QByteArrayList bal1 = lhs; const QByteArrayList bal2 = rhs; - QCOMPARE(qMove(bal1) + bal2, expectedResult); + QCOMPARE(std::move(bal1) + bal2, expectedResult); } { QList lba1 = lhs; const QByteArrayList bal2 = rhs; - QCOMPARE(qMove(lba1) + bal2, expectedResult); + QCOMPARE(std::move(lba1) + bal2, expectedResult); } { QByteArrayList bal1 = lhs; const QList lba2 = rhs; - QCOMPARE(qMove(bal1) + lba2, expectedResult); + QCOMPARE(std::move(bal1) + lba2, expectedResult); } { QList lba1 = lhs; const QList lba2 = rhs; - QCOMPARE(qMove(lba1) + lba2, QList(expectedResult)); // check we don't mess with old code + QCOMPARE(std::move(lba1) + lba2, QList(expectedResult)); // check we don't mess with old code } // operator += for const lvalues @@ -232,7 +232,7 @@ void tst_QByteArrayList::operator_plus() const QByteArrayList t1 = lhs; QByteArrayList t2 = rhs; - QCOMPARE(qMove(t1) + t2, expectedResult); + QCOMPARE(std::move(t1) + t2, expectedResult); } void tst_QByteArrayList::operator_plus_data() const diff --git a/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp b/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp index 31a5f93822..9b45e17a28 100644 --- a/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp +++ b/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp @@ -68,7 +68,7 @@ void tst_QContiguousCache::assignment() // copy: cc1 = cc2; // move: - cc1 = qMove(cc2); + cc1 = std::move(cc2); } void tst_QContiguousCache::empty() diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index ade9c5e754..ebec83403a 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -573,10 +573,10 @@ void tst_QSharedPointer::useOfForwardDeclared() // move assignment: QSharedPointer sp4; - sp4 = qMove(sp); + sp4 = std::move(sp); // and move constuction: - QSharedPointer sp5 = qMove(sp2); + QSharedPointer sp5 = std::move(sp2); // swapping: sp4.swap(sp3); diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index e25c9e8395..d891ef7e12 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -2202,12 +2202,12 @@ void tst_QString::toUpper() // call rvalue-ref while shared (the original mustn't change) QString copy = s; - QCOMPARE(qMove(copy).toUpper(), QString("GROSSSTRASSE")); + QCOMPARE(std::move(copy).toUpper(), QString("GROSSSTRASSE")); QCOMPARE(s, QString::fromUtf8("Gro\xc3\x9fstra\xc3\x9f""e")); // call rvalue-ref version on detached case copy.clear(); - QCOMPARE(qMove(s).toUpper(), QString("GROSSSTRASSE")); + QCOMPARE(std::move(s).toUpper(), QString("GROSSSTRASSE")); } QString lower, upper; @@ -2417,11 +2417,11 @@ void tst_QString::trimmed() QCOMPARE(a.trimmed(), QLatin1String("a")); a="Text"; - QCOMPARE(qMove(a).trimmed(), QLatin1String("Text")); + QCOMPARE(std::move(a).trimmed(), QLatin1String("Text")); a=" "; - QCOMPARE(qMove(a).trimmed(), QLatin1String("")); + QCOMPARE(std::move(a).trimmed(), QLatin1String("")); a=" a "; - QCOMPARE(qMove(a).trimmed(), QLatin1String("a")); + QCOMPARE(std::move(a).trimmed(), QLatin1String("a")); } void tst_QString::simplified_data() @@ -2476,13 +2476,13 @@ void tst_QString::simplified() // without detaching: QString copy1 = full; - QCOMPARE(qMove(full).simplified(), simple); + QCOMPARE(std::move(full).simplified(), simple); QCOMPARE(full, orig_full); // force a detach if (!full.isEmpty()) full[0] = full[0]; - QCOMPARE(qMove(full).simplified(), simple); + QCOMPARE(std::move(full).simplified(), simple); } void tst_QString::insert_data(bool emptyIsNoop) @@ -4524,7 +4524,7 @@ void tst_QString::toLatin1Roundtrip() // try the rvalue version of toLatin1() QString s = unicodesrc; - QCOMPARE(qMove(s).toLatin1(), latin1); + QCOMPARE(std::move(s).toLatin1(), latin1); // and verify that the moved-from object can still be used s = "foo"; diff --git a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp index 05579dce6e..aaf40a9c2e 100644 --- a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp +++ b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp @@ -436,7 +436,7 @@ void tst_QVersionNumber::normalized() QFETCH(QVersionNumber, expected); QCOMPARE(version.normalized(), expected); - QCOMPARE(qMove(version).normalized(), expected); + QCOMPARE(std::move(version).normalized(), expected); } void tst_QVersionNumber::isNormalized_data() @@ -590,21 +590,21 @@ void tst_QVersionNumber::moveSemantics() // QVersionNumber(QVersionNumber &&) { QVersionNumber v1(1, 2, 3); - QVersionNumber v2 = qMove(v1); + QVersionNumber v2 = std::move(v1); QCOMPARE(v2, QVersionNumber(1, 2, 3)); } // QVersionNumber &operator=(QVersionNumber &&) { QVersionNumber v1(1, 2, 3); QVersionNumber v2; - v2 = qMove(v1); + v2 = std::move(v1); QCOMPARE(v2, QVersionNumber(1, 2, 3)); } // QVersionNumber(QVector &&) { QVector segments = QVector() << 1 << 2 << 3; QVersionNumber v1(segments); - QVersionNumber v2(qMove(segments)); + QVersionNumber v2(std::move(segments)); QVERIFY(!v1.isNull()); QVERIFY(!v2.isNull()); QCOMPARE(v1, v2); @@ -620,7 +620,7 @@ void tst_QVersionNumber::moveSemantics() QVERIFY(!v.isNull()); QVERIFY(!nv.isNull()); QVERIFY(nv.isNormalized()); - nv = qMove(v).normalized(); + nv = std::move(v).normalized(); QVERIFY(!nv.isNull()); QVERIFY(nv.isNormalized()); } @@ -632,7 +632,7 @@ void tst_QVersionNumber::moveSemantics() segments = v.segments(); QVERIFY(!v.isNull()); QVERIFY(!segments.empty()); - segments = qMove(v).segments(); + segments = std::move(v).segments(); QVERIFY(!segments.empty()); } #endif diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 4d41b5e873..50eb61b219 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -3403,7 +3403,7 @@ void tst_QImage::ditherGradient_data() QTest::newRow("rgb32 -> rgb666 (dithering)") << rgb32 << QImage::Format_RGB666 << int(Qt::PreferDither | Qt::OrderedDither) << 129; // Test we get the same results for opaque input in the ARGBPM implementation. - rgb32 = qMove(rgb32).convertToFormat(QImage::Format_ARGB32_Premultiplied); + rgb32 = std::move(rgb32).convertToFormat(QImage::Format_ARGB32_Premultiplied); QTest::newRow("argb32pm -> argb4444pm (no dither)") << rgb32 << QImage::Format_ARGB4444_Premultiplied << 0 << 16; QTest::newRow("argb32pm -> rgb444 (dithering)") << rgb32 << QImage::Format_RGB444 << int(Qt::PreferDither | Qt::OrderedDither) << 33; QTest::newRow("argb32pm -> argb4444pm (dithering)") << rgb32 << QImage::Format_ARGB4444_Premultiplied << int(Qt::PreferDither | Qt::OrderedDither) << 33; diff --git a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp index 7f29b1c24e..234793a7cf 100644 --- a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp +++ b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp @@ -148,14 +148,14 @@ void tst_QPalette::moveSemantics() QCOMPARE(src, control); QVERIFY(!dst.isCopyOf(src)); QVERIFY(!dst.isCopyOf(control)); - dst = qMove(src); // move assignment + dst = std::move(src); // move assignment QVERIFY(!dst.isCopyOf(src)); // isCopyOf() works on moved-from palettes, too QVERIFY(dst.isCopyOf(control)); QCOMPARE(dst, control); src = control; // check moved-from 'src' can still be assigned to (doesn't crash) QVERIFY(src.isCopyOf(dst)); QVERIFY(src.isCopyOf(control)); - QPalette dst2(qMove(src)); // move construction + QPalette dst2(std::move(src)); // move construction QVERIFY(!src.isCopyOf(dst)); QVERIFY(!src.isCopyOf(dst2)); QVERIFY(!src.isCopyOf(control)); diff --git a/tests/auto/gui/painting/qpen/tst_qpen.cpp b/tests/auto/gui/painting/qpen/tst_qpen.cpp index ef65d653ce..295ae27d17 100644 --- a/tests/auto/gui/painting/qpen/tst_qpen.cpp +++ b/tests/auto/gui/painting/qpen/tst_qpen.cpp @@ -95,7 +95,7 @@ void tst_QPen::move() QPen p1(Qt::black); // check that moving does the right thing: - QPen p2 = qMove(p1); // could be move or copy construction, so don't check p1's state + QPen p2 = std::move(p1); // could be move or copy construction, so don't check p1's state QCOMPARE(p2.color(), QColor(Qt::black)); // this, executed ehre, would crash: @@ -110,7 +110,7 @@ void tst_QPen::move() QCOMPARE(p1.color(), QColor(Qt::yellow)); // check that moved-from QPens p2, p3 can still be safely destroyed: - QPen p5 = qMove(p2); + QPen p5 = std::move(p2); // intentionally no more statements beyond this point } @@ -120,7 +120,7 @@ void tst_QPen::move_assign() QPen p1(Qt::black), p2(Qt::white); // check that moving does the right thing: - p2 = qMove(p1); // could be move or copy assignment, so don't check p1's state + p2 = std::move(p1); // could be move or copy assignment, so don't check p1's state QCOMPARE(p2.color(), QColor(Qt::black)); // check that move-assigned-from QPen p1 can still be used, albeit @@ -137,7 +137,7 @@ void tst_QPen::move_assign() // check that moved-from QPens p2, p3 can still be safely destroyed: QPen p5; - p5 = qMove(p2); + p5 = std::move(p2); // intentionally no more statements beyond this point } diff --git a/tests/auto/network/kernel/qnetworkdatagram/tst_qnetworkdatagram.cpp b/tests/auto/network/kernel/qnetworkdatagram/tst_qnetworkdatagram.cpp index 5eedd1043b..cd6019090f 100644 --- a/tests/auto/network/kernel/qnetworkdatagram/tst_qnetworkdatagram.cpp +++ b/tests/auto/network/kernel/qnetworkdatagram/tst_qnetworkdatagram.cpp @@ -131,7 +131,7 @@ void tst_QNetworkDatagram::makeReply() QNetworkDatagram copy = dgram; copy.setData(copy.data()); { - QNetworkDatagram reply = qMove(copy).makeReply("World"); + QNetworkDatagram reply = std::move(copy).makeReply("World"); QCOMPARE(reply.data(), QByteArray("World")); QCOMPARE(reply.senderAddress(), QHostAddress(localAddress)); QCOMPARE(reply.senderPort(), localAddress.isEmpty() ? -1 : dgram.destinationPort()); diff --git a/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp b/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp index 2ada4fedb6..6f527e7b6b 100644 --- a/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp +++ b/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp @@ -252,7 +252,7 @@ class QTestTranslator : public QTranslator { const QString m_str; public: - explicit QTestTranslator(QString str) : m_str(qMove(str)) {} + explicit QTestTranslator(QString str) : m_str(std::move(str)) {} QString translate(const char *, const char *sourceText, const char *, int) const override { return m_str + sourceText + m_str; } @@ -265,7 +265,7 @@ class QTranslatorGuard { Translator t; public: template - explicit QTranslatorGuard(Arg a) : t(qMove(a)) + explicit QTranslatorGuard(Arg a) : t(std::move(a)) { qApp->installTranslator(&t); } ~QTranslatorGuard() { qApp->removeTranslator(&t); } diff --git a/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp b/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp index 605df100ee..570c7b59fa 100644 --- a/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp +++ b/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp @@ -357,10 +357,10 @@ void tst_QImageConversion::convertGenericInplace() QFETCH(QImage::Format, outputFormat); QImage::Format inputFormat = inputImage.format(); - QImage tmpImage = qMove(inputImage); + QImage tmpImage = std::move(inputImage); QBENCHMARK { - tmpImage = (qMove(tmpImage).convertToFormat(outputFormat)).convertToFormat(inputFormat); + tmpImage = (std::move(tmpImage).convertToFormat(outputFormat)).convertToFormat(inputFormat); } } From 4628e5cded8b1b4f064b75f23436bc6fc66ce043 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 2 Apr 2019 11:56:33 +0200 Subject: [PATCH 165/292] Remove handling of missing very old compiler feature check Removes handling of missing Q_COMPILER_NULLPTR, Q_COMPILER_AUTODECL, Q_COMPILER_LAMBDA, Q_COMPILER_VARIADIC_MACROS and Q_COMPILER_AUTO_FUNCTION. We haven't supported any compilers without these for a long time. Change-Id: I3df88206516a25763e2c28b083733780f35a8764 Reviewed-by: Thiago Macieira --- src/concurrent/qtconcurrentrun.h | 8 ----- src/corelib/io/qdebug.h | 2 -- src/corelib/io/qloggingcategory.h | 35 ------------------- src/corelib/kernel/qobjectdefs.h | 12 ++----- src/corelib/tools/qarraydata.h | 30 ---------------- src/corelib/tools/qstring.cpp | 4 +-- src/testlib/qtestcase.h | 8 ----- .../qtconcurrentmap/tst_qtconcurrentmap.cpp | 5 --- .../qtconcurrentrun/tst_qtconcurrentrun.cpp | 8 ----- .../corelib/global/qlogging/tst_qlogging.cpp | 8 ----- .../qloggingcategory/tst_qloggingcategory.cpp | 4 --- .../kernel/qmetatype/tst_qmetatype.cpp | 8 ++--- .../corelib/kernel/qobject/tst_qobject.cpp | 12 +------ .../tools/qarraydata/tst_qarraydata.cpp | 6 ---- .../tools/qbytearray/tst_qbytearray.cpp | 4 --- .../qsharedpointer/tst_qsharedpointer.cpp | 6 ---- .../corelib/tools/qstring/tst_qstring.cpp | 4 +-- tests/auto/tools/moc/parse-defines.h | 11 ------ 18 files changed, 10 insertions(+), 165 deletions(-) diff --git a/src/concurrent/qtconcurrentrun.h b/src/concurrent/qtconcurrentrun.h index 6001010a78..22dae70460 100644 --- a/src/concurrent/qtconcurrentrun.h +++ b/src/concurrent/qtconcurrentrun.h @@ -99,8 +99,6 @@ QFuture run(T (*functionPointer)(Param1, Param2, Param3, Param4, Param5), con return (new StoredFunctorCall5(functionPointer, arg1, arg2, arg3, arg4, arg5))->start(); } -#if defined(Q_COMPILER_DECLTYPE) && defined(Q_COMPILER_AUTO_FUNCTION) - template auto run(Functor functor) -> typename std::enable_if::Value, QFuture>::type { @@ -148,8 +146,6 @@ auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, return (new StoredFunctorCall5(functor, arg1, arg2, arg3, arg4, arg5))->start(); } -#endif - template QFuture run(FunctionObject functionObject) { @@ -370,8 +366,6 @@ QFuture run(QThreadPool *pool, T (*functionPointer)(Param1, Param2, Param3, P return (new StoredFunctorCall5(functionPointer, arg1, arg2, arg3, arg4, arg5))->start(pool); } -#if defined(Q_COMPILER_DECLTYPE) && defined(Q_COMPILER_AUTO_FUNCTION) - template auto run(QThreadPool *pool, Functor functor) -> typename std::enable_if::Value, QFuture>::type { @@ -419,8 +413,6 @@ auto run(QThreadPool *pool, Functor functor, const Arg1 &arg1, const Arg2 &arg2, return (new StoredFunctorCall5(functor, arg1, arg2, arg3, arg4, arg5))->start(pool); } -#endif - template QFuture run(QThreadPool *pool, FunctionObject functionObject) { diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index ea2d57370d..f9dc4203db 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -161,9 +161,7 @@ public: inline QDebug &operator<<(QLatin1String t) { putByteArray(t.latin1(), t.size(), ContainsLatin1); return maybeSpace(); } inline QDebug &operator<<(const QByteArray & t) { putByteArray(t.constData(), t.size(), ContainsBinary); return maybeSpace(); } inline QDebug &operator<<(const void * t) { stream->ts << t; return maybeSpace(); } -#ifdef Q_COMPILER_NULLPTR inline QDebug &operator<<(std::nullptr_t) { stream->ts << "(nullptr)"; return maybeSpace(); } -#endif inline QDebug &operator<<(QTextStreamFunction f) { stream->ts << f; return *this; diff --git a/src/corelib/io/qloggingcategory.h b/src/corelib/io/qloggingcategory.h index 91e3144300..5825095729 100644 --- a/src/corelib/io/qloggingcategory.h +++ b/src/corelib/io/qloggingcategory.h @@ -111,8 +111,6 @@ private: #define Q_DECLARE_LOGGING_CATEGORY(name) \ extern const QLoggingCategory &name(); -#if defined(Q_COMPILER_VARIADIC_MACROS) || defined(Q_MOC_RUN) - #define Q_LOGGING_CATEGORY(name, ...) \ const QLoggingCategory &name() \ { \ @@ -148,39 +146,6 @@ private: for (bool qt_category_enabled = category().isCriticalEnabled(); qt_category_enabled; qt_category_enabled = false) \ QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC, category().categoryName()).critical(__VA_ARGS__) -#else // defined(Q_COMPILER_VARIADIC_MACROS) || defined(Q_MOC_RUN) - -// Optional msgType argument not supported -#define Q_LOGGING_CATEGORY(name, string) \ - const QLoggingCategory &name() \ - { \ - static const QLoggingCategory category(string); \ - return category; \ - } - -// check for enabled category inside QMessageLogger. -#if !defined(QT_NO_DEBUG_OUTPUT) -# define qCDebug qDebug -#else -# define qCDebug(category) QT_NO_QDEBUG_MACRO() -#endif - -#if !defined(QT_NO_INFO_OUTPUT) -# define qCInfo qInfo -#else -# define qCInfo(category) QT_NO_QDEBUG_MACRO() -#endif - -#if !defined(QT_NO_WARNING_OUTPUT) -# define qCWarning qWarning -#else -# define qCWarning(category) QT_NO_QDEBUG_MACRO() -#endif - -#define qCCritical qCritical - -#endif // Q_COMPILER_VARIADIC_MACROS || defined(Q_MOC_RUN) - QT_END_NAMESPACE #endif // QLOGGINGCATEGORY_H diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index a437a994fd..28674193c3 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -64,11 +64,7 @@ class QString; // The following macros can be defined by tools that understand Qt // to have the information from the macro. #ifndef QT_ANNOTATE_CLASS -# ifndef Q_COMPILER_VARIADIC_MACROS -# define QT_ANNOTATE_CLASS(type, x) -# else -# define QT_ANNOTATE_CLASS(type, ...) -# endif +# define QT_ANNOTATE_CLASS(type, ...) #endif #ifndef QT_ANNOTATE_CLASS2 # define QT_ANNOTATE_CLASS2(type, a1, a2) @@ -105,11 +101,7 @@ class QString; #endif #define Q_PLUGIN_METADATA(x) QT_ANNOTATE_CLASS(qt_plugin_metadata, x) #define Q_INTERFACES(x) QT_ANNOTATE_CLASS(qt_interfaces, x) -#ifdef Q_COMPILER_VARIADIC_MACROS -# define Q_PROPERTY(...) QT_ANNOTATE_CLASS(qt_property, __VA_ARGS__) -#else -# define Q_PROPERTY(text) QT_ANNOTATE_CLASS(qt_property, text) -#endif +#define Q_PROPERTY(...) QT_ANNOTATE_CLASS(qt_property, __VA_ARGS__) #define Q_PRIVATE_PROPERTY(d, text) QT_ANNOTATE_CLASS2(qt_private_property, d, text) #ifndef Q_REVISION # define Q_REVISION(v) diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index f78b9be2db..7e3f8c9dbd 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -306,8 +306,6 @@ struct QArrayDataPointerRef // accomplished by hiding a static const instance of QStaticArrayData, which is // POD. -#if defined(Q_COMPILER_VARIADIC_MACROS) -#if defined(Q_COMPILER_LAMBDA) // Hide array inside a lambda #define Q_ARRAY_LITERAL(Type, ...) \ ([]() -> QArrayDataPointerRef { \ @@ -324,10 +322,7 @@ struct QArrayDataPointerRef return StaticWrapper::get(); \ }()) \ /**/ -#endif -#endif // defined(Q_COMPILER_VARIADIC_MACROS) -#if defined(Q_ARRAY_LITERAL) #define Q_ARRAY_LITERAL_IMPL(Type, ...) \ union { Type type_must_be_POD; } dummy; Q_UNUSED(dummy) \ \ @@ -342,31 +337,6 @@ struct QArrayDataPointerRef { static_cast *>( \ const_cast(&literal.header)) }; \ /**/ -#else -// As a fallback, memory is allocated and data copied to the heap. - -// The fallback macro does NOT use variadic macros and does NOT support -// variable number of arguments. It is suitable for char arrays. - -namespace QtPrivate { - template - inline QArrayDataPointerRef qMakeArrayLiteral(const T (&array)[N]) - { - union { T type_must_be_POD; } dummy; Q_UNUSED(dummy) - - QArrayDataPointerRef result = { QTypedArrayData::allocate(N) }; - Q_CHECK_PTR(result.ptr); - - ::memcpy(result.ptr->data(), array, N * sizeof(T)); - result.ptr->size = N; - - return result; - } -} - -#define Q_ARRAY_LITERAL(Type, Array) \ - QT_PREPEND_NAMESPACE(QtPrivate::qMakeArrayLiteral)( Array ) -#endif // !defined(Q_ARRAY_LITERAL) namespace QtPrivate { struct Q_CORE_EXPORT QContainerImplHelper diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 4c5d95d1a1..39cb016d98 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -201,7 +201,7 @@ qsizetype QtPrivate::qustrlen(const ushort *str) noexcept return result; } -#if defined(Q_COMPILER_LAMBDA) && !defined(__OPTIMIZE_SIZE__) +#if !defined(__OPTIMIZE_SIZE__) namespace { template struct UnrollTailLoop { @@ -627,7 +627,7 @@ void qt_from_latin1(ushort *dst, const char *str, size_t size) noexcept size = size % 8; dst += offset; str += offset; -# if defined(Q_COMPILER_LAMBDA) && !defined(__OPTIMIZE_SIZE__) +# if !defined(__OPTIMIZE_SIZE__) return UnrollTailLoop<7>::exec(int(size), [=](int i) { dst[i] = (uchar)str[i]; }); # endif #endif diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index 5d566b835e..794283ff78 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -189,16 +189,8 @@ do {\ return;\ } while (false) -#ifdef Q_COMPILER_VARIADIC_MACROS - #define QSKIP(statement, ...) QSKIP_INTERNAL(statement) -#else - -#define QSKIP(statement) QSKIP_INTERNAL(statement) - -#endif - #define QEXPECT_FAIL(dataIndex, comment, mode)\ do {\ if (!QTest::qExpectFail(dataIndex, static_cast(comment), QTest::mode, __FILE__, __LINE__))\ diff --git a/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp b/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp index b864b065e6..9b71994b84 100644 --- a/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp +++ b/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp @@ -127,14 +127,11 @@ void tst_QtConcurrentMap::map() QtConcurrent::map(numberList.begin(), numberList.end(), &Number::multiplyBy2).waitForFinished(); QCOMPARE(numberList, QList() << 4 << 8 << 12); -#ifdef Q_COMPILER_LAMBDA // lambda QtConcurrent::map(list, [](int &x){x *= 2;}).waitForFinished(); QCOMPARE(list, QList() << 128 << 256 << 384); QtConcurrent::map(list.begin(), list.end(), [](int &x){x *= 2;}).waitForFinished(); QCOMPARE(list, QList() << 256 << 512 << 768); -#endif - } // functors don't take arguments by reference, making these no-ops @@ -160,13 +157,11 @@ void tst_QtConcurrentMap::map() QtConcurrent::map(list.begin(), list.end(), multiplyBy2Immutable).waitForFinished(); QCOMPARE(list, QList() << 1 << 2 << 3); -#ifdef Q_COMPILER_LAMBDA // lambda QtConcurrent::map(list, [](int x){x *= 2;}).waitForFinished(); QCOMPARE(list, QList() << 1 << 2 << 3); QtConcurrent::map(list.begin(), list.end(), [](int x){x *= 2;}).waitForFinished(); QCOMPARE(list, QList() << 1 << 2 << 3); -#endif } // Linked lists and forward iterators diff --git a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp index 1596a9fafd..9b5bb85fff 100644 --- a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp +++ b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp @@ -48,12 +48,8 @@ private slots: #ifndef QT_NO_EXCEPTIONS void exceptions(); #endif -#ifdef Q_COMPILER_DECLTYPE void functor(); -#endif -#ifdef Q_COMPILER_LAMBDA void lambda(); -#endif }; void light() @@ -648,7 +644,6 @@ void tst_QtConcurrentRun::exceptions() } #endif -#ifdef Q_COMPILER_DECLTYPE // Compiler supports decltype struct Functor { int operator()() { return 42; } @@ -706,9 +701,7 @@ void tst_QtConcurrentRun::functor() QtConcurrent::run(&pool, f, 1,2,3,4,5).waitForFinished(); } } -#endif -#ifdef Q_COMPILER_LAMBDA // Compiler supports lambda void tst_QtConcurrentRun::lambda() { @@ -742,7 +735,6 @@ void tst_QtConcurrentRun::lambda() } #endif } -#endif QTEST_MAIN(tst_QtConcurrentRun) #include "tst_qtconcurrentrun.moc" diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp index d3ed1a6d0d..f212fe6f27 100644 --- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp +++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp @@ -254,19 +254,15 @@ public: int rvalue() && { ADD("TestClass1::rvalue"); return 0; } int const_rvalue() const && { ADD("TestClass1::const_rvalue"); return 0; } #endif -#ifdef Q_COMPILER_DECLTYPE int decltype_param(int x = 0, decltype(x) = 0) { ADD("TestClass1::decltype_param"); return x; } template int decltype_template_param(T x = 0, decltype(x) = 0) { ADD("TestClass1::decltype_template_param"); return x; } template void decltype_template_param2(T x, decltype(x + QString())) { ADD("TestClass1::decltype_template_param2"); } -# ifdef Q_COMPILER_AUTO_FUNCTION auto decltype_return(int x = 0) -> decltype(x) { ADD("TestClass1::decltype_return"); return x; } template auto decltype_template_return(T x = 0) -> decltype(x) { ADD("TestClass1::decltype_template_return"); return x; } -# endif -#endif public: TestClass1() @@ -323,15 +319,11 @@ public: std::move(*this).rvalue(); std::move(*this).const_rvalue(); #endif -#ifdef Q_COMPILER_DECLTYPE decltype_param(); decltype_template_param(0); decltype_template_param2(QByteArray(), QString()); -# ifdef Q_COMPILER_AUTO_FUNCTION decltype_return(); decltype_template_return(0); -# endif -#endif } }; diff --git a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp index 11a9b3f189..08635d34c5 100644 --- a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp +++ b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp @@ -369,11 +369,9 @@ private slots: } Q_LOGGING_CATEGORY(TST_MACRO_1, "tst.macro.1") -#ifdef Q_COMPILER_VARIADIC_MACROS Q_LOGGING_CATEGORY(TST_MACRO_2, "tst.macro.2", QtDebugMsg) Q_LOGGING_CATEGORY(TST_MACRO_3, "tst.macro.3", QtFatalMsg) Q_LOGGING_CATEGORY(TST_MACRO_4, "tst.macro.4", QtInfoMsg) -#endif void QLoggingCategoryMacro() { @@ -384,7 +382,6 @@ private slots: QCOMPARE(cat1.isWarningEnabled(), true); QCOMPARE(cat1.isCriticalEnabled(), true); -#ifdef Q_COMPILER_VARIADIC_MACROS const QLoggingCategory &cat2 = TST_MACRO_2(); QCOMPARE(cat2.categoryName(), "tst.macro.2"); QCOMPARE(cat2.isDebugEnabled(), true); @@ -405,7 +402,6 @@ private slots: QCOMPARE(cat4.isInfoEnabled(), true); QCOMPARE(cat4.isWarningEnabled(), true); QCOMPARE(cat4.isCriticalEnabled(), true); -#endif } void qCDebugMacros() diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index e2bb7dab2a..28458c43c7 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -1499,7 +1499,7 @@ public: typedef MyObject* MyObjectPtr; Q_DECLARE_METATYPE(MyObjectPtr) -#if defined(Q_COMPILER_VARIADIC_MACROS) && !defined(TST_QMETATYPE_BROKEN_COMPILER) +#if !defined(TST_QMETATYPE_BROKEN_COMPILER) static QByteArray createTypeName(const char *begin, const char *va) { QByteArray tn(begin); @@ -1697,7 +1697,7 @@ void tst_QMetaType::automaticTemplateRegistration() QVERIFY(qRegisterMetaType("UnregisteredTypeList") > 0); } -#if defined(Q_COMPILER_VARIADIC_MACROS) && !defined(TST_QMETATYPE_BROKEN_COMPILER) +#if !defined(TST_QMETATYPE_BROKEN_COMPILER) #define FOR_EACH_STATIC_PRIMITIVE_TYPE(F) \ F(bool) \ @@ -1776,7 +1776,7 @@ void tst_QMetaType::automaticTemplateRegistration() CREATE_AND_VERIFY_CONTAINER(QHash, void*, void*) CREATE_AND_VERIFY_CONTAINER(QHash, const void*, const void*) -#endif // Q_COMPILER_VARIADIC_MACROS +#endif // !defined(TST_QMETATYPE_BROKEN_COMPILER) #define TEST_OWNING_SMARTPOINTER(SMARTPOINTER, ELEMENT_TYPE, FLAG_TEST, FROMVARIANTFUNCTION) \ { \ @@ -2565,9 +2565,7 @@ Q_DECLARE_METATYPE(UndefinedFunction0); Q_DECLARE_METATYPE(UndefinedFunction1); Q_DECLARE_METATYPE(UndefinedFunction2); Q_DECLARE_METATYPE(UndefinedFunction3); -#ifdef Q_COMPILER_VARIADIC_TEMPLATES Q_DECLARE_METATYPE(UndefinedFunction4); -#endif QTEST_MAIN(tst_QMetaType) #include "tst_qmetatype.moc" diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index f51fb9bf49..4a27b5bffe 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -6029,7 +6029,6 @@ void tst_QObject::connectFunctorArgDifference() QStringListModel model; connect(&model, &QStringListModel::rowsInserted, SlotFunctor()); -#if defined(Q_COMPILER_LAMBDA) connect(&timer, &QTimer::timeout, [=](){}); connect(&timer, &QTimer::objectNameChanged, [=](const QString &){}); connect(qApp, &QCoreApplication::aboutToQuit, [=](){}); @@ -6037,7 +6036,6 @@ void tst_QObject::connectFunctorArgDifference() connect(&timer, &QTimer::objectNameChanged, [=](){}); connect(&model, &QStringListModel::rowsInserted, [=](){}); connect(&model, &QStringListModel::rowsInserted, [=](const QModelIndex &){}); -#endif QVERIFY(true); } @@ -6075,7 +6073,6 @@ void tst_QObject::connectFunctorQueued() e.exec(); QCOMPARE(status, 2); -#if defined(Q_COMPILER_LAMBDA) status = 1; connect(&obj, &SenderObject::signal1, this, [&status] { status = 2; }, Qt::QueuedConnection); @@ -6083,7 +6080,6 @@ void tst_QObject::connectFunctorQueued() QCOMPARE(status, 1); e.exec(); QCOMPARE(status, 2); -#endif } void tst_QObject::connectFunctorWithContext() @@ -6117,7 +6113,6 @@ void tst_QObject::connectFunctorWithContext() e.exec(); QCOMPARE(status, 2); -#if defined(Q_COMPILER_LAMBDA) status = 1; connect(&obj, &SenderObject::signal1, this, [this, &status, &obj] { status = 2; QCOMPARE(sender(), &obj); }, Qt::QueuedConnection); @@ -6125,7 +6120,6 @@ void tst_QObject::connectFunctorWithContext() QCOMPARE(status, 1); e.exec(); QCOMPARE(status, 2); -#endif // Free context->deleteLater(); @@ -6435,7 +6429,7 @@ void connectFunctorOverload_impl(Signal signal, int expOverload, QList void tst_QObject::connectFunctorOverloads() { -#if defined (Q_COMPILER_DECLTYPE) && defined (Q_COMPILER_VARIADIC_TEMPLATES) +#if defined (Q_COMPILER_VARIADIC_TEMPLATES) connectFunctorOverload_impl(&FunctorArgDifferenceObject::signal_ii, 1, (QList() << 1 << 2)); connectFunctorOverload_impl(&FunctorArgDifferenceObject::signal_iiS, 1, @@ -6609,7 +6603,6 @@ void tst_QObject::disconnectDoesNotLeakFunctor() } QCOMPARE(countedStructObjectsCount, 0); { -#if defined(Q_COMPILER_LAMBDA) CountedStruct s; QCOMPARE(countedStructObjectsCount, 1); QTimer timer; @@ -6619,7 +6612,6 @@ void tst_QObject::disconnectDoesNotLeakFunctor() QCOMPARE(countedStructObjectsCount, 2); QVERIFY(QObject::disconnect(c)); QCOMPARE(countedStructObjectsCount, 1); -#endif // Q_COMPILER_LAMBDA } QCOMPARE(countedStructObjectsCount, 0); } @@ -6667,7 +6659,6 @@ void tst_QObject::contextDoesNotLeakFunctor() } QCOMPARE(countedStructObjectsCount, 0); { -#if defined(Q_COMPILER_LAMBDA) CountedStruct s; QEventLoop e; ContextObject *context = new ContextObject; @@ -6680,7 +6671,6 @@ void tst_QObject::contextDoesNotLeakFunctor() context->deleteLater(); e.exec(); QCOMPARE(countedStructObjectsCount, 1); -#endif // Q_COMPILER_LAMBDA } QCOMPARE(countedStructObjectsCount, 0); } diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp index a00c962510..2d1ae07b35 100644 --- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp +++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp @@ -78,9 +78,7 @@ private slots: void fromRawData_data(); void fromRawData(); void literals(); -#if defined(Q_COMPILER_VARIADIC_MACROS) && defined(Q_COMPILER_LAMBDA) void variadicLiterals(); -#endif #ifdef Q_COMPILER_RVALUE_REFS void rValueReferences(); #endif @@ -1618,9 +1616,7 @@ void tst_QArrayData::literals() QCOMPARE(v.size(), size_t(11)); // v.capacity() is unspecified, for now -#if defined(Q_COMPILER_VARIADIC_MACROS) && defined(Q_COMPILER_LAMBDA) QVERIFY(v.isStatic()); -#endif #if !defined(QT_NO_UNSHARABLE_CONTAINERS) QVERIFY(v.isSharable()); @@ -1633,7 +1629,6 @@ void tst_QArrayData::literals() } } -#if defined(Q_COMPILER_VARIADIC_MACROS) && defined(Q_COMPILER_LAMBDA) // Variadic Q_ARRAY_LITERAL need to be available in the current configuration. void tst_QArrayData::variadicLiterals() { @@ -1682,7 +1677,6 @@ void tst_QArrayData::variadicLiterals() QCOMPARE(const_(v)[i], i); } } -#endif #ifdef Q_COMPILER_RVALUE_REFS // std::remove_reference is in C++11, but requires library support diff --git a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp index 2dbf86c2f5..987b3058e3 100644 --- a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp @@ -138,9 +138,7 @@ private slots: void reserveExtended(); void movablity_data(); void movablity(); -#if defined(Q_COMPILER_LAMBDA) void literals(); -#endif void toUpperLower_data(); void toUpperLower(); void isUpper(); @@ -2192,7 +2190,6 @@ void tst_QByteArray::movablity() QVERIFY(true); } -#if defined(Q_COMPILER_LAMBDA) // Only tested on c++0x compliant compiler or gcc void tst_QByteArray::literals() { @@ -2213,7 +2210,6 @@ void tst_QByteArray::literals() QVERIFY(str2.constData() == s); QVERIFY(str2.data() != s); } -#endif void tst_QByteArray::toUpperLower_data() { diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index ebec83403a..19b2aa02f3 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -89,9 +89,7 @@ private slots: #endif void constCorrectness(); void customDeleter(); -#ifdef Q_COMPILER_LAMBDA void lambdaCustomDeleter(); -#endif void creating(); void creatingCvQualified(); void creatingVariadic(); @@ -1670,7 +1668,6 @@ void tst_QSharedPointer::customDeleter() safetyCheck(); } -#ifdef Q_COMPILER_LAMBDA // The compiler needs to be in C++11 mode and to support lambdas void tst_QSharedPointer::lambdaCustomDeleter() { @@ -1698,7 +1695,6 @@ void tst_QSharedPointer::lambdaCustomDeleter() } safetyCheck(); } -#endif void customQObjectDeleterFn(QObject *obj) { @@ -2233,11 +2229,9 @@ void tst_QSharedPointer::invalidConstructs_data() << &QTest::QExternalTest::tryCompileFail << "struct IncompatibleCustomDeleter { void operator()(int *); };\n" "QSharedPointer ptr(new Data, IncompatibleCustomDeleter());\n"; -#ifdef Q_COMPILER_LAMBDA QTest::newRow("incompatible-custom-lambda-deleter") << &QTest::QExternalTest::tryCompileFail << "QSharedPointer ptr(new Data, [](int *) {});\n"; -#endif } void tst_QSharedPointer::invalidConstructs() diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index d891ef7e12..79f5a8c46d 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -578,7 +578,7 @@ private slots: #ifdef QT_USE_ICU void toUpperLower_icu(); #endif -#if !defined(QT_NO_UNICODE_LITERAL) && defined(Q_COMPILER_LAMBDA) +#if !defined(QT_NO_UNICODE_LITERAL) void literals(); #endif void eightBitLiterals_data(); @@ -6621,7 +6621,7 @@ void tst_QString::toUpperLower_icu() } #endif -#if !defined(QT_NO_UNICODE_LITERAL) && defined(Q_COMPILER_LAMBDA) +#if !defined(QT_NO_UNICODE_LITERAL) // Only tested on c++0x compliant compiler or gcc void tst_QString::literals() { diff --git a/tests/auto/tools/moc/parse-defines.h b/tests/auto/tools/moc/parse-defines.h index 7b0fa29d7c..bd22b0b9af 100644 --- a/tests/auto/tools/moc/parse-defines.h +++ b/tests/auto/tools/moc/parse-defines.h @@ -51,7 +51,6 @@ #define PD_CLASSINFO Q_CLASSINFO -#if defined(Q_COMPILER_VARIADIC_MACROS) || defined (Q_MOC_RUN) #define PD_VARARG(x, ...) x(__VA_ARGS__) #if defined(Q_CC_GNU) || defined(Q_MOC_RUN) @@ -61,7 +60,6 @@ #define PD_VARARGEXT(x, ...) x(__VA_ARGS__) #endif -#endif #define PD_ADD_SUFFIX(x) PD_DEFINE1(x,_SUFFIX) #define PD_DEFINE_ITSELF PD_ADD_SUFFIX(PD_DEFINE_ITSELF) @@ -100,7 +98,6 @@ public slots: PD_TEST_IDENTIFIER_ARG(void, combined6()) {} -#if defined(Q_COMPILER_VARIADIC_MACROS) || defined (Q_MOC_RUN) PD_VARARG(void vararg1) {} PD_VARARG(void vararg2, int) {} PD_VARARG(void vararg3, int, int) {} @@ -108,14 +105,6 @@ public slots: PD_VARARGEXT(void vararg4) {} PD_VARARGEXT(void vararg5, int) {} PD_VARARGEXT(void vararg6, int, int) {} -#else - void vararg1() {} - void vararg2(int) {} - void vararg3(int,int) {} - void vararg4() {} - void vararg5(int) {} - void vararg6(int,int) {} -#endif #define OUTERFUNCTION(x) x #define INNERFUNCTION(x) OUTERFUNCTION(x) From 5c90a9699871006d51fdd83bd38c8c8ea5dfa26e Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 2 Apr 2019 13:07:05 +0200 Subject: [PATCH 166/292] Remove handling of missing Q_COMPILER_CLASS_ENUM Change-Id: I1fd6d601e49e803b4c3308fb0ca41136c628afbc Reviewed-by: Thiago Macieira --- src/corelib/global/qnamespace.h | 2 +- .../auto/corelib/global/qflags/tst_qflags.cpp | 6 ------ .../corelib/kernel/qvariant/tst_qvariant.cpp | 20 +++++-------------- tests/auto/tools/moc/cxx11-enums.h | 18 ----------------- .../corelib/tools/qdatetime/main.cpp | 5 +---- 5 files changed, 7 insertions(+), 44 deletions(-) diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 610d7e4db7..90dd36113f 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -1614,7 +1614,7 @@ public: TitleBarArea // For move }; -#if defined(Q_COMPILER_CLASS_ENUM) && defined(Q_COMPILER_CONSTEXPR) +#if defined(Q_COMPILER_CONSTEXPR) enum class Initialization { Uninitialized }; diff --git a/tests/auto/corelib/global/qflags/tst_qflags.cpp b/tests/auto/corelib/global/qflags/tst_qflags.cpp index 72b086350e..8265d21350 100644 --- a/tests/auto/corelib/global/qflags/tst_qflags.cpp +++ b/tests/auto/corelib/global/qflags/tst_qflags.cpp @@ -142,7 +142,6 @@ void tst_QFlags::signedness() std::is_signed::value)); } -#if defined(Q_COMPILER_CLASS_ENUM) enum class MyStrictEnum { StrictZero, StrictOne, StrictTwo, StrictFour=4 }; Q_DECLARE_FLAGS( MyStrictFlags, MyStrictEnum ) Q_DECLARE_OPERATORS_FOR_FLAGS( MyStrictFlags ) @@ -154,11 +153,9 @@ Q_STATIC_ASSERT( !QTypeInfo::isComplex ); Q_STATIC_ASSERT( !QTypeInfo::isStatic ); Q_STATIC_ASSERT( !QTypeInfo::isLarge ); Q_STATIC_ASSERT( !QTypeInfo::isPointer ); -#endif void tst_QFlags::classEnum() { -#if defined(Q_COMPILER_CLASS_ENUM) // The main aim of the test is making sure it compiles // The QCOMPARE are there as an extra MyStrictEnum e1 = MyStrictEnum::StrictOne; @@ -257,7 +254,6 @@ void tst_QFlags::classEnum() // Just to make sure it compiles if (false) qDebug() << f3; -#endif } void tst_QFlags::initializerLists() @@ -268,12 +264,10 @@ void tst_QFlags::initializerLists() QVERIFY(bts.testFlag(Qt::RightButton)); QVERIFY(!bts.testFlag(Qt::MiddleButton)); -#if defined(Q_COMPILER_CLASS_ENUM) MyStrictNoOpFlags flags = { MyStrictNoOpEnum::StrictOne, MyStrictNoOpEnum::StrictFour }; QVERIFY(flags.testFlag(MyStrictNoOpEnum::StrictOne)); QVERIFY(flags.testFlag(MyStrictNoOpEnum::StrictFour)); QVERIFY(!flags.testFlag(MyStrictNoOpEnum::StrictTwo)); -#endif // Q_COMPILER_CLASS_ENUM #else QSKIP("This test requires C++11 initializer_list support."); diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index a9162a6a6f..6ae8fd0010 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -59,12 +59,6 @@ class CustomNonQObject; -#if defined(Q_COMPILER_CLASS_ENUM) -#define ENUM_SIZE(X) : X -#else -#define ENUM_SIZE(X) -#endif - class tst_QVariant : public QObject { Q_OBJECT @@ -82,15 +76,15 @@ public: enum MetaEnumTest_Enum1 : qint64 { MetaEnumTest_Enum1_value = 42, MetaEnumTest_Enum1_bigValue = (Q_INT64_C(1) << 33) + 50 }; Q_ENUM(MetaEnumTest_Enum1) - enum MetaEnumTest_Enum3 ENUM_SIZE(qint64) { MetaEnumTest_Enum3_value = -47, MetaEnumTest_Enum3_bigValue = (Q_INT64_C(1) << 56) + 5, MetaEnumTest_Enum3_bigNegValue = -(Q_INT64_C(1) << 56) - 3 }; + enum MetaEnumTest_Enum3 : qint64 { MetaEnumTest_Enum3_value = -47, MetaEnumTest_Enum3_bigValue = (Q_INT64_C(1) << 56) + 5, MetaEnumTest_Enum3_bigNegValue = -(Q_INT64_C(1) << 56) - 3 }; Q_ENUM(MetaEnumTest_Enum3) - enum MetaEnumTest_Enum4 ENUM_SIZE(quint64) { MetaEnumTest_Enum4_value = 47, MetaEnumTest_Enum4_bigValue = (Q_INT64_C(1) << 52) + 45 }; + enum MetaEnumTest_Enum4 : quint64 { MetaEnumTest_Enum4_value = 47, MetaEnumTest_Enum4_bigValue = (Q_INT64_C(1) << 52) + 45 }; Q_ENUM(MetaEnumTest_Enum4) - enum MetaEnumTest_Enum5 ENUM_SIZE(uint) { MetaEnumTest_Enum5_value = 47 }; + enum MetaEnumTest_Enum5 : uint { MetaEnumTest_Enum5_value = 47 }; Q_ENUM(MetaEnumTest_Enum5) - enum MetaEnumTest_Enum6 ENUM_SIZE(uchar) { MetaEnumTest_Enum6_value = 47 }; + enum MetaEnumTest_Enum6 : uchar { MetaEnumTest_Enum6_value = 47 }; Q_ENUM(MetaEnumTest_Enum6) - enum MetaEnumTest_Enum8 ENUM_SIZE(short) { MetaEnumTest_Enum8_value = 47 }; + enum MetaEnumTest_Enum8 : short { MetaEnumTest_Enum8_value = 47 }; Q_ENUM(MetaEnumTest_Enum8) private slots: @@ -4700,7 +4694,6 @@ Q_DECLARE_METATYPE(EnumTest_Enum0) enum EnumTest_Enum1 : qint64 { EnumTest_Enum1_value = 42, EnumTest_Enum1_bigValue = (Q_INT64_C(1) << 33) + 50 }; Q_DECLARE_METATYPE(EnumTest_Enum1) -#if defined(Q_COMPILER_CLASS_ENUM) enum EnumTest_Enum3 : qint64 { EnumTest_Enum3_value = -47, EnumTest_Enum3_bigValue = (Q_INT64_C(1) << 56) + 5 }; Q_DECLARE_METATYPE(EnumTest_Enum3) enum EnumTest_Enum4 : quint64 { EnumTest_Enum4_value = 47, EnumTest_Enum4_bigValue = (Q_INT64_C(1) << 52) + 45 }; @@ -4713,7 +4706,6 @@ enum class EnumTest_Enum7 { EnumTest_Enum7_value = 47, ensureSignedEnum7 = -1 }; Q_DECLARE_METATYPE(EnumTest_Enum7) enum EnumTest_Enum8 : short { EnumTest_Enum8_value = 47 }; Q_DECLARE_METATYPE(EnumTest_Enum8) -#endif template void testVariant(Enum value, bool *ok) { @@ -4772,7 +4764,6 @@ void tst_QVariant::enums() QVERIFY(ok); testVariant(EnumTest_Enum1_bigValue, &ok); QVERIFY(ok); -#if defined(Q_COMPILER_CLASS_ENUM) testVariant(EnumTest_Enum3::EnumTest_Enum3_value, &ok); QVERIFY(ok); testVariant(EnumTest_Enum3::EnumTest_Enum3_bigValue, &ok); @@ -4791,7 +4782,6 @@ void tst_QVariant::enums() QVERIFY(ok); testVariant(EnumTest_Enum3::EnumTest_Enum3_value, &ok); QVERIFY(ok); -#endif } template void testVariantMeta(Enum value, bool *ok, const char *string) diff --git a/tests/auto/tools/moc/cxx11-enums.h b/tests/auto/tools/moc/cxx11-enums.h index cc14c0acda..d5bd228f12 100644 --- a/tests/auto/tools/moc/cxx11-enums.h +++ b/tests/auto/tools/moc/cxx11-enums.h @@ -30,7 +30,6 @@ #define CXX11_ENUMS_H #include -#if defined(Q_COMPILER_CLASS_ENUM) || defined(Q_MOC_RUN) class CXX11Enums { Q_GADGET @@ -73,21 +72,4 @@ public: Q_FLAGS(ClassFlags) }; -#else -//workaround to get the moc compiled code to compile -class CXX11Enums -{ - Q_GADGET -public: - struct EnumClass { enum { A0, A1, A2, A3 }; }; - struct TypedEnumClass { enum { C0, C1, C2, C3 }; }; - enum NormalEnum { D2 = 2, D3, D0 =0 , D1 }; - enum TypedEnum { B0, B1 , B2, B3 }; -}; - -class CXX11Enums2 : public CXX11Enums -{ - Q_GADGET -}; -#endif #endif // CXX11_ENUMS_H diff --git a/tests/benchmarks/corelib/tools/qdatetime/main.cpp b/tests/benchmarks/corelib/tools/qdatetime/main.cpp index 2c1e3d97ae..b693400376 100644 --- a/tests/benchmarks/corelib/tools/qdatetime/main.cpp +++ b/tests/benchmarks/corelib/tools/qdatetime/main.cpp @@ -35,10 +35,7 @@ class tst_QDateTime : public QObject { Q_OBJECT - enum -#if defined(Q_COMPILER_CLASS_ENUM) || (defined(Q_CC_MSVC) && _MSC_VER >= 1700) - : qint64 -#endif + enum : qint64 { SECS_PER_DAY = 86400, MSECS_PER_DAY = 86400000, From 946d868619fe19c494fd2b7bb6694b29e17203d1 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Tue, 20 Nov 2018 21:55:13 +0100 Subject: [PATCH 167/292] QEasyingCurve: fix data stream operators MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Until now, QEasingCurve was not streaming all it's internal state. Therefore, doing store/reload operation through QDataStream would not yield the same curve as the original. This patch fixes it. [ChangeLog][QtCore][QEasingCurve] QEasingCurve now properly streams all the data needed to QDataStream. Change-Id: I1619501f5b4237983c8c68e148745a5e58863f55 Fixes: QTBUG-68181 Reviewed-by: Jan Arve Sæther --- src/corelib/tools/qeasingcurve.cpp | 53 ++++++++++++++++--- .../tools/qeasingcurve/tst_qeasingcurve.cpp | 33 ++++++++++++ 2 files changed, 80 insertions(+), 6 deletions(-) diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp index f82048db0f..9169b5c7f1 100644 --- a/src/corelib/tools/qeasingcurve.cpp +++ b/src/corelib/tools/qeasingcurve.cpp @@ -339,6 +339,23 @@ struct TCBPoint { }; Q_DECLARE_TYPEINFO(TCBPoint, Q_PRIMITIVE_TYPE); +QDataStream &operator<<(QDataStream &stream, const TCBPoint &point) +{ + stream << point._point + << point._t + << point._c + << point._b; + return stream; +} + +QDataStream &operator>>(QDataStream &stream, TCBPoint &point) +{ + stream >> point._point + >> point._t + >> point._c + >> point._b; + return stream; +} typedef QVector TCBPoints; @@ -363,6 +380,34 @@ public: }; +QDataStream &operator<<(QDataStream &stream, QEasingCurveFunction *func) +{ + if (func) { + stream << func->_p; + stream << func->_a; + stream << func->_o; + if (stream.version() > QDataStream::Qt_5_12) { + stream << func->_bezierCurves; + stream << func->_tcbPoints; + } + } + return stream; +} + +QDataStream &operator>>(QDataStream &stream, QEasingCurveFunction *func) +{ + if (func) { + stream >> func->_p; + stream >> func->_a; + stream >> func->_o; + if (stream.version() > QDataStream::Qt_5_12) { + stream >> func->_bezierCurves; + stream >> func->_tcbPoints; + } + } + return stream; +} + static QEasingCurve::EasingFunction curveToFunc(QEasingCurve::Type curve); qreal QEasingCurveFunction::value(qreal t) @@ -1480,9 +1525,7 @@ QDataStream &operator<<(QDataStream &stream, const QEasingCurve &easing) bool hasConfig = easing.d_ptr->config; stream << hasConfig; if (hasConfig) { - stream << easing.d_ptr->config->_p; - stream << easing.d_ptr->config->_a; - stream << easing.d_ptr->config->_o; + stream << easing.d_ptr->config; } return stream; } @@ -1515,9 +1558,7 @@ QDataStream &operator>>(QDataStream &stream, QEasingCurve &easing) easing.d_ptr->config = nullptr; if (hasConfig) { QEasingCurveFunction *config = curveToFunctionObject(type); - stream >> config->_p; - stream >> config->_a; - stream >> config->_o; + stream >> config; easing.d_ptr->config = config; } return stream; diff --git a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp index 0196dd2d23..c21d0afacb 100644 --- a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp +++ b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp @@ -55,6 +55,8 @@ private slots: void testCbrtFloat(); void cpp11(); void quadraticEquation(); + void streamInOut_data(); + void streamInOut(); }; void tst_QEasingCurve::type() @@ -879,5 +881,36 @@ void tst_QEasingCurve::quadraticEquation() { } } +void tst_QEasingCurve::streamInOut_data() +{ + QTest::addColumn("version"); + QTest::addColumn("equality"); + + QTest::newRow("5.11") << int(QDataStream::Qt_5_11) << false; + QTest::newRow("5.13") << int(QDataStream::Qt_5_13) << true; +} + +void tst_QEasingCurve::streamInOut() +{ + QFETCH(int, version); + QFETCH(bool, equality); + + QEasingCurve orig; + orig.addCubicBezierSegment(QPointF(0.43, 0.0025), QPointF(0.38, 0.51), QPointF(0.57, 0.99)); + + QEasingCurve copy; + + QByteArray data; + QDataStream dsw(&data,QIODevice::WriteOnly); + QDataStream dsr(&data,QIODevice::ReadOnly); + + dsw.setVersion(version); + dsr.setVersion(version); + dsw << orig; + dsr >> copy; + + QCOMPARE(copy == orig, equality); +} + QTEST_MAIN(tst_QEasingCurve) #include "tst_qeasingcurve.moc" From 58b4e0736919e0504f5ca5307ad7aefa894a6f38 Mon Sep 17 00:00:00 2001 From: Milian Wolff Date: Thu, 11 Jan 2018 17:46:24 +0100 Subject: [PATCH 168/292] Optimize QTimer::singleShot(0, ...) when taking PMF or Functor callable QTimer::singleShot is optimized for zero timeouts when using the API taking a string method name. This optimization was not used for the API taking a PMF or functor. This patch adds it, making the various API calls behave similarly from a performance point of view. The approach taken here requires a QObject context object. If none is available, e.g. a nullptr was passed explicitly, or the QTimer::singleShot(O, Functor) API was used, the optimization could not easily be applied. This is not only bad from a performance POV, but also poses as a potential source for heisenbugs: Using the different API versions of QTimer::singleShot would use different code paths internally, which then would not ensure the expected slot call order. This problem actually existed already when mixing the string-based slot syntax with PMF/functors in the QTimer::singleShot API. This patch overcomes this hurdle and fixes all of the above: When we encounter a 0ms single shot timer, and no QObject context object is available, we fall back to the main thread, or create a temporary QObject for any other thread. The updated and extended benchmark shows that this is still a significant performance improvement over using a timer: ********* Start testing of qtimer_vs_qmetaobject ********* Config: Using QtTest library 5.14.0, Qt 5.14.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 8.2.1 20181127) PASS : qtimer_vs_qmetaobject::initTestCase() PASS : qtimer_vs_qmetaobject::bench(singleShot_slot) RESULT : qtimer_vs_qmetaobject::bench():"singleShot_slot": 7.48 msecs per iteration (total: 748, iterations: 100) PASS : qtimer_vs_qmetaobject::bench(singleShot_pmf) RESULT : qtimer_vs_qmetaobject::bench():"singleShot_pmf": 7.20 msecs per iteration (total: 720, iterations: 100) PASS : qtimer_vs_qmetaobject::bench(singleShot_functor) RESULT : qtimer_vs_qmetaobject::bench():"singleShot_functor": 6.79 msecs per iteration (total: 679, iterations: 100) PASS : qtimer_vs_qmetaobject::bench(singleShot_functor_noctx) RESULT : qtimer_vs_qmetaobject::bench():"singleShot_functor_noctx": 6.92 msecs per iteration (total: 693, iterations: 100) PASS : qtimer_vs_qmetaobject::bench(invokeMethod_string) RESULT : qtimer_vs_qmetaobject::bench():"invokeMethod_string": 7.34 msecs per iteration (total: 735, iterations: 100) PASS : qtimer_vs_qmetaobject::bench(invokeMethod_pmf) RESULT : qtimer_vs_qmetaobject::bench():"invokeMethod_pmf": 6.90 msecs per iteration (total: 690, iterations: 100) PASS : qtimer_vs_qmetaobject::bench(invokeMethod_functor) RESULT : qtimer_vs_qmetaobject::bench():"invokeMethod_functor": 6.62 msecs per iteration (total: 662, iterations: 100) PASS : qtimer_vs_qmetaobject::benchBackgroundThread(singleShot_slot) RESULT : qtimer_vs_qmetaobject::benchBackgroundThread():"singleShot_slot": 7.45 msecs per iteration (total: 745, iterations: 100) PASS : qtimer_vs_qmetaobject::benchBackgroundThread(singleShot_pmf) RESULT : qtimer_vs_qmetaobject::benchBackgroundThread():"singleShot_pmf": 7.46 msecs per iteration (total: 747, iterations: 100) PASS : qtimer_vs_qmetaobject::benchBackgroundThread(singleShot_functor) RESULT : qtimer_vs_qmetaobject::benchBackgroundThread():"singleShot_functor": 6.70 msecs per iteration (total: 671, iterations: 100) PASS : qtimer_vs_qmetaobject::benchBackgroundThread(singleShot_functor_noctx) RESULT : qtimer_vs_qmetaobject::benchBackgroundThread():"singleShot_functor_noctx": 13.75 msecs per iteration (total: 1,376, iterations: 100) PASS : qtimer_vs_qmetaobject::benchBackgroundThread(invokeMethod_string) RESULT : qtimer_vs_qmetaobject::benchBackgroundThread():"invokeMethod_string": 7.05 msecs per iteration (total: 706, iterations: 100) PASS : qtimer_vs_qmetaobject::benchBackgroundThread(invokeMethod_pmf) RESULT : qtimer_vs_qmetaobject::benchBackgroundThread():"invokeMethod_pmf": 6.70 msecs per iteration (total: 670, iterations: 100) PASS : qtimer_vs_qmetaobject::benchBackgroundThread(invokeMethod_functor) RESULT : qtimer_vs_qmetaobject::benchBackgroundThread():"invokeMethod_functor": 6.58 msecs per iteration (total: 658, iterations: 100) PASS : qtimer_vs_qmetaobject::cleanupTestCase() Totals: 16 passed, 0 failed, 0 skipped, 0 blacklisted, 20977ms ********* Finished testing of qtimer_vs_qmetaobject ********* Without the change to qtimer.cpp, the results are: ********* Start testing of qtimer_vs_qmetaobject ********* Config: Using QtTest library 5.14.0, Qt 5.14.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 8.2.1 20181127) PASS : qtimer_vs_qmetaobject::initTestCase() PASS : qtimer_vs_qmetaobject::bench(singleShot_slot) RESULT : qtimer_vs_qmetaobject::bench():"singleShot_slot": 7.45 msecs per iteration (total: 745, iterations: 100) PASS : qtimer_vs_qmetaobject::bench(singleShot_pmf) RESULT : qtimer_vs_qmetaobject::bench():"singleShot_pmf": 112.84 msecs per iteration (total: 11,285, iterations: 100) PASS : qtimer_vs_qmetaobject::bench(singleShot_functor) RESULT : qtimer_vs_qmetaobject::bench():"singleShot_functor": 115.62 msecs per iteration (total: 11,563, iterations: 100) PASS : qtimer_vs_qmetaobject::bench(singleShot_functor_noctx) RESULT : qtimer_vs_qmetaobject::bench():"singleShot_functor_noctx": 110.81 msecs per iteration (total: 11,082, iterations: 100) PASS : qtimer_vs_qmetaobject::bench(invokeMethod_string) RESULT : qtimer_vs_qmetaobject::bench():"invokeMethod_string": 7.04 msecs per iteration (total: 704, iterations: 100) PASS : qtimer_vs_qmetaobject::bench(invokeMethod_pmf) RESULT : qtimer_vs_qmetaobject::bench():"invokeMethod_pmf": 6.62 msecs per iteration (total: 662, iterations: 100) PASS : qtimer_vs_qmetaobject::bench(invokeMethod_functor) RESULT : qtimer_vs_qmetaobject::bench():"invokeMethod_functor": 6.62 msecs per iteration (total: 662, iterations: 100) PASS : qtimer_vs_qmetaobject::benchBackgroundThread(singleShot_slot) RESULT : qtimer_vs_qmetaobject::benchBackgroundThread():"singleShot_slot": 7.45 msecs per iteration (total: 746, iterations: 100) PASS : qtimer_vs_qmetaobject::benchBackgroundThread(singleShot_pmf) RESULT : qtimer_vs_qmetaobject::benchBackgroundThread():"singleShot_pmf": 118.42 msecs per iteration (total: 11,842, iterations: 100) PASS : qtimer_vs_qmetaobject::benchBackgroundThread(singleShot_functor) RESULT : qtimer_vs_qmetaobject::benchBackgroundThread():"singleShot_functor": 119.35 msecs per iteration (total: 11,936, iterations: 100) PASS : qtimer_vs_qmetaobject::benchBackgroundThread(singleShot_functor_noctx) RESULT : qtimer_vs_qmetaobject::benchBackgroundThread():"singleShot_functor_noctx": 130.96 msecs per iteration (total: 13,096, iterations: 100) PASS : qtimer_vs_qmetaobject::benchBackgroundThread(invokeMethod_string) RESULT : qtimer_vs_qmetaobject::benchBackgroundThread():"invokeMethod_string": 8.08 msecs per iteration (total: 808, iterations: 100) PASS : qtimer_vs_qmetaobject::benchBackgroundThread(invokeMethod_pmf) RESULT : qtimer_vs_qmetaobject::benchBackgroundThread():"invokeMethod_pmf": 6.79 msecs per iteration (total: 680, iterations: 100) PASS : qtimer_vs_qmetaobject::benchBackgroundThread(invokeMethod_functor) RESULT : qtimer_vs_qmetaobject::benchBackgroundThread():"invokeMethod_functor": 7.49 msecs per iteration (total: 749, iterations: 100) PASS : qtimer_vs_qmetaobject::cleanupTestCase() Totals: 16 passed, 0 failed, 0 skipped, 0 blacklisted, 153995ms ********* Finished testing of qtimer_vs_qmetaobject ********* Additionally, this patch adds a unit test to verify that the slot call order for 0ms single shot timers is followed while mixing the various API versions. It fails without this patch but passes now. Finally, another test is added to verify that using QTimer::singleShot before a QCoreApplication was constructed is still working properly. Change-Id: I0d6211554b6198cb3e527be9ec3adc572b1b54ee Reviewed-by: Thiago Macieira --- src/corelib/kernel/qobjectdefs.h | 1 + src/corelib/kernel/qtimer.cpp | 29 +++++ src/testlib/qtest.h | 27 ++-- .../auto/corelib/kernel/qtimer/tst_qtimer.cpp | 123 +++++++++++++++++- .../tst_qtimer_vs_qmetaobject.cpp | 21 ++- 5 files changed, 182 insertions(+), 19 deletions(-) diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index 28674193c3..418b8cf1d2 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -576,6 +576,7 @@ struct Q_CORE_EXPORT QMetaObject private: static bool invokeMethodImpl(QObject *object, QtPrivate::QSlotObjectBase *slot, Qt::ConnectionType type, void *ret); + friend class QTimer; }; class Q_CORE_EXPORT QMetaObject::Connection { diff --git a/src/corelib/kernel/qtimer.cpp b/src/corelib/kernel/qtimer.cpp index 13f027074a..188d529f04 100644 --- a/src/corelib/kernel/qtimer.cpp +++ b/src/corelib/kernel/qtimer.cpp @@ -42,6 +42,8 @@ #include "qabstracteventdispatcher.h" #include "qcoreapplication.h" #include "qobject_p.h" +#include "qthread.h" +#include "qcoreapplication_p.h" QT_BEGIN_NAMESPACE @@ -343,6 +345,33 @@ void QTimer::singleShotImpl(int msec, Qt::TimerType timerType, const QObject *receiver, QtPrivate::QSlotObjectBase *slotObj) { + if (msec == 0) { + bool deleteReceiver = false; + // Optimize: set a receiver context when none is given, such that we can use + // QMetaObject::invokeMethod which is more efficient than going through a timer. + // We need a QObject living in the current thread. But the QThread itself lives + // in a different thread - with the exception of the main QThread which lives in + // itself. And QThread::currentThread() is among the few QObjects we know that will + // most certainly be there. Note that one can actually call singleShot before the + // QApplication is created! + if (!receiver && QThread::currentThread() == QCoreApplicationPrivate::mainThread()) { + // reuse main thread as context object + receiver = QThread::currentThread(); + } else if (!receiver) { + // Create a receiver context object on-demand. According to the benchmarks, + // this is still more efficient than going through a timer. + receiver = new QObject; + deleteReceiver = true; + } + + QMetaObject::invokeMethodImpl(const_cast(receiver), slotObj, + Qt::QueuedConnection, nullptr); + + if (deleteReceiver) + const_cast(receiver)->deleteLater(); + return; + } + new QSingleShotTimer(msec, timerType, receiver, slotObj); } diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h index ebd94939ce..89abc616d9 100644 --- a/src/testlib/qtest.h +++ b/src/testlib/qtest.h @@ -424,48 +424,45 @@ int main(int argc, char *argv[]) \ # define QTEST_DISABLE_KEYPAD_NAVIGATION #endif -#define QTEST_MAIN(TestObject) \ -int main(int argc, char *argv[]) \ -{ \ +#define QTEST_MAIN_IMPL(TestObject) \ TESTLIB_SELFCOVERAGE_START(#TestObject) \ QApplication app(argc, argv); \ app.setAttribute(Qt::AA_Use96Dpi, true); \ QTEST_DISABLE_KEYPAD_NAVIGATION \ TestObject tc; \ QTEST_SET_MAIN_SOURCE_PATH \ - return QTest::qExec(&tc, argc, argv); \ -} + return QTest::qExec(&tc, argc, argv); #elif defined(QT_GUI_LIB) #include -#define QTEST_MAIN(TestObject) \ -int main(int argc, char *argv[]) \ -{ \ +#define QTEST_MAIN_IMPL(TestObject) \ TESTLIB_SELFCOVERAGE_START(#TestObject) \ QGuiApplication app(argc, argv); \ app.setAttribute(Qt::AA_Use96Dpi, true); \ TestObject tc; \ QTEST_SET_MAIN_SOURCE_PATH \ - return QTest::qExec(&tc, argc, argv); \ -} + return QTest::qExec(&tc, argc, argv); #else -#define QTEST_MAIN(TestObject) \ -int main(int argc, char *argv[]) \ -{ \ +#define QTEST_MAIN_IMPL(TestObject) \ TESTLIB_SELFCOVERAGE_START(#TestObject) \ QCoreApplication app(argc, argv); \ app.setAttribute(Qt::AA_Use96Dpi, true); \ TestObject tc; \ QTEST_SET_MAIN_SOURCE_PATH \ - return QTest::qExec(&tc, argc, argv); \ -} + return QTest::qExec(&tc, argc, argv); #endif // QT_GUI_LIB +#define QTEST_MAIN(TestObject) \ +int main(int argc, char *argv[]) \ +{ \ + QTEST_MAIN_IMPL(TestObject) \ +} + #define QTEST_GUILESS_MAIN(TestObject) \ int main(int argc, char *argv[]) \ { \ diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp index 3b10547dc4..d06059bbe5 100644 --- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp +++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp @@ -73,7 +73,12 @@ private slots: void recurseOnTimeoutAndStopTimer(); void singleShotToFunctors(); void singleShot_chrono(); + void singleShot_static(); void crossThreadSingleShotToFunctor(); + void timerOrder(); + void timerOrder_data(); + void timerOrderBackgroundThread(); + void timerOrderBackgroundThread_data() { timerOrder_data(); } void dontBlockEvents(); void postedEventsShouldNotStarveTimers(); @@ -1033,5 +1038,121 @@ void tst_QTimer::callOnTimeout() QVERIFY(!connection); } -QTEST_MAIN(tst_QTimer) +class OrderHelper : public QObject +{ + Q_OBJECT +public: + enum CallType + { + String, + PMF, + Functor, + FunctorNoCtx + }; + Q_ENUM(CallType) + QVector calls; + + void triggerCall(CallType callType) + { + switch (callType) + { + case String: + QTimer::singleShot(0, this, SLOT(stringSlot())); + break; + case PMF: + QTimer::singleShot(0, this, &OrderHelper::pmfSlot); + break; + case Functor: + QTimer::singleShot(0, this, [this]() { functorSlot(); }); + break; + case FunctorNoCtx: + QTimer::singleShot(0, [this]() { functorNoCtxSlot(); }); + break; + } + } + +public slots: + void stringSlot() { calls << String; } + void pmfSlot() { calls << PMF; } + void functorSlot() { calls << Functor; } + void functorNoCtxSlot() { calls << FunctorNoCtx; } +}; + +Q_DECLARE_METATYPE(OrderHelper::CallType) + +void tst_QTimer::timerOrder() +{ + QFETCH(QVector, calls); + + OrderHelper helper; + + for (const auto call : calls) + helper.triggerCall(call); + + QTRY_COMPARE(helper.calls, calls); +} + +void tst_QTimer::timerOrder_data() +{ + QTest::addColumn>("calls"); + + QVector calls = { + OrderHelper::String, OrderHelper::PMF, + OrderHelper::Functor, OrderHelper::FunctorNoCtx + }; + std::sort(calls.begin(), calls.end()); + + int permutation = 0; + do { + QTest::addRow("permutation=%d", permutation) << calls; + ++permutation; + } while (std::next_permutation(calls.begin(), calls.end())); +} + +void tst_QTimer::timerOrderBackgroundThread() +{ +#if !QT_CONFIG(cxx11_future) + QSKIP("This test requires QThread::create"); +#else + auto *thread = QThread::create([this]() { timerOrder(); }); + thread->start(); + QVERIFY(thread->wait()); + delete thread; +#endif +} + +struct StaticSingleShotUser +{ + StaticSingleShotUser() + { + for (auto call : calls()) + helper.triggerCall(call); + } + OrderHelper helper; + + static QVector calls() + { + return {OrderHelper::String, OrderHelper::PMF, + OrderHelper::Functor, OrderHelper::FunctorNoCtx}; + } +}; + +static StaticSingleShotUser *s_staticSingleShotUser = nullptr; + +void tst_QTimer::singleShot_static() +{ + QCoreApplication::processEvents(); + QCOMPARE(s_staticSingleShotUser->helper.calls, s_staticSingleShotUser->calls()); +} + +// NOTE: to prevent any static initialization order fiasco, we handle QTEST_MAIN +// ourselves, but instantiate the staticSingleShotUser before qApp + +int main(int argc, char *argv[]) +{ + StaticSingleShotUser staticSingleShotUser; + s_staticSingleShotUser = &staticSingleShotUser; + QTEST_MAIN_IMPL(tst_QTimer) +} + #include "tst_qtimer.moc" diff --git a/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp b/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp index 07976aa056..6af5b8d586 100644 --- a/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp +++ b/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp @@ -28,6 +28,7 @@ #include #include +#include #define INVOKE_COUNT 10000 @@ -37,6 +38,8 @@ class qtimer_vs_qmetaobject : public QObject private slots: void bench(); void bench_data(); + void benchBackgroundThread(); + void benchBackgroundThread_data() { bench_data(); } }; class InvokeCounter : public QObject { @@ -47,8 +50,10 @@ public slots: void invokeSlot() { count++; if (count == INVOKE_COUNT) - QTestEventLoop::instance().exitLoop(); + emit allInvoked(); } +signals: + void allInvoked(); protected: int count; }; @@ -98,11 +103,11 @@ void qtimer_vs_qmetaobject::bench() QBENCHMARK { InvokeCounter invokeCounter; + QSignalSpy spy(&invokeCounter, &InvokeCounter::allInvoked); for(int i = 0; i < INVOKE_COUNT; ++i) { invoke(&invokeCounter); } - QTestEventLoop::instance().enterLoop(10); - QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY(spy.wait(10000)); } } @@ -118,6 +123,16 @@ void qtimer_vs_qmetaobject::bench_data() QTest::addRow("invokeMethod_functor") << 6; } +void qtimer_vs_qmetaobject::benchBackgroundThread() +{ +#if !QT_CONFIG(cxx11_future) + QSKIP("This test requires QThread::create"); +#else + QScopedPointer thread(QThread::create([this]() { bench(); })); + thread->start(); + QVERIFY(thread->wait()); +#endif +} QTEST_MAIN(qtimer_vs_qmetaobject) From 6accc102d3300986fcfa7417d3371f6556f8361a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 5 Apr 2019 12:51:10 +0200 Subject: [PATCH 169/292] QStyle/QWidget: Avoid repetitive invocation of QStyleHelper::dpiScaled() Store the result of QStyleHelper::dpiScaled() or functions dependent on it in a variable, preparing the addition of a DPI parameter. Task-number: QTBUG-45055 Change-Id: Ic70d65b590793c29a4b1f7a7a5312dd169517fc5 Reviewed-by: Richard Moe Gustavsen --- .../styles/windowsvista/qwindowsxpstyle.cpp | 17 +++++++++++------ src/widgets/dialogs/qwizard.cpp | 10 ++++++---- src/widgets/dialogs/qwizard_win.cpp | 4 ++-- src/widgets/styles/qwindowsstyle.cpp | 6 ++++-- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp index 90026e5bf0..a331b2ee87 100644 --- a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp +++ b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp @@ -1486,11 +1486,13 @@ case PE_Frame: // Inner white border p->setPen(QPen(option->palette.base().color(), 0)); - p->drawRect(QRectF(option->rect).adjusted(QStyleHelper::dpiScaled(0.5), QStyleHelper::dpiScaled(0.5), - QStyleHelper::dpiScaled(-1), QStyleHelper::dpiScaled(-1))); + const auto topLevelAdjustment = QStyleHelper::dpiScaled(0.5); + const auto bottomRightAdjustment = QStyleHelper::dpiScaled(-1); + p->drawRect(QRectF(option->rect).adjusted(topLevelAdjustment, topLevelAdjustment, + bottomRightAdjustment, bottomRightAdjustment)); // Outer dark border p->setPen(QPen(bordercolor, 0)); - p->drawRect(QRectF(option->rect).adjusted(0, 0, QStyleHelper::dpiScaled(-0.5), QStyleHelper::dpiScaled(-0.5))); + p->drawRect(QRectF(option->rect).adjusted(0, 0, -topLevelAdjustment, -topLevelAdjustment)); p->setPen(oldPen); return; } else if (fillType == BT_NONE) { @@ -3534,9 +3536,12 @@ QRect QWindowsXPStyle::subControlRect(ComplexControl cc, const QStyleOptionCompl qRound(QStyleHelper::dpiScaled(16)), he - qRound(QStyleHelper::dpiScaled(2))); break; - case SC_ComboBoxEditField: - rect = QRect(x + qRound(QStyleHelper::dpiScaled(2)), y + qRound(QStyleHelper::dpiScaled(2)), - wi - qRound(QStyleHelper::dpiScaled(3 + 16)), he - qRound(QStyleHelper::dpiScaled(4))); + case SC_ComboBoxEditField: { + const int frame = qRound(QStyleHelper::dpiScaled(2)); + rect = QRect(x + frame, y + frame, + wi - qRound(QStyleHelper::dpiScaled(3 + 16)), + he - qRound(QStyleHelper::dpiScaled(4))); + } break; case SC_ComboBoxListBoxPopup: diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index c692a0f8db..f428114bbe 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -1595,23 +1595,25 @@ bool QWizardPrivate::handleAeroStyleChange() bool vistaMargins = false; if (isVistaThemeEnabled()) { + const int topOffset = vistaHelper->topOffset(); + const int topPadding = vistaHelper->topPadding(); if (isVistaThemeEnabled(QVistaHelper::VistaAero)) { if (isWindow) { vistaHelper->setDWMTitleBar(QVistaHelper::ExtendedTitleBar); q->installEventFilter(vistaHelper); } q->setMouseTracking(true); - antiFlickerWidget->move(0, vistaHelper->titleBarSize() + vistaHelper->topOffset()); + antiFlickerWidget->move(0, vistaHelper->titleBarSize() + topOffset); vistaHelper->backButton()->move( - 0, vistaHelper->topOffset() // ### should ideally work without the '+ 1' - - qMin(vistaHelper->topOffset(), vistaHelper->topPadding() + 1)); + 0, topOffset // ### should ideally work without the '+ 1' + - qMin(topOffset, topPadding + 1)); vistaMargins = true; vistaHelper->backButton()->show(); } else { if (isWindow) vistaHelper->setDWMTitleBar(QVistaHelper::NormalTitleBar); q->setMouseTracking(true); - antiFlickerWidget->move(0, vistaHelper->topOffset()); + antiFlickerWidget->move(0, topOffset); vistaHelper->backButton()->move(0, -1); // ### should ideally work with (0, 0) } if (isWindow) diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp index 4986bbc75f..95f8f6a878 100644 --- a/src/widgets/dialogs/qwizard_win.cpp +++ b/src/widgets/dialogs/qwizard_win.cpp @@ -293,9 +293,9 @@ void QVistaHelper::drawTitleBar(QPainter *painter) int glowOffset = 0; if (vistaState() == VistaAero) { - textHeight += 2 * glowSize(); - textWidth += 2 * glowSize(); glowOffset = glowSize(); + textHeight += 2 * glowOffset; + textWidth += 2 * glowOffset; } const int titleLeft = (wizard->layoutDirection() == Qt::LeftToRight diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index 4e450813cb..7b5da9bfa8 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -802,8 +802,10 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPen oldPen = p->pen(); p->setPen(QPen(opt->palette.shadow().color(), 0)); QRectF rect = opt->rect; - rect.adjust(QStyleHelper::dpiScaled(0.5), QStyleHelper::dpiScaled(0.5), - QStyleHelper::dpiScaled(-1.5), QStyleHelper::dpiScaled(-1.5)); + const qreal topLevelAdjustment = QStyleHelper::dpiScaled(0.5); + const qreal bottomRightAdjustment = QStyleHelper::dpiScaled(-1.5); + rect.adjust(topLevelAdjustment, topLevelAdjustment, + bottomRightAdjustment, bottomRightAdjustment); p->drawRect(rect); p->setPen(oldPen); break; From d54de865a49c2012d1b54fca878a432020a0f488 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 27 Nov 2018 10:25:51 +0100 Subject: [PATCH 170/292] uic: Port method calls to python Use the language helper for dereferencing pointers and end of line. Task-number: PYSIDE-797 Change-Id: Icbca9015f2a3e8800ad4a56edf8fef9ee43f4528 Reviewed-by: Qt CI Bot Reviewed-by: Cristian Maureira-Fredes --- src/tools/uic/cpp/cppwriteinitialization.cpp | 343 ++++++++++++------- src/tools/uic/shared/language.cpp | 11 + src/tools/uic/shared/language.h | 2 + 3 files changed, 228 insertions(+), 128 deletions(-) diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 9986e7306d..c5b3ad47ce 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -120,7 +120,8 @@ namespace { // Write object->setFoo(x); template void writeSetter(const QString &indent, const QString &varName,const QString &setter, Value v, QTextStream &str) { - str << indent << varName << "->" << setter << '(' << v << ");\n"; + str << indent << varName << language::derefPointer + << setter << '(' << v << ')' << language::eol; } static inline bool iconHasStatePixmaps(const DomResourceIcon *i) { @@ -529,7 +530,8 @@ void WriteInitialization::acceptUI(DomUI *node) continue; } - m_output << m_indent << b.objName << "->setBuddy(" << b.buddy << ");\n"; + m_output << m_indent << b.objName << language::derefPointer + << "setBuddy(" << b.buddy << ')' << language::eol; } if (!m_buddies.empty()) m_output << language::closeQtConfig(shortcutConfigKey()); @@ -540,7 +542,8 @@ void WriteInitialization::acceptUI(DomUI *node) if (!m_delayedActionInitialization.isEmpty()) m_output << "\n" << m_delayedActionInitialization; - m_output << "\n" << m_indent << "retranslateUi(" << varName << ");\n"; + m_output << "\n" << m_indent << language::self + << "retranslateUi(" << varName << ')' << language::eol; if (node->elementConnections()) acceptConnections(node->elementConnections()); @@ -548,8 +551,10 @@ void WriteInitialization::acceptUI(DomUI *node) if (!m_delayedInitialization.isEmpty()) m_output << "\n" << m_delayedInitialization << "\n"; - if (m_option.autoConnection) - m_output << "\n" << m_indent << "QMetaObject::connectSlotsByName(" << varName << ");\n"; + if (m_option.autoConnection) { + m_output << "\n" << m_indent << "QMetaObject" << language::qualifier + << "connectSlotsByName(" << varName << ')' << language::eol; + } m_output << m_option.indent << language::endFunctionDefinition("setupUi"); @@ -586,9 +591,11 @@ void WriteInitialization::addWizardPage(const QString &pageVarName, const DomWid } } if (id.isEmpty()) { - m_output << m_indent << parentWidget << "->addPage(" << pageVarName << ");\n"; + m_output << m_indent << parentWidget << language::derefPointer + << "addPage(" << pageVarName << ')' << language::eol; } else { - m_output << m_indent << parentWidget << "->setPage(" << id << ", " << pageVarName << ");\n"; + m_output << m_indent << parentWidget << language::derefPointer + << "setPage(" << id << ", " << pageVarName << ')' << language::eol; } } @@ -667,26 +674,31 @@ void WriteInitialization::acceptWidget(DomWidget *node) if (cwi->extends(parentClass, QLatin1String("QMainWindow"))) { if (cwi->extends(className, QLatin1String("QMenuBar"))) { - m_output << m_indent << parentWidget << "->setMenuBar(" << varName <<");\n"; + m_output << m_indent << parentWidget << language::derefPointer + << "setMenuBar(" << varName << ')' << language::eol; } else if (cwi->extends(className, QLatin1String("QToolBar"))) { - m_output << m_indent << parentWidget << "->addToolBar(" - << toolBarAreaStringFromDOMAttributes(attributes) << varName << ");\n"; + m_output << m_indent << parentWidget << language::derefPointer << "addToolBar(" + << toolBarAreaStringFromDOMAttributes(attributes) << varName + << ')' << language::eol; if (const DomProperty *pbreak = attributes.value(QLatin1String("toolBarBreak"))) { if (pbreak->elementBool() == QLatin1String("true")) { - m_output << m_indent << parentWidget << "->insertToolBarBreak(" << varName << ");\n"; + m_output << m_indent << parentWidget << language::derefPointer + << "insertToolBarBreak(" << varName << ')' << language::eol; } } } else if (cwi->extends(className, QLatin1String("QDockWidget"))) { - m_output << m_indent << parentWidget << "->addDockWidget("; + m_output << m_indent << parentWidget << language::derefPointer << "addDockWidget("; if (DomProperty *pstyle = attributes.value(QLatin1String("dockWidgetArea"))) m_output << "Qt::" << language::dockWidgetArea(pstyle->elementNumber()) << ", "; m_output << varName << ");\n"; } else if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QStatusBar"))) { - m_output << m_indent << parentWidget << "->setStatusBar(" << varName << ");\n"; + m_output << m_indent << parentWidget << language::derefPointer + << "setStatusBar(" << varName << ')' << language::eol; } else { - m_output << m_indent << parentWidget << "->setCentralWidget(" << varName << ");\n"; + m_output << m_indent << parentWidget << language::derefPointer + << "setCentralWidget(" << varName << ')' << language::eol; } } @@ -695,7 +707,8 @@ void WriteInitialization::acceptWidget(DomWidget *node) if (addPageMethod.isEmpty()) addPageMethod = cwi->simpleContainerAddPageMethod(parentClass); if (!addPageMethod.isEmpty()) { - m_output << m_indent << parentWidget << "->" << addPageMethod << '(' << varName << ");\n"; + m_output << m_indent << parentWidget << language::derefPointer + << addPageMethod << '(' << varName << ')' << language::eol; } else if (m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("QWizard"))) { addWizardPage(varName, node, parentWidget); } else if (m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("QToolBox"))) { @@ -704,19 +717,21 @@ void WriteInitialization::acceptWidget(DomWidget *node) QString icon; if (const DomProperty *picon = attributes.value(QLatin1String("icon"))) icon = QLatin1String(", ") + iconCall(picon); // Side effect: Writes icon definition + m_output << m_indent << parentWidget << language::derefPointer << "addItem(" + << varName << icon << ", " << noTrCall(plabelString, pageDefaultString) + << ')' << language::eol; - m_output << m_indent << parentWidget << "->addItem(" << varName << icon - << ", " << noTrCall(plabelString, pageDefaultString) << ");\n"; - - autoTrOutput(plabelString, pageDefaultString) << m_indent << parentWidget << "->setItemText(" - << parentWidget << "->indexOf(" << varName << "), " << autoTrCall(plabelString, pageDefaultString) << ");\n"; + autoTrOutput(plabelString, pageDefaultString) << m_indent << parentWidget + << language::derefPointer << "setItemText(" << parentWidget + << language::derefPointer << "indexOf(" << varName << "), " + << autoTrCall(plabelString, pageDefaultString) << ')' << language::eol; if (DomProperty *ptoolTip = attributes.value(QLatin1String("toolTip"))) { autoTrOutput(ptoolTip->elementString()) << language::openQtConfig(toolTipConfigKey()) - << m_indent << parentWidget << "->setItemToolTip(" << parentWidget - << "->indexOf(" << varName << "), " - << autoTrCall(ptoolTip->elementString()) << ");\n" + << m_indent << parentWidget << language::derefPointer << "setItemToolTip(" << parentWidget + << language::derefPointer << "indexOf(" << varName << "), " + << autoTrCall(ptoolTip->elementString()) << ')' << language::eol << language::closeQtConfig(toolTipConfigKey()); } } else if (m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("QTabWidget"))) { @@ -725,26 +740,28 @@ void WriteInitialization::acceptWidget(DomWidget *node) QString icon; if (const DomProperty *picon = attributes.value(QLatin1String("icon"))) icon = QLatin1String(", ") + iconCall(picon); // Side effect: Writes icon definition - m_output << m_indent << parentWidget << "->addTab(" << varName << icon - << ", " << "QString());\n"; + m_output << m_indent << parentWidget << language::derefPointer << "addTab(" + << varName << icon << ", " << "QString())" << language::eol; - autoTrOutput(ptitleString, pageDefaultString) << m_indent << parentWidget << "->setTabText(" - << parentWidget << "->indexOf(" << varName << "), " << autoTrCall(ptitleString, pageDefaultString) << ");\n"; + autoTrOutput(ptitleString, pageDefaultString) << m_indent << parentWidget + << language::derefPointer << "setTabText(" << parentWidget + << language::derefPointer << "indexOf(" << varName << "), " + << autoTrCall(ptitleString, pageDefaultString) << ')' << language::eol; if (const DomProperty *ptoolTip = attributes.value(QLatin1String("toolTip"))) { autoTrOutput(ptoolTip->elementString()) << language::openQtConfig(toolTipConfigKey()) - << m_indent << parentWidget << "->setTabToolTip(" << parentWidget - << "->indexOf(" << varName << "), " - << autoTrCall(ptoolTip->elementString()) << ");\n" + << m_indent << parentWidget << language::derefPointer << "setTabToolTip(" + << parentWidget << language::derefPointer << "indexOf(" << varName + << "), " << autoTrCall(ptoolTip->elementString()) << ')' << language::eol << language::closeQtConfig(toolTipConfigKey()); } if (const DomProperty *pwhatsThis = attributes.value(QLatin1String("whatsThis"))) { autoTrOutput(pwhatsThis->elementString()) << language::openQtConfig(whatsThisConfigKey()) - << m_indent << parentWidget << "->setTabWhatsThis(" << parentWidget - << "->indexOf(" << varName << "), " - << autoTrCall(pwhatsThis->elementString()) << ");\n" + << m_indent << parentWidget << language::derefPointer << "setTabWhatsThis(" + << parentWidget << language::derefPointer << "indexOf(" << varName + << "), " << autoTrCall(pwhatsThis->elementString()) << ')' << language::eol << language::closeQtConfig(whatsThisConfigKey()); } } @@ -779,8 +796,9 @@ void WriteInitialization::acceptWidget(DomWidget *node) headerProperties << fakeProperty; } } - writeProperties(varName + QLatin1String("->header()"), QLatin1String("QHeaderView"), - headerProperties, WritePropertyIgnoreObjectName); + writeProperties(varName + language::derefPointer + QLatin1String("header()"), + QLatin1String("QHeaderView"), headerProperties, + WritePropertyIgnoreObjectName); } else if (cwi->extendsOneOf(className, tables)) { static const QLatin1String headerPrefixes[] = { @@ -798,8 +816,9 @@ void WriteInitialization::acceptWidget(DomWidget *node) headerProperties << fakeProperty; } } - writeProperties(varName + QLatin1String("->") + headerPrefix + QLatin1String("()"), - QLatin1String("QHeaderView"), + const QString headerVar = varName + language::derefPointer + + headerPrefix + QLatin1String("()"); + writeProperties(headerVar, QLatin1String("QHeaderView"), headerProperties, WritePropertyIgnoreObjectName); } } @@ -816,8 +835,10 @@ void WriteInitialization::acceptWidget(DomWidget *node) continue; } - if (!name.isEmpty()) - m_output << m_indent << name << "->raise();\n"; + if (!name.isEmpty()) { + m_output << m_indent << name << language::derefPointer << "raise()" + << language::eol; + } } } @@ -853,7 +874,8 @@ void WriteInitialization::addButtonGroup(const DomWidget *buttonNode, const QStr m_buttonGroups.insert(groupName); writeProperties(groupName, className, group->elementProperty()); } - m_output << m_indent << groupName << "->addButton(" << varName << ");\n"; + m_output << m_indent << groupName << language::derefPointer << "addButton(" + << varName << ')' << language::eol; } void WriteInitialization::acceptLayout(DomLayout *node) @@ -958,9 +980,12 @@ void WriteInitialization::writePropertyList(const QString &varName, return; const QStringList list = value.split(QLatin1Char(',')); const int count = list.count(); - for (int i = 0; i < count; i++) - if (list.at(i) != defaultValue) - m_output << m_indent << varName << "->" << setFunction << '(' << i << ", " << list.at(i) << ");\n"; + for (int i = 0; i < count; i++) { + if (list.at(i) != defaultValue) { + m_output << m_indent << varName << language::derefPointer << setFunction + << '(' << i << ", " << list.at(i) << ')' << language::eol; + } + } } void WriteInitialization::acceptSpacer(DomSpacer *node) @@ -1007,7 +1032,7 @@ void WriteInitialization::acceptLayoutItem(DomLayoutItem *node) const QString layoutName = m_driver->findOrInsertLayout(layout); const QString itemName = m_driver->findOrInsertLayoutItem(node); - m_output << "\n" << m_indent << layoutName << "->" + m_output << "\n" << m_indent << layoutName << language::derefPointer << "" << layoutAddMethod(node->kind(), layout->attributeClass()) << '('; if (layout->attributeClass() == QLatin1String("QGridLayout")) { @@ -1078,14 +1103,16 @@ void WriteInitialization::acceptActionRef(DomActionRef *node) if (m_widgetChain.top() && actionName == QLatin1String("separator")) { // separator is always reserved! - m_actionOut << m_indent << varName << "->addSeparator();\n"; + m_actionOut << m_indent << varName << language::derefPointer + << "addSeparator()" << language::eol; return; } const DomWidget *domWidget = m_driver->widgetByName(actionName); if (domWidget && m_uic->isMenu(domWidget->attributeClass())) { - m_actionOut << m_indent << varName << "->addAction(" - << m_driver->findOrInsertWidget(domWidget) << "->menuAction());\n"; + m_actionOut << m_indent << varName << language::derefPointer + << "addAction(" << m_driver->findOrInsertWidget(domWidget) + << language::derefPointer << "menuAction())" << language::eol; return; } @@ -1096,8 +1123,9 @@ void WriteInitialization::acceptActionRef(DomActionRef *node) return; } - m_actionOut << m_indent << varName << "->addAction(" - << m_driver->findOrInsertAction(domAction) << ");\n"; + m_actionOut << m_indent << varName << language::derefPointer + << "addAction(" << m_driver->findOrInsertAction(domAction) + << ')' << language::eol; } QString WriteInitialization::writeStringListProperty(const DomStringList *list) const @@ -1146,20 +1174,31 @@ void WriteInitialization::writeProperties(const QString &varName, if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QAxWidget"))) { DomPropertyMap properties = propertyMap(lst); if (DomProperty *p = properties.value(QLatin1String("control"))) { - m_output << m_indent << varName << "->setControl(" - << language::qstring(toString(p->elementString()), m_dindent) << ");\n"; + m_output << m_indent << varName << language::derefPointer << "setControl(" + << language::qstring(toString(p->elementString()), m_dindent) + << ')' << language::eol; } } QString indent; if (!m_widgetChain.top()) { indent = m_option.indent; - m_output << m_indent << "if (" << varName << "->objectName().isEmpty())\n"; + switch (language::language()) { + case Language::Cpp: + m_output << m_indent << "if (" << varName << "->objectName().isEmpty())\n"; + break; + case Language::Python: + m_output << m_indent << "if " << varName << ".objectName():\n"; + break; + } } if (!(flags & WritePropertyIgnoreObjectName)) { - m_output << m_indent << indent << varName - << "->setObjectName(" << language::qstring(varName, m_dindent) - << ");\n"; + QString objectName = varName; + if (!language::self.isEmpty() && objectName.startsWith(language::self)) + objectName.remove(0, language::self.size()); + m_output << m_indent << indent + << varName << language::derefPointer << "setObjectName(" + << language::qstring(objectName, m_dindent) << ')' << language::eol; } int leftMargin, topMargin, rightMargin, bottomMargin; @@ -1176,13 +1215,14 @@ void WriteInitialization::writeProperties(const QString &varName, // special case for the property `geometry': Do not use position if (isTopLevel && propertyName == QLatin1String("geometry") && p->elementRect()) { const DomRect *r = p->elementRect(); - m_output << m_indent << varName << "->resize(" << r->elementWidth() << ", " << r->elementHeight() << ");\n"; + m_output << m_indent << varName << language::derefPointer << "resize(" + << r->elementWidth() << ", " << r->elementHeight() << ')' << language::eol; continue; } if (propertyName == QLatin1String("currentRow") // QListWidget::currentRow && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QListWidget"))) { - m_delayedOut << m_indent << varName << "->setCurrentRow(" - << p->elementNumber() << ");\n"; + m_delayedOut << m_indent << varName << language::derefPointer + << "setCurrentRow(" << p->elementNumber() << ')' << language::eol; continue; } static const QStringList currentIndexWidgets = { @@ -1191,14 +1231,15 @@ void WriteInitialization::writeProperties(const QString &varName, }; if (propertyName == QLatin1String("currentIndex") // set currentIndex later && (m_uic->customWidgetsInfo()->extendsOneOf(className, currentIndexWidgets))) { - m_delayedOut << m_indent << varName << "->setCurrentIndex(" - << p->elementNumber() << ");\n"; + m_delayedOut << m_indent << varName << language::derefPointer + << "setCurrentIndex(" << p->elementNumber() << ')' << language::eol; continue; } if (propertyName == QLatin1String("tabSpacing") && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QToolBox"))) { - m_delayedOut << m_indent << varName << "->layout()->setSpacing(" - << p->elementNumber() << ");\n"; + m_delayedOut << m_indent << varName << language::derefPointer + << "layout()" << language::derefPointer << "setSpacing(" + << p->elementNumber() << ')' << language::eol; continue; } if (propertyName == QLatin1String("control") // ActiveQt support @@ -1225,10 +1266,13 @@ void WriteInitialization::writeProperties(const QString &varName, if (p->elementEnum() == QLatin1String("Qt::Vertical")) shape = QLatin1String("QFrame::VLine"); - m_output << m_indent << varName << "->setFrameShape(" << shape << ");\n"; + m_output << m_indent << varName << language::derefPointer << "setFrameShape(" + << shape << ')' << language::eol; // QFrame Default is 'Plain'. Make the line 'Sunken' unless otherwise specified - if (!frameShadowEncountered) - m_output << m_indent << varName << "->setFrameShadow(QFrame::Sunken);\n"; + if (!frameShadowEncountered) { + m_output << m_indent << varName << language::derefPointer + << "setFrameShadow(QFrame::Sunken)" << language::eol; + } continue; } else if ((flags & WritePropertyIgnoreMargin) && propertyName == QLatin1String("margin")) { continue; @@ -1260,25 +1304,28 @@ void WriteInitialization::writeProperties(const QString &varName, QString setFunction; - if (stdset) { - setFunction = QLatin1String("->set") - + propertyName.at(0).toUpper() - + propertyName.midRef(1) - + QLatin1Char('('); - } else { - setFunction += QLatin1String("->setProperty(\"") - + propertyName - + QLatin1String("\", QVariant"); - if (p->kind() == DomProperty::Enum) - setFunction += QLatin1String("::fromValue"); - setFunction += QLatin1Char('('); - } + { + QTextStream str(&setFunction); + if (stdset) { + str << language::derefPointer <<"set" << propertyName.at(0).toUpper() + << propertyName.midRef(1) << '('; + } else { + str << language::derefPointer << QLatin1String("setProperty(\"") + << propertyName << "\", "; + if (language::language() == Language::Cpp) { + str << "QVariant"; + if (p->kind() == DomProperty::Enum) + str << "::fromValue"; + str << '('; + } + } + } // QTextStream QString varNewName = varName; switch (p->kind()) { case DomProperty::Bool: { - propertyValue = p->elementBool(); + propertyValue = language::boolValue(p->elementBool() == language::cppTrue); break; } case DomProperty::Color: @@ -1303,7 +1350,7 @@ void WriteInitialization::writeProperties(const QString &varName, break; case DomProperty::CursorShape: if (p->hasAttributeStdset() && !p->attributeStdset()) - varNewName += QLatin1String("->viewport()"); + varNewName += language::derefPointer + QLatin1String("viewport()"); propertyValue = QString::fromLatin1("QCursor(Qt::%1)") .arg(p->elementCursorShape()); break; @@ -1370,9 +1417,9 @@ void WriteInitialization::writeProperties(const QString &varName, } case DomProperty::SizePolicy: { const QString spName = writeSizePolicy( p->elementSizePolicy()); - m_output << m_indent << spName << QString::fromLatin1( - ".setHeightForWidth(%1->sizePolicy().hasHeightForWidth());\n") - .arg(varName); + m_output << m_indent << spName << ".setHeightForWidth(" + << varName << language::derefPointer << "sizePolicy().hasHeightForWidth())" + << language::eol; propertyValue = spName; break; @@ -1482,9 +1529,9 @@ void WriteInitialization::writeProperties(const QString &varName, if (!configKey.isEmpty()) o << language::openQtConfig(configKey); o << m_indent << varNewName << setFunction << propertyValue; - if (!stdset) + if (!stdset && language::language() == Language::Cpp) o << ')'; - o << ");\n"; + o << ')' << language::eol; if (!configKey.isEmpty()) o << language::closeQtConfig(configKey); @@ -1496,7 +1543,7 @@ void WriteInitialization::writeProperties(const QString &varName, } } if (leftMargin != -1 || topMargin != -1 || rightMargin != -1 || bottomMargin != -1) { - m_output << m_indent << varName << "->setContentsMargins(" + m_output << m_indent << varName << language::derefPointer << "setContentsMargins(" << leftMargin << ", " << topMargin << ", " << rightMargin << ", " << bottomMargin << ");\n"; } @@ -1562,15 +1609,15 @@ QString WriteInitialization::writeFontProperties(const DomFont *f) if (f->hasElementBold()) { m_output << m_indent << fontName << ".setBold(" - << (f->elementBold() ? "true" : "false") << ");\n"; + << language::boolValue(f->elementBold()) << ')' << language::eol; } if (f->hasElementItalic()) { m_output << m_indent << fontName << ".setItalic(" - << (f->elementItalic() ? "true" : "false") << ");\n"; + << language::boolValue(f->elementItalic()) << ')' << language::eol; } if (f->hasElementUnderline()) { m_output << m_indent << fontName << ".setUnderline(" - << (f->elementUnderline() ? "true" : "false") << ");\n"; + << language::boolValue(f->elementUnderline()) << ')' << language::eol; } if (f->hasElementWeight() && f->elementWeight() > 0) { m_output << m_indent << fontName << ".setWeight(" @@ -1578,11 +1625,11 @@ QString WriteInitialization::writeFontProperties(const DomFont *f) } if (f->hasElementStrikeOut()) { m_output << m_indent << fontName << ".setStrikeOut(" - << (f->elementStrikeOut() ? "true" : "false") << ");\n"; + << language::boolValue(f->elementStrikeOut()) << ')' << language::eol; } if (f->hasElementKerning()) { m_output << m_indent << fontName << ".setKerning(" - << (f->elementKerning() ? "true" : "false") << ");\n"; + << language::boolValue(f->elementKerning()) << ')' << language::eol; } if (f->hasElementAntialiasing()) { m_output << m_indent << fontName << ".setStyleStrategy(" @@ -1889,10 +1936,10 @@ void WriteInitialization::writeBrush(const DomBrush *brush, const QString &brush } else { const DomColor *color = brush->elementColor(); m_output << m_indent << "QBrush " << brushName << '(' - << domColor2QString(color) << ");\n"; + << domColor2QString(color) << ')' << language::eol; m_output << m_indent << brushName << ".setStyle(" - << "Qt::" << style << ");\n"; + << language::qtQualifier << style << ')' << language::eol; } } @@ -2000,13 +2047,15 @@ void WriteInitialization::initializeComboBox(DomWidget *w) if (icon) iconValue = iconCall(icon); - m_output << m_indent << varName << "->addItem("; + m_output << m_indent << varName << language::derefPointer << "addItem("; if (icon) m_output << iconValue << ", "; if (needsTranslation(text->elementString())) { m_output << "QString());\n"; - m_refreshOut << m_indent << varName << "->setItemText(" << i << ", " << trCall(text->elementString()) << ");\n"; + m_refreshOut << m_indent << varName << language::derefPointer + << "setItemText(" << i << ", " << trCall(text->elementString()) + << ')' << language::eol; } else { m_output << noTrCall(text->elementString()) << ");\n"; } @@ -2021,9 +2070,13 @@ QString WriteInitialization::disableSorting(DomWidget *w, const QString &varName if (!w->elementItem().isEmpty()) { tempName = m_driver->unique(QLatin1String("__sortingEnabled")); m_refreshOut << "\n"; - m_refreshOut << m_indent << "const bool " << tempName - << " = " << varName << "->isSortingEnabled();\n"; - m_refreshOut << m_indent << varName << "->setSortingEnabled(false);\n"; + m_refreshOut << m_indent; + if (language::language() == Language::Cpp) + m_refreshOut << "const bool "; + m_refreshOut << tempName << " = " << varName << language::derefPointer + << "isSortingEnabled()" << language::eol + << m_indent << varName << language::derefPointer + << "setSortingEnabled(" << language::boolValue(false) << ')' << language::eol; } return tempName; } @@ -2031,7 +2084,8 @@ QString WriteInitialization::disableSorting(DomWidget *w, const QString &varName void WriteInitialization::enableSorting(DomWidget *w, const QString &varName, const QString &tempName) { if (!w->elementItem().isEmpty()) { - m_refreshOut << m_indent << varName << "->setSortingEnabled(" << tempName << ");\n\n"; + m_refreshOut << m_indent << varName << language::derefPointer + << "setSortingEnabled(" << tempName << ')' << language::eol << '\n'; } } @@ -2056,7 +2110,7 @@ void WriteInitialization::addInitializer(Item *item, if (!value.isEmpty()) { QString setter; QTextStream str(&setter); - str << "->set" << name.at(0).toUpper() << name.midRef(1) << '('; + str << language::derefPointer << "set" << name.at(0).toUpper() << name.midRef(1) << '('; if (column >= 0) str << column << ", "; str << value << ");"; @@ -2106,10 +2160,11 @@ void WriteInitialization::addQtFlagsInitializer(Item *item, const DomPropertyMap &properties, const QString &name, int column) const { if (const DomProperty *p = properties.value(name)) { + const QString orOperator = QLatin1Char('|') + language::qtQualifier; QString v = p->elementSet(); if (!v.isEmpty()) { - v.replace(QLatin1Char('|'), QLatin1String("|Qt::")); - addInitializer(item, name, column, QLatin1String("Qt::") + v); + v.replace(QLatin1Char('|'), orOperator); + addInitializer(item, name, column, language::qtQualifier + v); } } } @@ -2124,7 +2179,7 @@ void WriteInitialization::addQtEnumInitializer(Item *item, if (const DomProperty *p = properties.value(name)) { QString v = p->elementEnum(); if (!v.isEmpty()) - addInitializer(item, name, column, QLatin1String("Qt::") + v); + addInitializer(item, name, column, language::qtQualifier + v); } } @@ -2173,7 +2228,9 @@ void WriteInitialization::initializeListWidget(DomWidget *w) addCommonInitializers(&item, properties); item.writeSetupUi(varName); - item.writeRetranslateUi(varName + QLatin1String("->item(") + QString::number(i) + QLatin1Char(')')); + QString parentPath; + QTextStream(&parentPath) << varName << language::derefPointer << "item(" << i << ')'; + item.writeRetranslateUi(parentPath); } enableSorting(w, varName, tempName); } @@ -2194,14 +2251,19 @@ void WriteInitialization::initializeTreeWidget(DomWidget *w) if (const DomProperty *p = properties.value(QLatin1String("text"))) { DomString *str = p->elementString(); - if (str && str->text().isEmpty()) - m_output << m_indent << varName << "->headerItem()->setText(" << i << ", QString());\n"; + if (str && str->text().isEmpty()) { + m_output << m_indent << varName << language::derefPointer + << "headerItem()" << language::derefPointer << "setText(" + << i << ", QString())" << language::eol; + } } } const QString itemName = item.writeSetupUi(QString(), Item::DontConstruct); - item.writeRetranslateUi(varName + QLatin1String("->headerItem()")); - if (!itemName.isNull()) - m_output << m_indent << varName << "->setHeaderItem(" << itemName << ");\n"; + item.writeRetranslateUi(varName + language::derefPointer + QLatin1String("headerItem()")); + if (!itemName.isNull()) { + m_output << m_indent << varName << language::derefPointer + << "setHeaderItem(" << itemName << ')' << language::eol; + } if (w->elementItem().empty()) return; @@ -2212,7 +2274,9 @@ void WriteInitialization::initializeTreeWidget(DomWidget *w) for (int i = 0; i < items.count(); i++) { Item *itm = items[i]; itm->writeSetupUi(varName); - itm->writeRetranslateUi(varName + QLatin1String("->topLevelItem(") + QString::number(i) + QLatin1Char(')')); + QString parentPath; + QTextStream(&parentPath) << varName << language::derefPointer << "topLevelItem(" << i << ')'; + itm->writeRetranslateUi(parentPath); delete itm; } @@ -2274,8 +2338,10 @@ void WriteInitialization::initializeTableWidget(DomWidget *w) const auto &columns = w->elementColumn(); if (!columns.empty()) { - m_output << m_indent << "if (" << varName << "->columnCount() < " << columns.size() << ")\n" - << m_dindent << varName << "->setColumnCount(" << columns.size() << ");\n"; + m_output << m_indent << "if (" << varName << language::derefPointer << "columnCount() < " + << columns.size() << ")\n" + << m_dindent << varName << language::derefPointer << "setColumnCount(" + << columns.size() << ')' << language::eol; } for (int i = 0; i < columns.size(); ++i) { @@ -2287,8 +2353,12 @@ void WriteInitialization::initializeTableWidget(DomWidget *w) addCommonInitializers(&item, properties); QString itemName = item.writeSetupUi(QString(), Item::ConstructItemAndVariable); - item.writeRetranslateUi(varName + QLatin1String("->horizontalHeaderItem(") + QString::number(i) + QLatin1Char(')')); - m_output << m_indent << varName << "->setHorizontalHeaderItem(" << i << ", " << itemName << ");\n"; + QString parentPath; + QTextStream(&parentPath) << varName << language::derefPointer + << "horizontalHeaderItem(" << i << ')'; + item.writeRetranslateUi(parentPath); + m_output << m_indent << varName << language::derefPointer << "setHorizontalHeaderItem(" + << i << ", " << itemName << ')' << language::eol; } } @@ -2296,8 +2366,9 @@ void WriteInitialization::initializeTableWidget(DomWidget *w) const auto &rows = w->elementRow(); if (!rows.isEmpty()) { - m_output << m_indent << "if (" << varName << "->rowCount() < " << rows.size() << ")\n" - << m_dindent << varName << "->setRowCount(" << rows.size() << ");\n"; + m_output << m_indent << "if (" << varName << language::derefPointer << "rowCount() < " << rows.size() << ")\n" + << m_dindent << varName << language::derefPointer << "setRowCount(" + << rows.size() << ')' << language::eol; } for (int i = 0; i < rows.size(); ++i) { @@ -2309,8 +2380,11 @@ void WriteInitialization::initializeTableWidget(DomWidget *w) addCommonInitializers(&item, properties); QString itemName = item.writeSetupUi(QString(), Item::ConstructItemAndVariable); - item.writeRetranslateUi(varName + QLatin1String("->verticalHeaderItem(") + QString::number(i) + QLatin1Char(')')); - m_output << m_indent << varName << "->setVerticalHeaderItem(" << i << ", " << itemName << ");\n"; + QString parentPath; + QTextStream(&parentPath) << varName << language::derefPointer << "verticalHeaderItem(" << i << ')'; + item.writeRetranslateUi(parentPath); + m_output << m_indent << varName << language::derefPointer << "setVerticalHeaderItem(" + << i << ", " << itemName << ')' << language::eol; } } @@ -2330,8 +2404,12 @@ void WriteInitialization::initializeTableWidget(DomWidget *w) addCommonInitializers(&item, properties); QString itemName = item.writeSetupUi(QString(), Item::ConstructItemAndVariable); - item.writeRetranslateUi(varName + QLatin1String("->item(") + QString::number(r) + QLatin1String(", ") + QString::number(c) + QLatin1Char(')')); - m_output << m_indent << varName << "->setItem(" << r << ", " << c << ", " << itemName << ");\n"; + QString parentPath; + QTextStream(&parentPath) << varName << language::derefPointer << "item(" << r + << ", " << c << ')'; + item.writeRetranslateUi(parentPath); + m_output << m_indent << varName << language::derefPointer << "setItem(" + << r << ", " << c << ", " << itemName << ')' << language::eol; } } enableSorting(w, varName, tempName); @@ -2347,10 +2425,12 @@ QString WriteInitialization::trCall(const QString &str, const QString &commentHi const bool idBasedTranslations = m_driver->useIdBasedTranslations(); if (m_option.translateFunction.isEmpty()) { - if (idBasedTranslations || m_option.idBased) + if (idBasedTranslations || m_option.idBased) { ts << "qtTrId("; - else - ts << "QCoreApplication::translate(\"" << m_generatedClass << "\", "; + } else { + ts << "QCoreApplication" << language::qualifier << "translate(" + << '"' << m_generatedClass << "\", "; + } } else { ts << m_option.translateFunction << '('; } @@ -2360,7 +2440,7 @@ QString WriteInitialization::trCall(const QString &str, const QString &commentHi if (!idBasedTranslations && !m_option.idBased) { ts << ", "; if (commentHint.isEmpty()) - ts << "nullptr"; + ts << language::nullPtr; else ts << language::charliteral(commentHint, m_dindent); } @@ -2376,7 +2456,8 @@ void WriteInitialization::initializeMenu(DomWidget *w, const QString &/*parentWi const DomAction *action = m_driver->actionByName(menuAction); if (action && action->hasAttributeMenu()) { - m_output << m_indent << menuAction << " = " << menuName << "->menuAction();\n"; + m_output << m_indent << menuAction << " = " << menuName + << language::derefPointer << "menuAction()" << language::eol; } } @@ -2570,7 +2651,10 @@ void WriteInitialization::Item::writeRetranslateUi(const QString &parentPath) generateMultiDirectiveBegin(m_retranslateUiStream, m_retranslateUiData.directives); const QString uniqueName = m_driver->unique(QLatin1String("___") + m_itemClassName.toLower()); - m_retranslateUiStream << m_indent << m_itemClassName << " *" << uniqueName << " = " << parentPath << ";\n"; + m_retranslateUiStream << m_indent; + if (language::language() == Language::Cpp) + m_retranslateUiStream << m_itemClassName << " *"; + m_retranslateUiStream << uniqueName << " = " << parentPath << language::eol; if (m_retranslateUiData.policy == ItemData::GenerateWithMultiDirective) generateMultiDirectiveEnd(m_retranslateUiStream, m_retranslateUiData.directives); @@ -2592,8 +2676,11 @@ void WriteInitialization::Item::writeRetranslateUi(const QString &parentPath) if (!oldDirective.isEmpty()) m_retranslateUiStream << language::closeQtConfig(oldDirective); - for (int i = 0; i < m_children.size(); i++) - m_children[i]->writeRetranslateUi(uniqueName + QLatin1String("->child(") + QString::number(i) + QLatin1Char(')')); + for (int i = 0; i < m_children.size(); i++) { + QString method; + QTextStream(&method) << uniqueName << language::derefPointer << "child(" << i << ')'; + m_children[i]->writeRetranslateUi(method); + } } void WriteInitialization::Item::addSetter(const QString &setter, const QString &directive, bool translatable) diff --git a/src/tools/uic/shared/language.cpp b/src/tools/uic/shared/language.cpp index fe44f95285..d09834f163 100644 --- a/src/tools/uic/shared/language.cpp +++ b/src/tools/uic/shared/language.cpp @@ -401,4 +401,15 @@ void formatConnection(QTextStream &str, const SignalSlot &sender, const SignalSl } } +QString boolValue(bool v) +{ + switch (language()) { + case Language::Cpp: + return v ? cppTrue : cppFalse; + case Language::Python: + return v ? QStringLiteral("True") : QStringLiteral("False"); + } + Q_UNREACHABLE(); +} + } // namespace language diff --git a/src/tools/uic/shared/language.h b/src/tools/uic/shared/language.h index eb50a2db7f..6f0e0bbb2e 100644 --- a/src/tools/uic/shared/language.h +++ b/src/tools/uic/shared/language.h @@ -199,6 +199,8 @@ struct SignalSlot void formatConnection(QTextStream &str, const SignalSlot &sender, const SignalSlot &receiver); +QString boolValue(bool v); + } // namespace language #endif // LANGUAGE_H From be56db2c49be02fd7083c5a02131462748e29bef Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 30 Nov 2018 09:51:47 +0100 Subject: [PATCH 171/292] uic: Fix enum values for Python Add a helper for replacing "::" by "." for Python. Task-number: PYSIDE-797 Change-Id: I017d430b0b8b2ffbbd3300d583603924fee4d479 Reviewed-by: Cristian Maureira-Fredes --- src/tools/uic/cpp/cppwriteinitialization.cpp | 173 ++++++++++--------- src/tools/uic/shared/language.cpp | 11 ++ src/tools/uic/shared/language.h | 2 + 3 files changed, 109 insertions(+), 77 deletions(-) diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index c5b3ad47ce..6ff7323b3d 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -102,11 +102,9 @@ namespace { if (orientation == QLatin1String("Qt::Vertical") || orientation == QLatin1String("Vertical")) isVspacer = true; } - - if (isVspacer) - output << "QSizePolicy::Minimum, " << sizeType << ')'; - else - output << sizeType << ", QSizePolicy::Minimum)"; + const QString horizType = isVspacer ? QLatin1String("QSizePolicy::Minimum") : sizeType; + const QString vertType = isVspacer ? sizeType : QLatin1String("QSizePolicy::Minimum"); + output << language::enumValue(horizType) << ", " << language::enumValue(vertType) << ')'; } @@ -678,7 +676,7 @@ void WriteInitialization::acceptWidget(DomWidget *node) << "setMenuBar(" << varName << ')' << language::eol; } else if (cwi->extends(className, QLatin1String("QToolBar"))) { m_output << m_indent << parentWidget << language::derefPointer << "addToolBar(" - << toolBarAreaStringFromDOMAttributes(attributes) << varName + << language::enumValue(toolBarAreaStringFromDOMAttributes(attributes)) << varName << ')' << language::eol; if (const DomProperty *pbreak = attributes.value(QLatin1String("toolBarBreak"))) { @@ -690,8 +688,10 @@ void WriteInitialization::acceptWidget(DomWidget *node) } else if (cwi->extends(className, QLatin1String("QDockWidget"))) { m_output << m_indent << parentWidget << language::derefPointer << "addDockWidget("; - if (DomProperty *pstyle = attributes.value(QLatin1String("dockWidgetArea"))) - m_output << "Qt::" << language::dockWidgetArea(pstyle->elementNumber()) << ", "; + if (DomProperty *pstyle = attributes.value(QLatin1String("dockWidgetArea"))) { + m_output << "Qt" << language::qualifier + << language::dockWidgetArea(pstyle->elementNumber()) << ", "; + } m_output << varName << ");\n"; } else if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QStatusBar"))) { m_output << m_indent << parentWidget << language::derefPointer @@ -1043,16 +1043,16 @@ void WriteInitialization::acceptLayoutItem(DomLayoutItem *node) const int colSpan = node->hasAttributeColSpan() ? node->attributeColSpan() : 1; m_output << itemName << ", " << row << ", " << col << ", " << rowSpan << ", " << colSpan; if (!node->attributeAlignment().isEmpty()) - m_output << ", " << node->attributeAlignment(); + m_output << ", " << language::enumValue(node->attributeAlignment()); } else if (layout->attributeClass() == QLatin1String("QFormLayout")) { const int row = node->attributeRow(); const int colSpan = node->hasAttributeColSpan() ? node->attributeColSpan() : 1; const QString role = formLayoutRole(node->attributeColumn(), colSpan); - m_output << row << ", " << role << ", " << itemName; + m_output << row << ", " << language::enumValue(role) << ", " << itemName; } else { m_output << itemName; if (layout->attributeClass().contains(QLatin1String("Box")) && !node->attributeAlignment().isEmpty()) - m_output << ", 0, " << node->attributeAlignment(); + m_output << ", 0, " << language::enumValue(node->attributeAlignment()); } m_output << ");\n\n"; } @@ -1267,11 +1267,13 @@ void WriteInitialization::writeProperties(const QString &varName, shape = QLatin1String("QFrame::VLine"); m_output << m_indent << varName << language::derefPointer << "setFrameShape(" - << shape << ')' << language::eol; + << language::enumValue(shape) << ')' << language::eol; // QFrame Default is 'Plain'. Make the line 'Sunken' unless otherwise specified if (!frameShadowEncountered) { m_output << m_indent << varName << language::derefPointer - << "setFrameShadow(QFrame::Sunken)" << language::eol; + << "setFrameShadow(" + << language::enumValue(QLatin1String("QFrame::Sunken")) + << ')' << language::eol; } continue; } else if ((flags & WritePropertyIgnoreMargin) && propertyName == QLatin1String("margin")) { @@ -1351,16 +1353,18 @@ void WriteInitialization::writeProperties(const QString &varName, case DomProperty::CursorShape: if (p->hasAttributeStdset() && !p->attributeStdset()) varNewName += language::derefPointer + QLatin1String("viewport()"); - propertyValue = QString::fromLatin1("QCursor(Qt::%1)") - .arg(p->elementCursorShape()); + propertyValue = QLatin1String("QCursor(Qt") + language::qualifier + + p->elementCursorShape() + QLatin1Char(')'); break; case DomProperty::Enum: propertyValue = p->elementEnum(); - if (!propertyValue.contains(QLatin1String("::"))) - propertyValue = className + QLatin1String("::") + propertyValue; + if (propertyValue.contains(language::cppQualifier)) + propertyValue = language::enumValue(propertyValue); + else + propertyValue.prepend(className + language::qualifier); break; case DomProperty::Set: - propertyValue = p->elementSet(); + propertyValue = language::enumValue(p->elementSet()); break; case DomProperty::Font: propertyValue = writeFontProperties(p->elementFont()); @@ -1411,8 +1415,9 @@ void WriteInitialization::writeProperties(const QString &varName, } case DomProperty::Locale: { const DomLocale *locale = p->elementLocale(); - propertyValue = QString::fromLatin1("QLocale(QLocale::%1, QLocale::%2)") - .arg(locale->attributeLanguage(), locale->attributeCountry()); + QTextStream(&propertyValue) << "QLocale(QLocale" << language::qualifier + << locale->attributeLanguage() << ", QLocale" << language::qualifier + << locale->attributeCountry() << ')'; break; } case DomProperty::SizePolicy: { @@ -1569,8 +1574,8 @@ QString WriteInitialization::writeSizePolicy(const DomSizePolicy *sp) m_output << "QSizePolicy" << language::qualifier << language::sizePolicy(sp->elementHSizeType()) << ", QSizePolicy" << language::qualifier << language::sizePolicy(sp->elementVSizeType()); } else if (sp->hasAttributeHSizeType() && sp->hasAttributeVSizeType()) { - m_output << "QSizePolicy::" << sp->attributeHSizeType() << ", QSizePolicy::" - << sp->attributeVSizeType(); + m_output << "QSizePolicy" << language::qualifier << sp->attributeHSizeType() + << ", QSizePolicy" << language::qualifier << sp->attributeVSizeType(); } m_output << ')' << language::eol; @@ -1632,16 +1637,28 @@ QString WriteInitialization::writeFontProperties(const DomFont *f) << language::boolValue(f->elementKerning()) << ')' << language::eol; } if (f->hasElementAntialiasing()) { - m_output << m_indent << fontName << ".setStyleStrategy(" - << (f->elementAntialiasing() ? "QFont::PreferDefault" : "QFont::NoAntialias") << ");\n"; + m_output << m_indent << fontName << ".setStyleStrategy(QFont" + << language::qualifier + << (f->elementAntialiasing() ? "PreferDefault" : "NoAntialias") + << ')' << language::eol; } if (f->hasElementStyleStrategy()) { - m_output << m_indent << fontName << ".setStyleStrategy(QFont::" - << f->elementStyleStrategy() << ");\n"; + m_output << m_indent << fontName << ".setStyleStrategy(QFont" + << language::qualifier << f->elementStyleStrategy() << ')' << language::eol; } return fontName; } +static void writeIconAddFile(QTextStream &output, const QString &indent, + const QString &iconName, const QString &fileName, + const char *mode, const char *state) +{ + output << indent << iconName << ".addFile(" + << language::qstring(fileName, indent) << ", QSize(), QIcon" + << language::qualifier << mode << ", QIcon" << language::qualifier + << state << ')' << language::eol; +} + // Post 4.4 write resource icon static void writeResourceIcon(QTextStream &output, const QString &iconName, @@ -1649,91 +1666,92 @@ static void writeResourceIcon(QTextStream &output, const DomResourceIcon *i) { if (i->hasElementNormalOff()) { - output << indent << iconName << ".addFile(" - << language::qstring(i->elementNormalOff()->text(), indent) - << ", QSize(), QIcon::Normal, QIcon::Off);\n"; + writeIconAddFile(output, indent, iconName, i->elementNormalOff()->text(), + "Normal", "Off"); } if (i->hasElementNormalOn()) { - output << indent << iconName << ".addFile(" - << language::qstring(i->elementNormalOn()->text(), indent) - << ", QSize(), QIcon::Normal, QIcon::On);\n"; + writeIconAddFile(output, indent, iconName, i->elementNormalOn()->text(), + "Normal", "On"); } if (i->hasElementDisabledOff()) { - output << indent << iconName << ".addFile(" - << language::qstring(i->elementDisabledOff()->text(), indent) - << ", QSize(), QIcon::Disabled, QIcon::Off);\n"; + writeIconAddFile(output, indent, iconName, i->elementDisabledOff()->text(), + "Disabled", "Off"); } if (i->hasElementDisabledOn()) { - output << indent << iconName << ".addFile(" - << language::qstring(i->elementDisabledOn()->text(), indent) - << ", QSize(), QIcon::Disabled, QIcon::On);\n"; + writeIconAddFile(output, indent, iconName, i->elementDisabledOn()->text(), + "Disabled", "On"); } if (i->hasElementActiveOff()) { - output << indent << iconName << ".addFile(" - << language::qstring(i->elementActiveOff()->text(), indent) - << ", QSize(), QIcon::Active, QIcon::Off);\n"; + writeIconAddFile(output, indent, iconName, i->elementActiveOff()->text(), + "Active", "Off"); } if (i->hasElementActiveOn()) { - output << indent << iconName << ".addFile(" - << language::qstring(i->elementActiveOn()->text(), indent) - << ", QSize(), QIcon::Active, QIcon::On);\n"; + writeIconAddFile(output, indent, iconName, i->elementActiveOn()->text(), + "Active", "On"); } if (i->hasElementSelectedOff()) { - output << indent << iconName << ".addFile(" - << language::qstring(i->elementSelectedOff()->text(), indent) - << ", QSize(), QIcon::Selected, QIcon::Off);\n"; + writeIconAddFile(output, indent, iconName, i->elementSelectedOff()->text(), + "Selected", "Off"); } if (i->hasElementSelectedOn()) { - output << indent << iconName << ".addFile(" - << language::qstring(i->elementSelectedOn()->text(), indent) - << "), QSize(), QIcon::Selected, QIcon::On);\n"; + writeIconAddFile(output, indent, iconName, i->elementSelectedOff()->text(), + "Selected", "On"); } } +static void writeIconAddPixmap(QTextStream &output, const QString &indent, + const QString &iconName, const QString &call, + const char *mode, const char *state) +{ + output << indent << iconName << ".addPixmap(" << call << ", QIcon" + << language::qualifier << mode << ", QIcon" << language::qualifier + << state << ')' << language::eol; +} + void WriteInitialization::writePixmapFunctionIcon(QTextStream &output, const QString &iconName, const QString &indent, const DomResourceIcon *i) const { if (i->hasElementNormalOff()) { - output << indent << iconName << ".addPixmap(" - << pixCall(QLatin1String("QPixmap"), i->elementNormalOff()->text()) - << ", QIcon::Normal, QIcon::Off);\n"; + writeIconAddPixmap(output, indent, iconName, + pixCall(QLatin1String("QPixmap"), i->elementNormalOff()->text()), + "Normal", "Off"); } if (i->hasElementNormalOn()) { - output << indent << iconName << ".addPixmap(" - << pixCall(QLatin1String("QPixmap"), i->elementNormalOn()->text()) - << ", QIcon::Normal, QIcon::On);\n"; + writeIconAddPixmap(output, indent, iconName, + pixCall(QLatin1String("QPixmap"), i->elementNormalOn()->text()), + "Normal", "On"); } if (i->hasElementDisabledOff()) { - output << indent << iconName << ".addPixmap(" - << pixCall(QLatin1String("QPixmap"), i->elementDisabledOff()->text()) - << ", QIcon::Disabled, QIcon::Off);\n"; + writeIconAddPixmap(output, indent, iconName, + pixCall(QLatin1String("QPixmap"), i->elementDisabledOff()->text()), + "Disabled", "Off"); } if (i->hasElementDisabledOn()) { - output << indent << iconName << ".addPixmap(" - << pixCall(QLatin1String("QPixmap"), i->elementDisabledOn()->text()) - << ", QIcon::Disabled, QIcon::On);\n"; + writeIconAddPixmap(output, indent, iconName, + pixCall(QLatin1String("QPixmap"), i->elementDisabledOn()->text()), + "Disabled", "On"); } if (i->hasElementActiveOff()) { - output << indent << iconName << ".addPixmap(" - << pixCall(QLatin1String("QPixmap"), i->elementActiveOff()->text()) - << ", QIcon::Active, QIcon::Off);\n"; + writeIconAddPixmap(output, indent, iconName, + pixCall(QLatin1String("QPixmap"), i->elementActiveOff()->text()), + "Active", "Off"); } if (i->hasElementActiveOn()) { - output << indent << iconName << ".addPixmap(" - << pixCall(QLatin1String("QPixmap"), i->elementActiveOn()->text()) - << ", QIcon::Active, QIcon::On);\n"; + writeIconAddPixmap(output, indent, iconName, + pixCall(QLatin1String("QPixmap"), i->elementActiveOn()->text()), + "Active", "On"); } if (i->hasElementSelectedOff()) { - output << indent << iconName << ".addPixmap(" - << pixCall(QLatin1String("QPixmap"), i->elementSelectedOff()->text()) - << ", QIcon::Selected, QIcon::Off);\n"; + writeIconAddPixmap(output, indent, iconName, + pixCall(QLatin1String("QPixmap"), i->elementSelectedOff()->text()), + "Selected", "Off"); } if (i->hasElementSelectedOn()) { - output << indent << iconName << ".addPixmap(" - << pixCall(QLatin1String("QPixmap"), i->elementSelectedOn()->text()) - << ", QIcon::Selected, QIcon::On);\n"; + writeIconAddPixmap(output, indent, iconName, + pixCall(QLatin1String("QPixmap"), i->elementSelectedOn()->text()), + "Selected", "On"); } } @@ -1826,7 +1844,7 @@ void WriteInitialization::writeColorGroup(DomColorGroup *colorGroup, const QStri const DomColor *color = colors.at(i); m_output << m_indent << paletteName << ".setColor(" << group - << ", QPalette::" << language::paletteColorRole(i) + << ", QPalette" << language::qualifier << language::paletteColorRole(i) << ", " << domColor2QString(color) << ");\n"; } @@ -1843,8 +1861,9 @@ void WriteInitialization::writeColorGroup(DomColorGroup *colorGroup, const QStri << versionAdded.majorVersion() << ", " << versionAdded.minorVersion() << ", " << versionAdded.microVersion() << ")\n"; } - m_output << m_indent << paletteName << ".setBrush(" << group - << ", " << "QPalette::" << roleName + m_output << m_indent << paletteName << ".setBrush(" + << language::enumValue(group) << ", " + << "QPalette" << language::qualifier << roleName << ", " << brushName << ");\n"; if (!versionAdded.isNull()) m_output << "#endif\n"; diff --git a/src/tools/uic/shared/language.cpp b/src/tools/uic/shared/language.cpp index d09834f163..235a8ed2fc 100644 --- a/src/tools/uic/shared/language.cpp +++ b/src/tools/uic/shared/language.cpp @@ -412,4 +412,15 @@ QString boolValue(bool v) Q_UNREACHABLE(); } +static inline QString dot() { return QStringLiteral("."); } + +QString enumValue(const QString &value) +{ + if (language() == Language::Cpp || !value.contains(cppQualifier)) + return value; + QString fixed = value; + fixed.replace(cppQualifier, dot()); + return fixed; +} + } // namespace language diff --git a/src/tools/uic/shared/language.h b/src/tools/uic/shared/language.h index 6f0e0bbb2e..fc8af9715b 100644 --- a/src/tools/uic/shared/language.h +++ b/src/tools/uic/shared/language.h @@ -201,6 +201,8 @@ void formatConnection(QTextStream &str, const SignalSlot &sender, const SignalSl QString boolValue(bool v); +QString enumValue(const QString &value); + } // namespace language #endif // LANGUAGE_H From 28c9e0e606d104e526bb1c8e6e8bcda3ee0aa496 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 2 Apr 2019 16:23:48 +0200 Subject: [PATCH 172/292] Remove handling of missing Q_COMPILER_RVALUE_REFS Change-Id: I7bc6c455fbae4cdad584c76773299a6d8cd40c82 Reviewed-by: Thiago Macieira --- src/concurrent/qtconcurrentfunctionwrappers.h | 2 -- src/corelib/io/qdir.h | 2 -- src/corelib/io/qfileinfo.h | 2 -- src/corelib/io/qprocess.h | 2 -- src/corelib/io/qstorageinfo.h | 2 -- src/corelib/io/qurl.h | 2 -- src/corelib/io/qurlquery.h | 2 -- src/corelib/itemmodels/qabstractitemmodel.h | 2 -- src/corelib/itemmodels/qitemselectionmodel.h | 2 -- src/corelib/kernel/qobject.h | 4 ---- src/corelib/kernel/qppsattribute.cpp | 2 -- src/corelib/kernel/qppsattribute_p.h | 2 -- src/corelib/kernel/qvariant.h | 2 -- src/corelib/mimetypes/qmimetype.h | 2 -- src/corelib/mimetypes/qmimetype_p.h | 2 -- src/corelib/serialization/qxmlstream.h | 6 ------ src/corelib/tools/qarraydatapointer.h | 2 -- src/corelib/tools/qbitarray.h | 2 -- src/corelib/tools/qbytearray.h | 2 -- src/corelib/tools/qcollator.h | 4 ---- src/corelib/tools/qcommandlineoption.h | 2 -- src/corelib/tools/qcontiguouscache.h | 2 -- 22 files changed, 52 deletions(-) diff --git a/src/concurrent/qtconcurrentfunctionwrappers.h b/src/concurrent/qtconcurrentfunctionwrappers.h index 734bb29df1..7ba6720e03 100644 --- a/src/concurrent/qtconcurrentfunctionwrappers.h +++ b/src/concurrent/qtconcurrentfunctionwrappers.h @@ -225,13 +225,11 @@ struct PushBackWrapper return c.push_back(u); } -#ifdef Q_COMPILER_RVALUE_REFS template inline void operator()(C &c, U &&u) const { return c.push_back(u); } -#endif }; template ::Value> diff --git a/src/corelib/io/qdir.h b/src/corelib/io/qdir.h index 547ac163c7..45a40995f8 100644 --- a/src/corelib/io/qdir.h +++ b/src/corelib/io/qdir.h @@ -109,9 +109,7 @@ public: QT_DEPRECATED_X("Use QDir::setPath() instead") QDir &operator=(const QString &path); #endif -#ifdef Q_COMPILER_RVALUE_REFS QDir &operator=(QDir &&other) noexcept { swap(other); return *this; } -#endif void swap(QDir &other) noexcept { qSwap(d_ptr, other.d_ptr); } diff --git a/src/corelib/io/qfileinfo.h b/src/corelib/io/qfileinfo.h index bd9e1d216f..111517325d 100644 --- a/src/corelib/io/qfileinfo.h +++ b/src/corelib/io/qfileinfo.h @@ -67,9 +67,7 @@ public: ~QFileInfo(); QFileInfo &operator=(const QFileInfo &fileinfo); -#ifdef Q_COMPILER_RVALUE_REFS QFileInfo &operator=(QFileInfo &&other) noexcept { swap(other); return *this; } -#endif void swap(QFileInfo &other) noexcept { qSwap(d_ptr, other.d_ptr); } diff --git a/src/corelib/io/qprocess.h b/src/corelib/io/qprocess.h index 83b7138ff9..9fda5fba11 100644 --- a/src/corelib/io/qprocess.h +++ b/src/corelib/io/qprocess.h @@ -72,9 +72,7 @@ public: QProcessEnvironment(); QProcessEnvironment(const QProcessEnvironment &other); ~QProcessEnvironment(); -#ifdef Q_COMPILER_RVALUE_REFS QProcessEnvironment &operator=(QProcessEnvironment && other) noexcept { swap(other); return *this; } -#endif QProcessEnvironment &operator=(const QProcessEnvironment &other); void swap(QProcessEnvironment &other) noexcept { qSwap(d, other.d); } diff --git a/src/corelib/io/qstorageinfo.h b/src/corelib/io/qstorageinfo.h index addcbb2990..237e68d2a1 100644 --- a/src/corelib/io/qstorageinfo.h +++ b/src/corelib/io/qstorageinfo.h @@ -62,9 +62,7 @@ public: ~QStorageInfo(); QStorageInfo &operator=(const QStorageInfo &other); -#ifdef Q_COMPILER_RVALUE_REFS QStorageInfo &operator=(QStorageInfo &&other) noexcept { swap(other); return *this; } -#endif inline void swap(QStorageInfo &other) noexcept { qSwap(d, other.d); } diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h index 70e549c1a9..94269e4369 100644 --- a/src/corelib/io/qurl.h +++ b/src/corelib/io/qurl.h @@ -182,12 +182,10 @@ public: QUrl(const QString &url, ParsingMode mode = TolerantMode); QUrl &operator=(const QString &url); #endif -#ifdef Q_COMPILER_RVALUE_REFS QUrl(QUrl &&other) noexcept : d(other.d) { other.d = nullptr; } inline QUrl &operator=(QUrl &&other) noexcept { qSwap(d, other.d); return *this; } -#endif ~QUrl(); inline void swap(QUrl &other) noexcept { qSwap(d, other.d); } diff --git a/src/corelib/io/qurlquery.h b/src/corelib/io/qurlquery.h index 2a497dc8da..89d0f88059 100644 --- a/src/corelib/io/qurlquery.h +++ b/src/corelib/io/qurlquery.h @@ -70,9 +70,7 @@ public: QUrlQuery(const QUrlQuery &other); QUrlQuery &operator=(const QUrlQuery &other); -#ifdef Q_COMPILER_RVALUE_REFS QUrlQuery &operator=(QUrlQuery &&other) noexcept { swap(other); return *this; } -#endif ~QUrlQuery(); bool operator==(const QUrlQuery &other) const; diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h index 496f583c22..43649cf79b 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.h +++ b/src/corelib/itemmodels/qabstractitemmodel.h @@ -117,12 +117,10 @@ public: inline bool operator!=(const QPersistentModelIndex &other) const { return !operator==(other); } QPersistentModelIndex &operator=(const QPersistentModelIndex &other); -#ifdef Q_COMPILER_RVALUE_REFS inline QPersistentModelIndex(QPersistentModelIndex &&other) noexcept : d(other.d) { other.d = nullptr; } inline QPersistentModelIndex &operator=(QPersistentModelIndex &&other) noexcept { qSwap(d, other.d); return *this; } -#endif inline void swap(QPersistentModelIndex &other) noexcept { qSwap(d, other.d); } bool operator==(const QModelIndex &other) const; bool operator!=(const QModelIndex &other) const; diff --git a/src/corelib/itemmodels/qitemselectionmodel.h b/src/corelib/itemmodels/qitemselectionmodel.h index e5cd24817b..3c3f9fb1ac 100644 --- a/src/corelib/itemmodels/qitemselectionmodel.h +++ b/src/corelib/itemmodels/qitemselectionmodel.h @@ -60,12 +60,10 @@ public: // ### Qt 6: remove them all, the compiler-generated ones are fine inline QItemSelectionRange(const QItemSelectionRange &other) : tl(other.tl), br(other.br) {} -# ifdef Q_COMPILER_RVALUE_REFS QItemSelectionRange(QItemSelectionRange &&other) noexcept : tl(std::move(other.tl)), br(std::move(other.br)) {} QItemSelectionRange &operator=(QItemSelectionRange &&other) noexcept { tl = std::move(other.tl); br = std::move(other.br); return *this; } -# endif QItemSelectionRange &operator=(const QItemSelectionRange &other) { tl = other.tl; br = other.br; return *this; } #endif // Qt < 6 diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 6d7b9521c2..1d83731441 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -544,10 +544,8 @@ public: inline explicit QSignalBlocker(QObject &o) noexcept; inline ~QSignalBlocker(); -#ifdef Q_COMPILER_RVALUE_REFS inline QSignalBlocker(QSignalBlocker &&other) noexcept; inline QSignalBlocker &operator=(QSignalBlocker &&other) noexcept; -#endif inline void reblock() noexcept; inline void unblock() noexcept; @@ -570,7 +568,6 @@ QSignalBlocker::QSignalBlocker(QObject &o) noexcept m_inhibited(false) {} -#ifdef Q_COMPILER_RVALUE_REFS QSignalBlocker::QSignalBlocker(QSignalBlocker &&other) noexcept : m_o(other.m_o), m_blocked(other.m_blocked), @@ -594,7 +591,6 @@ QSignalBlocker &QSignalBlocker::operator=(QSignalBlocker &&other) noexcept } return *this; } -#endif QSignalBlocker::~QSignalBlocker() { diff --git a/src/corelib/kernel/qppsattribute.cpp b/src/corelib/kernel/qppsattribute.cpp index 6be462edb5..166d590872 100644 --- a/src/corelib/kernel/qppsattribute.cpp +++ b/src/corelib/kernel/qppsattribute.cpp @@ -145,7 +145,6 @@ QPpsAttribute &QPpsAttribute::operator=(const QPpsAttribute &other) return *this; } -#ifdef Q_COMPILER_RVALUE_REFS QPpsAttribute::QPpsAttribute(QPpsAttribute &&other) : d(other.d) { other.d->type = QPpsAttribute::None; @@ -156,7 +155,6 @@ QPpsAttribute &QPpsAttribute::operator=(QPpsAttribute &&other) qSwap(d, other.d); return *this; } -#endif bool QPpsAttribute::operator==(const QPpsAttribute &other) const { diff --git a/src/corelib/kernel/qppsattribute_p.h b/src/corelib/kernel/qppsattribute_p.h index b59dcd5851..d6611cb675 100644 --- a/src/corelib/kernel/qppsattribute_p.h +++ b/src/corelib/kernel/qppsattribute_p.h @@ -96,10 +96,8 @@ public: bool operator==(const QPpsAttribute &other) const; bool operator!=(const QPpsAttribute &other) const; -#ifdef Q_COMPILER_RVALUE_REFS QPpsAttribute(QPpsAttribute &&other); QPpsAttribute &operator=(QPpsAttribute &&other); -#endif bool isValid() const; Type type() const; diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 6b35bfa9e9..2247c7adc8 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -267,12 +267,10 @@ class Q_CORE_EXPORT QVariant #endif QVariant& operator=(const QVariant &other); -#ifdef Q_COMPILER_RVALUE_REFS inline QVariant(QVariant &&other) noexcept : d(other.d) { other.d = Private(); } inline QVariant &operator=(QVariant &&other) noexcept { qSwap(d, other.d); return *this; } -#endif inline void swap(QVariant &other) noexcept { qSwap(d, other.d); } diff --git a/src/corelib/mimetypes/qmimetype.h b/src/corelib/mimetypes/qmimetype.h index c496af7d58..6d6f9eb488 100644 --- a/src/corelib/mimetypes/qmimetype.h +++ b/src/corelib/mimetypes/qmimetype.h @@ -78,9 +78,7 @@ public: QMimeType(); QMimeType(const QMimeType &other); QMimeType &operator=(const QMimeType &other); -#ifdef Q_COMPILER_RVALUE_REFS QMimeType &operator=(QMimeType &&other) noexcept { swap(other); return *this; } -#endif void swap(QMimeType &other) noexcept { qSwap(d, other.d); diff --git a/src/corelib/mimetypes/qmimetype_p.h b/src/corelib/mimetypes/qmimetype_p.h index 5a36e6613c..2918309ad7 100644 --- a/src/corelib/mimetypes/qmimetype_p.h +++ b/src/corelib/mimetypes/qmimetype_p.h @@ -103,7 +103,6 @@ QT_END_NAMESPACE } \ QT_END_NAMESPACE -#ifdef Q_COMPILER_RVALUE_REFS #define QMIMETYPE_BUILDER_FROM_RVALUE_REFS \ QT_BEGIN_NAMESPACE \ static QMimeType buildQMimeType ( \ @@ -122,6 +121,5 @@ QT_END_NAMESPACE return QMimeType(qMimeTypeData); \ } \ QT_END_NAMESPACE -#endif #endif // QMIMETYPE_P_H diff --git a/src/corelib/serialization/qxmlstream.h b/src/corelib/serialization/qxmlstream.h index fedd149fd0..55dcc4e4e8 100644 --- a/src/corelib/serialization/qxmlstream.h +++ b/src/corelib/serialization/qxmlstream.h @@ -59,19 +59,15 @@ public: inline QXmlStreamStringRef(const QStringRef &aString) :m_string(aString.string()?*aString.string():QString()), m_position(aString.position()), m_size(aString.size()){} QXmlStreamStringRef(const QString &aString) : m_string(aString), m_position(0), m_size(m_string.size()) {} -#ifdef Q_COMPILER_RVALUE_REFS QXmlStreamStringRef(QString &&aString) noexcept : m_string(std::move(aString)), m_position(0), m_size(m_string.size()) {} -#endif #if QT_VERSION < QT_VERSION_CHECK(6,0,0) QXmlStreamStringRef(const QXmlStreamStringRef &other) // = default : m_string(other.m_string), m_position(other.m_position), m_size(other.m_size) {} -#ifdef Q_COMPILER_RVALUE_REFS QXmlStreamStringRef(QXmlStreamStringRef &&other) noexcept // = default : m_string(std::move(other.m_string)), m_position(other.m_position), m_size(other.m_size) {} QXmlStreamStringRef &operator=(QXmlStreamStringRef &&other) noexcept // = default { swap(other); return *this; } -#endif QXmlStreamStringRef &operator=(const QXmlStreamStringRef &other) // = default { m_string = other.m_string; m_position = other.m_position; m_size = other.m_size; return *this; } inline ~QXmlStreamStringRef() {} // ### this prevents (or deprecates) all the move/copy special member functions, @@ -111,7 +107,6 @@ public: #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QXmlStreamAttribute(const QString &namespaceUri, const QString &name, const QString &value); QXmlStreamAttribute(const QXmlStreamAttribute &); -#ifdef Q_COMPILER_RVALUE_REFS QXmlStreamAttribute(QXmlStreamAttribute &&other) noexcept // = default; : m_name(std::move(other.m_name)), m_namespaceUri(std::move(other.m_namespaceUri)), @@ -132,7 +127,6 @@ public: m_isDefault = other.m_isDefault; return *this; } -#endif QXmlStreamAttribute& operator=(const QXmlStreamAttribute &); ~QXmlStreamAttribute(); #endif // < Qt 6 diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index bce8fc8ddc..0322615f91 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -82,7 +82,6 @@ public: return *this; } -#ifdef Q_COMPILER_RVALUE_REFS QArrayDataPointer(QArrayDataPointer &&other) noexcept : d(other.d) { @@ -95,7 +94,6 @@ public: this->swap(moved); return *this; } -#endif DataOps &operator*() const { diff --git a/src/corelib/tools/qbitarray.h b/src/corelib/tools/qbitarray.h index 78beff0d42..9b0e931aca 100644 --- a/src/corelib/tools/qbitarray.h +++ b/src/corelib/tools/qbitarray.h @@ -58,11 +58,9 @@ public: explicit QBitArray(int size, bool val = false); QBitArray(const QBitArray &other) : d(other.d) {} inline QBitArray &operator=(const QBitArray &other) { d = other.d; return *this; } -#ifdef Q_COMPILER_RVALUE_REFS inline QBitArray(QBitArray &&other) noexcept : d(std::move(other.d)) {} inline QBitArray &operator=(QBitArray &&other) noexcept { qSwap(d, other.d); return *this; } -#endif inline void swap(QBitArray &other) noexcept { qSwap(d, other.d); } diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h index 318d773eb6..14fcddce7c 100644 --- a/src/corelib/tools/qbytearray.h +++ b/src/corelib/tools/qbytearray.h @@ -177,11 +177,9 @@ public: QByteArray &operator=(const QByteArray &) noexcept; QByteArray &operator=(const char *str); -#ifdef Q_COMPILER_RVALUE_REFS inline QByteArray(QByteArray && other) noexcept : d(other.d) { other.d = Data::sharedNull(); } inline QByteArray &operator=(QByteArray &&other) noexcept { qSwap(d, other.d); return *this; } -#endif inline void swap(QByteArray &other) noexcept { qSwap(d, other.d); } diff --git a/src/corelib/tools/qcollator.h b/src/corelib/tools/qcollator.h index 6c76ef038f..96a5902526 100644 --- a/src/corelib/tools/qcollator.h +++ b/src/corelib/tools/qcollator.h @@ -57,10 +57,8 @@ public: QCollatorSortKey(const QCollatorSortKey &other); ~QCollatorSortKey(); QCollatorSortKey &operator=(const QCollatorSortKey &other); -#ifdef Q_COMPILER_RVALUE_REFS inline QCollatorSortKey &operator=(QCollatorSortKey &&other) noexcept { swap(other); return *this; } -#endif void swap(QCollatorSortKey &other) noexcept { d.swap(other.d); } @@ -87,12 +85,10 @@ public: QCollator(const QCollator &); ~QCollator(); QCollator &operator=(const QCollator &); -#ifdef Q_COMPILER_RVALUE_REFS QCollator(QCollator &&other) noexcept : d(other.d) { other.d = nullptr; } QCollator &operator=(QCollator &&other) noexcept { swap(other); return *this; } -#endif void swap(QCollator &other) noexcept { qSwap(d, other.d); } diff --git a/src/corelib/tools/qcommandlineoption.h b/src/corelib/tools/qcommandlineoption.h index 643427f6fb..e2ca64acef 100644 --- a/src/corelib/tools/qcommandlineoption.h +++ b/src/corelib/tools/qcommandlineoption.h @@ -71,9 +71,7 @@ public: ~QCommandLineOption(); QCommandLineOption &operator=(const QCommandLineOption &other); -#ifdef Q_COMPILER_RVALUE_REFS QCommandLineOption &operator=(QCommandLineOption &&other) noexcept { swap(other); return *this; } -#endif void swap(QCommandLineOption &other) noexcept { qSwap(d, other.d); } diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h index fdb9c6d19a..433e3f9ea4 100644 --- a/src/corelib/tools/qcontiguouscache.h +++ b/src/corelib/tools/qcontiguouscache.h @@ -107,10 +107,8 @@ public: #endif QContiguousCache &operator=(const QContiguousCache &other); -#ifdef Q_COMPILER_RVALUE_REFS inline QContiguousCache &operator=(QContiguousCache &&other) { qSwap(d, other.d); return *this; } -#endif inline void swap(QContiguousCache &other) { qSwap(d, other.d); } bool operator==(const QContiguousCache &other) const; inline bool operator!=(const QContiguousCache &other) const { return !(*this == other); } From 9d1905da9c59e9062a157199c81c076efc20eb28 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 8 Apr 2019 12:58:17 +0200 Subject: [PATCH 173/292] Revert "Fix font matching of typographic families on Windows" This reverts commit bcd2fa484a4fe93e77743195d7f72cce9e580d43. There was a report that this caused infinite recursion on some systems, so we revert it for now and re-add it later when the issue has been resolved. Task-number: QTBUG-74983 Change-Id: I747e0437232d72d7a87eb602b10fa09c7130ce8f Reviewed-by: Allan Sandfeld Jensen --- src/gui/text/qfontdatabase.cpp | 7 ------- src/gui/text/qplatformfontdatabase.cpp | 11 ----------- src/gui/text/qplatformfontdatabase.h | 2 -- .../windows/qwindowsfontdatabase.cpp | 17 +++++------------ .../windows/qwindowsfontdatabase_p.h | 2 -- 5 files changed, 5 insertions(+), 34 deletions(-) diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index ee37a84f5f..82e40510ae 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -804,13 +804,6 @@ QString qt_resolveFontFamilyAlias(const QString &alias) return alias; } -bool qt_isFontFamilyPopulated(const QString &familyName) -{ - QFontDatabasePrivate *d = privateDb(); - QtFontFamily *f = d->family(familyName, QFontDatabasePrivate::RequestFamily); - return f != nullptr && f->populated; -} - /*! Returns a list of alternative fonts for the specified \a family and \a style and \a script using the \a styleHint given. diff --git a/src/gui/text/qplatformfontdatabase.cpp b/src/gui/text/qplatformfontdatabase.cpp index 715b00d838..a911014a19 100644 --- a/src/gui/text/qplatformfontdatabase.cpp +++ b/src/gui/text/qplatformfontdatabase.cpp @@ -60,7 +60,6 @@ void qt_registerFont(const QString &familyname, const QString &stylename, void qt_registerFontFamily(const QString &familyName); void qt_registerAliasToFontFamily(const QString &familyName, const QString &alias); -bool qt_isFontFamilyPopulated(const QString &familyName); /*! Registers the pre-rendered QPF2 font contained in the given \a dataArray. @@ -666,16 +665,6 @@ void QPlatformFontDatabase::registerAliasToFontFamily(const QString &familyName, qt_registerAliasToFontFamily(familyName, alias); } -/*! - Helper function that returns true if the font family has already been registered and populated. - - \since 5.14 -*/ -bool QPlatformFontDatabase::isFamilyPopulated(const QString &familyName) -{ - return qt_isFontFamilyPopulated(familyName); -} - /*! \class QPlatformFontDatabase \since 5.0 diff --git a/src/gui/text/qplatformfontdatabase.h b/src/gui/text/qplatformfontdatabase.h index 38ba7f10b2..f4558129a7 100644 --- a/src/gui/text/qplatformfontdatabase.h +++ b/src/gui/text/qplatformfontdatabase.h @@ -139,8 +139,6 @@ public: static void registerFontFamily(const QString &familyName); static void registerAliasToFontFamily(const QString &familyName, const QString &alias); - - static bool isFamilyPopulated(const QString &familyName); }; QT_END_NAMESPACE diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp index 702cfbdc62..b1ba84fe14 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp @@ -1012,8 +1012,7 @@ static bool addFontToDatabase(QString familyName, const LOGFONT &logFont, const TEXTMETRIC *textmetric, const FONTSIGNATURE *signature, - int type, - QWindowsFontDatabase *db) + int type) { // the "@family" fonts are just the same as "family". Ignore them. if (familyName.isEmpty() || familyName.at(0) == QLatin1Char('@') || familyName.startsWith(QLatin1String("WST_"))) @@ -1093,12 +1092,6 @@ static bool addFontToDatabase(QString familyName, writingSystems.setSupported(ws); } - // We came here from populating a different font family, so we have - // to ensure the entire typographic family is populated before we - // mark it as such inside registerFont() - if (!subFamilyName.isEmpty() && familyName != subFamilyName && !QPlatformFontDatabase::isFamilyPopulated(familyName)) - db->populateFamily(familyName); - QPlatformFontDatabase::registerFont(familyName, styleName, foundryName, weight, style, stretch, antialias, scalable, size, fixed, writingSystems, createFontFile(faceName)); @@ -1125,7 +1118,7 @@ static bool addFontToDatabase(QString familyName, } static int QT_WIN_CALLBACK storeFont(const LOGFONT *logFont, const TEXTMETRIC *textmetric, - DWORD type, LPARAM lParam) + DWORD type, LPARAM) { const ENUMLOGFONTEX *f = reinterpret_cast(logFont); const QString familyName = QString::fromWCharArray(f->elfLogFont.lfFaceName); @@ -1137,7 +1130,7 @@ static int QT_WIN_CALLBACK storeFont(const LOGFONT *logFont, const TEXTMETRIC *t const FONTSIGNATURE *signature = nullptr; if (type & TRUETYPE_FONTTYPE) signature = &reinterpret_cast(textmetric)->ntmFontSig; - addFontToDatabase(familyName, styleName, *logFont, textmetric, signature, type, reinterpret_cast(lParam)); + addFontToDatabase(familyName, styleName, *logFont, textmetric, signature, type); // keep on enumerating return 1; @@ -1156,7 +1149,7 @@ void QWindowsFontDatabase::populateFamily(const QString &familyName) familyName.toWCharArray(lf.lfFaceName); lf.lfFaceName[familyName.size()] = 0; lf.lfPitchAndFamily = 0; - EnumFontFamiliesEx(dummy, &lf, storeFont, reinterpret_cast(this), 0); + EnumFontFamiliesEx(dummy, &lf, storeFont, 0, 0); ReleaseDC(0, dummy); } @@ -1597,7 +1590,7 @@ QStringList QWindowsFontDatabase::addApplicationFont(const QByteArray &fontData, GetTextMetrics(hdc, &textMetrics); addFontToDatabase(familyName, styleName, lf, &textMetrics, &signatures.at(j), - TRUETYPE_FONTTYPE, this); + TRUETYPE_FONTTYPE); SelectObject(hdc, oldobj); DeleteObject(hfont); diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_p.h b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_p.h index a1cab17a87..b85a2dceee 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_p.h +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_p.h @@ -96,8 +96,6 @@ public: QWindowsFontDatabase(); ~QWindowsFontDatabase() override; - void ensureFamilyPopulated(const QString &familyName); - void populateFontDatabase() override; void populateFamily(const QString &familyName) override; QFontEngine *fontEngine(const QFontDef &fontDef, void *handle) override; From 84ce5022ce9e65d753354bc472b7f28fbc014ebf Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 9 Nov 2018 11:26:00 +0100 Subject: [PATCH 174/292] QFileDialog (widgets-based): Remember selection in history Extend the history by a persistent model index list reflecting the selection. [ChangeLog][QtWidgets][QFileDialog] The widgets-based dialog now remembers the selected files when navigating the history Fixes: QTBUG-71415 Change-Id: I86774439be070c1b922acd0e9a27d029f02f68d3 Reviewed-by: Shawn Rutledge --- src/widgets/dialogs/qfiledialog.cpp | 62 ++++++++++++++++--- src/widgets/dialogs/qfiledialog_p.h | 12 +++- .../dialogs/qfiledialog/tst_qfiledialog.cpp | 10 +++ 3 files changed, 73 insertions(+), 11 deletions(-) diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index f772eb1241..fcac12068d 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -77,6 +77,8 @@ #include #endif +#include + QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC(QUrl, lastVisitedDir) @@ -3372,6 +3374,18 @@ void QFileDialogPrivate::_q_goHome() q->setDirectory(QDir::homePath()); } + +void QFileDialogPrivate::saveHistorySelection() +{ + if (qFileDialogUi.isNull() || currentHistoryLocation < 0 || currentHistoryLocation >= currentHistory.size()) + return; + auto &item = currentHistory[currentHistoryLocation]; + item.selection.clear(); + const auto selectedIndexes = qFileDialogUi->listView->selectionModel()->selectedRows(); + for (const auto &index : selectedIndexes) + item.selection.append(QPersistentModelIndex(index)); +} + /*! \internal @@ -3385,17 +3399,49 @@ void QFileDialogPrivate::_q_pathChanged(const QString &newPath) qFileDialogUi->sidebar->selectUrl(QUrl::fromLocalFile(newPath)); q->setHistory(qFileDialogUi->lookInCombo->history()); - if (currentHistoryLocation < 0 || currentHistory.value(currentHistoryLocation) != QDir::toNativeSeparators(newPath)) { + const QString newNativePath = QDir::toNativeSeparators(newPath); + + // equal paths indicate this was invoked by _q_navigateBack/Forward() + if (currentHistoryLocation < 0 || currentHistory.value(currentHistoryLocation).path != newNativePath) { + if (currentHistoryLocation >= 0) + saveHistorySelection(); while (currentHistoryLocation >= 0 && currentHistoryLocation + 1 < currentHistory.count()) { currentHistory.removeLast(); } - currentHistory.append(QDir::toNativeSeparators(newPath)); + currentHistory.append({newNativePath, PersistentModelIndexList()}); ++currentHistoryLocation; } qFileDialogUi->forwardButton->setEnabled(currentHistory.size() - currentHistoryLocation > 1); qFileDialogUi->backButton->setEnabled(currentHistoryLocation > 0); } +void QFileDialogPrivate::navigate(HistoryItem &historyItem) +{ + Q_Q(QFileDialog); + q->setDirectory(historyItem.path); + // Restore selection unless something has changed in the file system + if (qFileDialogUi.isNull() || historyItem.selection.isEmpty()) + return; + if (std::any_of(historyItem.selection.cbegin(), historyItem.selection.cend(), + [](const QPersistentModelIndex &i) { return !i.isValid(); })) { + historyItem.selection.clear(); + return; + } + + QAbstractItemView *view = q->viewMode() == QFileDialog::List + ? static_cast(qFileDialogUi->listView) + : static_cast(qFileDialogUi->treeView); + auto selectionModel = view->selectionModel(); + const QItemSelectionModel::SelectionFlags flags = QItemSelectionModel::Select + | QItemSelectionModel::Rows; + selectionModel->select(historyItem.selection.constFirst(), + flags | QItemSelectionModel::Clear | QItemSelectionModel::Current); + for (int i = 1, size = historyItem.selection.size(); i < size; ++i) + selectionModel->select(historyItem.selection.at(i), flags); + + view->scrollTo(historyItem.selection.constFirst()); +} + /*! \internal @@ -3403,11 +3449,9 @@ void QFileDialogPrivate::_q_pathChanged(const QString &newPath) */ void QFileDialogPrivate::_q_navigateBackward() { - Q_Q(QFileDialog); if (!currentHistory.isEmpty() && currentHistoryLocation > 0) { - --currentHistoryLocation; - QString previousHistory = currentHistory.at(currentHistoryLocation); - q->setDirectory(previousHistory); + saveHistorySelection(); + navigate(currentHistory[--currentHistoryLocation]); } } @@ -3418,11 +3462,9 @@ void QFileDialogPrivate::_q_navigateBackward() */ void QFileDialogPrivate::_q_navigateForward() { - Q_Q(QFileDialog); if (!currentHistory.isEmpty() && currentHistoryLocation < currentHistory.size() - 1) { - ++currentHistoryLocation; - QString nextHistory = currentHistory.at(currentHistoryLocation); - q->setDirectory(nextHistory); + saveHistorySelection(); + navigate(currentHistory[++currentHistoryLocation]); } } diff --git a/src/widgets/dialogs/qfiledialog_p.h b/src/widgets/dialogs/qfiledialog_p.h index 7e53b61031..dcf147348f 100644 --- a/src/widgets/dialogs/qfiledialog_p.h +++ b/src/widgets/dialogs/qfiledialog_p.h @@ -116,6 +116,14 @@ class Q_WIDGETS_EXPORT QFileDialogPrivate : public QDialogPrivate Q_DECLARE_PUBLIC(QFileDialog) public: + using PersistentModelIndexList = QVector; + + struct HistoryItem + { + QString path; + PersistentModelIndexList selection; + }; + QFileDialogPrivate(); QPlatformFileDialogHelper *platformFileDialogHelper() const @@ -193,9 +201,11 @@ public: void retranslateWindowTitle(); void retranslateStrings(); void emitFilesSelected(const QStringList &files); + void saveHistorySelection(); void _q_goHome(); void _q_pathChanged(const QString &); + void navigate(HistoryItem &); void _q_navigateBackward(); void _q_navigateForward(); void _q_navigateToParent(); @@ -237,7 +247,7 @@ public: QString setWindowTitle; - QStringList currentHistory; + QList currentHistory; int currentHistoryLocation; QAction *renameAction; diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index 748c8aaa84..f7482bae45 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp @@ -1421,6 +1421,16 @@ void tst_QFiledialog::clearLineEdit() QTRY_VERIFY(fd.directory().absolutePath() != workDirPath); QVERIFY(lineEdit->text().isEmpty()); + + // QTBUG-71415: When pressing back, the selection (activated + // directory) should be restored. + QToolButton *backButton = fd.findChild("backButton"); + QVERIFY(backButton); + QTreeView *treeView = fd.findChildren("treeView").value(0); + QVERIFY(treeView); + backButton->click(); + QTRY_COMPARE(treeView->selectionModel()->selectedIndexes().value(0).data().toString(), + dirName); } void tst_QFiledialog::enableChooseButton() From 0bee05f4c1036e2852de88f068e4f92926c4efa7 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 1 Apr 2019 13:17:24 +0200 Subject: [PATCH 175/292] Make the 64 bit raster backend an optional feature Can be used to make smaller binaries, and possibly speed up ARGB32 rendering on some platforms. Change-Id: I7647b197ba7a6582187cc9736b7e0d752bd5bee5 Reviewed-by: Lars Knoll --- src/gui/configure.json | 6 + src/gui/image/qimage.cpp | 2 + src/gui/painting/qcompositionfunctions.cpp | 730 ++++++++++-------- src/gui/painting/qdrawhelper.cpp | 422 +++++++--- src/gui/painting/qdrawhelper_avx2.cpp | 6 + src/gui/painting/qdrawhelper_p.h | 4 + src/gui/painting/qdrawhelper_sse4.cpp | 2 + src/gui/painting/qimagescale.cpp | 7 +- src/gui/painting/qpaintengine_raster.cpp | 6 + tests/auto/gui/image/qimage/tst_qimage.cpp | 4 + .../gui/painting/qpainter/tst_qpainter.cpp | 8 + 11 files changed, 782 insertions(+), 415 deletions(-) diff --git a/src/gui/configure.json b/src/gui/configure.json index 2ac06173a8..b7baf15571 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -1775,6 +1775,12 @@ "purpose": "Supports displaying \"What's this\" help.", "section": "Widget Support", "output": [ "publicFeature", "feature" ] + }, + "raster-64bit": { + "label": "QPainter - 64 bit raster", + "purpose": "Internal painting support for 64 bit (16 bpc) rasterization.", + "section": "Painting", + "output": [ "privateFeature" ] } }, diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 64e24fce44..917dde3b0f 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -4690,12 +4690,14 @@ QImage QImage::smoothScaled(int w, int h) const { case QImage::Format_RGBX8888: #endif case QImage::Format_RGBA8888_Premultiplied: +#if QT_CONFIG(raster_64bit) case QImage::Format_RGBX64: case QImage::Format_RGBA64_Premultiplied: break; case QImage::Format_RGBA64: src = src.convertToFormat(QImage::Format_RGBA64_Premultiplied); break; +#endif default: if (src.hasAlphaChannel()) src = src.convertToFormat(QImage::Format_ARGB32_Premultiplied); diff --git a/src/gui/painting/qcompositionfunctions.cpp b/src/gui/painting/qcompositionfunctions.cpp index 5c1afe8425..06a849e790 100644 --- a/src/gui/painting/qcompositionfunctions.cpp +++ b/src/gui/painting/qcompositionfunctions.cpp @@ -137,6 +137,7 @@ struct Rgba64OperationsBase { ::memcpy(dest, src, len * sizeof(Type)); } }; +#if QT_CONFIG(raster_64bit) const Rgba64OperationsBase::Type Rgba64OperationsBase::clear = QRgba64::fromRgba64(0); struct Rgba64OperationsC : public Rgba64OperationsBase @@ -309,10 +310,8 @@ struct Rgba64OperationsNEON : public Rgba64OperationsBase return interpolate65535(x, a1, y, a2); } }; - #endif -typedef Argb32OperationsC Argb32Operations; #if defined(__SSE2__) typedef Rgba64OperationsSSE2 Rgba64Operations; #elif defined(__ARM_NEON__) @@ -320,6 +319,9 @@ typedef Rgba64OperationsNEON Rgba64Operations; #else typedef Rgba64OperationsC Rgba64Operations; #endif +#endif // QT_CONFIG(raster_64bit) + +typedef Argb32OperationsC Argb32Operations; /* result = 0 @@ -343,20 +345,23 @@ void QT_FASTCALL comp_func_solid_Clear(uint *dest, int length, uint, uint const_ comp_func_Clear_template(dest, length, const_alpha); } -void QT_FASTCALL comp_func_solid_Clear_rgb64(QRgba64 *dest, int length, QRgba64, uint const_alpha) -{ - comp_func_Clear_template(dest, length, const_alpha); -} - void QT_FASTCALL comp_func_Clear(uint *dest, const uint *, int length, uint const_alpha) { comp_func_Clear_template(dest, length, const_alpha); } +#if QT_CONFIG(raster_64bit) +void QT_FASTCALL comp_func_solid_Clear_rgb64(QRgba64 *dest, int length, QRgba64, uint const_alpha) +{ + comp_func_Clear_template(dest, length, const_alpha); +} + void QT_FASTCALL comp_func_Clear_rgb64(QRgba64 *dest, const QRgba64 *, int length, uint const_alpha) { comp_func_Clear_template(dest, length, const_alpha); } +#endif + /* result = s @@ -399,36 +404,40 @@ void QT_FASTCALL comp_func_solid_Source(uint *dest, int length, uint color, uint comp_func_solid_Source_template(dest, length, color, const_alpha); } -void QT_FASTCALL comp_func_solid_Source_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) -{ - comp_func_solid_Source_template(dest, length, color, const_alpha); -} - void QT_FASTCALL comp_func_Source(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) { comp_func_Source_template(dest, src, length, const_alpha); } +#if QT_CONFIG(raster_64bit) +void QT_FASTCALL comp_func_solid_Source_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) +{ + comp_func_solid_Source_template(dest, length, color, const_alpha); +} + void QT_FASTCALL comp_func_Source_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha) { comp_func_Source_template(dest, src, length, const_alpha); } +#endif void QT_FASTCALL comp_func_solid_Destination(uint *, int, uint, uint) { } -void QT_FASTCALL comp_func_solid_Destination_rgb64(QRgba64 *, int, QRgba64, uint) -{ -} - void QT_FASTCALL comp_func_Destination(uint *, const uint *, int, uint) { } +#if QT_CONFIG(raster_64bit) +void QT_FASTCALL comp_func_solid_Destination_rgb64(QRgba64 *, int, QRgba64, uint) +{ +} + void QT_FASTCALL comp_func_Destination_rgb64(QRgba64 *, const QRgba64 *, int, uint) { } +#endif /* result = s + d * sia @@ -483,20 +492,22 @@ void QT_FASTCALL comp_func_solid_SourceOver(uint *dest, int length, uint color, comp_func_solid_SourceOver_template(dest, length, color, const_alpha); } -void QT_FASTCALL comp_func_solid_SourceOver_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) -{ - comp_func_solid_SourceOver_template(dest, length, color, const_alpha); -} - void QT_FASTCALL comp_func_SourceOver(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) { comp_func_SourceOver_template(dest, src, length, const_alpha); } +#if QT_CONFIG(raster_64bit) +void QT_FASTCALL comp_func_solid_SourceOver_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) +{ + comp_func_solid_SourceOver_template(dest, length, color, const_alpha); +} + void QT_FASTCALL comp_func_SourceOver_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha) { comp_func_SourceOver_template(dest, src, length, const_alpha); } +#endif /* result = d + s * dia @@ -542,20 +553,22 @@ void QT_FASTCALL comp_func_solid_DestinationOver(uint *dest, int length, uint co comp_func_solid_DestinationOver_template(dest, length, color, const_alpha); } -void QT_FASTCALL comp_func_solid_DestinationOver_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) -{ - comp_func_solid_DestinationOver_template(dest, length, color, const_alpha); -} - void QT_FASTCALL comp_func_DestinationOver(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) { comp_func_DestinationOver_template(dest, src, length, const_alpha); } +#if QT_CONFIG(raster_64bit) +void QT_FASTCALL comp_func_solid_DestinationOver_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) +{ + comp_func_solid_DestinationOver_template(dest, length, color, const_alpha); +} + void QT_FASTCALL comp_func_DestinationOver_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha) { comp_func_DestinationOver_template(dest, src, length, const_alpha); } +#endif /* result = s * da @@ -606,20 +619,22 @@ void QT_FASTCALL comp_func_solid_SourceIn(uint *dest, int length, uint color, ui comp_func_solid_SourceIn_template(dest, length, color, const_alpha); } -void QT_FASTCALL comp_func_solid_SourceIn_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) -{ - comp_func_solid_SourceIn_template(dest, length, color, const_alpha); -} - void QT_FASTCALL comp_func_SourceIn(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) { comp_func_SourceIn_template(dest, src, length, const_alpha); } +#if QT_CONFIG(raster_64bit) +void QT_FASTCALL comp_func_solid_SourceIn_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) +{ + comp_func_solid_SourceIn_template(dest, length, color, const_alpha); +} + void QT_FASTCALL comp_func_SourceIn_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha) { comp_func_SourceIn_template(dest, src, length, const_alpha); } +#endif /* result = d * sa @@ -665,20 +680,22 @@ void QT_FASTCALL comp_func_solid_DestinationIn(uint *dest, int length, uint colo comp_func_solid_DestinationIn_template(dest, length, color, const_alpha); } -void QT_FASTCALL comp_func_solid_DestinationIn_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) -{ - comp_func_solid_DestinationIn_template(dest, length, color, const_alpha); -} - void QT_FASTCALL comp_func_DestinationIn(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) { comp_func_DestinationIn_template(dest, src, length, const_alpha); } +#if QT_CONFIG(raster_64bit) +void QT_FASTCALL comp_func_solid_DestinationIn_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) +{ + comp_func_solid_DestinationIn_template(dest, length, color, const_alpha); +} + void QT_FASTCALL comp_func_DestinationIn_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha) { comp_func_DestinationIn_template(dest, src, length, const_alpha); } +#endif /* result = s * dia @@ -727,20 +744,22 @@ void QT_FASTCALL comp_func_solid_SourceOut(uint *dest, int length, uint color, u comp_func_solid_SourceOut_template(dest, length, color, const_alpha); } -void QT_FASTCALL comp_func_solid_SourceOut_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) -{ - comp_func_solid_SourceOut_template(dest, length, color, const_alpha); -} - void QT_FASTCALL comp_func_SourceOut(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) { comp_func_SourceOut_template(dest, src, length, const_alpha); } +#if QT_CONFIG(raster_64bit) +void QT_FASTCALL comp_func_solid_SourceOut_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) +{ + comp_func_solid_SourceOut_template(dest, length, color, const_alpha); +} + void QT_FASTCALL comp_func_SourceOut_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha) { comp_func_SourceOut_template(dest, src, length, const_alpha); } +#endif /* result = d * sia @@ -786,20 +805,22 @@ void QT_FASTCALL comp_func_solid_DestinationOut(uint *dest, int length, uint col comp_func_solid_DestinationOut_template(dest, length, color, const_alpha); } -void QT_FASTCALL comp_func_solid_DestinationOut_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) -{ - comp_func_solid_DestinationOut_template(dest, length, color, const_alpha); -} - void QT_FASTCALL comp_func_DestinationOut(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) { comp_func_DestinationOut_template(dest, src, length, const_alpha); } +#if QT_CONFIG(raster_64bit) +void QT_FASTCALL comp_func_solid_DestinationOut_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) +{ + comp_func_solid_DestinationOut_template(dest, length, color, const_alpha); +} + void QT_FASTCALL comp_func_DestinationOut_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha) { comp_func_DestinationOut_template(dest, src, length, const_alpha); } +#endif /* result = s*da + d*sia @@ -845,20 +866,22 @@ void QT_FASTCALL comp_func_solid_SourceAtop(uint *dest, int length, uint color, comp_func_solid_SourceAtop_template(dest, length, color, const_alpha); } -void QT_FASTCALL comp_func_solid_SourceAtop_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) -{ - comp_func_solid_SourceAtop_template(dest, length, color, const_alpha); -} - void QT_FASTCALL comp_func_SourceAtop(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) { comp_func_SourceAtop_template(dest, src, length, const_alpha); } +#if QT_CONFIG(raster_64bit) +void QT_FASTCALL comp_func_solid_SourceAtop_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) +{ + comp_func_solid_SourceAtop_template(dest, length, color, const_alpha); +} + void QT_FASTCALL comp_func_SourceAtop_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha) { comp_func_SourceAtop_template(dest, src, length, const_alpha); } +#endif /* result = d*sa + s*dia @@ -909,20 +932,22 @@ void QT_FASTCALL comp_func_solid_DestinationAtop(uint *dest, int length, uint co comp_func_solid_DestinationAtop_template(dest, length, color, const_alpha); } -void QT_FASTCALL comp_func_solid_DestinationAtop_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) -{ - comp_func_solid_DestinationAtop_template(dest, length, color, const_alpha); -} - void QT_FASTCALL comp_func_DestinationAtop(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) { comp_func_DestinationAtop_template(dest, src, length, const_alpha); } +#if QT_CONFIG(raster_64bit) +void QT_FASTCALL comp_func_solid_DestinationAtop_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) +{ + comp_func_solid_DestinationAtop_template(dest, length, color, const_alpha); +} + void QT_FASTCALL comp_func_DestinationAtop_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha) { comp_func_DestinationAtop_template(dest, src, length, const_alpha); } +#endif /* result = d*sia + s*dia @@ -969,20 +994,22 @@ void QT_FASTCALL comp_func_solid_XOR(uint *dest, int length, uint color, uint co comp_func_solid_XOR_template(dest, length, color, const_alpha); } -void QT_FASTCALL comp_func_solid_XOR_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) -{ - comp_func_solid_XOR_template(dest, length, color, const_alpha); -} - void QT_FASTCALL comp_func_XOR(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) { comp_func_XOR_template(dest, src, length, const_alpha); } +#if QT_CONFIG(raster_64bit) +void QT_FASTCALL comp_func_solid_XOR_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) +{ + comp_func_solid_XOR_template(dest, length, color, const_alpha); +} + void QT_FASTCALL comp_func_XOR_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha) { comp_func_XOR_template(dest, src, length, const_alpha); } +#endif struct QFullCoverage { inline void store(uint *dest, const uint src) const @@ -1078,20 +1105,22 @@ void QT_FASTCALL comp_func_solid_Plus(uint *dest, int length, uint color, uint c comp_func_solid_Plus_template(dest, length, color, const_alpha); } -void QT_FASTCALL comp_func_solid_Plus_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) -{ - comp_func_solid_Plus_template(dest, length, color, const_alpha); -} - void QT_FASTCALL comp_func_Plus(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) { comp_func_Plus_template(dest, src, length, const_alpha); } +#if QT_CONFIG(raster_64bit) +void QT_FASTCALL comp_func_solid_Plus_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) +{ + comp_func_solid_Plus_template(dest, length, color, const_alpha); +} + void QT_FASTCALL comp_func_Plus_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha) { comp_func_Plus_template(dest, src, length, const_alpha); } +#endif /* Dca' = Sca.Dca + Sca.(1 - Da) + Dca.(1 - Sa) @@ -1101,11 +1130,6 @@ static inline int multiply_op(int dst, int src, int da, int sa) return qt_div_255(src * dst + src * (255 - da) + dst * (255 - sa)); } -static inline uint multiply_op_rgb64(uint dst, uint src, uint da, uint sa) -{ - return qt_div_65535(src * dst + src * (65535 - da) + dst * (65535 - sa)); -} - template static inline void comp_func_solid_Multiply_impl(uint *dest, int length, uint color, const T &coverage) { @@ -1129,6 +1153,20 @@ static inline void comp_func_solid_Multiply_impl(uint *dest, int length, uint co } } +void QT_FASTCALL comp_func_solid_Multiply(uint *dest, int length, uint color, uint const_alpha) +{ + if (const_alpha == 255) + comp_func_solid_Multiply_impl(dest, length, color, QFullCoverage()); + else + comp_func_solid_Multiply_impl(dest, length, color, QPartialCoverage(const_alpha)); +} + +#if QT_CONFIG(raster_64bit) +static inline uint multiply_op_rgb64(uint dst, uint src, uint da, uint sa) +{ + return qt_div_65535(src * dst + src * (65535 - da) + dst * (65535 - sa)); +} + template static inline void comp_func_solid_Multiply_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) { @@ -1152,14 +1190,6 @@ static inline void comp_func_solid_Multiply_impl(QRgba64 *dest, int length, QRgb } } -void QT_FASTCALL comp_func_solid_Multiply(uint *dest, int length, uint color, uint const_alpha) -{ - if (const_alpha == 255) - comp_func_solid_Multiply_impl(dest, length, color, QFullCoverage()); - else - comp_func_solid_Multiply_impl(dest, length, color, QPartialCoverage(const_alpha)); -} - void QT_FASTCALL comp_func_solid_Multiply_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) { if (const_alpha == 255) @@ -1167,6 +1197,7 @@ void QT_FASTCALL comp_func_solid_Multiply_rgb64(QRgba64 *dest, int length, QRgba else comp_func_solid_Multiply_impl(dest, length, color, QPartialCoverage(const_alpha)); } +#endif template static inline void comp_func_Multiply_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) @@ -1189,6 +1220,15 @@ static inline void comp_func_Multiply_impl(uint *Q_DECL_RESTRICT dest, const uin } } +void QT_FASTCALL comp_func_Multiply(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) +{ + if (const_alpha == 255) + comp_func_Multiply_impl(dest, src, length, QFullCoverage()); + else + comp_func_Multiply_impl(dest, src, length, QPartialCoverage(const_alpha)); +} + +#if QT_CONFIG(raster_64bit) template static inline void comp_func_Multiply_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) { @@ -1210,14 +1250,6 @@ static inline void comp_func_Multiply_impl(QRgba64 *Q_DECL_RESTRICT dest, const } } -void QT_FASTCALL comp_func_Multiply(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) -{ - if (const_alpha == 255) - comp_func_Multiply_impl(dest, src, length, QFullCoverage()); - else - comp_func_Multiply_impl(dest, src, length, QPartialCoverage(const_alpha)); -} - void QT_FASTCALL comp_func_Multiply_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha) { if (const_alpha == 255) @@ -1225,6 +1257,7 @@ void QT_FASTCALL comp_func_Multiply_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const Q else comp_func_Multiply_impl(dest, src, length, QPartialCoverage(const_alpha)); } +#endif /* Dca' = (Sca.Da + Dca.Sa - Sca.Dca) + Sca.(1 - Da) + Dca.(1 - Sa) @@ -1253,6 +1286,15 @@ static inline void comp_func_solid_Screen_impl(uint *dest, int length, uint colo } } +void QT_FASTCALL comp_func_solid_Screen(uint *dest, int length, uint color, uint const_alpha) +{ + if (const_alpha == 255) + comp_func_solid_Screen_impl(dest, length, color, QFullCoverage()); + else + comp_func_solid_Screen_impl(dest, length, color, QPartialCoverage(const_alpha)); +} + +#if QT_CONFIG(raster_64bit) template static inline void comp_func_solid_Screen_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) { @@ -1276,14 +1318,6 @@ static inline void comp_func_solid_Screen_impl(QRgba64 *dest, int length, QRgba6 } } -void QT_FASTCALL comp_func_solid_Screen(uint *dest, int length, uint color, uint const_alpha) -{ - if (const_alpha == 255) - comp_func_solid_Screen_impl(dest, length, color, QFullCoverage()); - else - comp_func_solid_Screen_impl(dest, length, color, QPartialCoverage(const_alpha)); -} - void QT_FASTCALL comp_func_solid_Screen_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) { if (const_alpha == 255) @@ -1291,6 +1325,7 @@ void QT_FASTCALL comp_func_solid_Screen_rgb64(QRgba64 *dest, int length, QRgba64 else comp_func_solid_Screen_impl(dest, length, color, QPartialCoverage(const_alpha)); } +#endif template static inline void comp_func_Screen_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) @@ -1313,6 +1348,15 @@ static inline void comp_func_Screen_impl(uint *Q_DECL_RESTRICT dest, const uint } } +void QT_FASTCALL comp_func_Screen(uint *dest, const uint *src, int length, uint const_alpha) +{ + if (const_alpha == 255) + comp_func_Screen_impl(dest, src, length, QFullCoverage()); + else + comp_func_Screen_impl(dest, src, length, QPartialCoverage(const_alpha)); +} + +#if QT_CONFIG(raster_64bit) template static inline void comp_func_Screen_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) { @@ -1334,14 +1378,6 @@ static inline void comp_func_Screen_impl(QRgba64 *Q_DECL_RESTRICT dest, const QR } } -void QT_FASTCALL comp_func_Screen(uint *dest, const uint *src, int length, uint const_alpha) -{ - if (const_alpha == 255) - comp_func_Screen_impl(dest, src, length, QFullCoverage()); - else - comp_func_Screen_impl(dest, src, length, QPartialCoverage(const_alpha)); -} - void QT_FASTCALL comp_func_Screen_rgb64(QRgba64 *dest, const QRgba64 *src, int length, uint const_alpha) { if (const_alpha == 255) @@ -1349,6 +1385,7 @@ void QT_FASTCALL comp_func_Screen_rgb64(QRgba64 *dest, const QRgba64 *src, int l else comp_func_Screen_impl(dest, src, length, QPartialCoverage(const_alpha)); } +#endif /* if 2.Dca < Da @@ -1365,15 +1402,6 @@ static inline int overlay_op(int dst, int src, int da, int sa) return qt_div_255(sa * da - 2 * (da - dst) * (sa - src) + temp); } -static inline uint overlay_op_rgb64(uint dst, uint src, uint da, uint sa) -{ - const uint temp = src * (65535 - da) + dst * (65535 - sa); - if (2 * dst < da) - return qt_div_65535(2 * src * dst + temp); - else - return qt_div_65535(sa * da - 2 * (da - dst) * (sa - src) + temp); -} - template static inline void comp_func_solid_Overlay_impl(uint *dest, int length, uint color, const T &coverage) { @@ -1397,6 +1425,24 @@ static inline void comp_func_solid_Overlay_impl(uint *dest, int length, uint col } } +void QT_FASTCALL comp_func_solid_Overlay(uint *dest, int length, uint color, uint const_alpha) +{ + if (const_alpha == 255) + comp_func_solid_Overlay_impl(dest, length, color, QFullCoverage()); + else + comp_func_solid_Overlay_impl(dest, length, color, QPartialCoverage(const_alpha)); +} + +#if QT_CONFIG(raster_64bit) +static inline uint overlay_op_rgb64(uint dst, uint src, uint da, uint sa) +{ + const uint temp = src * (65535 - da) + dst * (65535 - sa); + if (2 * dst < da) + return qt_div_65535(2 * src * dst + temp); + else + return qt_div_65535(sa * da - 2 * (da - dst) * (sa - src) + temp); +} + template static inline void comp_func_solid_Overlay_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) { @@ -1420,14 +1466,6 @@ static inline void comp_func_solid_Overlay_impl(QRgba64 *dest, int length, QRgba } } -void QT_FASTCALL comp_func_solid_Overlay(uint *dest, int length, uint color, uint const_alpha) -{ - if (const_alpha == 255) - comp_func_solid_Overlay_impl(dest, length, color, QFullCoverage()); - else - comp_func_solid_Overlay_impl(dest, length, color, QPartialCoverage(const_alpha)); -} - void QT_FASTCALL comp_func_solid_Overlay_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) { if (const_alpha == 255) @@ -1435,6 +1473,7 @@ void QT_FASTCALL comp_func_solid_Overlay_rgb64(QRgba64 *dest, int length, QRgba6 else comp_func_solid_Overlay_impl(dest, length, color, QPartialCoverage(const_alpha)); } +#endif template static inline void comp_func_Overlay_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) @@ -1457,6 +1496,15 @@ static inline void comp_func_Overlay_impl(uint *Q_DECL_RESTRICT dest, const uint } } +void QT_FASTCALL comp_func_Overlay(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) +{ + if (const_alpha == 255) + comp_func_Overlay_impl(dest, src, length, QFullCoverage()); + else + comp_func_Overlay_impl(dest, src, length, QPartialCoverage(const_alpha)); +} + +#if QT_CONFIG(raster_64bit) template static inline void comp_func_Overlay_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) { @@ -1478,14 +1526,6 @@ static inline void comp_func_Overlay_impl(QRgba64 *Q_DECL_RESTRICT dest, const Q } } -void QT_FASTCALL comp_func_Overlay(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) -{ - if (const_alpha == 255) - comp_func_Overlay_impl(dest, src, length, QFullCoverage()); - else - comp_func_Overlay_impl(dest, src, length, QPartialCoverage(const_alpha)); -} - void QT_FASTCALL comp_func_Overlay_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha) { if (const_alpha == 255) @@ -1493,6 +1533,7 @@ void QT_FASTCALL comp_func_Overlay_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QR else comp_func_Overlay_impl(dest, src, length, QPartialCoverage(const_alpha)); } +#endif /* Dca' = min(Sca.Da, Dca.Sa) + Sca.(1 - Da) + Dca.(1 - Sa) @@ -1503,11 +1544,6 @@ static inline int darken_op(int dst, int src, int da, int sa) return qt_div_255(qMin(src * da, dst * sa) + src * (255 - da) + dst * (255 - sa)); } -static inline uint darken_op_rgb64(uint dst, uint src, uint da, uint sa) -{ - return qt_div_65535(qMin(src * da, dst * sa) + src * (65535 - da) + dst * (65535 - sa)); -} - template static inline void comp_func_solid_Darken_impl(uint *dest, int length, uint color, const T &coverage) { @@ -1531,6 +1567,20 @@ static inline void comp_func_solid_Darken_impl(uint *dest, int length, uint colo } } +void QT_FASTCALL comp_func_solid_Darken(uint *dest, int length, uint color, uint const_alpha) +{ + if (const_alpha == 255) + comp_func_solid_Darken_impl(dest, length, color, QFullCoverage()); + else + comp_func_solid_Darken_impl(dest, length, color, QPartialCoverage(const_alpha)); +} + +#if QT_CONFIG(raster_64bit) +static inline uint darken_op_rgb64(uint dst, uint src, uint da, uint sa) +{ + return qt_div_65535(qMin(src * da, dst * sa) + src * (65535 - da) + dst * (65535 - sa)); +} + template static inline void comp_func_solid_Darken_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) { @@ -1554,14 +1604,6 @@ static inline void comp_func_solid_Darken_impl(QRgba64 *dest, int length, QRgba6 } } -void QT_FASTCALL comp_func_solid_Darken(uint *dest, int length, uint color, uint const_alpha) -{ - if (const_alpha == 255) - comp_func_solid_Darken_impl(dest, length, color, QFullCoverage()); - else - comp_func_solid_Darken_impl(dest, length, color, QPartialCoverage(const_alpha)); -} - void QT_FASTCALL comp_func_solid_Darken_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) { if (const_alpha == 255) @@ -1569,6 +1611,7 @@ void QT_FASTCALL comp_func_solid_Darken_rgb64(QRgba64 *dest, int length, QRgba64 else comp_func_solid_Darken_impl(dest, length, color, QPartialCoverage(const_alpha)); } +#endif template static inline void comp_func_Darken_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) @@ -1591,6 +1634,15 @@ static inline void comp_func_Darken_impl(uint *Q_DECL_RESTRICT dest, const uint } } +void QT_FASTCALL comp_func_Darken(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) +{ + if (const_alpha == 255) + comp_func_Darken_impl(dest, src, length, QFullCoverage()); + else + comp_func_Darken_impl(dest, src, length, QPartialCoverage(const_alpha)); +} + +#if QT_CONFIG(raster_64bit) template static inline void comp_func_Darken_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) { @@ -1612,14 +1664,6 @@ static inline void comp_func_Darken_impl(QRgba64 *Q_DECL_RESTRICT dest, const QR } } -void QT_FASTCALL comp_func_Darken(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) -{ - if (const_alpha == 255) - comp_func_Darken_impl(dest, src, length, QFullCoverage()); - else - comp_func_Darken_impl(dest, src, length, QPartialCoverage(const_alpha)); -} - void QT_FASTCALL comp_func_Darken_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha) { if (const_alpha == 255) @@ -1627,6 +1671,7 @@ void QT_FASTCALL comp_func_Darken_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRg else comp_func_Darken_impl(dest, src, length, QPartialCoverage(const_alpha)); } +#endif /* Dca' = max(Sca.Da, Dca.Sa) + Sca.(1 - Da) + Dca.(1 - Sa) @@ -1637,11 +1682,6 @@ static inline int lighten_op(int dst, int src, int da, int sa) return qt_div_255(qMax(src * da, dst * sa) + src * (255 - da) + dst * (255 - sa)); } -static inline uint lighten_op_rgb64(uint dst, uint src, uint da, uint sa) -{ - return qt_div_65535(qMax(src * da, dst * sa) + src * (65535 - da) + dst * (65535 - sa)); -} - template static inline void comp_func_solid_Lighten_impl(uint *dest, int length, uint color, const T &coverage) { @@ -1665,6 +1705,21 @@ static inline void comp_func_solid_Lighten_impl(uint *dest, int length, uint col } } +void QT_FASTCALL comp_func_solid_Lighten(uint *dest, int length, uint color, uint const_alpha) +{ + if (const_alpha == 255) + comp_func_solid_Lighten_impl(dest, length, color, QFullCoverage()); + else + comp_func_solid_Lighten_impl(dest, length, color, QPartialCoverage(const_alpha)); +} + + +#if QT_CONFIG(raster_64bit) +static inline uint lighten_op_rgb64(uint dst, uint src, uint da, uint sa) +{ + return qt_div_65535(qMax(src * da, dst * sa) + src * (65535 - da) + dst * (65535 - sa)); +} + template static inline void comp_func_solid_Lighten_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) { @@ -1688,14 +1743,6 @@ static inline void comp_func_solid_Lighten_impl(QRgba64 *dest, int length, QRgba } } -void QT_FASTCALL comp_func_solid_Lighten(uint *dest, int length, uint color, uint const_alpha) -{ - if (const_alpha == 255) - comp_func_solid_Lighten_impl(dest, length, color, QFullCoverage()); - else - comp_func_solid_Lighten_impl(dest, length, color, QPartialCoverage(const_alpha)); -} - void QT_FASTCALL comp_func_solid_Lighten_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) { if (const_alpha == 255) @@ -1703,6 +1750,7 @@ void QT_FASTCALL comp_func_solid_Lighten_rgb64(QRgba64 *dest, int length, QRgba6 else comp_func_solid_Lighten_impl(dest, length, color, QPartialCoverage(const_alpha)); } +#endif template static inline void comp_func_Lighten_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) @@ -1725,6 +1773,15 @@ static inline void comp_func_Lighten_impl(uint *Q_DECL_RESTRICT dest, const uint } } +void QT_FASTCALL comp_func_Lighten(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) +{ + if (const_alpha == 255) + comp_func_Lighten_impl(dest, src, length, QFullCoverage()); + else + comp_func_Lighten_impl(dest, src, length, QPartialCoverage(const_alpha)); +} + +#if QT_CONFIG(raster_64bit) template static inline void comp_func_Lighten_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) { @@ -1746,14 +1803,6 @@ static inline void comp_func_Lighten_impl(QRgba64 *Q_DECL_RESTRICT dest, const Q } } -void QT_FASTCALL comp_func_Lighten(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) -{ - if (const_alpha == 255) - comp_func_Lighten_impl(dest, src, length, QFullCoverage()); - else - comp_func_Lighten_impl(dest, src, length, QPartialCoverage(const_alpha)); -} - void QT_FASTCALL comp_func_Lighten_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha) { if (const_alpha == 255) @@ -1761,6 +1810,7 @@ void QT_FASTCALL comp_func_Lighten_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QR else comp_func_Lighten_impl(dest, src, length, QPartialCoverage(const_alpha)); } +#endif /* if Sca.Da + Dca.Sa >= Sa.Da @@ -1781,19 +1831,6 @@ static inline int color_dodge_op(int dst, int src, int da, int sa) return qt_div_255(255 * dst_sa / (255 - 255 * src / sa) + temp); } -static inline uint color_dodge_op_rgb64(qint64 dst, qint64 src, qint64 da, qint64 sa) -{ - const qint64 sa_da = sa * da; - const qint64 dst_sa = dst * sa; - const qint64 src_da = src * da; - - const qint64 temp = src * (65535 - da) + dst * (65535 - sa); - if (src_da + dst_sa >= sa_da) - return qt_div_65535(sa_da + temp); - else - return qt_div_65535(65535 * dst_sa / (65535 - 65535 * src / sa) + temp); -} - template static inline void comp_func_solid_ColorDodge_impl(uint *dest, int length, uint color, const T &coverage) { @@ -1817,6 +1854,28 @@ static inline void comp_func_solid_ColorDodge_impl(uint *dest, int length, uint } } +void QT_FASTCALL comp_func_solid_ColorDodge(uint *dest, int length, uint color, uint const_alpha) +{ + if (const_alpha == 255) + comp_func_solid_ColorDodge_impl(dest, length, color, QFullCoverage()); + else + comp_func_solid_ColorDodge_impl(dest, length, color, QPartialCoverage(const_alpha)); +} + +#if QT_CONFIG(raster_64bit) +static inline uint color_dodge_op_rgb64(qint64 dst, qint64 src, qint64 da, qint64 sa) +{ + const qint64 sa_da = sa * da; + const qint64 dst_sa = dst * sa; + const qint64 src_da = src * da; + + const qint64 temp = src * (65535 - da) + dst * (65535 - sa); + if (src_da + dst_sa >= sa_da) + return qt_div_65535(sa_da + temp); + else + return qt_div_65535(65535 * dst_sa / (65535 - 65535 * src / sa) + temp); +} + template static inline void comp_func_solid_ColorDodge_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) { @@ -1840,14 +1899,6 @@ static inline void comp_func_solid_ColorDodge_impl(QRgba64 *dest, int length, QR } } -void QT_FASTCALL comp_func_solid_ColorDodge(uint *dest, int length, uint color, uint const_alpha) -{ - if (const_alpha == 255) - comp_func_solid_ColorDodge_impl(dest, length, color, QFullCoverage()); - else - comp_func_solid_ColorDodge_impl(dest, length, color, QPartialCoverage(const_alpha)); -} - void QT_FASTCALL comp_func_solid_ColorDodge_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) { if (const_alpha == 255) @@ -1855,6 +1906,7 @@ void QT_FASTCALL comp_func_solid_ColorDodge_rgb64(QRgba64 *dest, int length, QRg else comp_func_solid_ColorDodge_impl(dest, length, color, QPartialCoverage(const_alpha)); } +#endif template static inline void comp_func_ColorDodge_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) @@ -1877,6 +1929,15 @@ static inline void comp_func_ColorDodge_impl(uint *Q_DECL_RESTRICT dest, const u } } +void QT_FASTCALL comp_func_ColorDodge(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) +{ + if (const_alpha == 255) + comp_func_ColorDodge_impl(dest, src, length, QFullCoverage()); + else + comp_func_ColorDodge_impl(dest, src, length, QPartialCoverage(const_alpha)); +} + +#if QT_CONFIG(raster_64bit) template static inline void comp_func_ColorDodge_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) { @@ -1898,14 +1959,6 @@ static inline void comp_func_ColorDodge_impl(QRgba64 *Q_DECL_RESTRICT dest, cons } } -void QT_FASTCALL comp_func_ColorDodge(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) -{ - if (const_alpha == 255) - comp_func_ColorDodge_impl(dest, src, length, QFullCoverage()); - else - comp_func_ColorDodge_impl(dest, src, length, QPartialCoverage(const_alpha)); -} - void QT_FASTCALL comp_func_ColorDodge_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha) { if (const_alpha == 255) @@ -1913,6 +1966,7 @@ void QT_FASTCALL comp_func_ColorDodge_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const else comp_func_ColorDodge_impl(dest, src, length, QPartialCoverage(const_alpha)); } +#endif /* if Sca.Da + Dca.Sa <= Sa.Da @@ -1933,19 +1987,6 @@ static inline int color_burn_op(int dst, int src, int da, int sa) return qt_div_255(sa * (src_da + dst_sa - sa_da) / src + temp); } -static inline uint color_burn_op_rgb64(qint64 dst, qint64 src, qint64 da, qint64 sa) -{ - const qint64 src_da = src * da; - const qint64 dst_sa = dst * sa; - const qint64 sa_da = sa * da; - - const qint64 temp = src * (65535 - da) + dst * (65535 - sa); - - if (src == 0 || src_da + dst_sa <= sa_da) - return qt_div_65535(temp); - return qt_div_65535(sa * (src_da + dst_sa - sa_da) / src + temp); -} - template static inline void comp_func_solid_ColorBurn_impl(uint *dest, int length, uint color, const T &coverage) { @@ -1969,6 +2010,28 @@ static inline void comp_func_solid_ColorBurn_impl(uint *dest, int length, uint c } } +void QT_FASTCALL comp_func_solid_ColorBurn(uint *dest, int length, uint color, uint const_alpha) +{ + if (const_alpha == 255) + comp_func_solid_ColorBurn_impl(dest, length, color, QFullCoverage()); + else + comp_func_solid_ColorBurn_impl(dest, length, color, QPartialCoverage(const_alpha)); +} + +#if QT_CONFIG(raster_64bit) +static inline uint color_burn_op_rgb64(qint64 dst, qint64 src, qint64 da, qint64 sa) +{ + const qint64 src_da = src * da; + const qint64 dst_sa = dst * sa; + const qint64 sa_da = sa * da; + + const qint64 temp = src * (65535 - da) + dst * (65535 - sa); + + if (src == 0 || src_da + dst_sa <= sa_da) + return qt_div_65535(temp); + return qt_div_65535(sa * (src_da + dst_sa - sa_da) / src + temp); +} + template static inline void comp_func_solid_ColorBurn_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) { @@ -1992,14 +2055,6 @@ static inline void comp_func_solid_ColorBurn_impl(QRgba64 *dest, int length, QRg } } -void QT_FASTCALL comp_func_solid_ColorBurn(uint *dest, int length, uint color, uint const_alpha) -{ - if (const_alpha == 255) - comp_func_solid_ColorBurn_impl(dest, length, color, QFullCoverage()); - else - comp_func_solid_ColorBurn_impl(dest, length, color, QPartialCoverage(const_alpha)); -} - void QT_FASTCALL comp_func_solid_ColorBurn_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) { if (const_alpha == 255) @@ -2007,6 +2062,7 @@ void QT_FASTCALL comp_func_solid_ColorBurn_rgb64(QRgba64 *dest, int length, QRgb else comp_func_solid_ColorBurn_impl(dest, length, color, QPartialCoverage(const_alpha)); } +#endif template static inline void comp_func_ColorBurn_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) @@ -2029,6 +2085,15 @@ static inline void comp_func_ColorBurn_impl(uint *Q_DECL_RESTRICT dest, const ui } } +void QT_FASTCALL comp_func_ColorBurn(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) +{ + if (const_alpha == 255) + comp_func_ColorBurn_impl(dest, src, length, QFullCoverage()); + else + comp_func_ColorBurn_impl(dest, src, length, QPartialCoverage(const_alpha)); +} + +#if QT_CONFIG(raster_64bit) template static inline void comp_func_ColorBurn_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) { @@ -2050,14 +2115,6 @@ static inline void comp_func_ColorBurn_impl(QRgba64 *Q_DECL_RESTRICT dest, const } } -void QT_FASTCALL comp_func_ColorBurn(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) -{ - if (const_alpha == 255) - comp_func_ColorBurn_impl(dest, src, length, QFullCoverage()); - else - comp_func_ColorBurn_impl(dest, src, length, QPartialCoverage(const_alpha)); -} - void QT_FASTCALL comp_func_ColorBurn_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha) { if (const_alpha == 255) @@ -2065,6 +2122,7 @@ void QT_FASTCALL comp_func_ColorBurn_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const else comp_func_ColorBurn_impl(dest, src, length, QPartialCoverage(const_alpha)); } +#endif /* if 2.Sca < Sa @@ -2082,16 +2140,6 @@ static inline uint hardlight_op(int dst, int src, int da, int sa) return qt_div_255(sa * da - 2 * (da - dst) * (sa - src) + temp); } -static inline uint hardlight_op_rgb64(uint dst, uint src, uint da, uint sa) -{ - const uint temp = src * (65535 - da) + dst * (65535 - sa); - - if (2 * src < sa) - return qt_div_65535(2 * src * dst + temp); - else - return qt_div_65535(sa * da - 2 * (da - dst) * (sa - src) + temp); -} - template static inline void comp_func_solid_HardLight_impl(uint *dest, int length, uint color, const T &coverage) { @@ -2115,6 +2163,25 @@ static inline void comp_func_solid_HardLight_impl(uint *dest, int length, uint c } } +void QT_FASTCALL comp_func_solid_HardLight(uint *dest, int length, uint color, uint const_alpha) +{ + if (const_alpha == 255) + comp_func_solid_HardLight_impl(dest, length, color, QFullCoverage()); + else + comp_func_solid_HardLight_impl(dest, length, color, QPartialCoverage(const_alpha)); +} + +#if QT_CONFIG(raster_64bit) +static inline uint hardlight_op_rgb64(uint dst, uint src, uint da, uint sa) +{ + const uint temp = src * (65535 - da) + dst * (65535 - sa); + + if (2 * src < sa) + return qt_div_65535(2 * src * dst + temp); + else + return qt_div_65535(sa * da - 2 * (da - dst) * (sa - src) + temp); +} + template static inline void comp_func_solid_HardLight_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) { @@ -2138,14 +2205,6 @@ static inline void comp_func_solid_HardLight_impl(QRgba64 *dest, int length, QRg } } -void QT_FASTCALL comp_func_solid_HardLight(uint *dest, int length, uint color, uint const_alpha) -{ - if (const_alpha == 255) - comp_func_solid_HardLight_impl(dest, length, color, QFullCoverage()); - else - comp_func_solid_HardLight_impl(dest, length, color, QPartialCoverage(const_alpha)); -} - void QT_FASTCALL comp_func_solid_HardLight_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) { if (const_alpha == 255) @@ -2153,6 +2212,7 @@ void QT_FASTCALL comp_func_solid_HardLight_rgb64(QRgba64 *dest, int length, QRgb else comp_func_solid_HardLight_impl(dest, length, color, QPartialCoverage(const_alpha)); } +#endif template static inline void comp_func_HardLight_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) @@ -2175,6 +2235,15 @@ static inline void comp_func_HardLight_impl(uint *Q_DECL_RESTRICT dest, const ui } } +void QT_FASTCALL comp_func_HardLight(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) +{ + if (const_alpha == 255) + comp_func_HardLight_impl(dest, src, length, QFullCoverage()); + else + comp_func_HardLight_impl(dest, src, length, QPartialCoverage(const_alpha)); +} + +#if QT_CONFIG(raster_64bit) template static inline void comp_func_HardLight_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) { @@ -2196,14 +2265,6 @@ static inline void comp_func_HardLight_impl(QRgba64 *Q_DECL_RESTRICT dest, const } } -void QT_FASTCALL comp_func_HardLight(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) -{ - if (const_alpha == 255) - comp_func_HardLight_impl(dest, src, length, QFullCoverage()); - else - comp_func_HardLight_impl(dest, src, length, QPartialCoverage(const_alpha)); -} - void QT_FASTCALL comp_func_HardLight_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha) { if (const_alpha == 255) @@ -2211,6 +2272,7 @@ void QT_FASTCALL comp_func_HardLight_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const else comp_func_HardLight_impl(dest, src, length, QPartialCoverage(const_alpha)); } +#endif /* if 2.Sca <= Sa @@ -2235,22 +2297,6 @@ static inline int soft_light_op(int dst, int src, int da, int sa) } } -static inline uint soft_light_op_rgb64(qint64 dst, qint64 src, qint64 da, qint64 sa) -{ - const qint64 src2 = src << 1; - const qint64 dst_np = da != 0 ? (65535 * dst) / da : 0; - const qint64 temp = (src * (65535 - da) + dst * (65535 - sa)) * 65535; - const qint64 factor = qint64(65535) * 65535; - - if (src2 < sa) - return (dst * (sa * 65535 + (src2 - sa) * (65535 - dst_np)) + temp) / factor; - else if (4 * dst <= da) - return (dst * sa * 65535 + da * (src2 - sa) * ((((16 * dst_np - 12 * 65535) * dst_np + 3 * factor) * dst_np) / factor) + temp) / factor; - else { - return (dst * sa * 65535 + da * (src2 - sa) * (int(qSqrt(qreal(dst_np * 65535))) - dst_np) + temp) / factor; - } -} - template static inline void comp_func_solid_SoftLight_impl(uint *dest, int length, uint color, const T &coverage) { @@ -2274,6 +2320,23 @@ static inline void comp_func_solid_SoftLight_impl(uint *dest, int length, uint c } } +#if QT_CONFIG(raster_64bit) +static inline uint soft_light_op_rgb64(qint64 dst, qint64 src, qint64 da, qint64 sa) +{ + const qint64 src2 = src << 1; + const qint64 dst_np = da != 0 ? (65535 * dst) / da : 0; + const qint64 temp = (src * (65535 - da) + dst * (65535 - sa)) * 65535; + const qint64 factor = qint64(65535) * 65535; + + if (src2 < sa) + return (dst * (sa * 65535 + (src2 - sa) * (65535 - dst_np)) + temp) / factor; + else if (4 * dst <= da) + return (dst * sa * 65535 + da * (src2 - sa) * ((((16 * dst_np - 12 * 65535) * dst_np + 3 * factor) * dst_np) / factor) + temp) / factor; + else { + return (dst * sa * 65535 + da * (src2 - sa) * (int(qSqrt(qreal(dst_np * 65535))) - dst_np) + temp) / factor; + } +} + template static inline void comp_func_solid_SoftLight_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) { @@ -2296,6 +2359,7 @@ static inline void comp_func_solid_SoftLight_impl(QRgba64 *dest, int length, QRg coverage.store(&dest[i], qRgba64(r, g, b, a)); } } +#endif void QT_FASTCALL comp_func_solid_SoftLight(uint *dest, int length, uint color, uint const_alpha) { @@ -2305,14 +2369,6 @@ void QT_FASTCALL comp_func_solid_SoftLight(uint *dest, int length, uint color, u comp_func_solid_SoftLight_impl(dest, length, color, QPartialCoverage(const_alpha)); } -void QT_FASTCALL comp_func_solid_SoftLight_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) -{ - if (const_alpha == 255) - comp_func_solid_SoftLight_impl(dest, length, color, QFullCoverage()); - else - comp_func_solid_SoftLight_impl(dest, length, color, QPartialCoverage(const_alpha)); -} - template static inline void comp_func_SoftLight_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) { @@ -2334,6 +2390,23 @@ static inline void comp_func_SoftLight_impl(uint *Q_DECL_RESTRICT dest, const ui } } +void QT_FASTCALL comp_func_SoftLight(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) +{ + if (const_alpha == 255) + comp_func_SoftLight_impl(dest, src, length, QFullCoverage()); + else + comp_func_SoftLight_impl(dest, src, length, QPartialCoverage(const_alpha)); +} + +#if QT_CONFIG(raster_64bit) +void QT_FASTCALL comp_func_solid_SoftLight_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) +{ + if (const_alpha == 255) + comp_func_solid_SoftLight_impl(dest, length, color, QFullCoverage()); + else + comp_func_solid_SoftLight_impl(dest, length, color, QPartialCoverage(const_alpha)); +} + template static inline void comp_func_SoftLight_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) { @@ -2355,14 +2428,6 @@ static inline void comp_func_SoftLight_impl(QRgba64 *Q_DECL_RESTRICT dest, const } } -void QT_FASTCALL comp_func_SoftLight(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) -{ - if (const_alpha == 255) - comp_func_SoftLight_impl(dest, src, length, QFullCoverage()); - else - comp_func_SoftLight_impl(dest, src, length, QPartialCoverage(const_alpha)); -} - void QT_FASTCALL comp_func_SoftLight_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha) { if (const_alpha == 255) @@ -2370,6 +2435,7 @@ void QT_FASTCALL comp_func_SoftLight_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const else comp_func_SoftLight_impl(dest, src, length, QPartialCoverage(const_alpha)); } +#endif /* Dca' = abs(Dca.Sa - Sca.Da) + Sca.(1 - Da) + Dca.(1 - Sa) @@ -2380,11 +2446,6 @@ static inline int difference_op(int dst, int src, int da, int sa) return src + dst - qt_div_255(2 * qMin(src * da, dst * sa)); } -static inline uint difference_op_rgb64(qint64 dst, qint64 src, qint64 da, qint64 sa) -{ - return src + dst - qt_div_65535(2 * qMin(src * da, dst * sa)); -} - template static inline void comp_func_solid_Difference_impl(uint *dest, int length, uint color, const T &coverage) { @@ -2408,6 +2469,20 @@ static inline void comp_func_solid_Difference_impl(uint *dest, int length, uint } } +void QT_FASTCALL comp_func_solid_Difference(uint *dest, int length, uint color, uint const_alpha) +{ + if (const_alpha == 255) + comp_func_solid_Difference_impl(dest, length, color, QFullCoverage()); + else + comp_func_solid_Difference_impl(dest, length, color, QPartialCoverage(const_alpha)); +} + +#if QT_CONFIG(raster_64bit) +static inline uint difference_op_rgb64(qint64 dst, qint64 src, qint64 da, qint64 sa) +{ + return src + dst - qt_div_65535(2 * qMin(src * da, dst * sa)); +} + template static inline void comp_func_solid_Difference_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) { @@ -2431,14 +2506,6 @@ static inline void comp_func_solid_Difference_impl(QRgba64 *dest, int length, QR } } -void QT_FASTCALL comp_func_solid_Difference(uint *dest, int length, uint color, uint const_alpha) -{ - if (const_alpha == 255) - comp_func_solid_Difference_impl(dest, length, color, QFullCoverage()); - else - comp_func_solid_Difference_impl(dest, length, color, QPartialCoverage(const_alpha)); -} - void QT_FASTCALL comp_func_solid_Difference_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) { if (const_alpha == 255) @@ -2446,6 +2513,7 @@ void QT_FASTCALL comp_func_solid_Difference_rgb64(QRgba64 *dest, int length, QRg else comp_func_solid_Difference_impl(dest, length, color, QPartialCoverage(const_alpha)); } +#endif template static inline void comp_func_Difference_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) @@ -2468,6 +2536,15 @@ static inline void comp_func_Difference_impl(uint *Q_DECL_RESTRICT dest, const u } } +void QT_FASTCALL comp_func_Difference(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) +{ + if (const_alpha == 255) + comp_func_Difference_impl(dest, src, length, QFullCoverage()); + else + comp_func_Difference_impl(dest, src, length, QPartialCoverage(const_alpha)); +} + +#if QT_CONFIG(raster_64bit) template static inline void comp_func_Difference_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) { @@ -2489,14 +2566,6 @@ static inline void comp_func_Difference_impl(QRgba64 *Q_DECL_RESTRICT dest, cons } } -void QT_FASTCALL comp_func_Difference(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) -{ - if (const_alpha == 255) - comp_func_Difference_impl(dest, src, length, QFullCoverage()); - else - comp_func_Difference_impl(dest, src, length, QPartialCoverage(const_alpha)); -} - void QT_FASTCALL comp_func_Difference_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha) { if (const_alpha == 255) @@ -2504,6 +2573,7 @@ void QT_FASTCALL comp_func_Difference_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const else comp_func_Difference_impl(dest, src, length, QPartialCoverage(const_alpha)); } +#endif /* Dca' = (Sca.Da + Dca.Sa - 2.Sca.Dca) + Sca.(1 - Da) + Dca.(1 - Sa) @@ -2531,6 +2601,15 @@ static inline void QT_FASTCALL comp_func_solid_Exclusion_impl(uint *dest, int le } } +void QT_FASTCALL comp_func_solid_Exclusion(uint *dest, int length, uint color, uint const_alpha) +{ + if (const_alpha == 255) + comp_func_solid_Exclusion_impl(dest, length, color, QFullCoverage()); + else + comp_func_solid_Exclusion_impl(dest, length, color, QPartialCoverage(const_alpha)); +} + +#if QT_CONFIG(raster_64bit) template static inline void QT_FASTCALL comp_func_solid_Exclusion_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) { @@ -2555,14 +2634,6 @@ static inline void QT_FASTCALL comp_func_solid_Exclusion_impl(QRgba64 *dest, int } -void QT_FASTCALL comp_func_solid_Exclusion(uint *dest, int length, uint color, uint const_alpha) -{ - if (const_alpha == 255) - comp_func_solid_Exclusion_impl(dest, length, color, QFullCoverage()); - else - comp_func_solid_Exclusion_impl(dest, length, color, QPartialCoverage(const_alpha)); -} - void QT_FASTCALL comp_func_solid_Exclusion_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) { if (const_alpha == 255) @@ -2570,6 +2641,7 @@ void QT_FASTCALL comp_func_solid_Exclusion_rgb64(QRgba64 *dest, int length, QRgb else comp_func_solid_Exclusion_impl(dest, length, color, QPartialCoverage(const_alpha)); } +#endif template static inline void comp_func_Exclusion_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) @@ -2592,6 +2664,15 @@ static inline void comp_func_Exclusion_impl(uint *Q_DECL_RESTRICT dest, const ui } } +void QT_FASTCALL comp_func_Exclusion(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) +{ + if (const_alpha == 255) + comp_func_Exclusion_impl(dest, src, length, QFullCoverage()); + else + comp_func_Exclusion_impl(dest, src, length, QPartialCoverage(const_alpha)); +} + +#if QT_CONFIG(raster_64bit) template static inline void comp_func_Exclusion_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) { @@ -2613,14 +2694,6 @@ static inline void comp_func_Exclusion_impl(QRgba64 *Q_DECL_RESTRICT dest, const } } -void QT_FASTCALL comp_func_Exclusion(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha) -{ - if (const_alpha == 255) - comp_func_Exclusion_impl(dest, src, length, QFullCoverage()); - else - comp_func_Exclusion_impl(dest, src, length, QPartialCoverage(const_alpha)); -} - void QT_FASTCALL comp_func_Exclusion_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha) { if (const_alpha == 255) @@ -2628,6 +2701,7 @@ void QT_FASTCALL comp_func_Exclusion_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const else comp_func_Exclusion_impl(dest, src, length, QPartialCoverage(const_alpha)); } +#endif void QT_FASTCALL rasterop_solid_SourceOrDestination(uint *dest, int length, @@ -2977,6 +3051,7 @@ CompositionFunctionSolid qt_functionForModeSolid_C[] = { }; CompositionFunctionSolid64 qt_functionForModeSolid64_C[] = { +#if QT_CONFIG(raster_64bit) comp_func_solid_SourceOver_rgb64, comp_func_solid_DestinationOver_rgb64, comp_func_solid_Clear_rgb64, @@ -3001,6 +3076,10 @@ CompositionFunctionSolid64 qt_functionForModeSolid64_C[] = { comp_func_solid_SoftLight_rgb64, comp_func_solid_Difference_rgb64, comp_func_solid_Exclusion_rgb64, +#else + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +#endif 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -3047,6 +3126,7 @@ CompositionFunction qt_functionForMode_C[] = { }; CompositionFunction64 qt_functionForMode64_C[] = { +#if QT_CONFIG(raster_64bit) comp_func_SourceOver_rgb64, comp_func_DestinationOver_rgb64, comp_func_Clear_rgb64, @@ -3071,6 +3151,10 @@ CompositionFunction64 qt_functionForMode64_C[] = { comp_func_SoftLight_rgb64, comp_func_Difference_rgb64, comp_func_Exclusion_rgb64, +#else + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +#endif 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 1ed51d26a2..ac15d8f4f4 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -1117,6 +1117,7 @@ static const QRgba64 *QT_FASTCALL fetchARGB32PMToRGBA64PM(QRgba64 *buffer, const return convertARGB32PMToRGBA64PM(buffer, reinterpret_cast(src) + index, count, nullptr, nullptr); } +#if QT_CONFIG(raster_64bit) static void convertRGBA64ToRGBA64PM(QRgba64 *buffer, int count) { for (int i = 0; i < count; ++i) @@ -1126,6 +1127,7 @@ static void convertRGBA64ToRGBA64PM(QRgba64 *buffer, int count) static void convertRGBA64PMToRGBA64PM(QRgba64 *, int) { } +#endif static const QRgba64 *QT_FASTCALL fetchRGBA64ToRGBA64PM(QRgba64 *buffer, const uchar *src, int index, int count, const QVector *, QDitherInfo *) @@ -1699,22 +1701,6 @@ static uint *QT_FASTCALL destFetchUndefined(uint *buffer, QRasterBuffer *, int, return buffer; } -static QRgba64 *QT_FASTCALL destFetch64(QRgba64 *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length) -{ - const QPixelLayout *layout = &qPixelLayouts[rasterBuffer->format]; - return const_cast(layout->fetchToRGBA64PM(buffer, rasterBuffer->scanLine(y), x, length, nullptr, nullptr)); -} - -static QRgba64 * QT_FASTCALL destFetchRGB64(QRgba64 *, QRasterBuffer *rasterBuffer, int x, int y, int) -{ - return (QRgba64 *)rasterBuffer->scanLine(y) + x; -} - -static QRgba64 * QT_FASTCALL destFetch64Undefined(QRgba64 *buffer, QRasterBuffer *, int, int, int) -{ - return buffer; -} - static DestFetchProc destFetchProc[QImage::NImageFormats] = { 0, // Format_Invalid @@ -1748,6 +1734,23 @@ static DestFetchProc destFetchProc[QImage::NImageFormats] = destFetch, // Format_Grayscale16 }; +#if QT_CONFIG(raster_64bit) +static QRgba64 *QT_FASTCALL destFetch64(QRgba64 *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length) +{ + const QPixelLayout *layout = &qPixelLayouts[rasterBuffer->format]; + return const_cast(layout->fetchToRGBA64PM(buffer, rasterBuffer->scanLine(y), x, length, nullptr, nullptr)); +} + +static QRgba64 * QT_FASTCALL destFetchRGB64(QRgba64 *, QRasterBuffer *rasterBuffer, int x, int y, int) +{ + return (QRgba64 *)rasterBuffer->scanLine(y) + x; +} + +static QRgba64 * QT_FASTCALL destFetch64Undefined(QRgba64 *buffer, QRasterBuffer *, int, int, int) +{ + return buffer; +} + static DestFetchProc64 destFetchProc64[QImage::NImageFormats] = { 0, // Format_Invalid @@ -1780,6 +1783,7 @@ static DestFetchProc64 destFetchProc64[QImage::NImageFormats] = destFetchRGB64, // Format_RGBA64_Premultiplied destFetch64, // Format_Grayscale16 }; +#endif /* Returns the color in the mono destination color table @@ -1887,21 +1891,6 @@ static void QT_FASTCALL destStore(QRasterBuffer *rasterBuffer, int x, int y, con store(dest, buffer, x, length, nullptr, nullptr); } -static void QT_FASTCALL destStore64(QRasterBuffer *rasterBuffer, int x, int y, const QRgba64 *buffer, int length) -{ - auto store = qStoreFromRGBA64PM[rasterBuffer->format]; - uchar *dest = rasterBuffer->scanLine(y); - store(dest, buffer, x, length, nullptr, nullptr); -} - -static void QT_FASTCALL destStore64RGBA64(QRasterBuffer *rasterBuffer, int x, int y, const QRgba64 *buffer, int length) -{ - QRgba64 *dest = reinterpret_cast(rasterBuffer->scanLine(y)) + x; - for (int i = 0; i < length; ++i) { - dest[i] = buffer[i].unpremultiplied(); - } -} - static DestStoreProc destStoreProc[QImage::NImageFormats] = { 0, // Format_Invalid @@ -1935,6 +1924,22 @@ static DestStoreProc destStoreProc[QImage::NImageFormats] = destStore, // Format_Grayscale16 }; +#if QT_CONFIG(raster_64bit) +static void QT_FASTCALL destStore64(QRasterBuffer *rasterBuffer, int x, int y, const QRgba64 *buffer, int length) +{ + auto store = qStoreFromRGBA64PM[rasterBuffer->format]; + uchar *dest = rasterBuffer->scanLine(y); + store(dest, buffer, x, length, nullptr, nullptr); +} + +static void QT_FASTCALL destStore64RGBA64(QRasterBuffer *rasterBuffer, int x, int y, const QRgba64 *buffer, int length) +{ + QRgba64 *dest = reinterpret_cast(rasterBuffer->scanLine(y)) + x; + for (int i = 0; i < length; ++i) { + dest[i] = buffer[i].unpremultiplied(); + } +} + static DestStoreProc64 destStoreProc64[QImage::NImageFormats] = { 0, // Format_Invalid @@ -1967,6 +1972,7 @@ static DestStoreProc64 destStoreProc64[QImage::NImageFormats] = 0, // Format_RGBA64_Premultiplied destStore64, // Format_Grayscale16 }; +#endif /* Source fetches @@ -2017,6 +2023,7 @@ static const uint *QT_FASTCALL fetchUntransformedRGB16(uint *buffer, const Opera return buffer; } +#if QT_CONFIG(raster_64bit) static const QRgba64 *QT_FASTCALL fetchUntransformed64(QRgba64 *buffer, const Operator *, const QSpanData *data, int y, int x, int length) { @@ -2030,6 +2037,7 @@ static const QRgba64 *QT_FASTCALL fetchUntransformedRGBA64PM(QRgba64 *, const Op const uchar *scanLine = data->texture.scanLine(y); return reinterpret_cast(scanLine) + x; } +#endif template inline void fetchTransformed_pixelBounds(int max, int l1, int l2, int &v) @@ -2220,6 +2228,7 @@ static const uint *QT_FASTCALL fetchTransformed(uint *buffer, const Operator *, return buffer; } +#if QT_CONFIG(raster_64bit) template /* either BlendTransformed or BlendTransformedTiled */ static const QRgba64 *QT_FASTCALL fetchTransformed64(QRgba64 *buffer, const Operator *, const QSpanData *data, int y, int x, int length) @@ -2240,6 +2249,7 @@ static const QRgba64 *QT_FASTCALL fetchTransformed64(QRgba64 *buffer, const Oper convertRGBA64ToRGBA64PM(buffer, length); return buffer; } +#endif /** \internal interpolate 4 argb pixels with the distx and disty factor. @@ -3541,6 +3551,7 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper return buffer; } +#if QT_CONFIG(raster_64bit) template static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64_uint32(QRgba64 *buffer, const QSpanData *data, int y, int x, int length) @@ -3861,6 +3872,7 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co return fetchTransformedBilinear64_uint64(buffer, data, y, x, length); return fetchTransformedBilinear64_uint32(buffer, data, y, x, length); } +#endif // FetchUntransformed can have more specialized methods added depending on SIMD features. static SourceFetchProc sourceFetchUntransformed[QImage::NImageFormats] = { @@ -3931,6 +3943,20 @@ static SourceFetchProc sourceFetchAny32[NBlendTypes] = { fetchTransformedBilinear // TransformedBilinearTiled }; +static inline SourceFetchProc getSourceFetch(TextureBlendType blendType, QImage::Format format) +{ + if (format == QImage::Format_RGB32 || format == QImage::Format_ARGB32_Premultiplied) + return sourceFetchARGB32PM[blendType]; + if (blendType == BlendUntransformed || blendType == BlendTiled) + return sourceFetchUntransformed[format]; + if (qPixelLayouts[format].bpp == QPixelLayout::BPP16) + return sourceFetchAny16[blendType]; + if (qPixelLayouts[format].bpp == QPixelLayout::BPP32) + return sourceFetchAny32[blendType]; + return sourceFetchGeneric[blendType]; +} + +#if QT_CONFIG(raster_64bit) static const SourceFetchProc64 sourceFetchGeneric64[NBlendTypes] = { fetchUntransformed64, // Untransformed fetchUntransformed64, // Tiled @@ -3949,25 +3975,13 @@ static const SourceFetchProc64 sourceFetchRGBA64PM[NBlendTypes] = { fetchTransformedBilinear64 // BilinearTiled }; -static inline SourceFetchProc getSourceFetch(TextureBlendType blendType, QImage::Format format) -{ - if (format == QImage::Format_RGB32 || format == QImage::Format_ARGB32_Premultiplied) - return sourceFetchARGB32PM[blendType]; - if (blendType == BlendUntransformed || blendType == BlendTiled) - return sourceFetchUntransformed[format]; - if (qPixelLayouts[format].bpp == QPixelLayout::BPP16) - return sourceFetchAny16[blendType]; - if (qPixelLayouts[format].bpp == QPixelLayout::BPP32) - return sourceFetchAny32[blendType]; - return sourceFetchGeneric[blendType]; -} - static inline SourceFetchProc64 getSourceFetch64(TextureBlendType blendType, QImage::Format format) { if (format == QImage::Format_RGBX64 || format == QImage::Format_RGBA64_Premultiplied) return sourceFetchRGBA64PM[blendType]; return sourceFetchGeneric64[blendType]; } +#endif #define FIXPT_BITS 8 @@ -3979,11 +3993,13 @@ static uint qt_gradient_pixel_fixed(const QGradientData *data, int fixed_pos) return data->colorTable32[qt_gradient_clamp(data, ipos)]; } +#if QT_CONFIG(raster_64bit) static const QRgba64& qt_gradient_pixel64_fixed(const QGradientData *data, int fixed_pos) { int ipos = (fixed_pos + (FIXPT_SIZE / 2)) >> FIXPT_BITS; return data->colorTable64[qt_gradient_clamp(data, ipos)]; } +#endif static void QT_FASTCALL getLinearGradientValues(LinearGradientValues *v, const QSpanData *data) { @@ -4017,6 +4033,7 @@ public: } }; +#if QT_CONFIG(raster_64bit) class GradientBase64 { public: @@ -4035,6 +4052,7 @@ public: qt_memfill64((quint64*)buffer, fill, length); } }; +#endif template static inline const BlendType * QT_FASTCALL qt_fetch_linear_gradient_template( @@ -4112,11 +4130,13 @@ static const uint * QT_FASTCALL qt_fetch_linear_gradient(uint *buffer, const Ope return qt_fetch_linear_gradient_template(buffer, op, data, y, x, length); } +#if QT_CONFIG(raster_64bit) static const QRgba64 * QT_FASTCALL qt_fetch_linear_gradient_rgb64(QRgba64 *buffer, const Operator *op, const QSpanData *data, int y, int x, int length) { return qt_fetch_linear_gradient_template(buffer, op, data, y, x, length); } +#endif static void QT_FASTCALL getRadialGradientValues(RadialGradientValues *v, const QSpanData *data) { @@ -4178,11 +4198,13 @@ const uint * QT_FASTCALL qt_fetch_radial_gradient_plain(uint *buffer, const Oper static SourceFetchProc qt_fetch_radial_gradient = qt_fetch_radial_gradient_plain; +#if QT_CONFIG(raster_64bit) const QRgba64 * QT_FASTCALL qt_fetch_radial_gradient_rgb64(QRgba64 *buffer, const Operator *op, const QSpanData *data, int y, int x, int length) { return qt_fetch_radial_gradient_template, QRgba64>(buffer, op, data, y, x, length); } +#endif template static inline const BlendType * QT_FASTCALL qt_fetch_conical_gradient_template( @@ -4241,23 +4263,29 @@ static const uint * QT_FASTCALL qt_fetch_conical_gradient(uint *buffer, const Op return qt_fetch_conical_gradient_template(buffer, data, y, x, length); } +#if QT_CONFIG(raster_64bit) static const QRgba64 * QT_FASTCALL qt_fetch_conical_gradient_rgb64(QRgba64 *buffer, const Operator *, const QSpanData *data, int y, int x, int length) { return qt_fetch_conical_gradient_template(buffer, data, y, x, length); } +#endif extern CompositionFunctionSolid qt_functionForModeSolid_C[]; extern CompositionFunctionSolid64 qt_functionForModeSolid64_C[]; static const CompositionFunctionSolid *functionForModeSolid = qt_functionForModeSolid_C; +#if QT_CONFIG(raster_64bit) static const CompositionFunctionSolid64 *functionForModeSolid64 = qt_functionForModeSolid64_C; +#endif extern CompositionFunction qt_functionForMode_C[]; extern CompositionFunction64 qt_functionForMode64_C[]; static const CompositionFunction *functionForMode = qt_functionForMode_C; +#if QT_CONFIG(raster_64bit) static const CompositionFunction64 *functionForMode64 = qt_functionForMode64_C; +#endif static TextureBlendType getBlendType(const QSpanData *data) { @@ -4289,41 +4317,58 @@ static inline Operator getOperator(const QSpanData *data, const QSpan *spans, in case QSpanData::Solid: solidSource = data->solidColor.isOpaque(); op.srcFetch = 0; +#if QT_CONFIG(raster_64bit) op.srcFetch64 = 0; +#endif break; case QSpanData::LinearGradient: solidSource = !data->gradient.alphaColor; getLinearGradientValues(&op.linear, data); op.srcFetch = qt_fetch_linear_gradient; +#if QT_CONFIG(raster_64bit) op.srcFetch64 = qt_fetch_linear_gradient_rgb64; +#endif break; case QSpanData::RadialGradient: solidSource = !data->gradient.alphaColor; getRadialGradientValues(&op.radial, data); op.srcFetch = qt_fetch_radial_gradient; +#if QT_CONFIG(raster_64bit) op.srcFetch64 = qt_fetch_radial_gradient_rgb64; +#endif break; case QSpanData::ConicalGradient: solidSource = !data->gradient.alphaColor; op.srcFetch = qt_fetch_conical_gradient; +#if QT_CONFIG(raster_64bit) op.srcFetch64 = qt_fetch_conical_gradient_rgb64; +#endif break; case QSpanData::Texture: solidSource = !data->texture.hasAlpha; op.srcFetch = getSourceFetch(getBlendType(data), data->texture.format); +#if QT_CONFIG(raster_64bit) op.srcFetch64 = getSourceFetch64(getBlendType(data), data->texture.format);; +#endif break; default: Q_UNREACHABLE(); break; } +#if !QT_CONFIG(raster_64bit) + op.srcFetch64 = 0; +#endif op.mode = data->rasterBuffer->compositionMode; if (op.mode == QPainter::CompositionMode_SourceOver && solidSource) op.mode = QPainter::CompositionMode_Source; op.destFetch = destFetchProc[data->rasterBuffer->format]; +#if QT_CONFIG(raster_64bit) op.destFetch64 = destFetchProc64[data->rasterBuffer->format]; +#else + op.destFetch64 = 0; +#endif if (op.mode == QPainter::CompositionMode_Source && (data->type != QSpanData::Texture || data->texture.const_alpha == 256)) { const QSpan *lastSpan = spans + spanCount; @@ -4340,18 +4385,25 @@ static inline Operator getOperator(const QSpanData *data, const QSpan *spans, in // But don't clear passthrough destFetch as they are just as fast and save destStore. if (op.destFetch != destFetchARGB32P) op.destFetch = destFetchUndefined; +#if QT_CONFIG(raster_64bit) if (op.destFetch64 != destFetchRGB64) op.destFetch64 = destFetch64Undefined; +#endif } } op.destStore = destStoreProc[data->rasterBuffer->format]; - op.destStore64 = destStoreProc64[data->rasterBuffer->format]; - op.funcSolid = functionForModeSolid[op.mode]; - op.funcSolid64 = functionForModeSolid64[op.mode]; op.func = functionForMode[op.mode]; +#if QT_CONFIG(raster_64bit) + op.destStore64 = destStoreProc64[data->rasterBuffer->format]; + op.funcSolid64 = functionForModeSolid64[op.mode]; op.func64 = functionForMode64[op.mode]; +#else + op.destStore64 = 0; + op.funcSolid64 = 0; + op.func64 = 0; +#endif return op; } @@ -4458,6 +4510,7 @@ static void blend_color_argb(int count, const QSpan *spans, void *userData) void blend_color_generic_rgb64(int count, const QSpan *spans, void *userData) { +#if QT_CONFIG(raster_64bit) QSpanData *data = reinterpret_cast(userData); Operator op = getOperator(data, nullptr, 0); if (!op.funcSolid64) { @@ -4492,6 +4545,9 @@ void blend_color_generic_rgb64(int count, const QSpan *spans, void *userData) } ++spans; } +#else + blend_color_generic(count, spans, userData); +#endif } static void blend_color_rgb16(int count, const QSpan *spans, void *userData) @@ -4665,6 +4721,7 @@ public: } }; +#if QT_CONFIG(raster_64bit) class BlendSrcGenericRGB64 : public QBlendBase { public: @@ -4695,6 +4752,7 @@ public: op.destStore64(data->rasterBuffer, x, y, dest, len); } }; +#endif static void blend_src_generic(int count, const QSpan *spans, void *userData) { @@ -4703,6 +4761,7 @@ static void blend_src_generic(int count, const QSpan *spans, void *userData) handleSpans(count, spans, data, blend); } +#if QT_CONFIG(raster_64bit) static void blend_src_generic_rgb64(int count, const QSpan *spans, void *userData) { QSpanData *data = reinterpret_cast(userData); @@ -4716,6 +4775,7 @@ static void blend_src_generic_rgb64(int count, const QSpan *spans, void *userDat handleSpans(count, spans, data, blend32); } } +#endif static void blend_untransformed_generic(int count, const QSpan *spans, void *userData) { @@ -4762,6 +4822,7 @@ static void blend_untransformed_generic(int count, const QSpan *spans, void *use } } +#if QT_CONFIG(raster_64bit) static void blend_untransformed_generic_rgb64(int count, const QSpan *spans, void *userData) { QSpanData *data = reinterpret_cast(userData); @@ -4810,6 +4871,7 @@ static void blend_untransformed_generic_rgb64(int count, const QSpan *spans, voi ++spans; } } +#endif static void blend_untransformed_argb(int count, const QSpan *spans, void *userData) { @@ -5004,6 +5066,7 @@ static void blend_tiled_generic(int count, const QSpan *spans, void *userData) } } +#if QT_CONFIG(raster_64bit) static void blend_tiled_generic_rgb64(int count, const QSpan *spans, void *userData) { QSpanData *data = reinterpret_cast(userData); @@ -5099,6 +5162,7 @@ static void blend_tiled_generic_rgb64(int count, const QSpan *spans, void *userD ++spans; } } +#endif static void blend_tiled_argb(int count, const QSpan *spans, void *userData) { @@ -5275,6 +5339,7 @@ static const ProcessSpans processTextureSpansGeneric[NBlendTypes] = { blend_src_generic // TransformedBilinearTiled }; +#if QT_CONFIG(raster_64bit) static const ProcessSpans processTextureSpansGeneric64[NBlendTypes] = { blend_untransformed_generic_rgb64, // Untransformed blend_tiled_generic_rgb64, // Tiled @@ -5283,6 +5348,7 @@ static const ProcessSpans processTextureSpansGeneric64[NBlendTypes] = { blend_src_generic_rgb64, // TransformedBilinear blend_src_generic_rgb64 // TransformedBilinearTiled }; +#endif void qBlendTexture(int count, const QSpan *spans, void *userData) { @@ -5296,6 +5362,7 @@ void qBlendTexture(int count, const QSpan *spans, void *userData) case QImage::Format_RGB16: proc = processTextureSpansRGB16[blendType]; break; +#if QT_CONFIG(raster_64bit) #if defined(__SSE2__) || defined(__ARM_NEON__) || (Q_PROCESSOR_WORDSIZE == 8) case QImage::Format_ARGB32: case QImage::Format_RGBA8888: @@ -5310,6 +5377,7 @@ void qBlendTexture(int count, const QSpan *spans, void *userData) case QImage::Format_Grayscale16: proc = processTextureSpansGeneric64[blendType]; break; +#endif // QT_CONFIG(raster_64bit) case QImage::Format_Invalid: Q_UNREACHABLE(); return; @@ -5377,7 +5445,11 @@ static void blend_vertical_gradient(int count, const QSpan *spans, void *userDat while (count--) { int y = spans->y; +#if QT_CONFIG(raster_64bit) data->solidColor = qt_gradient_pixel64_fixed(&data->gradient, yinc * y + off); +#else + data->solidColor = QRgba64::fromArgb32(qt_gradient_pixel_fixed(&data->gradient, yinc * y + off)); +#endif blend_color(1, spans, userData); ++spans; } @@ -5400,6 +5472,7 @@ void qBlendGradient(int count, const QSpan *spans, void *userData) if (isVerticalGradient) return blend_vertical_gradient_argb(count, spans, userData); return blend_src_generic(count, spans, userData); +#if QT_CONFIG(raster_64bit) #if defined(__SSE2__) || defined(__ARM_NEON__) || (Q_PROCESSOR_WORDSIZE == 8) case QImage::Format_ARGB32: case QImage::Format_RGBA8888: @@ -5414,6 +5487,7 @@ void qBlendGradient(int count, const QSpan *spans, void *userData) if (isVerticalGradient) return blend_vertical_gradient(count, spans, userData); return blend_src_generic_rgb64(count, spans, userData); +#endif // QT_CONFIG(raster_64bit) case QImage::Format_Invalid: break; default: @@ -5523,6 +5597,35 @@ inline static void qt_bitmapblit_quint16(QRasterBuffer *rasterBuffer, map, mapWidth, mapHeight, mapStride); } +static inline void grayBlendPixel(quint32 *dst, int coverage, QRgba64 srcLinear, const QColorTrcLut *colorProfile) +{ + // Do a gammacorrected gray alphablend... + const QRgba64 dstLinear = colorProfile ? colorProfile->toLinear64(*dst) : QRgba64::fromArgb32(*dst); + + QRgba64 blend = interpolate255(srcLinear, coverage, dstLinear, 255 - coverage); + + *dst = colorProfile ? colorProfile->fromLinear64(blend) : toArgb32(blend); +} + +static inline void alphamapblend_argb32(quint32 *dst, int coverage, QRgba64 srcLinear, quint32 src, const QColorTrcLut *colorProfile) +{ + if (coverage == 0) { + // nothing + } else if (coverage == 255) { + *dst = src; + } else if (!colorProfile) { + *dst = INTERPOLATE_PIXEL_255(src, coverage, *dst, 255 - coverage); + } else { + if (*dst >= 0xff000000) { + grayBlendPixel(dst, coverage, srcLinear, colorProfile); + } else { + // Give up and do a naive gray alphablend. Needed to deal with ARGB32 and invalid ARGB32_premultiplied, see QTBUG-60571 + *dst = INTERPOLATE_PIXEL_255(src, coverage, *dst, 255 - coverage); + } + } +} + +#if QT_CONFIG(raster_64bit) static inline void alphamapblend_generic(int coverage, QRgba64 *dest, int x, const QRgba64 &srcLinear, const QRgba64 &src, const QColorTrcLut *colorProfile) { if (coverage == 0) { @@ -5624,6 +5727,85 @@ static void qt_alphamapblit_generic(QRasterBuffer *rasterBuffer, } // for (yp -> bottom) } } +#else +static void qt_alphamapblit_generic(QRasterBuffer *rasterBuffer, + int x, int y, const QRgba64 &color, + const uchar *map, + int mapWidth, int mapHeight, int mapStride, + const QClipData *clip, bool useGammaCorrection) +{ + if (color.isTransparent()) + return; + + const quint32 c = color.toArgb32(); + + const QColorTrcLut *colorProfile = nullptr; + + if (useGammaCorrection) + colorProfile = QGuiApplicationPrivate::instance()->colorProfileForA8Text(); + + QRgba64 srcColor = color; + if (colorProfile) { + if (color.isOpaque()) + srcColor = colorProfile->toLinear(srcColor); + else + srcColor = colorProfile->toLinear(srcColor.unpremultiplied()).premultiplied(); + } + + quint32 buffer[BufferSize]; + const DestFetchProc destFetch = destFetchProc[rasterBuffer->format]; + const DestStoreProc destStore = destStoreProc[rasterBuffer->format]; + + if (!clip) { + for (int ly = 0; ly < mapHeight; ++ly) { + int i = x; + int length = mapWidth; + while (length > 0) { + int l = qMin(BufferSize, length); + quint32 *dest = destFetch(buffer, rasterBuffer, i, y + ly, l); + for (int j=0; j < l; ++j) { + const int coverage = map[j + (i - x)]; + alphamapblend_argb32(dest + j, coverage, srcColor, c, colorProfile); + } + if (destStore) + destStore(rasterBuffer, i, y + ly, dest, l); + length -= l; + i += l; + } + map += mapStride; + } + } else { + int bottom = qMin(y + mapHeight, rasterBuffer->height()); + + int top = qMax(y, 0); + map += (top - y) * mapStride; + + const_cast(clip)->initialize(); + for (int yp = top; ypm_clipLines[yp]; + + for (int i=0; i(x, clip.x); + int end = qMin(x + mapWidth, clip.x + clip.len); + if (end <= start) + continue; + Q_ASSERT(end - start <= BufferSize); + quint32 *dest = destFetch(buffer, rasterBuffer, start, clip.y, end - start); + + for (int xp=start; xp line.count) + map += mapStride; + } // for (yp -> bottom) + } +} +#endif static inline void alphamapblend_quint16(int coverage, quint16 *dest, int x, const quint16 srcColor) { @@ -5684,44 +5866,6 @@ void qt_alphamapblit_quint16(QRasterBuffer *rasterBuffer, } } -static inline void rgbBlendPixel(quint32 *dst, int coverage, QRgba64 slinear, const QColorTrcLut *colorProfile) -{ - // Do a gammacorrected RGB alphablend... - const QRgba64 dlinear = colorProfile ? colorProfile->toLinear64(*dst) : QRgba64::fromArgb32(*dst); - - QRgba64 blend = rgbBlend(dlinear, slinear, coverage); - - *dst = colorProfile ? colorProfile->fromLinear64(blend) : toArgb32(blend); -} - -static inline void grayBlendPixel(quint32 *dst, int coverage, QRgba64 srcLinear, const QColorTrcLut *colorProfile) -{ - // Do a gammacorrected gray alphablend... - const QRgba64 dstLinear = colorProfile ? colorProfile->toLinear64(*dst) : QRgba64::fromArgb32(*dst); - - QRgba64 blend = interpolate255(srcLinear, coverage, dstLinear, 255 - coverage); - - *dst = colorProfile ? colorProfile->fromLinear64(blend) : toArgb32(blend); -} - -static inline void alphamapblend_argb32(quint32 *dst, int coverage, QRgba64 srcLinear, quint32 src, const QColorTrcLut *colorProfile) -{ - if (coverage == 0) { - // nothing - } else if (coverage == 255) { - *dst = src; - } else if (!colorProfile) { - *dst = INTERPOLATE_PIXEL_255(src, coverage, *dst, 255 - coverage); - } else { - if (*dst >= 0xff000000) { - grayBlendPixel(dst, coverage, srcLinear, colorProfile); - } else { - // Give up and do a naive gray alphablend. Needed to deal with ARGB32 and invalid ARGB32_premultiplied, see QTBUG-60571 - *dst = INTERPOLATE_PIXEL_255(src, coverage, *dst, 255 - coverage); - } - } -} - static void qt_alphamapblit_argb32(QRasterBuffer *rasterBuffer, int x, int y, const QRgba64 &color, const uchar *map, @@ -5790,6 +5934,16 @@ static inline int qRgbAvg(QRgb rgb) return (qRed(rgb) * 5 + qGreen(rgb) * 6 + qBlue(rgb) * 5) / 16; } +static inline void rgbBlendPixel(quint32 *dst, int coverage, QRgba64 slinear, const QColorTrcLut *colorProfile) +{ + // Do a gammacorrected RGB alphablend... + const QRgba64 dlinear = colorProfile ? colorProfile->toLinear64(*dst) : QRgba64::fromArgb32(*dst); + + QRgba64 blend = rgbBlend(dlinear, slinear, coverage); + + *dst = colorProfile ? colorProfile->fromLinear64(blend) : toArgb32(blend); +} + static inline QRgb rgbBlend(QRgb d, QRgb s, uint rgbAlpha) { #if defined(__SSE2__) @@ -5830,6 +5984,7 @@ static inline QRgb rgbBlend(QRgb d, QRgb s, uint rgbAlpha) #endif } +#if QT_CONFIG(raster_64bit) static inline void alphargbblend_generic(uint coverage, QRgba64 *dest, int x, const QRgba64 &srcLinear, const QRgba64 &src, const QColorTrcLut *colorProfile) { if (coverage == 0xff000000) { @@ -5851,6 +6006,7 @@ static inline void alphargbblend_generic(uint coverage, QRgba64 *dest, int x, co } } } +#endif static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba64 &srcLinear, quint32 src, const QColorTrcLut *colorProfile) { @@ -5869,6 +6025,7 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba } } +#if QT_CONFIG(raster_64bit) static void qt_alphargbblit_generic(QRasterBuffer *rasterBuffer, int x, int y, const QRgba64 &color, const uint *src, int mapWidth, int mapHeight, int srcStride, @@ -5943,6 +6100,84 @@ static void qt_alphargbblit_generic(QRasterBuffer *rasterBuffer, } // for (yp -> bottom) } } +#else +static void qt_alphargbblit_generic(QRasterBuffer *rasterBuffer, + int x, int y, const QRgba64 &color, + const uint *src, int mapWidth, int mapHeight, int srcStride, + const QClipData *clip, bool useGammaCorrection) +{ + if (color.isTransparent()) + return; + + const quint32 c = color.toArgb32(); + + const QColorTrcLut *colorProfile = nullptr; + + if (useGammaCorrection) + colorProfile = QGuiApplicationPrivate::instance()->colorProfileForA32Text(); + + QRgba64 srcColor = color; + if (colorProfile) { + if (color.isOpaque()) + srcColor = colorProfile->toLinear(srcColor); + else + srcColor = colorProfile->toLinear(srcColor.unpremultiplied()).premultiplied(); + } + + quint32 buffer[BufferSize]; + const DestFetchProc destFetch = destFetchProc[rasterBuffer->format]; + const DestStoreProc destStore = destStoreProc[rasterBuffer->format]; + + if (!clip) { + for (int ly = 0; ly < mapHeight; ++ly) { + int i = x; + int length = mapWidth; + while (length > 0) { + int l = qMin(BufferSize, length); + quint32 *dest = destFetch(buffer, rasterBuffer, i, y + ly, l); + for (int j=0; j < l; ++j) { + const uint coverage = src[j + (i - x)]; + alphargbblend_argb32(dest + j, coverage, srcColor, c, colorProfile); + } + if (destStore) + destStore(rasterBuffer, i, y + ly, dest, l); + length -= l; + i += l; + } + src += srcStride; + } + } else { + int bottom = qMin(y + mapHeight, rasterBuffer->height()); + + int top = qMax(y, 0); + src += (top - y) * srcStride; + + const_cast(clip)->initialize(); + for (int yp = top; ypm_clipLines[yp]; + + for (int i=0; i(x, clip.x); + int end = qMin(x + mapWidth, clip.x + clip.len); + if (end <= start) + continue; + Q_ASSERT(end - start <= BufferSize); + quint32 *dest = destFetch(buffer, rasterBuffer, start, clip.y, end - start); + + for (int xp=start; xp line.count) + src += srcStride; + } // for (yp -> bottom) + } +} +#endif static void qt_alphargbblit_argb32(QRasterBuffer *rasterBuffer, int x, int y, const QRgba64 &color, @@ -6533,8 +6768,10 @@ static void qInitDrawhelperFunctions() qPixelLayouts[QImage::Format_A2RGB30_Premultiplied].storeFromARGB32PM = storeA2RGB30PMFromARGB32PM_sse4; qStoreFromRGBA64PM[QImage::Format_ARGB32] = storeARGB32FromRGBA64PM_sse4; qStoreFromRGBA64PM[QImage::Format_RGBA8888] = storeRGBA8888FromRGBA64PM_sse4; +#if QT_CONFIG(raster_64bit) destStoreProc64[QImage::Format_ARGB32] = destStore64ARGB32_sse4; destStoreProc64[QImage::Format_RGBA8888] = destStore64RGBA8888_sse4; +#endif } #endif @@ -6558,18 +6795,19 @@ static void qInitDrawhelperFunctions() qBlendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_avx2; extern void QT_FASTCALL comp_func_Source_avx2(uint *destPixels, const uint *srcPixels, int length, uint const_alpha); - extern void QT_FASTCALL comp_func_Source_rgb64_avx2(QRgba64 *destPixels, const QRgba64 *srcPixels, int length, uint const_alpha); extern void QT_FASTCALL comp_func_SourceOver_avx2(uint *destPixels, const uint *srcPixels, int length, uint const_alpha); - extern void QT_FASTCALL comp_func_SourceOver_rgb64_avx2(QRgba64 *destPixels, const QRgba64 *srcPixels, int length, uint const_alpha); extern void QT_FASTCALL comp_func_solid_SourceOver_avx2(uint *destPixels, int length, uint color, uint const_alpha); - extern void QT_FASTCALL comp_func_solid_SourceOver_rgb64_avx2(QRgba64 *destPixels, int length, QRgba64 color, uint const_alpha); - qt_functionForMode_C[QPainter::CompositionMode_Source] = comp_func_Source_avx2; - qt_functionForMode64_C[QPainter::CompositionMode_Source] = comp_func_Source_rgb64_avx2; qt_functionForMode_C[QPainter::CompositionMode_SourceOver] = comp_func_SourceOver_avx2; - qt_functionForMode64_C[QPainter::CompositionMode_SourceOver] = comp_func_SourceOver_rgb64_avx2; qt_functionForModeSolid_C[QPainter::CompositionMode_SourceOver] = comp_func_solid_SourceOver_avx2; +#if QT_CONFIG(raster_64bit) + extern void QT_FASTCALL comp_func_Source_rgb64_avx2(QRgba64 *destPixels, const QRgba64 *srcPixels, int length, uint const_alpha); + extern void QT_FASTCALL comp_func_SourceOver_rgb64_avx2(QRgba64 *destPixels, const QRgba64 *srcPixels, int length, uint const_alpha); + extern void QT_FASTCALL comp_func_solid_SourceOver_rgb64_avx2(QRgba64 *destPixels, int length, QRgba64 color, uint const_alpha); + qt_functionForMode64_C[QPainter::CompositionMode_Source] = comp_func_Source_rgb64_avx2; + qt_functionForMode64_C[QPainter::CompositionMode_SourceOver] = comp_func_SourceOver_rgb64_avx2; qt_functionForModeSolid64_C[QPainter::CompositionMode_SourceOver] = comp_func_solid_SourceOver_rgb64_avx2; +#endif extern void QT_FASTCALL fetchTransformedBilinearARGB32PM_simple_scale_helper_avx2(uint *b, uint *end, const QTextureData &image, int &fx, int &fy, int fdx, int /*fdy*/); @@ -6593,6 +6831,7 @@ static void qInitDrawhelperFunctions() qPixelLayouts[QImage::Format_RGBA8888].fetchToARGB32PM = fetchRGBA8888ToARGB32PM_avx2; qPixelLayouts[QImage::Format_RGBA8888].convertToARGB32PM = convertRGBA8888ToARGB32PM_avx2; +#if QT_CONFIG(raster_64bit) extern const QRgba64 * QT_FASTCALL convertARGB32ToRGBA64PM_avx2(QRgba64 *, const uint *, int, const QVector *, QDitherInfo *); extern const QRgba64 * QT_FASTCALL convertRGBA8888ToRGBA64PM_avx2(QRgba64 *, const uint *, int count, const QVector *, QDitherInfo *); extern const QRgba64 *QT_FASTCALL fetchARGB32ToRGBA64PM_avx2(QRgba64 *, const uchar *, int, int, const QVector *, QDitherInfo *); @@ -6601,6 +6840,7 @@ static void qInitDrawhelperFunctions() qPixelLayouts[QImage::Format_RGBX8888].convertToRGBA64PM = convertRGBA8888ToRGBA64PM_avx2; qPixelLayouts[QImage::Format_ARGB32].fetchToRGBA64PM = fetchARGB32ToRGBA64PM_avx2; qPixelLayouts[QImage::Format_RGBX8888].fetchToRGBA64PM = fetchRGBA8888ToRGBA64PM_avx2; +#endif } #endif diff --git a/src/gui/painting/qdrawhelper_avx2.cpp b/src/gui/painting/qdrawhelper_avx2.cpp index 2b3cc9b226..fb50cb6a50 100644 --- a/src/gui/painting/qdrawhelper_avx2.cpp +++ b/src/gui/painting/qdrawhelper_avx2.cpp @@ -396,6 +396,7 @@ void QT_FASTCALL comp_func_SourceOver_avx2(uint *destPixels, const uint *srcPixe BLEND_SOURCE_OVER_ARGB32_WITH_CONST_ALPHA_AVX2(dst, src, length, const_alpha); } +#if QT_CONFIG(raster_64bit) void QT_FASTCALL comp_func_SourceOver_rgb64_avx2(QRgba64 *dst, const QRgba64 *src, int length, uint const_alpha) { Q_ASSERT(const_alpha < 256); // const_alpha is in [0-255] @@ -453,6 +454,7 @@ void QT_FASTCALL comp_func_SourceOver_rgb64_avx2(QRgba64 *dst, const QRgba64 *sr blend_pixel(dst[x], src[x], const_alpha); } } +#endif void QT_FASTCALL comp_func_Source_avx2(uint *dst, const uint *src, int length, uint const_alpha) { @@ -485,6 +487,7 @@ void QT_FASTCALL comp_func_Source_avx2(uint *dst, const uint *src, int length, u } } +#if QT_CONFIG(raster_64bit) void QT_FASTCALL comp_func_Source_rgb64_avx2(QRgba64 *dst, const QRgba64 *src, int length, uint const_alpha) { Q_ASSERT(const_alpha < 256); // const_alpha is in [0-255] @@ -517,6 +520,7 @@ void QT_FASTCALL comp_func_Source_rgb64_avx2(QRgba64 *dst, const QRgba64 *src, i dst[x] = interpolate65535(src[x], ca, dst[x], cia); } } +#endif void QT_FASTCALL comp_func_solid_SourceOver_avx2(uint *destPixels, int length, uint color, uint const_alpha) { @@ -549,6 +553,7 @@ void QT_FASTCALL comp_func_solid_SourceOver_avx2(uint *destPixels, int length, u } } +#if QT_CONFIG(raster_64bit) void QT_FASTCALL comp_func_solid_SourceOver_rgb64_avx2(QRgba64 *destPixels, int length, QRgba64 color, uint const_alpha) { Q_ASSERT(const_alpha < 256); // const_alpha is in [0-255] @@ -579,6 +584,7 @@ void QT_FASTCALL comp_func_solid_SourceOver_rgb64_avx2(QRgba64 *destPixels, int destPixels[x] = color + multiplyAlpha65535(destPixels[x], minusAlphaOfColor); } } +#endif #define interpolate_4_pixels_16_avx2(tlr1, tlr2, blr1, blr2, distx, disty, colorMask, v_256, b) \ { \ diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index 1e99a34842..9c5d525722 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -296,7 +296,9 @@ struct QGradientData #define GRADIENT_STOPTABLE_SIZE 1024 #define GRADIENT_STOPTABLE_SIZE_SHIFT 10 +#if QT_CONFIG(raster_64bit) const QRgba64 *colorTable64; //[GRADIENT_STOPTABLE_SIZE]; +#endif const QRgb *colorTable32; //[GRADIENT_STOPTABLE_SIZE]; uint alphaColor : 1; @@ -402,11 +404,13 @@ static inline uint qt_gradient_pixel(const QGradientData *data, qreal pos) return data->colorTable32[qt_gradient_clamp(data, ipos)]; } +#if QT_CONFIG(raster_64bit) static inline const QRgba64& qt_gradient_pixel64(const QGradientData *data, qreal pos) { int ipos = int(pos * (GRADIENT_STOPTABLE_SIZE - 1) + qreal(0.5)); return data->colorTable64[qt_gradient_clamp(data, ipos)]; } +#endif static inline qreal qRadialDeterminant(qreal a, qreal b, qreal c) { diff --git a/src/gui/painting/qdrawhelper_sse4.cpp b/src/gui/painting/qdrawhelper_sse4.cpp index d9a687b1b4..5e8acc332d 100644 --- a/src/gui/painting/qdrawhelper_sse4.cpp +++ b/src/gui/painting/qdrawhelper_sse4.cpp @@ -399,6 +399,7 @@ void QT_FASTCALL storeA2RGB30PMFromARGB32PM_sse4(uchar *dest, const uint *src, i d[i] = qConvertArgb32ToA2rgb30_sse4(src[i]); } +#if QT_CONFIG(raster_64bit) void QT_FASTCALL destStore64ARGB32_sse4(QRasterBuffer *rasterBuffer, int x, int y, const QRgba64 *buffer, int length) { uint *dest = (uint*)rasterBuffer->scanLine(y) + x; @@ -410,6 +411,7 @@ void QT_FASTCALL destStore64RGBA8888_sse4(QRasterBuffer *rasterBuffer, int x, in uint *dest = (uint*)rasterBuffer->scanLine(y) + x; convertARGBFromRGBA64PM_sse4(dest, buffer, length); } +#endif void QT_FASTCALL storeARGB32FromRGBA64PM_sse4(uchar *dest, const QRgba64 *src, int index, int count, const QVector *, QDitherInfo *) diff --git a/src/gui/painting/qimagescale.cpp b/src/gui/painting/qimagescale.cpp index 8a5274bd37..0d7205b483 100644 --- a/src/gui/painting/qimagescale.cpp +++ b/src/gui/painting/qimagescale.cpp @@ -528,6 +528,7 @@ static void qt_qimageScaleAARGBA_down_xy(QImageScaleInfo *isi, unsigned int *des } } +#if QT_CONFIG(raster_64bit) static void qt_qimageScaleRgba64_up_x_down_y(QImageScaleInfo *isi, QRgba64 *dest, int dw, int dh, int dow, int sow); @@ -728,6 +729,7 @@ static void qt_qimageScaleRgba64_down_xy(QImageScaleInfo *isi, QRgba64 *dest, } } } +#endif static void qt_qimageScaleAARGB_up_x_down_y(QImageScaleInfo *isi, unsigned int *dest, int dw, int dh, int dow, int sow); @@ -945,10 +947,13 @@ QImage qSmoothScaleImage(const QImage &src, int dw, int dh) return QImage(); } +#if QT_CONFIG(raster_64bit) if (src.depth() > 32) qt_qimageScaleRgba64(scaleinfo, (QRgba64 *)buffer.scanLine(0), dw, dh, dw, src.bytesPerLine() / 8); - else if (src.hasAlphaChannel()) + else +#endif + if (src.hasAlphaChannel()) qt_qimageScaleAARGBA(scaleinfo, (unsigned int *)buffer.scanLine(0), dw, dh, dw, src.bytesPerLine() / 4); else diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 2c99671d0b..b0dec5cf78 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -4531,7 +4531,9 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode auto cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); gradient.colorTable32 = cacheInfo->buffer32; +#if QT_CONFIG(raster_64bit) gradient.colorTable64 = cacheInfo->buffer64; +#endif cachedGradient = std::move(cacheInfo); gradient.spread = g->spread(); @@ -4553,7 +4555,9 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode auto cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); gradient.colorTable32 = cacheInfo->buffer32; +#if QT_CONFIG(raster_64bit) gradient.colorTable64 = cacheInfo->buffer64; +#endif cachedGradient = std::move(cacheInfo); gradient.spread = g->spread(); @@ -4579,7 +4583,9 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode auto cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); gradient.colorTable32 = cacheInfo->buffer32; +#if QT_CONFIG(raster_64bit) gradient.colorTable64 = cacheInfo->buffer64; +#endif cachedGradient = std::move(cacheInfo); gradient.spread = QGradient::RepeatSpread; diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 50eb61b219..441ec17412 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -1852,7 +1852,9 @@ void tst_QImage::smoothScale4_data() QTest::addColumn("format"); QTest::newRow("RGB32") << QImage::Format_RGB32; +#if QT_CONFIG(raster_64bit) QTest::newRow("RGBx64") << QImage::Format_RGBX64; +#endif } void tst_QImage::smoothScale4() @@ -3412,6 +3414,7 @@ void tst_QImage::ditherGradient_data() QTest::newRow("argb32pm -> argb6666pm (no dither)") << rgb32 << QImage::Format_ARGB6666_Premultiplied << 0 << 64; QTest::newRow("argb32pm -> argb6666pm (dithering)") << rgb32 << QImage::Format_ARGB6666_Premultiplied << int(Qt::PreferDither | Qt::OrderedDither) << 129; +#if QT_CONFIG(raster_64bit) QImage rgb30(1024, 16, QImage::Format_RGB30); QLinearGradient gradient30(QRectF(rgb30.rect()).topLeft(), QRectF(rgb30.rect()).topRight()); gradient30.setColorAt(0.0, QColor(0, 0, 0)); @@ -3424,6 +3427,7 @@ void tst_QImage::ditherGradient_data() QTest::newRow("rgb30 -> rgb32 (dithering)") << rgb30 << QImage::Format_RGB32 << int(Qt::PreferDither | Qt::OrderedDither) << 513; QTest::newRow("rgb30 -> rgb888 (no dither)") << rgb30 << QImage::Format_RGB888 << 0 << 256; QTest::newRow("rgb30 -> rgb888 (dithering)") << rgb30 << QImage::Format_RGB888 << int(Qt::PreferDither | Qt::OrderedDither) << 513; +#endif } void tst_QImage::ditherGradient() diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index bc0baed15c..cec164b8b2 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -185,10 +185,12 @@ private slots: void gradientPixelFormat_data(); void gradientPixelFormat(); +#if QT_CONFIG(raster_64bit) void linearGradientRgb30_data(); void linearGradientRgb30(); void radialGradientRgb30_data(); void radialGradientRgb30(); +#endif void fpe_pixmapTransform(); void fpe_zeroLengthLines(); @@ -3946,6 +3948,7 @@ void tst_QPainter::gradientInterpolation() } } +#if QT_CONFIG(raster_64bit) void tst_QPainter::linearGradientRgb30_data() { QTest::addColumn("stop0"); @@ -4004,6 +4007,7 @@ void tst_QPainter::radialGradientRgb30() QVERIFY(qGray(p1.rgb()) >= qGray(p2.rgb())); } } +#endif void tst_QPainter::drawPolygon() { @@ -4884,14 +4888,18 @@ void tst_QPainter::blendARGBonRGB_data() << QPainter::CompositionMode_SourceOver << qRgba(255, 0, 0, 85) << 85; QTest::newRow("ARGB_PM over RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied << QPainter::CompositionMode_SourceOver << qRgba(85, 0, 0, 85) << 85; +#if QT_CONFIG(raster_64bit) QTest::newRow("ARGB source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32 << QPainter::CompositionMode_Source << qRgba(255, 0, 0, 85) << 85; QTest::newRow("ARGB source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32 << QPainter::CompositionMode_Source << qRgba(255, 0, 0, 120) << 85; +#endif QTest::newRow("ARGB_PM source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied << QPainter::CompositionMode_Source << qRgba(85, 0, 0, 85) << 85; +#if QT_CONFIG(raster_64bit) QTest::newRow("ARGB_PM source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied << QPainter::CompositionMode_Source << qRgba(180, 0, 0, 180) << 170; +#endif QTest::newRow("ARGB source-in RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32 << QPainter::CompositionMode_SourceIn << qRgba(255, 0, 0, 85) << 85; QTest::newRow("ARGB_PM source-in RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied From 434c866e1b76c12b3bf3dcdd76a00f4d29aa64d3 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 9 Apr 2019 15:31:16 +0200 Subject: [PATCH 176/292] QtGui: Use member initialization for QWindowPrivate, QScreenPrivate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the constructors, destructors in favor of member initialization. Change-Id: I323826328fb783ea2cd931c0e6aad45a98a2ebeb Reviewed-by: Morten Johan Sørvig --- src/gui/kernel/qscreen_p.h | 18 +++----- src/gui/kernel/qwindow_p.h | 85 +++++++++++--------------------------- 2 files changed, 31 insertions(+), 72 deletions(-) diff --git a/src/gui/kernel/qscreen_p.h b/src/gui/kernel/qscreen_p.h index 8e81c7bf87..e5988ff829 100644 --- a/src/gui/kernel/qscreen_p.h +++ b/src/gui/kernel/qscreen_p.h @@ -64,12 +64,6 @@ class QScreenPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QScreen) public: - QScreenPrivate() - : platformScreen(nullptr) - , orientationUpdateMask(nullptr) - { - } - void setPlatformScreen(QPlatformScreen *screen); void updateHighDpi() { @@ -79,16 +73,16 @@ public: void updatePrimaryOrientation(); - QPlatformScreen *platformScreen; + QPlatformScreen *platformScreen = nullptr; Qt::ScreenOrientations orientationUpdateMask; - Qt::ScreenOrientation orientation; - Qt::ScreenOrientation filteredOrientation; - Qt::ScreenOrientation primaryOrientation; + Qt::ScreenOrientation orientation = Qt::PrimaryOrientation; + Qt::ScreenOrientation filteredOrientation = Qt::PrimaryOrientation; + Qt::ScreenOrientation primaryOrientation = Qt::LandscapeOrientation; QRect geometry; QRect availableGeometry; - QDpi logicalDpi; - qreal refreshRate; + QDpi logicalDpi = {96, 96}; + qreal refreshRate = 60; }; QT_END_NAMESPACE diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h index cc1cc24525..d918ed5b52 100644 --- a/src/gui/kernel/qwindow_p.h +++ b/src/gui/kernel/qwindow_p.h @@ -77,45 +77,10 @@ public: QWindowPrivate() : QObjectPrivate() - , surfaceType(QWindow::RasterSurface) - , windowFlags(Qt::Window) - , parentWindow(nullptr) - , platformWindow(nullptr) - , visible(false) - , visibilityOnDestroy(false) - , exposed(false) - , windowState(Qt::WindowNoState) - , visibility(QWindow::Hidden) - , resizeEventPending(true) - , receivedExpose(false) - , positionPolicy(WindowFrameExclusive) - , positionAutomatic(true) - , resizeAutomatic(true) - , contentOrientation(Qt::PrimaryOrientation) - , opacity(qreal(1.0)) - , minimumSize(0, 0) - , maximumSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX) - , modality(Qt::NonModal) - , blockedByModalWindow(false) - , updateRequestPending(false) - , transientParent(nullptr) - , topLevelScreen(nullptr) -#ifndef QT_NO_CURSOR - , cursor(Qt::ArrowCursor) - , hasCursor(false) -#endif - , compositing(false) -#if QT_CONFIG(vulkan) - , vulkanInstance(nullptr) -#endif { isWindow = true; } - ~QWindowPrivate() - { - } - void init(QScreen *targetScreen = nullptr); void maybeQuitOnLastWindowClosed(); @@ -166,57 +131,57 @@ public: virtual bool allowClickThrough(const QPoint &) const { return true; } - QWindow::SurfaceType surfaceType; - Qt::WindowFlags windowFlags; - QWindow *parentWindow; - QPlatformWindow *platformWindow; - bool visible; - bool visibilityOnDestroy; - bool exposed; + QWindow::SurfaceType surfaceType = QWindow::RasterSurface; + Qt::WindowFlags windowFlags = Qt::Window; + QWindow *parentWindow = nullptr; + QPlatformWindow *platformWindow = nullptr; + bool visible= false; + bool visibilityOnDestroy = false; + bool exposed = false; QSurfaceFormat requestedFormat; QString windowTitle; QString windowFilePath; QIcon windowIcon; QRect geometry; - Qt::WindowStates windowState; - QWindow::Visibility visibility; - bool resizeEventPending; - bool receivedExpose; - PositionPolicy positionPolicy; - bool positionAutomatic; + Qt::WindowStates windowState = Qt::WindowNoState; + QWindow::Visibility visibility = QWindow::Hidden; + bool resizeEventPending = true; + bool receivedExpose = false; + PositionPolicy positionPolicy = WindowFrameExclusive; + bool positionAutomatic = true; // resizeAutomatic suppresses resizing by QPlatformWindow::initialGeometry(). // It also indicates that width/height=0 is acceptable (for example, for // the QRollEffect widget) and is thus not cleared in setGeometry(). // An alternative approach might be using -1,-1 as a default size. - bool resizeAutomatic; - Qt::ScreenOrientation contentOrientation; - qreal opacity; + bool resizeAutomatic = true; + Qt::ScreenOrientation contentOrientation = Qt::PrimaryOrientation; + qreal opacity= 1; QRegion mask; - QSize minimumSize; - QSize maximumSize; + QSize minimumSize = {0, 0}; + QSize maximumSize = {QWINDOWSIZE_MAX, QWINDOWSIZE_MAX}; QSize baseSize; QSize sizeIncrement; - Qt::WindowModality modality; - bool blockedByModalWindow; + Qt::WindowModality modality = Qt::NonModal; + bool blockedByModalWindow = false; - bool updateRequestPending; + bool updateRequestPending = false; bool transientParentPropertySet = false; QPointer transientParent; QPointer topLevelScreen; #ifndef QT_NO_CURSOR - QCursor cursor; - bool hasCursor; + QCursor cursor = {Qt::ArrowCursor}; + bool hasCursor = false; #endif - bool compositing; + bool compositing = false; QElapsedTimer lastComposeTime; #if QT_CONFIG(vulkan) - QVulkanInstance *vulkanInstance; + QVulkanInstance *vulkanInstance = nullptr; #endif }; From 95f787bfdc890c259e8b347bdad9123d534efe0f Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 9 Apr 2019 13:33:15 +0200 Subject: [PATCH 177/292] Replace Q_DECL_NOTHROW with noexcept the remaining places The first replacement had missed objective-C++ code some places ourside the src dir. In C-files Q_DECL_NOTHROW is replaced with Q_DECL_NOEXCEPT as we still need to turn it off when compiled in C mode, but can get rid of the old NOTHROW moniker. Change-Id: I6370f57066679c5120d0265a69e7e378e09d4759 Reviewed-by: Thiago Macieira --- qmake/library/proitems.h | 6 ++-- src/corelib/global/qfloat16_f16c.c | 4 +-- src/corelib/kernel/qcore_foundation.mm | 18 +++++----- src/corelib/kernel/qcore_mac_objc.mm | 2 +- .../qtconcurrentmap/tst_qtconcurrentmap.cpp | 20 +++++------ .../qtconcurrentrun/tst_qtconcurrentrun.cpp | 16 ++++----- tests/auto/corelib/global/qglobal/qglobal.c | 2 +- .../corelib/kernel/qobject/tst_qobject.cpp | 22 ++++++------ .../auto/corelib/kernel/qtimer/tst_qtimer.cpp | 2 +- .../qxmlstream/tst_qxmlstream.cpp | 2 +- .../testlib/selftests/cmptest/tst_cmptest.cpp | 2 +- .../kernel/qformlayout/tst_qformlayout.cpp | 8 ++--- util/unicode/main.cpp | 36 +++++++++---------- 13 files changed, 70 insertions(+), 70 deletions(-) diff --git a/qmake/library/proitems.h b/qmake/library/proitems.h index 71e5e05367..6882f2802f 100644 --- a/qmake/library/proitems.h +++ b/qmake/library/proitems.h @@ -429,7 +429,7 @@ class ProFunctionDef { public: ProFunctionDef(ProFile *pro, int offset) : m_pro(pro), m_offset(offset) { m_pro->ref(); } ProFunctionDef(const ProFunctionDef &o) : m_pro(o.m_pro), m_offset(o.m_offset) { m_pro->ref(); } - ProFunctionDef(ProFunctionDef &&other) Q_DECL_NOTHROW + ProFunctionDef(ProFunctionDef &&other) noexcept : m_pro(other.m_pro), m_offset(other.m_offset) { other.m_pro = nullptr; } ~ProFunctionDef() { m_pro->deref(); } ProFunctionDef &operator=(const ProFunctionDef &o) @@ -442,13 +442,13 @@ public: } return *this; } - ProFunctionDef &operator=(ProFunctionDef &&other) Q_DECL_NOTHROW + ProFunctionDef &operator=(ProFunctionDef &&other) noexcept { ProFunctionDef moved(std::move(other)); swap(moved); return *this; } - void swap(ProFunctionDef &other) Q_DECL_NOTHROW + void swap(ProFunctionDef &other) noexcept { qSwap(m_pro, other.m_pro); qSwap(m_offset, other.m_offset); diff --git a/src/corelib/global/qfloat16_f16c.c b/src/corelib/global/qfloat16_f16c.c index a7eadc71b7..ba1e16f481 100644 --- a/src/corelib/global/qfloat16_f16c.c +++ b/src/corelib/global/qfloat16_f16c.c @@ -54,7 +54,7 @@ extern "C" { #endif QT_FUNCTION_TARGET(F16C) -void qFloatToFloat16_fast(quint16 *out, const float *in, qsizetype len) Q_DECL_NOTHROW +void qFloatToFloat16_fast(quint16 *out, const float *in, qsizetype len) Q_DECL_NOEXCEPT { qsizetype i = 0; int epilog_i; @@ -70,7 +70,7 @@ void qFloatToFloat16_fast(quint16 *out, const float *in, qsizetype len) Q_DECL_N } QT_FUNCTION_TARGET(F16C) -void qFloatFromFloat16_fast(float *out, const quint16 *in, qsizetype len) Q_DECL_NOTHROW +void qFloatFromFloat16_fast(float *out, const quint16 *in, qsizetype len) Q_DECL_NOEXCEPT { qsizetype i = 0; int epilog_i; diff --git a/src/corelib/kernel/qcore_foundation.mm b/src/corelib/kernel/qcore_foundation.mm index 56eabc4b8c..623d462749 100644 --- a/src/corelib/kernel/qcore_foundation.mm +++ b/src/corelib/kernel/qcore_foundation.mm @@ -501,7 +501,7 @@ NSTimeZone *QTimeZone::toNSTimeZone() const \sa QRectF::fromCGRect() */ -CGRect QRect::toCGRect() const Q_DECL_NOTHROW +CGRect QRect::toCGRect() const noexcept { return CGRectMake(x(), y(), width(), height()); } @@ -513,7 +513,7 @@ CGRect QRect::toCGRect() const Q_DECL_NOTHROW \sa fromCGRect() */ -CGRect QRectF::toCGRect() const Q_DECL_NOTHROW +CGRect QRectF::toCGRect() const noexcept { return CGRectMake(x(), y(), width(), height()); } @@ -525,7 +525,7 @@ CGRect QRectF::toCGRect() const Q_DECL_NOTHROW \sa toCGRect() */ -QRectF QRectF::fromCGRect(CGRect rect) Q_DECL_NOTHROW +QRectF QRectF::fromCGRect(CGRect rect) noexcept { return QRectF(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); } @@ -539,7 +539,7 @@ QRectF QRectF::fromCGRect(CGRect rect) Q_DECL_NOTHROW \sa QPointF::fromCGPoint() */ -CGPoint QPoint::toCGPoint() const Q_DECL_NOTHROW +CGPoint QPoint::toCGPoint() const noexcept { return CGPointMake(x(), y()); } @@ -551,7 +551,7 @@ CGPoint QPoint::toCGPoint() const Q_DECL_NOTHROW \sa fromCGPoint() */ -CGPoint QPointF::toCGPoint() const Q_DECL_NOTHROW +CGPoint QPointF::toCGPoint() const noexcept { return CGPointMake(x(), y()); } @@ -563,7 +563,7 @@ CGPoint QPointF::toCGPoint() const Q_DECL_NOTHROW \sa toCGPoint() */ -QPointF QPointF::fromCGPoint(CGPoint point) Q_DECL_NOTHROW +QPointF QPointF::fromCGPoint(CGPoint point) noexcept { return QPointF(point.x, point.y); } @@ -577,7 +577,7 @@ QPointF QPointF::fromCGPoint(CGPoint point) Q_DECL_NOTHROW \sa QSizeF::fromCGSize() */ -CGSize QSize::toCGSize() const Q_DECL_NOTHROW +CGSize QSize::toCGSize() const noexcept { return CGSizeMake(width(), height()); } @@ -589,7 +589,7 @@ CGSize QSize::toCGSize() const Q_DECL_NOTHROW \sa fromCGSize() */ -CGSize QSizeF::toCGSize() const Q_DECL_NOTHROW +CGSize QSizeF::toCGSize() const noexcept { return CGSizeMake(width(), height()); } @@ -601,7 +601,7 @@ CGSize QSizeF::toCGSize() const Q_DECL_NOTHROW \sa toCGSize() */ -QSizeF QSizeF::fromCGSize(CGSize size) Q_DECL_NOTHROW +QSizeF QSizeF::fromCGSize(CGSize size) noexcept { return QSizeF(size.width, size.height); } diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm index 6687eb88a5..6b51eb65d9 100644 --- a/src/corelib/kernel/qcore_mac_objc.mm +++ b/src/corelib/kernel/qcore_mac_objc.mm @@ -371,7 +371,7 @@ bool operator<(const KeyPair &entry, const Qt::Key &key) struct qtKey2CocoaKeySortLessThan { typedef bool result_type; - Q_DECL_CONSTEXPR result_type operator()(const KeyPair &entry1, const KeyPair &entry2) const Q_DECL_NOTHROW + Q_DECL_CONSTEXPR result_type operator()(const KeyPair &entry1, const KeyPair &entry2) const noexcept { return entry1.qtKey < entry2.qtKey; } diff --git a/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp b/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp index 9b71994b84..b5486307a7 100644 --- a/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp +++ b/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp @@ -2021,12 +2021,12 @@ int fn(int &i) return i; } -int fnConstNoExcept(const int &i) Q_DECL_NOTHROW +int fnConstNoExcept(const int &i) noexcept { return i; } -int fnNoExcept(int &i) Q_DECL_NOTHROW +int fnNoExcept(int &i) noexcept { return i; } @@ -2041,12 +2041,12 @@ QString changeType(int &) return QString(); } -QString changeTypeConstNoExcept(const int &) Q_DECL_NOTHROW +QString changeTypeConstNoExcept(const int &) noexcept { return QString(); } -QString changeTypeNoExcept(int &) Q_DECL_NOTHROW +QString changeTypeNoExcept(int &) noexcept { return QString(); } @@ -2061,12 +2061,12 @@ int changeTypeQStringList(QStringList &) return 0; } -int changeTypeQStringListConstNoExcept(const QStringList &) Q_DECL_NOTHROW +int changeTypeQStringListConstNoExcept(const QStringList &) noexcept { return 0; } -int changeTypeQStringListNoExcept(QStringList &) Q_DECL_NOTHROW +int changeTypeQStringListNoExcept(QStringList &) noexcept { return 0; } @@ -2096,22 +2096,22 @@ public: return QString(); } - MemFnTester fnNoExcept() Q_DECL_NOTHROW + MemFnTester fnNoExcept() noexcept { return MemFnTester(); } - MemFnTester fnConstNoExcept() const Q_DECL_NOTHROW + MemFnTester fnConstNoExcept() const noexcept { return MemFnTester(); } - QString changeTypeNoExcept() Q_DECL_NOTHROW + QString changeTypeNoExcept() noexcept { return QString(); } - QString changeTypeConstNoExcept() const Q_DECL_NOTHROW + QString changeTypeConstNoExcept() const noexcept { return QString(); } diff --git a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp index 9b5bb85fff..8506d18dae 100644 --- a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp +++ b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp @@ -122,23 +122,23 @@ public: class ANoExcept { public: - int member0() Q_DECL_NOTHROW { return 10; } - int member1(int in) Q_DECL_NOTHROW { return in; } + int member0() noexcept { return 10; } + int member1(int in) noexcept { return in; } typedef int result_type; - int operator()() Q_DECL_NOTHROW { return 10; } - int operator()(int in) Q_DECL_NOTHROW { return in; } + int operator()() noexcept { return 10; } + int operator()(int in) noexcept { return in; } }; class AConstNoExcept { public: - int member0() const Q_DECL_NOTHROW { return 10; } - int member1(int in) const Q_DECL_NOTHROW { return in; } + int member0() const noexcept { return 10; } + int member1(int in) const noexcept { return in; } typedef int result_type; - int operator()() const Q_DECL_NOTHROW { return 10; } - int operator()(int in) const Q_DECL_NOTHROW { return in; } + int operator()() const noexcept { return 10; } + int operator()(int in) const noexcept { return in; } }; void tst_QtConcurrentRun::returnValue() diff --git a/tests/auto/corelib/global/qglobal/qglobal.c b/tests/auto/corelib/global/qglobal/qglobal.c index 0719c4b921..c7124454d0 100644 --- a/tests/auto/corelib/global/qglobal/qglobal.c +++ b/tests/auto/corelib/global/qglobal/qglobal.c @@ -85,7 +85,7 @@ int tst_QtVersion() return QT_VERSION; } -const char *tst_qVersion() Q_DECL_NOTHROW +const char *tst_qVersion() Q_DECL_NOEXCEPT { #if !defined(QT_NAMESPACE) return qVersion(); diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index 4a27b5bffe..e0394a5d25 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -4794,13 +4794,13 @@ class LotsOfSignalsAndSlots: public QObject public slots: void slot_v() {} - void slot_v_noexcept() Q_DECL_NOTHROW {} + void slot_v_noexcept() noexcept {} void slot_vi(int) {} - void slot_vi_noexcept() Q_DECL_NOTHROW {} + void slot_vi_noexcept() noexcept {} void slot_vii(int, int) {} void slot_viii(int, int, int) {} int slot_i() { return 0; } - int slot_i_noexcept() Q_DECL_NOTHROW { return 0; } + int slot_i_noexcept() noexcept { return 0; } int slot_ii(int) { return 0; } int slot_iii(int, int) { return 0; } int slot_iiii(int, int, int) { return 0; } @@ -4814,18 +4814,18 @@ class LotsOfSignalsAndSlots: public QObject void slot_vPFvvE(fptr) {} void const_slot_v() const {}; - void const_slot_v_noexcept() const Q_DECL_NOTHROW {} + void const_slot_v_noexcept() const noexcept {} void const_slot_vi(int) const {}; - void const_slot_vi_noexcept(int) const Q_DECL_NOTHROW {} + void const_slot_vi_noexcept(int) const noexcept {} static void static_slot_v() {} - static void static_slot_v_noexcept() Q_DECL_NOTHROW {} + static void static_slot_v_noexcept() noexcept {} static void static_slot_vi(int) {} - static void static_slot_vi_noexcept(int) Q_DECL_NOTHROW {} + static void static_slot_vi_noexcept(int) noexcept {} static void static_slot_vii(int, int) {} static void static_slot_viii(int, int, int) {} static int static_slot_i() { return 0; } - static int static_slot_i_noexcept() Q_DECL_NOTHROW { return 0; } + static int static_slot_i_noexcept() noexcept { return 0; } static int static_slot_ii(int) { return 0; } static int static_slot_iii(int, int) { return 0; } static int static_slot_iiii(int, int, int) { return 0; } @@ -4988,11 +4988,11 @@ void tst_QObject::connectCxx0xTypeMatching() } -void receiverFunction_noexcept() Q_DECL_NOTHROW {} -struct Functor_noexcept { void operator()() Q_DECL_NOTHROW {} }; +void receiverFunction_noexcept() noexcept {} +struct Functor_noexcept { void operator()() noexcept {} }; void tst_QObject::connectCxx17Noexcept() { - // this is about connecting signals to slots with the Q_DECL_NOTHROW qualifier + // this is about connecting signals to slots with the noexcept qualifier // as semantics changed due to http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0012r1.html typedef LotsOfSignalsAndSlots Foo; Foo obj; diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp index d06059bbe5..b7c87418c7 100644 --- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp +++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp @@ -773,7 +773,7 @@ public: quitEventLoop_noexcept(); } - static void quitEventLoop_noexcept() Q_DECL_NOTHROW + static void quitEventLoop_noexcept() noexcept { QVERIFY(!_e.isNull()); _e->quit(); diff --git a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp index 8fdf91b090..e4d50607b7 100644 --- a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp +++ b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp @@ -253,7 +253,7 @@ public: qFatal("%s: aId must not be an empty string", Q_FUNC_INFO); } - void swap(MissedBaseline &other) Q_DECL_NOTHROW + void swap(MissedBaseline &other) noexcept { qSwap(id, other.id); qSwap(expected, other.expected); diff --git a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp index 8e2c7694a5..467c53088e 100644 --- a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp +++ b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp @@ -256,7 +256,7 @@ void tst_Cmptest::compare_boolfuncs() namespace { template -T *null() Q_DECL_NOTHROW { return nullptr; } +T *null() noexcept { return nullptr; } } void tst_Cmptest::compare_to_nullptr() diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp index cff3dad35e..ab32643061 100644 --- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp +++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp @@ -52,7 +52,7 @@ using namespace QTestPrivate; Q_CONSTEXPR QFormLayout::ItemRole invalidRole = QFormLayout::ItemRole(3); struct QFormLayoutTakeRowResultHolder { - QFormLayoutTakeRowResultHolder(QFormLayout::TakeRowResult result) Q_DECL_NOTHROW + QFormLayoutTakeRowResultHolder(QFormLayout::TakeRowResult result) noexcept : labelItem(result.labelItem), fieldItem(result.fieldItem) { @@ -66,20 +66,20 @@ struct QFormLayoutTakeRowResultHolder { if (fieldItem) disposer.setItem(0, QFormLayout::FieldRole, fieldItem); } - QFormLayoutTakeRowResultHolder(QFormLayoutTakeRowResultHolder &&other) Q_DECL_NOTHROW + QFormLayoutTakeRowResultHolder(QFormLayoutTakeRowResultHolder &&other) noexcept : labelItem(other.labelItem), fieldItem(other.fieldItem) { other.labelItem = nullptr; other.fieldItem = nullptr; } - QFormLayoutTakeRowResultHolder &operator=(QFormLayoutTakeRowResultHolder &&other) Q_DECL_NOTHROW + QFormLayoutTakeRowResultHolder &operator=(QFormLayoutTakeRowResultHolder &&other) noexcept { swap(other); return *this; } - void swap(QFormLayoutTakeRowResultHolder &other) Q_DECL_NOTHROW + void swap(QFormLayoutTakeRowResultHolder &other) noexcept { qSwap(labelItem, other.labelItem); qSwap(fieldItem, other.fieldItem); diff --git a/util/unicode/main.cpp b/util/unicode/main.cpp index 22a4405ca9..8576f00e35 100644 --- a/util/unicode/main.cpp +++ b/util/unicode/main.cpp @@ -818,8 +818,8 @@ static const char *property_string = " ushort lineBreakClass : 6; /* 6 used */\n" " ushort script : 8;\n" "};\n\n" - "Q_CORE_EXPORT const Properties * QT_FASTCALL properties(uint ucs4) Q_DECL_NOTHROW;\n" - "Q_CORE_EXPORT const Properties * QT_FASTCALL properties(ushort ucs2) Q_DECL_NOTHROW;\n" + "Q_CORE_EXPORT const Properties * QT_FASTCALL properties(uint ucs4) noexcept;\n" + "Q_CORE_EXPORT const Properties * QT_FASTCALL properties(ushort ucs2) noexcept;\n" "\n" "struct LowercaseTraits\n" "{\n" @@ -855,20 +855,20 @@ static const char *property_string = "\n"; static const char *methods = - "Q_CORE_EXPORT GraphemeBreakClass QT_FASTCALL graphemeBreakClass(uint ucs4) Q_DECL_NOTHROW;\n" - "inline GraphemeBreakClass graphemeBreakClass(QChar ch) Q_DECL_NOTHROW\n" + "Q_CORE_EXPORT GraphemeBreakClass QT_FASTCALL graphemeBreakClass(uint ucs4) noexcept;\n" + "inline GraphemeBreakClass graphemeBreakClass(QChar ch) noexcept\n" "{ return graphemeBreakClass(ch.unicode()); }\n" "\n" - "Q_CORE_EXPORT WordBreakClass QT_FASTCALL wordBreakClass(uint ucs4) Q_DECL_NOTHROW;\n" - "inline WordBreakClass wordBreakClass(QChar ch) Q_DECL_NOTHROW\n" + "Q_CORE_EXPORT WordBreakClass QT_FASTCALL wordBreakClass(uint ucs4) noexcept;\n" + "inline WordBreakClass wordBreakClass(QChar ch) noexcept\n" "{ return wordBreakClass(ch.unicode()); }\n" "\n" - "Q_CORE_EXPORT SentenceBreakClass QT_FASTCALL sentenceBreakClass(uint ucs4) Q_DECL_NOTHROW;\n" - "inline SentenceBreakClass sentenceBreakClass(QChar ch) Q_DECL_NOTHROW\n" + "Q_CORE_EXPORT SentenceBreakClass QT_FASTCALL sentenceBreakClass(uint ucs4) noexcept;\n" + "inline SentenceBreakClass sentenceBreakClass(QChar ch) noexcept\n" "{ return sentenceBreakClass(ch.unicode()); }\n" "\n" - "Q_CORE_EXPORT LineBreakClass QT_FASTCALL lineBreakClass(uint ucs4) Q_DECL_NOTHROW;\n" - "inline LineBreakClass lineBreakClass(QChar ch) Q_DECL_NOTHROW\n" + "Q_CORE_EXPORT LineBreakClass QT_FASTCALL lineBreakClass(uint ucs4) noexcept;\n" + "inline LineBreakClass lineBreakClass(QChar ch) noexcept\n" "{ return lineBreakClass(ch.unicode()); }\n" "\n"; @@ -2521,42 +2521,42 @@ static QByteArray createPropertyInfo() out += "\n};\n\n"; - out += "Q_DECL_CONST_FUNCTION static inline const Properties *qGetProp(uint ucs4) Q_DECL_NOTHROW\n" + out += "Q_DECL_CONST_FUNCTION static inline const Properties *qGetProp(uint ucs4) noexcept\n" "{\n" " return uc_properties + GET_PROP_INDEX(ucs4);\n" "}\n" "\n" - "Q_DECL_CONST_FUNCTION static inline const Properties *qGetProp(ushort ucs2) Q_DECL_NOTHROW\n" + "Q_DECL_CONST_FUNCTION static inline const Properties *qGetProp(ushort ucs2) noexcept\n" "{\n" " return uc_properties + GET_PROP_INDEX_UCS2(ucs2);\n" "}\n" "\n" - "Q_DECL_CONST_FUNCTION Q_CORE_EXPORT const Properties * QT_FASTCALL properties(uint ucs4) Q_DECL_NOTHROW\n" + "Q_DECL_CONST_FUNCTION Q_CORE_EXPORT const Properties * QT_FASTCALL properties(uint ucs4) noexcept\n" "{\n" " return qGetProp(ucs4);\n" "}\n" "\n" - "Q_DECL_CONST_FUNCTION Q_CORE_EXPORT const Properties * QT_FASTCALL properties(ushort ucs2) Q_DECL_NOTHROW\n" + "Q_DECL_CONST_FUNCTION Q_CORE_EXPORT const Properties * QT_FASTCALL properties(ushort ucs2) noexcept\n" "{\n" " return qGetProp(ucs2);\n" "}\n\n"; - out += "Q_CORE_EXPORT GraphemeBreakClass QT_FASTCALL graphemeBreakClass(uint ucs4) Q_DECL_NOTHROW\n" + out += "Q_CORE_EXPORT GraphemeBreakClass QT_FASTCALL graphemeBreakClass(uint ucs4) noexcept\n" "{\n" " return static_cast(qGetProp(ucs4)->graphemeBreakClass);\n" "}\n" "\n" - "Q_CORE_EXPORT WordBreakClass QT_FASTCALL wordBreakClass(uint ucs4) Q_DECL_NOTHROW\n" + "Q_CORE_EXPORT WordBreakClass QT_FASTCALL wordBreakClass(uint ucs4) noexcept\n" "{\n" " return static_cast(qGetProp(ucs4)->wordBreakClass);\n" "}\n" "\n" - "Q_CORE_EXPORT SentenceBreakClass QT_FASTCALL sentenceBreakClass(uint ucs4) Q_DECL_NOTHROW\n" + "Q_CORE_EXPORT SentenceBreakClass QT_FASTCALL sentenceBreakClass(uint ucs4) noexcept\n" "{\n" " return static_cast(qGetProp(ucs4)->sentenceBreakClass);\n" "}\n" "\n" - "Q_CORE_EXPORT LineBreakClass QT_FASTCALL lineBreakClass(uint ucs4) Q_DECL_NOTHROW\n" + "Q_CORE_EXPORT LineBreakClass QT_FASTCALL lineBreakClass(uint ucs4) noexcept\n" "{\n" " return static_cast(qGetProp(ucs4)->lineBreakClass);\n" "}\n" From 235ac95520a0fc2c822dedce7358e3c64a764255 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 2 Oct 2018 17:25:17 +0200 Subject: [PATCH 178/292] Improve the default selection of locale for QCollator QCollator was using the default-constructed QLocale() as its default; this locale's default was the system locale; however, that didn't pay any attention to system settings for collation such as Unix's environment variable LC_COLLATE or the MS-Win LOCALE_SSORTLOCALE configuration option. Teach the system locale back-ends to look up their relevant settings, add QLocale::collation() as a channel via which to access that and change no-parameter construction of QCollator to a separate implementation (rather than the constructor taking QLocale having a default) using it. [ChangeLog][QtCore][QLocale] The system locale now knows what to use for collation, QLocale::system().collation(). [ChangeLog][QtCore][QCollator] The default QCollator now uses the system's collation locale, rather than the system locale itself. Fixes: QTBUG-58621 Change-Id: I90f86621541385330315d1f9d6a4b982bdcea9d5 Reviewed-by: Thiago Macieira --- src/corelib/tools/qcollator.cpp | 16 +++++++++++++--- src/corelib/tools/qcollator.h | 3 ++- src/corelib/tools/qlocale.cpp | 23 +++++++++++++++++++++++ src/corelib/tools/qlocale.h | 2 +- src/corelib/tools/qlocale_p.h | 1 + src/corelib/tools/qlocale_unix.cpp | 8 +++++++- src/corelib/tools/qlocale_win.cpp | 8 ++++++++ 7 files changed, 55 insertions(+), 6 deletions(-) diff --git a/src/corelib/tools/qcollator.cpp b/src/corelib/tools/qcollator.cpp index d73eb0d07c..6e85027462 100644 --- a/src/corelib/tools/qcollator.cpp +++ b/src/corelib/tools/qcollator.cpp @@ -46,7 +46,6 @@ QT_BEGIN_NAMESPACE - /*! \class QCollator \inmodule QtCore @@ -71,9 +70,20 @@ QT_BEGIN_NAMESPACE */ /*! - Constructs a QCollator for \a locale. + \since 5.13 - If \a locale is not specified, the system's default locale is used. + Constructs a QCollator using the system's default collation locale. + + \sa setLocale(), QLocale::collation() +*/ +QCollator::QCollator() + : d(new QCollatorPrivate(QLocale::system().collation())) +{ + d->init(); +} + +/*! + Constructs a QCollator from \a locale. \sa setLocale() */ diff --git a/src/corelib/tools/qcollator.h b/src/corelib/tools/qcollator.h index 96a5902526..6bb5038371 100644 --- a/src/corelib/tools/qcollator.h +++ b/src/corelib/tools/qcollator.h @@ -81,7 +81,8 @@ inline bool operator<(const QCollatorSortKey &lhs, const QCollatorSortKey &rhs) class Q_CORE_EXPORT QCollator { public: - explicit QCollator(const QLocale &locale = QLocale()); + QCollator(); + explicit QCollator(const QLocale &locale); QCollator(const QCollator &); ~QCollator(); QCollator &operator=(const QCollator &); diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 9a3929c4a7..9f414b1b72 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -4131,6 +4131,29 @@ QStringList QLocale::uiLanguages() const return uiLanguages; } +/*! + \since 5.13 + + Returns the locale to use for collation. + + The result is usually this locale; however, the system locale (which is + commonly the default locale) will return the system collation locale. + The result is suitable for passing to QCollator's constructor. + + \sa QCollator +*/ +QLocale QLocale::collation() const +{ +#ifndef QT_NO_SYSTEMLOCALE + if (d->m_data == systemData()) { + QString res = systemLocale()->query(QSystemLocale::Collation, QVariant()).toString(); + if (!res.isEmpty()) + return QLocale(res); + } +#endif + return *this; +} + /*! \since 4.8 diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h index cb462db770..3dc5ee0a01 100644 --- a/src/corelib/tools/qlocale.h +++ b/src/corelib/tools/qlocale.h @@ -1048,7 +1048,7 @@ public: QString pmText() const; MeasurementSystem measurementSystem() const; - + QLocale collation() const; Qt::LayoutDirection textDirection() const; QString toUpper(const QString &str) const; diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index de973d5eac..16ded7650c 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -113,6 +113,7 @@ public: Weekdays, // QList CurrencySymbol, // QString in: CurrencyToStringArgument CurrencyToString, // QString in: qlonglong, qulonglong or double + Collation, // QString UILanguages, // QStringList StringToStandardQuotation, // QString in: QStringRef to quote StringToAlternateQuotation, // QString in: QStringRef to quote diff --git a/src/corelib/tools/qlocale_unix.cpp b/src/corelib/tools/qlocale_unix.cpp index f202082213..ff4274d932 100644 --- a/src/corelib/tools/qlocale_unix.cpp +++ b/src/corelib/tools/qlocale_unix.cpp @@ -69,6 +69,7 @@ struct QSystemLocaleData QLocale lc_messages; QByteArray lc_messages_var; QByteArray lc_measurement_var; + QByteArray lc_collate_var; QStringList uiLanguages; }; @@ -82,6 +83,7 @@ void QSystemLocaleData::readEnvironment() QByteArray monetary = all.isEmpty() ? qgetenv("LC_MONETARY") : all; lc_messages_var = all.isEmpty() ? qgetenv("LC_MESSAGES") : all; lc_measurement_var = all.isEmpty() ? qgetenv("LC_MEASUREMENT") : all; + lc_collate_var = all.isEmpty() ? qgetenv("LC_COLLATE") : all; QByteArray lang = qgetenv("LANG"); if (lang.isEmpty()) lang = QByteArray("C"); @@ -95,6 +97,8 @@ void QSystemLocaleData::readEnvironment() lc_messages_var = lang; if (lc_measurement_var.isEmpty()) lc_measurement_var = lang; + if (lc_collate_var.isEmpty()) + lc_collate_var = lang; lc_numeric = QLocale(QString::fromLatin1(numeric)); lc_time = QLocale(QString::fromLatin1(time)); lc_monetary = QLocale(QString::fromLatin1(monetary)); @@ -247,13 +251,15 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const return QString(); } case MeasurementSystem: { - const QString meas_locale = QString::fromLatin1(d->lc_measurement_var.constData(), d->lc_measurement_var.size()); + const QString meas_locale = QString::fromLatin1(d->lc_measurement_var); if (meas_locale.compare(QLatin1String("Metric"), Qt::CaseInsensitive) == 0) return QLocale::MetricSystem; if (meas_locale.compare(QLatin1String("Other"), Qt::CaseInsensitive) == 0) return QLocale::MetricSystem; return QVariant((int)QLocale(meas_locale).measurementSystem()); } + case Collation: + return QString::fromLatin1(d->lc_collate_var); case UILanguages: { if (!d->uiLanguages.isEmpty()) return d->uiLanguages; diff --git a/src/corelib/tools/qlocale_win.cpp b/src/corelib/tools/qlocale_win.cpp index ebc4430046..dc904ad02d 100644 --- a/src/corelib/tools/qlocale_win.cpp +++ b/src/corelib/tools/qlocale_win.cpp @@ -120,6 +120,7 @@ struct QSystemLocalePrivate QVariant toString(const QTime &, QLocale::FormatType); QVariant toString(const QDateTime &, QLocale::FormatType); QVariant measurementSystem(); + QVariant collation(); QVariant amText(); QVariant pmText(); QVariant firstDayOfWeek(); @@ -455,6 +456,11 @@ QVariant QSystemLocalePrivate::measurementSystem() return QLocale::MetricSystem; } +QVariant QSystemLocalePrivate::collation() +{ + return getLocaleInfo(LOCALE_SSORTLOCALE); +} + QVariant QSystemLocalePrivate::amText() { wchar_t output[15]; // maximum length including terminating zero character for Win2003+ @@ -808,6 +814,8 @@ QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const return QVariant(QLocale::AnyScript); case MeasurementSystem: return d->measurementSystem(); + case Collation: + return d->collation(); case AMText: return d->amText(); case PMText: From 217f3d83d74507e40ee5a6f43b026bb440515d6e Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Wed, 6 Jun 2018 17:12:45 +0200 Subject: [PATCH 179/292] tst_QWidget: Skip based on capabilities instead of platform == wayland Skip based on support for window activation instead of platform. Makes it clear why the tests are skipped, and also enables them automatically if we implement a shell extension that adds support for it. Task-number: QTBUG-66849 Change-Id: I322aba5ce5f8db651db7b71f223ffacec037c920 Reviewed-by: Richard Moe Gustavsen --- .../widgets/kernel/qwidget/tst_qwidget.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 0ac8ccdbe7..9e30f17fa9 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -2418,8 +2418,8 @@ void tst_QWidget::showMinimizedKeepsFocus() { if (m_platform == QStringLiteral("xcb")) QSKIP("QTBUG-26424"); - if (m_platform == QStringLiteral("wayland")) - QSKIP("Wayland: This fails. Figure out why."); + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QSKIP("Window activation is not supported."); if (m_platform == QStringLiteral("offscreen")) QSKIP("Platform offscreen does not support showMinimized()"); @@ -2625,8 +2625,8 @@ void tst_QWidget::icon() void tst_QWidget::hideWhenFocusWidgetIsChild() { - if (m_platform == QStringLiteral("wayland")) - QSKIP("Wayland: This fails. Figure out why."); + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QSKIP("Window activation is not supported."); QScopedPointer testWidget(new QWidget); testWidget->setWindowTitle(__FUNCTION__); @@ -5433,8 +5433,8 @@ void tst_QWidget::multipleToplevelFocusCheck() QSKIP("QTBUG-52974"); #endif - if (m_platform == QStringLiteral("wayland")) - QSKIP("Wayland: This fails. Figure out why."); + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QSKIP("Window activation is not supported"); else if (m_platform == QStringLiteral("winrt")) QSKIP("Winrt: Sometimes crashes in QTextLayout. - QTBUG-68297"); TopLevelFocusCheck w1; @@ -9535,8 +9535,8 @@ void tst_QWidget::setGraphicsEffect() void tst_QWidget::activateWindow() { - if (m_platform == QStringLiteral("wayland")) - QSKIP("Wayland: This fails. Figure out why."); + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QSKIP("Window activation is not supported."); // Test case for QTBUG-26711 @@ -9603,8 +9603,8 @@ void tst_QWidget::openModal_taskQTBUG_5804() void tst_QWidget::focusProxyAndInputMethods() { - if (m_platform == QStringLiteral("wayland")) - QSKIP("Wayland: This fails. Figure out why."); + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QSKIP("Window activation is not supported."); QScopedPointer toplevel(new QWidget(0, Qt::X11BypassWindowManagerHint)); toplevel->resize(200, 200); toplevel->setAttribute(Qt::WA_InputMethodEnabled, true); From e7e557cea2f35031cf3a51fcb8fa7a275625830f Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 29 Mar 2019 16:05:25 +0100 Subject: [PATCH 180/292] moc: Add a standard way of specifying a URI as part of Q_PLUGIN_METADATA Usually, when you load a plugin, you don't want to load just any plugin that fulfills a given interface, but rather a specific one. When loading dynamic plugins you can differentiate the plugins by file name. This doesn't work in the static case, and file names are also separate from the plugin metadata shipped inside the plugin files. To solve this problem, different hacks have been developed in various places. QML extension plugins add a special property "uri" via the -M option of moc, QML debug plugins expect you to add a json file with an array of "Keys", Qt Creator plugins have a "Name" in their json files, etc. By allowing the identifier for the plugin to be specified inline with the metadata declaration we can make many of the above workarounds obsolete and provide a clean way for users to find their plugins. Task-number: QTBUG-74775 Change-Id: Ie2af16c49d4c5aa5a77fab0fae1e0a4449bd7a39 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/plugin/qplugin_p.h | 6 ++++-- src/tools/moc/generator.cpp | 6 ++++++ src/tools/moc/moc.cpp | 4 ++++ src/tools/moc/moc.h | 1 + .../auto/corelib/plugin/qpluginloader/staticplugin/main.cpp | 2 +- .../auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp | 1 + 6 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/corelib/plugin/qplugin_p.h b/src/corelib/plugin/qplugin_p.h index 717129268b..ce45ebf700 100644 --- a/src/corelib/plugin/qplugin_p.h +++ b/src/corelib/plugin/qplugin_p.h @@ -60,7 +60,8 @@ enum class QtPluginMetaDataKeys { Requirements, IID, ClassName, - MetaData + MetaData, + URI }; // F(IntKey, StringKey, Description) @@ -68,7 +69,8 @@ enum class QtPluginMetaDataKeys { #define QT_PLUGIN_FOREACH_METADATA(F) \ F(QtPluginMetaDataKeys::IID, "IID", "Plugin's Interface ID") \ F(QtPluginMetaDataKeys::ClassName, "className", "Plugin class name") \ - F(QtPluginMetaDataKeys::MetaData, "MetaData", "Other meta data") + F(QtPluginMetaDataKeys::MetaData, "MetaData", "Other meta data") \ + F(QtPluginMetaDataKeys::URI, "URI", "Plugin URI") QT_END_NAMESPACE diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 02c1fbd394..ab7e400f47 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -1652,6 +1652,12 @@ void Generator::generatePluginMetaData() jsonObjectToCbor(&map, o); } + if (!cdef->pluginData.uri.isEmpty()) { + dev.nextItem("\"URI\""); + cbor_encode_int(&map, int(QtPluginMetaDataKeys::URI)); + cbor_encode_text_string(&map, cdef->pluginData.uri.constData(), cdef->pluginData.uri.size()); + } + // Add -M args from the command line: for (auto it = cdef->pluginData.metaArgs.cbegin(), end = cdef->pluginData.metaArgs.cend(); it != end; ++it) { const QJsonArray &a = it.value(); diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 2f52dd6ca0..7f43917f7e 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -1311,6 +1311,9 @@ void Moc::parsePluginData(ClassDef *def) if (l == "IID") { next(STRING_LITERAL); def->pluginData.iid = unquotedLexem(); + } else if (l == "URI") { + next(STRING_LITERAL); + def->pluginData.uri = unquotedLexem(); } else if (l == "FILE") { next(STRING_LITERAL); QByteArray metaDataFile = unquotedLexem(); @@ -1351,6 +1354,7 @@ void Moc::parsePluginData(ClassDef *def) + " does not contain a valid JSON object. Declaration will be ignored"; warning(msg.constData()); def->pluginData.iid = QByteArray(); + def->pluginData.uri = QByteArray(); return; } } diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h index 2bba8a5bb9..bb1c9501fe 100644 --- a/src/tools/moc/moc.h +++ b/src/tools/moc/moc.h @@ -167,6 +167,7 @@ struct ClassDef : BaseDef { struct PluginData { QByteArray iid; + QByteArray uri; QMap metaArgs; QJsonDocument metaData; } pluginData; diff --git a/tests/auto/corelib/plugin/qpluginloader/staticplugin/main.cpp b/tests/auto/corelib/plugin/qpluginloader/staticplugin/main.cpp index d891839b1e..6d163ea336 100644 --- a/tests/auto/corelib/plugin/qpluginloader/staticplugin/main.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/staticplugin/main.cpp @@ -31,7 +31,7 @@ class StaticPlugin : public QObject { Q_OBJECT - Q_PLUGIN_METADATA(IID "SomeIID") + Q_PLUGIN_METADATA(IID "SomeIID" URI "qt.test.pluginloader.staticplugin") public: StaticPlugin() {} }; diff --git a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp index 4316ea14ea..b06000d9c4 100644 --- a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp @@ -552,6 +552,7 @@ void tst_QPluginLoader::staticPlugins() QCOMPARE(metaData.value("version").toInt(), QT_VERSION); QCOMPARE(metaData.value("IID").toString(), "SomeIID"); QCOMPARE(metaData.value("ExtraMetaData"), QJsonArray({ "StaticPlugin", "foo" })); + QCOMPARE(metaData.value("URI").toString(), "qt.test.pluginloader.staticplugin"); } From d63a76af8c9bec213d6968627f6985b1267b409e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 9 Jan 2019 14:59:21 +0100 Subject: [PATCH 181/292] uic: Refactor WriteInitialization::writeIconProperties() and add Python Unfold the function with returns to reduce nesting and add language handling. Task-number: PYSIDE-797 Change-Id: Ie6c47745b118d75c0bb2c9eea7d52c8f0377f1a6 Reviewed-by: Cristian Maureira-Fredes --- src/tools/uic/cpp/cppwriteinitialization.cpp | 107 +++++++++++-------- 1 file changed, 64 insertions(+), 43 deletions(-) diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 6ff7323b3d..8aea864be5 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -1760,55 +1760,76 @@ QString WriteInitialization::writeIconProperties(const DomResourceIcon *i) // check cache const IconHandle iconHandle(i); const IconPropertiesNameMap::const_iterator it = m_iconPropertiesNameMap.constFind(iconHandle); - if (it != m_iconPropertiesNameMap.constEnd()) { + if (it != m_iconPropertiesNameMap.constEnd()) return it.value(); - } // insert with new name const QString iconName = m_driver->unique(QLatin1String("icon")); m_iconPropertiesNameMap.insert(IconHandle(i), iconName); - if (isIconFormat44(i)) { - if (i->attributeTheme().isEmpty()) { - // No theme: Write resource icon as is - m_output << m_indent << "QIcon " << iconName << ";\n"; - if (m_uic->pixmapFunction().isEmpty()) - writeResourceIcon(m_output, iconName, m_indent, i); - else - writePixmapFunctionIcon(m_output, iconName, m_indent, i); - } else { - // Theme: Generate code to check the theme and default to resource - if (iconHasStatePixmaps(i)) { - // Theme + default state pixmaps: - // Generate code to check the theme and default to state pixmaps - m_output << m_indent << "QIcon " << iconName << ";\n"; - const char themeNameStringVariableC[] = "iconThemeName"; - // Store theme name in a variable - m_output << m_indent; - if (m_firstThemeIcon) { // Declare variable string - m_output << "QString "; - m_firstThemeIcon = false; - } - m_output << themeNameStringVariableC << " = " - << language::qstring(i->attributeTheme()) << ";\n"; - m_output << m_indent << "if (QIcon::hasThemeIcon(" - << themeNameStringVariableC - << ")) {\n" - << m_dindent << iconName << " = QIcon::fromTheme(" << themeNameStringVariableC << ");\n" - << m_indent << "} else {\n"; - if (m_uic->pixmapFunction().isEmpty()) - writeResourceIcon(m_output, iconName, m_dindent, i); - else - writePixmapFunctionIcon(m_output, iconName, m_dindent, i); - m_output << m_indent << "}\n"; - } else { - // Theme, but no state pixmaps: Construct from theme directly. - m_output << m_indent << "QIcon " << iconName << "(QIcon::fromTheme(" - << language::qstring(i->attributeTheme()) << "));\n"; - } // Theme, but not state - } // >= 4.4 - } else { // pre-4.4 legacy - m_output << m_indent << "const QIcon " << iconName << " = " << pixCall(QLatin1String("QIcon"), i->text())<< ";\n"; + + const bool isCpp = language::language() == Language::Cpp; + + if (Q_UNLIKELY(!isIconFormat44(i))) { // pre-4.4 legacy + m_output << m_indent; + if (isCpp) + m_output << "const QIcon "; + m_output << iconName << " = " << pixCall(QLatin1String("QIcon"), i->text()) + << language::eol; + return iconName; } + + // 4.4 onwards + if (i->attributeTheme().isEmpty()) { + // No theme: Write resource icon as is + m_output << m_indent << language::stackVariable("QIcon", iconName) + << language::eol; + if (m_uic->pixmapFunction().isEmpty()) + writeResourceIcon(m_output, iconName, m_indent, i); + else + writePixmapFunctionIcon(m_output, iconName, m_indent, i); + return iconName; + } + + // Theme: Generate code to check the theme and default to resource + if (iconHasStatePixmaps(i)) { + // Theme + default state pixmaps: + // Generate code to check the theme and default to state pixmaps + m_output << m_indent << language::stackVariable("QIcon", iconName) << ";\n"; + const char themeNameStringVariableC[] = "iconThemeName"; + // Store theme name in a variable + m_output << m_indent; + if (m_firstThemeIcon) { // Declare variable string + if (isCpp) + m_output << "QString "; + m_firstThemeIcon = false; + } + m_output << themeNameStringVariableC << " = " + << language::qstring(i->attributeTheme()) << language::eol; + m_output << m_indent << "if "; + if (isCpp) + m_output << '('; + m_output << "QIcon" << language::qualifier << "hasThemeIcon(" + << themeNameStringVariableC << ')' << (isCpp ? ") {" : ":") << '\n' + << m_dindent << iconName << " = QIcon" << language::qualifier << "fromTheme(" + << themeNameStringVariableC << ')' << language::eol + << m_indent << (isCpp ? "} else {" : "else:") << '\n'; + if (m_uic->pixmapFunction().isEmpty()) + writeResourceIcon(m_output, iconName, m_dindent, i); + else + writePixmapFunctionIcon(m_output, iconName, m_dindent, i); + m_output << m_indent; + if (isCpp) + m_output << '}'; + m_output << '\n'; + return iconName; + } + + // Theme, but no state pixmaps: Construct from theme directly. + m_output << m_indent + << language::stackVariableWithInitParameters("QIcon", iconName) + << "QIcon" << language::qualifier << "fromTheme(" + << language::qstring(i->attributeTheme()) << "))" + << language::eol; return iconName; } From 6dca11e1af05ddd06439709a210ec225c41276c4 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 10 Jan 2019 10:28:31 +0100 Subject: [PATCH 182/292] uic: Port WriteInitialization::writeBrush() be able to generate Python Task-number: PYSIDE-797 Change-Id: I7c4e204a5ac9be2dee8f06c38323a15a0372fe5c Reviewed-by: Cristian Maureira-Fredes --- src/tools/uic/cpp/cppwriteinitialization.cpp | 46 ++++++++++++-------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 8aea864be5..afd0376643 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -1931,31 +1931,36 @@ void WriteInitialization::writeBrush(const DomBrush *brush, const QString &brush const QString gradientType = gradient->attributeType(); const QString gradientName = m_driver->unique(QLatin1String("gradient")); if (gradientType == QLatin1String("LinearGradient")) { - m_output << m_indent << "QLinearGradient " << gradientName - << '(' << gradient->attributeStartX() + m_output << m_indent + << language::stackVariableWithInitParameters("QLinearGradient", gradientName) + << gradient->attributeStartX() << ", " << gradient->attributeStartY() << ", " << gradient->attributeEndX() - << ", " << gradient->attributeEndY() << ");\n"; + << ", " << gradient->attributeEndY() << ')' << language::eol; } else if (gradientType == QLatin1String("RadialGradient")) { - m_output << m_indent << "QRadialGradient " << gradientName - << '(' << gradient->attributeCentralX() + m_output << m_indent + << language::stackVariableWithInitParameters("QRadialGradient", gradientName) + << gradient->attributeCentralX() << ", " << gradient->attributeCentralY() << ", " << gradient->attributeRadius() << ", " << gradient->attributeFocalX() - << ", " << gradient->attributeFocalY() << ");\n"; + << ", " << gradient->attributeFocalY() << ')' << language::eol; } else if (gradientType == QLatin1String("ConicalGradient")) { - m_output << m_indent << "QConicalGradient " << gradientName - << '(' << gradient->attributeCentralX() + m_output << m_indent + << language::stackVariableWithInitParameters("QConicalGradient", gradientName) + << gradient->attributeCentralX() << ", " << gradient->attributeCentralY() - << ", " << gradient->attributeAngle() << ");\n"; + << ", " << gradient->attributeAngle() << ')' << language::eol; } - m_output << m_indent << gradientName << ".setSpread(QGradient::" - << gradient->attributeSpread() << ");\n"; + m_output << m_indent << gradientName << ".setSpread(QGradient" + << language::qualifier << gradient->attributeSpread() + << ')' << language::eol; if (gradient->hasAttributeCoordinateMode()) { - m_output << m_indent << gradientName << ".setCoordinateMode(QGradient::" - << gradient->attributeCoordinateMode() << ");\n"; + m_output << m_indent << gradientName << ".setCoordinateMode(QGradient" + << language::qualifier << gradient->attributeCoordinateMode() + << ')' << language::eol; } const auto &stops = gradient->elementGradientStop(); @@ -1963,19 +1968,22 @@ void WriteInitialization::writeBrush(const DomBrush *brush, const QString &brush const DomColor *color = stop->elementColor(); m_output << m_indent << gradientName << ".setColorAt(" << stop->attributePosition() << ", " - << domColor2QString(color) << ");\n"; + << domColor2QString(color) << ')' << language::eol; } - m_output << m_indent << "QBrush " << brushName << '(' - << gradientName << ");\n"; + m_output << m_indent + << language::stackVariableWithInitParameters("QBrush", brushName) + << gradientName << ')' << language::eol; } else if (style == QLatin1String("TexturePattern")) { const DomProperty *property = brush->elementTexture(); const QString iconValue = iconCall(property); - m_output << m_indent << "QBrush " << brushName << " = QBrush(" - << iconValue << ");\n"; + m_output << m_indent + << language::stackVariableWithInitParameters("QBrush", brushName) + << iconValue << ')' << language::eol; } else { const DomColor *color = brush->elementColor(); - m_output << m_indent << "QBrush " << brushName << '(' + m_output << m_indent + << language::stackVariableWithInitParameters("QBrush", brushName) << domColor2QString(color) << ')' << language::eol; m_output << m_indent << brushName << ".setStyle(" From 8f44aeb10317664dd7cae92e628fb0814e432e17 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 2 Jul 2018 13:20:39 +0200 Subject: [PATCH 183/292] Add Extended RGB model to QColor Can be used to represent wide-gamut and HDR colors. Change-Id: I1cca442069ce2f2c070f723fe930fe1f2f5580ad Reviewed-by: Lars Knoll --- src/gui/painting/qcolor.cpp | 226 +++++++++++++----- src/gui/painting/qcolor.h | 10 +- src/gui/painting/qcolortransform.cpp | 41 +++- src/gui/painting/qcolortrc_p.h | 21 +- tests/auto/gui/painting/qcolor/tst_qcolor.cpp | 215 ++++++++++------- .../painting/qcolorspace/tst_qcolorspace.cpp | 55 +++++ 6 files changed, 411 insertions(+), 157 deletions(-) diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index bb42660cf2..174350d884 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -39,6 +39,7 @@ #include "qcolor.h" #include "qcolor_p.h" +#include "qfloat16.h" #include "qnamespace.h" #include "qdatastream.h" #include "qvariant.h" @@ -494,6 +495,14 @@ static QStringList get_colornames() with this value, a pixel value will be used that is appropriate for the underlying pixel format in use. + \section1 The Extended RGB Color Model + + The extended RGB color model, also known as the scRGB color space, + is the same the RGB color model except it allows values under 0.0, + and over 1.0. This makes it possible to represent colors that would + otherwise be outside the range of the RGB colorspace but still use + the same values for colors inside the RGB colorspace. + \section1 The HSV Color Model The RGB model is hardware-oriented. Its representation is close to @@ -603,12 +612,13 @@ static QStringList get_colornames() /*! \enum QColor::Spec - The type of color specified, either RGB, HSV, CMYK or HSL. + The type of color specified, either RGB, extended RGB, HSV, CMYK or HSL. \value Rgb \value Hsv \value Cmyk \value Hsl + \value ExtendedRgb \value Invalid \sa spec(), convertTo() @@ -778,6 +788,10 @@ QColor::QColor(Spec spec) noexcept case Hsl: setHsl(0, 0, 0, 0); break; + case ExtendedRgb: + cspec = spec; + setRgbF(0, 0, 0, 0); + break; } } @@ -1211,6 +1225,17 @@ void QColor::setHsl(int h, int s, int l, int a) ct.ahsl.pad = 0; } +static inline qfloat16 &castF16(quint16 &v) +{ + // this works because qfloat16 internally is a quint16 + return *reinterpret_cast(&v); +} + +static inline const qfloat16 &castF16(const quint16 &v) +{ + return *reinterpret_cast(&v); +} + /*! Sets the contents pointed to by \a r, \a g, \a b, and \a a, to the red, green, blue, and alpha-channel (transparency) components of the color's @@ -1226,18 +1251,27 @@ void QColor::getRgbF(qreal *r, qreal *g, qreal *b, qreal *a) const if (!r || !g || !b) return; - if (cspec != Invalid && cspec != Rgb) { + if (cspec == Invalid) + return; + + if (cspec != Rgb && cspec != ExtendedRgb) { toRgb().getRgbF(r, g, b, a); return; } - *r = ct.argb.red / qreal(USHRT_MAX); - *g = ct.argb.green / qreal(USHRT_MAX); - *b = ct.argb.blue / qreal(USHRT_MAX); - - if (a) - *a = ct.argb.alpha / qreal(USHRT_MAX); - + if (cspec == Rgb) { + *r = ct.argb.red / qreal(USHRT_MAX); + *g = ct.argb.green / qreal(USHRT_MAX); + *b = ct.argb.blue / qreal(USHRT_MAX); + if (a) + *a = ct.argb.alpha / qreal(USHRT_MAX); + } else { + *r = castF16(ct.argbExtended.redF16); + *g = castF16(ct.argbExtended.greenF16); + *b = castF16(ct.argbExtended.blueF16); + if (a) + *a = castF16(ct.argbExtended.alphaF16); + } } /*! @@ -1274,26 +1308,35 @@ void QColor::getRgb(int *r, int *g, int *b, int *a) const Sets the color channels of this color to \a r (red), \a g (green), \a b (blue) and \a a (alpha, transparency). - All values must be in the range 0.0-1.0. + The alpha value must be in the range 0.0-1.0. + If any of the other values are outside the range of 0.0-1.0 the + color model will be set as \c ExtendedRgb. \sa rgb(), getRgbF(), setRgb() */ void QColor::setRgbF(qreal r, qreal g, qreal b, qreal a) { - if (r < qreal(0.0) || r > qreal(1.0) - || g < qreal(0.0) || g > qreal(1.0) - || b < qreal(0.0) || b > qreal(1.0) - || a < qreal(0.0) || a > qreal(1.0)) { - qWarning("QColor::setRgbF: RGB parameters out of range"); + if (a < qreal(0.0) || a > qreal(1.0)) { + qWarning("QColor::setRgbF: Alpha parameter is out of range"); invalidate(); return; } - + if (r < qreal(0.0) || r > qreal(1.0) || + g < qreal(0.0) || g > qreal(1.0) || + b < qreal(0.0) || b > qreal(1.0) || cspec == ExtendedRgb) { + cspec = ExtendedRgb; + castF16(ct.argbExtended.redF16) = qfloat16(r); + castF16(ct.argbExtended.greenF16) = qfloat16(g); + castF16(ct.argbExtended.blueF16) = qfloat16(b); + castF16(ct.argbExtended.alphaF16) = qfloat16(a); + ct.argbExtended.pad = 0; + return; + } cspec = Rgb; - ct.argb.alpha = qRound(a * USHRT_MAX); ct.argb.red = qRound(r * USHRT_MAX); ct.argb.green = qRound(g * USHRT_MAX); ct.argb.blue = qRound(b * USHRT_MAX); + ct.argb.alpha = qRound(a * USHRT_MAX); ct.argb.pad = 0; } @@ -1421,7 +1464,11 @@ void QColor::setRgb(QRgb rgb) noexcept \sa setAlpha(), alphaF(), {QColor#Alpha-Blended Drawing}{Alpha-Blended Drawing} */ int QColor::alpha() const noexcept -{ return ct.argb.alpha >> 8; } +{ + if (cspec == ExtendedRgb) + return qRound(qreal(castF16(ct.argbExtended.alphaF16)) * 255); + return ct.argb.alpha >> 8; +} /*! @@ -1434,6 +1481,11 @@ int QColor::alpha() const noexcept void QColor::setAlpha(int alpha) { QCOLOR_INT_RANGE_CHECK("QColor::setAlpha", alpha); + if (cspec == ExtendedRgb) { + constexpr qreal f = qreal(1.0) / 255; + castF16(ct.argbExtended.alphaF16) = alpha * f; + return; + } ct.argb.alpha = alpha * 0x101; } @@ -1443,7 +1495,11 @@ void QColor::setAlpha(int alpha) \sa setAlphaF(), alpha(), {QColor#Alpha-Blended Drawing}{Alpha-Blended Drawing} */ qreal QColor::alphaF() const noexcept -{ return ct.argb.alpha / qreal(USHRT_MAX); } +{ + if (cspec == ExtendedRgb) + return castF16(ct.argbExtended.alphaF16); + return ct.argb.alpha / qreal(USHRT_MAX); +} /*! Sets the alpha of this color to \a alpha. qreal alpha is specified in the @@ -1455,6 +1511,10 @@ qreal QColor::alphaF() const noexcept void QColor::setAlphaF(qreal alpha) { QCOLOR_REAL_RANGE_CHECK("QColor::setAlphaF", alpha); + if (cspec == ExtendedRgb) { + castF16(ct.argbExtended.alphaF16) = alpha; + return; + } qreal tmp = alpha * USHRT_MAX; ct.argb.alpha = qRound(tmp); } @@ -1550,25 +1610,29 @@ void QColor::setBlue(int blue) */ qreal QColor::redF() const noexcept { - if (cspec != Invalid && cspec != Rgb) - return toRgb().redF(); - return ct.argb.red / qreal(USHRT_MAX); + if (cspec == Rgb || cspec == Invalid) + return ct.argb.red / qreal(USHRT_MAX); + if (cspec == ExtendedRgb) + return castF16(ct.argbExtended.redF16); + + return toRgb().redF(); } /*! - Sets the red color component of this color to \a red. Float components - are specified in the range 0.0-1.0. + Sets the red color component of this color to \a red. If \a red lies outside + the 0.0-1.0 range, the color model will be changed to \c ExtendedRgb. \sa redF(), red(), setRgbF() */ void QColor::setRedF(qreal red) { - QCOLOR_REAL_RANGE_CHECK("QColor::setRedF", red); - if (cspec != Rgb) - setRgbF(red, greenF(), blueF(), alphaF()); - else + if (cspec == Rgb && red >= qreal(0.0) && red <= qreal(1.0)) ct.argb.red = qRound(red * USHRT_MAX); + else if (cspec == ExtendedRgb) + castF16(ct.argbExtended.redF16) = red; + else + setRgbF(red, greenF(), blueF(), alphaF()); } /*! @@ -1578,25 +1642,29 @@ void QColor::setRedF(qreal red) */ qreal QColor::greenF() const noexcept { - if (cspec != Invalid && cspec != Rgb) - return toRgb().greenF(); - return ct.argb.green / qreal(USHRT_MAX); + if (cspec == Rgb || cspec == Invalid) + return ct.argb.green / qreal(USHRT_MAX); + if (cspec == ExtendedRgb) + return castF16(ct.argbExtended.greenF16); + + return toRgb().greenF(); } /*! - Sets the green color component of this color to \a green. Float components - are specified in the range 0.0-1.0. + Sets the green color component of this color to \a green. If \a green lies outside + the 0.0-1.0 range, the color model will be changed to \c ExtendedRgb. \sa greenF(), green(), setRgbF() */ void QColor::setGreenF(qreal green) { - QCOLOR_REAL_RANGE_CHECK("QColor::setGreenF", green); - if (cspec != Rgb) - setRgbF(redF(), green, blueF(), alphaF()); - else + if (cspec == Rgb && green >= qreal(0.0) && green <= qreal(1.0)) ct.argb.green = qRound(green * USHRT_MAX); + else if (cspec == ExtendedRgb) + castF16(ct.argbExtended.greenF16) = green; + else + setRgbF(redF(), green, blueF(), alphaF()); } /*! @@ -1606,24 +1674,27 @@ void QColor::setGreenF(qreal green) */ qreal QColor::blueF() const noexcept { - if (cspec != Invalid && cspec != Rgb) - return toRgb().blueF(); - return ct.argb.blue / qreal(USHRT_MAX); + if (cspec == Rgb || cspec == Invalid) + return ct.argb.blue / qreal(USHRT_MAX); + if (cspec == ExtendedRgb) + return castF16(ct.argbExtended.blueF16); + + return toRgb().blueF(); } /*! - Sets the blue color component of this color to \a blue. Float components - are specified in the range 0.0-1.0. - + Sets the blue color component of this color to \a blue. If \a blue lies outside + the 0.0-1.0 range, the color model will be changed to \c ExtendedRgb. \sa blueF(), blue(), setRgbF() */ void QColor::setBlueF(qreal blue) { - QCOLOR_REAL_RANGE_CHECK("QColor::setBlueF", blue); - if (cspec != Rgb) - setRgbF(redF(), greenF(), blue, alphaF()); - else + if (cspec == Rgb && blue >= qreal(0.0) && blue <= qreal(1.0)) ct.argb.blue = qRound(blue * USHRT_MAX); + else if (cspec == ExtendedRgb) + castF16(ct.argbExtended.blueF16) = blue; + else + setRgbF(redF(), greenF(), blue, alphaF()); } /*! @@ -1932,6 +2003,30 @@ qreal QColor::blackF() const noexcept return ct.acmyk.black / qreal(USHRT_MAX); } +/*! + Create and returns an extended RGB QColor based on this color. + \since 5.14 + + \sa toRgb, convertTo() +*/ +QColor QColor::toExtendedRgb() const noexcept +{ + if (!isValid() || cspec == ExtendedRgb) + return *this; + if (cspec != Rgb) + return toRgb().toExtendedRgb(); + + constexpr qreal f = qreal(1.0) / USHRT_MAX; + QColor color; + color.cspec = ExtendedRgb; + castF16(color.ct.argbExtended.alphaF16) = qfloat16(ct.argb.alpha * f); + castF16(color.ct.argbExtended.redF16) = qfloat16(ct.argb.red * f); + castF16(color.ct.argbExtended.greenF16) = qfloat16(ct.argb.green * f); + castF16(color.ct.argbExtended.blueF16) = qfloat16(ct.argb.blue * f); + color.ct.argbExtended.pad = 0; + return color; +} + /*! Create and returns an RGB QColor based on this color. @@ -1944,7 +2039,8 @@ QColor QColor::toRgb() const noexcept QColor color; color.cspec = Rgb; - color.ct.argb.alpha = ct.argb.alpha; + if (cspec != ExtendedRgb) + color.ct.argb.alpha = ct.argb.alpha; color.ct.argb.pad = 0; switch (cspec) { @@ -2066,6 +2162,12 @@ QColor QColor::toRgb() const noexcept color.ct.argb.blue = qRound((qreal(1.0) - (y * (qreal(1.0) - k) + k)) * USHRT_MAX); break; } + case ExtendedRgb: + color.ct.argb.alpha = qRound(USHRT_MAX * qreal(castF16(ct.argbExtended.alphaF16))); + color.ct.argb.red = qRound(USHRT_MAX * qBound(qreal(0.0), qreal(castF16(ct.argbExtended.redF16)), qreal(1.0))); + color.ct.argb.green = qRound(USHRT_MAX * qBound(qreal(0.0), qreal(castF16(ct.argbExtended.greenF16)), qreal(1.0))); + color.ct.argb.blue = qRound(USHRT_MAX * qBound(qreal(0.0), qreal(castF16(ct.argbExtended.blueF16)), qreal(1.0))); + break; default: break; } @@ -2238,6 +2340,8 @@ QColor QColor::convertTo(QColor::Spec colorSpec) const noexcept switch (colorSpec) { case Rgb: return toRgb(); + case ExtendedRgb: + return toExtendedRgb(); case Hsv: return toHsv(); case Cmyk: @@ -2317,20 +2421,32 @@ QColor QColor::fromRgb(int r, int g, int b, int a) color values, \a r (red), \a g (green), \a b (blue), and \a a (alpha-channel, i.e. transparency). - All the values must be in the range 0.0-1.0. + The alpha value must be in the range 0.0-1.0. + If any of the other values are outside the range of 0.0-1.0 the + color model will be set as \c ExtendedRgb. \sa fromRgb(), fromRgba64(), toRgb(), isValid() */ QColor QColor::fromRgbF(qreal r, qreal g, qreal b, qreal a) { - if (r < qreal(0.0) || r > qreal(1.0) - || g < qreal(0.0) || g > qreal(1.0) - || b < qreal(0.0) || b > qreal(1.0) - || a < qreal(0.0) || a > qreal(1.0)) { - qWarning("QColor::fromRgbF: RGB parameters out of range"); + if (a < qreal(0.0) || a > qreal(1.0)) { + qWarning("QColor::fromRgbF: Alpha parameter out of range"); return QColor(); } + if (r < qreal(0.0) || r > qreal(1.0) + || g < qreal(0.0) || g > qreal(1.0) + || b < qreal(0.0) || b > qreal(1.0)) { + QColor color; + color.cspec = ExtendedRgb; + castF16(color.ct.argbExtended.alphaF16) = qfloat16(a); + castF16(color.ct.argbExtended.redF16) = qfloat16(r); + castF16(color.ct.argbExtended.greenF16) = qfloat16(g); + castF16(color.ct.argbExtended.blueF16) = qfloat16(b); + color.ct.argbExtended.pad = 0; + return color; + } + QColor color; color.cspec = Rgb; color.ct.argb.alpha = qRound(a * USHRT_MAX); @@ -2885,6 +3001,8 @@ QDebug operator<<(QDebug dbg, const QColor &c) dbg.nospace() << "QColor(Invalid)"; else if (c.spec() == QColor::Rgb) dbg.nospace() << "QColor(ARGB " << c.alphaF() << ", " << c.redF() << ", " << c.greenF() << ", " << c.blueF() << ')'; + else if (c.spec() == QColor::ExtendedRgb) + dbg.nospace() << "QColor(Ext. ARGB " << c.alphaF() << ", " << c.redF() << ", " << c.greenF() << ", " << c.blueF() << ')'; else if (c.spec() == QColor::Hsv) dbg.nospace() << "QColor(AHSV " << c.alphaF() << ", " << c.hueF() << ", " << c.saturationF() << ", " << c.valueF() << ')'; else if (c.spec() == QColor::Cmyk) diff --git a/src/gui/painting/qcolor.h b/src/gui/painting/qcolor.h index cbc8b98f9c..77b2d43c40 100644 --- a/src/gui/painting/qcolor.h +++ b/src/gui/painting/qcolor.h @@ -64,7 +64,7 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QColor &); class Q_GUI_EXPORT QColor { public: - enum Spec { Invalid, Rgb, Hsv, Cmyk, Hsl }; + enum Spec { Invalid, Rgb, Hsv, Cmyk, Hsl, ExtendedRgb }; enum NameFormat { HexRgb, HexArgb }; inline QColor() noexcept; @@ -198,6 +198,7 @@ public: QColor toHsv() const noexcept; QColor toCmyk() const noexcept; QColor toHsl() const noexcept; + QColor toExtendedRgb() const noexcept; Q_REQUIRED_RESULT QColor convertTo(Spec colorSpec) const noexcept; @@ -275,6 +276,13 @@ private: ushort lightness; ushort pad; } ahsl; + struct { + ushort alphaF16; + ushort redF16; + ushort greenF16; + ushort blueF16; + ushort pad; + } argbExtended; ushort array[5]; } ct; diff --git a/src/gui/painting/qcolortransform.cpp b/src/gui/painting/qcolortransform.cpp index b677c4b36b..c723e12f8a 100644 --- a/src/gui/painting/qcolortransform.cpp +++ b/src/gui/painting/qcolortransform.cpp @@ -204,19 +204,36 @@ QColor QColorTransform::map(const QColor &color) const if (!d_ptr) return color; Q_D(const QColorTransform); - QColorVector c = { (float)color.redF(), (float)color.greenF(), (float)color.blueF() }; - c.x = d->colorSpaceIn->trc[0].apply(c.x); - c.y = d->colorSpaceIn->trc[1].apply(c.y); - c.z = d->colorSpaceIn->trc[2].apply(c.z); - c = d->colorMatrix.map(c); - if (d_ptr->colorSpaceOut->lutsGenerated.loadAcquire()) { - c.x = d->colorSpaceOut->lut[0]->fromLinear(c.x); - c.y = d->colorSpaceOut->lut[1]->fromLinear(c.y); - c.z = d->colorSpaceOut->lut[2]->fromLinear(c.z); + QColor clr = color; + if (color.spec() != QColor::ExtendedRgb || color.spec() != QColor::Rgb) + clr = clr.toRgb(); + + QColorVector c = { (float)clr.redF(), (float)clr.greenF(), (float)clr.blueF() }; + if (clr.spec() == QColor::ExtendedRgb) { + c.x = d->colorSpaceIn->trc[0].applyExtended(c.x); + c.y = d->colorSpaceIn->trc[1].applyExtended(c.y); + c.z = d->colorSpaceIn->trc[2].applyExtended(c.z); } else { - c.x = d->colorSpaceOut->trc[0].applyInverse(c.x); - c.y = d->colorSpaceOut->trc[1].applyInverse(c.y); - c.z = d->colorSpaceOut->trc[2].applyInverse(c.z); + c.x = d->colorSpaceIn->trc[0].apply(c.x); + c.y = d->colorSpaceIn->trc[1].apply(c.y); + c.z = d->colorSpaceIn->trc[2].apply(c.z); + } + c = d->colorMatrix.map(c); + bool inGamut = c.x >= 0.0f && c.x <= 1.0f && c.y >= 0.0f && c.y <= 1.0f && c.z >= 0.0f && c.z <= 1.0f; + if (inGamut) { + if (d_ptr->colorSpaceOut->lutsGenerated.loadAcquire()) { + c.x = d->colorSpaceOut->lut[0]->fromLinear(c.x); + c.y = d->colorSpaceOut->lut[1]->fromLinear(c.y); + c.z = d->colorSpaceOut->lut[2]->fromLinear(c.z); + } else { + c.x = d->colorSpaceOut->trc[0].applyInverse(c.x); + c.y = d->colorSpaceOut->trc[1].applyInverse(c.y); + c.z = d->colorSpaceOut->trc[2].applyInverse(c.z); + } + } else { + c.x = d->colorSpaceOut->trc[0].applyInverseExtended(c.x); + c.y = d->colorSpaceOut->trc[1].applyInverseExtended(c.y); + c.z = d->colorSpaceOut->trc[2].applyInverseExtended(c.z); } QColor out; out.setRgbF(c.x, c.y, c.z, color.alphaF()); diff --git a/src/gui/painting/qcolortrc_p.h b/src/gui/painting/qcolortrc_p.h index 3a649f3756..3ef9d442fc 100644 --- a/src/gui/painting/qcolortrc_p.h +++ b/src/gui/painting/qcolortrc_p.h @@ -91,7 +91,16 @@ public: return m_fun.apply(x); return x; } - + float applyExtended(float x) const + { + if (x >= 0.0f && x <= 1.0f) + return apply(x); + if (m_type == Type::Function) + return std::copysign(m_fun.apply(std::abs(x)), x); + if (m_type == Type::Table) + return x < 0.0f ? 0.0f : 1.0f; + return x; + } float applyInverse(float x) const { if (m_type == Type::Table) @@ -100,6 +109,16 @@ public: return m_fun.inverted().apply(x); return x; } + float applyInverseExtended(float x) const + { + if (x >= 0.0f && x <= 1.0f) + return applyInverse(x); + if (m_type == Type::Function) + return std::copysign(applyInverse(x), x); + if (m_type == Type::Table) + return x < 0.0f ? 0.0f : 1.0f; + return x; + } friend inline bool operator!=(const QColorTrc &o1, const QColorTrc &o2); friend inline bool operator==(const QColorTrc &o1, const QColorTrc &o2); diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp index 13d0618bd9..4d92bdd382 100644 --- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp +++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp @@ -70,6 +70,7 @@ private slots: void setBlue(); void setRgb(); + void setRgbF(); void setRgba(); void setHsv(); void setCmyk(); @@ -187,28 +188,28 @@ void tst_QColor::getSetCheck() // void QColor::setRedF(qreal) obj1.setRedF(0.0); QCOMPARE(obj1.redF(), qreal(0.0)); - obj1.setRedF(-0.2); - QCOMPARE(obj1.redF(), qreal(0.0)); // range<0.0, 1.0 - obj1.setRedF(1.1); - QCOMPARE(obj1.redF(), qreal(1.0)); // range<0.0, 1.0 + obj1.setRedF(-0.25); + QCOMPARE(obj1.redF(), qreal(-0.25)); + obj1.setRedF(1.25); + QCOMPARE(obj1.redF(), qreal(1.25)); // qreal QColor::greenF() // void QColor::setGreenF(qreal) obj1.setGreenF(0.0); QCOMPARE(obj1.greenF(), qreal(0.0)); - obj1.setGreenF(-0.2); - QCOMPARE(obj1.greenF(), qreal(0.0)); // range<0.0, 1.0 - obj1.setGreenF(1.1); - QCOMPARE(obj1.greenF(), qreal(1.0)); // range<0.0, 1.0 + obj1.setGreenF(-0.25); + QCOMPARE(obj1.greenF(), qreal(-0.25)); + obj1.setGreenF(1.5); + QCOMPARE(obj1.greenF(), qreal(1.5)); // qreal QColor::blueF() // void QColor::setBlueF(qreal) obj1.setBlueF(0.0); QCOMPARE(obj1.blueF(), qreal(0.0)); - obj1.setBlueF(-0.2); - QCOMPARE(obj1.blueF(), qreal(0.0)); // range<0.0, 1.0 - obj1.setBlueF(1.1); - QCOMPARE(obj1.blueF(), qreal(1.0)); // range<0.0, 1.0 + obj1.setBlueF(-0.5); + QCOMPARE(obj1.blueF(), qreal(-0.5)); + obj1.setBlueF(2.0); + QCOMPARE(obj1.blueF(), qreal(2.0)); // QRgb QColor::rgba() // void QColor::setRgba(QRgb) @@ -677,30 +678,81 @@ void tst_QColor::setRgb() { QColor color; + for (int a = 0; a <= 255; ++a) { + QRgb rgb = qRgba(0, 0, 0, a); + + color.setRgb(0, 0, 0, a); + QCOMPARE(color.alpha(), a); + QCOMPARE(color.rgb(), qRgb(0, 0, 0)); + + color.setRgb(rgb); + QCOMPARE(color.alpha(), 255); + QCOMPARE(color.rgb(), qRgb(0, 0, 0)); + + int r, g, b, a2; + color.setRgb(0, 0, 0, a); + color.getRgb(&r, &g, &b, &a2); + QCOMPARE(a2, a); + + QColor c(0, 0, 0); + c.setAlpha(a); + QCOMPARE(c.alpha(), a); + } + + for (int r = 0; r <= 255; ++r) { + QRgb rgb = qRgb(r, 0, 0); + + color.setRgb(r, 0, 0); + QCOMPARE(color.red(), r); + QCOMPARE(color.rgb(), rgb); + + color.setRgb(rgb); + QCOMPARE(color.red(), r); + QCOMPARE(color.rgb(), rgb); + + int r2, g, b, a; + color.getRgb(&r2, &g, &b, &a); + QCOMPARE(r2, r); + } + + for (int g = 0; g <= 255; ++g) { + QRgb rgb = qRgb(0, g, 0); + + color.setRgb(0, g, 0); + QCOMPARE(color.green(), g); + QCOMPARE(color.rgb(), rgb); + + color.setRgb(rgb); + QCOMPARE(color.green(), g); + QCOMPARE(color.rgb(), rgb); + + int r, g2, b, a; + color.getRgb(&r, &g2, &b, &a); + QCOMPARE(g2, g); + } + + for (int b = 0; b <= 255; ++b) { + QRgb rgb = qRgb(0, 0, b); + + color.setRgb(0, 0, b); + QCOMPARE(color.blue(), b); + QCOMPARE(color.rgb(), rgb); + + color.setRgb(rgb); + QCOMPARE(color.blue(), b); + QCOMPARE(color.rgb(), rgb); + + int r, g, b2, a; + color.getRgb(&r, &g, &b2, &a); + QCOMPARE(b2, b); + } +} + +void tst_QColor::setRgbF() +{ + QColor color; + for (int A = 0; A <= USHRT_MAX; ++A) { - { - // 0-255 - int a = A >> 8; - QRgb rgb = qRgba(0, 0, 0, a); - - color.setRgb(0, 0, 0, a); - QCOMPARE(color.alpha(), a); - QCOMPARE(color.rgb(), qRgb(0, 0, 0)); - - color.setRgb(rgb); - QCOMPARE(color.alpha(), 255); - QCOMPARE(color.rgb(), qRgb(0, 0, 0)); - - int r, g, b, a2; - color.setRgb(0, 0, 0, a); - color.getRgb(&r, &g, &b, &a2); - QCOMPARE(a2, a); - - QColor c(0, 0, 0); - c.setAlpha(a); - QCOMPARE(c.alpha(), a); - } - { // 0.0-1.0 qreal a = A / qreal(USHRT_MAX); @@ -719,24 +771,6 @@ void tst_QColor::setRgb() } for (int R = 0; R <= USHRT_MAX; ++R) { - { - // 0-255 - int r = R >> 8; - QRgb rgb = qRgb(r, 0, 0); - - color.setRgb(r, 0, 0); - QCOMPARE(color.red(), r); - QCOMPARE(color.rgb(), rgb); - - color.setRgb(rgb); - QCOMPARE(color.red(), r); - QCOMPARE(color.rgb(), rgb); - - int r2, g, b, a; - color.getRgb(&r2, &g, &b, &a); - QCOMPARE(r2, r); - } - { // 0.0-1.0 qreal r = R / qreal(USHRT_MAX); @@ -750,24 +784,6 @@ void tst_QColor::setRgb() } for (int G = 0; G <= USHRT_MAX; ++G) { - { - // 0-255 - int g = G >> 8; - QRgb rgb = qRgb(0, g, 0); - - color.setRgb(0, g, 0); - QCOMPARE(color.green(), g); - QCOMPARE(color.rgb(), rgb); - - color.setRgb(rgb); - QCOMPARE(color.green(), g); - QCOMPARE(color.rgb(), rgb); - - int r, g2, b, a; - color.getRgb(&r, &g2, &b, &a); - QCOMPARE(g2, g); - } - { // 0.0-1.0 qreal g = G / qreal(USHRT_MAX); @@ -781,24 +797,6 @@ void tst_QColor::setRgb() } for (int B = 0; B <= USHRT_MAX; ++B) { - { - // 0-255 - int b = B >> 8; - QRgb rgb = qRgb(0, 0, b); - - color.setRgb(0, 0, b); - QCOMPARE(color.blue(), b); - QCOMPARE(color.rgb(), rgb); - - color.setRgb(rgb); - QCOMPARE(color.blue(), b); - QCOMPARE(color.rgb(), rgb); - - int r, g, b2, a; - color.getRgb(&r, &g, &b2, &a); - QCOMPARE(b2, b); - } - { // 0.0-1.0 qreal b = B / qreal(USHRT_MAX); @@ -810,6 +808,45 @@ void tst_QColor::setRgb() QCOMPARE(b2, b); } } + + for (int R = -128; R <= 512; ++R) { + { + // extended RGB + qreal r = R / qreal(256); + color.setRgbF(r, 0.0, 0.0); + QCOMPARE(qfloat16(color.redF()), qfloat16(r)); + + qreal r2, g, b, a; + color.getRgbF(&r2, &g, &b, &a); + QCOMPARE(qfloat16(r2), qfloat16(r)); + } + } + + for (int G = -128; G <= 512; ++G) { + { + // extended RGB + qreal g = G / qreal(256); + color.setRgbF(0.0, g, 0.0); + QCOMPARE(qfloat16(color.greenF()), qfloat16(g)); + + qreal r, g2, b, a; + color.getRgbF(&r, &g2, &b, &a); + QCOMPARE(qfloat16(g2), qfloat16(g)); + } + } + + for (int B = -128; B <= 512; ++B) { + { + // extended RGB + qreal b = B / qreal(256); + color.setRgbF(0.0, 0.0, b); + QCOMPARE(qfloat16(color.blueF()), qfloat16(b)); + + qreal r, g, b2, a; + color.getRgbF(&r, &g, &b2, &a); + QCOMPARE(qfloat16(b2), qfloat16(b)); + } + } } void tst_QColor::setRgba() diff --git a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp index 9bd4b75443..35bca58854 100644 --- a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp +++ b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp @@ -57,6 +57,8 @@ private slots: void imageConversion(); void loadImage(); + + void gamut(); }; tst_QColorSpace::tst_QColorSpace() @@ -232,6 +234,59 @@ void tst_QColorSpace::loadImage() // Test the iccProfile getter returns the ICC profile from the image // which since we didn't write it, isn't identical to our defaults. QVERIFY(defaultProPhotoRgb.iccProfile() != image.colorSpace().iccProfile()); + + QColorTransform transform = image.colorSpace().transformationToColorSpace(QColorSpace::SRgb); + qreal maxRed = 0; + qreal maxBlue = 0; + qreal maxRed2 = 0; + qreal maxBlue2 = 0; + for (int y = 0; y < image.height(); ++y) { + for (int x = 0; x < image.width(); ++x) { + QColor p = image.pixelColor(x, y); + maxRed = std::max(maxRed, p.redF()); + maxBlue = std::max(maxBlue, p.blueF()); + p = transform.map(p); + maxRed2 = std::max(maxRed2, p.redF()); + maxBlue2 = std::max(maxBlue2, p.blueF()); + + } + } + // ProPhotoRgb can be a lot more red and blue than SRgb can, so it will have lower values. + QVERIFY(maxRed2 > maxRed); + QVERIFY(maxBlue2 > maxBlue); +} + +void tst_QColorSpace::gamut() +{ + QColor black = QColor::fromRgbF(0.0, 0.0, 0.0); + QColor white = QColor::fromRgbF(1.0, 1.0, 1.0); + QColor red = QColor::fromRgbF(1.0, 0.0, 0.0); + QColor green = QColor::fromRgbF(0.0, 1.0, 0.0); + QColor blue = QColor::fromRgbF(0.0, 0.0, 1.0); + + QColorTransform toAdobeRgb = QColorSpace(QColorSpace::SRgb).transformationToColorSpace(QColorSpace::AdobeRgb); + + QColor tblack = toAdobeRgb.map(black); + QColor twhite = toAdobeRgb.map(white); + QColor tred = toAdobeRgb.map(red); + QColor tgreen = toAdobeRgb.map(green); + QColor tblue = toAdobeRgb.map(blue); + + // Black is black + QCOMPARE(tblack, black); + + // This white hasn't changed + QCOMPARE(twhite, white); + + // Adobe's red and blue gamut corners are the same as sRGB's + // So, a color in the red corner, will stay in the red corner + // the same for blue, but not for green. + QVERIFY(tred.greenF() < 0.001); + QVERIFY(tred.blueF() < 0.001); + QVERIFY(tblue.redF() < 0.001); + QVERIFY(tblue.greenF() < 0.001); + QVERIFY(tgreen.redF() > 0.2); + QVERIFY(tgreen.blueF() > 0.2); } QTEST_MAIN(tst_QColorSpace) From cab6587e5e798d902d6656e2fdb431b476dc0a17 Mon Sep 17 00:00:00 2001 From: Martin Koller Date: Sun, 14 Apr 2019 12:47:58 +0200 Subject: [PATCH 184/292] Avoid debug messages for not implemented "grab" methods Change-Id: Ie32b5d261854703fa17bb844cf8354709b031a4c Reviewed-by: BogDan Vatra --- src/plugins/platforms/android/qandroidplatformwindow.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/platforms/android/qandroidplatformwindow.h b/src/plugins/platforms/android/qandroidplatformwindow.h index f2e51bd3df..5edd274759 100644 --- a/src/plugins/platforms/android/qandroidplatformwindow.h +++ b/src/plugins/platforms/android/qandroidplatformwindow.h @@ -65,6 +65,9 @@ public: void setParent(const QPlatformWindow *window) override; WId winId() const override { return m_windowId; } + bool setMouseGrabEnabled(bool grab) override { return false; } + bool setKeyboardGrabEnabled(bool grab) override { return false; } + QAndroidPlatformScreen *platformScreen() const; void propagateSizeHints() override; From 093a1a6232083e5b9c18a9e85e5759ba3ce280fb Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Mon, 25 Mar 2019 12:47:21 +0100 Subject: [PATCH 185/292] tslib: use ts_setup() to find the device This automatically searches for some default devices. This not only reduces the amount of code, it also makes sure that Qt will by default find the same input devices that tslib (e.g. ts_calibrate) will find. Fixes: QTBUG-74680 Change-Id: Ied3fff7e8ed9d6637d2b8cf32119660133d251a3 Reviewed-by: Laszlo Agocs --- src/gui/configure.json | 2 +- src/platformsupport/input/tslib/qtslib.cpp | 26 +++++----------------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/src/gui/configure.json b/src/gui/configure.json index 5bcfbc88bf..7a1796041e 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -476,7 +476,7 @@ "tslib": { "label": "tslib", "test": { - "main": "ts_open(\"foo\", 0);" + "main": "ts_setup(nullptr, 0);" }, "headers": "tslib.h", "sources": [ diff --git a/src/platformsupport/input/tslib/qtslib.cpp b/src/platformsupport/input/tslib/qtslib.cpp index f8fdc151ec..c4caea5c80 100644 --- a/src/platformsupport/input/tslib/qtslib.cpp +++ b/src/platformsupport/input/tslib/qtslib.cpp @@ -62,31 +62,15 @@ QTsLibMouseHandler::QTsLibMouseHandler(const QString &key, qCDebug(qLcTsLib) << "Initializing tslib plugin" << key << specification; setObjectName(QLatin1String("TSLib Mouse Handler")); - QByteArray device = qgetenv("TSLIB_TSDEVICE"); - - if (specification.startsWith(QLatin1String("/dev/"))) - device = specification.toLocal8Bit(); - - if (device.isEmpty()) - device = QByteArrayLiteral("/dev/input/event1"); - - m_dev = ts_open(device.constData(), 1); + m_dev = ts_setup(nullptr, 1); if (!m_dev) { - qErrnoWarning(errno, "ts_open() failed"); + qErrnoWarning(errno, "ts_setup() failed"); return; } - if (ts_config(m_dev)) - qErrnoWarning(errno, "ts_config() failed"); - - int fd = ts_fd(m_dev); - if (fd >= 0) { - qCDebug(qLcTsLib) << "tslib device is" << device; - m_notify = new QSocketNotifier(fd, QSocketNotifier::Read, this); - connect(m_notify, &QSocketNotifier::activated, this, &QTsLibMouseHandler::readMouseData); - } else { - qErrnoWarning(errno, "tslib: Cannot open input device %s", device.constData()); - } + qCDebug(qLcTsLib) << "tslib device is" << ts_get_eventpath(m_dev); + m_notify = new QSocketNotifier(ts_fd(m_dev), QSocketNotifier::Read, this); + connect(m_notify, &QSocketNotifier::activated, this, &QTsLibMouseHandler::readMouseData); } QTsLibMouseHandler::~QTsLibMouseHandler() From 327c8a805e508303c245020123ec3ecbfd2c898b Mon Sep 17 00:00:00 2001 From: Rob Samblanet Date: Tue, 23 Oct 2018 12:52:06 -0500 Subject: [PATCH 186/292] android: Properly indicate successful Qt install This patch ensures that installed files are written to physical disk before the 'cache.version' file is written. QtLoader.java uses the 'cache.version' file written during self-installation to indicate whether re-installation is necessary. The 'cache.version' file, however, was being written at the start of installation, so its existence merely indicated that the installation was attempted. In the case of power loss during installation, the existence of 'cache.version' would prevent retrying installation on the next launch, so the bad installation was irrecoverable. [ChangeLog][Android] Fixed an issue where an application installation would be irrecoverably broken if power loss or a crash occurred during its first initialization run. Fixes: QTBUG-71523 Change-Id: If771b223a0a709a994c766eea5a4ba14ae95201e Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../qt5/android/bindings/QtLoader.java | 100 +++++++++++++----- 1 file changed, 75 insertions(+), 25 deletions(-) diff --git a/src/android/java/src/org/qtproject/qt5/android/bindings/QtLoader.java b/src/android/java/src/org/qtproject/qt5/android/bindings/QtLoader.java index 9d5578ed6d..d3b0600b2f 100644 --- a/src/android/java/src/org/qtproject/qt5/android/bindings/QtLoader.java +++ b/src/android/java/src/org/qtproject/qt5/android/bindings/QtLoader.java @@ -159,6 +159,9 @@ public abstract class QtLoader { protected ComponentInfo m_contextInfo; private Class m_delegateClass; + private static ArrayList m_fileOutputStreams = new ArrayList(); + // List of open file streams associated with files copied during installation. + QtLoader(ContextWrapper context, Class clazz) { m_context = context; m_delegateClass = clazz; @@ -357,7 +360,7 @@ public abstract class QtLoader { AssetManager assetsManager = m_context.getAssets(); InputStream inputStream = null; - OutputStream outputStream = null; + FileOutputStream outputStream = null; try { inputStream = assetsManager.open(source); outputStream = new FileOutputStream(destinationFile); @@ -369,8 +372,12 @@ public abstract class QtLoader { inputStream.close(); if (outputStream != null) - outputStream.close(); + // Ensure that the buffered data is flushed to the OS for writing. + outputStream.flush(); } + // Mark the output stream as still needing to be written to physical disk. + // The output stream will be closed after this sync completes. + m_fileOutputStreams.add(outputStream); } private static void createBundledBinary(String source, String destination) @@ -388,7 +395,7 @@ public abstract class QtLoader { destinationFile.createNewFile(); InputStream inputStream = null; - OutputStream outputStream = null; + FileOutputStream outputStream = null; try { inputStream = new FileInputStream(source); outputStream = new FileOutputStream(destinationFile); @@ -400,8 +407,12 @@ public abstract class QtLoader { inputStream.close(); if (outputStream != null) - outputStream.close(); + // Ensure that the buffered data is flushed to the OS for writing. + outputStream.flush(); } + // Mark the output stream as still needing to be written to physical disk. + // The output stream will be closed after this sync completes. + m_fileOutputStreams.add(outputStream); } private boolean cleanCacheIfNecessary(String pluginsPrefix, long packageVersion) @@ -449,27 +460,6 @@ public abstract class QtLoader { if (!cleanCacheIfNecessary(pluginsPrefix, packageVersion)) return; - { - File versionFile = new File(pluginsPrefix + "cache.version"); - - File parentDirectory = versionFile.getParentFile(); - if (!parentDirectory.exists()) - parentDirectory.mkdirs(); - - versionFile.createNewFile(); - - DataOutputStream outputStream = null; - try { - outputStream = new DataOutputStream(new FileOutputStream(versionFile)); - outputStream.writeLong(packageVersion); - } catch (Exception e) { - e.printStackTrace(); - } finally { - if (outputStream != null) - outputStream.close(); - } - } - { // why can't we load the plugins directly from libs ?!?! String key = BUNDLED_IN_LIB_RESOURCE_ID_KEY; @@ -499,6 +489,66 @@ public abstract class QtLoader { } } + + // The Java compiler must be assured that variables belonging to this parent thread will not + // go out of scope during the runtime of the spawned thread (since in general spawned + // threads can outlive their parent threads). Copy variables and declare as 'final' before + // passing into the spawned thread. + final String pluginsPrefixFinal = pluginsPrefix; + final long packageVersionFinal = packageVersion; + + // Spawn a worker thread to write all installed files to physical disk and indicate + // successful installation by creating the 'cache.version' file. + new Thread(new Runnable() { + @Override + public void run() { + try { + finalizeInstallation(pluginsPrefixFinal, packageVersionFinal); + } catch (Exception e) { + Log.e(QtApplication.QtTAG, e.getMessage()); + e.printStackTrace(); + return; + } + } + }).start(); + } + + private void finalizeInstallation(String pluginsPrefix, long packageVersion) + throws IOException + { + { + // Write all installed files to physical disk and close each output stream + for (FileOutputStream fileOutputStream : m_fileOutputStreams) { + fileOutputStream.getFD().sync(); + fileOutputStream.close(); + } + + m_fileOutputStreams.clear(); + } + + { + // Create 'cache.version' file + + File versionFile = new File(pluginsPrefix + "cache.version"); + + File parentDirectory = versionFile.getParentFile(); + if (!parentDirectory.exists()) + parentDirectory.mkdirs(); + + versionFile.createNewFile(); + + DataOutputStream outputStream = null; + try { + outputStream = new DataOutputStream(new FileOutputStream(versionFile)); + outputStream.writeLong(packageVersion); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (outputStream != null) + outputStream.close(); + } + } + } private void deleteRecursively(File directory) From 7fe52779f4fe1a9aa01abd1f0d75107bdb6757e8 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 3 Dec 2018 16:20:29 +0100 Subject: [PATCH 187/292] uic test: Pre-populate the test data array Task-number: PYSIDE-797 Change-Id: I2beed73f20bbfc8b5b4f2352cc53d80a64b95d8e Reviewed-by: Cristian Maureira-Fredes --- tests/auto/tools/uic/tst_uic.cpp | 64 ++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 24 deletions(-) diff --git a/tests/auto/tools/uic/tst_uic.cpp b/tests/auto/tools/uic/tst_uic.cpp index f9553028fe..946296b844 100644 --- a/tests/auto/tools/uic/tst_uic.cpp +++ b/tests/auto/tools/uic/tst_uic.cpp @@ -36,17 +36,27 @@ #include #include #include +#include #include static const char keepEnvVar[] = "UIC_KEEP_GENERATED_FILES"; static const char diffToStderrEnvVar[] = "UIC_STDERR_DIFF"; +struct TestEntry +{ + QByteArray name; + QString baselineBaseName; + QString generatedFileName; +}; + class tst_uic : public QObject { Q_OBJECT public: + using TestEntries = QVector; + tst_uic(); private Q_SLOTS: @@ -66,9 +76,12 @@ private Q_SLOTS: void runCompare(); private: + void populateTestEntries(); + const QString m_command; QString m_baseline; QTemporaryDir m_generated; + TestEntries m_testEntries; QRegularExpression m_versionRegexp; }; @@ -105,9 +118,28 @@ void tst_uic::initTestCase() arg(QDir::currentPath()); if (!outLines.empty()) msg += outLines.front(); + populateTestEntries(); + QVERIFY(!m_testEntries.isEmpty()); qDebug("%s", qPrintable(msg)); } +void tst_uic::populateTestEntries() +{ + const QString generatedPrefix = m_generated.path() + QLatin1Char('/'); + QDir baseline(m_baseline); + const QString baseLinePrefix = baseline.path() + QLatin1Char('/'); + const QFileInfoList baselineFiles = + baseline.entryInfoList(QStringList(QString::fromLatin1("*.ui")), QDir::Files); + m_testEntries.reserve(baselineFiles.size()); + for (const QFileInfo &baselineFile : baselineFiles) { + const QString baseName = baselineFile.baseName(); + const QString baselineBaseName = baseLinePrefix + baseName; + const QString generatedFile = generatedPrefix + baselineFile.fileName() + + QLatin1String(".h"); + m_testEntries.append(TestEntry{baseName.toLocal8Bit(), baselineBaseName, generatedFile}); + } +} + static const char helpFormat[] = R"( Note: The environment variable '%s' can be set to keep the temporary files for error analysis. @@ -171,22 +203,12 @@ void tst_uic::run_data() const QTest::addColumn("generatedFile"); QTest::addColumn("options"); - QDir generated(m_generated.path()); - QDir baseline(m_baseline); - const QFileInfoList baselineFiles = baseline.entryInfoList(QStringList("*.ui"), QDir::Files); - foreach (const QFileInfo &baselineFile, baselineFiles) { - const QString generatedFile = generated.absolutePath() - + QLatin1Char('/') + baselineFile.fileName() - + QLatin1String(".h"); - + for (const TestEntry &te : m_testEntries) { QStringList options; - if (baselineFile.fileName() == QLatin1String("qttrid.ui")) + if (te.name == QByteArrayLiteral("qttrid")) options << QStringList(QLatin1String("-idbased")); - - QTest::newRow(qPrintable(baselineFile.baseName())) - << baselineFile.absoluteFilePath() - << generatedFile - << options; + QTest::newRow(te.name.constData()) << (te.baselineBaseName + QLatin1String(".ui")) + << te.generatedFileName << options; } } @@ -264,15 +286,9 @@ void tst_uic::compare_data() const QTest::addColumn("originalFile"); QTest::addColumn("generatedFile"); - QDir generated(m_generated.path()); - QDir baseline(m_baseline); - const QFileInfoList baselineFiles = baseline.entryInfoList(QStringList("*.h"), QDir::Files); - foreach (const QFileInfo &baselineFile, baselineFiles) { - const QString generatedFile = generated.absolutePath() - + QLatin1Char('/') + baselineFile.fileName(); - QTest::newRow(qPrintable(baselineFile.baseName())) - << baselineFile.absoluteFilePath() - << generatedFile; + for (const TestEntry &te : m_testEntries) { + QTest::newRow(te.name.constData()) << (te.baselineBaseName + QLatin1String(".ui.h")) + << te.generatedFileName; } } @@ -280,7 +296,7 @@ void tst_uic::runTranslation() { QProcess process; - QDir baseline(m_baseline); + const QDir baseline(m_baseline); QDir generated(m_generated.path()); generated.mkdir(QLatin1String("translation")); From 7a84a0a6d18c7a9e7fc7c963561c561b3027c1e7 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 3 Dec 2018 16:57:04 +0100 Subject: [PATCH 188/292] uic test: Test Python Add a test that checks for the Presence of Qt for Python and runs Python compile tests on the baseline files. Task-number: PYSIDE-797 Change-Id: I7e15c3c75261a7d94fc6654a95d49ba323cbe7d6 Reviewed-by: Cristian Maureira-Fredes --- tests/auto/tools/uic/tst_uic.cpp | 102 +++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/tests/auto/tools/uic/tst_uic.cpp b/tests/auto/tools/uic/tst_uic.cpp index 946296b844..5b2f1f008b 100644 --- a/tests/auto/tools/uic/tst_uic.cpp +++ b/tests/auto/tools/uic/tst_uic.cpp @@ -73,6 +73,9 @@ private Q_SLOTS: void compare(); void compare_data() const; + void python(); + void python_data() const; + void runCompare(); private: @@ -83,6 +86,7 @@ private: QTemporaryDir m_generated; TestEntries m_testEntries; QRegularExpression m_versionRegexp; + QString m_python; }; tst_uic::tst_uic() @@ -98,6 +102,32 @@ static QByteArray msgProcessStartFailed(const QString &command, const QString &w return result.toLocal8Bit(); } +// Locate Python and check whether PySide2 is installed +static QString locatePython(QTemporaryDir &generatedDir) +{ + QString python = QStandardPaths::findExecutable(QLatin1String("python")); + if (python.isEmpty()) { + qWarning("Cannot locate python, skipping tests"); + return QString(); + } + QFile importTestFile(generatedDir.filePath(QLatin1String("import_test.py"))); + if (!importTestFile.open(QIODevice::WriteOnly| QIODevice::Text)) + return QString(); + importTestFile.write("import PySide2.QtCore\n"); + importTestFile.close(); + QProcess process; + process.start(python, {importTestFile.fileName()}); + if (!process.waitForStarted() || !process.waitForFinished()) + return QString(); + if (process.exitStatus() != QProcess::NormalExit || process.exitCode() != 0) { + const QString stdErr = QString::fromLocal8Bit(process.readAllStandardError()).simplified(); + qWarning("PySide2 is not installed (%s)", qPrintable(stdErr)); + return QString(); + } + importTestFile.remove(); + return python; +} + void tst_uic::initTestCase() { QVERIFY2(m_generated.isValid(), qPrintable(m_generated.errorString())); @@ -121,6 +151,8 @@ void tst_uic::initTestCase() populateTestEntries(); QVERIFY(!m_testEntries.isEmpty()); qDebug("%s", qPrintable(msg)); + + m_python = locatePython(m_generated); } void tst_uic::populateTestEntries() @@ -343,5 +375,75 @@ void tst_uic::runCompare() QCOMPARE(generatedFileContents, originalFileContents); } +// Let uic generate Python code and verify that it is syntactically +// correct by compiling it into .pyc. This test is executed only +// when python with an installed Qt for Python is detected (see locatePython()). + +static inline QByteArray msgCompilePythonFailed(const QByteArray &error) +{ + // If there is a line with blanks and caret indicating an error in the line + // above, insert the cursor into the offending line and remove the caret. + QByteArrayList lines = error.trimmed().split('\n'); + for (int i = lines.size() - 1; i > 0; --i) { + const auto &line = lines.at(i); + const int caret = line.indexOf('^'); + if (caret == 0 || (caret > 0 && line.at(caret - 1) == ' ')) { + lines.removeAt(i); + lines[i - 1].insert(caret, '|'); + break; + } + } + return lines.join('\n'); +} + +void tst_uic::python_data() const +{ + QTest::addColumn("originalFile"); + QTest::addColumn("generatedFile"); + + const int size = m_python.isEmpty() + ? qMin(1, m_testEntries.size()) : m_testEntries.size(); + for (int i = 0; i < size; ++i) { + const TestEntry &te = m_testEntries.at(i); + // qprintsettingsoutput: variable named 'from' clashes with Python + if (!te.baselineBaseName.endsWith(QLatin1String("/qprintsettingsoutput"))) { + QString generatedFile = te.generatedFileName; + generatedFile.chop(1); // foo.h -> foo.py + generatedFile.append(QLatin1String("py")); + QTest::newRow(te.name.constData()) + << (te.baselineBaseName + QLatin1String(".ui")) + << generatedFile; + } + } +} + +void tst_uic::python() +{ + QFETCH(QString, originalFile); + QFETCH(QString, generatedFile); + if (m_python.isEmpty()) + QSKIP("Python was not found"); + + QStringList uicArguments{QLatin1String("-g"), QLatin1String("python"), + originalFile, QLatin1String("-o"), generatedFile}; + QProcess process; + process.setWorkingDirectory(m_generated.path()); + process.start(m_command, uicArguments); + QVERIFY2(process.waitForStarted(), msgProcessStartFailed(m_command, process.errorString())); + QVERIFY(process.waitForFinished()); + QCOMPARE(process.exitStatus(), QProcess::NormalExit); + QCOMPARE(process.exitCode(), 0); + QVERIFY(QFileInfo::exists(generatedFile)); + + // Test Python code generation by compiling the file + QStringList compileArguments{QLatin1String("-m"), QLatin1String("py_compile"), generatedFile}; + process.start(m_python, compileArguments); + QVERIFY2(process.waitForStarted(), msgProcessStartFailed(m_command, process.errorString())); + QVERIFY(process.waitForFinished()); + const bool compiled = process.exitStatus() == QProcess::NormalExit + && process.exitCode() == 0; + QVERIFY2(compiled, msgCompilePythonFailed(process.readAllStandardError()).constData()); +} + QTEST_MAIN(tst_uic) #include "tst_uic.moc" From f363540580eabd5aa27f4c172da796d637e38dfa Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 16 Apr 2019 09:54:46 +0200 Subject: [PATCH 189/292] uic: Do not generate Q_UNUSED for Python Task-number: PYSIDE-797 Change-Id: Id269af024c03c2c586d440659bb6c49c3d6eedc6 Reviewed-by: Cristian Maureira-Fredes --- src/tools/uic/cpp/cppwriteinitialization.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index afd0376643..b8ff91f354 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -556,7 +556,7 @@ void WriteInitialization::acceptUI(DomUI *node) m_output << m_option.indent << language::endFunctionDefinition("setupUi"); - if (!m_mainFormUsedInRetranslateUi) { + if (!m_mainFormUsedInRetranslateUi && language::language() == Language::Cpp) { m_refreshInitialization += m_indent; m_refreshInitialization += QLatin1String("Q_UNUSED("); m_refreshInitialization += varName ; From 2e1763d83a1dacfc5b747934fb77fa7cec7bfe47 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 3 Mar 2016 20:20:42 +0100 Subject: [PATCH 190/292] Non-associative containers: add range constructors Something nice we'd like to detect for array-backed containers is if the iterator passed is a Contiguous one; if the type is also trivially copyable / Q_PRIMITIVE_TYPE, we could memcpy() the whole range. However, there's no trait in the Standard to detect contiguous iterators (the best approximation would be detecting if the iterator is actually a pointer). Also, it's probably not smart to do the work now for QVector since QVector needs refactoring anyhow, and this work will be lost. QString and QByteArray are left in another commit. [ChangeLog][QtCore][QVector] Added range constructor. [ChangeLog][QtCore][QVarLengthArray] Added range constructor. [ChangeLog][QtCore][QList] Added range constructor. [ChangeLog][QtCore][QStringList] Added range constructor. [ChangeLog][QtCore][QLinkedList] Added range constructor. [ChangeLog][QtCore][QSet] Added range constructor. Change-Id: I220edb796053c9c4d31a6dbdc7efc5fc0f6678f9 Reviewed-by: Milian Wolff --- src/corelib/tools/qcontainertools_impl.h | 93 +++ src/corelib/tools/qlinkedlist.cpp | 8 + src/corelib/tools/qlinkedlist.h | 12 +- src/corelib/tools/qlist.cpp | 8 + src/corelib/tools/qlist.h | 16 +- src/corelib/tools/qset.h | 16 +- src/corelib/tools/qset.qdoc | 11 + src/corelib/tools/qstringlist.cpp | 7 + src/corelib/tools/qstringlist.h | 4 + src/corelib/tools/qvarlengtharray.h | 13 +- src/corelib/tools/qvarlengtharray.qdoc | 8 + src/corelib/tools/qvector.h | 13 + src/corelib/tools/qvector.qdoc | 7 + src/corelib/tools/tools.pri | 1 + .../tst_containerapisymmetry.cpp | 593 ++++++++++++++++++ .../tools/qstringlist/tst_qstringlist.cpp | 37 ++ 16 files changed, 833 insertions(+), 14 deletions(-) create mode 100644 src/corelib/tools/qcontainertools_impl.h diff --git a/src/corelib/tools/qcontainertools_impl.h b/src/corelib/tools/qcontainertools_impl.h new file mode 100644 index 0000000000..c2de50b145 --- /dev/null +++ b/src/corelib/tools/qcontainertools_impl.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz +** Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#if 0 +#pragma qt_sync_skip_header_check +#pragma qt_sync_stop_processing +#endif + +#ifndef QCONTAINERTOOLS_IMPL_H +#define QCONTAINERTOOLS_IMPL_H + +#include +#include + +#ifndef Q_QDOC + +QT_BEGIN_NAMESPACE + +namespace QtPrivate +{ +template +using IfIsInputIterator = typename std::enable_if< + std::is_convertible::iterator_category, std::input_iterator_tag>::value, + bool>::type; + +template +using IfIsForwardIterator = typename std::enable_if< + std::is_convertible::iterator_category, std::forward_iterator_tag>::value, + bool>::type; + +template +using IfIsNotForwardIterator = typename std::enable_if< + !std::is_convertible::iterator_category, std::forward_iterator_tag>::value, + bool>::type; + +template = true> +void reserveIfForwardIterator(Container *, InputIterator, InputIterator) +{ +} + +template = true> +void reserveIfForwardIterator(Container *c, ForwardIterator f, ForwardIterator l) +{ + c->reserve(static_cast(std::distance(f, l))); +} +} // namespace QtPrivate + +QT_END_NAMESPACE + +#endif // Q_QDOC + +#endif // QCONTAINERTOOLS_IMPL_H diff --git a/src/corelib/tools/qlinkedlist.cpp b/src/corelib/tools/qlinkedlist.cpp index d9d93862e5..c0450f5cd8 100644 --- a/src/corelib/tools/qlinkedlist.cpp +++ b/src/corelib/tools/qlinkedlist.cpp @@ -153,6 +153,14 @@ const QLinkedListData QLinkedListData::shared_null = { initializer lists. */ +/*! \fn template template QLinkedList::QLinkedList(InputIterator first, InputIterator last) + \since 5.14 + + Constructs a list with the contents in the iterator range [\a first, \a last). + + The value type of \c InputIterator must be convertible to \c T. +*/ + /*! \fn template QLinkedList::~QLinkedList() Destroys the list. References to the values in the list, and all diff --git a/src/corelib/tools/qlinkedlist.h b/src/corelib/tools/qlinkedlist.h index 91367a74b3..83f70deceb 100644 --- a/src/corelib/tools/qlinkedlist.h +++ b/src/corelib/tools/qlinkedlist.h @@ -42,6 +42,7 @@ #include #include +#include #include #include @@ -84,11 +85,14 @@ public: inline QLinkedList(const QLinkedList &l) : d(l.d) { d->ref.ref(); if (!d->sharable) detach(); } #if defined(Q_COMPILER_INITIALIZER_LISTS) inline QLinkedList(std::initializer_list list) - : d(const_cast(&QLinkedListData::shared_null)) - { - std::copy(list.begin(), list.end(), std::back_inserter(*this)); - } + : QLinkedList(list.begin(), list.end()) {} #endif + template = true> + inline QLinkedList(InputIterator first, InputIterator last) + : QLinkedList() + { + std::copy(first, last, std::back_inserter(*this)); + } ~QLinkedList(); QLinkedList &operator=(const QLinkedList &); #ifdef Q_COMPILER_RVALUE_REFS diff --git a/src/corelib/tools/qlist.cpp b/src/corelib/tools/qlist.cpp index 6f8084c676..48617f0539 100644 --- a/src/corelib/tools/qlist.cpp +++ b/src/corelib/tools/qlist.cpp @@ -545,6 +545,14 @@ void **QListData::erase(void **xi) \since 5.2 */ +/*! \fn template template QList::QList(InputIterator first, InputIterator last) + \since 5.14 + + Constructs a QList with the contents in the iterator range [\a first, \a last). + + The value type of \c InputIterator must be convertible to \c T. +*/ + /*! \fn template QList QList::mid(int pos, int length) const diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 77d8df4a88..dfb8a8a4ab 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -169,9 +170,11 @@ public: inline void swap(QList &other) noexcept { qSwap(d, other.d); } #ifdef Q_COMPILER_INITIALIZER_LISTS inline QList(std::initializer_list args) - : d(const_cast(&QListData::shared_null)) - { reserve(int(args.size())); std::copy(args.begin(), args.end(), std::back_inserter(*this)); } + : QList(args.begin(), args.end()) {} #endif + template = true> + QList(InputIterator first, InputIterator last); + bool operator==(const QList &l) const; inline bool operator!=(const QList &l) const { return !(*this == l); } @@ -842,6 +845,15 @@ Q_OUTOFLINE_TEMPLATE QList::~QList() dealloc(d); } +template +template > +QList::QList(InputIterator first, InputIterator last) + : QList() +{ + QtPrivate::reserveIfForwardIterator(this, first, last); + std::copy(first, last, std::back_inserter(*this)); +} + template Q_OUTOFLINE_TEMPLATE bool QList::operator==(const QList &l) const { diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h index aa915f7ed1..7ae715d247 100644 --- a/src/corelib/tools/qset.h +++ b/src/corelib/tools/qset.h @@ -41,6 +41,8 @@ #define QSET_H #include +#include + #ifdef Q_COMPILER_INITIALIZER_LISTS #include #endif @@ -59,12 +61,16 @@ public: inline QSet() noexcept {} #ifdef Q_COMPILER_INITIALIZER_LISTS inline QSet(std::initializer_list list) - { - reserve(int(list.size())); - for (typename std::initializer_list::const_iterator it = list.begin(); it != list.end(); ++it) - insert(*it); - } + : QSet(list.begin(), list.end()) {} #endif + template = true> + inline QSet(InputIterator first, InputIterator last) + { + QtPrivate::reserveIfForwardIterator(this, first, last); + for (; first != last; ++first) + insert(*first); + } + // compiler-generated copy/move ctor/assignment operators are fine! // compiler-generated destructor is fine! diff --git a/src/corelib/tools/qset.qdoc b/src/corelib/tools/qset.qdoc index 48863f2399..2e7a5a29ce 100644 --- a/src/corelib/tools/qset.qdoc +++ b/src/corelib/tools/qset.qdoc @@ -113,6 +113,17 @@ compiled in C++11 mode. */ +/*! \fn template template QSet::QSet(InputIterator first, InputIterator last) + \since 5.14 + + Constructs a set with the contents in the iterator range [\a first, \a last). + + The value type of \c InputIterator must be convertible to \c T. + + \note If the range [\a first, \a last) contains duplicate elements, + the first one is retained. +*/ + /*! \fn template void QSet::swap(QSet &other) diff --git a/src/corelib/tools/qstringlist.cpp b/src/corelib/tools/qstringlist.cpp index cc6eaf8ad2..49247d66b8 100644 --- a/src/corelib/tools/qstringlist.cpp +++ b/src/corelib/tools/qstringlist.cpp @@ -847,5 +847,12 @@ int QtPrivate::QStringList_removeDuplicates(QStringList *that) lists. */ + /*! \fn template QStringList::QStringList(InputIterator first, InputIterator last) + \since 5.14 + + Constructs a QStringList with the contents in the iterator range [\a first, \a last). + + The value type of \c InputIterator must be convertible to \c QString. + */ QT_END_NAMESPACE diff --git a/src/corelib/tools/qstringlist.h b/src/corelib/tools/qstringlist.h index 6387161269..5ad01a0658 100644 --- a/src/corelib/tools/qstringlist.h +++ b/src/corelib/tools/qstringlist.h @@ -44,6 +44,7 @@ #define QSTRINGLIST_H #include +#include #include #include #include @@ -109,6 +110,9 @@ public: #ifdef Q_COMPILER_INITIALIZER_LISTS inline QStringList(std::initializer_list args) : QList(args) { } #endif + template = true> + inline QStringList(InputIterator first, InputIterator last) + : QList(first, last) { } QStringList &operator=(const QList &other) { QList::operator=(other); return *this; } diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index c03fbb2218..c81af68593 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -71,13 +72,19 @@ public: #ifdef Q_COMPILER_INITIALIZER_LISTS QVarLengthArray(std::initializer_list args) - : a(Prealloc), s(0), ptr(reinterpret_cast(array)) + : QVarLengthArray(args.begin(), args.end()) { - if (args.size()) - append(args.begin(), int(args.size())); } #endif + template = true> + inline QVarLengthArray(InputIterator first, InputIterator last) + : QVarLengthArray() + { + QtPrivate::reserveIfForwardIterator(this, first, last); + std::copy(first, last, std::back_inserter(*this)); + } + inline ~QVarLengthArray() { if (QTypeInfo::isComplex) { T *i = ptr + s; diff --git a/src/corelib/tools/qvarlengtharray.qdoc b/src/corelib/tools/qvarlengtharray.qdoc index bc8df82517..80769e3769 100644 --- a/src/corelib/tools/qvarlengtharray.qdoc +++ b/src/corelib/tools/qvarlengtharray.qdoc @@ -110,6 +110,14 @@ lists. */ +/*! \fn template template QVarLengthArray::QVarLengthArray(InputIterator first, InputIterator last) + \since 5.14 + + Constructs an array with the contents in the iterator range [\a first, \a last). + + The value type of \c InputIterator must be convertible to \c T. +*/ + /*! \fn template QVarLengthArray::~QVarLengthArray() diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 096c369e51..6cbf794c6c 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -81,6 +82,9 @@ public: inline QVector(std::initializer_list args); QVector &operator=(std::initializer_list args); #endif + template = true> + inline QVector(InputIterator first, InputIterator last); + bool operator==(const QVector &v) const; inline bool operator!=(const QVector &v) const { return !(*this == v); } @@ -557,6 +561,15 @@ QT_WARNING_POP # endif // Q_CC_MSVC #endif // Q_COMPILER_INITIALIZER_LISTS +template +template > +QVector::QVector(InputIterator first, InputIterator last) + : QVector() +{ + QtPrivate::reserveIfForwardIterator(this, first, last); + std::copy(first, last, std::back_inserter(*this)); +} + template void QVector::freeData(Data *x) { diff --git a/src/corelib/tools/qvector.qdoc b/src/corelib/tools/qvector.qdoc index 69bbb5f9a2..cb47d36356 100644 --- a/src/corelib/tools/qvector.qdoc +++ b/src/corelib/tools/qvector.qdoc @@ -243,6 +243,13 @@ lists. */ +/*! \fn template template QVector::QVector(InputIterator first, InputIterator last) + \since 5.14 + + Constructs a vector with the contents in the iterator range [\a first, \a last). + + The value type of \c InputIterator must be convertible to \c T. +*/ /*! \fn template QVector::~QVector() diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri index 995bab694e..5dcb6c9ee0 100644 --- a/src/corelib/tools/tools.pri +++ b/src/corelib/tools/tools.pri @@ -18,6 +18,7 @@ HEADERS += \ tools/qcollator.h \ tools/qcollator_p.h \ tools/qcontainerfwd.h \ + tools/qcontainertools_impl.h \ tools/qcryptographichash.h \ tools/qdatetime.h \ tools/qdatetime_p.h \ diff --git a/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp b/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp index 3b8111f1a3..196276c52f 100644 --- a/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp +++ b/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp @@ -34,13 +34,375 @@ #include "qstring.h" #include "qvarlengtharray.h" #include "qvector.h" +#include "qdebug.h" +#include +#include #include // for reference +#include +#include + +// MSVC has these containers from the Standard Library, but it lacks +// a __has_include mechanism (that we need to use for other stdlibs). +// For the sake of increasing our test coverage, work around the issue. + +#ifdef Q_CC_MSVC +#define COMPILER_HAS_STDLIB_INCLUDE(x) 1 +#else +#define COMPILER_HAS_STDLIB_INCLUDE(x) QT_HAS_INCLUDE(x) +#endif + +#if COMPILER_HAS_STDLIB_INCLUDE() +#include +#endif +#if COMPILER_HAS_STDLIB_INCLUDE() +#include +#endif + +struct Movable +{ + explicit Movable(int i = 0) Q_DECL_NOTHROW + : i(i) + { + ++instanceCount; + } + + Movable(const Movable &m) + : i(m.i) + { + ++instanceCount; + } + + ~Movable() + { + --instanceCount; + } + + int i; + static int instanceCount; +}; + +int Movable::instanceCount = 0; +bool operator==(Movable lhs, Movable rhs) Q_DECL_NOTHROW { return lhs.i == rhs.i; } +bool operator!=(Movable lhs, Movable rhs) Q_DECL_NOTHROW { return lhs.i != rhs.i; } +bool operator<(Movable lhs, Movable rhs) Q_DECL_NOTHROW { return lhs.i < rhs.i; } + +uint qHash(Movable m, uint seed = 0) Q_DECL_NOTHROW { return qHash(m.i, seed); } +QDebug &operator<<(QDebug &d, Movable m) +{ + const QDebugStateSaver saver(d); + return d.nospace() << "Movable(" << m.i << ")"; +} + +QT_BEGIN_NAMESPACE +Q_DECLARE_TYPEINFO(Movable, Q_MOVABLE_TYPE); +QT_END_NAMESPACE + +struct Complex +{ + explicit Complex(int i = 0) Q_DECL_NOTHROW + : i(i) + { + ++instanceCount; + } + + Complex(const Complex &c) + : i(c.i) + { + ++instanceCount; + } + + ~Complex() + { + --instanceCount; + } + + int i; + static int instanceCount; +}; + +int Complex::instanceCount = 0; +bool operator==(Complex lhs, Complex rhs) Q_DECL_NOTHROW { return lhs.i == rhs.i; } +bool operator!=(Complex lhs, Complex rhs) Q_DECL_NOTHROW { return lhs.i != rhs.i; } +bool operator<(Complex lhs, Complex rhs) Q_DECL_NOTHROW { return lhs.i < rhs.i; } + +uint qHash(Complex c, uint seed = 0) Q_DECL_NOTHROW { return qHash(c.i, seed); } +QDebug &operator<<(QDebug &d, Complex c) +{ + const QDebugStateSaver saver(d); + return d.nospace() << "Complex(" << c.i << ")"; +} + + +struct DuplicateStrategyTestType +{ + explicit DuplicateStrategyTestType(int i = 0) Q_DECL_NOTHROW + : i(i), + j(++counter) + { + } + + int i; + int j; + + static int counter; +}; + +int DuplicateStrategyTestType::counter = 0; + +// only look at the i member, not j. j allows us to identify which instance +// gets inserted in containers that don't allow for duplicates +bool operator==(DuplicateStrategyTestType lhs, DuplicateStrategyTestType rhs) Q_DECL_NOTHROW +{ + return lhs.i == rhs.i; +} + +bool operator!=(DuplicateStrategyTestType lhs, DuplicateStrategyTestType rhs) Q_DECL_NOTHROW +{ + return lhs.i != rhs.i; +} + +bool operator<(DuplicateStrategyTestType lhs, DuplicateStrategyTestType rhs) Q_DECL_NOTHROW +{ + return lhs.i < rhs.i; +} + +uint qHash(DuplicateStrategyTestType c, uint seed = 0) Q_DECL_NOTHROW +{ + return qHash(c.i, seed); +} + +bool reallyEqual(DuplicateStrategyTestType lhs, DuplicateStrategyTestType rhs) Q_DECL_NOTHROW +{ + return lhs.i == rhs.i && lhs.j == rhs.j; +} + +QDebug &operator<<(QDebug &d, DuplicateStrategyTestType c) +{ + const QDebugStateSaver saver(d); + return d.nospace() << "DuplicateStrategyTestType(" << c.i << "," << c.j << ")"; +} + + +namespace std { +template<> +struct hash +{ + std::size_t operator()(Movable m) const Q_DECL_NOTHROW + { + return hash()(m.i); + } +}; + +template<> +struct hash +{ + std::size_t operator()(Complex m) const Q_DECL_NOTHROW + { + return hash()(m.i); + } +}; + +template<> +struct hash +{ + std::size_t operator()(DuplicateStrategyTestType m) const Q_DECL_NOTHROW + { + return hash()(m.i); + } +}; +} + +// work around the fact that QVarLengthArray has a non-type +// template parameter, and that breaks non_associative_container_duplicates_strategy +template +class VarLengthArray : public QVarLengthArray +{ +public: +#ifdef Q_COMPILER_INHERITING_CONSTRUCTORS + using QVarLengthArray::QVarLengthArray; +#else + template + VarLengthArray(InputIterator first, InputIterator last) + : QVarLengthArray(first, last) + { + } + +#ifdef Q_COMPILER_INITIALIZER_LISTS + VarLengthArray(std::initializer_list args) + : QVarLengthArray(args) + { + } +#endif +#endif +}; class tst_ContainerApiSymmetry : public QObject { Q_OBJECT + int m_movableInstanceCount; + int m_complexInstanceCount; + +private Q_SLOTS: + void init(); + void cleanup(); + +private: + template + void ranged_ctor_non_associative_impl() const; + + template class Container> + void non_associative_container_duplicates_strategy() const; + +private Q_SLOTS: + // non associative + void ranged_ctor_std_vector_int() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_std_vector_char() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_std_vector_QChar() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_std_vector_Movable() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_std_vector_Complex() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_std_vector_duplicates_strategy() { non_associative_container_duplicates_strategy(); } + + void ranged_ctor_QVector_int() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_QVector_char() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_QVector_QChar() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_QVector_Movable() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_QVector_Complex() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_QVector_duplicates_strategy() { non_associative_container_duplicates_strategy(); } + + void ranged_ctor_QVarLengthArray_int() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_QVarLengthArray_Movable() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_QVarLengthArray_Complex() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_QVarLengthArray_duplicates_strategy() { non_associative_container_duplicates_strategy(); } // note the VarLengthArray passed + + void ranged_ctor_QList_int() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_QList_Movable() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_QList_Complex() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_QList_duplicates_strategy() { non_associative_container_duplicates_strategy(); } + + void ranged_ctor_std_list_int() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_std_list_Movable() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_std_list_Complex() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_std_list_duplicates_strategy() { non_associative_container_duplicates_strategy(); } + + void ranged_ctor_std_forward_list_int() { +#if COMPILER_HAS_STDLIB_INCLUDE() + ranged_ctor_non_associative_impl>(); +#else + QSKIP(" is needed for this test"); +#endif + } + + void ranged_ctor_std_forward_list_Movable() { +#if COMPILER_HAS_STDLIB_INCLUDE() + ranged_ctor_non_associative_impl>(); +#else + QSKIP(" is needed for this test"); +#endif + } + + void ranged_ctor_std_forward_list_Complex() { +#if COMPILER_HAS_STDLIB_INCLUDE() + ranged_ctor_non_associative_impl>(); +#else + QSKIP(" is needed for this test"); +#endif + } + + void ranged_ctor_std_forward_list_duplicates_strategy() { +#if COMPILER_HAS_STDLIB_INCLUDE() + non_associative_container_duplicates_strategy(); +#else + QSKIP(" is needed for this test"); +#endif + } + + void ranged_ctor_QLinkedList_int() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_QLinkedList_Movable() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_QLinkedList_Complex() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_QLinkedList_duplicates_strategy() { non_associative_container_duplicates_strategy(); } + + void ranged_ctor_std_set_int() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_std_set_Movable() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_std_set_Complex() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_std_set_duplicates_strategy() { non_associative_container_duplicates_strategy(); } + + void ranged_ctor_std_multiset_int() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_std_multiset_Movable() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_std_multiset_Complex() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_std_multiset_duplicates_strategy() { non_associative_container_duplicates_strategy(); } + + void ranged_ctor_std_unordered_set_int() { +#if COMPILER_HAS_STDLIB_INCLUDE() + ranged_ctor_non_associative_impl>(); +#else + QSKIP(" is needed for this test"); +#endif + } + + void ranged_ctor_std_unordered_set_Movable() { +#if COMPILER_HAS_STDLIB_INCLUDE() + ranged_ctor_non_associative_impl>(); +#else + QSKIP(" is needed for this test"); +#endif + } + + void ranged_ctor_std_unordered_set_Complex() { +#if COMPILER_HAS_STDLIB_INCLUDE() + ranged_ctor_non_associative_impl>(); +#else + QSKIP(" is needed for this test"); +#endif + } + + void ranged_ctor_unordered_set_duplicates_strategy() { +#if COMPILER_HAS_STDLIB_INCLUDE() + non_associative_container_duplicates_strategy(); +#else + QSKIP(" is needed for this test"); +#endif + } + + + void ranged_ctor_std_unordered_multiset_int() { +#if COMPILER_HAS_STDLIB_INCLUDE() + ranged_ctor_non_associative_impl>(); +#else + QSKIP(" is needed for this test"); +#endif + } + + void ranged_ctor_std_unordered_multiset_Movable() { +#if COMPILER_HAS_STDLIB_INCLUDE() + ranged_ctor_non_associative_impl>(); +#else + QSKIP(" is needed for this test"); +#endif + } + + void ranged_ctor_std_unordered_multiset_Complex() { +#if COMPILER_HAS_STDLIB_INCLUDE() + ranged_ctor_non_associative_impl>(); +#else + QSKIP(" is needed for this test"); +#endif + } + + void ranged_ctor_std_unordered_multiset_duplicates_strategy() { +#if COMPILER_HAS_STDLIB_INCLUDE() + non_associative_container_duplicates_strategy(); +#else + QSKIP(" is needed for this test"); +#endif + } + + void ranged_ctor_QSet_int() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_QSet_Movable() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_QSet_Complex() { ranged_ctor_non_associative_impl>(); } + void ranged_ctor_QSet_duplicates_strategy() { non_associative_container_duplicates_strategy(); } + private: template void front_back_impl() const; @@ -58,6 +420,237 @@ private Q_SLOTS: void front_back_QByteArray() { front_back_impl(); } }; +void tst_ContainerApiSymmetry::init() +{ + m_movableInstanceCount = Movable::instanceCount; + m_complexInstanceCount = Complex::instanceCount; +} + +void tst_ContainerApiSymmetry::cleanup() +{ + // very simple leak check + QCOMPARE(Movable::instanceCount, m_movableInstanceCount); + QCOMPARE(Complex::instanceCount, m_complexInstanceCount); +} + +template +Container createContainerReference() +{ + using V = typename Container::value_type; + + return {V(0), V(1), V(2), V(0)}; +} + +template +void tst_ContainerApiSymmetry::ranged_ctor_non_associative_impl() const +{ + using V = typename Container::value_type; + + // the double V(0) is deliberate + const auto reference = createContainerReference(); + + // plain array + const V values1[] = { V(0), V(1), V(2), V(0) }; + + const Container c1(values1, values1 + sizeof(values1)/sizeof(values1[0])); + + // from QList + QList l2; + l2 << V(0) << V(1) << V(2) << V(0); + + const Container c2a(l2.begin(), l2.end()); + const Container c2b(l2.cbegin(), l2.cend()); + + // from std::list + std::list l3; + l3.push_back(V(0)); + l3.push_back(V(1)); + l3.push_back(V(2)); + l3.push_back(V(0)); + const Container c3a(l3.begin(), l3.end()); + + // from const std::list + const std::list l3c = l3; + const Container c3b(l3c.begin(), l3c.end()); + + // from itself + const Container c4(reference.begin(), reference.end()); + + QCOMPARE(c1, reference); + QCOMPARE(c2a, reference); + QCOMPARE(c2b, reference); + QCOMPARE(c3a, reference); + QCOMPARE(c3b, reference); + QCOMPARE(c4, reference); +} + + +// type traits for detecting whether a non-associative container +// accepts duplicated values, and if it doesn't, whether construction/insertion +// prefer the new values (overwriting) or the old values (rejecting) + +struct ContainerAcceptsDuplicateValues {}; +struct ContainerOverwritesDuplicateValues {}; +struct ContainerRejectsDuplicateValues {}; + +template +struct ContainerDuplicatedValuesStrategy {}; + +template +struct ContainerDuplicatedValuesStrategy> : ContainerAcceptsDuplicateValues {}; + +template +struct ContainerDuplicatedValuesStrategy> : ContainerAcceptsDuplicateValues {}; + +template +struct ContainerDuplicatedValuesStrategy> : ContainerAcceptsDuplicateValues {}; + +template +struct ContainerDuplicatedValuesStrategy> : ContainerAcceptsDuplicateValues {}; + +template +struct ContainerDuplicatedValuesStrategy> : ContainerAcceptsDuplicateValues {}; + +template +struct ContainerDuplicatedValuesStrategy> : ContainerAcceptsDuplicateValues {}; + +#if COMPILER_HAS_STDLIB_INCLUDE() +template +struct ContainerDuplicatedValuesStrategy> : ContainerAcceptsDuplicateValues {}; +#endif + +template +struct ContainerDuplicatedValuesStrategy> : ContainerAcceptsDuplicateValues {}; + +// assuming https://cplusplus.github.io/LWG/lwg-active.html#2844 resolution +template +struct ContainerDuplicatedValuesStrategy> : ContainerRejectsDuplicateValues {}; + +template +struct ContainerDuplicatedValuesStrategy> : ContainerAcceptsDuplicateValues {}; + +#if COMPILER_HAS_STDLIB_INCLUDE() +// assuming https://cplusplus.github.io/LWG/lwg-active.html#2844 resolution +template +struct ContainerDuplicatedValuesStrategy> : ContainerRejectsDuplicateValues {}; + +template +struct ContainerDuplicatedValuesStrategy> : ContainerAcceptsDuplicateValues {}; +#endif + +template +struct ContainerDuplicatedValuesStrategy> : ContainerRejectsDuplicateValues {}; + +#if defined(Q_COMPILER_INITIALIZER_LISTS) +template +void non_associative_container_check_duplicates_impl(const std::initializer_list &reference, const Container &c, ContainerAcceptsDuplicateValues) +{ + // do a deep check for equality, not ordering + QVERIFY(std::distance(reference.begin(), reference.end()) == std::distance(c.begin(), c.end())); + QVERIFY(std::is_permutation(reference.begin(), reference.end(), c.begin(), &reallyEqual)); +} + +enum class IterationOnReference +{ + ForwardIteration, + ReverseIteration +}; + +template +void non_associative_container_check_duplicates_impl_no_duplicates(const std::initializer_list &reference, const Container &c, IterationOnReference ior) +{ + std::vector valuesAlreadySeen; + + // iterate on reference forward or backwards, depending on ior. this will give + // us the expected semantics when checking for duplicated values into c + auto it = [&reference, ior]() { + switch (ior) { + case IterationOnReference::ForwardIteration: return reference.begin(); + case IterationOnReference::ReverseIteration: return reference.end() - 1; + }; + return std::initializer_list::const_iterator(); + }(); + + const auto &end = [&reference, ior]() { + switch (ior) { + case IterationOnReference::ForwardIteration: return reference.end(); + case IterationOnReference::ReverseIteration: return reference.begin() - 1; + }; + return std::initializer_list::const_iterator(); + }(); + + while (it != end) { + const auto &value = *it; + + // check that there is indeed the same value in the container (using operator==) + const auto &valueInContainerIterator = std::find(c.begin(), c.end(), value); + QVERIFY(valueInContainerIterator != c.end()); + QVERIFY(value == *valueInContainerIterator); + + // if the value is a duplicate, we don't expect to find it in the container + // (when doing a deep comparison). otherwise it should be there + + const auto &valuesAlreadySeenIterator = std::find(valuesAlreadySeen.cbegin(), valuesAlreadySeen.cend(), value); + const bool valueIsDuplicated = (valuesAlreadySeenIterator != valuesAlreadySeen.cend()); + + const auto &reallyEqualCheck = [&value](const DuplicateStrategyTestType &v) { return reallyEqual(value, v); }; + QCOMPARE(std::find_if(c.begin(), c.end(), reallyEqualCheck) == c.end(), valueIsDuplicated); + + valuesAlreadySeen.push_back(value); + + switch (ior) { + case IterationOnReference::ForwardIteration: + ++it; + break; + case IterationOnReference::ReverseIteration: + --it; + break; + }; + } + +} + +template +void non_associative_container_check_duplicates_impl(const std::initializer_list &reference, const Container &c, ContainerRejectsDuplicateValues) +{ + non_associative_container_check_duplicates_impl_no_duplicates(reference, c, IterationOnReference::ForwardIteration); +} + +template +void non_associative_container_check_duplicates_impl(const std::initializer_list &reference, const Container &c, ContainerOverwritesDuplicateValues) +{ + non_associative_container_check_duplicates_impl_no_duplicates(reference, c, IterationOnReference::ReverseIteration); +} + +template +void non_associative_container_check_duplicates(const std::initializer_list &reference, const Container &c) +{ + non_associative_container_check_duplicates_impl(reference, c, ContainerDuplicatedValuesStrategy()); +} + +template class Container> +void tst_ContainerApiSymmetry::non_associative_container_duplicates_strategy() const +{ + // first and last are "duplicates" -- they compare equal for operator==, + // but they differ when using reallyEqual + const std::initializer_list reference{ DuplicateStrategyTestType{0}, + DuplicateStrategyTestType{1}, + DuplicateStrategyTestType{2}, + DuplicateStrategyTestType{0} }; + Container c1{reference}; + non_associative_container_check_duplicates(reference, c1); + + Container c2{reference.begin(), reference.end()}; + non_associative_container_check_duplicates(reference, c2); +} +#else +template class Container> +void tst_ContainerApiSymmetry::non_associative_container_duplicates_strategy() const +{ + QSKIP("Test requires a better compiler"); +} +#endif // Q_COMPILER_INITIALIZER_LISTS + template Container make(int size) { diff --git a/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp b/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp index 42bdf62a93..37368c3dfc 100644 --- a/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp +++ b/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp @@ -30,13 +30,17 @@ #include #include #include +#include #include +#include + class tst_QStringList : public QObject { Q_OBJECT private slots: + void constructors(); void sort(); void filter(); void replaceInStrings(); @@ -66,6 +70,39 @@ private slots: extern const char email[]; +void tst_QStringList::constructors() +{ + { + QStringList list; + QVERIFY(list.isEmpty()); + QCOMPARE(list.size(), 0); + QVERIFY(list == QStringList()); + } + { + QString str = "abc"; + QStringList list(str); + QVERIFY(!list.isEmpty()); + QCOMPARE(list.size(), 1); + QCOMPARE(list.at(0), str); + } + { + QStringList list{ "a", "b", "c" }; + QVERIFY(!list.isEmpty()); + QCOMPARE(list.size(), 3); + QCOMPARE(list.at(0), "a"); + QCOMPARE(list.at(1), "b"); + QCOMPARE(list.at(2), "c"); + } + { + const QVector reference{ "a", "b", "c" }; + QCOMPARE(reference.size(), 3); + + QStringList list(reference.cbegin(), reference.cend()); + QCOMPARE(list.size(), reference.size()); + QVERIFY(std::equal(list.cbegin(), list.cend(), reference.cbegin())); + } +} + void tst_QStringList::indexOf_regExp() { QStringList list; From dea94de304e92f162ed0f1d4a30f03717a19b198 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 18 Dec 2017 07:54:00 +0100 Subject: [PATCH 191/292] Import MD4C Markdown parser into 3rdparty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It has an MIT license and will be used to add Markdown (CommonMark) support to QTextDocument. Currently this is version 0.3.0 RC plus a few more patches. [ChangeLog][Third-Party Code] Qt Gui: Added md4c markdown parser to src/3rdparty/md4c (MIT licensed). Change-Id: Ie74373c89f2a30ba76ee728aee5e1ca166829f44 Reviewed-by: Lisandro Damián Nicanor Pérez Meyer Reviewed-by: Lars Knoll Reviewed-by: Gatis Paeglis --- src/3rdparty/md4c.pri | 3 + src/3rdparty/md4c/LICENSE.md | 22 + src/3rdparty/md4c/md4c.c | 6016 +++++++++++++++++++++++++ src/3rdparty/md4c/md4c.h | 359 ++ src/3rdparty/md4c/qt_attribution.json | 15 + 5 files changed, 6415 insertions(+) create mode 100644 src/3rdparty/md4c.pri create mode 100644 src/3rdparty/md4c/LICENSE.md create mode 100644 src/3rdparty/md4c/md4c.c create mode 100644 src/3rdparty/md4c/md4c.h create mode 100644 src/3rdparty/md4c/qt_attribution.json diff --git a/src/3rdparty/md4c.pri b/src/3rdparty/md4c.pri new file mode 100644 index 0000000000..e0150dc6ed --- /dev/null +++ b/src/3rdparty/md4c.pri @@ -0,0 +1,3 @@ +INCLUDEPATH += $$PWD/md4c +HEADERS += $$PWD/md4c/md4c.h +SOURCES += $$PWD/md4c/md4c.c diff --git a/src/3rdparty/md4c/LICENSE.md b/src/3rdparty/md4c/LICENSE.md new file mode 100644 index 0000000000..d58ef9341d --- /dev/null +++ b/src/3rdparty/md4c/LICENSE.md @@ -0,0 +1,22 @@ + +# The MIT License (MIT) + +Copyright © 2016-2019 Martin Mitáš + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the “Software”), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. diff --git a/src/3rdparty/md4c/md4c.c b/src/3rdparty/md4c/md4c.c new file mode 100644 index 0000000000..4c0ad5c0fc --- /dev/null +++ b/src/3rdparty/md4c/md4c.c @@ -0,0 +1,6016 @@ +/* + * MD4C: Markdown parser for C + * (http://github.com/mity/md4c) + * + * Copyright (c) 2016-2019 Martin Mitas + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "md4c.h" + +#include +#include +#include + + +/***************************** + *** Miscellaneous Stuff *** + *****************************/ + +#ifdef _MSC_VER + /* MSVC does not understand "inline" when building as pure C (not C++). + * However it understands "__inline" */ + #ifndef __cplusplus + #define inline __inline + #endif +#endif + +#ifdef _T + #undef _T +#endif +#if defined MD4C_USE_UTF16 + #define _T(x) L##x +#else + #define _T(x) x +#endif + +/* Misc. macros. */ +#define SIZEOF_ARRAY(a) (sizeof(a) / sizeof(a[0])) + +#define STRINGIZE_(x) #x +#define STRINGIZE(x) STRINGIZE_(x) + +#ifndef TRUE + #define TRUE 1 + #define FALSE 0 +#endif + + +/************************ + *** Internal Types *** + ************************/ + +/* These are omnipresent so lets save some typing. */ +#define CHAR MD_CHAR +#define SZ MD_SIZE +#define OFF MD_OFFSET + +typedef struct MD_MARK_tag MD_MARK; +typedef struct MD_BLOCK_tag MD_BLOCK; +typedef struct MD_CONTAINER_tag MD_CONTAINER; +typedef struct MD_REF_DEF_tag MD_REF_DEF; + + +/* During analyzes of inline marks, we need to manage some "mark chains", + * of (yet unresolved) openers. This structure holds start/end of the chain. + * The chain internals are then realized through MD_MARK::prev and ::next. + */ +typedef struct MD_MARKCHAIN_tag MD_MARKCHAIN; +struct MD_MARKCHAIN_tag { + int head; /* Index of first mark in the chain, or -1 if empty. */ + int tail; /* Index of last mark in the chain, or -1 if empty. */ +}; + +/* Context propagated through all the parsing. */ +typedef struct MD_CTX_tag MD_CTX; +struct MD_CTX_tag { + /* Immutable stuff (parameters of md_parse()). */ + const CHAR* text; + SZ size; + MD_PARSER parser; + void* userdata; + + /* Helper temporary growing buffer. */ + CHAR* buffer; + unsigned alloc_buffer; + + /* Reference definitions. */ + MD_REF_DEF* ref_defs; + int n_ref_defs; + int alloc_ref_defs; + void** ref_def_hashtable; + int ref_def_hashtable_size; + + /* Stack of inline/span markers. + * This is only used for parsing a single block contents but by storing it + * here we may reuse the stack for subsequent blocks; i.e. we have fewer + * (re)allocations. */ + MD_MARK* marks; + int n_marks; + int alloc_marks; + +#if defined MD4C_USE_UTF16 + char mark_char_map[128]; +#else + char mark_char_map[256]; +#endif + + /* For resolving of inline spans. */ + MD_MARKCHAIN mark_chains[8]; +#define PTR_CHAIN ctx->mark_chains[0] +#define TABLECELLBOUNDARIES ctx->mark_chains[1] +#define BACKTICK_OPENERS ctx->mark_chains[2] +#define LOWERTHEN_OPENERS ctx->mark_chains[3] +#define ASTERISK_OPENERS ctx->mark_chains[4] +#define UNDERSCORE_OPENERS ctx->mark_chains[5] +#define TILDE_OPENERS ctx->mark_chains[6] +#define BRACKET_OPENERS ctx->mark_chains[7] +#define OPENERS_CHAIN_FIRST 2 +#define OPENERS_CHAIN_LAST 7 + + int n_table_cell_boundaries; + + /* For resolving links. */ + int unresolved_link_head; + int unresolved_link_tail; + + /* For block analysis. + * Notes: + * -- It holds MD_BLOCK as well as MD_LINE structures. After each + * MD_BLOCK, its (multiple) MD_LINE(s) follow. + * -- For MD_BLOCK_HTML and MD_BLOCK_CODE, MD_VERBATIMLINE(s) are used + * instead of MD_LINE(s). + */ + void* block_bytes; + MD_BLOCK* current_block; + int n_block_bytes; + int alloc_block_bytes; + + /* For container block analysis. */ + MD_CONTAINER* containers; + int n_containers; + int alloc_containers; + + int last_line_has_list_loosening_effect; + int last_list_item_starts_with_two_blank_lines; + + /* Minimal indentation to call the block "indented code block". */ + unsigned code_indent_offset; + + /* Contextual info for line analysis. */ + SZ code_fence_length; /* For checking closing fence length. */ + int html_block_type; /* For checking closing raw HTML condition. */ +}; + +typedef enum MD_LINETYPE_tag MD_LINETYPE; +enum MD_LINETYPE_tag { + MD_LINE_BLANK, + MD_LINE_HR, + MD_LINE_ATXHEADER, + MD_LINE_SETEXTHEADER, + MD_LINE_SETEXTUNDERLINE, + MD_LINE_INDENTEDCODE, + MD_LINE_FENCEDCODE, + MD_LINE_HTML, + MD_LINE_TEXT, + MD_LINE_TABLE, + MD_LINE_TABLEUNDERLINE +}; + +typedef struct MD_LINE_ANALYSIS_tag MD_LINE_ANALYSIS; +struct MD_LINE_ANALYSIS_tag { + MD_LINETYPE type : 16; + unsigned data : 16; + OFF beg; + OFF end; + unsigned indent; /* Indentation level. */ +}; + +typedef struct MD_LINE_tag MD_LINE; +struct MD_LINE_tag { + OFF beg; + OFF end; +}; + +typedef struct MD_VERBATIMLINE_tag MD_VERBATIMLINE; +struct MD_VERBATIMLINE_tag { + OFF beg; + OFF end; + OFF indent; +}; + + +/******************* + *** Debugging *** + *******************/ + +#define MD_LOG(msg) \ + do { \ + if(ctx->parser.debug_log != NULL) \ + ctx->parser.debug_log((msg), ctx->userdata); \ + } while(0) + +#ifdef DEBUG + #define MD_ASSERT(cond) \ + do { \ + if(!(cond)) { \ + MD_LOG(__FILE__ ":" STRINGIZE(__LINE__) ": " \ + "Assertion '" STRINGIZE(cond) "' failed."); \ + exit(1); \ + } \ + } while(0) + + #define MD_UNREACHABLE() MD_ASSERT(1 == 0) +#else + #ifdef __GNUC__ + #define MD_ASSERT(cond) do { if(!(cond)) __builtin_unreachable(); } while(0) + #define MD_UNREACHABLE() do { __builtin_unreachable(); } while(0) + #elif defined _MSC_VER && _MSC_VER > 120 + #define MD_ASSERT(cond) do { __assume(cond); } while(0) + #define MD_UNREACHABLE() do { __assume(0); } while(0) + #else + #define MD_ASSERT(cond) do {} while(0) + #define MD_UNREACHABLE() do {} while(0) + #endif +#endif + + +/***************** + *** Helpers *** + *****************/ + +/* Character accessors. */ +#define CH(off) (ctx->text[(off)]) +#define STR(off) (ctx->text + (off)) + +/* Character classification. + * Note we assume ASCII compatibility of code points < 128 here. */ +#define ISIN_(ch, ch_min, ch_max) ((ch_min) <= (unsigned)(ch) && (unsigned)(ch) <= (ch_max)) +#define ISANYOF_(ch, palette) (md_strchr((palette), (ch)) != NULL) +#define ISANYOF2_(ch, ch1, ch2) ((ch) == (ch1) || (ch) == (ch2)) +#define ISANYOF3_(ch, ch1, ch2, ch3) ((ch) == (ch1) || (ch) == (ch2) || (ch) == (ch3)) +#define ISASCII_(ch) ((unsigned)(ch) <= 127) +#define ISBLANK_(ch) (ISANYOF2_((ch), _T(' '), _T('\t'))) +#define ISNEWLINE_(ch) (ISANYOF2_((ch), _T('\r'), _T('\n'))) +#define ISWHITESPACE_(ch) (ISBLANK_(ch) || ISANYOF2_((ch), _T('\v'), _T('\f'))) +#define ISCNTRL_(ch) ((unsigned)(ch) <= 31 || (unsigned)(ch) == 127) +#define ISPUNCT_(ch) (ISIN_(ch, 33, 47) || ISIN_(ch, 58, 64) || ISIN_(ch, 91, 96) || ISIN_(ch, 123, 126)) +#define ISUPPER_(ch) (ISIN_(ch, _T('A'), _T('Z'))) +#define ISLOWER_(ch) (ISIN_(ch, _T('a'), _T('z'))) +#define ISALPHA_(ch) (ISUPPER_(ch) || ISLOWER_(ch)) +#define ISDIGIT_(ch) (ISIN_(ch, _T('0'), _T('9'))) +#define ISXDIGIT_(ch) (ISDIGIT_(ch) || ISIN_(ch, _T('A'), _T('F')) || ISIN_(ch, _T('a'), _T('f'))) +#define ISALNUM_(ch) (ISALPHA_(ch) || ISDIGIT_(ch)) + +#define ISANYOF(off, palette) ISANYOF_(CH(off), (palette)) +#define ISANYOF2(off, ch1, ch2) ISANYOF2_(CH(off), (ch1), (ch2)) +#define ISANYOF3(off, ch1, ch2, ch3) ISANYOF3_(CH(off), (ch1), (ch2), (ch3)) +#define ISASCII(off) ISASCII_(CH(off)) +#define ISBLANK(off) ISBLANK_(CH(off)) +#define ISNEWLINE(off) ISNEWLINE_(CH(off)) +#define ISWHITESPACE(off) ISWHITESPACE_(CH(off)) +#define ISCNTRL(off) ISCNTRL_(CH(off)) +#define ISPUNCT(off) ISPUNCT_(CH(off)) +#define ISUPPER(off) ISUPPER_(CH(off)) +#define ISLOWER(off) ISLOWER_(CH(off)) +#define ISALPHA(off) ISALPHA_(CH(off)) +#define ISDIGIT(off) ISDIGIT_(CH(off)) +#define ISXDIGIT(off) ISXDIGIT_(CH(off)) +#define ISALNUM(off) ISALNUM_(CH(off)) +static inline const CHAR* +md_strchr(const CHAR* str, CHAR ch) +{ + OFF i; + for(i = 0; str[i] != _T('\0'); i++) { + if(ch == str[i]) + return (str + i); + } + return NULL; +} + +/* Case insensitive check of string equality. */ +static inline int +md_ascii_case_eq(const CHAR* s1, const CHAR* s2, SZ n) +{ + OFF i; + for(i = 0; i < n; i++) { + CHAR ch1 = s1[i]; + CHAR ch2 = s2[i]; + + if(ISLOWER_(ch1)) + ch1 += ('A'-'a'); + if(ISLOWER_(ch2)) + ch2 += ('A'-'a'); + if(ch1 != ch2) + return FALSE; + } + return TRUE; +} + +static inline int +md_ascii_eq(const CHAR* s1, const CHAR* s2, SZ n) +{ + return memcmp(s1, s2, n * sizeof(CHAR)) == 0; +} + +static int +md_text_with_null_replacement(MD_CTX* ctx, MD_TEXTTYPE type, const CHAR* str, SZ size) +{ + OFF off = 0; + int ret = 0; + + while(1) { + while(off < size && str[off] != _T('\0')) + off++; + + if(off > 0) { + ret = ctx->parser.text(type, str, off, ctx->userdata); + if(ret != 0) + return ret; + + str += off; + size -= off; + off = 0; + } + + if(off >= size) + return 0; + + ret = ctx->parser.text(MD_TEXT_NULLCHAR, _T(""), 1, ctx->userdata); + if(ret != 0) + return ret; + off++; + } +} + + +#define MD_CHECK(func) \ + do { \ + ret = (func); \ + if(ret < 0) \ + goto abort; \ + } while(0) + + +#define MD_TEMP_BUFFER(sz) \ + do { \ + if(sz > ctx->alloc_buffer) { \ + CHAR* new_buffer; \ + SZ new_size = ((sz) + (sz) / 2 + 128) & ~127; \ + \ + new_buffer = realloc(ctx->buffer, new_size); \ + if(new_buffer == NULL) { \ + MD_LOG("realloc() failed."); \ + ret = -1; \ + goto abort; \ + } \ + \ + ctx->buffer = new_buffer; \ + ctx->alloc_buffer = new_size; \ + } \ + } while(0) + + +#define MD_ENTER_BLOCK(type, arg) \ + do { \ + ret = ctx->parser.enter_block((type), (arg), ctx->userdata); \ + if(ret != 0) { \ + MD_LOG("Aborted from enter_block() callback."); \ + goto abort; \ + } \ + } while(0) + +#define MD_LEAVE_BLOCK(type, arg) \ + do { \ + ret = ctx->parser.leave_block((type), (arg), ctx->userdata); \ + if(ret != 0) { \ + MD_LOG("Aborted from leave_block() callback."); \ + goto abort; \ + } \ + } while(0) + +#define MD_ENTER_SPAN(type, arg) \ + do { \ + ret = ctx->parser.enter_span((type), (arg), ctx->userdata); \ + if(ret != 0) { \ + MD_LOG("Aborted from enter_span() callback."); \ + goto abort; \ + } \ + } while(0) + +#define MD_LEAVE_SPAN(type, arg) \ + do { \ + ret = ctx->parser.leave_span((type), (arg), ctx->userdata); \ + if(ret != 0) { \ + MD_LOG("Aborted from leave_span() callback."); \ + goto abort; \ + } \ + } while(0) + +#define MD_TEXT(type, str, size) \ + do { \ + if(size > 0) { \ + ret = ctx->parser.text((type), (str), (size), ctx->userdata); \ + if(ret != 0) { \ + MD_LOG("Aborted from text() callback."); \ + goto abort; \ + } \ + } \ + } while(0) + +#define MD_TEXT_INSECURE(type, str, size) \ + do { \ + if(size > 0) { \ + ret = md_text_with_null_replacement(ctx, type, str, size); \ + if(ret != 0) { \ + MD_LOG("Aborted from text() callback."); \ + goto abort; \ + } \ + } \ + } while(0) + + + +/************************* + *** Unicode Support *** + *************************/ + +typedef struct MD_UNICODE_FOLD_INFO_tag MD_UNICODE_FOLD_INFO; +struct MD_UNICODE_FOLD_INFO_tag { + int codepoints[3]; + int n_codepoints; +}; + + +#if defined MD4C_USE_UTF16 || defined MD4C_USE_UTF8 + static int + md_is_unicode_whitespace__(int codepoint) + { + /* The ASCII ones are the most frequently used ones, so lets check them first. */ + if(codepoint <= 0x7f) + return ISWHITESPACE_(codepoint); + + /* Check for Unicode codepoints in Zs class above 127. */ + if(codepoint == 0x00a0 || codepoint == 0x1680) + return TRUE; + if(0x2000 <= codepoint && codepoint <= 0x200a) + return TRUE; + if(codepoint == 0x202f || codepoint == 0x205f || codepoint == 0x3000) + return TRUE; + + return FALSE; + } + + static int + md_unicode_cmp__(const void* p_codepoint_a, const void* p_codepoint_b) + { + return (*(const int*)p_codepoint_a - *(const int*)p_codepoint_b); + } + + static int + md_is_unicode_punct__(int codepoint) + { + /* non-ASCII (above 127) Unicode punctuation codepoints (classes + * Pc, Pd, Pe, Pf, Pi, Po, Ps). + * + * Warning: Keep the array sorted. + */ + static const int punct_list[] = { + 0x00a1, 0x00a7, 0x00ab, 0x00b6, 0x00b7, 0x00bb, 0x00bf, 0x037e, 0x0387, 0x055a, 0x055b, 0x055c, 0x055d, 0x055e, 0x055f, 0x0589, + 0x058a, 0x05be, 0x05c0, 0x05c3, 0x05c6, 0x05f3, 0x05f4, 0x0609, 0x060a, 0x060c, 0x060d, 0x061b, 0x061e, 0x061f, 0x066a, 0x066b, + 0x066c, 0x066d, 0x06d4, 0x0700, 0x0701, 0x0702, 0x0703, 0x0704, 0x0705, 0x0706, 0x0707, 0x0708, 0x0709, 0x070a, 0x070b, 0x070c, + 0x070d, 0x07f7, 0x07f8, 0x07f9, 0x0830, 0x0831, 0x0832, 0x0833, 0x0834, 0x0835, 0x0836, 0x0837, 0x0838, 0x0839, 0x083a, 0x083b, + 0x083c, 0x083d, 0x083e, 0x085e, 0x0964, 0x0965, 0x0970, 0x0af0, 0x0df4, 0x0e4f, 0x0e5a, 0x0e5b, 0x0f04, 0x0f05, 0x0f06, 0x0f07, + 0x0f08, 0x0f09, 0x0f0a, 0x0f0b, 0x0f0c, 0x0f0d, 0x0f0e, 0x0f0f, 0x0f10, 0x0f11, 0x0f12, 0x0f14, 0x0f3a, 0x0f3b, 0x0f3c, 0x0f3d, + 0x0f85, 0x0fd0, 0x0fd1, 0x0fd2, 0x0fd3, 0x0fd4, 0x0fd9, 0x0fda, 0x104a, 0x104b, 0x104c, 0x104d, 0x104e, 0x104f, 0x10fb, 0x1360, + 0x1361, 0x1362, 0x1363, 0x1364, 0x1365, 0x1366, 0x1367, 0x1368, 0x1400, 0x166d, 0x166e, 0x169b, 0x169c, 0x16eb, 0x16ec, 0x16ed, + 0x1735, 0x1736, 0x17d4, 0x17d5, 0x17d6, 0x17d8, 0x17d9, 0x17da, 0x1800, 0x1801, 0x1802, 0x1803, 0x1804, 0x1805, 0x1806, 0x1807, + 0x1808, 0x1809, 0x180a, 0x1944, 0x1945, 0x1a1e, 0x1a1f, 0x1aa0, 0x1aa1, 0x1aa2, 0x1aa3, 0x1aa4, 0x1aa5, 0x1aa6, 0x1aa8, 0x1aa9, + 0x1aaa, 0x1aab, 0x1aac, 0x1aad, 0x1b5a, 0x1b5b, 0x1b5c, 0x1b5d, 0x1b5e, 0x1b5f, 0x1b60, 0x1bfc, 0x1bfd, 0x1bfe, 0x1bff, 0x1c3b, + 0x1c3c, 0x1c3d, 0x1c3e, 0x1c3f, 0x1c7e, 0x1c7f, 0x1cc0, 0x1cc1, 0x1cc2, 0x1cc3, 0x1cc4, 0x1cc5, 0x1cc6, 0x1cc7, 0x1cd3, 0x2010, + 0x2011, 0x2012, 0x2013, 0x2014, 0x2015, 0x2016, 0x2017, 0x2018, 0x2019, 0x201a, 0x201b, 0x201c, 0x201d, 0x201e, 0x201f, 0x2020, + 0x2021, 0x2022, 0x2023, 0x2024, 0x2025, 0x2026, 0x2027, 0x2030, 0x2031, 0x2032, 0x2033, 0x2034, 0x2035, 0x2036, 0x2037, 0x2038, + 0x2039, 0x203a, 0x203b, 0x203c, 0x203d, 0x203e, 0x203f, 0x2040, 0x2041, 0x2042, 0x2043, 0x2045, 0x2046, 0x2047, 0x2048, 0x2049, + 0x204a, 0x204b, 0x204c, 0x204d, 0x204e, 0x204f, 0x2050, 0x2051, 0x2053, 0x2054, 0x2055, 0x2056, 0x2057, 0x2058, 0x2059, 0x205a, + 0x205b, 0x205c, 0x205d, 0x205e, 0x207d, 0x207e, 0x208d, 0x208e, 0x2308, 0x2309, 0x230a, 0x230b, 0x2329, 0x232a, 0x2768, 0x2769, + 0x276a, 0x276b, 0x276c, 0x276d, 0x276e, 0x276f, 0x2770, 0x2771, 0x2772, 0x2773, 0x2774, 0x2775, 0x27c5, 0x27c6, 0x27e6, 0x27e7, + 0x27e8, 0x27e9, 0x27ea, 0x27eb, 0x27ec, 0x27ed, 0x27ee, 0x27ef, 0x2983, 0x2984, 0x2985, 0x2986, 0x2987, 0x2988, 0x2989, 0x298a, + 0x298b, 0x298c, 0x298d, 0x298e, 0x298f, 0x2990, 0x2991, 0x2992, 0x2993, 0x2994, 0x2995, 0x2996, 0x2997, 0x2998, 0x29d8, 0x29d9, + 0x29da, 0x29db, 0x29fc, 0x29fd, 0x2cf9, 0x2cfa, 0x2cfb, 0x2cfc, 0x2cfe, 0x2cff, 0x2d70, 0x2e00, 0x2e01, 0x2e02, 0x2e03, 0x2e04, + 0x2e05, 0x2e06, 0x2e07, 0x2e08, 0x2e09, 0x2e0a, 0x2e0b, 0x2e0c, 0x2e0d, 0x2e0e, 0x2e0f, 0x2e10, 0x2e11, 0x2e12, 0x2e13, 0x2e14, + 0x2e15, 0x2e16, 0x2e17, 0x2e18, 0x2e19, 0x2e1a, 0x2e1b, 0x2e1c, 0x2e1d, 0x2e1e, 0x2e1f, 0x2e20, 0x2e21, 0x2e22, 0x2e23, 0x2e24, + 0x2e25, 0x2e26, 0x2e27, 0x2e28, 0x2e29, 0x2e2a, 0x2e2b, 0x2e2c, 0x2e2d, 0x2e2e, 0x2e30, 0x2e31, 0x2e32, 0x2e33, 0x2e34, 0x2e35, + 0x2e36, 0x2e37, 0x2e38, 0x2e39, 0x2e3a, 0x2e3b, 0x2e3c, 0x2e3d, 0x2e3e, 0x2e3f, 0x2e40, 0x2e41, 0x2e42, 0x2e43, 0x2e44, 0x3001, + 0x3002, 0x3003, 0x3008, 0x3009, 0x300a, 0x300b, 0x300c, 0x300d, 0x300e, 0x300f, 0x3010, 0x3011, 0x3014, 0x3015, 0x3016, 0x3017, + 0x3018, 0x3019, 0x301a, 0x301b, 0x301c, 0x301d, 0x301e, 0x301f, 0x3030, 0x303d, 0x30a0, 0x30fb, 0xa4fe, 0xa4ff, 0xa60d, 0xa60e, + 0xa60f, 0xa673, 0xa67e, 0xa6f2, 0xa6f3, 0xa6f4, 0xa6f5, 0xa6f6, 0xa6f7, 0xa874, 0xa875, 0xa876, 0xa877, 0xa8ce, 0xa8cf, 0xa8f8, + 0xa8f9, 0xa8fa, 0xa8fc, 0xa92e, 0xa92f, 0xa95f, 0xa9c1, 0xa9c2, 0xa9c3, 0xa9c4, 0xa9c5, 0xa9c6, 0xa9c7, 0xa9c8, 0xa9c9, 0xa9ca, + 0xa9cb, 0xa9cc, 0xa9cd, 0xa9de, 0xa9df, 0xaa5c, 0xaa5d, 0xaa5e, 0xaa5f, 0xaade, 0xaadf, 0xaaf0, 0xaaf1, 0xabeb, 0xfd3e, 0xfd3f, + 0xfe10, 0xfe11, 0xfe12, 0xfe13, 0xfe14, 0xfe15, 0xfe16, 0xfe17, 0xfe18, 0xfe19, 0xfe30, 0xfe31, 0xfe32, 0xfe33, 0xfe34, 0xfe35, + 0xfe36, 0xfe37, 0xfe38, 0xfe39, 0xfe3a, 0xfe3b, 0xfe3c, 0xfe3d, 0xfe3e, 0xfe3f, 0xfe40, 0xfe41, 0xfe42, 0xfe43, 0xfe44, 0xfe45, + 0xfe46, 0xfe47, 0xfe48, 0xfe49, 0xfe4a, 0xfe4b, 0xfe4c, 0xfe4d, 0xfe4e, 0xfe4f, 0xfe50, 0xfe51, 0xfe52, 0xfe54, 0xfe55, 0xfe56, + 0xfe57, 0xfe58, 0xfe59, 0xfe5a, 0xfe5b, 0xfe5c, 0xfe5d, 0xfe5e, 0xfe5f, 0xfe60, 0xfe61, 0xfe63, 0xfe68, 0xfe6a, 0xfe6b, 0xff01, + 0xff02, 0xff03, 0xff05, 0xff06, 0xff07, 0xff08, 0xff09, 0xff0a, 0xff0c, 0xff0d, 0xff0e, 0xff0f, 0xff1a, 0xff1b, 0xff1f, 0xff20, + 0xff3b, 0xff3c, 0xff3d, 0xff3f, 0xff5b, 0xff5d, 0xff5f, 0xff60, 0xff61, 0xff62, 0xff63, 0xff64, 0xff65, 0x10100, 0x10101, 0x10102, + 0x1039f, 0x103d0, 0x1056f, 0x10857, 0x1091f, 0x1093f, 0x10a50, 0x10a51, 0x10a52, 0x10a53, 0x10a54, 0x10a55, 0x10a56, 0x10a57, 0x10a58, 0x10a7f, + 0x10af0, 0x10af1, 0x10af2, 0x10af3, 0x10af4, 0x10af5, 0x10af6, 0x10b39, 0x10b3a, 0x10b3b, 0x10b3c, 0x10b3d, 0x10b3e, 0x10b3f, 0x10b99, 0x10b9a, + 0x10b9b, 0x10b9c, 0x11047, 0x11048, 0x11049, 0x1104a, 0x1104b, 0x1104c, 0x1104d, 0x110bb, 0x110bc, 0x110be, 0x110bf, 0x110c0, 0x110c1, 0x11140, + 0x11141, 0x11142, 0x11143, 0x11174, 0x11175, 0x111c5, 0x111c6, 0x111c7, 0x111c8, 0x111c9, 0x111cd, 0x111db, 0x111dd, 0x111de, 0x111df, 0x11238, + 0x11239, 0x1123a, 0x1123b, 0x1123c, 0x1123d, 0x112a9, 0x1144b, 0x1144c, 0x1144d, 0x1144e, 0x1144f, 0x1145b, 0x1145d, 0x114c6, 0x115c1, 0x115c2, + 0x115c3, 0x115c4, 0x115c5, 0x115c6, 0x115c7, 0x115c8, 0x115c9, 0x115ca, 0x115cb, 0x115cc, 0x115cd, 0x115ce, 0x115cf, 0x115d0, 0x115d1, 0x115d2, + 0x115d3, 0x115d4, 0x115d5, 0x115d6, 0x115d7, 0x11641, 0x11642, 0x11643, 0x11660, 0x11661, 0x11662, 0x11663, 0x11664, 0x11665, 0x11666, 0x11667, + 0x11668, 0x11669, 0x1166a, 0x1166b, 0x1166c, 0x1173c, 0x1173d, 0x1173e, 0x11c41, 0x11c42, 0x11c43, 0x11c44, 0x11c45, 0x11c70, 0x11c71, 0x12470, + 0x12471, 0x12472, 0x12473, 0x12474, 0x16a6e, 0x16a6f, 0x16af5, 0x16b37, 0x16b38, 0x16b39, 0x16b3a, 0x16b3b, 0x16b44, 0x1bc9f, 0x1da87, 0x1da88, + 0x1da89, 0x1da8a, 0x1da8b, 0x1e95e, 0x1e95f + }; + + /* The ASCII ones are the most frequently used ones, so lets check them first. */ + if(codepoint <= 0x7f) + return ISPUNCT_(codepoint); + + return (bsearch(&codepoint, punct_list, SIZEOF_ARRAY(punct_list), sizeof(int), md_unicode_cmp__) != NULL); + } + + static void + md_get_unicode_fold_info(int codepoint, MD_UNICODE_FOLD_INFO* info) + { + /* This maps single codepoint within a range to a single codepoint + * within an offseted range. */ + static const struct { + int min_codepoint; + int max_codepoint; + int offset; + } range_map[] = { + { 0x00c0, 0x00d6, 32 }, { 0x00d8, 0x00de, 32 }, { 0x0388, 0x038a, 37 }, { 0x0391, 0x03a1, 32 }, { 0x03a3, 0x03ab, 32 }, { 0x0400, 0x040f, 80 }, + { 0x0410, 0x042f, 32 }, { 0x0531, 0x0556, 48 }, { 0x1f08, 0x1f0f, -8 }, { 0x1f18, 0x1f1d, -8 }, { 0x1f28, 0x1f2f, -8 }, { 0x1f38, 0x1f3f, -8 }, + { 0x1f48, 0x1f4d, -8 }, { 0x1f68, 0x1f6f, -8 }, { 0x1fc8, 0x1fcb, -86 }, { 0x2160, 0x216f, 16 }, { 0x24b6, 0x24cf, 26 }, { 0xff21, 0xff3a, 32 }, + { 0x10400, 0x10425, 40 } + }; + + /* This maps single codepoint to another single codepoint. */ + static const struct { + int src_codepoint; + int dest_codepoint; + } single_map[] = { + { 0x00b5, 0x03bc }, { 0x0100, 0x0101 }, { 0x0102, 0x0103 }, { 0x0104, 0x0105 }, { 0x0106, 0x0107 }, { 0x0108, 0x0109 }, { 0x010a, 0x010b }, { 0x010c, 0x010d }, + { 0x010e, 0x010f }, { 0x0110, 0x0111 }, { 0x0112, 0x0113 }, { 0x0114, 0x0115 }, { 0x0116, 0x0117 }, { 0x0118, 0x0119 }, { 0x011a, 0x011b }, { 0x011c, 0x011d }, + { 0x011e, 0x011f }, { 0x0120, 0x0121 }, { 0x0122, 0x0123 }, { 0x0124, 0x0125 }, { 0x0126, 0x0127 }, { 0x0128, 0x0129 }, { 0x012a, 0x012b }, { 0x012c, 0x012d }, + { 0x012e, 0x012f }, { 0x0132, 0x0133 }, { 0x0134, 0x0135 }, { 0x0136, 0x0137 }, { 0x0139, 0x013a }, { 0x013b, 0x013c }, { 0x013d, 0x013e }, { 0x013f, 0x0140 }, + { 0x0141, 0x0142 }, { 0x0143, 0x0144 }, { 0x0145, 0x0146 }, { 0x0147, 0x0148 }, { 0x014a, 0x014b }, { 0x014c, 0x014d }, { 0x014e, 0x014f }, { 0x0150, 0x0151 }, + { 0x0152, 0x0153 }, { 0x0154, 0x0155 }, { 0x0156, 0x0157 }, { 0x0158, 0x0159 }, { 0x015a, 0x015b }, { 0x015c, 0x015d }, { 0x015e, 0x015f }, { 0x0160, 0x0161 }, + { 0x0162, 0x0163 }, { 0x0164, 0x0165 }, { 0x0166, 0x0167 }, { 0x0168, 0x0169 }, { 0x016a, 0x016b }, { 0x016c, 0x016d }, { 0x016e, 0x016f }, { 0x0170, 0x0171 }, + { 0x0172, 0x0173 }, { 0x0174, 0x0175 }, { 0x0176, 0x0177 }, { 0x0178, 0x00ff }, { 0x0179, 0x017a }, { 0x017b, 0x017c }, { 0x017d, 0x017e }, { 0x017f, 0x0073 }, + { 0x0181, 0x0253 }, { 0x0182, 0x0183 }, { 0x0184, 0x0185 }, { 0x0186, 0x0254 }, { 0x0187, 0x0188 }, { 0x0189, 0x0256 }, { 0x018a, 0x0257 }, { 0x018b, 0x018c }, + { 0x018e, 0x01dd }, { 0x018f, 0x0259 }, { 0x0190, 0x025b }, { 0x0191, 0x0192 }, { 0x0193, 0x0260 }, { 0x0194, 0x0263 }, { 0x0196, 0x0269 }, { 0x0197, 0x0268 }, + { 0x0198, 0x0199 }, { 0x019c, 0x026f }, { 0x019d, 0x0272 }, { 0x019f, 0x0275 }, { 0x01a0, 0x01a1 }, { 0x01a2, 0x01a3 }, { 0x01a4, 0x01a5 }, { 0x01a6, 0x0280 }, + { 0x01a7, 0x01a8 }, { 0x01a9, 0x0283 }, { 0x01ac, 0x01ad }, { 0x01ae, 0x0288 }, { 0x01af, 0x01b0 }, { 0x01b1, 0x028a }, { 0x01b2, 0x028b }, { 0x01b3, 0x01b4 }, + { 0x01b5, 0x01b6 }, { 0x01b7, 0x0292 }, { 0x01b8, 0x01b9 }, { 0x01bc, 0x01bd }, { 0x01c4, 0x01c6 }, { 0x01c5, 0x01c6 }, { 0x01c7, 0x01c9 }, { 0x01c8, 0x01c9 }, + { 0x01ca, 0x01cc }, { 0x01cb, 0x01cc }, { 0x01cd, 0x01ce }, { 0x01cf, 0x01d0 }, { 0x01d1, 0x01d2 }, { 0x01d3, 0x01d4 }, { 0x01d5, 0x01d6 }, { 0x01d7, 0x01d8 }, + { 0x01d9, 0x01da }, { 0x01db, 0x01dc }, { 0x01de, 0x01df }, { 0x01e0, 0x01e1 }, { 0x01e2, 0x01e3 }, { 0x01e4, 0x01e5 }, { 0x01e6, 0x01e7 }, { 0x01e8, 0x01e9 }, + { 0x01ea, 0x01eb }, { 0x01ec, 0x01ed }, { 0x01ee, 0x01ef }, { 0x01f1, 0x01f3 }, { 0x01f2, 0x01f3 }, { 0x01f4, 0x01f5 }, { 0x01f6, 0x0195 }, { 0x01f7, 0x01bf }, + { 0x01f8, 0x01f9 }, { 0x01fa, 0x01fb }, { 0x01fc, 0x01fd }, { 0x01fe, 0x01ff }, { 0x0200, 0x0201 }, { 0x0202, 0x0203 }, { 0x0204, 0x0205 }, { 0x0206, 0x0207 }, + { 0x0208, 0x0209 }, { 0x020a, 0x020b }, { 0x020c, 0x020d }, { 0x020e, 0x020f }, { 0x0210, 0x0211 }, { 0x0212, 0x0213 }, { 0x0214, 0x0215 }, { 0x0216, 0x0217 }, + { 0x0218, 0x0219 }, { 0x021a, 0x021b }, { 0x021c, 0x021d }, { 0x021e, 0x021f }, { 0x0220, 0x019e }, { 0x0222, 0x0223 }, { 0x0224, 0x0225 }, { 0x0226, 0x0227 }, + { 0x0228, 0x0229 }, { 0x022a, 0x022b }, { 0x022c, 0x022d }, { 0x022e, 0x022f }, { 0x0230, 0x0231 }, { 0x0232, 0x0233 }, { 0x0345, 0x03b9 }, { 0x0386, 0x03ac }, + { 0x038c, 0x03cc }, { 0x038e, 0x03cd }, { 0x038f, 0x03ce }, { 0x03c2, 0x03c3 }, { 0x03d0, 0x03b2 }, { 0x03d1, 0x03b8 }, { 0x03d5, 0x03c6 }, { 0x03d6, 0x03c0 }, + { 0x03d8, 0x03d9 }, { 0x03da, 0x03db }, { 0x03dc, 0x03dd }, { 0x03de, 0x03df }, { 0x03e0, 0x03e1 }, { 0x03e2, 0x03e3 }, { 0x03e4, 0x03e5 }, { 0x03e6, 0x03e7 }, + { 0x03e8, 0x03e9 }, { 0x03ea, 0x03eb }, { 0x03ec, 0x03ed }, { 0x03ee, 0x03ef }, { 0x03f0, 0x03ba }, { 0x03f1, 0x03c1 }, { 0x03f2, 0x03c3 }, { 0x03f4, 0x03b8 }, + { 0x03f5, 0x03b5 }, { 0x0460, 0x0461 }, { 0x0462, 0x0463 }, { 0x0464, 0x0465 }, { 0x0466, 0x0467 }, { 0x0468, 0x0469 }, { 0x046a, 0x046b }, { 0x046c, 0x046d }, + { 0x046e, 0x046f }, { 0x0470, 0x0471 }, { 0x0472, 0x0473 }, { 0x0474, 0x0475 }, { 0x0476, 0x0477 }, { 0x0478, 0x0479 }, { 0x047a, 0x047b }, { 0x047c, 0x047d }, + { 0x047e, 0x047f }, { 0x0480, 0x0481 }, { 0x048a, 0x048b }, { 0x048c, 0x048d }, { 0x048e, 0x048f }, { 0x0490, 0x0491 }, { 0x0492, 0x0493 }, { 0x0494, 0x0495 }, + { 0x0496, 0x0497 }, { 0x0498, 0x0499 }, { 0x049a, 0x049b }, { 0x049c, 0x049d }, { 0x049e, 0x049f }, { 0x04a0, 0x04a1 }, { 0x04a2, 0x04a3 }, { 0x04a4, 0x04a5 }, + { 0x04a6, 0x04a7 }, { 0x04a8, 0x04a9 }, { 0x04aa, 0x04ab }, { 0x04ac, 0x04ad }, { 0x04ae, 0x04af }, { 0x04b0, 0x04b1 }, { 0x04b2, 0x04b3 }, { 0x04b4, 0x04b5 }, + { 0x04b6, 0x04b7 }, { 0x04b8, 0x04b9 }, { 0x04ba, 0x04bb }, { 0x04bc, 0x04bd }, { 0x04be, 0x04bf }, { 0x04c1, 0x04c2 }, { 0x04c3, 0x04c4 }, { 0x04c5, 0x04c6 }, + { 0x04c7, 0x04c8 }, { 0x04c9, 0x04ca }, { 0x04cb, 0x04cc }, { 0x04cd, 0x04ce }, { 0x04d0, 0x04d1 }, { 0x04d2, 0x04d3 }, { 0x04d4, 0x04d5 }, { 0x04d6, 0x04d7 }, + { 0x04d8, 0x04d9 }, { 0x04da, 0x04db }, { 0x04dc, 0x04dd }, { 0x04de, 0x04df }, { 0x04e0, 0x04e1 }, { 0x04e2, 0x04e3 }, { 0x04e4, 0x04e5 }, { 0x04e6, 0x04e7 }, + { 0x04e8, 0x04e9 }, { 0x04ea, 0x04eb }, { 0x04ec, 0x04ed }, { 0x04ee, 0x04ef }, { 0x04f0, 0x04f1 }, { 0x04f2, 0x04f3 }, { 0x04f4, 0x04f5 }, { 0x04f8, 0x04f9 }, + { 0x0500, 0x0501 }, { 0x0502, 0x0503 }, { 0x0504, 0x0505 }, { 0x0506, 0x0507 }, { 0x0508, 0x0509 }, { 0x050a, 0x050b }, { 0x050c, 0x050d }, { 0x050e, 0x050f }, + { 0x1e00, 0x1e01 }, { 0x1e02, 0x1e03 }, { 0x1e04, 0x1e05 }, { 0x1e06, 0x1e07 }, { 0x1e08, 0x1e09 }, { 0x1e0a, 0x1e0b }, { 0x1e0c, 0x1e0d }, { 0x1e0e, 0x1e0f }, + { 0x1e10, 0x1e11 }, { 0x1e12, 0x1e13 }, { 0x1e14, 0x1e15 }, { 0x1e16, 0x1e17 }, { 0x1e18, 0x1e19 }, { 0x1e1a, 0x1e1b }, { 0x1e1c, 0x1e1d }, { 0x1e1e, 0x1e1f }, + { 0x1e20, 0x1e21 }, { 0x1e22, 0x1e23 }, { 0x1e24, 0x1e25 }, { 0x1e26, 0x1e27 }, { 0x1e28, 0x1e29 }, { 0x1e2a, 0x1e2b }, { 0x1e2c, 0x1e2d }, { 0x1e2e, 0x1e2f }, + { 0x1e30, 0x1e31 }, { 0x1e32, 0x1e33 }, { 0x1e34, 0x1e35 }, { 0x1e36, 0x1e37 }, { 0x1e38, 0x1e39 }, { 0x1e3a, 0x1e3b }, { 0x1e3c, 0x1e3d }, { 0x1e3e, 0x1e3f }, + { 0x1e40, 0x1e41 }, { 0x1e42, 0x1e43 }, { 0x1e44, 0x1e45 }, { 0x1e46, 0x1e47 }, { 0x1e48, 0x1e49 }, { 0x1e4a, 0x1e4b }, { 0x1e4c, 0x1e4d }, { 0x1e4e, 0x1e4f }, + { 0x1e50, 0x1e51 }, { 0x1e52, 0x1e53 }, { 0x1e54, 0x1e55 }, { 0x1e56, 0x1e57 }, { 0x1e58, 0x1e59 }, { 0x1e5a, 0x1e5b }, { 0x1e5c, 0x1e5d }, { 0x1e5e, 0x1e5f }, + { 0x1e60, 0x1e61 }, { 0x1e62, 0x1e63 }, { 0x1e64, 0x1e65 }, { 0x1e66, 0x1e67 }, { 0x1e68, 0x1e69 }, { 0x1e6a, 0x1e6b }, { 0x1e6c, 0x1e6d }, { 0x1e6e, 0x1e6f }, + { 0x1e70, 0x1e71 }, { 0x1e72, 0x1e73 }, { 0x1e74, 0x1e75 }, { 0x1e76, 0x1e77 }, { 0x1e78, 0x1e79 }, { 0x1e7a, 0x1e7b }, { 0x1e7c, 0x1e7d }, { 0x1e7e, 0x1e7f }, + { 0x1e80, 0x1e81 }, { 0x1e82, 0x1e83 }, { 0x1e84, 0x1e85 }, { 0x1e86, 0x1e87 }, { 0x1e88, 0x1e89 }, { 0x1e8a, 0x1e8b }, { 0x1e8c, 0x1e8d }, { 0x1e8e, 0x1e8f }, + { 0x1e90, 0x1e91 }, { 0x1e92, 0x1e93 }, { 0x1e94, 0x1e95 }, { 0x1e9b, 0x1e61 }, { 0x1ea0, 0x1ea1 }, { 0x1ea2, 0x1ea3 }, { 0x1ea4, 0x1ea5 }, { 0x1ea6, 0x1ea7 }, + { 0x1ea8, 0x1ea9 }, { 0x1eaa, 0x1eab }, { 0x1eac, 0x1ead }, { 0x1eae, 0x1eaf }, { 0x1eb0, 0x1eb1 }, { 0x1eb2, 0x1eb3 }, { 0x1eb4, 0x1eb5 }, { 0x1eb6, 0x1eb7 }, + { 0x1eb8, 0x1eb9 }, { 0x1eba, 0x1ebb }, { 0x1ebc, 0x1ebd }, { 0x1ebe, 0x1ebf }, { 0x1ec0, 0x1ec1 }, { 0x1ec2, 0x1ec3 }, { 0x1ec4, 0x1ec5 }, { 0x1ec6, 0x1ec7 }, + { 0x1ec8, 0x1ec9 }, { 0x1eca, 0x1ecb }, { 0x1ecc, 0x1ecd }, { 0x1ece, 0x1ecf }, { 0x1ed0, 0x1ed1 }, { 0x1ed2, 0x1ed3 }, { 0x1ed4, 0x1ed5 }, { 0x1ed6, 0x1ed7 }, + { 0x1ed8, 0x1ed9 }, { 0x1eda, 0x1edb }, { 0x1edc, 0x1edd }, { 0x1ede, 0x1edf }, { 0x1ee0, 0x1ee1 }, { 0x1ee2, 0x1ee3 }, { 0x1ee4, 0x1ee5 }, { 0x1ee6, 0x1ee7 }, + { 0x1ee8, 0x1ee9 }, { 0x1eea, 0x1eeb }, { 0x1eec, 0x1eed }, { 0x1eee, 0x1eef }, { 0x1ef0, 0x1ef1 }, { 0x1ef2, 0x1ef3 }, { 0x1ef4, 0x1ef5 }, { 0x1ef6, 0x1ef7 }, + { 0x1ef8, 0x1ef9 }, { 0x1f59, 0x1f51 }, { 0x1f5b, 0x1f53 }, { 0x1f5d, 0x1f55 }, { 0x1f5f, 0x1f57 }, { 0x1fb8, 0x1fb0 }, { 0x1fb9, 0x1fb1 }, { 0x1fba, 0x1f70 }, + { 0x1fbb, 0x1f71 }, { 0x1fbe, 0x03b9 }, { 0x1fd8, 0x1fd0 }, { 0x1fd9, 0x1fd1 }, { 0x1fda, 0x1f76 }, { 0x1fdb, 0x1f77 }, { 0x1fe8, 0x1fe0 }, { 0x1fe9, 0x1fe1 }, + { 0x1fea, 0x1f7a }, { 0x1feb, 0x1f7b }, { 0x1fec, 0x1fe5 }, { 0x1ff8, 0x1f78 }, { 0x1ff9, 0x1f79 }, { 0x1ffa, 0x1f7c }, { 0x1ffb, 0x1f7d }, { 0x2126, 0x03c9 }, + { 0x212a, 0x006b }, { 0x212b, 0x00e5 }, + }; + + /* This maps single codepoint to two codepoints. */ + static const struct { + int src_codepoint; + int dest_codepoint0; + int dest_codepoint1; + } double_map[] = { + { 0x00df, 0x0073, 0x0073 }, { 0x0130, 0x0069, 0x0307 }, { 0x0149, 0x02bc, 0x006e }, { 0x01f0, 0x006a, 0x030c }, { 0x0587, 0x0565, 0x0582 }, { 0x1e96, 0x0068, 0x0331 }, + { 0x1e97, 0x0074, 0x0308 }, { 0x1e98, 0x0077, 0x030a }, { 0x1e99, 0x0079, 0x030a }, { 0x1e9a, 0x0061, 0x02be }, { 0x1f50, 0x03c5, 0x0313 }, { 0x1f80, 0x1f00, 0x03b9 }, + { 0x1f81, 0x1f01, 0x03b9 }, { 0x1f82, 0x1f02, 0x03b9 }, { 0x1f83, 0x1f03, 0x03b9 }, { 0x1f84, 0x1f04, 0x03b9 }, { 0x1f85, 0x1f05, 0x03b9 }, { 0x1f86, 0x1f06, 0x03b9 }, + { 0x1f87, 0x1f07, 0x03b9 }, { 0x1f88, 0x1f00, 0x03b9 }, { 0x1f89, 0x1f01, 0x03b9 }, { 0x1f8a, 0x1f02, 0x03b9 }, { 0x1f8b, 0x1f03, 0x03b9 }, { 0x1f8c, 0x1f04, 0x03b9 }, + { 0x1f8d, 0x1f05, 0x03b9 }, { 0x1f8e, 0x1f06, 0x03b9 }, { 0x1f8f, 0x1f07, 0x03b9 }, { 0x1f90, 0x1f20, 0x03b9 }, { 0x1f91, 0x1f21, 0x03b9 }, { 0x1f92, 0x1f22, 0x03b9 }, + { 0x1f93, 0x1f23, 0x03b9 }, { 0x1f94, 0x1f24, 0x03b9 }, { 0x1f95, 0x1f25, 0x03b9 }, { 0x1f96, 0x1f26, 0x03b9 }, { 0x1f97, 0x1f27, 0x03b9 }, { 0x1f98, 0x1f20, 0x03b9 }, + { 0x1f99, 0x1f21, 0x03b9 }, { 0x1f9a, 0x1f22, 0x03b9 }, { 0x1f9b, 0x1f23, 0x03b9 }, { 0x1f9c, 0x1f24, 0x03b9 }, { 0x1f9d, 0x1f25, 0x03b9 }, { 0x1f9e, 0x1f26, 0x03b9 }, + { 0x1f9f, 0x1f27, 0x03b9 }, { 0x1fa0, 0x1f60, 0x03b9 }, { 0x1fa1, 0x1f61, 0x03b9 }, { 0x1fa2, 0x1f62, 0x03b9 }, { 0x1fa3, 0x1f63, 0x03b9 }, { 0x1fa4, 0x1f64, 0x03b9 }, + { 0x1fa5, 0x1f65, 0x03b9 }, { 0x1fa6, 0x1f66, 0x03b9 }, { 0x1fa7, 0x1f67, 0x03b9 }, { 0x1fa8, 0x1f60, 0x03b9 }, { 0x1fa9, 0x1f61, 0x03b9 }, { 0x1faa, 0x1f62, 0x03b9 }, + { 0x1fab, 0x1f63, 0x03b9 }, { 0x1fac, 0x1f64, 0x03b9 }, { 0x1fad, 0x1f65, 0x03b9 }, { 0x1fae, 0x1f66, 0x03b9 }, { 0x1faf, 0x1f67, 0x03b9 }, { 0x1fb2, 0x1f70, 0x03b9 }, + { 0x1fb3, 0x03b1, 0x03b9 }, { 0x1fb4, 0x03ac, 0x03b9 }, { 0x1fb6, 0x03b1, 0x0342 }, { 0x1fbc, 0x03b1, 0x03b9 }, { 0x1fc2, 0x1f74, 0x03b9 }, { 0x1fc3, 0x03b7, 0x03b9 }, + { 0x1fc4, 0x03ae, 0x03b9 }, { 0x1fc6, 0x03b7, 0x0342 }, { 0x1fcc, 0x03b7, 0x03b9 }, { 0x1fd6, 0x03b9, 0x0342 }, { 0x1fe4, 0x03c1, 0x0313 }, { 0x1fe6, 0x03c5, 0x0342 }, + { 0x1ff2, 0x1f7c, 0x03b9 }, { 0x1ff3, 0x03c9, 0x03b9 }, { 0x1ff4, 0x03ce, 0x03b9 }, { 0x1ff6, 0x03c9, 0x0342 }, { 0x1ffc, 0x03c9, 0x03b9 }, { 0xfb00, 0x0066, 0x0066 }, + { 0xfb01, 0x0066, 0x0069 }, { 0xfb02, 0x0066, 0x006c }, { 0xfb05, 0x0073, 0x0074 }, { 0xfb06, 0x0073, 0x0074 }, { 0xfb13, 0x0574, 0x0576 }, { 0xfb14, 0x0574, 0x0565 }, + { 0xfb15, 0x0574, 0x056b }, { 0xfb16, 0x057e, 0x0576 }, { 0xfb17, 0x0574, 0x056d } + }; + + /* This maps single codepoint to three codepoints. */ + static const struct { + int src_codepoint; + int dest_codepoint0; + int dest_codepoint1; + int dest_codepoint2; + } triple_map[] = { + { 0x0390, 0x03b9, 0x0308, 0x0301 }, { 0x03b0, 0x03c5, 0x0308, 0x0301 }, { 0x1f52, 0x03c5, 0x0313, 0x0300 }, { 0x1f54, 0x03c5, 0x0313, 0x0301 }, + { 0x1f56, 0x03c5, 0x0313, 0x0342 }, { 0x1fb7, 0x03b1, 0x0342, 0x03b9 }, { 0x1fc7, 0x03b7, 0x0342, 0x03b9 }, { 0x1fd2, 0x03b9, 0x0308, 0x0300 }, + { 0x1fd3, 0x03b9, 0x0308, 0x0301 }, { 0x1fd7, 0x03b9, 0x0308, 0x0342 }, { 0x1fe2, 0x03c5, 0x0308, 0x0300 }, { 0x1fe3, 0x03c5, 0x0308, 0x0301 }, + { 0x1fe7, 0x03c5, 0x0308, 0x0342 }, { 0x1ff7, 0x03c9, 0x0342, 0x03b9 }, { 0xfb03, 0x0066, 0x0066, 0x0069 }, { 0xfb04, 0x0066, 0x0066, 0x006c } + }; + + int i; + + /* Fast path for ASCII characters. */ + if(codepoint <= 0x7f) { + info->codepoints[0] = codepoint; + if(ISUPPER_(codepoint)) + info->codepoints[0] += 'a' - 'A'; + info->n_codepoints = 1; + return; + } + + for(i = 0; i < SIZEOF_ARRAY(range_map); i++) { + if(range_map[i].min_codepoint <= codepoint && codepoint <= range_map[i].max_codepoint) { + info->codepoints[0] = codepoint + range_map[i].offset; + info->n_codepoints = 1; + return; + } + } + + for(i = 0; i < SIZEOF_ARRAY(single_map); i++) { + if(codepoint == single_map[i].src_codepoint) { + info->codepoints[0] = single_map[i].dest_codepoint; + info->n_codepoints = 1; + return; + } + } + + for(i = 0; i < SIZEOF_ARRAY(double_map); i++) { + if(codepoint == double_map[i].src_codepoint) { + info->codepoints[0] = double_map[i].dest_codepoint0; + info->codepoints[1] = double_map[i].dest_codepoint1; + info->n_codepoints = 2; + return; + } + } + + for(i = 0; i < SIZEOF_ARRAY(triple_map); i++) { + if(codepoint == triple_map[i].src_codepoint) { + info->codepoints[0] = triple_map[i].dest_codepoint0; + info->codepoints[1] = triple_map[i].dest_codepoint1; + info->codepoints[2] = triple_map[i].dest_codepoint2; + info->n_codepoints = 3; + return; + } + } + + info->codepoints[0] = codepoint; + info->n_codepoints = 1; + } +#endif + + +#if defined MD4C_USE_UTF16 + #define IS_UTF16_SURROGATE_HI(word) (((WORD)(word) & 0xfc00) == 0xd800) + #define IS_UTF16_SURROGATE_LO(word) (((WORD)(word) & 0xfc00) == 0xdc00) + #define UTF16_DECODE_SURROGATE(hi, lo) (0x10000 + ((((unsigned)(hi) & 0x3ff) << 10) | (((unsigned)(lo) & 0x3ff) << 0))) + + static int + md_decode_utf16le__(const CHAR* str, SZ str_size, SZ* p_size) + { + if(IS_UTF16_SURROGATE_HI(str[0])) { + if(1 < str_size && IS_UTF16_SURROGATE_LO(str[1])) { + if(p_size != NULL) + *p_size = 2; + return UTF16_DECODE_SURROGATE(str[0], str[1]); + } + } + + if(p_size != NULL) + *p_size = 1; + return str[0]; + } + + static int + md_decode_utf16le_before__(MD_CTX* ctx, OFF off) + { + if(off > 2 && IS_UTF16_SURROGATE_HI(CH(off-2)) && IS_UTF16_SURROGATE_LO(CH(off-1))) + return UTF16_DECODE_SURROGATE(CH(off-2), CH(off-1)); + + return CH(off); + } + + /* No whitespace uses surrogates, so no decoding needed here. */ + #define ISUNICODEWHITESPACE_(codepoint) md_is_unicode_whitespace__(codepoint) + #define ISUNICODEWHITESPACE(off) md_is_unicode_whitespace__(CH(off)) + #define ISUNICODEWHITESPACEBEFORE(off) md_is_unicode_whitespace__(CH((off)-1)) + + #define ISUNICODEPUNCT(off) md_is_unicode_punct__(md_decode_utf16le__(STR(off), ctx->size - (off), NULL)) + #define ISUNICODEPUNCTBEFORE(off) md_is_unicode_punct__(md_decode_utf16le_before__(ctx, off)) + + static inline int + md_decode_unicode(const CHAR* str, OFF off, SZ str_size, SZ* p_char_size) + { + return md_decode_utf16le__(str+off, str_size-off, p_char_size); + } +#elif defined MD4C_USE_UTF8 + #define IS_UTF8_LEAD1(byte) ((unsigned char)(byte) <= 0x7f) + #define IS_UTF8_LEAD2(byte) (((unsigned char)(byte) & 0xe0) == 0xc0) + #define IS_UTF8_LEAD3(byte) (((unsigned char)(byte) & 0xf0) == 0xe0) + #define IS_UTF8_LEAD4(byte) (((unsigned char)(byte) & 0xf8) == 0xf0) + #define IS_UTF8_TAIL(byte) (((unsigned char)(byte) & 0xc0) == 0x80) + + static int + md_decode_utf8__(const CHAR* str, SZ str_size, SZ* p_size) + { + if(!IS_UTF8_LEAD1(str[0])) { + if(IS_UTF8_LEAD2(str[0])) { + if(1 < str_size && IS_UTF8_TAIL(str[1])) { + if(p_size != NULL) + *p_size = 2; + + return (((unsigned int)str[0] & 0x1f) << 6) | + (((unsigned int)str[1] & 0x3f) << 0); + } + } else if(IS_UTF8_LEAD3(str[0])) { + if(2 < str_size && IS_UTF8_TAIL(str[1]) && IS_UTF8_TAIL(str[2])) { + if(p_size != NULL) + *p_size = 3; + + return (((unsigned int)str[0] & 0x0f) << 12) | + (((unsigned int)str[1] & 0x3f) << 6) | + (((unsigned int)str[2] & 0x3f) << 0); + } + } else if(IS_UTF8_LEAD4(str[0])) { + if(3 < str_size && IS_UTF8_TAIL(str[1]) && IS_UTF8_TAIL(str[2]) && IS_UTF8_TAIL(str[3])) { + if(p_size != NULL) + *p_size = 4; + + return (((unsigned int)str[0] & 0x07) << 18) | + (((unsigned int)str[1] & 0x3f) << 12) | + (((unsigned int)str[2] & 0x3f) << 6) | + (((unsigned int)str[3] & 0x3f) << 0); + } + } + } + + if(p_size != NULL) + *p_size = 1; + return str[0]; + } + + static int + md_decode_utf8_before__(MD_CTX* ctx, OFF off) + { + if(!IS_UTF8_LEAD1(CH(off-1))) { + if(off > 1 && IS_UTF8_LEAD2(CH(off-2)) && IS_UTF8_TAIL(CH(off-1))) + return (((unsigned int)CH(off-2) & 0x1f) << 6) | + (((unsigned int)CH(off-1) & 0x3f) << 0); + + if(off > 2 && IS_UTF8_LEAD3(CH(off-3)) && IS_UTF8_TAIL(CH(off-2)) && IS_UTF8_TAIL(CH(off-1))) + return (((unsigned int)CH(off-3) & 0x0f) << 12) | + (((unsigned int)CH(off-2) & 0x3f) << 6) | + (((unsigned int)CH(off-1) & 0x3f) << 0); + + if(off > 3 && IS_UTF8_LEAD4(CH(off-4)) && IS_UTF8_TAIL(CH(off-3)) && IS_UTF8_TAIL(CH(off-2)) && IS_UTF8_TAIL(CH(off-1))) + return (((unsigned int)CH(off-4) & 0x07) << 18) | + (((unsigned int)CH(off-3) & 0x3f) << 12) | + (((unsigned int)CH(off-2) & 0x3f) << 6) | + (((unsigned int)CH(off-1) & 0x3f) << 0); + } + + return CH(off-1); + } + + #define ISUNICODEWHITESPACE_(codepoint) md_is_unicode_whitespace__(codepoint) + #define ISUNICODEWHITESPACE(off) md_is_unicode_whitespace__(md_decode_utf8__(STR(off), ctx->size - (off), NULL)) + #define ISUNICODEWHITESPACEBEFORE(off) md_is_unicode_whitespace__(md_decode_utf8_before__(ctx, off)) + + #define ISUNICODEPUNCT(off) md_is_unicode_punct__(md_decode_utf8__(STR(off), ctx->size - (off), NULL)) + #define ISUNICODEPUNCTBEFORE(off) md_is_unicode_punct__(md_decode_utf8_before__(ctx, off)) + + static inline int + md_decode_unicode(const CHAR* str, OFF off, SZ str_size, SZ* p_char_size) + { + return md_decode_utf8__(str+off, str_size-off, p_char_size); + } +#else + #define ISUNICODEWHITESPACE_(codepoint) ISWHITESPACE_(codepoint) + #define ISUNICODEWHITESPACE(off) ISWHITESPACE(off) + #define ISUNICODEWHITESPACEBEFORE(off) ISWHITESPACE((off)-1) + + #define ISUNICODEPUNCT(off) ISPUNCT(off) + #define ISUNICODEPUNCTBEFORE(off) ISPUNCT((off)-1) + + static inline void + md_get_unicode_fold_info(int codepoint, MD_UNICODE_FOLD_INFO* info) + { + info->codepoints[0] = codepoint; + if(ISUPPER_(codepoint)) + info->codepoints[0] += 'a' - 'A'; + info->n_codepoints = 1; + } + + static inline int + md_decode_unicode(const CHAR* str, OFF off, SZ str_size, SZ* p_size) + { + *p_size = 1; + return str[off]; + } +#endif + + +/************************************* + *** Helper string manipulations *** + *************************************/ + +/* Fill buffer with copy of the string between 'beg' and 'end' but replace any + * line breaks with given replacement character. + * + * NOTE: Caller is responsible to make sure the buffer is large enough. + * (Given the output is always shorter then input, (end - beg) is good idea + * what the caller should allocate.) + */ +static void +md_merge_lines(MD_CTX* ctx, OFF beg, OFF end, const MD_LINE* lines, int n_lines, + CHAR line_break_replacement_char, CHAR* buffer, SZ* p_size) +{ + CHAR* ptr = buffer; + int line_index = 0; + OFF off = beg; + + while(1) { + const MD_LINE* line = &lines[line_index]; + OFF line_end = line->end; + if(end < line_end) + line_end = end; + + while(off < line_end) { + *ptr = CH(off); + ptr++; + off++; + } + + if(off >= end) { + *p_size = ptr - buffer; + return; + } + + *ptr = line_break_replacement_char; + ptr++; + + line_index++; + off = lines[line_index].beg; + } +} + +/* Wrapper of md_merge_lines() which allocates new buffer for the output string. + */ +static int +md_merge_lines_alloc(MD_CTX* ctx, OFF beg, OFF end, const MD_LINE* lines, int n_lines, + CHAR line_break_replacement_char, CHAR** p_str, SZ* p_size) +{ + CHAR* buffer; + + buffer = (CHAR*) malloc(sizeof(CHAR) * (end - beg)); + if(buffer == NULL) { + MD_LOG("malloc() failed."); + return -1; + } + + md_merge_lines(ctx, beg, end, lines, n_lines, + line_break_replacement_char, buffer, p_size); + + *p_str = buffer; + return 0; +} + +static OFF +md_skip_unicode_whitespace(const CHAR* label, OFF off, SZ size) +{ + SZ char_size; + int codepoint; + + while(off < size) { + codepoint = md_decode_unicode(label, off, size, &char_size); + if(!ISUNICODEWHITESPACE_(codepoint) && !ISNEWLINE_(label[off])) + break; + off += char_size; + } + + return off; +} + + +/****************************** + *** Recognizing raw HTML *** + ******************************/ + +/* md_is_html_tag() may be called when processing inlines (inline raw HTML) + * or when breaking document to blocks (checking for start of HTML block type 7). + * + * When breaking document to blocks, we do not yet know line boundaries, but + * in that case the whole tag has to live on a single line. We distinguish this + * by n_lines == 0. + */ +static int +md_is_html_tag(MD_CTX* ctx, const MD_LINE* lines, int n_lines, OFF beg, OFF max_end, OFF* p_end) +{ + int attr_state; + OFF off = beg; + OFF line_end = (n_lines > 0) ? lines[0].end : ctx->size; + int i = 0; + + MD_ASSERT(CH(beg) == _T('<')); + + if(off + 1 >= line_end) + return FALSE; + off++; + + /* For parsing attributes, we need a little state automaton below. + * State -1: no attributes are allowed. + * State 0: attribute could follow after some whitespace. + * State 1: after a whitespace (attribute name may follow). + * State 2: after attribute name ('=' MAY follow). + * State 3: after '=' (value specification MUST follow). + * State 41: in middle of unquoted attribute value. + * State 42: in middle of single-quoted attribute value. + * State 43: in middle of double-quoted attribute value. + */ + attr_state = 0; + + if(CH(off) == _T('/')) { + /* Closer tag "". No attributes may be present. */ + attr_state = -1; + off++; + } + + /* Tag name */ + if(off >= line_end || !ISALPHA(off)) + return FALSE; + off++; + while(off < line_end && (ISALNUM(off) || CH(off) == _T('-'))) + off++; + + /* (Optional) attributes (if not closer), (optional) '/' (if not closer) + * and final '>'. */ + while(1) { + while(off < line_end && !ISNEWLINE(off)) { + if(attr_state > 40) { + if(attr_state == 41 && (ISBLANK(off) || ISANYOF(off, _T("\"'=<>`")))) { + attr_state = 0; + off--; /* Put the char back for re-inspection in the new state. */ + } else if(attr_state == 42 && CH(off) == _T('\'')) { + attr_state = 0; + } else if(attr_state == 43 && CH(off) == _T('"')) { + attr_state = 0; + } + off++; + } else if(ISWHITESPACE(off)) { + if(attr_state == 0) + attr_state = 1; + off++; + } else if(attr_state <= 2 && CH(off) == _T('>')) { + /* End. */ + goto done; + } else if(attr_state <= 2 && CH(off) == _T('/') && off+1 < line_end && CH(off+1) == _T('>')) { + /* End with digraph '/>' */ + off++; + goto done; + } else if((attr_state == 1 || attr_state == 2) && (ISALPHA(off) || CH(off) == _T('_') || CH(off) == _T(':'))) { + off++; + /* Attribute name */ + while(off < line_end && (ISALNUM(off) || ISANYOF(off, _T("_.:-")))) + off++; + attr_state = 2; + } else if(attr_state == 2 && CH(off) == _T('=')) { + /* Attribute assignment sign */ + off++; + attr_state = 3; + } else if(attr_state == 3) { + /* Expecting start of attribute value. */ + if(CH(off) == _T('"')) + attr_state = 43; + else if(CH(off) == _T('\'')) + attr_state = 42; + else if(!ISANYOF(off, _T("\"'=<>`")) && !ISNEWLINE(off)) + attr_state = 41; + else + return FALSE; + off++; + } else { + /* Anything unexpected. */ + return FALSE; + } + } + + /* We have to be on a single line. See definition of start condition + * of HTML block, type 7. */ + if(n_lines == 0) + return FALSE; + + i++; + if(i >= n_lines) + return FALSE; + + off = lines[i].beg; + line_end = lines[i].end; + + if(attr_state == 0 || attr_state == 41) + attr_state = 1; + + if(off >= max_end) + return FALSE; + } + +done: + if(off >= max_end) + return FALSE; + + *p_end = off+1; + return TRUE; +} + +static int +md_is_html_comment(MD_CTX* ctx, const MD_LINE* lines, int n_lines, OFF beg, OFF max_end, OFF* p_end) +{ + OFF off = beg; + int i = 0; + + MD_ASSERT(CH(beg) == _T('<')); + + if(off + 4 >= lines[0].end) + return FALSE; + if(CH(off+1) != _T('!') || CH(off+2) != _T('-') || CH(off+3) != _T('-')) + return FALSE; + off += 4; + + /* ">" and "->" must follow the opening. */ + if(off < lines[0].end && CH(off) == _T('>')) + return FALSE; + if(off+1 < lines[0].end && CH(off) == _T('-') && CH(off+1) == _T('>')) + return FALSE; + + while(1) { + while(off + 2 < lines[i].end) { + if(CH(off) == _T('-') && CH(off+1) == _T('-')) { + if(CH(off+2) == _T('>')) { + /* Success. */ + off += 2; + goto done; + } else { + /* "--" is prohibited inside the comment. */ + return FALSE; + } + } + + off++; + } + + i++; + if(i >= n_lines) + return FALSE; + + off = lines[i].beg; + + if(off >= max_end) + return FALSE; + } + +done: + if(off >= max_end) + return FALSE; + + *p_end = off+1; + return TRUE; +} + +static int +md_is_html_processing_instruction(MD_CTX* ctx, const MD_LINE* lines, int n_lines, OFF beg, OFF max_end, OFF* p_end) +{ + OFF off = beg; + int i = 0; + + MD_ASSERT(CH(beg) == _T('<')); + + if(off + 2 >= lines[0].end) + return FALSE; + if(CH(off+1) != _T('?')) + return FALSE; + off += 2; + + while(1) { + while(off + 1 < lines[i].end) { + if(CH(off) == _T('?') && CH(off+1) == _T('>')) { + /* Success. */ + off++; + goto done; + } + + off++; + } + + i++; + if(i >= n_lines) + return FALSE; + + off = lines[i].beg; + if(off >= max_end) + return FALSE; + } + +done: + if(off >= max_end) + return FALSE; + + *p_end = off+1; + return TRUE; +} + +static int +md_is_html_declaration(MD_CTX* ctx, const MD_LINE* lines, int n_lines, OFF beg, OFF max_end, OFF* p_end) +{ + OFF off = beg; + int i = 0; + + MD_ASSERT(CH(beg) == _T('<')); + + if(off + 2 >= lines[0].end) + return FALSE; + if(CH(off+1) != _T('!')) + return FALSE; + off += 2; + + /* Declaration name. */ + if(off >= lines[0].end || !ISALPHA(off)) + return FALSE; + off++; + while(off < lines[0].end && ISALPHA(off)) + off++; + if(off < lines[0].end && !ISWHITESPACE(off)) + return FALSE; + + while(1) { + while(off < lines[i].end) { + if(CH(off) == _T('>')) { + /* Success. */ + goto done; + } + + off++; + } + + i++; + if(i >= n_lines) + return FALSE; + + off = lines[i].beg; + if(off >= max_end) + return FALSE; + } + +done: + if(off >= max_end) + return FALSE; + + *p_end = off+1; + return TRUE; +} + +static int +md_is_html_cdata(MD_CTX* ctx, const MD_LINE* lines, int n_lines, OFF beg, OFF max_end, OFF* p_end) +{ + static const CHAR open_str[] = _T("= lines[0].end) + return FALSE; + if(memcmp(STR(off), open_str, open_size) != 0) + return FALSE; + off += open_size; + + while(1) { + while(off + 2 < lines[i].end) { + if(CH(off) == _T(']') && CH(off+1) == _T(']') && CH(off+2) == _T('>')) { + /* Success. */ + off += 2; + goto done; + } + + off++; + } + + i++; + if(i >= n_lines) + return FALSE; + + off = lines[i].beg; + if(off >= max_end) + return FALSE; + } + +done: + if(off >= max_end) + return FALSE; + + *p_end = off+1; + return TRUE; +} + +static int +md_is_html_any(MD_CTX* ctx, const MD_LINE* lines, int n_lines, OFF beg, OFF max_end, OFF* p_end) +{ + if(md_is_html_tag(ctx, lines, n_lines, beg, max_end, p_end) == TRUE) + return TRUE; + if(md_is_html_comment(ctx, lines, n_lines, beg, max_end, p_end) == TRUE) + return TRUE; + if(md_is_html_processing_instruction(ctx, lines, n_lines, beg, max_end, p_end) == TRUE) + return TRUE; + if(md_is_html_declaration(ctx, lines, n_lines, beg, max_end, p_end) == TRUE) + return TRUE; + if(md_is_html_cdata(ctx, lines, n_lines, beg, max_end, p_end) == TRUE) + return TRUE; + + return FALSE; +} + + +/**************************** + *** Recognizing Entity *** + ****************************/ + +static int +md_is_hex_entity_contents(MD_CTX* ctx, const CHAR* text, OFF beg, OFF max_end, OFF* p_end) +{ + OFF off = beg; + + while(off < max_end && ISXDIGIT_(text[off]) && off - beg <= 8) + off++; + + if(1 <= off - beg && off - beg <= 8) { + *p_end = off; + return TRUE; + } else { + return FALSE; + } +} + +static int +md_is_dec_entity_contents(MD_CTX* ctx, const CHAR* text, OFF beg, OFF max_end, OFF* p_end) +{ + OFF off = beg; + + while(off < max_end && ISDIGIT_(text[off]) && off - beg <= 8) + off++; + + if(1 <= off - beg && off - beg <= 8) { + *p_end = off; + return TRUE; + } else { + return FALSE; + } +} + +static int +md_is_named_entity_contents(MD_CTX* ctx, const CHAR* text, OFF beg, OFF max_end, OFF* p_end) +{ + OFF off = beg; + + if(off < max_end && ISALPHA_(text[off])) + off++; + else + return FALSE; + + while(off < max_end && ISALNUM_(text[off]) && off - beg <= 48) + off++; + + if(2 <= off - beg && off - beg <= 48) { + *p_end = off; + return TRUE; + } else { + return FALSE; + } +} + +static int +md_is_entity_str(MD_CTX* ctx, const CHAR* text, OFF beg, OFF max_end, OFF* p_end) +{ + int is_contents; + OFF off = beg; + + MD_ASSERT(text[off] == _T('&')); + off++; + + if(off+2 < max_end && text[off] == _T('#') && (text[off+1] == _T('x') || text[off+1] == _T('X'))) + is_contents = md_is_hex_entity_contents(ctx, text, off+2, max_end, &off); + else if(off+1 < max_end && text[off] == _T('#')) + is_contents = md_is_dec_entity_contents(ctx, text, off+1, max_end, &off); + else + is_contents = md_is_named_entity_contents(ctx, text, off, max_end, &off); + + if(is_contents && off < max_end && text[off] == _T(';')) { + *p_end = off+1; + return TRUE; + } else { + return FALSE; + } +} + +static inline int +md_is_entity(MD_CTX* ctx, OFF beg, OFF max_end, OFF* p_end) +{ + return md_is_entity_str(ctx, ctx->text, beg, max_end, p_end); +} + + +/****************************** + *** Attribute Management *** + ******************************/ + +typedef struct MD_ATTRIBUTE_BUILD_tag MD_ATTRIBUTE_BUILD; +struct MD_ATTRIBUTE_BUILD_tag { + CHAR* text; + MD_TEXTTYPE* substr_types; + OFF* substr_offsets; + int substr_count; + int substr_alloc; + MD_TEXTTYPE trivial_types[1]; + OFF trivial_offsets[2]; +}; + + +#define MD_BUILD_ATTR_NO_ESCAPES 0x0001 + +static int +md_build_attr_append_substr(MD_CTX* ctx, MD_ATTRIBUTE_BUILD* build, + MD_TEXTTYPE type, OFF off) +{ + if(build->substr_count >= build->substr_alloc) { + MD_TEXTTYPE* new_substr_types; + OFF* new_substr_offsets; + + build->substr_alloc = (build->substr_alloc == 0 ? 8 : build->substr_alloc * 2); + + new_substr_types = (MD_TEXTTYPE*) realloc(build->substr_types, + build->substr_alloc * sizeof(MD_TEXTTYPE)); + if(new_substr_types == NULL) { + MD_LOG("realloc() failed."); + return -1; + } + /* Note +1 to reserve space for final offset (== raw_size). */ + new_substr_offsets = (OFF*) realloc(build->substr_offsets, + (build->substr_alloc+1) * sizeof(OFF)); + if(new_substr_offsets == NULL) { + MD_LOG("realloc() failed."); + free(new_substr_types); + return -1; + } + + build->substr_types = new_substr_types; + build->substr_offsets = new_substr_offsets; + } + + build->substr_types[build->substr_count] = type; + build->substr_offsets[build->substr_count] = off; + build->substr_count++; + return 0; +} + +static void +md_free_attribute(MD_CTX* ctx, MD_ATTRIBUTE_BUILD* build) +{ + if(build->substr_alloc > 0) { + free(build->text); + free(build->substr_types); + free(build->substr_offsets); + } +} + +static int +md_build_attribute(MD_CTX* ctx, const CHAR* raw_text, SZ raw_size, + unsigned flags, MD_ATTRIBUTE* attr, MD_ATTRIBUTE_BUILD* build) +{ + OFF raw_off, off; + int is_trivial; + int ret = 0; + + memset(build, 0, sizeof(MD_ATTRIBUTE_BUILD)); + + /* If there is no backslash and no ampersand, build trivial attribute + * without any malloc(). */ + is_trivial = TRUE; + for(raw_off = 0; raw_off < raw_size; raw_off++) { + if(ISANYOF3_(raw_text[raw_off], _T('\\'), _T('&'), _T('\0'))) { + is_trivial = FALSE; + break; + } + } + + if(is_trivial) { + build->text = (CHAR*) (raw_size ? raw_text : NULL); + build->substr_types = build->trivial_types; + build->substr_offsets = build->trivial_offsets; + build->substr_count = 1; + build->substr_alloc = 0; + build->trivial_types[0] = MD_TEXT_NORMAL; + build->trivial_offsets[0] = 0; + build->trivial_offsets[1] = raw_size; + off = raw_size; + } else { + build->text = (CHAR*) malloc(raw_size * sizeof(CHAR)); + if(build->text == NULL) { + MD_LOG("malloc() failed."); + goto abort; + } + + raw_off = 0; + off = 0; + + while(raw_off < raw_size) { + if(raw_text[raw_off] == _T('\0')) { + MD_CHECK(md_build_attr_append_substr(ctx, build, MD_TEXT_NULLCHAR, off)); + memcpy(build->text + off, raw_text + raw_off, 1); + off++; + raw_off++; + continue; + } + + if(raw_text[raw_off] == _T('&')) { + OFF ent_end; + + if(md_is_entity_str(ctx, raw_text, raw_off, raw_size, &ent_end)) { + MD_CHECK(md_build_attr_append_substr(ctx, build, MD_TEXT_ENTITY, off)); + memcpy(build->text + off, raw_text + raw_off, ent_end - raw_off); + off += ent_end - raw_off; + raw_off = ent_end; + continue; + } + } + + if(build->substr_count == 0 || build->substr_types[build->substr_count-1] != MD_TEXT_NORMAL) + MD_CHECK(md_build_attr_append_substr(ctx, build, MD_TEXT_NORMAL, off)); + + if(!(flags & MD_BUILD_ATTR_NO_ESCAPES) && + raw_text[raw_off] == _T('\\') && raw_off+1 < raw_size && + (ISPUNCT_(raw_text[raw_off+1]) || ISNEWLINE_(raw_text[raw_off+1]))) + raw_off++; + + build->text[off++] = raw_text[raw_off++]; + } + build->substr_offsets[build->substr_count] = off; + } + + attr->text = build->text; + attr->size = off; + attr->substr_offsets = build->substr_offsets; + attr->substr_types = build->substr_types; + return 0; + +abort: + md_free_attribute(ctx, build); + return -1; +} + + +/********************************************* + *** Dictionary of Reference Definitions *** + *********************************************/ + +#define MD_FNV1A_BASE 2166136261 +#define MD_FNV1A_PRIME 16777619 + +static inline unsigned +md_fnv1a(unsigned base, const void* data, size_t n) +{ + const unsigned char* buf = (const unsigned char*) data; + unsigned hash = base; + size_t i; + + for(i = 0; i < n; i++) { + hash ^= buf[i]; + hash *= MD_FNV1A_PRIME; + } + + return hash; +} + + +struct MD_REF_DEF_tag { + CHAR* label; + CHAR* title; + unsigned hash; + SZ label_size : 24; + unsigned label_needs_free : 1; + unsigned title_needs_free : 1; + SZ title_size; + OFF dest_beg; + OFF dest_end; +}; + +/* Label equivalence is quite complicated with regards to whitespace and case + * folding. This complicates computing a hash of it as well as direct comparison + * of two labels. */ + +static unsigned +md_link_label_hash(const CHAR* label, SZ size) +{ + unsigned hash = MD_FNV1A_BASE; + OFF off; + int codepoint; + int is_whitespace = FALSE; + + off = md_skip_unicode_whitespace(label, 0, size); + while(off < size) { + SZ char_size; + + codepoint = md_decode_unicode(label, off, size, &char_size); + is_whitespace = ISUNICODEWHITESPACE_(codepoint) || ISNEWLINE_(label[off]); + + if(is_whitespace) { + codepoint = ' '; + hash = md_fnv1a(hash, &codepoint, 1 * sizeof(int)); + + off = md_skip_unicode_whitespace(label, off, size); + } else { + MD_UNICODE_FOLD_INFO fold_info; + + md_get_unicode_fold_info(codepoint, &fold_info); + hash = md_fnv1a(hash, fold_info.codepoints, fold_info.n_codepoints * sizeof(int)); + + off += char_size; + } + } + + if(!is_whitespace) { + codepoint = ' '; + hash = md_fnv1a(hash, &codepoint, 1 * sizeof(int)); + } + + return hash; +} + +static int +md_link_label_cmp(const CHAR* a_label, SZ a_size, const CHAR* b_label, SZ b_size) +{ + OFF a_off; + OFF b_off; + + /* The slow path, with Unicode case folding and Unicode whitespace collapsing. */ + a_off = md_skip_unicode_whitespace(a_label, 0, a_size); + b_off = md_skip_unicode_whitespace(b_label, 0, b_size); + while(a_off < a_size || b_off < b_size) { + int a_codepoint, b_codepoint; + SZ a_char_size, b_char_size; + int a_is_whitespace, b_is_whitespace; + + if(a_off < a_size) { + a_codepoint = md_decode_unicode(a_label, a_off, a_size, &a_char_size); + a_is_whitespace = ISUNICODEWHITESPACE_(a_codepoint) || ISNEWLINE_(a_label[a_off]); + } else { + /* Treat end of label as a whitespace. */ + a_codepoint = -1; + a_is_whitespace = TRUE; + } + + if(b_off < b_size) { + b_codepoint = md_decode_unicode(b_label, b_off, b_size, &b_char_size); + b_is_whitespace = ISUNICODEWHITESPACE_(b_codepoint) || ISNEWLINE_(b_label[b_off]); + } else { + /* Treat end of label as a whitespace. */ + b_codepoint = -1; + b_is_whitespace = TRUE; + } + + if(a_is_whitespace || b_is_whitespace) { + if(!a_is_whitespace || !b_is_whitespace) + return (a_is_whitespace ? -1 : +1); + + a_off = md_skip_unicode_whitespace(a_label, a_off, a_size); + b_off = md_skip_unicode_whitespace(b_label, b_off, b_size); + } else { + MD_UNICODE_FOLD_INFO a_fold_info, b_fold_info; + int cmp; + + md_get_unicode_fold_info(a_codepoint, &a_fold_info); + md_get_unicode_fold_info(b_codepoint, &b_fold_info); + + if(a_fold_info.n_codepoints != b_fold_info.n_codepoints) + return (a_fold_info.n_codepoints - b_fold_info.n_codepoints); + cmp = memcmp(a_fold_info.codepoints, b_fold_info.codepoints, a_fold_info.n_codepoints * sizeof(int)); + if(cmp != 0) + return cmp; + + a_off += a_char_size; + b_off += b_char_size; + } + } + + return 0; +} + +typedef struct MD_REF_DEF_LIST_tag MD_REF_DEF_LIST; +struct MD_REF_DEF_LIST_tag { + int n_ref_defs; + int alloc_ref_defs; + MD_REF_DEF* ref_defs[]; /* Valid items always point into ctx->ref_defs[] */ +}; + +static int +md_ref_def_cmp(const void* a, const void* b) +{ + const MD_REF_DEF* a_ref = *(const MD_REF_DEF**)a; + const MD_REF_DEF* b_ref = *(const MD_REF_DEF**)b; + + if(a_ref->hash < b_ref->hash) + return -1; + else if(a_ref->hash > b_ref->hash) + return +1; + else + return md_link_label_cmp(a_ref->label, a_ref->label_size, b_ref->label, b_ref->label_size); +} + +static int +md_ref_def_cmp_stable(const void* a, const void* b) +{ + int cmp; + + cmp = md_ref_def_cmp(a, b); + + /* Ensure stability of the sorting. */ + if(cmp == 0) { + const MD_REF_DEF* a_ref = *(const MD_REF_DEF**)a; + const MD_REF_DEF* b_ref = *(const MD_REF_DEF**)b; + + if(a_ref < b_ref) + cmp = -1; + else if(a_ref > b_ref) + cmp = +1; + else + cmp = 0; + } + + return cmp; +} + +static int +md_build_ref_def_hashtable(MD_CTX* ctx) +{ + int i, j; + + if(ctx->n_ref_defs == 0) + return 0; + + ctx->ref_def_hashtable_size = (ctx->n_ref_defs * 5) / 4; + ctx->ref_def_hashtable = malloc(ctx->ref_def_hashtable_size * sizeof(void*)); + if(ctx->ref_def_hashtable == NULL) { + MD_LOG("malloc() failed."); + goto abort; + } + memset(ctx->ref_def_hashtable, 0, ctx->ref_def_hashtable_size * sizeof(void*)); + + /* Each member of ctx->ref_def_hashtable[] can be: + * -- NULL, + * -- pointer to the MD_REF_DEF in ctx->ref_defs[], or + * -- pointer to a MD_REF_DEF_LIST, which holds multiple pointers to + * such MD_REF_DEFs. + */ + for(i = 0; i < ctx->n_ref_defs; i++) { + MD_REF_DEF* def = &ctx->ref_defs[i]; + void* bucket; + MD_REF_DEF_LIST* list; + + def->hash = md_link_label_hash(def->label, def->label_size); + bucket = ctx->ref_def_hashtable[def->hash % ctx->ref_def_hashtable_size]; + + if(bucket == NULL) { + ctx->ref_def_hashtable[def->hash % ctx->ref_def_hashtable_size] = def; + continue; + } + + if(ctx->ref_defs <= (MD_REF_DEF*) bucket && (MD_REF_DEF*) bucket < ctx->ref_defs + ctx->n_ref_defs) { + /* The bucket already contains one ref. def. Lets see whether it + * is the same label (ref. def. duplicate) or different one + * (hash conflict). */ + MD_REF_DEF* old_def = (MD_REF_DEF*) bucket; + + if(md_link_label_cmp(def->label, def->label_size, old_def->label, old_def->label_size) == 0) { + /* Ignore this ref. def. */ + continue; + } + + /* Make the bucket capable of holding more ref. defs. */ + list = (MD_REF_DEF_LIST*) malloc(sizeof(MD_REF_DEF_LIST) + 4 * sizeof(MD_REF_DEF)); + if(list == NULL) { + MD_LOG("malloc() failed."); + goto abort; + } + list->ref_defs[0] = old_def; + list->ref_defs[1] = def; + list->n_ref_defs = 2; + list->alloc_ref_defs = 4; + ctx->ref_def_hashtable[def->hash % ctx->ref_def_hashtable_size] = list; + continue; + } + + /* Append the def to the bucket list. */ + list = (MD_REF_DEF_LIST*) bucket; + if(list->n_ref_defs >= list->alloc_ref_defs) { + MD_REF_DEF_LIST* list_tmp = (MD_REF_DEF_LIST*) realloc(list, + sizeof(MD_REF_DEF_LIST) + 2 * list->alloc_ref_defs * sizeof(MD_REF_DEF)); + if(list_tmp == NULL) { + MD_LOG("realloc() failed."); + goto abort; + } + list = list_tmp; + list->alloc_ref_defs *= 2; + ctx->ref_def_hashtable[def->hash % ctx->ref_def_hashtable_size] = list; + } + + list->ref_defs[list->n_ref_defs] = def; + list->n_ref_defs++; + } + + /* Sort the complex buckets so we can use bsearch() with them. */ + for(i = 0; i < ctx->ref_def_hashtable_size; i++) { + void* bucket = ctx->ref_def_hashtable[i]; + MD_REF_DEF_LIST* list; + + if(bucket == NULL) + continue; + if(ctx->ref_defs <= (MD_REF_DEF*) bucket && (MD_REF_DEF*) bucket < ctx->ref_defs + ctx->n_ref_defs) + continue; + + list = (MD_REF_DEF_LIST*) bucket; + qsort(list->ref_defs, list->n_ref_defs, sizeof(MD_REF_DEF*), md_ref_def_cmp_stable); + + /* Disable duplicates. */ + for(j = 1; j < list->n_ref_defs; j++) { + if(md_ref_def_cmp(&list->ref_defs[j-1], &list->ref_defs[j]) == 0) + list->ref_defs[j] = list->ref_defs[j-1]; + } + } + + return 0; + +abort: + return -1; +} + +static void +md_free_ref_def_hashtable(MD_CTX* ctx) +{ + if(ctx->ref_def_hashtable != NULL) { + int i; + + for(i = 0; i < ctx->ref_def_hashtable_size; i++) { + void* bucket = ctx->ref_def_hashtable[i]; + if(bucket == NULL) + continue; + if(ctx->ref_defs <= (MD_REF_DEF*) bucket && (MD_REF_DEF*) bucket < ctx->ref_defs + ctx->n_ref_defs) + continue; + free(bucket); + } + + free(ctx->ref_def_hashtable); + } +} + +static const MD_REF_DEF* +md_lookup_ref_def(MD_CTX* ctx, const CHAR* label, SZ label_size) +{ + unsigned hash; + void* bucket; + + if(ctx->ref_def_hashtable_size == 0) + return NULL; + + hash = md_link_label_hash(label, label_size); + bucket = ctx->ref_def_hashtable[hash % ctx->ref_def_hashtable_size]; + + if(bucket == NULL) { + return NULL; + } else if(ctx->ref_defs <= (MD_REF_DEF*) bucket && (MD_REF_DEF*) bucket < ctx->ref_defs + ctx->n_ref_defs) { + const MD_REF_DEF* def = (MD_REF_DEF*) bucket; + + if(md_link_label_cmp(def->label, def->label_size, label, label_size) == 0) + return def; + else + return NULL; + } else { + MD_REF_DEF_LIST* list = (MD_REF_DEF_LIST*) bucket; + MD_REF_DEF key_buf; + const MD_REF_DEF* key = &key_buf; + const MD_REF_DEF** ret; + + key_buf.label = (CHAR*) label; + key_buf.label_size = label_size; + key_buf.hash = md_link_label_hash(key_buf.label, key_buf.label_size); + + ret = (const MD_REF_DEF**) bsearch(&key, list->ref_defs, + list->n_ref_defs, sizeof(MD_REF_DEF*), md_ref_def_cmp); + if(ret != NULL) + return *ret; + else + return NULL; + } +} + + +/*************************** + *** Recognizing Links *** + ***************************/ + +/* Note this code is partially shared between processing inlines and blocks + * as reference definitions and links share some helper parser functions. + */ + +typedef struct MD_LINK_ATTR_tag MD_LINK_ATTR; +struct MD_LINK_ATTR_tag { + OFF dest_beg; + OFF dest_end; + + CHAR* title; + SZ title_size; + int title_needs_free; +}; + + +static int +md_is_link_label(MD_CTX* ctx, const MD_LINE* lines, int n_lines, OFF beg, + OFF* p_end, int* p_beg_line_index, int* p_end_line_index, + OFF* p_contents_beg, OFF* p_contents_end) +{ + OFF off = beg; + OFF contents_beg = 0; + OFF contents_end = 0; + int line_index = 0; + int len = 0; + + if(CH(off) != _T('[')) + return FALSE; + off++; + + while(1) { + OFF line_end = lines[line_index].end; + + while(off < line_end) { + if(CH(off) == _T('\\') && off+1 < ctx->size && (ISPUNCT(off+1) || ISNEWLINE(off+1))) { + if(contents_end == 0) { + contents_beg = off; + *p_beg_line_index = line_index; + } + contents_end = off + 2; + off += 2; + } else if(CH(off) == _T('[')) { + return FALSE; + } else if(CH(off) == _T(']')) { + if(contents_beg < contents_end) { + /* Success. */ + *p_contents_beg = contents_beg; + *p_contents_end = contents_end; + *p_end = off+1; + *p_end_line_index = line_index; + return TRUE; + } else { + /* Link label must have some non-whitespace contents. */ + return FALSE; + } + } else { + int codepoint; + SZ char_size; + + codepoint = md_decode_unicode(ctx->text, off, ctx->size, &char_size); + if(!ISUNICODEWHITESPACE_(codepoint)) { + if(contents_end == 0) { + contents_beg = off; + *p_beg_line_index = line_index; + } + contents_end = off + char_size; + } + + off += char_size; + } + + len++; + if(len > 999) + return FALSE; + } + + line_index++; + len++; + if(line_index < n_lines) + off = lines[line_index].beg; + else + break; + } + + return FALSE; +} + +static int +md_is_link_destination_A(MD_CTX* ctx, OFF beg, OFF max_end, OFF* p_end, + OFF* p_contents_beg, OFF* p_contents_end) +{ + OFF off = beg; + + if(off >= max_end || CH(off) != _T('<')) + return FALSE; + off++; + + while(off < max_end) { + if(CH(off) == _T('\\') && off+1 < max_end && ISPUNCT(off+1)) { + off += 2; + continue; + } + + if(ISWHITESPACE(off) || CH(off) == _T('<')) + return FALSE; + + if(CH(off) == _T('>')) { + /* Success. */ + *p_contents_beg = beg+1; + *p_contents_end = off; + *p_end = off+1; + return TRUE; + } + + off++; + } + + return FALSE; +} + +static int +md_is_link_destination_B(MD_CTX* ctx, OFF beg, OFF max_end, OFF* p_end, + OFF* p_contents_beg, OFF* p_contents_end) +{ + OFF off = beg; + int parenthesis_level = 0; + + while(off < max_end) { + if(CH(off) == _T('\\') && off+1 < max_end && ISPUNCT(off+1)) { + off += 2; + continue; + } + + if(ISWHITESPACE(off) || ISCNTRL(off)) + break; + + /* Link destination may include balanced pairs of unescaped '(' ')'. + * Note we limit the maximal nesting level by 32 to protect us from + * https://github.com/jgm/cmark/issues/214 */ + if(CH(off) == _T('(')) { + parenthesis_level++; + if(parenthesis_level > 32) + return FALSE; + } else if(CH(off) == _T(')')) { + if(parenthesis_level == 0) + break; + parenthesis_level--; + } + + off++; + } + + if(parenthesis_level != 0 || off == beg) + return FALSE; + + /* Success. */ + *p_contents_beg = beg; + *p_contents_end = off; + *p_end = off; + return TRUE; +} + +static int +md_is_link_title(MD_CTX* ctx, const MD_LINE* lines, int n_lines, OFF beg, + OFF* p_end, int* p_beg_line_index, int* p_end_line_index, + OFF* p_contents_beg, OFF* p_contents_end) +{ + OFF off = beg; + CHAR closer_char; + int line_index = 0; + + /* Optional white space with up to one line break. */ + while(off < lines[line_index].end && ISWHITESPACE(off)) + off++; + if(off >= lines[line_index].end) { + line_index++; + if(line_index >= n_lines) + return FALSE; + off = lines[line_index].beg; + } + + *p_beg_line_index = line_index; + + /* First char determines how to detect end of it. */ + switch(CH(off)) { + case _T('"'): closer_char = _T('"'); break; + case _T('\''): closer_char = _T('\''); break; + case _T('('): closer_char = _T(')'); break; + default: return FALSE; + } + off++; + + *p_contents_beg = off; + + while(line_index < n_lines) { + OFF line_end = lines[line_index].end; + + while(off < line_end) { + if(CH(off) == _T('\\') && off+1 < ctx->size && (ISPUNCT(off+1) || ISNEWLINE(off+1))) { + off++; + } else if(CH(off) == closer_char) { + /* Success. */ + *p_contents_end = off; + *p_end = off+1; + *p_end_line_index = line_index; + return TRUE; + } + + off++; + } + + line_index++; + } + + return FALSE; +} + +/* Returns 0 if it is not a reference definition. + * + * Returns N > 0 if it is a reference definition. N then corresponds to the + * number of lines forming it). In this case the definition is stored for + * resolving any links referring to it. + * + * Returns -1 in case of an error (out of memory). + */ +static int +md_is_link_reference_definition_helper( + MD_CTX* ctx, const MD_LINE* lines, int n_lines, + int (*is_link_dest_fn)(MD_CTX*, OFF, OFF, OFF*, OFF*, OFF*)) +{ + OFF label_contents_beg; + OFF label_contents_end; + int label_contents_line_index = -1; + int label_is_multiline; + CHAR* label; + SZ label_size; + int label_needs_free = FALSE; + OFF dest_contents_beg; + OFF dest_contents_end; + OFF title_contents_beg; + OFF title_contents_end; + int title_contents_line_index; + int title_is_multiline; + OFF off; + int line_index = 0; + int tmp_line_index; + MD_REF_DEF* def; + int ret; + + /* Link label. */ + if(!md_is_link_label(ctx, lines, n_lines, lines[0].beg, + &off, &label_contents_line_index, &line_index, + &label_contents_beg, &label_contents_end)) + return FALSE; + label_is_multiline = (label_contents_line_index != line_index); + + /* Colon. */ + if(off >= lines[line_index].end || CH(off) != _T(':')) + return FALSE; + off++; + + /* Optional white space with up to one line break. */ + while(off < lines[line_index].end && ISWHITESPACE(off)) + off++; + if(off >= lines[line_index].end) { + line_index++; + if(line_index >= n_lines) + return FALSE; + off = lines[line_index].beg; + } + + /* Link destination. */ + if(!is_link_dest_fn(ctx, off, lines[line_index].end, + &off, &dest_contents_beg, &dest_contents_end)) + return FALSE; + + /* (Optional) title. Note we interpret it as an title only if nothing + * more follows on its last line. */ + if(md_is_link_title(ctx, lines + line_index, n_lines - line_index, off, + &off, &title_contents_line_index, &tmp_line_index, + &title_contents_beg, &title_contents_end) + && off >= lines[line_index + tmp_line_index].end) + { + title_is_multiline = (tmp_line_index != title_contents_line_index); + title_contents_line_index += line_index; + line_index += tmp_line_index; + } else { + /* Not a title. */ + title_is_multiline = FALSE; + title_contents_beg = off; + title_contents_end = off; + title_contents_line_index = 0; + } + + /* Nothing more can follow on the last line. */ + if(off < lines[line_index].end) + return FALSE; + + /* Construct label. */ + if(!label_is_multiline) { + label = (CHAR*) STR(label_contents_beg); + label_size = label_contents_end - label_contents_beg; + label_needs_free = FALSE; + } else { + MD_CHECK(md_merge_lines_alloc(ctx, label_contents_beg, label_contents_end, + lines + label_contents_line_index, n_lines - label_contents_line_index, + _T(' '), &label, &label_size)); + label_needs_free = TRUE; + } + + /* Store the reference definition. */ + if(ctx->n_ref_defs >= ctx->alloc_ref_defs) { + MD_REF_DEF* new_defs; + + ctx->alloc_ref_defs = (ctx->alloc_ref_defs > 0 ? ctx->alloc_ref_defs * 2 : 16); + new_defs = (MD_REF_DEF*) realloc(ctx->ref_defs, ctx->alloc_ref_defs * sizeof(MD_REF_DEF)); + if(new_defs == NULL) { + MD_LOG("realloc() failed."); + ret = -1; + goto abort; + } + + ctx->ref_defs = new_defs; + } + + def = &ctx->ref_defs[ctx->n_ref_defs]; + memset(def, 0, sizeof(MD_REF_DEF)); + + def->label = label; + def->label_size = label_size; + def->label_needs_free = label_needs_free; + + def->dest_beg = dest_contents_beg; + def->dest_end = dest_contents_end; + + if(title_contents_beg >= title_contents_end) { + def->title = NULL; + def->title_size = 0; + } else if(!title_is_multiline) { + def->title = (CHAR*) STR(title_contents_beg); + def->title_size = title_contents_end - title_contents_beg; + } else { + MD_CHECK(md_merge_lines_alloc(ctx, title_contents_beg, title_contents_end, + lines + title_contents_line_index, n_lines - title_contents_line_index, + _T('\n'), &def->title, &def->title_size)); + def->title_needs_free = TRUE; + } + + /* Success. */ + ctx->n_ref_defs++; + return line_index + 1; + +abort: + /* Failure. */ + if(label_needs_free) + free(label); + return -1; +} + +static inline int +md_is_link_reference_definition(MD_CTX* ctx, const MD_LINE* lines, int n_lines) +{ + int ret; + ret = md_is_link_reference_definition_helper(ctx, lines, n_lines, md_is_link_destination_A); + if(ret == 0) + ret = md_is_link_reference_definition_helper(ctx, lines, n_lines, md_is_link_destination_B); + return ret; +} + +static int +md_is_link_reference(MD_CTX* ctx, const MD_LINE* lines, int n_lines, + OFF beg, OFF end, MD_LINK_ATTR* attr) +{ + const MD_REF_DEF* def; + const MD_LINE* beg_line; + const MD_LINE* end_line; + CHAR* label; + SZ label_size; + int ret; + + MD_ASSERT(CH(beg) == _T('[') || CH(beg) == _T('!')); + MD_ASSERT(CH(end-1) == _T(']')); + + beg += (CH(beg) == _T('!') ? 2 : 1); + end--; + + /* Find lines corresponding to the beg and end positions. */ + MD_ASSERT(lines[0].beg <= beg); + beg_line = lines; + while(beg >= beg_line->end) + beg_line++; + + MD_ASSERT(end <= lines[n_lines-1].end); + end_line = beg_line; + while(end >= end_line->end) + end_line++; + + if(beg_line != end_line) { + MD_CHECK(md_merge_lines_alloc(ctx, beg, end, beg_line, + n_lines - (beg_line - lines), _T(' '), &label, &label_size)); + } else { + label = (CHAR*) STR(beg); + label_size = end - beg; + } + + def = md_lookup_ref_def(ctx, label, label_size); + if(def != NULL) { + attr->dest_beg = def->dest_beg; + attr->dest_end = def->dest_end; + attr->title = def->title; + attr->title_size = def->title_size; + attr->title_needs_free = FALSE; + } + + if(beg_line != end_line) + free(label); + + ret = (def != NULL); + +abort: + return ret; +} + +static int +md_is_inline_link_spec_helper(MD_CTX* ctx, const MD_LINE* lines, int n_lines, + OFF beg, OFF* p_end, MD_LINK_ATTR* attr, + int (*is_link_dest_fn)(MD_CTX*, OFF, OFF, OFF*, OFF*, OFF*)) +{ + int line_index = 0; + int tmp_line_index; + OFF title_contents_beg; + OFF title_contents_end; + int title_contents_line_index; + int title_is_multiline; + OFF off = beg; + int ret = FALSE; + + while(off >= lines[line_index].end) + line_index++; + + MD_ASSERT(CH(off) == _T('(')); + off++; + + /* Optional white space with up to one line break. */ + while(off < lines[line_index].end && ISWHITESPACE(off)) + off++; + if(off >= lines[line_index].end && ISNEWLINE(off)) { + line_index++; + if(line_index >= n_lines) + return FALSE; + off = lines[line_index].beg; + } + + /* Link destination may be omitted, but only when not also having a title. */ + if(off < ctx->size && CH(off) == _T(')')) { + attr->dest_beg = off; + attr->dest_end = off; + attr->title = NULL; + attr->title_size = 0; + attr->title_needs_free = FALSE; + off++; + *p_end = off; + return TRUE; + } + + /* Link destination. */ + if(!is_link_dest_fn(ctx, off, lines[line_index].end, + &off, &attr->dest_beg, &attr->dest_end)) + return FALSE; + + /* (Optional) title. */ + if(md_is_link_title(ctx, lines + line_index, n_lines - line_index, off, + &off, &title_contents_line_index, &tmp_line_index, + &title_contents_beg, &title_contents_end)) + { + title_is_multiline = (tmp_line_index != title_contents_line_index); + title_contents_line_index += line_index; + line_index += tmp_line_index; + } else { + /* Not a title. */ + title_is_multiline = FALSE; + title_contents_beg = off; + title_contents_end = off; + title_contents_line_index = 0; + } + + /* Optional whitespace followed with final ')'. */ + while(off < lines[line_index].end && ISWHITESPACE(off)) + off++; + if(off >= lines[line_index].end && ISNEWLINE(off)) { + line_index++; + if(line_index >= n_lines) + return FALSE; + off = lines[line_index].beg; + } + if(CH(off) != _T(')')) + goto abort; + off++; + + if(title_contents_beg >= title_contents_end) { + attr->title = NULL; + attr->title_size = 0; + attr->title_needs_free = FALSE; + } else if(!title_is_multiline) { + attr->title = (CHAR*) STR(title_contents_beg); + attr->title_size = title_contents_end - title_contents_beg; + attr->title_needs_free = FALSE; + } else { + MD_CHECK(md_merge_lines_alloc(ctx, title_contents_beg, title_contents_end, + lines + title_contents_line_index, n_lines - title_contents_line_index, + _T('\n'), &attr->title, &attr->title_size)); + attr->title_needs_free = TRUE; + } + + *p_end = off; + ret = TRUE; + +abort: + return ret; +} + +static inline int +md_is_inline_link_spec(MD_CTX* ctx, const MD_LINE* lines, int n_lines, + OFF beg, OFF* p_end, MD_LINK_ATTR* attr) +{ + return md_is_inline_link_spec_helper(ctx, lines, n_lines, beg, p_end, attr, md_is_link_destination_A) || + md_is_inline_link_spec_helper(ctx, lines, n_lines, beg, p_end, attr, md_is_link_destination_B); +} + +static void +md_free_ref_defs(MD_CTX* ctx) +{ + int i; + + for(i = 0; i < ctx->n_ref_defs; i++) { + MD_REF_DEF* def = &ctx->ref_defs[i]; + + if(def->label_needs_free) + free(def->label); + if(def->title_needs_free) + free(def->title); + } + + free(ctx->ref_defs); +} + + +/****************************************** + *** Processing Inlines (a.k.a Spans) *** + ******************************************/ + +/* We process inlines in few phases: + * + * (1) We go through the block text and collect all significant characters + * which may start/end a span or some other significant position into + * ctx->marks[]. Core of this is what md_collect_marks() does. + * + * We also do some very brief preliminary context-less analysis, whether + * it might be opener or closer (e.g. of an emphasis span). + * + * This speeds the other steps as we do not need to re-iterate over all + * characters anymore. + * + * (2) We analyze each potential mark types, in order by their precedence. + * + * In each md_analyze_XXX() function, we re-iterate list of the marks, + * skipping already resolved regions (in preceding precedences) and try to + * resolve them. + * + * (2.1) For trivial marks, which are single (e.g. HTML entity), we just mark + * them as resolved. + * + * (2.2) For range-type marks, we analyze whether the mark could be closer + * and, if yes, whether there is some preceding opener it could satisfy. + * + * If not we check whether it could be really an opener and if yes, we + * remember it so subsequent closers may resolve it. + * + * (3) Finally, when all marks were analyzed, we render the block contents + * by calling MD_RENDERER::text() callback, interrupting by ::enter_span() + * or ::close_span() whenever we reach a resolved mark. + */ + + +/* The mark structure. + * + * '\\': Maybe escape sequence. + * '\0': NULL char. + * '*': Maybe (strong) emphasis start/end. + * '_': Maybe (strong) emphasis start/end. + * '~': Maybe strikethrough start/end (needs MD_FLAG_STRIKETHROUGH). + * '`': Maybe code span start/end. + * '&': Maybe start of entity. + * ';': Maybe end of entity. + * '<': Maybe start of raw HTML or autolink. + * '>': Maybe end of raw HTML or autolink. + * '[': Maybe start of link label or link text. + * '!': Equivalent of '[' for image. + * ']': Maybe end of link label or link text. + * '@': Maybe permissive e-mail auto-link (needs MD_FLAG_PERMISSIVEEMAILAUTOLINKS). + * ':': Maybe permissive URL auto-link (needs MD_FLAG_PERMISSIVEURLAUTOLINKS). + * '.': Maybe permissive WWW auto-link (needs MD_FLAG_PERMISSIVEWWWAUTOLINKS). + * 'D': Dummy mark, it reserves a space for splitting a previous mark + * (e.g. emphasis) or to make more space for storing some special data + * related to the preceding mark (e.g. link). + * + * Note that not all instances of these chars in the text imply creation of the + * structure. Only those which have (or may have, after we see more context) + * the special meaning. + * + * (Keep this struct as small as possible to fit as much of them into CPU + * cache line.) + */ +struct MD_MARK_tag { + OFF beg; + OFF end; + + /* For unresolved openers, 'prev' and 'next' form the chain of open openers + * of given type 'ch'. + * + * During resolving, we disconnect from the chain and point to the + * corresponding counterpart so opener points to its closer and vice versa. + */ + int prev; + int next; + CHAR ch; + unsigned char flags; +}; + +/* Mark flags (these apply to ALL mark types). */ +#define MD_MARK_POTENTIAL_OPENER 0x01 /* Maybe opener. */ +#define MD_MARK_POTENTIAL_CLOSER 0x02 /* Maybe closer. */ +#define MD_MARK_OPENER 0x04 /* Definitely opener. */ +#define MD_MARK_CLOSER 0x08 /* Definitely closer. */ +#define MD_MARK_RESOLVED 0x10 /* Resolved in any definite way. */ + +/* Mark flags specific for various mark types (so they can share bits). */ +#define MD_MARK_EMPH_INTRAWORD 0x20 /* Helper for the "rule of 3". */ +#define MD_MARK_EMPH_MODULO3_0 0x40 +#define MD_MARK_EMPH_MODULO3_1 0x80 +#define MD_MARK_EMPH_MODULO3_2 (0x40 | 0x80) +#define MD_MARK_EMPH_MODULO3_MASK (0x40 | 0x80) +#define MD_MARK_AUTOLINK 0x20 /* Distinguisher for '<', '>'. */ +#define MD_MARK_VALIDPERMISSIVEAUTOLINK 0x20 /* For permissive autolinks. */ + + +static MD_MARK* +md_push_mark(MD_CTX* ctx) +{ + if(ctx->n_marks >= ctx->alloc_marks) { + MD_MARK* new_marks; + + ctx->alloc_marks = (ctx->alloc_marks > 0 ? ctx->alloc_marks * 2 : 64); + new_marks = realloc(ctx->marks, ctx->alloc_marks * sizeof(MD_MARK)); + if(new_marks == NULL) { + MD_LOG("realloc() failed."); + return NULL; + } + + ctx->marks = new_marks; + } + + return &ctx->marks[ctx->n_marks++]; +} + +#define PUSH_MARK_() \ + do { \ + mark = md_push_mark(ctx); \ + if(mark == NULL) { \ + ret = -1; \ + goto abort; \ + } \ + } while(0) + +#define PUSH_MARK(ch_, beg_, end_, flags_) \ + do { \ + PUSH_MARK_(); \ + mark->beg = (beg_); \ + mark->end = (end_); \ + mark->prev = -1; \ + mark->next = -1; \ + mark->ch = (char)(ch_); \ + mark->flags = (flags_); \ + } while(0) + + +static void +md_mark_chain_append(MD_CTX* ctx, MD_MARKCHAIN* chain, int mark_index) +{ + if(chain->tail >= 0) + ctx->marks[chain->tail].next = mark_index; + else + chain->head = mark_index; + + ctx->marks[mark_index].prev = chain->tail; + chain->tail = mark_index; +} + +/* Sometimes, we need to store a pointer into the mark. It is quite rare + * so we do not bother to make MD_MARK use union, and it can only happen + * for dummy marks. */ +static inline void +md_mark_store_ptr(MD_CTX* ctx, int mark_index, void* ptr) +{ + MD_MARK* mark = &ctx->marks[mark_index]; + MD_ASSERT(mark->ch == 'D'); + + /* Check only members beg and end are misused for this. */ + MD_ASSERT(sizeof(void*) <= 2 * sizeof(OFF)); + memcpy(mark, &ptr, sizeof(void*)); +} + +static inline void* +md_mark_get_ptr(MD_CTX* ctx, int mark_index) +{ + void* ptr; + MD_MARK* mark = &ctx->marks[mark_index]; + MD_ASSERT(mark->ch == 'D'); + memcpy(&ptr, mark, sizeof(void*)); + return ptr; +} + +static void +md_resolve_range(MD_CTX* ctx, MD_MARKCHAIN* chain, int opener_index, int closer_index) +{ + MD_MARK* opener = &ctx->marks[opener_index]; + MD_MARK* closer = &ctx->marks[closer_index]; + + /* Remove opener from the list of openers. */ + if(chain != NULL) { + if(opener->prev >= 0) + ctx->marks[opener->prev].next = opener->next; + else + chain->head = opener->next; + + if(opener->next >= 0) + ctx->marks[opener->next].prev = opener->prev; + else + chain->tail = opener->prev; + } + + /* Interconnect opener and closer and mark both as resolved. */ + opener->next = closer_index; + opener->flags |= MD_MARK_OPENER | MD_MARK_RESOLVED; + closer->prev = opener_index; + closer->flags |= MD_MARK_CLOSER | MD_MARK_RESOLVED; +} + + +#define MD_ROLLBACK_ALL 0 +#define MD_ROLLBACK_CROSSING 1 + +/* In the range ctx->marks[opener_index] ... [closer_index], undo some or all + * resolvings accordingly to these rules: + * + * (1) All openers BEFORE the range corresponding to any closer inside the + * range are un-resolved and they are re-added to their respective chains + * of unresolved openers. This ensures we can reuse the opener for closers + * AFTER the range. + * + * (2) If 'how' is MD_ROLLBACK_ALL, then ALL resolved marks inside the range + * are discarded. + * + * (3) If 'how' is MD_ROLLBACK_CROSSING, only closers with openers handled + * in (1) are discarded. I.e. pairs of openers and closers which are both + * inside the range are retained as well as any unpaired marks. + */ +static void +md_rollback(MD_CTX* ctx, int opener_index, int closer_index, int how) +{ + int i; + int mark_index; + + /* Cut all unresolved openers at the mark index. */ + for(i = OPENERS_CHAIN_FIRST; i < OPENERS_CHAIN_LAST+1; i++) { + MD_MARKCHAIN* chain = &ctx->mark_chains[i]; + + while(chain->tail >= opener_index) + chain->tail = ctx->marks[chain->tail].prev; + + if(chain->tail >= 0) + ctx->marks[chain->tail].next = -1; + else + chain->head = -1; + } + + /* Go backwards so that un-resolved openers are re-added into their + * respective chains, in the right order. */ + mark_index = closer_index - 1; + while(mark_index > opener_index) { + MD_MARK* mark = &ctx->marks[mark_index]; + int mark_flags = mark->flags; + int discard_flag = (how == MD_ROLLBACK_ALL); + + if(mark->flags & MD_MARK_CLOSER) { + int mark_opener_index = mark->prev; + + /* Undo opener BEFORE the range. */ + if(mark_opener_index < opener_index) { + MD_MARK* mark_opener = &ctx->marks[mark_opener_index]; + MD_MARKCHAIN* chain; + + mark_opener->flags &= ~(MD_MARK_OPENER | MD_MARK_CLOSER | MD_MARK_RESOLVED); + + switch(mark_opener->ch) { + case '*': chain = &ASTERISK_OPENERS; break; + case '_': chain = &UNDERSCORE_OPENERS; break; + case '`': chain = &BACKTICK_OPENERS; break; + case '<': chain = &LOWERTHEN_OPENERS; break; + case '~': chain = &TILDE_OPENERS; break; + default: MD_UNREACHABLE(); break; + } + md_mark_chain_append(ctx, chain, mark_opener_index); + + discard_flag = 1; + } + } + + /* And reset our flags. */ + if(discard_flag) + mark->flags &= ~(MD_MARK_OPENER | MD_MARK_CLOSER | MD_MARK_RESOLVED); + + /* Jump as far as we can over unresolved or non-interesting marks. */ + switch(how) { + case MD_ROLLBACK_CROSSING: + if((mark_flags & MD_MARK_CLOSER) && mark->prev > opener_index) { + /* If we are closer with opener INSIDE the range, there may + * not be any other crosser inside the subrange. */ + mark_index = mark->prev; + break; + } + /* Pass through. */ + default: + mark_index--; + break; + } + } +} + +static void +md_build_mark_char_map(MD_CTX* ctx) +{ + memset(ctx->mark_char_map, 0, sizeof(ctx->mark_char_map)); + + ctx->mark_char_map['\\'] = 1; + ctx->mark_char_map['*'] = 1; + ctx->mark_char_map['_'] = 1; + ctx->mark_char_map['`'] = 1; + ctx->mark_char_map['&'] = 1; + ctx->mark_char_map[';'] = 1; + ctx->mark_char_map['<'] = 1; + ctx->mark_char_map['>'] = 1; + ctx->mark_char_map['['] = 1; + ctx->mark_char_map['!'] = 1; + ctx->mark_char_map[']'] = 1; + ctx->mark_char_map['\0'] = 1; + + if(ctx->parser.flags & MD_FLAG_STRIKETHROUGH) + ctx->mark_char_map['~'] = 1; + + if(ctx->parser.flags & MD_FLAG_PERMISSIVEEMAILAUTOLINKS) + ctx->mark_char_map['@'] = 1; + + if(ctx->parser.flags & MD_FLAG_PERMISSIVEURLAUTOLINKS) + ctx->mark_char_map[':'] = 1; + + if(ctx->parser.flags & MD_FLAG_PERMISSIVEWWWAUTOLINKS) + ctx->mark_char_map['.'] = 1; + + if(ctx->parser.flags & MD_FLAG_TABLES) + ctx->mark_char_map['|'] = 1; + + if(ctx->parser.flags & MD_FLAG_COLLAPSEWHITESPACE) { + int i; + + for(i = 0; i < sizeof(ctx->mark_char_map); i++) { + if(ISWHITESPACE_(i)) + ctx->mark_char_map[i] = 1; + } + } +} + +static int +md_collect_marks(MD_CTX* ctx, const MD_LINE* lines, int n_lines, int table_mode) +{ + int i; + int ret = 0; + MD_MARK* mark; + + for(i = 0; i < n_lines; i++) { + const MD_LINE* line = &lines[i]; + OFF off = line->beg; + OFF line_end = line->end; + + while(TRUE) { + CHAR ch; + +#ifdef MD4C_USE_UTF16 + /* For UTF-16, mark_char_map[] covers only ASCII. */ + #define IS_MARK_CHAR(off) ((CH(off) < SIZEOF_ARRAY(ctx->mark_char_map)) && \ + (ctx->mark_char_map[(unsigned char) CH(off)])) +#else + /* For 8-bit encodings, mark_char_map[] covers all 256 elements. */ + #define IS_MARK_CHAR(off) (ctx->mark_char_map[(unsigned char) CH(off)]) +#endif + + /* Optimization: Fast path (with some loop unrolling). */ + while(off + 4 < line_end && !IS_MARK_CHAR(off+0) && !IS_MARK_CHAR(off+1) + && !IS_MARK_CHAR(off+2) && !IS_MARK_CHAR(off+3)) + off += 4; + while(off < line_end && !IS_MARK_CHAR(off+0)) + off++; + + if(off >= line_end) + break; + + ch = CH(off); + + /* A backslash escape. + * It can go beyond line->end as it may involve escaped new + * line to form a hard break. */ + if(ch == _T('\\') && off+1 < ctx->size && (ISPUNCT(off+1) || ISNEWLINE(off+1))) { + /* Hard-break cannot be on the last line of the block. */ + if(!ISNEWLINE(off+1) || i+1 < n_lines) + PUSH_MARK(ch, off, off+2, MD_MARK_RESOLVED); + + /* If '`' or '>' follows, we need both marks as the backslash + * may be inside a code span or an autolink where escaping is + * disabled. */ + if(CH(off+1) == _T('`') || CH(off+1) == _T('>')) + off++; + else + off += 2; + continue; + } + + /* A potential (string) emphasis start/end. */ + if(ch == _T('*') || ch == _T('_')) { + OFF tmp = off+1; + int left_level; /* What precedes: 0 = whitespace; 1 = punctuation; 2 = other char. */ + int right_level; /* What follows: 0 = whitespace; 1 = punctuation; 2 = other char. */ + + while(tmp < line_end && CH(tmp) == ch) + tmp++; + + if(off == line->beg || ISUNICODEWHITESPACEBEFORE(off)) + left_level = 0; + else if(ISUNICODEPUNCTBEFORE(off)) + left_level = 1; + else + left_level = 2; + + if(tmp == line_end || ISUNICODEWHITESPACE(tmp)) + right_level = 0; + else if(ISUNICODEPUNCT(tmp)) + right_level = 1; + else + right_level = 2; + + /* Intra-word underscore doesn't have special meaning. */ + if(ch == _T('_') && left_level == 2 && right_level == 2) { + left_level = 0; + right_level = 0; + } + + if(left_level != 0 || right_level != 0) { + unsigned flags = 0; + + if(left_level > 0 && left_level >= right_level) + flags |= MD_MARK_POTENTIAL_CLOSER; + if(right_level > 0 && right_level >= left_level) + flags |= MD_MARK_POTENTIAL_OPENER; + if(left_level == 2 && right_level == 2) + flags |= MD_MARK_EMPH_INTRAWORD; + + /* For "the rule of three" we need to remember the original + * size of the mark (modulo three), before we potentially + * split the mark when being later resolved partially by some + * shorter closer. */ + switch((tmp - off) % 3) { + case 0: flags |= MD_MARK_EMPH_MODULO3_0; break; + case 1: flags |= MD_MARK_EMPH_MODULO3_1; break; + case 2: flags |= MD_MARK_EMPH_MODULO3_2; break; + } + + PUSH_MARK(ch, off, tmp, flags); + + /* During resolving, multiple asterisks may have to be + * split into independent span start/ends. Consider e.g. + * "**foo* bar*". Therefore we push also some empty dummy + * marks to have enough space for that. */ + off++; + while(off < tmp) { + PUSH_MARK('D', off, off, 0); + off++; + } + continue; + } + + off = tmp; + continue; + } + + /* A potential code span start/end. */ + if(ch == _T('`')) { + OFF tmp = off+1; + + while(tmp < line_end && CH(tmp) == _T('`')) + tmp++; + + /* We limit code span marks to lower then 256 backticks. This + * solves a pathologic case of too many openers, each of + * different length: Their resolving is then O(n^2). */ + if(tmp - off < 256) + PUSH_MARK(ch, off, tmp, MD_MARK_POTENTIAL_OPENER | MD_MARK_POTENTIAL_CLOSER); + + off = tmp; + continue; + } + + /* A potential entity start. */ + if(ch == _T('&')) { + PUSH_MARK(ch, off, off+1, MD_MARK_POTENTIAL_OPENER); + off++; + continue; + } + + /* A potential entity end. */ + if(ch == _T(';')) { + /* We surely cannot be entity unless the previous mark is '&'. */ + if(ctx->n_marks > 0 && ctx->marks[ctx->n_marks-1].ch == _T('&')) + PUSH_MARK(ch, off, off+1, MD_MARK_POTENTIAL_CLOSER); + + off++; + continue; + } + + /* A potential autolink or raw HTML start/end. */ + if(ch == _T('<') || ch == _T('>')) { + if(!(ctx->parser.flags & MD_FLAG_NOHTMLSPANS)) + PUSH_MARK(ch, off, off+1, (ch == _T('<') ? MD_MARK_POTENTIAL_OPENER : MD_MARK_POTENTIAL_CLOSER)); + + off++; + continue; + } + + /* A potential link or its part. */ + if(ch == _T('[') || (ch == _T('!') && off+1 < line_end && CH(off+1) == _T('['))) { + OFF tmp = (ch == _T('[') ? off+1 : off+2); + PUSH_MARK(ch, off, tmp, MD_MARK_POTENTIAL_OPENER); + off = tmp; + /* Two dummies to make enough place for data we need if it is + * a link. */ + PUSH_MARK('D', off, off, 0); + PUSH_MARK('D', off, off, 0); + continue; + } + if(ch == _T(']')) { + PUSH_MARK(ch, off, off+1, MD_MARK_POTENTIAL_CLOSER); + off++; + continue; + } + + /* A potential permissive e-mail autolink. */ + if(ch == _T('@')) { + if(line->beg + 1 <= off && ISALNUM(off-1) && + off + 3 < line->end && ISALNUM(off+1)) + { + PUSH_MARK(ch, off, off+1, MD_MARK_POTENTIAL_OPENER); + /* Push a dummy as a reserve for a closer. */ + PUSH_MARK('D', off, off, 0); + } + + off++; + continue; + } + + /* A potential permissive URL autolink. */ + if(ch == _T(':')) { + static struct { + const CHAR* scheme; + SZ scheme_size; + const CHAR* suffix; + SZ suffix_size; + } scheme_map[] = { + /* In the order from the most frequently used, arguably. */ + { _T("http"), 4, _T("//"), 2 }, + { _T("https"), 5, _T("//"), 2 }, + { _T("ftp"), 3, _T("//"), 2 } + }; + int scheme_index; + + for(scheme_index = 0; scheme_index < SIZEOF_ARRAY(scheme_map); scheme_index++) { + const CHAR* scheme = scheme_map[scheme_index].scheme; + const SZ scheme_size = scheme_map[scheme_index].scheme_size; + const CHAR* suffix = scheme_map[scheme_index].suffix; + const SZ suffix_size = scheme_map[scheme_index].suffix_size; + + if(line->beg + scheme_size <= off && md_ascii_eq(STR(off-scheme_size), scheme, scheme_size) && + (line->beg + scheme_size == off || ISWHITESPACE(off-scheme_size-1) || ISANYOF(off-scheme_size-1, _T("*_~(["))) && + off + 1 + suffix_size < line->end && md_ascii_eq(STR(off+1), suffix, suffix_size)) + { + PUSH_MARK(ch, off-scheme_size, off+1+suffix_size, MD_MARK_POTENTIAL_OPENER); + /* Push a dummy as a reserve for a closer. */ + PUSH_MARK('D', off, off, 0); + off += 1 + suffix_size; + continue; + } + } + + off++; + continue; + } + + /* A potential permissive WWW autolink. */ + if(ch == _T('.')) { + if(line->beg + 3 <= off && md_ascii_eq(STR(off-3), _T("www"), 3) && + (line->beg + 3 == off || ISWHITESPACE(off-4) || ISANYOF(off-4, _T("*_~(["))) && + off + 1 < line_end) + { + PUSH_MARK(ch, off-3, off+1, MD_MARK_POTENTIAL_OPENER); + /* Push a dummy as a reserve for a closer. */ + PUSH_MARK('D', off, off, 0); + off++; + continue; + } + + off++; + continue; + } + + /* A potential table cell boundary. */ + if(table_mode && ch == _T('|')) { + PUSH_MARK(ch, off, off+1, 0); + off++; + continue; + } + + /* A potential strikethrough start/end. */ + if(ch == _T('~')) { + OFF tmp = off+1; + + while(tmp < line_end && CH(tmp) == _T('~')) + tmp++; + + PUSH_MARK(ch, off, tmp, MD_MARK_POTENTIAL_OPENER | MD_MARK_POTENTIAL_CLOSER); + off = tmp; + } + + /* Turn non-trivial whitespace into single space. */ + if(ISWHITESPACE_(ch)) { + OFF tmp = off+1; + + while(tmp < line_end && ISWHITESPACE(tmp)) + tmp++; + + if(tmp - off > 1 || ch != _T(' ')) + PUSH_MARK(ch, off, tmp, MD_MARK_RESOLVED); + + off = tmp; + continue; + } + + /* NULL character. */ + if(ch == _T('\0')) { + PUSH_MARK(ch, off, off+1, MD_MARK_RESOLVED); + off++; + continue; + } + + off++; + } + } + + /* Add a dummy mark at the end of the mark vector to simplify + * process_inlines(). */ + PUSH_MARK(127, ctx->size, ctx->size, MD_MARK_RESOLVED); + +abort: + return ret; +} + + +/* Analyze whether the back-tick is really start/end mark of a code span. + * If yes, reset all marks inside of it and setup flags of both marks. */ +static void +md_analyze_backtick(MD_CTX* ctx, int mark_index) +{ + MD_MARK* mark = &ctx->marks[mark_index]; + int opener_index = BACKTICK_OPENERS.tail; + + /* Try to find unresolved opener of the same length. If we find it, + * we form a code span. */ + while(opener_index >= 0) { + MD_MARK* opener = &ctx->marks[opener_index]; + + if(opener->end - opener->beg == mark->end - mark->beg) { + /* Rollback anything found inside it. + * (e.g. the code span contains some back-ticks or other special + * chars we misinterpreted.) */ + md_rollback(ctx, opener_index, mark_index, MD_ROLLBACK_ALL); + + /* Resolve the span. */ + md_resolve_range(ctx, &BACKTICK_OPENERS, opener_index, mark_index); + + /* Append any space or new line inside the span into the mark + * itself to swallow it. */ + while(CH(opener->end) == _T(' ') || ISNEWLINE(opener->end)) + opener->end++; + if(mark->beg > opener->end) { + while(CH(mark->beg-1) == _T(' ') || ISNEWLINE(mark->beg-1)) + mark->beg--; + } + + /* Done. */ + return; + } + + opener_index = ctx->marks[opener_index].prev; + } + + /* We didn't find any matching opener, so we ourselves may be the opener + * of some upcoming closer. We also have to handle specially if there is + * a backslash mark before it as that can cancel the first backtick. */ + if(mark_index > 0 && (mark-1)->beg == mark->beg - 1 && (mark-1)->ch == '\\') { + if(mark->end - mark->beg == 1) { + /* Single escaped backtick. */ + return; + } + + /* Remove the escaped backtick from the opener. */ + mark->beg++; + } + + if(mark->flags & MD_MARK_POTENTIAL_OPENER) + md_mark_chain_append(ctx, &BACKTICK_OPENERS, mark_index); +} + +static int +md_is_autolink_uri(MD_CTX* ctx, OFF beg, OFF end) +{ + OFF off = beg; + + /* Check for scheme. */ + if(off >= end || !ISASCII(off)) + return FALSE; + off++; + while(1) { + if(off >= end) + return FALSE; + if(off - beg > 32) + return FALSE; + if(CH(off) == _T(':') && off - beg >= 2) + break; + if(!ISALNUM(off) && CH(off) != _T('+') && CH(off) != _T('-') && CH(off) != _T('.')) + return FALSE; + off++; + } + + /* Check the path after the scheme. */ + while(off < end) { + if(ISWHITESPACE(off) || ISCNTRL(off) || CH(off) == _T('<') || CH(off) == _T('>')) + return FALSE; + off++; + } + + return TRUE; +} + +static int +md_is_autolink_email(MD_CTX* ctx, OFF beg, OFF end) +{ + OFF off = beg; + int label_len; + + /* The code should correspond to this regexp: + /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+ + @[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])? + (?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/ + */ + + /* Username (before '@'). */ + while(off < end && (ISALNUM(off) || ISANYOF(off, _T(".!#$%&'*+/=?^_`{|}~-")))) + off++; + if(off <= beg) + return FALSE; + + /* '@' */ + if(off >= end || CH(off) != _T('@')) + return FALSE; + off++; + + /* Labels delimited with '.'; each label is sequence of 1 - 62 alnum + * characters or '-', but '-' is not allowed as first or last char. */ + label_len = 0; + while(off < end) { + if(ISALNUM(off)) + label_len++; + else if(CH(off) == _T('-') && label_len > 0) + label_len++; + else if(CH(off) == _T('.') && label_len > 0 && CH(off-1) != _T('-')) + label_len = 0; + else + return FALSE; + + if(label_len > 63) + return FALSE; + + off++; + } + + if(label_len <= 0 || CH(off-1) == _T('-')) + return FALSE; + + return TRUE; +} + +static int +md_is_autolink(MD_CTX* ctx, OFF beg, OFF end, int* p_missing_mailto) +{ + MD_ASSERT(CH(beg) == _T('<')); + MD_ASSERT(CH(end-1) == _T('>')); + + beg++; + end--; + + if(md_is_autolink_uri(ctx, beg, end)) + return TRUE; + + if(md_is_autolink_email(ctx, beg, end)) { + *p_missing_mailto = 1; + return TRUE; + } + + return FALSE; +} + +static void +md_analyze_lt_gt(MD_CTX* ctx, int mark_index, const MD_LINE* lines, int n_lines) +{ + MD_MARK* mark = &ctx->marks[mark_index]; + int opener_index; + + /* If it is an opener ('<'), remember it. */ + if(mark->flags & MD_MARK_POTENTIAL_OPENER) { + md_mark_chain_append(ctx, &LOWERTHEN_OPENERS, mark_index); + return; + } + + /* Otherwise we are potential closer and we try to resolve with since all + * the chained unresolved openers. */ + opener_index = LOWERTHEN_OPENERS.head; + while(opener_index >= 0) { + MD_MARK* opener = &ctx->marks[opener_index]; + OFF detected_end; + int is_autolink = 0; + int is_missing_mailto = 0; + int is_raw_html = 0; + + is_autolink = (md_is_autolink(ctx, opener->beg, mark->end, &is_missing_mailto)); + + if(is_autolink) { + if(is_missing_mailto) + opener->ch = _T('@'); + } else { + /* Identify the line where the opening mark lives. */ + int line_index = 0; + while(1) { + if(opener->beg < lines[line_index].end) + break; + line_index++; + } + + is_raw_html = (md_is_html_any(ctx, lines + line_index, + n_lines - line_index, opener->beg, mark->end, &detected_end)); + } + + /* Check whether the range forms a valid raw HTML. */ + if(is_autolink || is_raw_html) { + md_rollback(ctx, opener_index, mark_index, MD_ROLLBACK_ALL); + md_resolve_range(ctx, &LOWERTHEN_OPENERS, opener_index, mark_index); + + if(is_raw_html) { + /* If this fails, it means we have missed some earlier opportunity + * to resolve the opener of raw HTML. */ + MD_ASSERT(detected_end == mark->end); + + /* Make these marks zero width so the '<' and '>' are part of its + * contents. */ + opener->end = opener->beg; + mark->beg = mark->end; + + opener->flags &= ~MD_MARK_AUTOLINK; + mark->flags &= ~MD_MARK_AUTOLINK; + } else { + opener->flags |= MD_MARK_AUTOLINK; + mark->flags |= MD_MARK_AUTOLINK; + } + + /* And we are done. */ + return; + } + + opener_index = opener->next; + } +} + +static void +md_analyze_bracket(MD_CTX* ctx, int mark_index) +{ + /* We cannot really resolve links here as for that we would need + * more context. E.g. a following pair of brackets (reference link), + * or enclosing pair of brackets (if the inner is the link, the outer + * one cannot be.) + * + * Therefore we here only construct a list of resolved '[' ']' pairs + * ordered by position of the closer. This allows ur to analyze what is + * or is not link in the right order, from inside to outside in case + * of nested brackets. + * + * The resolving itself is deferred into md_resolve_links(). + */ + + MD_MARK* mark = &ctx->marks[mark_index]; + + if(mark->flags & MD_MARK_POTENTIAL_OPENER) { + md_mark_chain_append(ctx, &BRACKET_OPENERS, mark_index); + return; + } + + if(BRACKET_OPENERS.tail >= 0) { + /* Pop the opener from the chain. */ + int opener_index = BRACKET_OPENERS.tail; + MD_MARK* opener = &ctx->marks[opener_index]; + if(opener->prev >= 0) + ctx->marks[opener->prev].next = -1; + else + BRACKET_OPENERS.head = -1; + BRACKET_OPENERS.tail = opener->prev; + + /* Interconnect the opener and closer. */ + opener->next = mark_index; + mark->prev = opener_index; + + /* Add the pair into chain of potential links for md_resolve_links(). + * Note we misuse opener->prev for this as opener->next points to its + * closer. */ + if(ctx->unresolved_link_tail >= 0) + ctx->marks[ctx->unresolved_link_tail].prev = opener_index; + else + ctx->unresolved_link_head = opener_index; + ctx->unresolved_link_tail = opener_index; + opener->prev = -1; + } +} + +/* Forward declaration. */ +static void md_analyze_link_contents(MD_CTX* ctx, const MD_LINE* lines, int n_lines, + int mark_beg, int mark_end); + +static int +md_resolve_links(MD_CTX* ctx, const MD_LINE* lines, int n_lines) +{ + int opener_index = ctx->unresolved_link_head; + OFF last_link_beg = 0; + OFF last_link_end = 0; + OFF last_img_beg = 0; + OFF last_img_end = 0; + + while(opener_index >= 0) { + MD_MARK* opener = &ctx->marks[opener_index]; + int closer_index = opener->next; + MD_MARK* closer = &ctx->marks[closer_index]; + int next_index = opener->prev; + MD_MARK* next_opener; + MD_MARK* next_closer; + MD_LINK_ATTR attr; + int is_link = FALSE; + + if(next_index >= 0) { + next_opener = &ctx->marks[next_index]; + next_closer = &ctx->marks[next_opener->next]; + } else { + next_opener = NULL; + next_closer = NULL; + } + + /* If nested ("[ [ ] ]"), we need to make sure that: + * - The outer does not end inside of (...) belonging to the inner. + * - The outer cannot be link if the inner is link (i.e. not image). + * + * (Note we here analyze from inner to outer as the marks are ordered + * by closer->beg.) + */ + if((opener->beg < last_link_beg && closer->end < last_link_end) || + (opener->beg < last_img_beg && closer->end < last_img_end) || + (opener->beg < last_link_end && opener->ch == '[')) + { + opener_index = next_index; + continue; + } + + if(next_opener != NULL && next_opener->beg == closer->end) { + if(next_closer->beg > closer->end + 1) { + /* Might be full reference link. */ + is_link = md_is_link_reference(ctx, lines, n_lines, next_opener->beg, next_closer->end, &attr); + } else { + /* Might be shortcut reference link. */ + is_link = md_is_link_reference(ctx, lines, n_lines, opener->beg, closer->end, &attr); + } + + if(is_link < 0) + return -1; + + if(is_link) { + /* Eat the 2nd "[...]". */ + closer->end = next_closer->end; + } + } else { + if(closer->end < ctx->size && CH(closer->end) == _T('(')) { + /* Might be inline link. */ + OFF inline_link_end = -1; + + is_link = md_is_inline_link_spec(ctx, lines, n_lines, closer->end, &inline_link_end, &attr); + if(is_link < 0) + return -1; + + /* Check the closing ')' is not inside an already resolved range + * (i.e. a range with a higher priority), e.g. a code span. */ + if(is_link) { + int i = closer_index + 1; + + while(i < ctx->n_marks) { + MD_MARK* mark = &ctx->marks[i]; + + if(mark->beg >= inline_link_end) + break; + if((mark->flags & (MD_MARK_OPENER | MD_MARK_RESOLVED)) == (MD_MARK_OPENER | MD_MARK_RESOLVED)) { + if(ctx->marks[mark->next].beg >= inline_link_end) { + /* Cancel the link status. */ + if(attr.title_needs_free) + free(attr.title); + is_link = FALSE; + break; + } + + i = mark->next + 1; + } else { + i++; + } + } + } + + if(is_link) { + /* Eat the "(...)" */ + closer->end = inline_link_end; + } + } + + if(!is_link) { + /* Might be collapsed reference link. */ + is_link = md_is_link_reference(ctx, lines, n_lines, opener->beg, closer->end, &attr); + if(is_link < 0) + return -1; + } + } + + if(is_link) { + /* Resolve the brackets as a link. */ + opener->flags |= MD_MARK_OPENER | MD_MARK_RESOLVED; + closer->flags |= MD_MARK_CLOSER | MD_MARK_RESOLVED; + + /* If it is a link, we store the destination and title in the two + * dummy marks after the opener. */ + MD_ASSERT(ctx->marks[opener_index+1].ch == 'D'); + ctx->marks[opener_index+1].beg = attr.dest_beg; + ctx->marks[opener_index+1].end = attr.dest_end; + + MD_ASSERT(ctx->marks[opener_index+2].ch == 'D'); + md_mark_store_ptr(ctx, opener_index+2, attr.title); + if(attr.title_needs_free) + md_mark_chain_append(ctx, &PTR_CHAIN, opener_index+2); + ctx->marks[opener_index+2].prev = attr.title_size; + + if(opener->ch == '[') { + last_link_beg = opener->beg; + last_link_end = closer->end; + } else { + last_img_beg = opener->beg; + last_img_end = closer->end; + } + + md_analyze_link_contents(ctx, lines, n_lines, opener_index+1, closer_index); + } + + opener_index = next_index; + } + + return 0; +} + +/* Analyze whether the mark '&' starts a HTML entity. + * If so, update its flags as well as flags of corresponding closer ';'. */ +static void +md_analyze_entity(MD_CTX* ctx, int mark_index) +{ + MD_MARK* opener = &ctx->marks[mark_index]; + MD_MARK* closer; + OFF off; + + /* Cannot be entity if there is no closer as the next mark. + * (Any other mark between would mean strange character which cannot be + * part of the entity. + * + * So we can do all the work on '&' and do not call this later for the + * closing mark ';'. + */ + if(mark_index + 1 >= ctx->n_marks) + return; + closer = &ctx->marks[mark_index+1]; + if(closer->ch != ';') + return; + + if(md_is_entity(ctx, opener->beg, closer->end, &off)) { + MD_ASSERT(off == closer->end); + + md_resolve_range(ctx, NULL, mark_index, mark_index+1); + opener->end = closer->end; + } +} + +static void +md_analyze_table_cell_boundary(MD_CTX* ctx, int mark_index) +{ + MD_MARK* mark = &ctx->marks[mark_index]; + mark->flags |= MD_MARK_RESOLVED; + + md_mark_chain_append(ctx, &TABLECELLBOUNDARIES, mark_index); + ctx->n_table_cell_boundaries++; +} + +/* Split a longer mark into two. The new mark takes the given count of + * characters. May only be called if an adequate number of dummy 'D' marks + * follows. + */ +static int +md_split_simple_pairing_mark(MD_CTX* ctx, int mark_index, SZ n) +{ + MD_MARK* mark = &ctx->marks[mark_index]; + int new_mark_index = mark_index + (mark->end - mark->beg - n); + MD_MARK* dummy = &ctx->marks[new_mark_index]; + + MD_ASSERT(mark->end - mark->beg > n); + MD_ASSERT(dummy->ch == 'D'); + + memcpy(dummy, mark, sizeof(MD_MARK)); + mark->end -= n; + dummy->beg = mark->end; + + return new_mark_index; +} + +static void +md_analyze_simple_pairing_mark(MD_CTX* ctx, MD_MARKCHAIN* chain, int mark_index, + int apply_rule_of_three) +{ + MD_MARK* mark = &ctx->marks[mark_index]; + + /* If we can be a closer, try to resolve with the preceding opener. */ + if((mark->flags & MD_MARK_POTENTIAL_CLOSER) && chain->tail >= 0) { + int opener_index = chain->tail; + MD_MARK* opener = &ctx->marks[opener_index]; + SZ opener_size = opener->end - opener->beg; + SZ closer_size = mark->end - mark->beg; + + /* Apply the "rule of three". */ + if(apply_rule_of_three) { + while((mark->flags & MD_MARK_EMPH_INTRAWORD) || (opener->flags & MD_MARK_EMPH_INTRAWORD)) { + SZ opener_orig_size_modulo3; + + switch(opener->flags & MD_MARK_EMPH_MODULO3_MASK) { + case MD_MARK_EMPH_MODULO3_0: opener_orig_size_modulo3 = 0; break; + case MD_MARK_EMPH_MODULO3_1: opener_orig_size_modulo3 = 1; break; + case MD_MARK_EMPH_MODULO3_2: opener_orig_size_modulo3 = 2; break; + default: MD_UNREACHABLE(); break; + } + + if((opener_orig_size_modulo3 + closer_size) % 3 != 0) { + /* This opener is suitable. */ + break; + } + + if(opener->prev >= 0) { + /* Try previous opener. */ + opener_index = opener->prev; + opener = &ctx->marks[opener_index]; + opener_size = opener->end - opener->beg; + closer_size = mark->end - mark->beg; + } else { + /* No suitable opener found. */ + goto cannot_resolve; + } + } + } + + if(opener_size > closer_size) { + opener_index = md_split_simple_pairing_mark(ctx, opener_index, closer_size); + md_mark_chain_append(ctx, chain, opener_index); + } else if(opener_size < closer_size) { + md_split_simple_pairing_mark(ctx, mark_index, closer_size - opener_size); + } + + md_rollback(ctx, opener_index, mark_index, MD_ROLLBACK_CROSSING); + md_resolve_range(ctx, chain, opener_index, mark_index); + return; + } + +cannot_resolve: + /* If not resolved, and we can be an opener, remember the mark for + * the future. */ + if(mark->flags & MD_MARK_POTENTIAL_OPENER) + md_mark_chain_append(ctx, chain, mark_index); +} + +static inline void +md_analyze_asterisk(MD_CTX* ctx, int mark_index) +{ + md_analyze_simple_pairing_mark(ctx, &ASTERISK_OPENERS, mark_index, 1); +} + +static inline void +md_analyze_underscore(MD_CTX* ctx, int mark_index) +{ + md_analyze_simple_pairing_mark(ctx, &UNDERSCORE_OPENERS, mark_index, 1); +} + +static void +md_analyze_tilde(MD_CTX* ctx, int mark_index) +{ + /* We attempt to be Github Flavored Markdown compatible here. GFM says + * that length of the tilde sequence is not important at all. Note that + * implies the TILDE_OPENERS chain can have at most one item. */ + + if(TILDE_OPENERS.head >= 0) { + /* The chain already contains an opener, so we may resolve the span. */ + int opener_index = TILDE_OPENERS.head; + + md_rollback(ctx, opener_index, mark_index, MD_ROLLBACK_CROSSING); + md_resolve_range(ctx, &TILDE_OPENERS, opener_index, mark_index); + } else { + /* We can only be opener. */ + md_mark_chain_append(ctx, &TILDE_OPENERS, mark_index); + } +} + +static void +md_analyze_permissive_url_autolink(MD_CTX* ctx, int mark_index) +{ + MD_MARK* opener = &ctx->marks[mark_index]; + int closer_index = mark_index + 1; + MD_MARK* closer = &ctx->marks[closer_index]; + MD_MARK* next_resolved_mark; + OFF off = opener->end; + int seen_dot = FALSE; + int seen_underscore_or_hyphen[2] = { FALSE, FALSE }; + + /* Check for domain. */ + while(off < ctx->size) { + if(ISALNUM(off)) { + off++; + } else if(CH(off) == _T('.')) { + seen_dot = TRUE; + seen_underscore_or_hyphen[0] = seen_underscore_or_hyphen[1]; + seen_underscore_or_hyphen[1] = FALSE; + off++; + } else if(ISANYOF2(off, _T('-'), _T('_'))) { + seen_underscore_or_hyphen[1] = TRUE; + off++; + } else { + break; + } + } + + if(off <= opener->end || !seen_dot || seen_underscore_or_hyphen[0] || seen_underscore_or_hyphen[1]) + return; + + /* Check for path. */ + next_resolved_mark = closer + 1; + while(next_resolved_mark->ch == 'D' || !(next_resolved_mark->flags & MD_MARK_RESOLVED)) + next_resolved_mark++; + while(off < next_resolved_mark->beg && CH(off) != _T('<') && !ISWHITESPACE(off) && !ISNEWLINE(off)) + off++; + + /* Path validation. */ + if(ISANYOF(off-1, _T("?!.,:*_~)"))) { + if(CH(off-1) != _T(')')) { + off--; + } else { + int parenthesis_balance = 0; + OFF tmp; + + for(tmp = opener->end; tmp < off; tmp++) { + if(CH(tmp) == _T('(')) + parenthesis_balance++; + else if(CH(tmp) == _T(')')) + parenthesis_balance--; + } + + if(parenthesis_balance < 0) + off--; + } + } + + /* Ok. Lets call it auto-link. Adapt opener and create closer to zero + * length so all the contents becomes the link text. */ + MD_ASSERT(closer->ch == 'D'); + opener->end = opener->beg; + closer->ch = opener->ch; + closer->beg = off; + closer->end = off; + md_resolve_range(ctx, NULL, mark_index, closer_index); +} + +/* The permissive autolinks do not have to be enclosed in '<' '>' but we + * instead impose stricter rules what is understood as an e-mail address + * here. Actually any non-alphanumeric characters with exception of '.' + * are prohibited both in username and after '@'. */ +static void +md_analyze_permissive_email_autolink(MD_CTX* ctx, int mark_index) +{ + MD_MARK* opener = &ctx->marks[mark_index]; + int closer_index; + MD_MARK* closer; + OFF beg = opener->beg; + OFF end = opener->end; + int dot_count = 0; + + MD_ASSERT(CH(beg) == _T('@')); + + /* Scan for name before '@'. */ + while(beg > 0 && (ISALNUM(beg-1) || ISANYOF(beg-1, _T(".-_+")))) + beg--; + + /* Scan for domain after '@'. */ + while(end < ctx->size && (ISALNUM(end) || ISANYOF(end, _T(".-_")))) { + if(CH(end) == _T('.')) + dot_count++; + end++; + } + if(CH(end-1) == _T('.')) { /* Final '.' not part of it. */ + dot_count--; + end--; + } + else if(ISANYOF2(end-1, _T('-'), _T('_'))) /* These are forbidden at the end. */ + return; + if(CH(end-1) == _T('@') || dot_count == 0) + return; + + /* Ok. Lets call it auto-link. Adapt opener and create closer to zero + * length so all the contents becomes the link text. */ + closer_index = mark_index + 1; + closer = &ctx->marks[closer_index]; + MD_ASSERT(closer->ch == 'D'); + + opener->beg = beg; + opener->end = beg; + closer->ch = opener->ch; + closer->beg = end; + closer->end = end; + md_resolve_range(ctx, NULL, mark_index, closer_index); +} + +static inline void +md_analyze_marks(MD_CTX* ctx, const MD_LINE* lines, int n_lines, + int mark_beg, int mark_end, const CHAR* mark_chars) +{ + int i = mark_beg; + + while(i < mark_end) { + MD_MARK* mark = &ctx->marks[i]; + + /* Skip resolved spans. */ + if(mark->flags & MD_MARK_RESOLVED) { + if(mark->flags & MD_MARK_OPENER) { + MD_ASSERT(i < mark->next); + i = mark->next + 1; + } else { + i++; + } + continue; + } + + /* Skip marks we do not want to deal with. */ + if(!ISANYOF_(mark->ch, mark_chars)) { + i++; + continue; + } + + /* Analyze the mark. */ + switch(mark->ch) { + case '`': md_analyze_backtick(ctx, i); break; + case '<': /* Pass through. */ + case '>': md_analyze_lt_gt(ctx, i, lines, n_lines); break; + case '[': /* Pass through. */ + case '!': /* Pass through. */ + case ']': md_analyze_bracket(ctx, i); break; + case '&': md_analyze_entity(ctx, i); break; + case '|': md_analyze_table_cell_boundary(ctx, i); break; + case '*': md_analyze_asterisk(ctx, i); break; + case '_': md_analyze_underscore(ctx, i); break; + case '~': md_analyze_tilde(ctx, i); break; + case '.': /* Pass through. */ + case ':': md_analyze_permissive_url_autolink(ctx, i); break; + case '@': md_analyze_permissive_email_autolink(ctx, i); break; + } + + i++; + } +} + +/* Analyze marks (build ctx->marks). */ +static int +md_analyze_inlines(MD_CTX* ctx, const MD_LINE* lines, int n_lines, int table_mode) +{ + int ret; + + /* Reset the previously collected stack of marks. */ + ctx->n_marks = 0; + + /* Collect all marks. */ + MD_CHECK(md_collect_marks(ctx, lines, n_lines, table_mode)); + + /* We analyze marks in few groups to handle their precedence. */ + /* (1) Entities; code spans; autolinks; raw HTML. */ + md_analyze_marks(ctx, lines, n_lines, 0, ctx->n_marks, _T("&`<>")); + BACKTICK_OPENERS.head = -1; + BACKTICK_OPENERS.tail = -1; + LOWERTHEN_OPENERS.head = -1; + LOWERTHEN_OPENERS.tail = -1; + + if(table_mode) { + /* (2) Analyze table cell boundaries. + * Note we reset TABLECELLBOUNDARIES chain prior to the call md_analyze_marks(), + * not after, because caller may need it. */ + MD_ASSERT(n_lines == 1); + TABLECELLBOUNDARIES.head = -1; + TABLECELLBOUNDARIES.tail = -1; + ctx->n_table_cell_boundaries = 0; + md_analyze_marks(ctx, lines, n_lines, 0, ctx->n_marks, _T("|")); + return ret; + } + + /* (3) Links. */ + md_analyze_marks(ctx, lines, n_lines, 0, ctx->n_marks, _T("[]!")); + MD_CHECK(md_resolve_links(ctx, lines, n_lines)); + BRACKET_OPENERS.head = -1; + BRACKET_OPENERS.tail = -1; + ctx->unresolved_link_head = -1; + ctx->unresolved_link_tail = -1; + + /* (4) Emphasis and strong emphasis; permissive autolinks. */ + md_analyze_link_contents(ctx, lines, n_lines, 0, ctx->n_marks); + +abort: + return ret; +} + +static void +md_analyze_link_contents(MD_CTX* ctx, const MD_LINE* lines, int n_lines, + int mark_beg, int mark_end) +{ + md_analyze_marks(ctx, lines, n_lines, mark_beg, mark_end, _T("*_~@:.")); + ASTERISK_OPENERS.head = -1; + ASTERISK_OPENERS.tail = -1; + UNDERSCORE_OPENERS.head = -1; + UNDERSCORE_OPENERS.tail = -1; + TILDE_OPENERS.head = -1; + TILDE_OPENERS.tail = -1; +} + +static int +md_enter_leave_span_a(MD_CTX* ctx, int enter, MD_SPANTYPE type, + const CHAR* dest, SZ dest_size, int prohibit_escapes_in_dest, + const CHAR* title, SZ title_size) +{ + MD_ATTRIBUTE_BUILD href_build = { 0 }; + MD_ATTRIBUTE_BUILD title_build = { 0 }; + MD_SPAN_A_DETAIL det; + int ret = 0; + + /* Note we here rely on fact that MD_SPAN_A_DETAIL and + * MD_SPAN_IMG_DETAIL are binary-compatible. */ + memset(&det, 0, sizeof(MD_SPAN_A_DETAIL)); + MD_CHECK(md_build_attribute(ctx, dest, dest_size, + (prohibit_escapes_in_dest ? MD_BUILD_ATTR_NO_ESCAPES : 0), + &det.href, &href_build)); + MD_CHECK(md_build_attribute(ctx, title, title_size, 0, &det.title, &title_build)); + + if(enter) + MD_ENTER_SPAN(type, &det); + else + MD_LEAVE_SPAN(type, &det); + +abort: + md_free_attribute(ctx, &href_build); + md_free_attribute(ctx, &title_build); + return ret; +} + +/* Render the output, accordingly to the analyzed ctx->marks. */ +static int +md_process_inlines(MD_CTX* ctx, const MD_LINE* lines, int n_lines) +{ + MD_TEXTTYPE text_type; + const MD_LINE* line = lines; + MD_MARK* prev_mark = NULL; + MD_MARK* mark; + OFF off = lines[0].beg; + OFF end = lines[n_lines-1].end; + int enforce_hardbreak = 0; + int ret = 0; + + /* Find first resolved mark. Note there is always at least one resolved + * mark, the dummy last one after the end of the latest line we actually + * never really reach. This saves us of a lot of special checks and cases + * in this function. */ + mark = ctx->marks; + while(!(mark->flags & MD_MARK_RESOLVED)) + mark++; + + text_type = MD_TEXT_NORMAL; + + while(1) { + /* Process the text up to the next mark or end-of-line. */ + OFF tmp = (line->end < mark->beg ? line->end : mark->beg); + if(tmp > off) { + MD_TEXT(text_type, STR(off), tmp - off); + off = tmp; + } + + /* If reached the mark, process it and move to next one. */ + if(off >= mark->beg) { + switch(mark->ch) { + case '\\': /* Backslash escape. */ + if(ISNEWLINE(mark->beg+1)) + enforce_hardbreak = 1; + else + MD_TEXT(text_type, STR(mark->beg+1), 1); + break; + + case ' ': /* Non-trivial space. */ + MD_TEXT(text_type, _T(" "), 1); + break; + + case '`': /* Code span. */ + if(mark->flags & MD_MARK_OPENER) { + MD_ENTER_SPAN(MD_SPAN_CODE, NULL); + text_type = MD_TEXT_CODE; + } else { + MD_LEAVE_SPAN(MD_SPAN_CODE, NULL); + text_type = MD_TEXT_NORMAL; + } + break; + + case '_': + case '*': /* Emphasis, strong emphasis. */ + if(mark->flags & MD_MARK_OPENER) { + if((mark->end - off) % 2) { + MD_ENTER_SPAN(MD_SPAN_EM, NULL); + off++; + } + while(off + 1 < mark->end) { + MD_ENTER_SPAN(MD_SPAN_STRONG, NULL); + off += 2; + } + } else { + while(off + 1 < mark->end) { + MD_LEAVE_SPAN(MD_SPAN_STRONG, NULL); + off += 2; + } + if((mark->end - off) % 2) { + MD_LEAVE_SPAN(MD_SPAN_EM, NULL); + off++; + } + } + break; + + case '~': + if(mark->flags & MD_MARK_OPENER) + MD_ENTER_SPAN(MD_SPAN_DEL, NULL); + else + MD_LEAVE_SPAN(MD_SPAN_DEL, NULL); + break; + + case '[': /* Link, image. */ + case '!': + case ']': + { + const MD_MARK* opener = (mark->ch != ']' ? mark : &ctx->marks[mark->prev]); + const MD_MARK* dest_mark = opener+1; + const MD_MARK* title_mark = opener+2; + + MD_ASSERT(dest_mark->ch == 'D'); + MD_ASSERT(title_mark->ch == 'D'); + + MD_CHECK(md_enter_leave_span_a(ctx, (mark->ch != ']'), + (opener->ch == '!' ? MD_SPAN_IMG : MD_SPAN_A), + STR(dest_mark->beg), dest_mark->end - dest_mark->beg, FALSE, + md_mark_get_ptr(ctx, title_mark - ctx->marks), title_mark->prev)); + + /* link/image closer may span multiple lines. */ + if(mark->ch == ']') { + while(mark->end > line->end) + line++; + } + + break; + } + + case '<': + case '>': /* Autolink or raw HTML. */ + if(!(mark->flags & MD_MARK_AUTOLINK)) { + /* Raw HTML. */ + if(mark->flags & MD_MARK_OPENER) + text_type = MD_TEXT_HTML; + else + text_type = MD_TEXT_NORMAL; + break; + } + /* Pass through, if auto-link. */ + + case '@': /* Permissive e-mail autolink. */ + case ':': /* Permissive URL autolink. */ + case '.': /* Permissive WWW autolink. */ + { + MD_MARK* opener = ((mark->flags & MD_MARK_OPENER) ? mark : &ctx->marks[mark->prev]); + MD_MARK* closer = &ctx->marks[opener->next]; + const CHAR* dest = STR(opener->end); + SZ dest_size = closer->beg - opener->end; + + /* For permissive auto-links we do not know closer mark + * position at the time of md_collect_marks(), therefore + * it can be out-of-order in ctx->marks[]. + * + * With this flag, we make sure that we output the closer + * only if we processed the opener. */ + if(mark->flags & MD_MARK_OPENER) + closer->flags |= MD_MARK_VALIDPERMISSIVEAUTOLINK; + + if(opener->ch == '@' || opener->ch == '.') { + dest_size += 7; + MD_TEMP_BUFFER(dest_size * sizeof(CHAR)); + memcpy(ctx->buffer, + (opener->ch == '@' ? _T("mailto:") : _T("http://")), + 7 * sizeof(CHAR)); + memcpy(ctx->buffer + 7, dest, (dest_size-7) * sizeof(CHAR)); + dest = ctx->buffer; + } + + if(closer->flags & MD_MARK_VALIDPERMISSIVEAUTOLINK) + MD_CHECK(md_enter_leave_span_a(ctx, (mark->flags & MD_MARK_OPENER), + MD_SPAN_A, dest, dest_size, TRUE, NULL, 0)); + break; + } + + case '&': /* Entity. */ + MD_TEXT(MD_TEXT_ENTITY, STR(mark->beg), mark->end - mark->beg); + break; + + case '\0': + MD_TEXT(MD_TEXT_NULLCHAR, _T(""), 1); + break; + + case 127: + goto abort; + } + + off = mark->end; + + /* Move to next resolved mark. */ + prev_mark = mark; + mark++; + while(!(mark->flags & MD_MARK_RESOLVED) || mark->beg < off) + mark++; + } + + /* If reached end of line, move to next one. */ + if(off >= line->end) { + /* If it is the last line, we are done. */ + if(off >= end) + break; + + if(text_type == MD_TEXT_CODE) { + /* Inside code spans, new lines are transformed into single + * spaces. */ + MD_ASSERT(prev_mark != NULL); + MD_ASSERT(prev_mark->ch == '`' && (prev_mark->flags & MD_MARK_OPENER)); + MD_ASSERT(mark->ch == '`' && (mark->flags & MD_MARK_CLOSER)); + + if(prev_mark->end < off && off < mark->beg) + MD_TEXT(MD_TEXT_CODE, _T(" "), 1); + } else if(text_type == MD_TEXT_HTML) { + /* Inside raw HTML, we output the new line verbatim, including + * any trailing spaces. */ + OFF tmp = off; + + while(tmp < end && ISBLANK(tmp)) + tmp++; + if(tmp > off) + MD_TEXT(MD_TEXT_HTML, STR(off), tmp - off); + MD_TEXT(MD_TEXT_HTML, _T("\n"), 1); + } else { + /* Output soft or hard line break. */ + MD_TEXTTYPE break_type = MD_TEXT_SOFTBR; + + if(text_type == MD_TEXT_NORMAL) { + if(enforce_hardbreak) + break_type = MD_TEXT_BR; + else if((CH(line->end) == _T(' ') && CH(line->end+1) == _T(' '))) + break_type = MD_TEXT_BR; + } + + MD_TEXT(break_type, _T("\n"), 1); + } + + /* Move to the next line. */ + line++; + off = line->beg; + + enforce_hardbreak = 0; + } + } + +abort: + return ret; +} + + +/*************************** + *** Processing Tables *** + ***************************/ + +static void +md_analyze_table_alignment(MD_CTX* ctx, OFF beg, OFF end, MD_ALIGN* align, int n_align) +{ + static const MD_ALIGN align_map[] = { MD_ALIGN_DEFAULT, MD_ALIGN_LEFT, MD_ALIGN_RIGHT, MD_ALIGN_CENTER }; + OFF off = beg; + + while(n_align > 0) { + int index = 0; /* index into align_map[] */ + + while(CH(off) != _T('-')) + off++; + if(off > beg && CH(off-1) == _T(':')) + index |= 1; + while(off < end && CH(off) == _T('-')) + off++; + if(off < end && CH(off) == _T(':')) + index |= 2; + + *align = align_map[index]; + align++; + n_align--; + } + +} + +/* Forward declaration. */ +static int md_process_normal_block_contents(MD_CTX* ctx, const MD_LINE* lines, int n_lines); + +static int +md_process_table_cell(MD_CTX* ctx, MD_BLOCKTYPE cell_type, MD_ALIGN align, OFF beg, OFF end) +{ + MD_LINE line; + MD_BLOCK_TD_DETAIL det; + int ret = 0; + + while(beg < end && ISWHITESPACE(beg)) + beg++; + while(end > beg && ISWHITESPACE(end-1)) + end--; + + det.align = align; + line.beg = beg; + line.end = end; + + MD_ENTER_BLOCK(cell_type, &det); + MD_CHECK(md_process_normal_block_contents(ctx, &line, 1)); + MD_LEAVE_BLOCK(cell_type, &det); + +abort: + return ret; +} + +static int +md_process_table_row(MD_CTX* ctx, MD_BLOCKTYPE cell_type, OFF beg, OFF end, + const MD_ALIGN* align, int col_count) +{ + MD_LINE line = { beg, end }; + OFF* pipe_offs = NULL; + int i, j, n; + int ret = 0; + + /* Break the line into table cells by identifying pipe characters who + * form the cell boundary. */ + MD_CHECK(md_analyze_inlines(ctx, &line, 1, TRUE)); + + /* We have to remember the cell boundaries in local buffer because + * ctx->marks[] shall be reused during cell contents processing. */ + n = ctx->n_table_cell_boundaries; + pipe_offs = (OFF*) malloc(n * sizeof(OFF)); + if(pipe_offs == NULL) { + MD_LOG("malloc() failed."); + ret = -1; + goto abort; + } + for(i = TABLECELLBOUNDARIES.head, j = 0; i >= 0; i = ctx->marks[i].next) { + MD_MARK* mark = &ctx->marks[i]; + pipe_offs[j++] = mark->beg; + } + + /* Process cells. */ + MD_ENTER_BLOCK(MD_BLOCK_TR, NULL); + j = 0; + if(beg < pipe_offs[0] && j < col_count) + MD_CHECK(md_process_table_cell(ctx, cell_type, align[j++], beg, pipe_offs[0])); + for(i = 0; i < n-1 && j < col_count; i++) + MD_CHECK(md_process_table_cell(ctx, cell_type, align[j++], pipe_offs[i]+1, pipe_offs[i+1])); + if(pipe_offs[n-1] < end-1 && j < col_count) + MD_CHECK(md_process_table_cell(ctx, cell_type, align[j++], pipe_offs[n-1]+1, end)); + /* Make sure we call enough table cells even if the current table contains + * too few of them. */ + while(j < col_count) + MD_CHECK(md_process_table_cell(ctx, cell_type, align[j++], 0, 0)); + + MD_LEAVE_BLOCK(MD_BLOCK_TR, NULL); + +abort: + free(pipe_offs); + + /* Free any temporary memory blocks stored within some dummy marks. */ + for(i = PTR_CHAIN.head; i >= 0; i = ctx->marks[i].next) + free(md_mark_get_ptr(ctx, i)); + PTR_CHAIN.head = -1; + PTR_CHAIN.tail = -1; + + return ret; +} + +static int +md_process_table_block_contents(MD_CTX* ctx, int col_count, const MD_LINE* lines, int n_lines) +{ + MD_ALIGN* align; + int i; + int ret = 0; + + /* At least two lines have to be present: The column headers and the line + * with the underlines. */ + MD_ASSERT(n_lines >= 2); + + align = malloc(col_count * sizeof(MD_ALIGN)); + if(align == NULL) { + MD_LOG("malloc() failed."); + ret = -1; + goto abort; + } + + md_analyze_table_alignment(ctx, lines[1].beg, lines[1].end, align, col_count); + + MD_ENTER_BLOCK(MD_BLOCK_THEAD, NULL); + MD_CHECK(md_process_table_row(ctx, MD_BLOCK_TH, + lines[0].beg, lines[0].end, align, col_count)); + MD_LEAVE_BLOCK(MD_BLOCK_THEAD, NULL); + + MD_ENTER_BLOCK(MD_BLOCK_TBODY, NULL); + for(i = 2; i < n_lines; i++) { + MD_CHECK(md_process_table_row(ctx, MD_BLOCK_TD, + lines[i].beg, lines[i].end, align, col_count)); + } + MD_LEAVE_BLOCK(MD_BLOCK_TBODY, NULL); + +abort: + free(align); + return ret; +} + +static int +md_is_table_row(MD_CTX* ctx, OFF beg, OFF* p_end) +{ + MD_LINE line = { beg, beg }; + int i; + int ret = FALSE; + + /* Find end of line. */ + while(line.end < ctx->size && !ISNEWLINE(line.end)) + line.end++; + + MD_CHECK(md_analyze_inlines(ctx, &line, 1, TRUE)); + + if(TABLECELLBOUNDARIES.head >= 0) { + if(p_end != NULL) + *p_end = line.end; + ret = TRUE; + } + +abort: + /* Free any temporary memory blocks stored within some dummy marks. */ + for(i = PTR_CHAIN.head; i >= 0; i = ctx->marks[i].next) + free(md_mark_get_ptr(ctx, i)); + PTR_CHAIN.head = -1; + PTR_CHAIN.tail = -1; + + return ret; +} + + +/************************** + *** Processing Block *** + **************************/ + +#define MD_BLOCK_CONTAINER_OPENER 0x01 +#define MD_BLOCK_CONTAINER_CLOSER 0x02 +#define MD_BLOCK_CONTAINER (MD_BLOCK_CONTAINER_OPENER | MD_BLOCK_CONTAINER_CLOSER) +#define MD_BLOCK_LOOSE_LIST 0x04 + +struct MD_BLOCK_tag { + MD_BLOCKTYPE type : 8; + unsigned flags : 8; + + /* MD_BLOCK_H: Header level (1 - 6) + * MD_BLOCK_CODE: Non-zero if fenced, zero if indented. + * MD_BLOCK_LI: Task mark character (0 if not task list item, 'x', 'X' or ' '). + * MD_BLOCK_TABLE: Column count (as determined by the table underline). + */ + unsigned data : 16; + + /* Leaf blocks: Count of lines (MD_LINE or MD_VERBATIMLINE) on the block. + * MD_BLOCK_LI: Task mark offset in the input doc. + * MD_BLOCK_OL: Start item number. + */ + unsigned n_lines; +}; + +struct MD_CONTAINER_tag { + CHAR ch; + unsigned is_loose : 8; + unsigned is_task : 8; + unsigned start; + unsigned mark_indent; + unsigned contents_indent; + OFF block_byte_off; + OFF task_mark_off; +}; + + +static int +md_process_normal_block_contents(MD_CTX* ctx, const MD_LINE* lines, int n_lines) +{ + int i; + int ret; + + MD_CHECK(md_analyze_inlines(ctx, lines, n_lines, FALSE)); + MD_CHECK(md_process_inlines(ctx, lines, n_lines)); + +abort: + /* Free any temporary memory blocks stored within some dummy marks. */ + for(i = PTR_CHAIN.head; i >= 0; i = ctx->marks[i].next) + free(md_mark_get_ptr(ctx, i)); + PTR_CHAIN.head = -1; + PTR_CHAIN.tail = -1; + + return ret; +} + +static int +md_process_verbatim_block_contents(MD_CTX* ctx, MD_TEXTTYPE text_type, const MD_VERBATIMLINE* lines, int n_lines) +{ + static const CHAR indent_chunk_str[] = _T(" "); + static const SZ indent_chunk_size = SIZEOF_ARRAY(indent_chunk_str) - 1; + + int i; + int ret = 0; + + for(i = 0; i < n_lines; i++) { + const MD_VERBATIMLINE* line = &lines[i]; + int indent = line->indent; + + MD_ASSERT(indent >= 0); + + /* Output code indentation. */ + while(indent > SIZEOF_ARRAY(indent_chunk_str)) { + MD_TEXT(text_type, indent_chunk_str, indent_chunk_size); + indent -= SIZEOF_ARRAY(indent_chunk_str); + } + if(indent > 0) + MD_TEXT(text_type, indent_chunk_str, indent); + + /* Output the code line itself. */ + MD_TEXT_INSECURE(text_type, STR(line->beg), line->end - line->beg); + + /* Enforce end-of-line. */ + MD_TEXT(text_type, _T("\n"), 1); + } + +abort: + return ret; +} + +static int +md_process_code_block_contents(MD_CTX* ctx, int is_fenced, const MD_VERBATIMLINE* lines, int n_lines) +{ + if(is_fenced) { + /* Skip the first line in case of fenced code: It is the fence. + * (Only the starting fence is present due to logic in md_analyze_line().) */ + lines++; + n_lines--; + } else { + /* Ignore blank lines at start/end of indented code block. */ + while(n_lines > 0 && lines[0].beg == lines[0].end) { + lines++; + n_lines--; + } + while(n_lines > 0 && lines[n_lines-1].beg == lines[n_lines-1].end) { + n_lines--; + } + } + + if(n_lines == 0) + return 0; + + return md_process_verbatim_block_contents(ctx, MD_TEXT_CODE, lines, n_lines); +} + +static int +md_setup_fenced_code_detail(MD_CTX* ctx, const MD_BLOCK* block, MD_BLOCK_CODE_DETAIL* det, + MD_ATTRIBUTE_BUILD* info_build, MD_ATTRIBUTE_BUILD* lang_build) +{ + const MD_VERBATIMLINE* fence_line = (const MD_VERBATIMLINE*)(block + 1); + OFF beg = fence_line->beg; + OFF end = fence_line->end; + OFF lang_end; + CHAR fence_ch = CH(fence_line->beg); + int ret = 0; + + /* Skip the fence itself. */ + while(beg < ctx->size && CH(beg) == fence_ch) + beg++; + /* Trim initial spaces. */ + while(beg < ctx->size && CH(beg) == _T(' ')) + beg++; + + /* Trim trailing spaces. */ + while(end > beg && CH(end-1) == _T(' ')) + end--; + + /* Build info string attribute. */ + MD_CHECK(md_build_attribute(ctx, STR(beg), end - beg, 0, &det->info, info_build)); + + /* Build info string attribute. */ + lang_end = beg; + while(lang_end < end && !ISWHITESPACE(lang_end)) + lang_end++; + MD_CHECK(md_build_attribute(ctx, STR(beg), lang_end - beg, 0, &det->lang, lang_build)); + +abort: + return ret; +} + +static int +md_process_leaf_block(MD_CTX* ctx, const MD_BLOCK* block) +{ + union { + MD_BLOCK_H_DETAIL header; + MD_BLOCK_CODE_DETAIL code; + } det; + MD_ATTRIBUTE_BUILD info_build; + MD_ATTRIBUTE_BUILD lang_build; + int is_in_tight_list; + int clean_fence_code_detail = FALSE; + int ret = 0; + + memset(&det, 0, sizeof(det)); + + if(ctx->n_containers == 0) + is_in_tight_list = FALSE; + else + is_in_tight_list = !ctx->containers[ctx->n_containers-1].is_loose; + + switch(block->type) { + case MD_BLOCK_H: + det.header.level = block->data; + break; + + case MD_BLOCK_CODE: + /* For fenced code block, we may need to set the info string. */ + if(block->data != 0) { + memset(&det.code, 0, sizeof(MD_BLOCK_CODE_DETAIL)); + clean_fence_code_detail = TRUE; + MD_CHECK(md_setup_fenced_code_detail(ctx, block, &det.code, &info_build, &lang_build)); + } + break; + + default: + /* Noop. */ + break; + } + + if(!is_in_tight_list || block->type != MD_BLOCK_P) + MD_ENTER_BLOCK(block->type, (void*) &det); + + /* Process the block contents accordingly to is type. */ + switch(block->type) { + case MD_BLOCK_HR: + /* noop */ + break; + + case MD_BLOCK_CODE: + MD_CHECK(md_process_code_block_contents(ctx, (block->data != 0), + (const MD_VERBATIMLINE*)(block + 1), block->n_lines)); + break; + + case MD_BLOCK_HTML: + MD_CHECK(md_process_verbatim_block_contents(ctx, MD_TEXT_HTML, + (const MD_VERBATIMLINE*)(block + 1), block->n_lines)); + break; + + case MD_BLOCK_TABLE: + MD_CHECK(md_process_table_block_contents(ctx, block->data, + (const MD_LINE*)(block + 1), block->n_lines)); + break; + + default: + MD_CHECK(md_process_normal_block_contents(ctx, + (const MD_LINE*)(block + 1), block->n_lines)); + break; + } + + if(!is_in_tight_list || block->type != MD_BLOCK_P) + MD_LEAVE_BLOCK(block->type, (void*) &det); + +abort: + if(clean_fence_code_detail) { + md_free_attribute(ctx, &info_build); + md_free_attribute(ctx, &lang_build); + } + return ret; +} + +static int +md_process_all_blocks(MD_CTX* ctx) +{ + int byte_off = 0; + int ret = 0; + + /* ctx->containers now is not needed for detection of lists and list items + * so we reuse it for tracking what lists are loose or tight. We rely + * on the fact the vector is large enough to hold the deepest nesting + * level of lists. */ + ctx->n_containers = 0; + + while(byte_off < ctx->n_block_bytes) { + MD_BLOCK* block = (MD_BLOCK*)((char*)ctx->block_bytes + byte_off); + union { + MD_BLOCK_UL_DETAIL ul; + MD_BLOCK_OL_DETAIL ol; + MD_BLOCK_LI_DETAIL li; + } det; + + switch(block->type) { + case MD_BLOCK_UL: + det.ul.is_tight = (block->flags & MD_BLOCK_LOOSE_LIST) ? FALSE : TRUE; + det.ul.mark = (CHAR) block->data; + break; + + case MD_BLOCK_OL: + det.ol.start = block->n_lines; + det.ol.is_tight = (block->flags & MD_BLOCK_LOOSE_LIST) ? FALSE : TRUE; + det.ol.mark_delimiter = (CHAR) block->data; + break; + + case MD_BLOCK_LI: + det.li.is_task = (block->data != 0); + det.li.task_mark = (CHAR) block->data; + det.li.task_mark_offset = (OFF) block->n_lines; + break; + + default: + /* noop */ + break; + } + + if(block->flags & MD_BLOCK_CONTAINER) { + if(block->flags & MD_BLOCK_CONTAINER_CLOSER) { + MD_LEAVE_BLOCK(block->type, &det); + + if(block->type == MD_BLOCK_UL || block->type == MD_BLOCK_OL || block->type == MD_BLOCK_QUOTE) + ctx->n_containers--; + } + + if(block->flags & MD_BLOCK_CONTAINER_OPENER) { + MD_ENTER_BLOCK(block->type, &det); + + if(block->type == MD_BLOCK_UL || block->type == MD_BLOCK_OL) { + ctx->containers[ctx->n_containers].is_loose = (block->flags & MD_BLOCK_LOOSE_LIST); + ctx->n_containers++; + } else if(block->type == MD_BLOCK_QUOTE) { + /* This causes that any text in a block quote, even if + * nested inside a tight list item, is wrapped with + *

    ...

    . */ + ctx->containers[ctx->n_containers].is_loose = TRUE; + ctx->n_containers++; + } + } + } else { + MD_CHECK(md_process_leaf_block(ctx, block)); + + if(block->type == MD_BLOCK_CODE || block->type == MD_BLOCK_HTML) + byte_off += block->n_lines * sizeof(MD_VERBATIMLINE); + else + byte_off += block->n_lines * sizeof(MD_LINE); + } + + byte_off += sizeof(MD_BLOCK); + } + + ctx->n_block_bytes = 0; + +abort: + return ret; +} + + +/************************************ + *** Grouping Lines into Blocks *** + ************************************/ + +static void* +md_push_block_bytes(MD_CTX* ctx, int n_bytes) +{ + void* ptr; + + if(ctx->n_block_bytes + n_bytes > ctx->alloc_block_bytes) { + void* new_block_bytes; + + ctx->alloc_block_bytes = (ctx->alloc_block_bytes > 0 ? ctx->alloc_block_bytes * 2 : 512); + new_block_bytes = realloc(ctx->block_bytes, ctx->alloc_block_bytes); + if(new_block_bytes == NULL) { + MD_LOG("realloc() failed."); + return NULL; + } + + /* Fix the ->current_block after the reallocation. */ + if(ctx->current_block != NULL) { + OFF off_current_block = (char*) ctx->current_block - (char*) ctx->block_bytes; + ctx->current_block = (MD_BLOCK*) ((char*) new_block_bytes + off_current_block); + } + + ctx->block_bytes = new_block_bytes; + } + + ptr = (char*)ctx->block_bytes + ctx->n_block_bytes; + ctx->n_block_bytes += n_bytes; + return ptr; +} + +static int +md_start_new_block(MD_CTX* ctx, const MD_LINE_ANALYSIS* line) +{ + MD_BLOCK* block; + + MD_ASSERT(ctx->current_block == NULL); + + block = (MD_BLOCK*) md_push_block_bytes(ctx, sizeof(MD_BLOCK)); + if(block == NULL) + return -1; + + switch(line->type) { + case MD_LINE_HR: + block->type = MD_BLOCK_HR; + break; + + case MD_LINE_ATXHEADER: + case MD_LINE_SETEXTHEADER: + block->type = MD_BLOCK_H; + break; + + case MD_LINE_FENCEDCODE: + case MD_LINE_INDENTEDCODE: + block->type = MD_BLOCK_CODE; + break; + + case MD_LINE_TEXT: + block->type = MD_BLOCK_P; + break; + + case MD_LINE_HTML: + block->type = MD_BLOCK_HTML; + break; + + case MD_LINE_BLANK: + case MD_LINE_SETEXTUNDERLINE: + case MD_LINE_TABLEUNDERLINE: + default: + MD_UNREACHABLE(); + break; + } + + block->flags = 0; + block->data = line->data; + block->n_lines = 0; + + ctx->current_block = block; + return 0; +} + +/* Eat from start of current (textual) block any reference definitions and + * remember them so we can resolve any links referring to them. + * + * (Reference definitions can only be at start of it as they cannot break + * a paragraph.) + */ +static int +md_consume_link_reference_definitions(MD_CTX* ctx) +{ + MD_LINE* lines = (MD_LINE*) (ctx->current_block + 1); + int n_lines = ctx->current_block->n_lines; + int n = 0; + + /* Compute how many lines at the start of the block form one or more + * reference definitions. */ + while(n < n_lines) { + int n_link_ref_lines; + + n_link_ref_lines = md_is_link_reference_definition(ctx, + lines + n, n_lines - n); + /* Not a reference definition? */ + if(n_link_ref_lines == 0) + break; + + /* We fail if it is the ref. def. but it could not be stored due + * a memory allocation error. */ + if(n_link_ref_lines < 0) + return -1; + + n += n_link_ref_lines; + } + + /* If there was at least one reference definition, we need to remove + * its lines from the block, or perhaps even the whole block. */ + if(n > 0) { + if(n == n_lines) { + /* Remove complete block. */ + ctx->n_block_bytes -= n * sizeof(MD_LINE); + ctx->n_block_bytes -= sizeof(MD_BLOCK); + } else { + /* Remove just some initial lines from the block. */ + memmove(lines, lines + n, (n_lines - n) * sizeof(MD_LINE)); + ctx->current_block->n_lines -= n; + ctx->n_block_bytes -= n * sizeof(MD_LINE); + } + } + + return 0; +} + +static int +md_end_current_block(MD_CTX* ctx) +{ + int ret = 0; + + if(ctx->current_block == NULL) + return ret; + + /* Check whether there is a reference definition. (We do this here instead + * of in md_analyze_line() because reference definition can take multiple + * lines.) */ + if(ctx->current_block->type == MD_BLOCK_P) { + MD_LINE* lines = (MD_LINE*) (ctx->current_block + 1); + if(CH(lines[0].beg) == _T('[')) + MD_CHECK(md_consume_link_reference_definitions(ctx)); + } + + /* Mark we are not building any block anymore. */ + ctx->current_block = NULL; + +abort: + return ret; +} + +static int +md_add_line_into_current_block(MD_CTX* ctx, const MD_LINE_ANALYSIS* analysis) +{ + MD_ASSERT(ctx->current_block != NULL); + + if(ctx->current_block->type == MD_BLOCK_CODE || ctx->current_block->type == MD_BLOCK_HTML) { + MD_VERBATIMLINE* line; + + line = (MD_VERBATIMLINE*) md_push_block_bytes(ctx, sizeof(MD_VERBATIMLINE)); + if(line == NULL) + return -1; + + line->indent = analysis->indent; + line->beg = analysis->beg; + line->end = analysis->end; + } else { + MD_LINE* line; + + line = (MD_LINE*) md_push_block_bytes(ctx, sizeof(MD_LINE)); + if(line == NULL) + return -1; + + line->beg = analysis->beg; + line->end = analysis->end; + } + ctx->current_block->n_lines++; + + return 0; +} + +static int +md_push_container_bytes(MD_CTX* ctx, MD_BLOCKTYPE type, unsigned start, + unsigned data, unsigned flags) +{ + MD_BLOCK* block; + int ret = 0; + + MD_CHECK(md_end_current_block(ctx)); + + block = (MD_BLOCK*) md_push_block_bytes(ctx, sizeof(MD_BLOCK)); + if(block == NULL) + return -1; + + block->type = type; + block->flags = flags; + block->data = data; + block->n_lines = start; + +abort: + return ret; +} + + + +/*********************** + *** Line Analysis *** + ***********************/ + +static int +md_is_hr_line(MD_CTX* ctx, OFF beg, OFF* p_end) +{ + OFF off = beg + 1; + int n = 1; + + while(off < ctx->size && (CH(off) == CH(beg) || CH(off) == _T(' ') || CH(off) == _T('\t'))) { + if(CH(off) == CH(beg)) + n++; + off++; + } + + if(n < 3) + return FALSE; + + /* Nothing else can be present on the line. */ + if(off < ctx->size && !ISNEWLINE(off)) + return FALSE; + + *p_end = off; + return TRUE; +} + +static int +md_is_atxheader_line(MD_CTX* ctx, OFF beg, OFF* p_beg, OFF* p_end, unsigned* p_level) +{ + int n; + OFF off = beg + 1; + + while(off < ctx->size && CH(off) == _T('#') && off - beg < 7) + off++; + n = off - beg; + + if(n > 6) + return FALSE; + *p_level = n; + + if(!(ctx->parser.flags & MD_FLAG_PERMISSIVEATXHEADERS) && off < ctx->size && + CH(off) != _T(' ') && CH(off) != _T('\t') && !ISNEWLINE(off)) + return FALSE; + + while(off < ctx->size && CH(off) == _T(' ')) + off++; + *p_beg = off; + *p_end = off; + return TRUE; +} + +static int +md_is_setext_underline(MD_CTX* ctx, OFF beg, OFF* p_end, unsigned* p_level) +{ + OFF off = beg + 1; + + while(off < ctx->size && CH(off) == CH(beg)) + off++; + + while(off < ctx->size && CH(off) == _T(' ')) + off++; + + /* Optionally, space(s) can follow. */ + while(off < ctx->size && CH(off) == _T(' ')) + off++; + + /* But nothing more is allowed on the line. */ + if(off < ctx->size && !ISNEWLINE(off)) + return FALSE; + + *p_level = (CH(beg) == _T('=') ? 1 : 2); + *p_end = off; + return TRUE; +} + +static int +md_is_table_underline(MD_CTX* ctx, OFF beg, OFF* p_end, unsigned* p_col_count) +{ + OFF off = beg; + int found_pipe = FALSE; + unsigned col_count = 0; + + if(off < ctx->size && CH(off) == _T('|')) { + found_pipe = TRUE; + off++; + while(off < ctx->size && ISWHITESPACE(off)) + off++; + } + + while(1) { + OFF cell_beg; + int delimited = FALSE; + + /* Cell underline ("-----", ":----", "----:" or ":----:") */ + cell_beg = off; + if(off < ctx->size && CH(off) == _T(':')) + off++; + while(off < ctx->size && CH(off) == _T('-')) + off++; + if(off < ctx->size && CH(off) == _T(':')) + off++; + if(off - cell_beg < 3) + return FALSE; + + col_count++; + + /* Pipe delimiter (optional at the end of line). */ + while(off < ctx->size && ISWHITESPACE(off)) + off++; + if(off < ctx->size && CH(off) == _T('|')) { + delimited = TRUE; + found_pipe = TRUE; + off++; + while(off < ctx->size && ISWHITESPACE(off)) + off++; + } + + /* Success, if we reach end of line. */ + if(off >= ctx->size || ISNEWLINE(off)) + break; + + if(!delimited) + return FALSE; + } + + if(!found_pipe) + return FALSE; + + *p_end = off; + *p_col_count = col_count; + return TRUE; +} + +static int +md_is_opening_code_fence(MD_CTX* ctx, OFF beg, OFF* p_end) +{ + OFF off = beg; + + while(off < ctx->size && CH(off) == CH(beg)) + off++; + + /* Fence must have at least three characters. */ + if(off - beg < 3) + return FALSE; + + ctx->code_fence_length = off - beg; + + /* Optionally, space(s) can follow. */ + while(off < ctx->size && CH(off) == _T(' ')) + off++; + + /* Optionally, an info string can follow. It must not contain '`'. */ + while(off < ctx->size && CH(off) != _T('`') && !ISNEWLINE(off)) + off++; + if(off < ctx->size && !ISNEWLINE(off)) + return FALSE; + + *p_end = off; + return TRUE; +} + +static int +md_is_closing_code_fence(MD_CTX* ctx, CHAR ch, OFF beg, OFF* p_end) +{ + OFF off = beg; + int ret = FALSE; + + /* Closing fence must have at least the same length and use same char as + * opening one. */ + while(off < ctx->size && CH(off) == ch) + off++; + if(off - beg < ctx->code_fence_length) + goto out; + + /* Optionally, space(s) can follow */ + while(off < ctx->size && CH(off) == _T(' ')) + off++; + + /* But nothing more is allowed on the line. */ + if(off < ctx->size && !ISNEWLINE(off)) + goto out; + + ret = TRUE; + +out: + /* Note we set *p_end even on failure: If we are not closing fence, caller + * would eat the line anyway without any parsing. */ + *p_end = off; + return ret; +} + +/* Returns type of the raw HTML block, or FALSE if it is not HTML block. + * (Refer to CommonMark specification for details about the types.) + */ +static int +md_is_html_block_start_condition(MD_CTX* ctx, OFF beg) +{ + typedef struct TAG_tag TAG; + struct TAG_tag { + const CHAR* name; + unsigned len : 8; + }; + + /* Type 6 is started by a long list of allowed tags. We use two-level + * tree to speed-up the search. */ +#ifdef X + #undef X +#endif +#define X(name) { _T(name), sizeof(name)-1 } +#define Xend { NULL, 0 } + static const TAG t1[] = { X("script"), X("pre"), X("style"), Xend }; + + static const TAG a6[] = { X("address"), X("article"), X("aside"), Xend }; + static const TAG b6[] = { X("base"), X("basefont"), X("blockquote"), X("body"), Xend }; + static const TAG c6[] = { X("caption"), X("center"), X("col"), X("colgroup"), Xend }; + static const TAG d6[] = { X("dd"), X("details"), X("dialog"), X("dir"), + X("div"), X("dl"), X("dt"), Xend }; + static const TAG f6[] = { X("fieldset"), X("figcaption"), X("figure"), X("footer"), + X("form"), X("frame"), X("frameset"), Xend }; + static const TAG h6[] = { X("h1"), X("head"), X("header"), X("hr"), X("html"), Xend }; + static const TAG i6[] = { X("iframe"), Xend }; + static const TAG l6[] = { X("legend"), X("li"), X("link"), Xend }; + static const TAG m6[] = { X("main"), X("menu"), X("menuitem"), X("meta"), Xend }; + static const TAG n6[] = { X("nav"), X("noframes"), Xend }; + static const TAG o6[] = { X("ol"), X("optgroup"), X("option"), Xend }; + static const TAG p6[] = { X("p"), X("param"), Xend }; + static const TAG s6[] = { X("section"), X("source"), X("summary"), Xend }; + static const TAG t6[] = { X("table"), X("tbody"), X("td"), X("tfoot"), X("th"), + X("thead"), X("title"), X("tr"), X("track"), Xend }; + static const TAG u6[] = { X("ul"), Xend }; + static const TAG xx[] = { Xend }; +#undef X + + static const TAG* map6[26] = { + a6, b6, c6, d6, xx, f6, xx, h6, i6, xx, xx, l6, m6, + n6, o6, p6, xx, xx, s6, t6, u6, xx, xx, xx, xx, xx + }; + OFF off = beg + 1; + int i; + + /* Check for type 1: size) { + if(md_ascii_case_eq(STR(off), t1[i].name, t1[i].len)) + return 1; + } + } + + /* Check for type 2: "), 3, p_end) ? 2 : FALSE); + + case 3: + return (md_line_contains(ctx, beg, _T("?>"), 2, p_end) ? 3 : FALSE); + + case 4: + return (md_line_contains(ctx, beg, _T(">"), 1, p_end) ? 4 : FALSE); + + case 5: + return (md_line_contains(ctx, beg, _T("]]>"), 3, p_end) ? 5 : FALSE); + + case 6: /* Pass through */ + case 7: + *p_end = beg; + return (ISNEWLINE(beg) ? ctx->html_block_type : FALSE); + + default: + MD_UNREACHABLE(); + } +} + + +static int +md_is_container_compatible(const MD_CONTAINER* pivot, const MD_CONTAINER* container) +{ + /* Block quote has no "items" like lists. */ + if(container->ch == _T('>')) + return FALSE; + + if(container->ch != pivot->ch) + return FALSE; + if(container->mark_indent > pivot->contents_indent) + return FALSE; + + return TRUE; +} + +static int +md_push_container(MD_CTX* ctx, const MD_CONTAINER* container) +{ + if(ctx->n_containers >= ctx->alloc_containers) { + MD_CONTAINER* new_containers; + + ctx->alloc_containers = (ctx->alloc_containers > 0 ? ctx->alloc_containers * 2 : 16); + new_containers = realloc(ctx->containers, ctx->alloc_containers * sizeof(MD_CONTAINER)); + if(new_containers == NULL) { + MD_LOG("realloc() failed."); + return -1; + } + + ctx->containers = new_containers; + } + + memcpy(&ctx->containers[ctx->n_containers++], container, sizeof(MD_CONTAINER)); + return 0; +} + +static int +md_enter_child_containers(MD_CTX* ctx, int n_children, unsigned data) +{ + int i; + int ret = 0; + + for(i = ctx->n_containers - n_children; i < ctx->n_containers; i++) { + MD_CONTAINER* c = &ctx->containers[i]; + int is_ordered_list = FALSE; + + switch(c->ch) { + case _T(')'): + case _T('.'): + is_ordered_list = TRUE; + /* Pass through */ + + case _T('-'): + case _T('+'): + case _T('*'): + /* Remember offset in ctx->block_bytes so we can revisit the + * block if we detect it is a loose list. */ + md_end_current_block(ctx); + c->block_byte_off = ctx->n_block_bytes; + + MD_CHECK(md_push_container_bytes(ctx, + (is_ordered_list ? MD_BLOCK_OL : MD_BLOCK_UL), + c->start, data, MD_BLOCK_CONTAINER_OPENER)); + MD_CHECK(md_push_container_bytes(ctx, MD_BLOCK_LI, + c->task_mark_off, + (c->is_task ? CH(c->task_mark_off) : 0), + MD_BLOCK_CONTAINER_OPENER)); + break; + + case _T('>'): + MD_CHECK(md_push_container_bytes(ctx, MD_BLOCK_QUOTE, 0, 0, MD_BLOCK_CONTAINER_OPENER)); + break; + + default: + MD_UNREACHABLE(); + break; + } + } + +abort: + return ret; +} + +static int +md_leave_child_containers(MD_CTX* ctx, int n_keep) +{ + int ret = 0; + + while(ctx->n_containers > n_keep) { + MD_CONTAINER* c = &ctx->containers[ctx->n_containers-1]; + int is_ordered_list = FALSE; + + switch(c->ch) { + case _T(')'): + case _T('.'): + is_ordered_list = TRUE; + /* Pass through */ + + case _T('-'): + case _T('+'): + case _T('*'): + MD_CHECK(md_push_container_bytes(ctx, MD_BLOCK_LI, + c->task_mark_off, (c->is_task ? CH(c->task_mark_off) : 0), + MD_BLOCK_CONTAINER_CLOSER)); + MD_CHECK(md_push_container_bytes(ctx, + (is_ordered_list ? MD_BLOCK_OL : MD_BLOCK_UL), 0, + c->ch, MD_BLOCK_CONTAINER_CLOSER)); + break; + + case _T('>'): + MD_CHECK(md_push_container_bytes(ctx, MD_BLOCK_QUOTE, 0, + 0, MD_BLOCK_CONTAINER_CLOSER)); + break; + + default: + MD_UNREACHABLE(); + break; + } + + ctx->n_containers--; + } + +abort: + return ret; +} + +static int +md_is_container_mark(MD_CTX* ctx, unsigned indent, OFF beg, OFF* p_end, MD_CONTAINER* p_container) +{ + OFF off = beg; + OFF max_end; + + /* Check for block quote mark. */ + if(off < ctx->size && CH(off) == _T('>')) { + off++; + p_container->ch = _T('>'); + p_container->is_loose = FALSE; + p_container->is_task = FALSE; + p_container->mark_indent = indent; + p_container->contents_indent = indent + 1; + *p_end = off; + return TRUE; + } + + /* Check for list item bullet mark. */ + if(off+1 < ctx->size && ISANYOF(off, _T("-+*")) && (ISBLANK(off+1) || ISNEWLINE(off+1))) { + p_container->ch = CH(off); + p_container->is_loose = FALSE; + p_container->is_task = FALSE; + p_container->mark_indent = indent; + p_container->contents_indent = indent + 1; + *p_end = off + 1; + return TRUE; + } + + /* Check for ordered list item marks. */ + max_end = off + 9; + if(max_end > ctx->size) + max_end = ctx->size; + p_container->start = 0; + while(off < max_end && ISDIGIT(off)) { + p_container->start = p_container->start * 10 + CH(off) - _T('0'); + off++; + } + if(off+1 < ctx->size && (CH(off) == _T('.') || CH(off) == _T(')')) && (ISBLANK(off+1) || ISNEWLINE(off+1))) { + p_container->ch = CH(off); + p_container->is_loose = FALSE; + p_container->is_task = FALSE; + p_container->mark_indent = indent; + p_container->contents_indent = indent + off - beg + 1; + *p_end = off + 1; + return TRUE; + } + + return FALSE; +} + +static unsigned +md_line_indentation(MD_CTX* ctx, unsigned total_indent, OFF beg, OFF* p_end) +{ + OFF off = beg; + unsigned indent = total_indent; + + while(off < ctx->size && ISBLANK(off)) { + if(CH(off) == _T('\t')) + indent = (indent + 4) & ~3; + else + indent++; + off++; + } + + *p_end = off; + return indent - total_indent; +} + +static const MD_LINE_ANALYSIS md_dummy_blank_line = { MD_LINE_BLANK, 0 }; + +/* Analyze type of the line and find some its properties. This serves as a + * main input for determining type and boundaries of a block. */ +static int +md_analyze_line(MD_CTX* ctx, OFF beg, OFF* p_end, + const MD_LINE_ANALYSIS* pivot_line, MD_LINE_ANALYSIS* line) +{ + unsigned total_indent = 0; + int n_parents = 0; + int n_brothers = 0; + int n_children = 0; + MD_CONTAINER container = { 0 }; + int prev_line_has_list_loosening_effect = ctx->last_line_has_list_loosening_effect; + OFF off = beg; + int ret = 0; + + line->indent = md_line_indentation(ctx, total_indent, off, &off); + total_indent += line->indent; + line->beg = off; + + /* Given the indentation and block quote marks '>', determine how many of + * the current containers are our parents. */ + while(n_parents < ctx->n_containers) { + MD_CONTAINER* c = &ctx->containers[n_parents]; + + if(c->ch == _T('>') && line->indent < ctx->code_indent_offset && + off < ctx->size && CH(off) == _T('>')) + { + /* Block quote mark. */ + off++; + total_indent++; + line->indent = md_line_indentation(ctx, total_indent, off, &off); + total_indent += line->indent; + + /* The optional 1st space after '>' is part of the block quote mark. */ + if(line->indent > 0) + line->indent--; + + line->beg = off; + } else if(c->ch != _T('>') && line->indent >= c->contents_indent) { + /* List. */ + line->indent -= c->contents_indent; + } else { + break; + } + + n_parents++; + } + +redo: + /* Check whether we are fenced code continuation. */ + if(pivot_line->type == MD_LINE_FENCEDCODE) { + line->beg = off; + + /* We are another MD_LINE_FENCEDCODE unless we are closing fence + * which we transform into MD_LINE_BLANK. */ + if(line->indent < ctx->code_indent_offset) { + if(md_is_closing_code_fence(ctx, CH(pivot_line->beg), off, &off)) { + line->type = MD_LINE_BLANK; + ctx->last_line_has_list_loosening_effect = FALSE; + goto done; + } + } + + if(off >= ctx->size || ISNEWLINE(off)) { + /* Blank line does not need any real indentation to be nested inside + * a list. */ + if(n_brothers + n_children == 0) { + while(n_parents < ctx->n_containers && ctx->containers[n_parents].ch != _T('>')) + n_parents++; + } + } + + /* Change indentation accordingly to the initial code fence. */ + if(n_parents == ctx->n_containers) { + if(line->indent > pivot_line->indent) + line->indent -= pivot_line->indent; + else + line->indent = 0; + + line->type = MD_LINE_FENCEDCODE; + goto done; + } + } + + /* Check whether we are HTML block continuation. */ + if(pivot_line->type == MD_LINE_HTML && ctx->html_block_type > 0) { + int html_block_type; + + html_block_type = md_is_html_block_end_condition(ctx, off, &off); + if(html_block_type > 0) { + MD_ASSERT(html_block_type == ctx->html_block_type); + + /* Make sure this is the last line of the block. */ + ctx->html_block_type = 0; + + /* Some end conditions serve as blank lines at the same time. */ + if(html_block_type == 6 || html_block_type == 7) { + line->type = MD_LINE_BLANK; + line->indent = 0; + goto done; + } + } + + if(n_parents == ctx->n_containers) { + line->type = MD_LINE_HTML; + goto done; + } + } + + /* Check for blank line. */ + if(off >= ctx->size || ISNEWLINE(off)) { + /* Blank line does not need any real indentation to be nested inside + * a list. */ + if(n_brothers + n_children == 0) { + while(n_parents < ctx->n_containers && ctx->containers[n_parents].ch != _T('>')) + n_parents++; + } + + if(pivot_line->type == MD_LINE_INDENTEDCODE && n_parents == ctx->n_containers) { + line->type = MD_LINE_INDENTEDCODE; + if(line->indent > ctx->code_indent_offset) + line->indent -= ctx->code_indent_offset; + else + line->indent = 0; + ctx->last_line_has_list_loosening_effect = FALSE; + } else { + line->type = MD_LINE_BLANK; + ctx->last_line_has_list_loosening_effect = (n_parents > 0 && + n_brothers + n_children == 0 && + ctx->containers[n_parents-1].ch != _T('>')); + +#if 1 + /* See https://github.com/mity/md4c/issues/6 + * + * This ugly checking tests we are in (yet empty) list item but not + * its very first line (with the list item mark). + * + * If we are such blank line, then any following non-blank line + * which would be part of this list item actually ends the list + * because "a list item can begin with at most one blank line." + */ + if(n_parents > 0 && ctx->containers[n_parents-1].ch != _T('>') && + n_brothers + n_children == 0 && ctx->current_block == NULL && + ctx->n_block_bytes > sizeof(MD_BLOCK)) + { + MD_BLOCK* top_block = (MD_BLOCK*) ((char*)ctx->block_bytes + ctx->n_block_bytes - sizeof(MD_BLOCK)); + if(top_block->type == MD_BLOCK_LI) + ctx->last_list_item_starts_with_two_blank_lines = TRUE; + } +#endif + } + goto done_on_eol; + } else { +#if 1 + /* This is 2nd half of the hack. If the flag is set (that is there + * were 2nd blank line at the start of the list item) and we would also + * belonging to such list item, then interrupt the list. */ + ctx->last_line_has_list_loosening_effect = FALSE; + if(ctx->last_list_item_starts_with_two_blank_lines) { + if(n_parents > 0 && ctx->containers[n_parents-1].ch != _T('>') && + n_brothers + n_children == 0 && ctx->current_block == NULL && + ctx->n_block_bytes > sizeof(MD_BLOCK)) + { + MD_BLOCK* top_block = (MD_BLOCK*) ((char*)ctx->block_bytes + ctx->n_block_bytes - sizeof(MD_BLOCK)); + if(top_block->type == MD_BLOCK_LI) + n_parents--; + } + + ctx->last_list_item_starts_with_two_blank_lines = FALSE; + } +#endif + } + + /* Check whether we are Setext underline. */ + if(line->indent < ctx->code_indent_offset && pivot_line->type == MD_LINE_TEXT + && (CH(off) == _T('=') || CH(off) == _T('-')) + && (n_parents == ctx->n_containers)) + { + unsigned level; + + if(md_is_setext_underline(ctx, off, &off, &level)) { + line->type = MD_LINE_SETEXTUNDERLINE; + line->data = level; + goto done; + } + } + + /* Check for thematic break line. */ + if(line->indent < ctx->code_indent_offset && ISANYOF(off, _T("-_*"))) { + if(md_is_hr_line(ctx, off, &off)) { + line->type = MD_LINE_HR; + goto done; + } + } + + /* Check for "brother" container. I.e. whether we are another list item + * in already started list. */ + if(n_parents < ctx->n_containers && n_brothers + n_children == 0) { + OFF tmp; + + if(md_is_container_mark(ctx, line->indent, off, &tmp, &container) && + md_is_container_compatible(&ctx->containers[n_parents], &container)) + { + pivot_line = &md_dummy_blank_line; + + off = tmp; + + total_indent += container.contents_indent - container.mark_indent; + line->indent = md_line_indentation(ctx, total_indent, off, &off); + total_indent += line->indent; + line->beg = off; + + /* Some of the following whitespace actually still belongs to the mark. */ + if(off >= ctx->size || ISNEWLINE(off)) { + container.contents_indent++; + } else if(line->indent <= ctx->code_indent_offset) { + container.contents_indent += line->indent; + line->indent = 0; + } else { + container.contents_indent += 1; + line->indent--; + } + + ctx->containers[n_parents].mark_indent = container.mark_indent; + ctx->containers[n_parents].contents_indent = container.contents_indent; + + n_brothers++; + goto redo; + } + } + + /* Check for indented code. + * Note indented code block cannot interrupt a paragraph. */ + if(line->indent >= ctx->code_indent_offset && + (pivot_line->type == MD_LINE_BLANK || pivot_line->type == MD_LINE_INDENTEDCODE)) + { + line->type = MD_LINE_INDENTEDCODE; + MD_ASSERT(line->indent >= ctx->code_indent_offset); + line->indent -= ctx->code_indent_offset; + line->data = 0; + goto done; + } + + /* Check for start of a new container block. */ + if(line->indent < ctx->code_indent_offset && + md_is_container_mark(ctx, line->indent, off, &off, &container)) + { + if(pivot_line->type == MD_LINE_TEXT && n_parents == ctx->n_containers && + (off >= ctx->size || ISNEWLINE(off))) + { + /* Noop. List mark followed by a blank line cannot interrupt a paragraph. */ + } else if(pivot_line->type == MD_LINE_TEXT && n_parents == ctx->n_containers && + (container.ch == _T('.') || container.ch == _T(')')) && container.start != 1) + { + /* Noop. Ordered list cannot interrupt a paragraph unless the start index is 1. */ + } else { + total_indent += container.contents_indent - container.mark_indent; + line->indent = md_line_indentation(ctx, total_indent, off, &off); + total_indent += line->indent; + + line->beg = off; + line->data = container.ch; + + /* Some of the following whitespace actually still belongs to the mark. */ + if(off >= ctx->size || ISNEWLINE(off)) { + container.contents_indent++; + } else if(line->indent <= ctx->code_indent_offset) { + container.contents_indent += line->indent; + line->indent = 0; + } else { + container.contents_indent += 1; + line->indent--; + } + + if(n_brothers + n_children == 0) + pivot_line = &md_dummy_blank_line; + + if(n_children == 0) + MD_CHECK(md_leave_child_containers(ctx, n_parents + n_brothers)); + + n_children++; + MD_CHECK(md_push_container(ctx, &container)); + goto redo; + } + } + + /* Check whether we are table continuation. */ + if(pivot_line->type == MD_LINE_TABLE && md_is_table_row(ctx, off, &off) && + n_parents == ctx->n_containers) + { + line->type = MD_LINE_TABLE; + goto done; + } + + /* Check for ATX header. */ + if(line->indent < ctx->code_indent_offset && CH(off) == _T('#')) { + unsigned level; + + if(md_is_atxheader_line(ctx, off, &line->beg, &off, &level)) { + line->type = MD_LINE_ATXHEADER; + line->data = level; + goto done; + } + } + + /* Check whether we are starting code fence. */ + if(CH(off) == _T('`') || CH(off) == _T('~')) { + if(md_is_opening_code_fence(ctx, off, &off)) { + line->type = MD_LINE_FENCEDCODE; + line->data = 1; + goto done; + } + } + + /* Check for start of raw HTML block. */ + if(CH(off) == _T('<') && !(ctx->parser.flags & MD_FLAG_NOHTMLBLOCKS)) + { + ctx->html_block_type = md_is_html_block_start_condition(ctx, off); + + /* HTML block type 7 cannot interrupt paragraph. */ + if(ctx->html_block_type == 7 && pivot_line->type == MD_LINE_TEXT) + ctx->html_block_type = 0; + + if(ctx->html_block_type > 0) { + /* The line itself also may immediately close the block. */ + if(md_is_html_block_end_condition(ctx, off, &off) == ctx->html_block_type) { + /* Make sure this is the last line of the block. */ + ctx->html_block_type = 0; + } + + line->type = MD_LINE_HTML; + goto done; + } + } + + /* Check for table underline. */ + if((ctx->parser.flags & MD_FLAG_TABLES) && pivot_line->type == MD_LINE_TEXT && + (CH(off) == _T('|') || CH(off) == _T('-') || CH(off) == _T(':')) && + n_parents == ctx->n_containers) + { + unsigned col_count; + + if(ctx->current_block != NULL && ctx->current_block->n_lines == 1 && + md_is_table_underline(ctx, off, &off, &col_count) && + md_is_table_row(ctx, pivot_line->beg, NULL)) + { + line->data = col_count; + line->type = MD_LINE_TABLEUNDERLINE; + goto done; + } + } + + /* By default, we are normal text line. */ + line->type = MD_LINE_TEXT; + if(pivot_line->type == MD_LINE_TEXT && n_brothers + n_children == 0) { + /* Lazy continuation. */ + n_parents = ctx->n_containers; + } + + /* Check for task mark. */ + if((ctx->parser.flags & MD_FLAG_TASKLISTS) && n_brothers + n_children > 0 && + ISANYOF_(ctx->containers[ctx->n_containers-1].ch, _T("-+*.)"))) + { + OFF tmp = off; + + while(tmp < ctx->size && tmp < off + 3 && ISBLANK(tmp)) + tmp++; + if(tmp + 2 < ctx->size && CH(tmp) == _T('[') && + ISANYOF(tmp+1, _T("xX ")) && CH(tmp+2) == _T(']') && + (tmp + 3 == ctx->size || ISBLANK(tmp+3) || ISNEWLINE(tmp+3))) + { + MD_CONTAINER* task_container = (n_children > 0 ? &ctx->containers[ctx->n_containers-1] : &container); + task_container->is_task = TRUE; + task_container->task_mark_off = tmp + 1; + off = tmp + 3; + while(ISWHITESPACE(off)) + off++; + line->beg = off; + } + } + +done: + /* Scan for end of the line. + * + * Note this is bottleneck of this function as we itereate over (almost) + * all line contents after some initial line indentation. To optimize, we + * try to eat multiple chars in every loop iteration. + * + * (Measured ~6% performance boost of md2html with this optimization for + * normal kind of input.) + */ + while(off + 4 < ctx->size && !ISNEWLINE(off+0) && !ISNEWLINE(off+1) + && !ISNEWLINE(off+2) && !ISNEWLINE(off+3)) + off += 4; + while(off < ctx->size && !ISNEWLINE(off)) + off++; + +done_on_eol: + /* Set end of the line. */ + line->end = off; + + /* But for ATX header, we should exclude the optional trailing mark. */ + if(line->type == MD_LINE_ATXHEADER) { + OFF tmp = line->end; + while(tmp > line->beg && CH(tmp-1) == _T(' ')) + tmp--; + while(tmp > line->beg && CH(tmp-1) == _T('#')) + tmp--; + if(tmp == line->beg || CH(tmp-1) == _T(' ') || (ctx->parser.flags & MD_FLAG_PERMISSIVEATXHEADERS)) + line->end = tmp; + } + + /* Trim trailing spaces. */ + if(line->type != MD_LINE_INDENTEDCODE && line->type != MD_LINE_FENCEDCODE) { + while(line->end > line->beg && CH(line->end-1) == _T(' ')) + line->end--; + } + + /* Eat also the new line. */ + if(off < ctx->size && CH(off) == _T('\r')) + off++; + if(off < ctx->size && CH(off) == _T('\n')) + off++; + + *p_end = off; + + /* If we belong to a list after seeing a blank line, the list is loose. */ + if(prev_line_has_list_loosening_effect && line->type != MD_LINE_BLANK && n_parents + n_brothers > 0) { + MD_CONTAINER* c = &ctx->containers[n_parents + n_brothers - 1]; + if(c->ch != _T('>')) { + MD_BLOCK* block = (MD_BLOCK*) (((char*)ctx->block_bytes) + c->block_byte_off); + block->flags |= MD_BLOCK_LOOSE_LIST; + } + } + + /* Leave any containers we are not part of anymore. */ + if(n_children == 0 && n_parents + n_brothers < ctx->n_containers) + MD_CHECK(md_leave_child_containers(ctx, n_parents + n_brothers)); + + /* Enter any container we found a mark for. */ + if(n_brothers > 0) { + MD_ASSERT(n_brothers == 1); + MD_CHECK(md_push_container_bytes(ctx, MD_BLOCK_LI, + ctx->containers[n_parents].task_mark_off, + (ctx->containers[n_parents].is_task ? CH(ctx->containers[n_parents].task_mark_off) : 0), + MD_BLOCK_CONTAINER_CLOSER)); + MD_CHECK(md_push_container_bytes(ctx, MD_BLOCK_LI, + container.task_mark_off, + (container.is_task ? CH(container.task_mark_off) : 0), + MD_BLOCK_CONTAINER_OPENER)); + ctx->containers[n_parents].is_task = container.is_task; + ctx->containers[n_parents].task_mark_off = container.task_mark_off; + } + + if(n_children > 0) + MD_CHECK(md_enter_child_containers(ctx, n_children, line->data)); + +abort: + return ret; +} + +static int +md_process_line(MD_CTX* ctx, const MD_LINE_ANALYSIS** p_pivot_line, const MD_LINE_ANALYSIS* line) +{ + const MD_LINE_ANALYSIS* pivot_line = *p_pivot_line; + int ret = 0; + + /* Blank line ends current leaf block. */ + if(line->type == MD_LINE_BLANK) { + MD_CHECK(md_end_current_block(ctx)); + *p_pivot_line = &md_dummy_blank_line; + return 0; + } + + /* Some line types form block on their own. */ + if(line->type == MD_LINE_HR || line->type == MD_LINE_ATXHEADER) { + MD_CHECK(md_end_current_block(ctx)); + + /* Add our single-line block. */ + MD_CHECK(md_start_new_block(ctx, line)); + MD_CHECK(md_add_line_into_current_block(ctx, line)); + MD_CHECK(md_end_current_block(ctx)); + *p_pivot_line = &md_dummy_blank_line; + return 0; + } + + /* MD_LINE_SETEXTUNDERLINE changes meaning of the current block and ends it. */ + if(line->type == MD_LINE_SETEXTUNDERLINE) { + MD_ASSERT(ctx->current_block != NULL); + ctx->current_block->type = MD_BLOCK_H; + ctx->current_block->data = line->data; + MD_CHECK(md_end_current_block(ctx)); + *p_pivot_line = &md_dummy_blank_line; + return 0; + } + + /* MD_LINE_TABLEUNDERLINE changes meaning of the current block. */ + if(line->type == MD_LINE_TABLEUNDERLINE) { + MD_ASSERT(ctx->current_block != NULL); + MD_ASSERT(ctx->current_block->n_lines == 1); + ctx->current_block->type = MD_BLOCK_TABLE; + ctx->current_block->data = line->data; + MD_ASSERT(pivot_line != &md_dummy_blank_line); + ((MD_LINE_ANALYSIS*)pivot_line)->type = MD_LINE_TABLE; + MD_CHECK(md_add_line_into_current_block(ctx, line)); + return 0; + } + + /* The current block also ends if the line has different type. */ + if(line->type != pivot_line->type) + MD_CHECK(md_end_current_block(ctx)); + + /* The current line may start a new block. */ + if(ctx->current_block == NULL) { + MD_CHECK(md_start_new_block(ctx, line)); + *p_pivot_line = line; + } + + /* In all other cases the line is just a continuation of the current block. */ + MD_CHECK(md_add_line_into_current_block(ctx, line)); + +abort: + return ret; +} + +static int +md_process_doc(MD_CTX *ctx) +{ + const MD_LINE_ANALYSIS* pivot_line = &md_dummy_blank_line; + MD_LINE_ANALYSIS line_buf[2]; + MD_LINE_ANALYSIS* line = &line_buf[0]; + OFF off = 0; + int ret = 0; + + MD_ENTER_BLOCK(MD_BLOCK_DOC, NULL); + + while(off < ctx->size) { + if(line == pivot_line) + line = (line == &line_buf[0] ? &line_buf[1] : &line_buf[0]); + + MD_CHECK(md_analyze_line(ctx, off, &off, pivot_line, line)); + MD_CHECK(md_process_line(ctx, &pivot_line, line)); + } + + md_end_current_block(ctx); + + MD_CHECK(md_build_ref_def_hashtable(ctx)); + + /* Process all blocks. */ + MD_CHECK(md_leave_child_containers(ctx, 0)); + MD_CHECK(md_process_all_blocks(ctx)); + + MD_LEAVE_BLOCK(MD_BLOCK_DOC, NULL); + +abort: + +#if 0 + /* Output some memory consumption statistics. */ + { + char buffer[256]; + sprintf(buffer, "Alloced %u bytes for block buffer.", + (unsigned)(ctx->alloc_block_bytes)); + MD_LOG(buffer); + + sprintf(buffer, "Alloced %u bytes for containers buffer.", + (unsigned)(ctx->alloc_containers * sizeof(MD_CONTAINER))); + MD_LOG(buffer); + + sprintf(buffer, "Alloced %u bytes for marks buffer.", + (unsigned)(ctx->alloc_marks * sizeof(MD_MARK))); + MD_LOG(buffer); + + sprintf(buffer, "Alloced %u bytes for aux. buffer.", + (unsigned)(ctx->alloc_buffer * sizeof(MD_CHAR))); + MD_LOG(buffer); + } +#endif + + return ret; +} + + +/******************** + *** Public API *** + ********************/ + +int +md_parse(const MD_CHAR* text, MD_SIZE size, const MD_PARSER* parser, void* userdata) +{ + MD_CTX ctx; + int i; + int ret; + + if(parser->abi_version != 0) { + if(parser->debug_log != NULL) + parser->debug_log("Unsupported abi_version.", userdata); + return -1; + } + + /* Setup context structure. */ + memset(&ctx, 0, sizeof(MD_CTX)); + ctx.text = text; + ctx.size = size; + memcpy(&ctx.parser, parser, sizeof(MD_PARSER)); + ctx.userdata = userdata; + ctx.code_indent_offset = (ctx.parser.flags & MD_FLAG_NOINDENTEDCODEBLOCKS) ? (OFF)(-1) : 4; + md_build_mark_char_map(&ctx); + + /* Reset all unresolved opener mark chains. */ + for(i = 0; i < SIZEOF_ARRAY(ctx.mark_chains); i++) { + ctx.mark_chains[i].head = -1; + ctx.mark_chains[i].tail = -1; + } + ctx.unresolved_link_head = -1; + ctx.unresolved_link_tail = -1; + + /* All the work. */ + ret = md_process_doc(&ctx); + + /* Clean-up. */ + md_free_ref_defs(&ctx); + md_free_ref_def_hashtable(&ctx); + free(ctx.buffer); + free(ctx.marks); + free(ctx.block_bytes); + free(ctx.containers); + + return ret; +} diff --git a/src/3rdparty/md4c/md4c.h b/src/3rdparty/md4c/md4c.h new file mode 100644 index 0000000000..10cba67e95 --- /dev/null +++ b/src/3rdparty/md4c/md4c.h @@ -0,0 +1,359 @@ +/* + * MD4C: Markdown parser for C + * (http://github.com/mity/md4c) + * + * Copyright (c) 2016-2019 Martin Mitas + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef MD4C_MARKDOWN_H +#define MD4C_MARKDOWN_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Magic to support UTF-16. */ +#if defined MD4C_USE_UTF16 + #ifdef _WIN32 + #include + typedef WCHAR MD_CHAR; + #else + #error MD4C_USE_UTF16 is only supported on Windows. + #endif +#else + typedef char MD_CHAR; +#endif + +typedef unsigned MD_SIZE; +typedef unsigned MD_OFFSET; + + +/* Block represents a part of document hierarchy structure like a paragraph + * or list item. + */ +typedef enum MD_BLOCKTYPE { + /* ... */ + MD_BLOCK_DOC = 0, + + /*
    ...
    */ + MD_BLOCK_QUOTE, + + /*
      ...
    + * Detail: Structure MD_BLOCK_UL_DETAIL. */ + MD_BLOCK_UL, + + /*
      ...
    + * Detail: Structure MD_BLOCK_OL_DETAIL. */ + MD_BLOCK_OL, + + /*
  1. ...
  2. + * Detail: Structure MD_BLOCK_LI_DETAIL. */ + MD_BLOCK_LI, + + /*
    */ + MD_BLOCK_HR, + + /*

    ...

    (for levels up to 6) + * Detail: Structure MD_BLOCK_H_DETAIL. */ + MD_BLOCK_H, + + /*
    ...
    + * Note the text lines within code blocks are terminated with '\n' + * instead of explicit MD_TEXT_BR. */ + MD_BLOCK_CODE, + + /* Raw HTML block. This itself does not correspond to any particular HTML + * tag. The contents of it _is_ raw HTML source intended to be put + * in verbatim form to the HTML output. */ + MD_BLOCK_HTML, + + /*

    ...

    */ + MD_BLOCK_P, + + /* ...
    and its contents. + * Detail: Structure MD_BLOCK_TD_DETAIL (used with MD_BLOCK_TH and MD_BLOCK_TD) + * Note all of these are used only if extension MD_FLAG_TABLES is enabled. */ + MD_BLOCK_TABLE, + MD_BLOCK_THEAD, + MD_BLOCK_TBODY, + MD_BLOCK_TR, + MD_BLOCK_TH, + MD_BLOCK_TD +} MD_BLOCKTYPE; + +/* Span represents an in-line piece of a document which should be rendered with + * the same font, color and other attributes. A sequence of spans forms a block + * like paragraph or list item. */ +typedef enum MD_SPANTYPE { + /* ... */ + MD_SPAN_EM, + + /* ... */ + MD_SPAN_STRONG, + + /*
    ... + * Detail: Structure MD_SPAN_A_DETAIL. */ + MD_SPAN_A, + + /* ... + * Detail: Structure MD_SPAN_IMG_DETAIL. + * Note: Image text can contain nested spans and even nested images. + * If rendered into ALT attribute of HTML tag, it's responsibility + * of the renderer to deal with it. + */ + MD_SPAN_IMG, + + /* ... */ + MD_SPAN_CODE, + + /* ... + * Note: Recognized only when MD_FLAG_STRIKETHROUGH is enabled. + */ + MD_SPAN_DEL +} MD_SPANTYPE; + +/* Text is the actual textual contents of span. */ +typedef enum MD_TEXTTYPE { + /* Normal text. */ + MD_TEXT_NORMAL = 0, + + /* NULL character. CommonMark requires replacing NULL character with + * the replacement char U+FFFD, so this allows caller to do that easily. */ + MD_TEXT_NULLCHAR, + + /* Line breaks. + * Note these are not sent from blocks with verbatim output (MD_BLOCK_CODE + * or MD_BLOCK_HTML). In such cases, '\n' is part of the text itself. */ + MD_TEXT_BR, /*
    (hard break) */ + MD_TEXT_SOFTBR, /* '\n' in source text where it is not semantically meaningful (soft break) */ + + /* Entity. + * (a) Named entity, e.g.   + * (Note MD4C does not have a list of known entities. + * Anything matching the regexp /&[A-Za-z][A-Za-z0-9]{1,47};/ is + * treated as a named entity.) + * (b) Numerical entity, e.g. Ӓ + * (c) Hexadecimal entity, e.g. ካ + * + * As MD4C is mostly encoding agnostic, application gets the verbatim + * entity text into the MD_RENDERER::text_callback(). */ + MD_TEXT_ENTITY, + + /* Text in a code block (inside MD_BLOCK_CODE) or inlined code (`code`). + * If it is inside MD_BLOCK_CODE, it includes spaces for indentation and + * '\n' for new lines. MD_TEXT_BR and MD_TEXT_SOFTBR are not sent for this + * kind of text. */ + MD_TEXT_CODE, + + /* Text is a raw HTML. If it is contents of a raw HTML block (i.e. not + * an inline raw HTML), then MD_TEXT_BR and MD_TEXT_SOFTBR are not used. + * The text contains verbatim '\n' for the new lines. */ + MD_TEXT_HTML +} MD_TEXTTYPE; + + +/* Alignment enumeration. */ +typedef enum MD_ALIGN { + MD_ALIGN_DEFAULT = 0, /* When unspecified. */ + MD_ALIGN_LEFT, + MD_ALIGN_CENTER, + MD_ALIGN_RIGHT +} MD_ALIGN; + + +/* String attribute. + * + * This wraps strings which are outside of a normal text flow and which are + * propagated within various detailed structures, but which still may contain + * string portions of different types like e.g. entities. + * + * So, for example, lets consider an image has a title attribute string + * set to "foo " bar". (Note the string size is 14.) + * + * Then the attribute MD_SPAN_IMG_DETAIL::title shall provide the following: + * -- [0]: "foo " (substr_types[0] == MD_TEXT_NORMAL; substr_offsets[0] == 0) + * -- [1]: """ (substr_types[1] == MD_TEXT_ENTITY; substr_offsets[1] == 4) + * -- [2]: " bar" (substr_types[2] == MD_TEXT_NORMAL; substr_offsets[2] == 10) + * -- [3]: (n/a) (n/a ; substr_offsets[3] == 14) + * + * Note that these conditions are guaranteed: + * -- substr_offsets[0] == 0 + * -- substr_offsets[LAST+1] == size + * -- Only MD_TEXT_NORMAL, MD_TEXT_ENTITY, MD_TEXT_NULLCHAR substrings can appear. + */ +typedef struct MD_ATTRIBUTE { + const MD_CHAR* text; + MD_SIZE size; + const MD_TEXTTYPE* substr_types; + const MD_OFFSET* substr_offsets; +} MD_ATTRIBUTE; + + +/* Detailed info for MD_BLOCK_UL. */ +typedef struct MD_BLOCK_UL_DETAIL { + int is_tight; /* Non-zero if tight list, zero if loose. */ + MD_CHAR mark; /* Item bullet character in MarkDown source of the list, e.g. '-', '+', '*'. */ +} MD_BLOCK_UL_DETAIL; + +/* Detailed info for MD_BLOCK_OL. */ +typedef struct MD_BLOCK_OL_DETAIL { + unsigned start; /* Start index of the ordered list. */ + int is_tight; /* Non-zero if tight list, zero if loose. */ + MD_CHAR mark_delimiter; /* Character delimiting the item marks in MarkDown source, e.g. '.' or ')' */ +} MD_BLOCK_OL_DETAIL; + +/* Detailed info for MD_BLOCK_LI. */ +typedef struct MD_BLOCK_LI_DETAIL { + int is_task; /* Can be non-zero only with MD_FLAG_TASKLISTS */ + MD_CHAR task_mark; /* If is_task, then one of 'x', 'X' or ' '. Undefined otherwise. */ + MD_OFFSET task_mark_offset; /* If is_task, then offset in the input of the char between '[' and ']'. */ +} MD_BLOCK_LI_DETAIL; + +/* Detailed info for MD_BLOCK_H. */ +typedef struct MD_BLOCK_H_DETAIL { + unsigned level; /* Header level (1 - 6) */ +} MD_BLOCK_H_DETAIL; + +/* Detailed info for MD_BLOCK_CODE. */ +typedef struct MD_BLOCK_CODE_DETAIL { + MD_ATTRIBUTE info; + MD_ATTRIBUTE lang; +} MD_BLOCK_CODE_DETAIL; + +/* Detailed info for MD_BLOCK_TH and MD_BLOCK_TD. */ +typedef struct MD_BLOCK_TD_DETAIL { + MD_ALIGN align; +} MD_BLOCK_TD_DETAIL; + +/* Detailed info for MD_SPAN_A. */ +typedef struct MD_SPAN_A_DETAIL { + MD_ATTRIBUTE href; + MD_ATTRIBUTE title; +} MD_SPAN_A_DETAIL; + +/* Detailed info for MD_SPAN_IMG. */ +typedef struct MD_SPAN_IMG_DETAIL { + MD_ATTRIBUTE src; + MD_ATTRIBUTE title; +} MD_SPAN_IMG_DETAIL; + + +/* Flags specifying extensions/deviations from CommonMark specification. + * + * By default (when MD_RENDERER::flags == 0), we follow CommonMark specification. + * The following flags may allow some extensions or deviations from it. + */ +#define MD_FLAG_COLLAPSEWHITESPACE 0x0001 /* In MD_TEXT_NORMAL, collapse non-trivial whitespace into single ' ' */ +#define MD_FLAG_PERMISSIVEATXHEADERS 0x0002 /* Do not require space in ATX headers ( ###header ) */ +#define MD_FLAG_PERMISSIVEURLAUTOLINKS 0x0004 /* Recognize URLs as autolinks even without '<', '>' */ +#define MD_FLAG_PERMISSIVEEMAILAUTOLINKS 0x0008 /* Recognize e-mails as autolinks even without '<', '>' and 'mailto:' */ +#define MD_FLAG_NOINDENTEDCODEBLOCKS 0x0010 /* Disable indented code blocks. (Only fenced code works.) */ +#define MD_FLAG_NOHTMLBLOCKS 0x0020 /* Disable raw HTML blocks. */ +#define MD_FLAG_NOHTMLSPANS 0x0040 /* Disable raw HTML (inline). */ +#define MD_FLAG_TABLES 0x0100 /* Enable tables extension. */ +#define MD_FLAG_STRIKETHROUGH 0x0200 /* Enable strikethrough extension. */ +#define MD_FLAG_PERMISSIVEWWWAUTOLINKS 0x0400 /* Enable WWW autolinks (even without any scheme prefix, if they begin with 'www.') */ +#define MD_FLAG_TASKLISTS 0x0800 /* Enable task list extension. */ + +#define MD_FLAG_PERMISSIVEAUTOLINKS (MD_FLAG_PERMISSIVEEMAILAUTOLINKS | MD_FLAG_PERMISSIVEURLAUTOLINKS | MD_FLAG_PERMISSIVEWWWAUTOLINKS) +#define MD_FLAG_NOHTML (MD_FLAG_NOHTMLBLOCKS | MD_FLAG_NOHTMLSPANS) + +/* Convenient sets of flags corresponding to well-known Markdown dialects. + * + * Note we may only support subset of features of the referred dialect. + * The constant just enables those extensions which bring us as close as + * possible given what features we implement. + * + * ABI compatibility note: Meaning of these can change in time as new + * extensions, bringing the dialect closer to the original, are implemented. + */ +#define MD_DIALECT_COMMONMARK 0 +#define MD_DIALECT_GITHUB (MD_FLAG_PERMISSIVEAUTOLINKS | MD_FLAG_TABLES | MD_FLAG_STRIKETHROUGH | MD_FLAG_TASKLISTS) + +/* Renderer structure. + */ +typedef struct MD_PARSER { + /* Reserved. Set to zero. + */ + unsigned abi_version; + + /* Dialect options. Bitmask of MD_FLAG_xxxx values. + */ + unsigned flags; + + /* Caller-provided rendering callbacks. + * + * For some block/span types, more detailed information is provided in a + * type-specific structure pointed by the argument 'detail'. + * + * The last argument of all callbacks, 'userdata', is just propagated from + * md_parse() and is available for any use by the application. + * + * Note any strings provided to the callbacks as their arguments or as + * members of any detail structure are generally not zero-terminated. + * Application has take the respective size information into account. + * + * Callbacks may abort further parsing of the document by returning non-zero. + */ + int (*enter_block)(MD_BLOCKTYPE /*type*/, void* /*detail*/, void* /*userdata*/); + int (*leave_block)(MD_BLOCKTYPE /*type*/, void* /*detail*/, void* /*userdata*/); + + int (*enter_span)(MD_SPANTYPE /*type*/, void* /*detail*/, void* /*userdata*/); + int (*leave_span)(MD_SPANTYPE /*type*/, void* /*detail*/, void* /*userdata*/); + + int (*text)(MD_TEXTTYPE /*type*/, const MD_CHAR* /*text*/, MD_SIZE /*size*/, void* /*userdata*/); + + /* Debug callback. Optional (may be NULL). + * + * If provided and something goes wrong, this function gets called. + * This is intended for debugging and problem diagnosis for developers; + * it is not intended to provide any errors suitable for displaying to an + * end user. + */ + void (*debug_log)(const char* /*msg*/, void* /*userdata*/); + + /* Reserved. Set to NULL. + */ + void (*syntax)(void); +} MD_PARSER; + + +/* For backward compatibility. Do not use in new code. */ +typedef MD_PARSER MD_RENDERER; + + +/* Parse the Markdown document stored in the string 'text' of size 'size'. + * The renderer provides callbacks to be called during the parsing so the + * caller can render the document on the screen or convert the Markdown + * to another format. + * + * Zero is returned on success. If a runtime error occurs (e.g. a memory + * fails), -1 is returned. If the processing is aborted due any callback + * returning non-zero, md_parse() the return value of the callback is returned. + */ +int md_parse(const MD_CHAR* text, MD_SIZE size, const MD_PARSER* parser, void* userdata); + + +#ifdef __cplusplus + } /* extern "C" { */ +#endif + +#endif /* MD4C_MARKDOWN_H */ diff --git a/src/3rdparty/md4c/qt_attribution.json b/src/3rdparty/md4c/qt_attribution.json new file mode 100644 index 0000000000..9180ed69b5 --- /dev/null +++ b/src/3rdparty/md4c/qt_attribution.json @@ -0,0 +1,15 @@ +{ + "Id": "md4c", + "Name": "MD4C", + "QDocModule": "qtgui", + "QtUsage": "Optionally used in QTextDocument if configured with textmarkdownreader.", + + "Description": "A CommonMark-compliant Markdown parser.", + "Homepage": "https://github.com/mity/md4c", + "License": "MIT License", + "LicenseId": "MIT", + "LicenseFile": "LICENSE.md", + "Version": "0.3.0", + "DownloadLocation": "https://github.com/mity/md4c/releases/tag/release-0.3.0-rc", + "Copyright": "Copyright © 2016-2019 Martin Mitáš" +} From 860bf13dbd2e9ad0a87b75defcab2cc3c9c771f3 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 17 Apr 2019 14:29:57 +0200 Subject: [PATCH 192/292] Fix compilation errors and warnings on INTEGRITY in md4c 3rdparty Change-Id: Ic27801f790b533f0a16099501fbe8a3ffe941d02 Reviewed-by: Shawn Rutledge --- src/3rdparty/md4c/md4c.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/3rdparty/md4c/md4c.c b/src/3rdparty/md4c/md4c.c index 4c0ad5c0fc..13c7bd3433 100644 --- a/src/3rdparty/md4c/md4c.c +++ b/src/3rdparty/md4c/md4c.c @@ -25,6 +25,7 @@ #include "md4c.h" +#include #include #include #include @@ -3375,7 +3376,7 @@ md_resolve_links(MD_CTX* ctx, const MD_LINE* lines, int n_lines) } else { if(closer->end < ctx->size && CH(closer->end) == _T('(')) { /* Might be inline link. */ - OFF inline_link_end = -1; + OFF inline_link_end = UINT_MAX; is_link = md_is_inline_link_spec(ctx, lines, n_lines, closer->end, &inline_link_end, &attr); if(is_link < 0) @@ -4152,11 +4153,14 @@ static int md_process_table_row(MD_CTX* ctx, MD_BLOCKTYPE cell_type, OFF beg, OFF end, const MD_ALIGN* align, int col_count) { - MD_LINE line = { beg, end }; + MD_LINE line; OFF* pipe_offs = NULL; int i, j, n; int ret = 0; + line.beg = beg; + line.end = end; + /* Break the line into table cells by identifying pipe characters who * form the cell boundary. */ MD_CHECK(md_analyze_inlines(ctx, &line, 1, TRUE)); @@ -4243,10 +4247,13 @@ abort: static int md_is_table_row(MD_CTX* ctx, OFF beg, OFF* p_end) { - MD_LINE line = { beg, beg }; + MD_LINE line; int i; int ret = FALSE; + line.beg = beg; + line.end = beg; + /* Find end of line. */ while(line.end < ctx->size && !ISNEWLINE(line.end)) line.end++; @@ -5186,6 +5193,7 @@ md_is_html_block_end_condition(MD_CTX* ctx, OFF beg, OFF* p_end) default: MD_UNREACHABLE(); } + return FALSE; } From 65314b6ce88cdbb28a22be0cab9856ec9bc9604b Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 18 Dec 2017 08:55:18 +0100 Subject: [PATCH 193/292] Add QTextMarkdownImporter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This provides the ability to read from a Markdown string or file into a QTextDocument, such that the formatting will be recognized and can be rendered. - Add QTextDocument::setMarkdown(QString) - Add QTextEdit::setMarkdown(QString) - Add TextFormat::MarkdownText - QWidgetTextControl::setContent() calls QTextDocument::setMarkdown() if that's the format Fixes: QTBUG-72349 Change-Id: Ief2ad71bf840666c64145d58e9ca71d05fad5659 Reviewed-by: Lisandro Damián Nicanor Pérez Meyer Reviewed-by: Gatis Paeglis --- src/corelib/global/qnamespace.h | 3 +- src/gui/configure.json | 34 ++ src/gui/text/qtextdocument.cpp | 30 +- src/gui/text/qtextdocument.h | 15 +- src/gui/text/qtextformat.h | 12 + src/gui/text/qtextmarkdownimporter.cpp | 435 +++++++++++++++++++ src/gui/text/qtextmarkdownimporter_p.h | 127 ++++++ src/gui/text/text.pri | 12 + src/widgets/widgets/qtextedit.cpp | 9 +- src/widgets/widgets/qtextedit.h | 5 +- src/widgets/widgets/qwidgettextcontrol.cpp | 15 +- src/widgets/widgets/qwidgettextcontrol_p.h | 5 +- src/widgets/widgets/qwidgettextcontrol_p_p.h | 2 +- 13 files changed, 696 insertions(+), 8 deletions(-) create mode 100644 src/gui/text/qtextmarkdownimporter.cpp create mode 100644 src/gui/text/qtextmarkdownimporter_p.h diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 90dd36113f..06aef81afc 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -1198,7 +1198,8 @@ public: enum TextFormat { PlainText, RichText, - AutoText + AutoText, + MarkdownText }; enum AspectRatioMode { diff --git a/src/gui/configure.json b/src/gui/configure.json index 7a1796041e..a4ea4375d1 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -28,6 +28,7 @@ "lgmon": "boolean", "libinput": "boolean", "libjpeg": { "type": "enum", "values": [ "no", "qt", "system" ] }, + "libmd4c": { "type": "enum", "values": [ "no", "qt", "system" ] }, "libpng": { "type": "enum", "values": [ "no", "qt", "system" ] }, "linuxfb": "boolean", "mtdev": "boolean", @@ -376,6 +377,17 @@ "-ljpeg" ] }, + "libmd4c": { + "label": "libmd4c", + "test": { + "main": "md_parse(\"hello\", 5, nullptr, nullptr);" + }, + "headers": "md4c.h", + "sources": [ + { "type": "pkgConfig", "args": "md4c" }, + { "libs": "-lmd4c" } + ] + }, "libpng": { "label": "libpng", "test": { @@ -1583,6 +1595,22 @@ "section": "Kernel", "output": [ "publicFeature", "feature" ] }, + "textmarkdownreader": { + "label": "MarkdownReader", + "disable": "input.libmd4c == 'no'", + "enable": "input.libmd4c == 'system' || input.libmd4c == 'qt' || input.libmd4c == 'yes'", + "purpose": "Provides a Markdown (CommonMark and GitHub) reader", + "section": "Kernel", + "output": [ "publicFeature" ] + }, + "system-textmarkdownreader": { + "label": " Using system libmd4c", + "disable": "input.libmd4c == 'qt'", + "enable": "input.libmd4c == 'system'", + "section": "Kernel", + "condition": "libs.libmd4c", + "output": [ "publicFeature" ] + }, "textodfwriter": { "label": "OdfWriter", "purpose": "Provides an ODF writer.", @@ -1861,6 +1889,12 @@ QMAKE_LIBDIR_OPENGL[_ES2] and QMAKE_LIBS_OPENGL[_ES2] in the mkspec for your pla "gif", "ico", "jpeg", "system-jpeg", "png", "system-png" ] }, + { + "section": "Text formats", + "entries": [ + "texthtmlparser", "cssparser", "textodfwriter", "textmarkdownreader", "system-textmarkdownreader" + ] + }, "egl", "openvg", { diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index fd3473b32e..87c8f1ba8a 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -70,6 +70,9 @@ #include #include "qpagedpaintdevice.h" #include "private/qpagedpaintdevice_p.h" +#if QT_CONFIG(textmarkdownreader) +#include +#endif #include @@ -3285,6 +3288,31 @@ QString QTextDocument::toHtml(const QByteArray &encoding) const } #endif // QT_NO_TEXTHTMLPARSER +/*! + Replaces the entire contents of the document with the given + Markdown-formatted text in the \a markdown string, with the given + \a features supported. By default, all supported GitHub-style + Markdown features are included; pass \c MarkdownDialectCommonMark + for a more basic parse. + + The Markdown formatting is respected as much as possible; for example, + "*bold* text" will produce text where the first word has a font weight that + gives it an emphasized appearance. + + Parsing of HTML included in the \a markdown string is handled in the same + way as in \l setHtml; however, Markdown formatting inside HTML blocks is + not supported. The \c MarkdownNoHTML feature flag can be set to disable + HTML parsing. + + The undo/redo history is reset when this function is called. +*/ +#if QT_CONFIG(textmarkdownreader) +void QTextDocument::setMarkdown(const QString &markdown, QTextDocument::MarkdownFeatures features) +{ + QTextMarkdownImporter(static_cast(int(features))).import(this, markdown); +} +#endif + /*! Returns a vector of text formats for all the formats used in the document. */ diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h index c9b22e053b..ade67999ad 100644 --- a/src/gui/text/qtextdocument.h +++ b/src/gui/text/qtextdocument.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -151,6 +151,19 @@ public: void setHtml(const QString &html); #endif +#if QT_CONFIG(textmarkdownreader) + // Must be in sync with QTextMarkdownImporter::Features, should be in sync with #define MD_FLAG_* in md4c + enum MarkdownFeature { + MarkdownNoHTML = 0x0020 | 0x0040, + MarkdownDialectCommonMark = 0, + MarkdownDialectGitHub = 0x0004 | 0x0008 | 0x0400 | 0x0100 | 0x0200 | 0x0800 + }; + Q_DECLARE_FLAGS(MarkdownFeatures, MarkdownFeature) + Q_FLAG(MarkdownFeatures) + + void setMarkdown(const QString &markdown, MarkdownFeatures features = MarkdownDialectGitHub); +#endif + QString toRawText() const; QString toPlainText() const; void setPlainText(const QString &text); diff --git a/src/gui/text/qtextformat.h b/src/gui/text/qtextformat.h index 80d8e82694..1eb52a379c 100644 --- a/src/gui/text/qtextformat.h +++ b/src/gui/text/qtextformat.h @@ -176,6 +176,7 @@ public: BlockNonBreakableLines = 0x1050, BlockTrailingHorizontalRulerWidth = 0x1060, HeadingLevel = 0x1070, + BlockMarker = 0x1080, // character properties FirstFontProperty = 0x1FE0, @@ -605,6 +606,12 @@ public: LineDistanceHeight = 4 }; + enum MarkerType { + NoMarker = 0, + Unchecked = 1, + Checked = 2 + }; + QTextBlockFormat(); bool isValid() const { return isBlockFormat(); } @@ -668,6 +675,11 @@ public: void setTabPositions(const QList &tabs); QList tabPositions() const; + inline void setMarker(MarkerType marker) + { setProperty(BlockMarker, int(marker)); } + inline MarkerType marker() const + { return MarkerType(intProperty(BlockMarker)); } + protected: explicit QTextBlockFormat(const QTextFormat &fmt); friend class QTextFormat; diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp new file mode 100644 index 0000000000..6c053ac81a --- /dev/null +++ b/src/gui/text/qtextmarkdownimporter.cpp @@ -0,0 +1,435 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qtextmarkdownimporter_p.h" +#include "qtextdocumentfragment_p.h" +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +Q_LOGGING_CATEGORY(lcMD, "qt.text.markdown") + +// -------------------------------------------------------- +// MD4C callback function wrappers + +static int CbEnterBlock(MD_BLOCKTYPE type, void *detail, void *userdata) +{ + QTextMarkdownImporter *mdi = static_cast(userdata); + return mdi->cbEnterBlock(type, detail); +} + +static int CbLeaveBlock(MD_BLOCKTYPE type, void *detail, void *userdata) +{ + QTextMarkdownImporter *mdi = static_cast(userdata); + return mdi->cbLeaveBlock(type, detail); +} + +static int CbEnterSpan(MD_SPANTYPE type, void *detail, void *userdata) +{ + QTextMarkdownImporter *mdi = static_cast(userdata); + return mdi->cbEnterSpan(type, detail); +} + +static int CbLeaveSpan(MD_SPANTYPE type, void *detail, void *userdata) +{ + QTextMarkdownImporter *mdi = static_cast(userdata); + return mdi->cbLeaveSpan(type, detail); +} + +static int CbText(MD_TEXTTYPE type, const MD_CHAR *text, MD_SIZE size, void *userdata) +{ + QTextMarkdownImporter *mdi = static_cast(userdata); + return mdi->cbText(type, text, size); +} + +static void CbDebugLog(const char *msg, void *userdata) +{ + Q_UNUSED(userdata) + qCDebug(lcMD) << msg; +} + +// MD4C callback function wrappers +// -------------------------------------------------------- + +static Qt::Alignment MdAlignment(MD_ALIGN a, Qt::Alignment defaultAlignment = Qt::AlignLeft | Qt::AlignVCenter) +{ + switch (a) { + case MD_ALIGN_LEFT: + return Qt::AlignLeft | Qt::AlignVCenter; + case MD_ALIGN_CENTER: + return Qt::AlignHCenter | Qt::AlignVCenter; + case MD_ALIGN_RIGHT: + return Qt::AlignRight | Qt::AlignVCenter; + default: // including MD_ALIGN_DEFAULT + return defaultAlignment; + } +} + +QTextMarkdownImporter::QTextMarkdownImporter(QTextMarkdownImporter::Features features) + : m_monoFont(QFontDatabase::systemFont(QFontDatabase::FixedFont)) + , m_features(features) +{ +} + +void QTextMarkdownImporter::import(QTextDocument *doc, const QString &markdown) +{ + MD_PARSER callbacks = { + 0, // abi_version + m_features, + &CbEnterBlock, + &CbLeaveBlock, + &CbEnterSpan, + &CbLeaveSpan, + &CbText, + &CbDebugLog, + nullptr // syntax + }; + m_doc = doc; + m_cursor = new QTextCursor(doc); + doc->clear(); + qCDebug(lcMD) << "default font" << doc->defaultFont() << "mono font" << m_monoFont; + QByteArray md = markdown.toUtf8(); + md_parse(md.constData(), md.size(), &callbacks, this); + delete m_cursor; + m_cursor = nullptr; +} + +int QTextMarkdownImporter::cbEnterBlock(MD_BLOCKTYPE type, void *det) +{ + m_blockType = type; + switch (type) { + case MD_BLOCK_P: { + QTextBlockFormat blockFmt; + int margin = m_doc->defaultFont().pointSize() / 2; + blockFmt.setTopMargin(margin); + blockFmt.setBottomMargin(margin); + m_cursor->insertBlock(blockFmt, QTextCharFormat()); + } break; + case MD_BLOCK_CODE: { + QTextBlockFormat blockFmt; + QTextCharFormat charFmt; + charFmt.setFont(m_monoFont); + m_cursor->insertBlock(blockFmt, charFmt); + } break; + case MD_BLOCK_H: { + MD_BLOCK_H_DETAIL *detail = static_cast(det); + QTextBlockFormat blockFmt; + QTextCharFormat charFmt; + int sizeAdjustment = 4 - detail->level; // H1 to H6: +3 to -2 + charFmt.setProperty(QTextFormat::FontSizeAdjustment, sizeAdjustment); + charFmt.setFontWeight(QFont::Bold); + blockFmt.setHeadingLevel(detail->level); + m_cursor->insertBlock(blockFmt, charFmt); + } break; + case MD_BLOCK_LI: { + MD_BLOCK_LI_DETAIL *detail = static_cast(det); + QTextBlockFormat bfmt = m_cursor->blockFormat(); + bfmt.setMarker(detail->is_task ? + (detail->task_mark == ' ' ? QTextBlockFormat::Unchecked : QTextBlockFormat::Checked) : + QTextBlockFormat::NoMarker); + if (!m_emptyList) { + m_cursor->insertBlock(bfmt, QTextCharFormat()); + m_listStack.top()->add(m_cursor->block()); + } + m_cursor->setBlockFormat(bfmt); + m_emptyList = false; // Avoid insertBlock for the first item (because insertList already did that) + } break; + case MD_BLOCK_UL: { + MD_BLOCK_UL_DETAIL *detail = static_cast(det); + QTextListFormat fmt; + fmt.setIndent(m_listStack.count() + 1); + switch (detail->mark) { + case '*': + fmt.setStyle(QTextListFormat::ListCircle); + break; + case '+': + fmt.setStyle(QTextListFormat::ListSquare); + break; + default: // including '-' + fmt.setStyle(QTextListFormat::ListDisc); + break; + } + m_listStack.push(m_cursor->insertList(fmt)); + m_emptyList = true; + } break; + case MD_BLOCK_OL: { + MD_BLOCK_OL_DETAIL *detail = static_cast(det); + QTextListFormat fmt; + fmt.setIndent(m_listStack.count() + 1); + fmt.setNumberSuffix(QChar::fromLatin1(detail->mark_delimiter)); + fmt.setStyle(QTextListFormat::ListDecimal); + m_listStack.push(m_cursor->insertList(fmt)); + m_emptyList = true; + } break; + case MD_BLOCK_TD: { + MD_BLOCK_TD_DETAIL *detail = static_cast(det); + ++m_tableCol; + // absolute movement (and storage of m_tableCol) shouldn't be necessary, but + // movePosition(QTextCursor::NextCell) doesn't work + QTextTableCell cell = m_currentTable->cellAt(m_tableRowCount - 1, m_tableCol); + if (!cell.isValid()) { + qWarning("malformed table in Markdown input"); + return 1; + } + *m_cursor = cell.firstCursorPosition(); + QTextBlockFormat blockFmt = m_cursor->blockFormat(); + blockFmt.setAlignment(MdAlignment(detail->align)); + m_cursor->setBlockFormat(blockFmt); + qCDebug(lcMD) << "TD; align" << detail->align << MdAlignment(detail->align) << "col" << m_tableCol; + } break; + case MD_BLOCK_TH: { + ++m_tableColumnCount; + ++m_tableCol; + if (m_currentTable->columns() < m_tableColumnCount) + m_currentTable->appendColumns(1); + auto cell = m_currentTable->cellAt(m_tableRowCount - 1, m_tableCol); + if (!cell.isValid()) { + qWarning("malformed table in Markdown input"); + return 1; + } + auto fmt = cell.format(); + fmt.setFontWeight(QFont::Bold); + cell.setFormat(fmt); + } break; + case MD_BLOCK_TR: { + ++m_tableRowCount; + m_nonEmptyTableCells.clear(); + if (m_currentTable->rows() < m_tableRowCount) + m_currentTable->appendRows(1); + m_tableCol = -1; + qCDebug(lcMD) << "TR" << m_currentTable->rows(); + } break; + case MD_BLOCK_TABLE: + m_tableColumnCount = 0; + m_tableRowCount = 0; + m_currentTable = m_cursor->insertTable(1, 1); // we don't know the dimensions yet + break; + case MD_BLOCK_HR: { + QTextBlockFormat blockFmt = m_cursor->blockFormat(); + blockFmt.setProperty(QTextFormat::BlockTrailingHorizontalRulerWidth, 1); + m_cursor->insertBlock(blockFmt, QTextCharFormat()); + } break; + default: + break; // nothing to do for now + } + return 0; // no error +} + +int QTextMarkdownImporter::cbLeaveBlock(MD_BLOCKTYPE type, void *detail) +{ + Q_UNUSED(detail) + switch (type) { + case MD_BLOCK_UL: + case MD_BLOCK_OL: + m_listStack.pop(); + break; + case MD_BLOCK_TR: { + // https://github.com/mity/md4c/issues/29 + // MD4C doesn't tell us explicitly which cells are merged, so merge empty cells + // with previous non-empty ones + int mergeEnd = -1; + int mergeBegin = -1; + for (int col = m_tableCol; col >= 0; --col) { + if (m_nonEmptyTableCells.contains(col)) { + if (mergeEnd >= 0 && mergeBegin >= 0) { + qCDebug(lcMD) << "merging cells" << mergeBegin << "to" << mergeEnd << "inclusive, on row" << m_currentTable->rows() - 1; + m_currentTable->mergeCells(m_currentTable->rows() - 1, mergeBegin - 1, 1, mergeEnd - mergeBegin + 2); + } + mergeEnd = -1; + mergeBegin = -1; + } else { + if (mergeEnd < 0) + mergeEnd = col; + else + mergeBegin = col; + } + } + } break; + case MD_BLOCK_QUOTE: { + QTextBlockFormat blockFmt = m_cursor->blockFormat(); + blockFmt.setIndent(1); + m_cursor->setBlockFormat(blockFmt); + } break; + case MD_BLOCK_TABLE: + qCDebug(lcMD) << "table ended with" << m_currentTable->columns() << "cols and" << m_currentTable->rows() << "rows"; + m_currentTable = nullptr; + m_cursor->movePosition(QTextCursor::End); + break; + default: + break; + } + return 0; // no error +} + +int QTextMarkdownImporter::cbEnterSpan(MD_SPANTYPE type, void *det) +{ + QTextCharFormat charFmt; + switch (type) { + case MD_SPAN_EM: + charFmt.setFontItalic(true); + break; + case MD_SPAN_STRONG: + charFmt.setFontWeight(QFont::Bold); + break; + case MD_SPAN_A: { + MD_SPAN_A_DETAIL *detail = static_cast(det); + QString url = QString::fromLatin1(detail->href.text, detail->href.size); + QString title = QString::fromLatin1(detail->title.text, detail->title.size); + charFmt.setAnchorHref(url); + charFmt.setAnchorName(title); + charFmt.setForeground(m_palette.link()); + qCDebug(lcMD) << "anchor" << url << title; + } break; + case MD_SPAN_IMG: { + m_imageSpan = true; + MD_SPAN_IMG_DETAIL *detail = static_cast(det); + QString src = QString::fromUtf8(detail->src.text, detail->src.size); + QString title = QString::fromUtf8(detail->title.text, detail->title.size); + QTextImageFormat img; + img.setName(src); + qCDebug(lcMD) << "image" << src << "title" << title << "relative to" << m_doc->baseUrl(); + m_cursor->insertImage(img); + break; + } + case MD_SPAN_CODE: + charFmt.setFont(m_monoFont); + break; + case MD_SPAN_DEL: + charFmt.setFontStrikeOut(true); + break; + } + m_spanFormatStack.push(charFmt); + m_cursor->setCharFormat(charFmt); + return 0; // no error +} + +int QTextMarkdownImporter::cbLeaveSpan(MD_SPANTYPE type, void *detail) +{ + Q_UNUSED(detail) + QTextCharFormat charFmt; + if (!m_spanFormatStack.isEmpty()) { + m_spanFormatStack.pop(); + if (!m_spanFormatStack.isEmpty()) + charFmt = m_spanFormatStack.top(); + } + m_cursor->setCharFormat(charFmt); + if (type == MD_SPAN_IMG) + m_imageSpan = false; + return 0; // no error +} + +int QTextMarkdownImporter::cbText(MD_TEXTTYPE type, const MD_CHAR *text, MD_SIZE size) +{ + if (m_imageSpan) + return 0; // it's the alt-text + static const QRegularExpression openingBracket(QStringLiteral("<[a-zA-Z]")); + static const QRegularExpression closingBracket(QStringLiteral("(/>|insertHtml(s); + s = QString(); + break; + case MD_TEXT_HTML: + // count how many tags are opened and how many are closed + { + int startIdx = 0; + while ((startIdx = s.indexOf(openingBracket, startIdx)) >= 0) { + ++m_htmlTagDepth; + startIdx += 2; + } + startIdx = 0; + while ((startIdx = s.indexOf(closingBracket, startIdx)) >= 0) { + --m_htmlTagDepth; + startIdx += 2; + } + } + m_htmlAccumulator += s; + s = QString(); + if (!m_htmlTagDepth) { // all open tags are now closed + qCDebug(lcMD) << "HTML" << m_htmlAccumulator; + m_cursor->insertHtml(m_htmlAccumulator); + if (m_spanFormatStack.isEmpty()) + m_cursor->setCharFormat(QTextCharFormat()); + else + m_cursor->setCharFormat(m_spanFormatStack.top()); + m_htmlAccumulator = QString(); + } + break; + } + + switch (m_blockType) { + case MD_BLOCK_TD: + m_nonEmptyTableCells.append(m_tableCol); + break; + default: + break; + } + + if (!s.isEmpty()) + m_cursor->insertText(s); + return 0; // no error +} + +QT_END_NAMESPACE diff --git a/src/gui/text/qtextmarkdownimporter_p.h b/src/gui/text/qtextmarkdownimporter_p.h new file mode 100644 index 0000000000..b73e744434 --- /dev/null +++ b/src/gui/text/qtextmarkdownimporter_p.h @@ -0,0 +1,127 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTEXTMARKDOWNIMPORTER_H +#define QTEXTMARKDOWNIMPORTER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include +#include + +#include "../../3rdparty/md4c/md4c.h" + +QT_BEGIN_NAMESPACE + +class QTextCursor; +class QTextDocument; +class QTextTable; + +class Q_GUI_EXPORT QTextMarkdownImporter +{ +public: + enum Feature { + FeatureCollapseWhitespace = MD_FLAG_COLLAPSEWHITESPACE, + FeaturePermissiveATXHeaders = MD_FLAG_PERMISSIVEATXHEADERS, + FeaturePermissiveURLAutoLinks = MD_FLAG_PERMISSIVEURLAUTOLINKS, + FeaturePermissiveMailAutoLinks = MD_FLAG_PERMISSIVEEMAILAUTOLINKS, + FeatureNoIndentedCodeBlocks = MD_FLAG_NOINDENTEDCODEBLOCKS, + FeatureNoHTMLBlocks = MD_FLAG_NOHTMLBLOCKS, + FeatureNoHTMLSpans = MD_FLAG_NOHTMLSPANS, + FeatureTables = MD_FLAG_TABLES, + FeatureStrikeThrough = MD_FLAG_STRIKETHROUGH, + FeaturePermissiveWWWAutoLinks = MD_FLAG_PERMISSIVEWWWAUTOLINKS, + FeatureTasklists = MD_FLAG_TASKLISTS, + // composite flags + FeaturePermissiveAutoLinks = MD_FLAG_PERMISSIVEAUTOLINKS, + FeatureNoHTML = MD_FLAG_NOHTML, + DialectCommonMark = MD_DIALECT_COMMONMARK, + DialectGitHub = MD_DIALECT_GITHUB + }; + Q_DECLARE_FLAGS(Features, Feature) + + QTextMarkdownImporter(Features features); + + void import(QTextDocument *doc, const QString &markdown); + +public: + // MD4C callbacks + int cbEnterBlock(MD_BLOCKTYPE type, void* detail); + int cbLeaveBlock(MD_BLOCKTYPE type, void* detail); + int cbEnterSpan(MD_SPANTYPE type, void* detail); + int cbLeaveSpan(MD_SPANTYPE type, void* detail); + int cbText(MD_TEXTTYPE type, const MD_CHAR* text, MD_SIZE size); + +private: + QTextDocument *m_doc = nullptr; + QTextCursor *m_cursor = nullptr; + QTextTable *m_currentTable = nullptr; // because m_cursor->currentTable() doesn't work + QString m_htmlAccumulator; + QVector m_nonEmptyTableCells; // in the current row + QStack m_listStack; + QStack m_spanFormatStack; + QFont m_monoFont; + QPalette m_palette; + int m_htmlTagDepth = 0; + int m_tableColumnCount = 0; + int m_tableRowCount = 0; + int m_tableCol = -1; // because relative cell movements (e.g. m_cursor->movePosition(QTextCursor::NextCell)) don't work + Features m_features; + MD_BLOCKTYPE m_blockType = MD_BLOCK_DOC; + bool m_emptyList = false; // true when the last thing we did was insertList + bool m_imageSpan = false; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QTextMarkdownImporter::Features) + +QT_END_NAMESPACE + +#endif // QTEXTMARKDOWNIMPORTER_H diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri index abe20abe02..b35a231747 100644 --- a/src/gui/text/text.pri +++ b/src/gui/text/text.pri @@ -97,6 +97,18 @@ qtConfig(textodfwriter) { text/qzip.cpp } +qtConfig(textmarkdownreader) { + qtConfig(system-textmarkdownreader) { + QMAKE_USE += libmd4c + } else { + include($$PWD/../../3rdparty/md4c.pri) + } + HEADERS += \ + text/qtextmarkdownimporter_p.h + SOURCES += \ + text/qtextmarkdownimporter.cpp +} + qtConfig(cssparser) { HEADERS += \ text/qcssparser_p.h diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index 920133d493..4a06f58b4a 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWidgets module of the Qt Toolkit. @@ -1202,6 +1202,13 @@ QString QTextEdit::toHtml() const } #endif +#if QT_CONFIG(textmarkdownreader) +void QTextEdit::setMarkdown(const QString &text) +{ + Q_D(const QTextEdit); + d->control->setMarkdown(text); +} +#endif /*! \reimp */ diff --git a/src/widgets/widgets/qtextedit.h b/src/widgets/widgets/qtextedit.h index 3aa23aaace..f20bd936c4 100644 --- a/src/widgets/widgets/qtextedit.h +++ b/src/widgets/widgets/qtextedit.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWidgets module of the Qt Toolkit. @@ -237,6 +237,9 @@ public Q_SLOTS: void setPlainText(const QString &text); #ifndef QT_NO_TEXTHTMLPARSER void setHtml(const QString &text); +#endif +#if QT_CONFIG(textmarkdownreader) + void setMarkdown(const QString &text); #endif void setText(const QString &text); diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index 711c4bfd2a..5744d43cbf 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWidgets module of the Qt Toolkit. @@ -491,6 +491,11 @@ void QWidgetTextControlPrivate::setContent(Qt::TextFormat format, const QString formatCursor.select(QTextCursor::Document); formatCursor.setCharFormat(charFormatForInsertion); formatCursor.endEditBlock(); +#if QT_CONFIG(textmarkdownreader) + } else if (format == Qt::MarkdownText) { + doc->setMarkdown(text); + doc->setUndoRedoEnabled(false); +#endif } else { #ifndef QT_NO_TEXTHTMLPARSER doc->setHtml(text); @@ -1194,6 +1199,14 @@ void QWidgetTextControl::setPlainText(const QString &text) d->setContent(Qt::PlainText, text); } +#if QT_CONFIG(textmarkdownreader) +void QWidgetTextControl::setMarkdown(const QString &text) +{ + Q_D(QWidgetTextControl); + d->setContent(Qt::MarkdownText, text); +} +#endif + void QWidgetTextControl::setHtml(const QString &text) { Q_D(QWidgetTextControl); diff --git a/src/widgets/widgets/qwidgettextcontrol_p.h b/src/widgets/widgets/qwidgettextcontrol_p.h index 9c80d53728..4c9e47dfc9 100644 --- a/src/widgets/widgets/qwidgettextcontrol_p.h +++ b/src/widgets/widgets/qwidgettextcontrol_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWidgets module of the Qt Toolkit. @@ -194,6 +194,9 @@ public: public Q_SLOTS: void setPlainText(const QString &text); +#if QT_CONFIG(textmarkdownreader) + void setMarkdown(const QString &text); +#endif void setHtml(const QString &text); #ifndef QT_NO_CLIPBOARD diff --git a/src/widgets/widgets/qwidgettextcontrol_p_p.h b/src/widgets/widgets/qwidgettextcontrol_p_p.h index 6a1ee564cd..6ccdfafe2b 100644 --- a/src/widgets/widgets/qwidgettextcontrol_p_p.h +++ b/src/widgets/widgets/qwidgettextcontrol_p_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWidgets module of the Qt Toolkit. From 642ef0c7311e18b9b4414af6ec3a2d8210bb6880 Mon Sep 17 00:00:00 2001 From: Konstantin Shegunov Date: Wed, 3 Apr 2019 13:00:01 +0300 Subject: [PATCH 194/292] Clear SSL key data as soon as possible when move-assigning Move-assign uses qSwap to exchange the private pointer and thus can extend the lifetime of sensitive data. The move assignment operator is changed so it releases the private data as soon as possible. [ChangeLog][QtNetwork][QSslKey] Key data is cleared as soon as possible when move-assigning. Change-Id: Iebd029bf657acfe000417ce648e3b3829948c0e5 Reviewed-by: Samuel Gaist --- src/network/ssl/qsslkey.h | 5 ++--- src/network/ssl/qsslkey_p.cpp | 18 ++++++++++++++++++ src/network/ssl/qsslkey_qt.cpp | 5 ++++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/network/ssl/qsslkey.h b/src/network/ssl/qsslkey.h index a865f20a51..74be406539 100644 --- a/src/network/ssl/qsslkey.h +++ b/src/network/ssl/qsslkey.h @@ -71,9 +71,8 @@ public: const QByteArray &passPhrase = QByteArray()); explicit QSslKey(Qt::HANDLE handle, QSsl::KeyType type = QSsl::PrivateKey); QSslKey(const QSslKey &other); -#ifdef Q_COMPILER_RVALUE_REFS - QSslKey &operator=(QSslKey &&other) noexcept { swap(other); return *this; } -#endif + QSslKey(QSslKey &&other) noexcept; + QSslKey &operator=(QSslKey &&other) noexcept; QSslKey &operator=(const QSslKey &other); ~QSslKey(); diff --git a/src/network/ssl/qsslkey_p.cpp b/src/network/ssl/qsslkey_p.cpp index b29b38beab..7d14aacebf 100644 --- a/src/network/ssl/qsslkey_p.cpp +++ b/src/network/ssl/qsslkey_p.cpp @@ -385,6 +385,24 @@ QSslKey::QSslKey(const QSslKey &other) : d(other.d) { } +QSslKey::QSslKey(QSslKey &&other) noexcept + : d(nullptr) +{ + qSwap(d, other.d); +} + +QSslKey &QSslKey::operator=(QSslKey &&other) noexcept +{ + if (this == &other) + return *this; + + // If no one else is referencing the key data we want to make sure + // before we swap the d-ptr that it is not left in memory. + d.reset(); + qSwap(d, other.d); + return *this; +} + /*! Destroys the QSslKey object. */ diff --git a/src/network/ssl/qsslkey_qt.cpp b/src/network/ssl/qsslkey_qt.cpp index 2662418a05..43969c3d28 100644 --- a/src/network/ssl/qsslkey_qt.cpp +++ b/src/network/ssl/qsslkey_qt.cpp @@ -48,6 +48,8 @@ #include +#include + QT_USE_NAMESPACE static const quint8 bits_table[256] = { @@ -186,8 +188,9 @@ static QByteArray deriveKey(QSslKeyPrivate::Cipher cipher, const QByteArray &pas void QSslKeyPrivate::clear(bool deep) { - Q_UNUSED(deep); isNull = true; + if (deep) + std::memset(derData.data(), 0, derData.size()); derData.clear(); keyLength = -1; } From e2906ea5c4b97ca9bb4ebf9710207097c44cc8ce Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Thu, 27 Sep 2018 00:19:49 +0200 Subject: [PATCH 195/292] QRegExp include cleanup QRegExp includes can be found in several files where there's not even a use of the class. This patch aims to avoid needless includes as well as follow the "include only what you use" moto. This patch removes a QRegExp include from the QStringList header which means that there is likely going to be code breaking since QStringList is used in many places and would get QRegExp in. [ChangeLog][Potentially Source-Incompatible Changes] qstringlist.h no longer includes qregexp.h. Change-Id: I32847532f16e419d4cb735ddc11a26551127e923 Reviewed-by: Thiago Macieira --- qmake/generators/metamakefile.cpp | 1 - qmake/generators/unix/unixmake.cpp | 1 - qmake/generators/win32/msbuild_objectmodel.cpp | 1 + qmake/generators/win32/msvc_objectmodel.cpp | 1 + qmake/library/ioutils.cpp | 1 + qmake/library/qmakeevaluator_p.h | 2 -- qmake/library/qmakeglobals.cpp | 1 - src/corelib/io/qdiriterator.cpp | 1 + src/corelib/itemmodels/qabstractitemmodel.cpp | 1 + src/corelib/kernel/qmetatype.cpp | 1 + src/corelib/kernel/qvariant.cpp | 1 + src/corelib/tools/qdatetimeparser.cpp | 1 - src/corelib/tools/qstringlist.cpp | 1 + src/gui/image/qpicture.cpp | 1 + src/gui/image/qxbmhandler.cpp | 1 + src/gui/image/qxpmhandler.cpp | 1 + src/gui/kernel/qkeysequence.cpp | 3 --- src/gui/kernel/qsimpledrag.cpp | 1 - src/network/access/qnetworkcookie.cpp | 1 + .../fontdatabases/windows/qwindowsfontdatabase_ft.cpp | 4 ++++ src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm | 1 - src/plugins/platforms/cocoa/qcocoamenuitem.mm | 1 + src/plugins/sqldrivers/sqlite2/qsql_sqlite2.cpp | 1 - src/sql/kernel/qsqlresult.cpp | 1 - src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp | 1 - src/tools/rcc/rcc.cpp | 1 + src/tools/tracegen/etw.cpp | 1 - src/tools/tracegen/lttng.cpp | 1 - src/widgets/dialogs/qcolordialog.cpp | 5 +++++ tests/auto/other/lancelot/paintcommands.h | 1 + tests/baselineserver/shared/baselineprotocol.cpp | 1 + 31 files changed, 25 insertions(+), 16 deletions(-) diff --git a/qmake/generators/metamakefile.cpp b/qmake/generators/metamakefile.cpp index 8ebd0c61ce..f9159ccd75 100644 --- a/qmake/generators/metamakefile.cpp +++ b/qmake/generators/metamakefile.cpp @@ -27,7 +27,6 @@ ****************************************************************************/ #include "metamakefile.h" -#include "qregexp.h" #include "qdir.h" #include "qdebug.h" #include "makefile.h" diff --git a/qmake/generators/unix/unixmake.cpp b/qmake/generators/unix/unixmake.cpp index 7f42fbe09e..836737e77d 100644 --- a/qmake/generators/unix/unixmake.cpp +++ b/qmake/generators/unix/unixmake.cpp @@ -28,7 +28,6 @@ #include "unixmake.h" #include "option.h" -#include #include #include #include diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp index 0e95766f8e..89428bd454 100644 --- a/qmake/generators/win32/msbuild_objectmodel.cpp +++ b/qmake/generators/win32/msbuild_objectmodel.cpp @@ -34,6 +34,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp index cf0b96ec9f..eb46e0cf69 100644 --- a/qmake/generators/win32/msvc_objectmodel.cpp +++ b/qmake/generators/win32/msvc_objectmodel.cpp @@ -34,6 +34,7 @@ #include #include +#include using namespace QMakeInternal; diff --git a/qmake/library/ioutils.cpp b/qmake/library/ioutils.cpp index 3e49a99cd5..d2171274d8 100644 --- a/qmake/library/ioutils.cpp +++ b/qmake/library/ioutils.cpp @@ -30,6 +30,7 @@ #include #include +#include #ifdef Q_OS_WIN # include diff --git a/qmake/library/qmakeevaluator_p.h b/qmake/library/qmakeevaluator_p.h index f888bc5765..da83ff0de2 100644 --- a/qmake/library/qmakeevaluator_p.h +++ b/qmake/library/qmakeevaluator_p.h @@ -31,8 +31,6 @@ #include "proitems.h" -#include - #define debugMsg if (!m_debugLevel) {} else debugMsgInternal #define traceMsg if (!m_debugLevel) {} else traceMsgInternal #ifdef PROEVALUATOR_DEBUG diff --git a/qmake/library/qmakeglobals.cpp b/qmake/library/qmakeglobals.cpp index daf4707779..1d76cecc45 100644 --- a/qmake/library/qmakeglobals.cpp +++ b/qmake/library/qmakeglobals.cpp @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp index 648593b020..69d61bf5a8 100644 --- a/src/corelib/io/qdiriterator.cpp +++ b/src/corelib/io/qdiriterator.cpp @@ -93,6 +93,7 @@ #include "qdir_p.h" #include "qabstractfileengine_p.h" +#include #include #include #include diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index 18f0f6f55f..664e16540b 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 19bda7e8d6..855d36794d 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -51,6 +51,7 @@ #include "quuid.h" #include "qvariant.h" #include "qdatastream.h" +#include "qregexp.h" #include "qmetatypeswitcher_p.h" #if QT_CONFIG(regularexpression) diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index cd4e233af0..4af2073365 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -55,6 +55,7 @@ #include "qstringlist.h" #include "qurl.h" #include "qlocale.h" +#include "qregexp.h" #include "quuid.h" #if QT_CONFIG(itemmodel) #include "qabstractitemmodel.h" diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp index e8470f6cde..5d1704daeb 100644 --- a/src/corelib/tools/qdatetimeparser.cpp +++ b/src/corelib/tools/qdatetimeparser.cpp @@ -47,7 +47,6 @@ #if QT_CONFIG(timezone) #include "qtimezone.h" #endif -#include "qregexp.h" #include "qdebug.h" //#define QDATETIMEPARSER_DEBUG diff --git a/src/corelib/tools/qstringlist.cpp b/src/corelib/tools/qstringlist.cpp index 49247d66b8..f6da7b1428 100644 --- a/src/corelib/tools/qstringlist.cpp +++ b/src/corelib/tools/qstringlist.cpp @@ -38,6 +38,7 @@ ****************************************************************************/ #include +#include #include #if QT_CONFIG(regularexpression) # include diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp index 56b82abcfa..350fda19ac 100644 --- a/src/gui/image/qpicture.cpp +++ b/src/gui/image/qpicture.cpp @@ -54,6 +54,7 @@ #include "qpainter.h" #include "qpainterpath.h" #include "qpixmap.h" +#include "qregexp.h" #include "qregion.h" #include "qdebug.h" diff --git a/src/gui/image/qxbmhandler.cpp b/src/gui/image/qxbmhandler.cpp index 65a5b63bc7..3cd15b3e4d 100644 --- a/src/gui/image/qxbmhandler.cpp +++ b/src/gui/image/qxbmhandler.cpp @@ -44,6 +44,7 @@ #include #include +#include #include #include diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp index a32dfda96d..7349a400a6 100644 --- a/src/gui/image/qxpmhandler.cpp +++ b/src/gui/image/qxpmhandler.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index 0fa3dcfbdb..8688bb8403 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -46,9 +46,6 @@ #include "qdebug.h" #include -#ifndef QT_NO_REGEXP -# include "qregexp.h" -#endif #ifndef QT_NO_DATASTREAM # include "qdatastream.h" #endif diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp index 9aab332ef5..bba2a863a9 100644 --- a/src/gui/kernel/qsimpledrag.cpp +++ b/src/gui/kernel/qsimpledrag.cpp @@ -48,7 +48,6 @@ #include "qpoint.h" #include "qbuffer.h" #include "qimage.h" -#include "qregexp.h" #include "qdir.h" #include "qimagereader.h" #include "qimagewriter.h" diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp index b7cf989477..903de322ff 100644 --- a/src/network/access/qnetworkcookie.cpp +++ b/src/network/access/qnetworkcookie.cpp @@ -46,6 +46,7 @@ #include "QtCore/qdebug.h" #include "QtCore/qlist.h" #include "QtCore/qlocale.h" +#include #include "QtCore/qstring.h" #include "QtCore/qstringlist.h" #include "QtCore/qurl.h" diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp index db2186644b..40d5749cf3 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp @@ -48,7 +48,11 @@ #include #include #include +#if QT_CONFIG(regularexpression) #include +#else +#include +#endif #include #include diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm index d1695ea860..5f32400af0 100644 --- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm @@ -51,7 +51,6 @@ #include "qt_mac_p.h" #include "qcocoahelpers.h" #include "qcocoaeventdispatcher.h" -#include #include #include #include diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm index e54b6284e5..32fc3ab660 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm @@ -53,6 +53,7 @@ #include #include +#include QT_BEGIN_NAMESPACE diff --git a/src/plugins/sqldrivers/sqlite2/qsql_sqlite2.cpp b/src/plugins/sqldrivers/sqlite2/qsql_sqlite2.cpp index 390f05c7aa..b7bcd044ab 100644 --- a/src/plugins/sqldrivers/sqlite2/qsql_sqlite2.cpp +++ b/src/plugins/sqldrivers/sqlite2/qsql_sqlite2.cpp @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include diff --git a/src/sql/kernel/qsqlresult.cpp b/src/sql/kernel/qsqlresult.cpp index 589088238b..cc91c6d0ed 100644 --- a/src/sql/kernel/qsqlresult.cpp +++ b/src/sql/kernel/qsqlresult.cpp @@ -41,7 +41,6 @@ #include "qvariant.h" #include "qhash.h" -#include "qregexp.h" #include "qsqlerror.h" #include "qsqlfield.h" #include "qsqlrecord.h" diff --git a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp index 7c6f0bdeef..522c55593f 100644 --- a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp +++ b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include #include diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp index bb4e6e3615..08fb6fca5f 100644 --- a/src/tools/rcc/rcc.cpp +++ b/src/tools/rcc/rcc.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include diff --git a/src/tools/tracegen/etw.cpp b/src/tools/tracegen/etw.cpp index e839137915..acd81bd5c1 100644 --- a/src/tools/tracegen/etw.cpp +++ b/src/tools/tracegen/etw.cpp @@ -45,7 +45,6 @@ #include #include #include -#include #include static inline QString providerVar(const QString &providerName) diff --git a/src/tools/tracegen/lttng.cpp b/src/tools/tracegen/lttng.cpp index f0fbca9e16..1aef1b3d17 100644 --- a/src/tools/tracegen/lttng.cpp +++ b/src/tools/tracegen/lttng.cpp @@ -46,7 +46,6 @@ #include #include #include -#include #include static void writeCtfMacro(QTextStream &stream, const Tracepoint::Field &field) diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index c0bacd553d..a6b6df4045 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -57,6 +57,11 @@ #include "qpainter.h" #include "qpixmap.h" #include "qpushbutton.h" +#if QT_CONFIG(regularexpression) +#include +#else +#include +#endif #if QT_CONFIG(settings) #include "qsettings.h" #endif diff --git a/tests/auto/other/lancelot/paintcommands.h b/tests/auto/other/lancelot/paintcommands.h index 79bdab634a..2923502e68 100644 --- a/tests/auto/other/lancelot/paintcommands.h +++ b/tests/auto/other/lancelot/paintcommands.h @@ -37,6 +37,7 @@ #include #include #include +#include QT_FORWARD_DECLARE_CLASS(QPainter) #ifndef QT_NO_OPENGL diff --git a/tests/baselineserver/shared/baselineprotocol.cpp b/tests/baselineserver/shared/baselineprotocol.cpp index c9f9cd9bd2..6357024341 100644 --- a/tests/baselineserver/shared/baselineprotocol.cpp +++ b/tests/baselineserver/shared/baselineprotocol.cpp @@ -38,6 +38,7 @@ #include #include #include +#include const QString PI_Project(QLS("Project")); const QString PI_TestCase(QLS("TestCase")); From 7d646508c8219408f90103ed13613db8d01a4065 Mon Sep 17 00:00:00 2001 From: Alexander Kanavin Date: Mon, 25 Feb 2019 16:05:13 +0100 Subject: [PATCH 196/292] libinput: add support for LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE This is required to get Qt EGLFS in qemu working, as qemu mouse device issues only absolute mouse events. Fixes: QTBUG-69172 Change-Id: Ia9985dc01d7871fdcd856c14160d54d3ce684396 Reviewed-by: Johan Helsing --- .../input/libinput/qlibinputhandler.cpp | 3 +++ .../input/libinput/qlibinputpointer.cpp | 18 ++++++++++++++++++ .../input/libinput/qlibinputpointer_p.h | 1 + 3 files changed, 22 insertions(+) diff --git a/src/platformsupport/input/libinput/qlibinputhandler.cpp b/src/platformsupport/input/libinput/qlibinputhandler.cpp index 52eaa18f4b..bb81890a67 100644 --- a/src/platformsupport/input/libinput/qlibinputhandler.cpp +++ b/src/platformsupport/input/libinput/qlibinputhandler.cpp @@ -205,6 +205,9 @@ void QLibInputHandler::processEvent(libinput_event *ev) case LIBINPUT_EVENT_POINTER_MOTION: m_pointer->processMotion(libinput_event_get_pointer_event(ev)); break; + case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE: + m_pointer->processAbsMotion(libinput_event_get_pointer_event(ev)); + break; case LIBINPUT_EVENT_POINTER_AXIS: m_pointer->processAxis(libinput_event_get_pointer_event(ev)); break; diff --git a/src/platformsupport/input/libinput/qlibinputpointer.cpp b/src/platformsupport/input/libinput/qlibinputpointer.cpp index c54b61fc66..db9e81b5df 100644 --- a/src/platformsupport/input/libinput/qlibinputpointer.cpp +++ b/src/platformsupport/input/libinput/qlibinputpointer.cpp @@ -103,6 +103,24 @@ void QLibInputPointer::processMotion(libinput_event_pointer *e) Qt::NoButton, QEvent::MouseMove, mods); } +void QLibInputPointer::processAbsMotion(libinput_event_pointer *e) +{ + QScreen * const primaryScreen = QGuiApplication::primaryScreen(); + const QRect g = QHighDpi::toNativePixels(primaryScreen->virtualGeometry(), primaryScreen); + + const double x = libinput_event_pointer_get_absolute_x_transformed(e, g.width()); + const double y = libinput_event_pointer_get_absolute_y_transformed(e, g.height()); + + m_pos.setX(qBound(g.left(), qRound(g.left() + x), g.right())); + m_pos.setY(qBound(g.top(), qRound(g.top() + y), g.bottom())); + + Qt::KeyboardModifiers mods = QGuiApplicationPrivate::inputDeviceManager()->keyboardModifiers(); + + QWindowSystemInterface::handleMouseEvent(nullptr, m_pos, m_pos, m_buttons, + Qt::NoButton, QEvent::MouseMove, mods); + +} + void QLibInputPointer::processAxis(libinput_event_pointer *e) { double value; // default axis value is 15 degrees per wheel click diff --git a/src/platformsupport/input/libinput/qlibinputpointer_p.h b/src/platformsupport/input/libinput/qlibinputpointer_p.h index a7a66337f1..55d4a5f919 100644 --- a/src/platformsupport/input/libinput/qlibinputpointer_p.h +++ b/src/platformsupport/input/libinput/qlibinputpointer_p.h @@ -64,6 +64,7 @@ public: void processButton(libinput_event_pointer *e); void processMotion(libinput_event_pointer *e); + void processAbsMotion(libinput_event_pointer *e); void processAxis(libinput_event_pointer *e); void setPos(const QPoint &pos); From c17d6d4e4657416051847d2c78ef944ea8f362f8 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 23 Apr 2019 16:13:12 +0200 Subject: [PATCH 197/292] Fix compiling with QHOSTINFO_DEBUG enabled Since we require getaddrinfo and freeaddrinfo, those symbols are not resolved dynamically, and will never be null, which causes compile errors. Correctly appending a string literal shuts up compiler warnings. Change-Id: I0096dca6a77ad86e0c89890444b8d7bbb38a40f2 Reviewed-by: Thiago Macieira --- src/network/kernel/qhostinfo_win.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/network/kernel/qhostinfo_win.cpp b/src/network/kernel/qhostinfo_win.cpp index c51e9968f8..ef7cff46f1 100644 --- a/src/network/kernel/qhostinfo_win.cpp +++ b/src/network/kernel/qhostinfo_win.cpp @@ -79,9 +79,8 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName) QHostInfo results; #if defined(QHOSTINFO_DEBUG) - qDebug("QHostInfoAgent::fromName(): looking up \"%s\" (IPv6 support is %s)", - hostName.toLatin1().constData(), - (getaddrinfo && freeaddrinfo) ? "enabled" : "disabled"); + qDebug("QHostInfoAgent::fromName(%s) looking up...", + hostName.toLatin1().constData()); #endif QHostAddress address; @@ -129,6 +128,12 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName) if (err == 0) { QList addresses; for (addrinfo *p = res; p != 0; p = p->ai_next) { +#ifdef QHOSTINFO_DEBUG + qDebug() << "getaddrinfo node: flags:" << p->ai_flags << "family:" << p->ai_family + << "ai_socktype:" << p->ai_socktype << "ai_protocol:" << p->ai_protocol + << "ai_addrlen:" << p->ai_addrlen; +#endif + switch (p->ai_family) { case AF_INET: { QHostAddress addr; @@ -163,7 +168,7 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName) QString tmp; QList addresses = results.addresses(); for (int i = 0; i < addresses.count(); ++i) { - if (i != 0) tmp += ", "; + if (i != 0) tmp += QLatin1String(", "); tmp += addresses.at(i).toString(); } qDebug("QHostInfoAgent::run(): found %i entries: {%s}", From b21b07877a96c175ee51e83e1b41425c2e67beb3 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Tue, 16 Apr 2019 09:58:23 +0200 Subject: [PATCH 198/292] Add a QVkConvenience class with vkFormatFromGlFormat Converts from OpenGL formats to Vulkan formats. There are commented out lines for the formats in QOpenGLTexture::TextureFormat for which it was hard to find an unambiguous mapping to vkFormat. Task-number: QTBUG-75108 Change-Id: I06a7fd8df7d98cef314410ffd79ca9cff6599357 Reviewed-by: Laszlo Agocs --- .../vkconvenience/qvkconvenience.cpp | 215 ++++++++++++++++++ .../vkconvenience/qvkconvenience_p.h | 67 ++++++ .../vkconvenience/vkconvenience.pro | 2 + 3 files changed, 284 insertions(+) create mode 100644 src/platformsupport/vkconvenience/qvkconvenience.cpp create mode 100644 src/platformsupport/vkconvenience/qvkconvenience_p.h diff --git a/src/platformsupport/vkconvenience/qvkconvenience.cpp b/src/platformsupport/vkconvenience/qvkconvenience.cpp new file mode 100644 index 0000000000..462cdc9e0d --- /dev/null +++ b/src/platformsupport/vkconvenience/qvkconvenience.cpp @@ -0,0 +1,215 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qvkconvenience_p.h" + +#include + +QT_BEGIN_NAMESPACE + +/*! + \class QVkConvenience + \brief A collection of static helper functions for Vulkan support + \since 5.14 + \internal + \ingroup qpa + */ + +VkFormat QVkConvenience::vkFormatFromGlFormat(uint glFormat) +{ + using GlFormat = QOpenGLTexture::TextureFormat; + switch (glFormat) { + case GlFormat::NoFormat: return VK_FORMAT_UNDEFINED; // GL_NONE + + // Unsigned normalized formats + case GlFormat::R8_UNorm: return VK_FORMAT_R8_UNORM; // GL_R8 + case GlFormat::RG8_UNorm: return VK_FORMAT_R8G8_UNORM; // GL_RG8 + case GlFormat::RGB8_UNorm: return VK_FORMAT_R8G8B8_UNORM; // GL_RGB8 + case GlFormat::RGBA8_UNorm: return VK_FORMAT_R8G8B8A8_UNORM; // GL_RGBA8 + + case GlFormat::R16_UNorm: return VK_FORMAT_R16_UNORM; // GL_R16 + case GlFormat::RG16_UNorm: return VK_FORMAT_R16G16_UNORM; // GL_RG16 + case GlFormat::RGB16_UNorm: return VK_FORMAT_R16G16B16_UNORM; // GL_RGB16 + case GlFormat::RGBA16_UNorm: return VK_FORMAT_R16G16B16A16_UNORM; // GL_RGBA16 + + // Signed normalized formats + case GlFormat::R8_SNorm: return VK_FORMAT_R8_SNORM; // GL_R8_SNORM + case GlFormat::RG8_SNorm: return VK_FORMAT_R8G8_SNORM; // GL_RG8_SNORM + case GlFormat::RGB8_SNorm: return VK_FORMAT_R8G8B8_SNORM; // GL_RGB8_SNORM + case GlFormat::RGBA8_SNorm: return VK_FORMAT_R8G8B8A8_SNORM; // GL_RGBA8_SNORM + + case GlFormat::R16_SNorm: return VK_FORMAT_R16_SNORM; // GL_R16_SNORM + case GlFormat::RG16_SNorm: return VK_FORMAT_R16G16_SNORM; // GL_RG16_SNORM + case GlFormat::RGB16_SNorm: return VK_FORMAT_R16G16B16_SNORM; // GL_RGB16_SNORM + case GlFormat::RGBA16_SNorm: return VK_FORMAT_R16G16B16A16_SNORM; // GL_RGBA16_SNORM + + // Unsigned integer formats + case GlFormat::R8U: return VK_FORMAT_R8_UINT; // GL_R8UI + case GlFormat::RG8U: return VK_FORMAT_R8G8_UINT; // GL_RG8UI + case GlFormat::RGB8U: return VK_FORMAT_R8G8B8_UINT; // GL_RGB8UI + case GlFormat::RGBA8U: return VK_FORMAT_R8G8B8A8_UINT; // GL_RGBA8UI + + case GlFormat::R16U: return VK_FORMAT_R16_UINT; // GL_R16UI + case GlFormat::RG16U: return VK_FORMAT_R16G16_UINT; // GL_RG16UI + case GlFormat::RGB16U: return VK_FORMAT_R16G16B16_UINT; // GL_RGB16UI + case GlFormat::RGBA16U: return VK_FORMAT_R16G16B16A16_UINT; // GL_RGBA16UI + + case GlFormat::R32U: return VK_FORMAT_R32_UINT; // GL_R32UI + case GlFormat::RG32U: return VK_FORMAT_R32G32_UINT; // GL_RG32UI + case GlFormat::RGB32U: return VK_FORMAT_R32G32B32_UINT; // GL_RGB32UI + case GlFormat::RGBA32U: return VK_FORMAT_R32G32B32A32_UINT; // GL_RGBA32UI + + // Signed integer formats + case GlFormat::R8I: return VK_FORMAT_R8_SINT; // GL_R8I + case GlFormat::RG8I: return VK_FORMAT_R8G8_SINT; // GL_RG8I + case GlFormat::RGB8I: return VK_FORMAT_R8G8B8_SINT; // GL_RGB8I + case GlFormat::RGBA8I: return VK_FORMAT_R8G8B8A8_SINT; // GL_RGBA8I + + case GlFormat::R16I: return VK_FORMAT_R16_SINT; // GL_R16I + case GlFormat::RG16I: return VK_FORMAT_R16G16_SINT; // GL_RG16I + case GlFormat::RGB16I: return VK_FORMAT_R16G16B16_SINT; // GL_RGB16I + case GlFormat::RGBA16I: return VK_FORMAT_R16G16B16A16_SINT; // GL_RGBA16I + + case GlFormat::R32I: return VK_FORMAT_R32_SINT; // GL_R32I + case GlFormat::RG32I: return VK_FORMAT_R32G32_SINT; // GL_RG32I + case GlFormat::RGB32I: return VK_FORMAT_R32G32B32_SINT; // GL_RGB32I + case GlFormat::RGBA32I: return VK_FORMAT_R32G32B32A32_SINT; // GL_RGBA32I + + // Floating point formats + case GlFormat::R16F: return VK_FORMAT_R16_SFLOAT; // GL_R16F + case GlFormat::RG16F: return VK_FORMAT_R16G16_SFLOAT; // GL_RG16F + case GlFormat::RGB16F: return VK_FORMAT_R16G16B16_SFLOAT; // GL_RGB16F + case GlFormat::RGBA16F: return VK_FORMAT_R16G16B16A16_SFLOAT; // GL_RGBA16F + + case GlFormat::R32F: return VK_FORMAT_R32_SFLOAT; // GL_R32F + case GlFormat::RG32F: return VK_FORMAT_R32G32_SFLOAT; // GL_RG32F + case GlFormat::RGB32F: return VK_FORMAT_R32G32B32_SFLOAT; // GL_RGB32F + case GlFormat::RGBA32F: return VK_FORMAT_R32G32B32A32_SFLOAT; // GL_RGBA32F + + // Packed formats + case GlFormat::RGB9E5: return VK_FORMAT_E5B9G9R9_UFLOAT_PACK32; // GL_RGB9_E5 + case GlFormat::RG11B10F: return VK_FORMAT_B10G11R11_UFLOAT_PACK32; // GL_R11F_G11F_B10F +// case GlFormat::RG3B2: return VK_FORMAT_R3_G3_B2; // GL_R3_G3_B2 + case GlFormat::R5G6B5: return VK_FORMAT_R5G6B5_UNORM_PACK16; // GL_RGB565 + case GlFormat::RGB5A1: return VK_FORMAT_R5G5B5A1_UNORM_PACK16; // GL_RGB5_A1 + case GlFormat::RGBA4: return VK_FORMAT_R4G4B4A4_UNORM_PACK16; // GL_RGBA4 + case GlFormat::RGB10A2: return VK_FORMAT_A2R10G10B10_UINT_PACK32; // GL_RGB10_A2UI + + // Depth formats +// case Format::D16: return VK_FORMAT_DEPTH_COMPONENT16; // GL_DEPTH_COMPONENT16 +// case Format::D24: return VK_FORMAT_DEPTH_COMPONENT24; // GL_DEPTH_COMPONENT24 +// case Format::D24S8: return VK_FORMAT_DEPTH24_STENCIL8; // GL_DEPTH24_STENCIL8 +// case Format::D32: return VK_FORMAT_DEPTH_COMPONENT32; // GL_DEPTH_COMPONENT32 +// case Format::D32F: return VK_FORMAT_DEPTH_COMPONENT32F; // GL_DEPTH_COMPONENT32F +// case Format::D32FS8X24: return VK_FORMAT_DEPTH32F_STENCIL8; // GL_DEPTH32F_STENCIL8 +// case Format::S8: return VK_FORMAT_STENCIL_INDEX8; // GL_STENCIL_INDEX8 + + // Compressed formats + case GlFormat::RGB_DXT1: return VK_FORMAT_BC1_RGB_UNORM_BLOCK; // GL_COMPRESSED_RGB_S3TC_DXT1_EXT + case GlFormat::RGBA_DXT1: return VK_FORMAT_BC1_RGBA_UNORM_BLOCK; // GL_COMPRESSED_RGBA_S3TC_DXT1_EXT + case GlFormat::RGBA_DXT3: return VK_FORMAT_BC2_UNORM_BLOCK; // GL_COMPRESSED_RGBA_S3TC_DXT3_EXT + case GlFormat::RGBA_DXT5: return VK_FORMAT_BC3_UNORM_BLOCK; // GL_COMPRESSED_RGBA_S3TC_DXT5_EXT + case GlFormat::R_ATI1N_UNorm: return VK_FORMAT_BC4_UNORM_BLOCK; // GL_COMPRESSED_RED_RGTC1 + case GlFormat::R_ATI1N_SNorm: return VK_FORMAT_BC4_SNORM_BLOCK; // GL_COMPRESSED_SIGNED_RED_RGTC1 + case GlFormat::RG_ATI2N_UNorm: return VK_FORMAT_BC5_UNORM_BLOCK; // GL_COMPRESSED_RG_RGTC2 + case GlFormat::RG_ATI2N_SNorm: return VK_FORMAT_BC5_SNORM_BLOCK; // GL_COMPRESSED_SIGNED_RG_RGTC2 + case GlFormat::RGB_BP_UNSIGNED_FLOAT: return VK_FORMAT_BC6H_UFLOAT_BLOCK; // GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB + case GlFormat::RGB_BP_SIGNED_FLOAT: return VK_FORMAT_BC6H_SFLOAT_BLOCK; // GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB + case GlFormat::RGB_BP_UNorm: return VK_FORMAT_BC7_UNORM_BLOCK; // GL_COMPRESSED_RGBA_BPTC_UNORM_ARB + case GlFormat::R11_EAC_UNorm: return VK_FORMAT_EAC_R11_UNORM_BLOCK; // GL_COMPRESSED_R11_EAC + case GlFormat::R11_EAC_SNorm: return VK_FORMAT_EAC_R11_SNORM_BLOCK; // GL_COMPRESSED_SIGNED_R11_EAC + case GlFormat::RG11_EAC_UNorm: return VK_FORMAT_EAC_R11G11_UNORM_BLOCK; // GL_COMPRESSED_RG11_EAC + case GlFormat::RG11_EAC_SNorm: return VK_FORMAT_EAC_R11G11_SNORM_BLOCK; // GL_COMPRESSED_SIGNED_RG11_EAC + case GlFormat::RGB8_ETC2: return VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK; // GL_COMPRESSED_RGB8_ETC2 + case GlFormat::SRGB8_ETC2: return VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ETC2 + case GlFormat::RGB8_PunchThrough_Alpha1_ETC2: return VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK; // GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 + case GlFormat::SRGB8_PunchThrough_Alpha1_ETC2: return VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 + case GlFormat::RGBA8_ETC2_EAC: return VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK; // GL_COMPRESSED_RGBA8_ETC2_EAC + case GlFormat::SRGB8_Alpha8_ETC2_EAC: return VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC +// case GlFormat::RGB8_ETC1: return VK_FORMAT_ETC1_RGB8_OES; // GL_ETC1_RGB8_OES + case GlFormat::RGBA_ASTC_4x4: return VK_FORMAT_ASTC_4x4_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_4x4_KHR + case GlFormat::RGBA_ASTC_5x4: return VK_FORMAT_ASTC_5x4_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_5x4_KHR + case GlFormat::RGBA_ASTC_5x5: return VK_FORMAT_ASTC_5x5_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_5x5_KHR + case GlFormat::RGBA_ASTC_6x5: return VK_FORMAT_ASTC_6x5_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_6x5_KHR + case GlFormat::RGBA_ASTC_6x6: return VK_FORMAT_ASTC_6x6_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_6x6_KHR + case GlFormat::RGBA_ASTC_8x5: return VK_FORMAT_ASTC_8x5_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_8x5_KHR + case GlFormat::RGBA_ASTC_8x6: return VK_FORMAT_ASTC_8x6_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_8x6_KHR + case GlFormat::RGBA_ASTC_8x8: return VK_FORMAT_ASTC_8x8_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_8x8_KHR + case GlFormat::RGBA_ASTC_10x5: return VK_FORMAT_ASTC_10x5_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_10x5_KHR + case GlFormat::RGBA_ASTC_10x6: return VK_FORMAT_ASTC_10x6_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_10x6_KHR + case GlFormat::RGBA_ASTC_10x8: return VK_FORMAT_ASTC_10x8_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_10x8_KHR + case GlFormat::RGBA_ASTC_10x10: return VK_FORMAT_ASTC_10x10_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_10x10_KHR + case GlFormat::RGBA_ASTC_12x10: return VK_FORMAT_ASTC_12x10_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_12x10_KHR + case GlFormat::RGBA_ASTC_12x12: return VK_FORMAT_ASTC_12x12_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_12x12_KHR + case GlFormat::SRGB8_Alpha8_ASTC_4x4: return VK_FORMAT_ASTC_4x4_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR + case GlFormat::SRGB8_Alpha8_ASTC_5x4: return VK_FORMAT_ASTC_5x4_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR + case GlFormat::SRGB8_Alpha8_ASTC_5x5: return VK_FORMAT_ASTC_5x5_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR + case GlFormat::SRGB8_Alpha8_ASTC_6x5: return VK_FORMAT_ASTC_6x5_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR + case GlFormat::SRGB8_Alpha8_ASTC_6x6: return VK_FORMAT_ASTC_6x6_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR + case GlFormat::SRGB8_Alpha8_ASTC_8x5: return VK_FORMAT_ASTC_8x5_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR + case GlFormat::SRGB8_Alpha8_ASTC_8x6: return VK_FORMAT_ASTC_8x6_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR + case GlFormat::SRGB8_Alpha8_ASTC_8x8: return VK_FORMAT_ASTC_8x8_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR + case GlFormat::SRGB8_Alpha8_ASTC_10x5: return VK_FORMAT_ASTC_10x5_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR + case GlFormat::SRGB8_Alpha8_ASTC_10x6: return VK_FORMAT_ASTC_10x6_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR + case GlFormat::SRGB8_Alpha8_ASTC_10x8: return VK_FORMAT_ASTC_10x8_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR + case GlFormat::SRGB8_Alpha8_ASTC_10x10: return VK_FORMAT_ASTC_10x10_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR + case GlFormat::SRGB8_Alpha8_ASTC_12x10: return VK_FORMAT_ASTC_12x10_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR + case GlFormat::SRGB8_Alpha8_ASTC_12x12: return VK_FORMAT_ASTC_12x12_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR + + // sRGB formats + case GlFormat::SRGB8: return VK_FORMAT_R8G8B8_SRGB; // GL_SRGB8 + case GlFormat::SRGB8_Alpha8: return VK_FORMAT_R8G8B8A8_SRGB; // GL_SRGB8_ALPHA8 + case GlFormat::SRGB_DXT1: return VK_FORMAT_BC1_RGB_SRGB_BLOCK; // GL_COMPRESSED_SRGB_S3TC_DXT1_EXT + case GlFormat::SRGB_Alpha_DXT1: return VK_FORMAT_BC1_RGBA_SRGB_BLOCK; // GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT + case GlFormat::SRGB_Alpha_DXT3: return VK_FORMAT_BC2_SRGB_BLOCK; // GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT + case GlFormat::SRGB_Alpha_DXT5: return VK_FORMAT_BC3_SRGB_BLOCK; // GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT + case GlFormat::SRGB_BP_UNorm: return VK_FORMAT_BC7_SRGB_BLOCK; // GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB + + // ES 2 formats +// case GlFormat::DepthFormat: return VK_FORMAT_DEPTH_COMPONENT; // GL_DEPTH_COMPONENT +// case GlFormat::AlphaFormat: return VK_FORMAT_ALPHA; // GL_ALPHA +// case GlFormat::RGBFormat: return VK_FORMAT_RGB; // GL_RGB +// case GlFormat::RGBAFormat: return VK_FORMAT_RGBA; // GL_RGBA +// case GlFormat::LuminanceFormat: return VK_FORMAT_LUMINANCE; // GL_LUMINANCE +// case GlFormat::LuminanceAlphaFormat: return VK_FORMAT; + default: return VK_FORMAT_UNDEFINED; + } +} + +QT_END_NAMESPACE diff --git a/src/platformsupport/vkconvenience/qvkconvenience_p.h b/src/platformsupport/vkconvenience/qvkconvenience_p.h new file mode 100644 index 0000000000..1dd1dfc4a7 --- /dev/null +++ b/src/platformsupport/vkconvenience/qvkconvenience_p.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QVKCONVENIENCE_P_H +#define QVKCONVENIENCE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class QVkConvenience +{ +public: + static VkFormat vkFormatFromGlFormat(uint glFormat); +}; + +QT_END_NAMESPACE + +#endif // QVKCONVENIENCE_P_H diff --git a/src/platformsupport/vkconvenience/vkconvenience.pro b/src/platformsupport/vkconvenience/vkconvenience.pro index 7a4cdb041d..ee540024cf 100644 --- a/src/platformsupport/vkconvenience/vkconvenience.pro +++ b/src/platformsupport/vkconvenience/vkconvenience.pro @@ -8,9 +8,11 @@ DEFINES += QT_NO_CAST_FROM_ASCII PRECOMPILED_HEADER = ../../corelib/global/qt_pch.h SOURCES += \ + qvkconvenience.cpp \ qbasicvulkanplatforminstance.cpp HEADERS += \ + qvkconvenience_p.h \ qbasicvulkanplatforminstance_p.h load(qt_module) From 2eb849ed516afc8e602dbec3da0ac12db2cdf8ec Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 21 Feb 2019 20:54:03 +0100 Subject: [PATCH 199/292] Implement std::numeric_limits This shall make it more nearly a first-class numeric type; in particular, I need some of these for testlib's comparing and formatting of float16 to handle NaNs and infinities sensibly. Change-Id: Ic894dd0eb3e05653cd7645ab496463e7a884dff8 Reviewed-by: Qt CI Bot Reviewed-by: Thiago Macieira --- src/corelib/global/qfloat16.h | 71 +++++++++ src/corelib/serialization/qcborvalue.cpp | 4 +- .../corelib/global/qfloat16/tst_qfloat16.cpp | 142 ++++++++++++++++++ 3 files changed, 215 insertions(+), 2 deletions(-) diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h index 243aea98be..4c3f9ca063 100644 --- a/src/corelib/global/qfloat16.h +++ b/src/corelib/global/qfloat16.h @@ -1,5 +1,6 @@ /**************************************************************************** ** +** Copyright (C) 2019 The Qt Company Ltd. ** Copyright (C) 2016 by Southwest Research Institute (R) ** Contact: http://www.qt-project.org/legal ** @@ -66,6 +67,13 @@ QT_BEGIN_NAMESPACE class qfloat16 { + struct Wrap + { + // To let our private constructor work, without other code seeing + // ambiguity when constructing from int, double &c. + quint16 b16; + constexpr inline explicit Wrap(int value) : b16(value) {} + }; public: constexpr inline qfloat16() noexcept : b16(0) {} inline qfloat16(float f) noexcept; @@ -75,8 +83,20 @@ public: bool isInf() const noexcept { return ((b16 >> 8) & 0x7e) == 0x7c; } bool isNaN() const noexcept { return ((b16 >> 8) & 0x7e) == 0x7e; } bool isFinite() const noexcept { return ((b16 >> 8) & 0x7c) != 0x7c; } + // Support for std::numeric_limits + static constexpr qfloat16 _limit_epsilon() noexcept { return qfloat16(Wrap(0x1400)); } + static constexpr qfloat16 _limit_min() noexcept { return qfloat16(Wrap(0x400)); } + static constexpr qfloat16 _limit_denorm_min() noexcept { return qfloat16(Wrap(1)); } + static constexpr qfloat16 _limit_max() noexcept { return qfloat16(Wrap(0x7bff)); } + static constexpr qfloat16 _limit_lowest() noexcept { return qfloat16(Wrap(0xfbff)); } + static constexpr qfloat16 _limit_infinity() noexcept { return qfloat16(Wrap(0x7c00)); } + static constexpr qfloat16 _limit_quiet_NaN() noexcept { return qfloat16(Wrap(0x7e00)); } + // Signalling NaN is 0x7f00 + inline constexpr bool isNormal() const noexcept + { return b16 == 0 || ((b16 & 0x7c00) && (b16 & 0x7c00) != 0x7c00); } private: quint16 b16; + constexpr inline explicit qfloat16(Wrap nibble) noexcept : b16(nibble.b16) {} Q_CORE_EXPORT static const quint32 mantissatable[]; Q_CORE_EXPORT static const quint32 exponenttable[]; @@ -263,4 +283,55 @@ QT_END_NAMESPACE Q_DECLARE_METATYPE(qfloat16) +namespace std { +template<> +class numeric_limits : public numeric_limits +{ +public: + /* + Treat quint16 b16 as if it were: + uint S: 1; // b16 >> 15 (sign) + uint E: 5; // (b16 >> 10) & 0x1f (offset exponent) + uint M: 10; // b16 & 0x3ff (adjusted mantissa) + + for E == 0: magnitude is M / 2.^{24} + for 0 < E < 31: magnitude is (1. + M / 2.^{10}) * 2.^{E - 15) + for E == 31: not finite + */ + static constexpr int digits = 11; + static constexpr int min_exponent = -13; + static constexpr int max_exponent = 16; + + static constexpr int digits10 = 3; + static constexpr int max_digits10 = 5; + static constexpr int min_exponent10 = -4; + static constexpr int max_exponent10 = 4; + + static constexpr QT_PREPEND_NAMESPACE(qfloat16) epsilon() + { return QT_PREPEND_NAMESPACE(qfloat16)::_limit_epsilon(); } + static constexpr QT_PREPEND_NAMESPACE(qfloat16) (min)() + { return QT_PREPEND_NAMESPACE(qfloat16)::_limit_min(); } + static constexpr QT_PREPEND_NAMESPACE(qfloat16) denorm_min() + { return QT_PREPEND_NAMESPACE(qfloat16)::_limit_denorm_min(); } + static constexpr QT_PREPEND_NAMESPACE(qfloat16) (max)() + { return QT_PREPEND_NAMESPACE(qfloat16)::_limit_max(); } + static constexpr QT_PREPEND_NAMESPACE(qfloat16) lowest() + { return QT_PREPEND_NAMESPACE(qfloat16)::_limit_lowest(); } + static constexpr QT_PREPEND_NAMESPACE(qfloat16) infinity() + { return QT_PREPEND_NAMESPACE(qfloat16)::_limit_infinity(); } + static constexpr QT_PREPEND_NAMESPACE(qfloat16) quiet_NaN() + { return QT_PREPEND_NAMESPACE(qfloat16)::_limit_quiet_NaN(); } +}; + +template<> class numeric_limits + : public numeric_limits {}; +template<> class numeric_limits + : public numeric_limits {}; +template<> class numeric_limits + : public numeric_limits {}; + +// Adding overloads to std isn't allowed, so we can't extend this to support +// for fpclassify(), isnormal() &c. (which, furthermore, are macros on MinGW). +} // namespace std + #endif // QFLOAT16_H diff --git a/src/corelib/serialization/qcborvalue.cpp b/src/corelib/serialization/qcborvalue.cpp index 288446878c..d469735ae9 100644 --- a/src/corelib/serialization/qcborvalue.cpp +++ b/src/corelib/serialization/qcborvalue.cpp @@ -766,8 +766,8 @@ static void writeDoubleToCbor(QCborStreamWriter &writer, double d, QCborValue::E if (qt_is_nan(d)) { if (opt & QCborValue::UseFloat16) { if ((opt & QCborValue::UseFloat16) == QCborValue::UseFloat16) - return writer.append(qfloat16(qt_qnan())); - return writer.append(float(qt_qnan())); + return writer.append(std::numeric_limits::quiet_NaN()); + return writer.append(std::numeric_limits::quiet_NaN()); } return writer.append(qt_qnan()); } diff --git a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp index 241dccb90e..b5a77a1de6 100644 --- a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp +++ b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp @@ -1,5 +1,6 @@ /**************************************************************************** ** +** Copyright (C) 2019 The Qt Company Ltd. ** Copyright (C) 2016 by Southwest Research Institute (R) ** Contact: https://www.qt.io/licensing/ ** @@ -48,6 +49,7 @@ private slots: void arithOps(); void floatToFloat16(); void floatFromFloat16(); + void limits(); }; void tst_qfloat16::fuzzyCompare_data() @@ -345,5 +347,145 @@ void tst_qfloat16::floatFromFloat16() QCOMPARE(out[i], expected[i]); } +static qfloat16 powf16(qfloat16 base, int raise) +{ + const qfloat16 one(1.f); + if (raise < 0) { + raise = -raise; + base = one / base; + } + qfloat16 answer = (raise & 1) ? base : one; + while (raise > 0) { + raise >>= 1; + base *= base; + if (raise & 1) + answer *= base; + } + return answer; +} + +void tst_qfloat16::limits() +{ + // *NOT* using QCOMPARE() on finite qfloat16 values, since that uses fuzzy + // comparison, and we need exact here. + using Bounds = std::numeric_limits; + QVERIFY(Bounds::is_specialized); + QVERIFY(Bounds::is_signed); + QVERIFY(!Bounds::is_integer); + QVERIFY(!Bounds::is_exact); + QVERIFY(Bounds::is_iec559); + QVERIFY(Bounds::is_bounded); + QVERIFY(!Bounds::is_modulo); + QVERIFY(!Bounds::traps); + QVERIFY(Bounds::has_infinity); + QVERIFY(Bounds::has_quiet_NaN); + QVERIFY(Bounds::has_signaling_NaN); + QCOMPARE(Bounds::has_denorm, std::denorm_present); + QCOMPARE(Bounds::round_style, std::round_to_nearest); + QCOMPARE(Bounds::radix, 2); + // Untested: has_denorm_loss + + // A few common values: + const qfloat16 zero(0), one(1), ten(10); + QVERIFY(qIsFinite(zero)); + QVERIFY(!qIsInf(zero)); + QVERIFY(!qIsNaN(zero)); + QVERIFY(qIsFinite(one)); + QVERIFY(!qIsInf(one)); + QVERIFY(!qIsNaN(one)); + QVERIFY(qIsFinite(ten)); + QVERIFY(!qIsInf(ten)); + QVERIFY(!qIsNaN(ten)); + + // digits in the mantissa, including the implicit 1 before the binary dot at its left: + QVERIFY(qfloat16(1 << (Bounds::digits - 1)) + one > qfloat16(1 << (Bounds::digits - 1))); + QVERIFY(qfloat16(1 << Bounds::digits) + one == qfloat16(1 << Bounds::digits)); + + // There is a wilful of-by-one in how m(ax|in)_exponent are defined; they're + // the lowest and highest n for which radix^{n-1} are normal and finite. + const qfloat16 two(Bounds::radix); + qfloat16 bit = powf16(two, Bounds::max_exponent - 1); + QVERIFY(qIsFinite(bit)); + QVERIFY(qIsInf(bit * two)); + bit = powf16(two, Bounds::min_exponent - 1); + QVERIFY(bit.isNormal()); + QVERIFY(!(bit / two).isNormal()); + QVERIFY(bit / two > zero); + + // Base ten (with no matching off-by-one idiocy): + // the lowest negative number n such that 10^n is a valid normalized value + qfloat16 low10(powf16(ten, Bounds::min_exponent10)); + QVERIFY(low10 > zero); + QVERIFY(low10.isNormal()); + low10 /= ten; + QVERIFY(low10 == zero || !low10.isNormal()); + // the largest positive number n such that 10^n is a representable finite value + qfloat16 high10(powf16(ten, Bounds::max_exponent10)); + QVERIFY(high10 > zero); + QVERIFY(qIsFinite(high10)); + QVERIFY(!qIsFinite(high10 * ten)); + + // How many digits are significant ? (Casts avoid linker errors ...) + QCOMPARE(int(Bounds::digits10), 3); // 9.79e-4 has enough sigificant digits: + qfloat16 below(9.785e-4f), above(9.794e-4f); +#if 0 // Sadly, the QEMU x-compile for arm64 "optimises" comparisons: + const bool overOptimised = false; +#else + const bool overOptimised = (below != above); + if (overOptimised) + QEXPECT_FAIL("", "Over-optimised on QEMU", Continue); +#endif // (but it did, so should, pass everywhere else, confirming digits10 is indeed 3). + QVERIFY(below == above); + QCOMPARE(int(Bounds::max_digits10), 5); // we need 5 to distinguish these two: + QVERIFY(qfloat16(1000.5f) != qfloat16(1001.4f)); + + // Actual limiting values of the type: + const qfloat16 rose(one + Bounds::epsilon()); + QVERIFY(rose > one); + if (overOptimised) + QEXPECT_FAIL("", "Over-optimised on QEMU", Continue); + QVERIFY(one + Bounds::epsilon() / rose == one); + QVERIFY(qIsInf(Bounds::infinity())); + QVERIFY(!qIsNaN(Bounds::infinity())); + QVERIFY(!qIsFinite(Bounds::infinity())); + // QCOMPARE(Bounds::infinity(), Bounds::infinity()); + QVERIFY(Bounds::infinity() > -Bounds::infinity()); + QVERIFY(Bounds::infinity() > zero); + QVERIFY(qIsInf(-Bounds::infinity())); + QVERIFY(!qIsNaN(-Bounds::infinity())); + QVERIFY(!qIsFinite(-Bounds::infinity())); + // QCOMPARE(-Bounds::infinity(), -Bounds::infinity()); + QVERIFY(-Bounds::infinity() < zero); + QVERIFY(qIsNaN(Bounds::quiet_NaN())); + QVERIFY(!qIsInf(Bounds::quiet_NaN())); + QVERIFY(!qIsFinite(Bounds::quiet_NaN())); + QVERIFY(!(Bounds::quiet_NaN() == Bounds::quiet_NaN())); + // QCOMPARE(Bounds::quiet_NaN(), Bounds::quiet_NaN()); + QVERIFY(Bounds::max() > zero); + QVERIFY(qIsFinite(Bounds::max())); + QVERIFY(!qIsInf(Bounds::max())); + QVERIFY(!qIsNaN(Bounds::max())); + QVERIFY(qIsInf(Bounds::max() * rose)); + QVERIFY(Bounds::lowest() < zero); + QVERIFY(qIsFinite(Bounds::lowest())); + QVERIFY(!qIsInf(Bounds::lowest())); + QVERIFY(!qIsNaN(Bounds::lowest())); + QVERIFY(qIsInf(Bounds::lowest() * rose)); + QVERIFY(Bounds::min() > zero); + QVERIFY(Bounds::min().isNormal()); + QVERIFY(!(Bounds::min() / rose).isNormal()); + QVERIFY(qIsFinite(Bounds::min())); + QVERIFY(!qIsInf(Bounds::min())); + QVERIFY(!qIsNaN(Bounds::min())); + QVERIFY(Bounds::denorm_min() > zero); + QVERIFY(!Bounds::denorm_min().isNormal()); + QVERIFY(qIsFinite(Bounds::denorm_min())); + QVERIFY(!qIsInf(Bounds::denorm_min())); + QVERIFY(!qIsNaN(Bounds::denorm_min())); + if (overOptimised) + QEXPECT_FAIL("", "Over-optimised on QEMU", Continue); + QCOMPARE(Bounds::denorm_min() / rose, zero); +} + QTEST_APPLESS_MAIN(tst_qfloat16) #include "tst_qfloat16.moc" From 934000c11afe8b03c81a8f52f3a51be6615087c6 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 22 Mar 2019 16:03:59 +0100 Subject: [PATCH 200/292] Implement qFpClassify(qfloat16) This extends support for qfloat16 sufficiently for the things testlib needs in order to treat it as a first-class citizen. Extended tests for qfloat to check qFpClassify() on it. Change-Id: I906292afaf51cd9c94ba384ff5aaa855edd56da1 Reviewed-by: Thiago Macieira --- src/corelib/global/qfloat16.cpp | 13 +++++++++++++ src/corelib/global/qfloat16.h | 2 ++ .../corelib/global/qfloat16/tst_qfloat16.cpp | 19 +++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/src/corelib/global/qfloat16.cpp b/src/corelib/global/qfloat16.cpp index 680268c59b..2bf6ff00c2 100644 --- a/src/corelib/global/qfloat16.cpp +++ b/src/corelib/global/qfloat16.cpp @@ -1,5 +1,6 @@ /**************************************************************************** ** +** Copyright (C) 2019 The Qt Company Ltd. ** Copyright (C) 2016 by Southwest Research Institute (R) ** Contact: http://www.qt-project.org/legal ** @@ -39,6 +40,7 @@ #include "qfloat16.h" #include "private/qsimd_p.h" +#include // for fpclassify()'s return values QT_BEGIN_NAMESPACE @@ -91,6 +93,17 @@ QT_BEGIN_NAMESPACE \sa qIsFinite */ +/*! + \internal + Implements qFpClassify() for qfloat16. + */ + +int qfloat16::fpClassify() const noexcept +{ + return isInf() ? FP_INFINITE : isNaN() ? FP_NAN + : !b16 ? FP_ZERO : isNormal() ? FP_NORMAL : FP_SUBNORMAL; +} + /*! \fn int qRound(qfloat16 value) \relates diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h index 4c3f9ca063..6f798f8b8f 100644 --- a/src/corelib/global/qfloat16.h +++ b/src/corelib/global/qfloat16.h @@ -83,6 +83,7 @@ public: bool isInf() const noexcept { return ((b16 >> 8) & 0x7e) == 0x7c; } bool isNaN() const noexcept { return ((b16 >> 8) & 0x7e) == 0x7e; } bool isFinite() const noexcept { return ((b16 >> 8) & 0x7c) != 0x7c; } + Q_CORE_EXPORT int fpClassify() const noexcept; // Support for std::numeric_limits static constexpr qfloat16 _limit_epsilon() noexcept { return qfloat16(Wrap(0x1400)); } static constexpr qfloat16 _limit_min() noexcept { return qfloat16(Wrap(0x400)); } @@ -117,6 +118,7 @@ Q_CORE_EXPORT void qFloatFromFloat16(float *, const qfloat16 *, qsizetype length Q_REQUIRED_RESULT inline bool qIsInf(qfloat16 f) noexcept { return f.isInf(); } Q_REQUIRED_RESULT inline bool qIsNaN(qfloat16 f) noexcept { return f.isNaN(); } Q_REQUIRED_RESULT inline bool qIsFinite(qfloat16 f) noexcept { return f.isFinite(); } +Q_REQUIRED_RESULT inline int qFpClassify(qfloat16 f) noexcept { return f.fpClassify(); } // Q_REQUIRED_RESULT quint32 qFloatDistance(qfloat16 a, qfloat16 b); // The remainder of these utility functions complement qglobal.h diff --git a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp index b5a77a1de6..b82751cfb5 100644 --- a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp +++ b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp @@ -390,12 +390,15 @@ void tst_qfloat16::limits() QVERIFY(qIsFinite(zero)); QVERIFY(!qIsInf(zero)); QVERIFY(!qIsNaN(zero)); + QCOMPARE(qFpClassify(zero), FP_ZERO); QVERIFY(qIsFinite(one)); QVERIFY(!qIsInf(one)); + QCOMPARE(qFpClassify(one), FP_NORMAL); QVERIFY(!qIsNaN(one)); QVERIFY(qIsFinite(ten)); QVERIFY(!qIsInf(ten)); QVERIFY(!qIsNaN(ten)); + QCOMPARE(qFpClassify(ten), FP_NORMAL); // digits in the mantissa, including the implicit 1 before the binary dot at its left: QVERIFY(qfloat16(1 << (Bounds::digits - 1)) + one > qfloat16(1 << (Bounds::digits - 1))); @@ -409,7 +412,9 @@ void tst_qfloat16::limits() QVERIFY(qIsInf(bit * two)); bit = powf16(two, Bounds::min_exponent - 1); QVERIFY(bit.isNormal()); + QCOMPARE(qFpClassify(bit), FP_NORMAL); QVERIFY(!(bit / two).isNormal()); + QCOMPARE(qFpClassify(bit / two), FP_SUBNORMAL); QVERIFY(bit / two > zero); // Base ten (with no matching off-by-one idiocy): @@ -424,6 +429,7 @@ void tst_qfloat16::limits() QVERIFY(high10 > zero); QVERIFY(qIsFinite(high10)); QVERIFY(!qIsFinite(high10 * ten)); + QCOMPARE(qFpClassify(high10), FP_NORMAL); // How many digits are significant ? (Casts avoid linker errors ...) QCOMPARE(int(Bounds::digits10), 3); // 9.79e-4 has enough sigificant digits: @@ -449,34 +455,46 @@ void tst_qfloat16::limits() QVERIFY(!qIsNaN(Bounds::infinity())); QVERIFY(!qIsFinite(Bounds::infinity())); // QCOMPARE(Bounds::infinity(), Bounds::infinity()); + QCOMPARE(qFpClassify(Bounds::infinity()), FP_INFINITE); + QVERIFY(Bounds::infinity() > -Bounds::infinity()); QVERIFY(Bounds::infinity() > zero); QVERIFY(qIsInf(-Bounds::infinity())); QVERIFY(!qIsNaN(-Bounds::infinity())); QVERIFY(!qIsFinite(-Bounds::infinity())); // QCOMPARE(-Bounds::infinity(), -Bounds::infinity()); + QCOMPARE(qFpClassify(-Bounds::infinity()), FP_INFINITE); + QVERIFY(-Bounds::infinity() < zero); QVERIFY(qIsNaN(Bounds::quiet_NaN())); QVERIFY(!qIsInf(Bounds::quiet_NaN())); QVERIFY(!qIsFinite(Bounds::quiet_NaN())); QVERIFY(!(Bounds::quiet_NaN() == Bounds::quiet_NaN())); // QCOMPARE(Bounds::quiet_NaN(), Bounds::quiet_NaN()); + QCOMPARE(qFpClassify(Bounds::quiet_NaN()), FP_NAN); + QVERIFY(Bounds::max() > zero); QVERIFY(qIsFinite(Bounds::max())); QVERIFY(!qIsInf(Bounds::max())); QVERIFY(!qIsNaN(Bounds::max())); QVERIFY(qIsInf(Bounds::max() * rose)); + QCOMPARE(qFpClassify(Bounds::max()), FP_NORMAL); + QVERIFY(Bounds::lowest() < zero); QVERIFY(qIsFinite(Bounds::lowest())); QVERIFY(!qIsInf(Bounds::lowest())); QVERIFY(!qIsNaN(Bounds::lowest())); QVERIFY(qIsInf(Bounds::lowest() * rose)); + QCOMPARE(qFpClassify(Bounds::lowest()), FP_NORMAL); + QVERIFY(Bounds::min() > zero); QVERIFY(Bounds::min().isNormal()); QVERIFY(!(Bounds::min() / rose).isNormal()); QVERIFY(qIsFinite(Bounds::min())); QVERIFY(!qIsInf(Bounds::min())); QVERIFY(!qIsNaN(Bounds::min())); + QCOMPARE(qFpClassify(Bounds::min()), FP_NORMAL); + QVERIFY(Bounds::denorm_min() > zero); QVERIFY(!Bounds::denorm_min().isNormal()); QVERIFY(qIsFinite(Bounds::denorm_min())); @@ -485,6 +503,7 @@ void tst_qfloat16::limits() if (overOptimised) QEXPECT_FAIL("", "Over-optimised on QEMU", Continue); QCOMPARE(Bounds::denorm_min() / rose, zero); + QCOMPARE(qFpClassify(Bounds::denorm_min()), FP_SUBNORMAL); } QTEST_APPLESS_MAIN(tst_qfloat16) From 3abfa4dfff08d9d2ab9aeb474656b36076a48b3b Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 21 Nov 2018 14:36:08 +0100 Subject: [PATCH 201/292] QtTestLib: handle float16 the same as double and float In QCOMPARE, handle NaNs and infinities the way tests want them handled, rather than by strict IEEE rules. In particular, if a test expects NaN, this lets it treat that just like any other expected value, despite NaN != NaN as float16 values. Likewise, format infinities and NaNs specially in toString() so that they're reported consistently. Enable the qfloat16 tests that depend on this QCOMPARE() behavior. Refise the testlib selftest's float test to test qfloat16 the same way it tests float and double (and format the test the same way). This is a follow-up to 37f617c405a. Change-Id: I433256a09b1657e6725d68d07c5f80d805bf586a Reviewed-by: Thiago Macieira --- src/testlib/qtestcase.cpp | 11 +- .../corelib/global/qfloat16/tst_qfloat16.cpp | 6 +- .../testlib/selftests/expected_float.lightxml | 191 ++++++++- .../auto/testlib/selftests/expected_float.tap | 377 +++++++++++++++++- .../testlib/selftests/expected_float.teamcity | 102 ++++- .../auto/testlib/selftests/expected_float.txt | 123 +++++- .../auto/testlib/selftests/expected_float.xml | 191 ++++++++- .../testlib/selftests/expected_float.xunitxml | 86 +++- .../testlib/selftests/float/tst_float.cpp | 30 +- 9 files changed, 1054 insertions(+), 63 deletions(-) diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index db44b3860a..cad29b5326 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -2539,7 +2539,8 @@ static bool floatingCompare(const T &t1, const T &t2) bool QTest::qCompare(qfloat16 const &t1, qfloat16 const &t2, const char *actual, const char *expected, const char *file, int line) { - return compare_helper(qFuzzyCompare(t1, t2), "Compared qfloat16s are not the same (fuzzy compare)", + return compare_helper(floatingCompare(t1, t2), + "Compared qfloat16s are not the same (fuzzy compare)", toString(t1), toString(t2), actual, expected, file, line); } @@ -2646,16 +2647,10 @@ template <> Q_TESTLIB_EXPORT char *QTest::toString(const TYPE &t) \ return msg; \ } +TO_STRING_FLOAT(qfloat16, %.3g) TO_STRING_FLOAT(float, %g) TO_STRING_FLOAT(double, %.12g) -template <> Q_TESTLIB_EXPORT char *QTest::toString(const qfloat16 &t) -{ - char *msg = new char[16]; - qsnprintf(msg, 16, "%.3g", static_cast(t)); - return msg; -} - template <> Q_TESTLIB_EXPORT char *QTest::toString(const char &t) { unsigned char c = static_cast(t); diff --git a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp index b82751cfb5..6894fd4cc3 100644 --- a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp +++ b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp @@ -454,7 +454,7 @@ void tst_qfloat16::limits() QVERIFY(qIsInf(Bounds::infinity())); QVERIFY(!qIsNaN(Bounds::infinity())); QVERIFY(!qIsFinite(Bounds::infinity())); - // QCOMPARE(Bounds::infinity(), Bounds::infinity()); + QCOMPARE(Bounds::infinity(), Bounds::infinity()); QCOMPARE(qFpClassify(Bounds::infinity()), FP_INFINITE); QVERIFY(Bounds::infinity() > -Bounds::infinity()); @@ -462,7 +462,7 @@ void tst_qfloat16::limits() QVERIFY(qIsInf(-Bounds::infinity())); QVERIFY(!qIsNaN(-Bounds::infinity())); QVERIFY(!qIsFinite(-Bounds::infinity())); - // QCOMPARE(-Bounds::infinity(), -Bounds::infinity()); + QCOMPARE(-Bounds::infinity(), -Bounds::infinity()); QCOMPARE(qFpClassify(-Bounds::infinity()), FP_INFINITE); QVERIFY(-Bounds::infinity() < zero); @@ -470,7 +470,7 @@ void tst_qfloat16::limits() QVERIFY(!qIsInf(Bounds::quiet_NaN())); QVERIFY(!qIsFinite(Bounds::quiet_NaN())); QVERIFY(!(Bounds::quiet_NaN() == Bounds::quiet_NaN())); - // QCOMPARE(Bounds::quiet_NaN(), Bounds::quiet_NaN()); + QCOMPARE(Bounds::quiet_NaN(), Bounds::quiet_NaN()); QCOMPARE(qFpClassify(Bounds::quiet_NaN()), FP_NAN); QVERIFY(Bounds::max() > zero); diff --git a/tests/auto/testlib/selftests/expected_float.lightxml b/tests/auto/testlib/selftests/expected_float.lightxml index 54d6eabdbd..5f5114bb2e 100644 --- a/tests/auto/testlib/selftests/expected_float.lightxml +++ b/tests/auto/testlib/selftests/expected_float.lightxml @@ -428,21 +428,24 @@ - - - + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/expected_float.tap b/tests/auto/testlib/selftests/expected_float.tap index 4a3b3906c2..9da51b93b3 100644 --- a/tests/auto/testlib/selftests/expected_float.tap +++ b/tests/auto/testlib/selftests/expected_float.tap @@ -759,8 +759,7 @@ not ok 77 - floatComparisons(should FAIL: -max != -inf) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp line: 137 ... -ok 78 - float16Comparisons(should SUCCEED 1) -not ok 79 - float16Comparisons(should FAIL 1) +not ok 78 - float16Comparisons(should FAIL 1) --- type: QCOMPARE message: Compared qfloat16s are not the same (fuzzy compare) @@ -772,6 +771,7 @@ not ok 79 - float16Comparisons(should FAIL 1) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp line: 171 ... +ok 79 - float16Comparisons(should PASS 1) not ok 80 - float16Comparisons(should FAIL 2) --- type: QCOMPARE @@ -784,7 +784,8 @@ not ok 80 - float16Comparisons(should FAIL 2) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp line: 171 ... -not ok 81 - float16Comparisons(should FAIL 3) +ok 81 - float16Comparisons(should PASS 2) +not ok 82 - float16Comparisons(should FAIL 3) --- type: QCOMPARE message: Compared qfloat16s are not the same (fuzzy compare) @@ -796,8 +797,348 @@ not ok 81 - float16Comparisons(should FAIL 3) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp line: 171 ... -ok 82 - float16Comparisons(should SUCCEED 2) -not ok 83 - compareFloatTests(1e0) +ok 83 - float16Comparisons(should PASS 3) +not ok 84 - float16Comparisons(should FAIL 4) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: 5.87e-05 (operandRight) + found: 5.93e-05 (operandLeft) + expected: 5.87e-05 (operandRight) + actual: 5.93e-05 (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +ok 85 - float16Comparisons(should PASS 4) +not ok 86 - float16Comparisons(should FAIL 5) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: 5.88e+04 (operandRight) + found: 5.94e+04 (operandLeft) + expected: 5.88e+04 (operandRight) + actual: 5.94e+04 (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +ok 87 - float16Comparisons(should PASS: NaN == NaN) +not ok 88 - float16Comparisons(should FAIL: NaN != 0) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: 0 (operandRight) + found: nan (operandLeft) + expected: 0 (operandRight) + actual: nan (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 89 - float16Comparisons(should FAIL: 0 != NaN) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: nan (operandRight) + found: 0 (operandLeft) + expected: nan (operandRight) + actual: 0 (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 90 - float16Comparisons(should FAIL: NaN != 1) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: 1 (operandRight) + found: nan (operandLeft) + expected: 1 (operandRight) + actual: nan (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 91 - float16Comparisons(should FAIL: 1 != NaN) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: nan (operandRight) + found: 1 (operandLeft) + expected: nan (operandRight) + actual: 1 (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +ok 92 - float16Comparisons(should PASS: inf == inf) +ok 93 - float16Comparisons(should PASS: -inf == -inf) +not ok 94 - float16Comparisons(should FAIL: inf != -inf) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: -inf (operandRight) + found: inf (operandLeft) + expected: -inf (operandRight) + actual: inf (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 95 - float16Comparisons(should FAIL: -inf != inf) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: inf (operandRight) + found: -inf (operandLeft) + expected: inf (operandRight) + actual: -inf (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 96 - float16Comparisons(should FAIL: inf != nan) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: nan (operandRight) + found: inf (operandLeft) + expected: nan (operandRight) + actual: inf (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 97 - float16Comparisons(should FAIL: nan != inf) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: inf (operandRight) + found: nan (operandLeft) + expected: inf (operandRight) + actual: nan (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 98 - float16Comparisons(should FAIL: -inf != nan) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: nan (operandRight) + found: -inf (operandLeft) + expected: nan (operandRight) + actual: -inf (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 99 - float16Comparisons(should FAIL: nan != -inf) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: -inf (operandRight) + found: nan (operandLeft) + expected: -inf (operandRight) + actual: nan (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 100 - float16Comparisons(should FAIL: inf != 0) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: 0 (operandRight) + found: inf (operandLeft) + expected: 0 (operandRight) + actual: inf (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 101 - float16Comparisons(should FAIL: 0 != inf) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: inf (operandRight) + found: 0 (operandLeft) + expected: inf (operandRight) + actual: 0 (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 102 - float16Comparisons(should FAIL: -inf != 0) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: 0 (operandRight) + found: -inf (operandLeft) + expected: 0 (operandRight) + actual: -inf (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 103 - float16Comparisons(should FAIL: 0 != -inf) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: -inf (operandRight) + found: 0 (operandLeft) + expected: -inf (operandRight) + actual: 0 (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 104 - float16Comparisons(should FAIL: inf != 1) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: 1 (operandRight) + found: inf (operandLeft) + expected: 1 (operandRight) + actual: inf (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 105 - float16Comparisons(should FAIL: 1 != inf) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: inf (operandRight) + found: 1 (operandLeft) + expected: inf (operandRight) + actual: 1 (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 106 - float16Comparisons(should FAIL: -inf != 1) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: 1 (operandRight) + found: -inf (operandLeft) + expected: 1 (operandRight) + actual: -inf (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 107 - float16Comparisons(should FAIL: 1 != -inf) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: -inf (operandRight) + found: 1 (operandLeft) + expected: -inf (operandRight) + actual: 1 (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 108 - float16Comparisons(should FAIL: inf != max) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: 6.55e+04 (operandRight) + found: inf (operandLeft) + expected: 6.55e+04 (operandRight) + actual: inf (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 109 - float16Comparisons(should FAIL: inf != -max) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: -6.55e+04 (operandRight) + found: inf (operandLeft) + expected: -6.55e+04 (operandRight) + actual: inf (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 110 - float16Comparisons(should FAIL: max != inf) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: inf (operandRight) + found: 6.55e+04 (operandLeft) + expected: inf (operandRight) + actual: 6.55e+04 (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 111 - float16Comparisons(should FAIL: -max != inf) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: inf (operandRight) + found: -6.55e+04 (operandLeft) + expected: inf (operandRight) + actual: -6.55e+04 (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 112 - float16Comparisons(should FAIL: -inf != max) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: 6.55e+04 (operandRight) + found: -inf (operandLeft) + expected: 6.55e+04 (operandRight) + actual: -inf (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 113 - float16Comparisons(should FAIL: -inf != -max) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: -6.55e+04 (operandRight) + found: -inf (operandLeft) + expected: -6.55e+04 (operandRight) + actual: -inf (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 114 - float16Comparisons(should FAIL: max != -inf) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: -inf (operandRight) + found: 6.55e+04 (operandLeft) + expected: -inf (operandRight) + actual: 6.55e+04 (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 115 - float16Comparisons(should FAIL: -max != -inf) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: -inf (operandRight) + found: -6.55e+04 (operandLeft) + expected: -inf (operandRight) + actual: -6.55e+04 (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 116 - compareFloatTests(1e0) --- type: QCOMPARE message: Compared floats are not the same (fuzzy compare) @@ -805,11 +1146,11 @@ not ok 83 - compareFloatTests(1e0) found: 1 (t1) expected: 3 (t3) actual: 1 (t1) - at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:216) + at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:210) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 216 + line: 210 ... -not ok 84 - compareFloatTests(1e-7) +not ok 117 - compareFloatTests(1e-7) --- type: QCOMPARE message: Compared floats are not the same (fuzzy compare) @@ -817,11 +1158,11 @@ not ok 84 - compareFloatTests(1e-7) found: 1e-07 (t1) expected: 3e-07 (t3) actual: 1e-07 (t1) - at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:216) + at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:210) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 216 + line: 210 ... -not ok 85 - compareFloatTests(1e+7) +not ok 118 - compareFloatTests(1e+7) --- type: QCOMPARE message: Compared floats are not the same (fuzzy compare) @@ -829,12 +1170,12 @@ not ok 85 - compareFloatTests(1e+7) found: 1e+07 (t1) expected: 3e+07 (t3) actual: 1e+07 (t1) - at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:216) + at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:210) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 216 + line: 210 ... -ok 86 - cleanupTestCase() -1..86 -# tests 86 -# pass 18 -# fail 68 +ok 119 - cleanupTestCase() +1..119 +# tests 119 +# pass 23 +# fail 96 diff --git a/tests/auto/testlib/selftests/expected_float.teamcity b/tests/auto/testlib/selftests/expected_float.teamcity index eb99d3f6ea..af81296c42 100644 --- a/tests/auto/testlib/selftests/expected_float.teamcity +++ b/tests/auto/testlib/selftests/expected_float.teamcity @@ -215,19 +215,113 @@ ##teamcity[testStarted name='floatComparisons(should FAIL: -max != -inf)' flowId='tst_float'] ##teamcity[testFailed name='floatComparisons(should FAIL: -max != -inf)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared floats are not the same (fuzzy compare)|n Actual (operandLeft) : -3.40282e+38|n Expected (operandRight): -inf' flowId='tst_float'] ##teamcity[testFinished name='floatComparisons(should FAIL: -max != -inf)' flowId='tst_float'] -##teamcity[testStarted name='float16Comparisons(should SUCCEED 1)' flowId='tst_float'] -##teamcity[testFinished name='float16Comparisons(should SUCCEED 1)' flowId='tst_float'] ##teamcity[testStarted name='float16Comparisons(should FAIL 1)' flowId='tst_float'] ##teamcity[testFailed name='float16Comparisons(should FAIL 1)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 1|n Expected (operandRight): 3' flowId='tst_float'] ##teamcity[testFinished name='float16Comparisons(should FAIL 1)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should PASS 1)' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should PASS 1)' flowId='tst_float'] ##teamcity[testStarted name='float16Comparisons(should FAIL 2)' flowId='tst_float'] ##teamcity[testFailed name='float16Comparisons(should FAIL 2)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 0.0001|n Expected (operandRight): 0.0003' flowId='tst_float'] ##teamcity[testFinished name='float16Comparisons(should FAIL 2)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should PASS 2)' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should PASS 2)' flowId='tst_float'] ##teamcity[testStarted name='float16Comparisons(should FAIL 3)' flowId='tst_float'] ##teamcity[testFailed name='float16Comparisons(should FAIL 3)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 98|n Expected (operandRight): 99' flowId='tst_float'] ##teamcity[testFinished name='float16Comparisons(should FAIL 3)' flowId='tst_float'] -##teamcity[testStarted name='float16Comparisons(should SUCCEED 2)' flowId='tst_float'] -##teamcity[testFinished name='float16Comparisons(should SUCCEED 2)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should PASS 3)' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should PASS 3)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL 4)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL 4)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 5.93e-05|n Expected (operandRight): 5.87e-05' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL 4)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should PASS 4)' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should PASS 4)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL 5)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL 5)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 5.94e+04|n Expected (operandRight): 5.88e+04' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL 5)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should PASS: NaN == NaN)' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should PASS: NaN == NaN)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: NaN != 0)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: NaN != 0)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : nan|n Expected (operandRight): 0' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: NaN != 0)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: 0 != NaN)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: 0 != NaN)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 0|n Expected (operandRight): nan' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: 0 != NaN)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: NaN != 1)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: NaN != 1)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : nan|n Expected (operandRight): 1' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: NaN != 1)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: 1 != NaN)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: 1 != NaN)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 1|n Expected (operandRight): nan' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: 1 != NaN)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should PASS: inf == inf)' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should PASS: inf == inf)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should PASS: -inf == -inf)' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should PASS: -inf == -inf)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: inf != -inf)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: inf != -inf)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : inf|n Expected (operandRight): -inf' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: inf != -inf)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: -inf != inf)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: -inf != inf)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : -inf|n Expected (operandRight): inf' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: -inf != inf)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: inf != nan)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: inf != nan)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : inf|n Expected (operandRight): nan' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: inf != nan)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: nan != inf)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: nan != inf)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : nan|n Expected (operandRight): inf' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: nan != inf)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: -inf != nan)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: -inf != nan)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : -inf|n Expected (operandRight): nan' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: -inf != nan)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: nan != -inf)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: nan != -inf)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : nan|n Expected (operandRight): -inf' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: nan != -inf)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: inf != 0)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: inf != 0)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : inf|n Expected (operandRight): 0' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: inf != 0)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: 0 != inf)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: 0 != inf)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 0|n Expected (operandRight): inf' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: 0 != inf)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: -inf != 0)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: -inf != 0)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : -inf|n Expected (operandRight): 0' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: -inf != 0)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: 0 != -inf)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: 0 != -inf)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 0|n Expected (operandRight): -inf' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: 0 != -inf)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: inf != 1)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: inf != 1)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : inf|n Expected (operandRight): 1' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: inf != 1)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: 1 != inf)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: 1 != inf)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 1|n Expected (operandRight): inf' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: 1 != inf)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: -inf != 1)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: -inf != 1)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : -inf|n Expected (operandRight): 1' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: -inf != 1)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: 1 != -inf)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: 1 != -inf)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 1|n Expected (operandRight): -inf' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: 1 != -inf)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: inf != max)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: inf != max)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : inf|n Expected (operandRight): 6.55e+04' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: inf != max)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: inf != -max)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: inf != -max)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : inf|n Expected (operandRight): -6.55e+04' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: inf != -max)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: max != inf)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: max != inf)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 6.55e+04|n Expected (operandRight): inf' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: max != inf)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: -max != inf)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: -max != inf)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : -6.55e+04|n Expected (operandRight): inf' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: -max != inf)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: -inf != max)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: -inf != max)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : -inf|n Expected (operandRight): 6.55e+04' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: -inf != max)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: -inf != -max)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: -inf != -max)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : -inf|n Expected (operandRight): -6.55e+04' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: -inf != -max)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: max != -inf)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: max != -inf)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 6.55e+04|n Expected (operandRight): -inf' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: max != -inf)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: -max != -inf)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: -max != -inf)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : -6.55e+04|n Expected (operandRight): -inf' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: -max != -inf)' flowId='tst_float'] ##teamcity[testStarted name='compareFloatTests(1e0)' flowId='tst_float'] ##teamcity[testFailed name='compareFloatTests(1e0)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared floats are not the same (fuzzy compare)|n Actual (t1): 1|n Expected (t3): 3' flowId='tst_float'] ##teamcity[testFinished name='compareFloatTests(1e0)' flowId='tst_float'] diff --git a/tests/auto/testlib/selftests/expected_float.txt b/tests/auto/testlib/selftests/expected_float.txt index 18a5bab628..d22a52a63d 100644 --- a/tests/auto/testlib/selftests/expected_float.txt +++ b/tests/auto/testlib/selftests/expected_float.txt @@ -263,20 +263,137 @@ FAIL! : tst_float::floatComparisons(should FAIL: -max != -inf) Compared floats Actual (operandLeft) : -3.40282e+38 Expected (operandRight): -inf Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] -PASS : tst_float::float16Comparisons(should SUCCEED 1) FAIL! : tst_float::float16Comparisons(should FAIL 1) Compared qfloat16s are not the same (fuzzy compare) Actual (operandLeft) : 1 Expected (operandRight): 3 Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +PASS : tst_float::float16Comparisons(should PASS 1) FAIL! : tst_float::float16Comparisons(should FAIL 2) Compared qfloat16s are not the same (fuzzy compare) Actual (operandLeft) : 0.0001 Expected (operandRight): 0.0003 Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +PASS : tst_float::float16Comparisons(should PASS 2) FAIL! : tst_float::float16Comparisons(should FAIL 3) Compared qfloat16s are not the same (fuzzy compare) Actual (operandLeft) : 98 Expected (operandRight): 99 Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] -PASS : tst_float::float16Comparisons(should SUCCEED 2) +PASS : tst_float::float16Comparisons(should PASS 3) +FAIL! : tst_float::float16Comparisons(should FAIL 4) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 5.93e-05 + Expected (operandRight): 5.87e-05 + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +PASS : tst_float::float16Comparisons(should PASS 4) +FAIL! : tst_float::float16Comparisons(should FAIL 5) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 5.94e+04 + Expected (operandRight): 5.88e+04 + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +PASS : tst_float::float16Comparisons(should PASS: NaN == NaN) +FAIL! : tst_float::float16Comparisons(should FAIL: NaN != 0) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : nan + Expected (operandRight): 0 + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: 0 != NaN) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 0 + Expected (operandRight): nan + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: NaN != 1) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : nan + Expected (operandRight): 1 + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: 1 != NaN) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 1 + Expected (operandRight): nan + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +PASS : tst_float::float16Comparisons(should PASS: inf == inf) +PASS : tst_float::float16Comparisons(should PASS: -inf == -inf) +FAIL! : tst_float::float16Comparisons(should FAIL: inf != -inf) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): -inf + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: -inf != inf) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): inf + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: inf != nan) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): nan + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: nan != inf) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : nan + Expected (operandRight): inf + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: -inf != nan) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): nan + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: nan != -inf) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : nan + Expected (operandRight): -inf + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: inf != 0) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): 0 + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: 0 != inf) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 0 + Expected (operandRight): inf + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: -inf != 0) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): 0 + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: 0 != -inf) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 0 + Expected (operandRight): -inf + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: inf != 1) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): 1 + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: 1 != inf) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 1 + Expected (operandRight): inf + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: -inf != 1) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): 1 + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: 1 != -inf) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 1 + Expected (operandRight): -inf + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: inf != max) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): 6.55e+04 + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: inf != -max) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): -6.55e+04 + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: max != inf) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 6.55e+04 + Expected (operandRight): inf + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: -max != inf) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -6.55e+04 + Expected (operandRight): inf + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: -inf != max) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): 6.55e+04 + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: -inf != -max) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): -6.55e+04 + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: max != -inf) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 6.55e+04 + Expected (operandRight): -inf + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: -max != -inf) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -6.55e+04 + Expected (operandRight): -inf + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] FAIL! : tst_float::compareFloatTests(1e0) Compared floats are not the same (fuzzy compare) Actual (t1): 1 Expected (t3): 3 @@ -290,5 +407,5 @@ FAIL! : tst_float::compareFloatTests(1e+7) Compared floats are not the same (fu Expected (t3): 3e+07 Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] PASS : tst_float::cleanupTestCase() -Totals: 18 passed, 68 failed, 0 skipped, 0 blacklisted, 0ms +Totals: 23 passed, 96 failed, 0 skipped, 0 blacklisted, 0ms ********* Finished testing of tst_float ********* diff --git a/tests/auto/testlib/selftests/expected_float.xml b/tests/auto/testlib/selftests/expected_float.xml index b8e1a23616..247bce9577 100644 --- a/tests/auto/testlib/selftests/expected_float.xml +++ b/tests/auto/testlib/selftests/expected_float.xml @@ -430,21 +430,24 @@ - - - + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/expected_float.xunitxml b/tests/auto/testlib/selftests/expected_float.xunitxml index 9b2af9b616..602f9252a4 100644 --- a/tests/auto/testlib/selftests/expected_float.xunitxml +++ b/tests/auto/testlib/selftests/expected_float.xunitxml @@ -1,5 +1,5 @@ - + @@ -206,6 +206,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + ("operandRight"); + qfloat16 zero(0), one(1); - QTest::newRow("should SUCCEED 1") - << qfloat16(0) - << qfloat16(0); - - QTest::newRow("should FAIL 1") - << qfloat16(1.000) - << qfloat16(3.000); - - QTest::newRow("should FAIL 2") - << qfloat16(1.000e-4f) - << qfloat16(3.000e-4f); + QTest::newRow("should FAIL 1") << one << qfloat16(3); + QTest::newRow("should PASS 1") << zero << zero; + QTest::newRow("should FAIL 2") << qfloat16(1e-4f) << qfloat16(3e-4f); // QCOMPARE for qfloat16s uses qFuzzyCompare() + QTest::newRow("should PASS 2") << qfloat16(1001) << qfloat16(1002); + QTest::newRow("should FAIL 3") << qfloat16(98) << qfloat16(99); + // ... which gets a bit unreliable near to the type's bounds + QTest::newRow("should PASS 3") << qfloat16(6e-5f) + qfloat16(6e-7f) << qfloat16(6e-5f) + qfloat16(11e-7f); + QTest::newRow("should FAIL 4") << qfloat16(6e-5f) - qfloat16(7e-7f) << qfloat16(6e-5f) - qfloat16(13e-7f); + QTest::newRow("should PASS 4") << qfloat16(6e4) + qfloat16(700) << qfloat16(6e4) + qfloat16(1200); + QTest::newRow("should FAIL 5") << qfloat16(6e4) - qfloat16(600) << qfloat16(6e4) - qfloat16(1200); - QTest::newRow("should FAIL 3") - << qfloat16(98) - << qfloat16(99); - - QTest::newRow("should SUCCEED 2") - << qfloat16(1001) - << qfloat16(1002); + nonFinite_data(zero, one); } void tst_float::compareFloatTests() const From 80853afd732aba126caa138ac421b036d2005f8d Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 23 Aug 2018 18:04:07 +0200 Subject: [PATCH 202/292] Add startOfDay() and endOfDay() methods to QDate These methods give the first and last QDateTime values in the given day, for a given time-zone or time-spec. These are usually the relevant midnight, or the millisecond before, except when time-zone transitions (typically DST changes) skip it, when care is needed to select the right moment. Adapted some code to make use of the new API, eliminating some old cruft from qdatetimeparser_p.h in the process. [ChangeLog][QtCore][QDate] Added startOfDay() and endOfDay() methods to provide a QDateTime at the start and end of a given date, taking account of any time skipped by transitions, e.g. a DST spring-forward, which can lead to a day starting at 01:00 or ending just before 23:00. Task-number: QTBUG-64485 Change-Id: I3dd7a34bedfbec8f8af00c43d13f50f99346ecd0 Reviewed-by: Thiago Macieira --- .../code/src_corelib_tools_qdatetime.cpp | 2 +- src/corelib/tools/qdatetime.cpp | 271 +++++++++++++++++- src/corelib/tools/qdatetime.h | 10 +- src/corelib/tools/qdatetimeparser.cpp | 10 +- src/corelib/tools/qdatetimeparser_p.h | 7 +- src/widgets/widgets/qabstractspinbox.cpp | 2 +- src/widgets/widgets/qdatetimeedit.cpp | 19 +- tests/auto/corelib/tools/qdate/qdate.pro | 2 +- tests/auto/corelib/tools/qdate/tst_qdate.cpp | 168 ++++++++++- 9 files changed, 462 insertions(+), 29 deletions(-) diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qdatetime.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qdatetime.cpp index 3ecb67a48f..a477e91548 100644 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qdatetime.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_tools_qdatetime.cpp @@ -128,7 +128,7 @@ qDebug("Time elapsed: %d ms", t.elapsed()); //! [11] QDateTime now = QDateTime::currentDateTime(); -QDateTime xmas(QDate(now.date().year(), 12, 25), QTime(0, 0)); +QDateTime xmas(QDate(now.date().year(), 12, 25).startOfDay()); qDebug("There are %d seconds to Christmas", now.secsTo(xmas)); //! [11] diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 6fa735dab7..cc98f80feb 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Copyright (C) 2016 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** @@ -617,6 +617,268 @@ int QDate::weekNumber(int *yearNumber) const return week; } +static bool inDateTimeRange(qint64 jd, bool start) +{ + using Bounds = std::numeric_limits; + if (jd < Bounds::min() + JULIAN_DAY_FOR_EPOCH) + return false; + jd -= JULIAN_DAY_FOR_EPOCH; + const qint64 maxDay = Bounds::max() / MSECS_PER_DAY; + const qint64 minDay = Bounds::min() / MSECS_PER_DAY - 1; + // (Divisions rounded towards zero, as MSECS_PER_DAY has factors other than two.) + // Range includes start of last day and end of first: + if (start) + return jd > minDay && jd <= maxDay; + return jd >= minDay && jd < maxDay; +} + +static QDateTime toEarliest(const QDate &day, const QDateTime &form) +{ + const Qt::TimeSpec spec = form.timeSpec(); + const int offset = (spec == Qt::OffsetFromUTC) ? form.offsetFromUtc() : 0; +#if QT_CONFIG(timezone) + QTimeZone zone; + if (spec == Qt::TimeZone) + zone = form.timeZone(); +#endif + auto moment = [=](QTime time) { + switch (spec) { + case Qt::OffsetFromUTC: return QDateTime(day, time, spec, offset); +#if QT_CONFIG(timezone) + case Qt::TimeZone: return QDateTime(day, time, zone); +#endif + default: return QDateTime(day, time, spec); + } + }; + // Longest routine time-zone transition is 2 hours: + QDateTime when = moment(QTime(2, 0)); + if (!when.isValid()) { + // Noon should be safe ... + when = moment(QTime(12, 0)); + if (!when.isValid()) { + // ... unless it's a 24-hour jump (moving the date-line) + when = moment(QTime(23, 59, 59, 999)); + if (!when.isValid()) + return QDateTime(); + } + } + int high = when.time().msecsSinceStartOfDay() / 60000; + int low = 0; + // Binary chop to the right minute + while (high > low + 1) { + int mid = (high + low) / 2; + QDateTime probe = moment(QTime(mid / 60, mid % 60)); + if (probe.isValid() && probe.date() == day) { + high = mid; + when = probe; + } else { + low = mid; + } + } + return when; +} + +/*! + \since 5.14 + \fn QDateTime QDate::startOfDay(Qt::TimeSpec spec, int offsetSeconds) const + \fn QDateTime QDate::startOfDay(const QTimeZone &zone) const + + Returns the start-moment of the day. Usually, this shall be midnight at the + start of the day: however, if a time-zone transition causes the given date + to skip over that midnight (e.g. a DST spring-forward skipping from the end + of the previous day to 01:00 of the new day), the actual earliest time in + the day is returned. This can only arise when the start-moment is specified + in terms of a time-zone (by passing its QTimeZone as \a zone) or in terms of + local time (by passing Qt::LocalTime as \a spec; this is its default). + + The \a offsetSeconds is ignored unless \a spec is Qt::OffsetFromUTC, when it + gives the implied zone's offset from UTC. As UTC and such zones have no + transitions, the start of the day is QTime(0, 0) in these cases. + + In the rare case of a date that was entirely skipped (this happens when a + zone east of the international date-line switches to being west of it), the + return shall be invalid. Passing Qt::TimeZone as \a spec (instead of + passing a QTimeZone) or passing an invalid time-zone as \a zone will also + produce an invalid result, as shall dates that start outside the range + representable by QDateTime. + + \sa endOfDay() +*/ +QDateTime QDate::startOfDay(Qt::TimeSpec spec, int offsetSeconds) const +{ + if (!inDateTimeRange(jd, true)) + return QDateTime(); + + switch (spec) { + case Qt::TimeZone: // should pass a QTimeZone instead of Qt::TimeZone + qWarning() << "Called QDate::startOfDay(Qt::TimeZone) on" << *this; + return QDateTime(); + case Qt::OffsetFromUTC: + case Qt::UTC: + return QDateTime(*this, QTime(0, 0), spec, offsetSeconds); + + case Qt::LocalTime: + if (offsetSeconds) + qWarning("Ignoring offset (%d seconds) passed with Qt::LocalTime", offsetSeconds); + break; + } + QDateTime when(*this, QTime(0, 0), spec); + if (!when.isValid()) + when = toEarliest(*this, when); + + return when.isValid() ? when : QDateTime(); +} + +#if QT_CONFIG(timezone) +/*! + \overload + \since 5.14 +*/ +QDateTime QDate::startOfDay(const QTimeZone &zone) const +{ + if (!inDateTimeRange(jd, true) || !zone.isValid()) + return QDateTime(); + + QDateTime when(*this, QTime(0, 0), zone); + if (when.isValid()) + return when; + + // The start of the day must have fallen in a spring-forward's gap; find the spring-forward: + if (zone.hasTransitions()) { + QTimeZone::OffsetData tran = zone.previousTransition(QDateTime(*this, QTime(23, 59, 59, 999), zone)); + const QDateTime &at = tran.atUtc.toTimeZone(zone); + if (at.isValid() && at.date() == *this) + return at; + } + + when = toEarliest(*this, when); + return when.isValid() ? when : QDateTime(); +} +#endif // timezone + +static QDateTime toLatest(const QDate &day, const QDateTime &form) +{ + const Qt::TimeSpec spec = form.timeSpec(); + const int offset = (spec == Qt::OffsetFromUTC) ? form.offsetFromUtc() : 0; +#if QT_CONFIG(timezone) + QTimeZone zone; + if (spec == Qt::TimeZone) + zone = form.timeZone(); +#endif + auto moment = [=](QTime time) { + switch (spec) { + case Qt::OffsetFromUTC: return QDateTime(day, time, spec, offset); +#if QT_CONFIG(timezone) + case Qt::TimeZone: return QDateTime(day, time, zone); +#endif + default: return QDateTime(day, time, spec); + } + }; + // Longest routine time-zone transition is 2 hours: + QDateTime when = moment(QTime(21, 59, 59, 999)); + if (!when.isValid()) { + // Noon should be safe ... + when = moment(QTime(12, 0)); + if (!when.isValid()) { + // ... unless it's a 24-hour jump (moving the date-line) + when = moment(QTime(0, 0)); + if (!when.isValid()) + return QDateTime(); + } + } + int high = 24 * 60; + int low = when.time().msecsSinceStartOfDay() / 60000; + // Binary chop to the right minute + while (high > low + 1) { + int mid = (high + low) / 2; + QDateTime probe = moment(QTime(mid / 60, mid % 60, 59, 999)); + if (probe.isValid() && probe.date() == day) { + low = mid; + when = probe; + } else { + high = mid; + } + } + return when; +} + +/*! + \since 5.14 + \fn QDateTime QDate::endOfDay(Qt::TimeSpec spec, int offsetSeconds) const + \fn QDateTime QDate::endOfDay(const QTimeZone &zone) const + + Returns the end-moment of the day. Usually, this is one millisecond before + the midnight at the end of the day: however, if a time-zone transition + causes the given date to skip over that midnight (e.g. a DST spring-forward + skipping from just before 23:00 to the start of the next day), the actual + latest time in the day is returned. This can only arise when the + start-moment is specified in terms of a time-zone (by passing its QTimeZone + as \a zone) or in terms of local time (by passing Qt::LocalTime as \a spec; + this is its default). + + The \a offsetSeconds is ignored unless \a spec is Qt::OffsetFromUTC, when it + gives the implied zone's offset from UTC. As UTC and such zones have no + transitions, the end of the day is QTime(23, 59, 59, 999) in these cases. + + In the rare case of a date that was entirely skipped (this happens when a + zone east of the international date-line switches to being west of it), the + return shall be invalid. Passing Qt::TimeZone as \a spec (instead of + passing a QTimeZone) will also produce an invalid result, as shall dates + that end outside the range representable by QDateTime. + + \sa startOfDay() +*/ +QDateTime QDate::endOfDay(Qt::TimeSpec spec, int offsetSeconds) const +{ + if (!inDateTimeRange(jd, false)) + return QDateTime(); + + switch (spec) { + case Qt::TimeZone: // should pass a QTimeZone instead of Qt::TimeZone + qWarning() << "Called QDate::endOfDay(Qt::TimeZone) on" << *this; + return QDateTime(); + case Qt::UTC: + case Qt::OffsetFromUTC: + return QDateTime(*this, QTime(23, 59, 59, 999), spec, offsetSeconds); + + case Qt::LocalTime: + if (offsetSeconds) + qWarning("Ignoring offset (%d seconds) passed with Qt::LocalTime", offsetSeconds); + break; + } + QDateTime when(*this, QTime(23, 59, 59, 999), spec); + if (!when.isValid()) + when = toLatest(*this, when); + return when.isValid() ? when : QDateTime(); +} + +#if QT_CONFIG(timezone) +/*! + \overload + \since 5.14 +*/ +QDateTime QDate::endOfDay(const QTimeZone &zone) const +{ + if (!inDateTimeRange(jd, false) || !zone.isValid()) + return QDateTime(); + + QDateTime when(*this, QTime(23, 59, 59, 999), zone); + if (when.isValid()) + return when; + + // The end of the day must have fallen in a spring-forward's gap; find the spring-forward: + if (zone.hasTransitions()) { + QTimeZone::OffsetData tran = zone.nextTransition(QDateTime(*this, QTime(0, 0), zone)); + const QDateTime &at = tran.atUtc.toTimeZone(zone); + if (at.isValid() && at.date() == *this) + return at; + } + + when = toLatest(*this, when); + return when.isValid() ? when : QDateTime(); +} +#endif // timezone + #if QT_DEPRECATED_SINCE(5, 11) && QT_CONFIG(textdate) /*! \since 4.5 @@ -1468,7 +1730,8 @@ bool QDate::isLeapYear(int y) \fn QTime::QTime() Constructs a null time object. For a null time, isNull() returns \c true and - isValid() returns \c false. If you need a zero time, use QTime(0, 0). + isValid() returns \c false. If you need a zero time, use QTime(0, 0). For + the start of a day, see QDate::startOfDay(). \sa isNull(), isValid() */ @@ -2392,8 +2655,8 @@ static void msecsToTime(qint64 msecs, QDate *date, QTime *time) qint64 jd = JULIAN_DAY_FOR_EPOCH; qint64 ds = 0; - if (qAbs(msecs) >= MSECS_PER_DAY) { - jd += (msecs / MSECS_PER_DAY); + if (msecs >= MSECS_PER_DAY || msecs <= -MSECS_PER_DAY) { + jd += msecs / MSECS_PER_DAY; msecs %= MSECS_PER_DAY; } diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h index 51d5dd9759..8873651f17 100644 --- a/src/corelib/tools/qdatetime.h +++ b/src/corelib/tools/qdatetime.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Copyright (C) 2016 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** @@ -55,6 +55,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(NSDate); QT_BEGIN_NAMESPACE class QTimeZone; +class QDateTime; class Q_CORE_EXPORT QDate { @@ -81,6 +82,13 @@ public: int daysInYear() const; int weekNumber(int *yearNum = nullptr) const; + QDateTime startOfDay(Qt::TimeSpec spec = Qt::LocalTime, int offsetSeconds = 0) const; + QDateTime endOfDay(Qt::TimeSpec spec = Qt::LocalTime, int offsetSeconds = 0) const; +#if QT_CONFIG(timezone) + QDateTime startOfDay(const QTimeZone &zone) const; + QDateTime endOfDay(const QTimeZone &zone) const; +#endif + #if QT_DEPRECATED_SINCE(5, 10) && QT_CONFIG(textdate) QT_DEPRECATED_X("Use QLocale::monthName or QLocale::standaloneMonthName") static QString shortMonthName(int month, MonthNameType type = DateFormat); diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp index 5d1704daeb..e1dc596d2d 100644 --- a/src/corelib/tools/qdatetimeparser.cpp +++ b/src/corelib/tools/qdatetimeparser.cpp @@ -1982,7 +1982,7 @@ QString QDateTimeParser::stateName(State s) const #if QT_CONFIG(datestring) bool QDateTimeParser::fromString(const QString &t, QDate *date, QTime *time) const { - QDateTime val(QDate(1900, 1, 1), QDATETIMEEDIT_TIME_MIN); + QDateTime val(QDate(1900, 1, 1).startOfDay()); const StateNode tmp = parse(t, -1, val, false); if (tmp.state != Acceptable || tmp.conflicts) { return false; @@ -2010,20 +2010,20 @@ QDateTime QDateTimeParser::getMinimum() const { // Cache the most common case if (spec == Qt::LocalTime) { - static const QDateTime localTimeMin(QDATETIMEEDIT_DATE_MIN, QDATETIMEEDIT_TIME_MIN, Qt::LocalTime); + static const QDateTime localTimeMin(QDATETIMEEDIT_DATE_MIN.startOfDay(Qt::LocalTime)); return localTimeMin; } - return QDateTime(QDATETIMEEDIT_DATE_MIN, QDATETIMEEDIT_TIME_MIN, spec); + return QDateTime(QDATETIMEEDIT_DATE_MIN.startOfDay(spec)); } QDateTime QDateTimeParser::getMaximum() const { // Cache the most common case if (spec == Qt::LocalTime) { - static const QDateTime localTimeMax(QDATETIMEEDIT_DATE_MAX, QDATETIMEEDIT_TIME_MAX, Qt::LocalTime); + static const QDateTime localTimeMax(QDATETIMEEDIT_DATE_MAX.endOfDay(Qt::LocalTime)); return localTimeMax; } - return QDateTime(QDATETIMEEDIT_DATE_MAX, QDATETIMEEDIT_TIME_MAX, spec); + return QDateTime(QDATETIMEEDIT_DATE_MAX.endOfDay(spec)); } QString QDateTimeParser::getAmPmText(AmPm ap, Case cs) const diff --git a/src/corelib/tools/qdatetimeparser_p.h b/src/corelib/tools/qdatetimeparser_p.h index e244fed09a..d9e39f0795 100644 --- a/src/corelib/tools/qdatetimeparser_p.h +++ b/src/corelib/tools/qdatetimeparser_p.h @@ -65,14 +65,11 @@ QT_REQUIRE_CONFIG(datetimeparser); -#define QDATETIMEEDIT_TIME_MIN QTime(0, 0, 0, 0) -#define QDATETIMEEDIT_TIME_MAX QTime(23, 59, 59, 999) +#define QDATETIMEEDIT_TIME_MIN QTime(0, 0) // Prefer QDate::startOfDay() +#define QDATETIMEEDIT_TIME_MAX QTime(23, 59, 59, 999) // Prefer QDate::endOfDay() #define QDATETIMEEDIT_DATE_MIN QDate(100, 1, 1) #define QDATETIMEEDIT_COMPAT_DATE_MIN QDate(1752, 9, 14) #define QDATETIMEEDIT_DATE_MAX QDate(9999, 12, 31) -#define QDATETIMEEDIT_DATETIME_MIN QDateTime(QDATETIMEEDIT_DATE_MIN, QDATETIMEEDIT_TIME_MIN) -#define QDATETIMEEDIT_COMPAT_DATETIME_MIN QDateTime(QDATETIMEEDIT_COMPAT_DATE_MIN, QDATETIMEEDIT_TIME_MIN) -#define QDATETIMEEDIT_DATETIME_MAX QDateTime(QDATETIMEEDIT_DATE_MAX, QDATETIMEEDIT_TIME_MAX) #define QDATETIMEEDIT_DATE_INITIAL QDate(2000, 1, 1) QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index c617525c45..56697c5e8f 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -2097,7 +2097,7 @@ QVariant operator*(const QVariant &arg1, double multiplier) days -= daysInt; qint64 msecs = qint64(arg1.toDateTime().time().msecsSinceStartOfDay() * multiplier + days * (24 * 3600 * 1000)); - ret = QDateTime(QDATETIMEEDIT_DATE_MIN.addDays(daysInt), QTime::fromMSecsSinceStartOfDay(msecs)); + ret = QDATETIMEEDIT_DATE_MIN.addDays(daysInt).startOfDay().addMSecs(msecs); break; } #endif // datetimeparser diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index b874e4e3a9..3f41fdeb59 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -153,7 +153,7 @@ QDateTimeEdit::QDateTimeEdit(QWidget *parent) : QAbstractSpinBox(*new QDateTimeEditPrivate, parent) { Q_D(QDateTimeEdit); - d->init(QDateTime(QDATETIMEEDIT_DATE_INITIAL, QDATETIMEEDIT_TIME_MIN)); + d->init(QDATETIMEEDIT_DATE_INITIAL.startOfDay()); } /*! @@ -165,8 +165,7 @@ QDateTimeEdit::QDateTimeEdit(const QDateTime &datetime, QWidget *parent) : QAbstractSpinBox(*new QDateTimeEditPrivate, parent) { Q_D(QDateTimeEdit); - d->init(datetime.isValid() ? datetime : QDateTime(QDATETIMEEDIT_DATE_INITIAL, - QDATETIMEEDIT_TIME_MIN)); + d->init(datetime.isValid() ? datetime : QDATETIMEEDIT_DATE_INITIAL.startOfDay()); } /*! @@ -342,7 +341,7 @@ QDateTime QDateTimeEdit::minimumDateTime() const void QDateTimeEdit::clearMinimumDateTime() { - setMinimumDateTime(QDateTime(QDATETIMEEDIT_COMPAT_DATE_MIN, QDATETIMEEDIT_TIME_MIN)); + setMinimumDateTime(QDATETIMEEDIT_COMPAT_DATE_MIN.startOfDay()); } void QDateTimeEdit::setMinimumDateTime(const QDateTime &dt) @@ -385,7 +384,7 @@ QDateTime QDateTimeEdit::maximumDateTime() const void QDateTimeEdit::clearMaximumDateTime() { - setMaximumDateTime(QDATETIMEEDIT_DATETIME_MAX); + setMaximumDateTime(QDATETIMEEDIT_DATE_MAX.endOfDay()); } void QDateTimeEdit::setMaximumDateTime(const QDateTime &dt) @@ -1658,8 +1657,8 @@ QDateTimeEditPrivate::QDateTimeEditPrivate() first.pos = 0; sections = 0; calendarPopup = false; - minimum = QDATETIMEEDIT_COMPAT_DATETIME_MIN; - maximum = QDATETIMEEDIT_DATETIME_MAX; + minimum = QDATETIMEEDIT_COMPAT_DATE_MIN.startOfDay(); + maximum = QDATETIMEEDIT_DATE_MAX.endOfDay(); arrowState = QStyle::State_None; monthCalendar = 0; readLocaleSettings(); @@ -1683,8 +1682,8 @@ void QDateTimeEditPrivate::updateTimeSpec() const bool dateShown = (sections & QDateTimeEdit::DateSections_Mask); if (!dateShown) { if (minimum.toTime() >= maximum.toTime()){ - minimum = QDateTime(value.toDate(), QDATETIMEEDIT_TIME_MIN, spec); - maximum = QDateTime(value.toDate(), QDATETIMEEDIT_TIME_MAX, spec); + minimum = value.toDate().startOfDay(spec); + maximum = value.toDate().endOfDay(spec); } } } @@ -2382,7 +2381,7 @@ void QDateTimeEditPrivate::init(const QVariant &var) Q_Q(QDateTimeEdit); switch (var.type()) { case QVariant::Date: - value = QDateTime(var.toDate(), QDATETIMEEDIT_TIME_MIN); + value = var.toDate().startOfDay(); updateTimeSpec(); q->setDisplayFormat(defaultDateFormat); if (sectionNodes.isEmpty()) // ### safeguard for broken locale diff --git a/tests/auto/corelib/tools/qdate/qdate.pro b/tests/auto/corelib/tools/qdate/qdate.pro index dd7c6cb888..925c3b4c78 100644 --- a/tests/auto/corelib/tools/qdate/qdate.pro +++ b/tests/auto/corelib/tools/qdate/qdate.pro @@ -1,4 +1,4 @@ CONFIG += testcase TARGET = tst_qdate -QT = core testlib +QT = core-private testlib SOURCES = tst_qdate.cpp diff --git a/tests/auto/corelib/tools/qdate/tst_qdate.cpp b/tests/auto/corelib/tools/qdate/tst_qdate.cpp index c17af8741b..0ef494b229 100644 --- a/tests/auto/corelib/tools/qdate/tst_qdate.cpp +++ b/tests/auto/corelib/tools/qdate/tst_qdate.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Copyright (C) 2016 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** @@ -27,6 +27,7 @@ ** ****************************************************************************/ +#include // for the icu feature test #include #include #include @@ -54,6 +55,13 @@ private slots: void weekNumber_invalid(); void weekNumber_data(); void weekNumber(); +#if QT_CONFIG(timezone) + void startOfDay_endOfDay_data(); + void startOfDay_endOfDay(); +#endif + void startOfDay_endOfDay_fixed_data(); + void startOfDay_endOfDay_fixed(); + void startOfDay_endOfDay_bounds(); void julianDaysLimits(); void addDays_data(); void addDays(); @@ -458,6 +466,164 @@ void tst_QDate::weekNumber_invalid() QCOMPARE( dt.weekNumber( &yearNumber ), 0 ); } +#if QT_CONFIG(timezone) +void tst_QDate::startOfDay_endOfDay_data() +{ + QTest::addColumn("date"); // Typically a spring-forward. + // A zone in which that date's start and end are worth checking: + QTest::addColumn("zoneName"); + // The start and end times in that zone: + QTest::addColumn("start"); + QTest::addColumn("end"); + + const QTime initial(0, 0), final(23, 59, 59, 999), invalid(QDateTime().time()); + + QTest::newRow("epoch") + << QDate(1970, 1, 1) << QByteArray("UTC") + << initial << final; + QTest::newRow("Brazil") + << QDate(2008, 10, 19) << QByteArray("America/Sao_Paulo") + << QTime(1, 0) << final; +#if QT_CONFIG(icu) || !defined(Q_OS_WIN) // MS's TZ APIs lack data + QTest::newRow("Sofia") + << QDate(1994, 3, 27) << QByteArray("Europe/Sofia") + << QTime(1, 0) << final; +#endif + QTest::newRow("Kiritimati") + << QDate(1994, 12, 31) << QByteArray("Pacific/Kiritimati") + << invalid << invalid; + QTest::newRow("Samoa") + << QDate(2011, 12, 30) << QByteArray("Pacific/Apia") + << invalid << invalid; + // TODO: find other zones with transitions at/crossing midnight. +} + +void tst_QDate::startOfDay_endOfDay() +{ + QFETCH(QDate, date); + QFETCH(QByteArray, zoneName); + QFETCH(QTime, start); + QFETCH(QTime, end); + const QTimeZone zone(zoneName); + const bool isSystem = QTimeZone::systemTimeZone() == zone; + QDateTime front(date.startOfDay(zone)), back(date.endOfDay(zone)); + if (end.isValid()) + QCOMPARE(date.addDays(1).startOfDay(zone).addMSecs(-1), back); + if (start.isValid()) + QCOMPARE(date.addDays(-1).endOfDay(zone).addMSecs(1), front); + do { // Avoids duplicating these tests for local-time when it *is* zone: + if (start.isValid()) { + QCOMPARE(front.date(), date); + QCOMPARE(front.time(), start); + } + if (end.isValid()) { + QCOMPARE(back.date(), date); + QCOMPARE(back.time(), end); + } + if (front.timeSpec() == Qt::LocalTime) + break; + front = date.startOfDay(Qt::LocalTime); + back = date.endOfDay(Qt::LocalTime); + } while (isSystem); + if (end.isValid()) + QCOMPARE(date.addDays(1).startOfDay(Qt::LocalTime).addMSecs(-1), back); + if (start.isValid()) + QCOMPARE(date.addDays(-1).endOfDay(Qt::LocalTime).addMSecs(1), front); + if (!isSystem) { + // These might fail if system zone coincides with zone; but only if it + // did something similarly unusual on the date picked for this test. + if (start.isValid()) { + QCOMPARE(front.date(), date); + QCOMPARE(front.time(), QTime(0, 0)); + } + if (end.isValid()) { + QCOMPARE(back.date(), date); + QCOMPARE(back.time(), QTime(23, 59, 59, 999)); + } + } +} +#endif // timezone + +void tst_QDate::startOfDay_endOfDay_fixed_data() +{ + const qint64 kilo(1000); + using Bounds = std::numeric_limits; + const QDateTime + first(QDateTime::fromMSecsSinceEpoch(Bounds::min() + 1, Qt::UTC)), + start32sign(QDateTime::fromMSecsSinceEpoch(-0x80000000L * kilo, Qt::UTC)), + end32sign(QDateTime::fromMSecsSinceEpoch(0x80000000L * kilo, Qt::UTC)), + end32unsign(QDateTime::fromMSecsSinceEpoch(0x100000000L * kilo, Qt::UTC)), + last(QDateTime::fromMSecsSinceEpoch(Bounds::max(), Qt::UTC)); + + const struct { + const char *name; + QDate date; + } data[] = { + { "epoch", QDate(1970, 1, 1) }, + { "y2k-leap-day", QDate(2000, 2, 29) }, + // Just outside the start and end of 32-bit time_t: + { "pre-sign32", QDate(start32sign.date().year(), 1, 1) }, + { "post-sign32", QDate(end32sign.date().year(), 12, 31) }, + { "post-uint32", QDate(end32unsign.date().year(), 12, 31) }, + // Just inside the start and end of QDateTime's range: + { "first-full", first.date().addDays(1) }, + { "last-full", last.date().addDays(-1) } + }; + + QTest::addColumn("date"); + for (const auto &r : data) + QTest::newRow(r.name) << r.date; +} + +void tst_QDate::startOfDay_endOfDay_fixed() +{ + const QTime early(0, 0), late(23, 59, 59, 999); + QFETCH(QDate, date); + + QDateTime start(date.startOfDay(Qt::UTC)); + QDateTime end(date.endOfDay(Qt::UTC)); + QCOMPARE(start.date(), date); + QCOMPARE(end.date(), date); + QCOMPARE(start.time(), early); + QCOMPARE(end.time(), late); + QCOMPARE(date.addDays(1).startOfDay(Qt::UTC).addMSecs(-1), end); + QCOMPARE(date.addDays(-1).endOfDay(Qt::UTC).addMSecs(1), start); + for (int offset = -60 * 16; offset <= 60 * 16; offset += 65) { + start = date.startOfDay(Qt::OffsetFromUTC, offset); + end = date.endOfDay(Qt::OffsetFromUTC, offset); + QCOMPARE(start.date(), date); + QCOMPARE(end.date(), date); + QCOMPARE(start.time(), early); + QCOMPARE(end.time(), late); + QCOMPARE(date.addDays(1).startOfDay(Qt::OffsetFromUTC, offset).addMSecs(-1), end); + QCOMPARE(date.addDays(-1).endOfDay(Qt::OffsetFromUTC, offset).addMSecs(1), start); + } +} + +void tst_QDate::startOfDay_endOfDay_bounds() +{ + // Check the days in which QDateTime's range starts and ends: + using Bounds = std::numeric_limits; + const QDateTime + first(QDateTime::fromMSecsSinceEpoch(Bounds::min(), Qt::UTC)), + last(QDateTime::fromMSecsSinceEpoch(Bounds::max(), Qt::UTC)), + epoch(QDateTime::fromMSecsSinceEpoch(0, Qt::UTC)); + // First, check these *are* the start and end of QDateTime's range: + QVERIFY(first.isValid()); + QVERIFY(last.isValid()); + QVERIFY(first < epoch); + QVERIFY(last > epoch); + // QDateTime's addMSecs doesn't check against {und,ov}erflow ... + QVERIFY(!first.addMSecs(-1).isValid() || first.addMSecs(-1) > first); + QVERIFY(!last.addMSecs(1).isValid() || last.addMSecs(1) < last); + + // Now test start/end methods with them: + QCOMPARE(first.date().endOfDay(Qt::UTC).time(), QTime(23, 59, 59, 999)); + QCOMPARE(last.date().startOfDay(Qt::UTC).time(), QTime(0, 0)); + QVERIFY(!first.date().startOfDay(Qt::UTC).isValid()); + QVERIFY(!last.date().endOfDay(Qt::UTC).isValid()); +} + void tst_QDate::julianDaysLimits() { qint64 min = std::numeric_limits::min(); From ae38dd485bab4a0591745b78afa28547ce6ae6fc Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 24 Apr 2019 15:41:48 +0200 Subject: [PATCH 203/292] uic: Fix missing Python import for QFontComboBox It requires QFontDatabase from QtGui. Add more classes from QtGui. Fixes: PYSIDE-994 Change-Id: Ib84c86e2305fad60560a3f12997eb1e46deb67cb Reviewed-by: Cristian Maureira-Fredes --- src/tools/uic/python/pythonwriteimports.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tools/uic/python/pythonwriteimports.cpp b/src/tools/uic/python/pythonwriteimports.cpp index 8e11981f37..303615f77b 100644 --- a/src/tools/uic/python/pythonwriteimports.cpp +++ b/src/tools/uic/python/pythonwriteimports.cpp @@ -40,7 +40,9 @@ QT_BEGIN_NAMESPACE static const char *standardImports = R"I(from PySide2.QtCore import (QCoreApplication, QMetaObject, QObject, QPoint, QRect, QSize, QUrl, Qt) -from PySide2.QtGui import (QColor, QFont, QIcon, QPixmap) +from PySide2.QtGui import (QBrush, QColor, QConicalGradient, QFont, + QFontDatabase, QIcon, QLinearGradient, QPalette, QPainter, QPixmap, + QRadialGradient) from PySide2.QtWidgets import * )I"; From f10d37c9c10c323c37d5ec617588348458e7286f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Wed, 24 Apr 2019 15:57:55 +0200 Subject: [PATCH 204/292] Fix -Wc++11-narrowing error in qtextmarkdownimporter error: non-constant-expression cannot be narrowed from type 'qt::QFlags::Int' (aka 'int') to 'unsigned int' in initializer list [-Wc++11-narrowing] Change-Id: Ic634a98d29a108741d41955da1fbf2c986e4a943 Reviewed-by: Shawn Rutledge --- src/gui/text/qtextmarkdownimporter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp index 6c053ac81a..6bff337ff4 100644 --- a/src/gui/text/qtextmarkdownimporter.cpp +++ b/src/gui/text/qtextmarkdownimporter.cpp @@ -117,7 +117,7 @@ void QTextMarkdownImporter::import(QTextDocument *doc, const QString &markdown) { MD_PARSER callbacks = { 0, // abi_version - m_features, + unsigned(m_features), &CbEnterBlock, &CbLeaveBlock, &CbEnterSpan, From e6d9617c79ea029cf60c5555a3d7a32bac1cdbf6 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 3 Mar 2016 20:20:42 +0100 Subject: [PATCH 205/292] QHash/QMultiHash: add range constructors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QMap and QMultiMap will go in a separate commit, due to QMap's insertion behavior that "reverses" the inserted elements. [ChangeLog][QtCore][QHash] Added range constructor. [ChangeLog][QtCore][QMultiHash] Added range constructor. Change-Id: Icfd0d0afde27792e8439ed6df3e8774696b134d3 Reviewed-by: Edward Welbourne Reviewed-by: Sérgio Martins Reviewed-by: Thiago Macieira --- src/corelib/tools/qcontainertools_impl.h | 43 ++++++ src/corelib/tools/qhash.cpp | 22 +++ src/corelib/tools/qhash.h | 43 ++++++ .../tst_containerapisymmetry.cpp | 140 ++++++++++++++++++ 4 files changed, 248 insertions(+) diff --git a/src/corelib/tools/qcontainertools_impl.h b/src/corelib/tools/qcontainertools_impl.h index c2de50b145..86a16eb32b 100644 --- a/src/corelib/tools/qcontainertools_impl.h +++ b/src/corelib/tools/qcontainertools_impl.h @@ -84,6 +84,49 @@ void reserveIfForwardIterator(Container *c, ForwardIterator f, ForwardIterator l { c->reserve(static_cast(std::distance(f, l))); } + +// for detecting expression validity +template +using void_t = void; + +template > +struct AssociativeIteratorHasKeyAndValue : std::false_type +{ +}; + +template +struct AssociativeIteratorHasKeyAndValue< + Iterator, + void_t().key()), + decltype(std::declval().value())> + > + : std::true_type +{ +}; + +template , typename = void_t<>> +struct AssociativeIteratorHasFirstAndSecond : std::false_type +{ +}; + +template +struct AssociativeIteratorHasFirstAndSecond< + Iterator, + void_t()->first), + decltype(std::declval()->second)> + > + : std::true_type +{ +}; + +template +using IfAssociativeIteratorHasKeyAndValue = + typename std::enable_if::value, bool>::type; + +template +using IfAssociativeIteratorHasFirstAndSecond = + typename std::enable_if::value, bool>::type; + } // namespace QtPrivate QT_END_NAMESPACE diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index dd22a38be1..5c7e535c30 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -1251,6 +1251,17 @@ uint qHash(long double key, uint seed) noexcept compiled in C++11 mode. */ +/*! \fn template template QHash::QHash(InputIterator begin, InputIterator end) + \since 5.14 + + Constructs a hash with a copy of each of the elements in the iterator range + [\a begin, \a end). Either the elements iterated by the range must be + objects with \c{first} and \c{second} data members (like \c{QPair}, + \c{std::pair}, etc.) convertible to \c Key and to \c T respectively; or the + iterators must have \c{key()} and \c{value()} member functions, returning a + key convertible to \c Key and a value convertible to \c T respectively. +*/ + /*! \fn template QHash::QHash(const QHash &other) Constructs a copy of \a other. @@ -2586,6 +2597,17 @@ uint qHash(long double key, uint seed) noexcept \sa operator=() */ +/*! \fn template template QMultiHash::QMultiHash(InputIterator begin, InputIterator end) + \since 5.14 + + Constructs a multi-hash with a copy of each of the elements in the iterator range + [\a begin, \a end). Either the elements iterated by the range must be + objects with \c{first} and \c{second} data members (like \c{QPair}, + \c{std::pair}, etc.) convertible to \c Key and to \c T respectively; or the + iterators must have \c{key()} and \c{value()} member functions, returning a + key convertible to \c Key and a value convertible to \c T respectively. +*/ + /*! \fn template QMultiHash::iterator QMultiHash::replace(const Key &key, const T &value) Inserts a new item with the \a key and a value of \a value. diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index 120ee9cc85..a757e85386 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -46,6 +46,7 @@ #include #include #include +#include #ifdef Q_COMPILER_INITIALIZER_LISTS #include @@ -258,6 +259,28 @@ public: QHash(QHash &&other) noexcept : d(other.d) { other.d = const_cast(&QHashData::shared_null); } QHash &operator=(QHash &&other) noexcept { QHash moved(std::move(other)); swap(moved); return *this; } +#endif +#ifdef Q_QDOC + template + QHash(InputIterator f, InputIterator l); +#else + template = true> + QHash(InputIterator f, InputIterator l) + : QHash() + { + QtPrivate::reserveIfForwardIterator(this, f, l); + for (; f != l; ++f) + insert(f.key(), f.value()); + } + + template = true> + QHash(InputIterator f, InputIterator l) + : QHash() + { + QtPrivate::reserveIfForwardIterator(this, f, l); + for (; f != l; ++f) + insert(f->first, f->second); + } #endif void swap(QHash &other) noexcept { qSwap(d, other.d); } @@ -1028,6 +1051,26 @@ public: for (typename std::initializer_list >::const_iterator it = list.begin(); it != list.end(); ++it) insert(it->first, it->second); } +#endif +#ifdef Q_QDOC + template + QMultiHash(InputIterator f, InputIterator l); +#else + template = true> + QMultiHash(InputIterator f, InputIterator l) + { + QtPrivate::reserveIfForwardIterator(this, f, l); + for (; f != l; ++f) + insert(f.key(), f.value()); + } + + template = true> + QMultiHash(InputIterator f, InputIterator l) + { + QtPrivate::reserveIfForwardIterator(this, f, l); + for (; f != l; ++f) + insert(f->first, f->second); + } #endif // compiler-generated copy/move ctors/assignment operators are fine! // compiler-generated destructor is fine! diff --git a/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp b/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp index 196276c52f..7df220acf9 100644 --- a/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp +++ b/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp @@ -34,6 +34,7 @@ #include "qstring.h" #include "qvarlengtharray.h" #include "qvector.h" +#include "qhash.h" #include "qdebug.h" #include @@ -41,6 +42,7 @@ #include // for reference #include #include +#include // MSVC has these containers from the Standard Library, but it lacks // a __has_include mechanism (that we need to use for other stdlibs). @@ -58,6 +60,9 @@ #if COMPILER_HAS_STDLIB_INCLUDE() #include #endif +#if COMPILER_HAS_STDLIB_INCLUDE() +#include +#endif struct Movable { @@ -255,6 +260,9 @@ private: template class Container> void non_associative_container_duplicates_strategy() const; + template + void ranged_ctor_associative_impl() const; + private Q_SLOTS: // non associative void ranged_ctor_std_vector_int() { ranged_ctor_non_associative_impl>(); } @@ -403,6 +411,71 @@ private Q_SLOTS: void ranged_ctor_QSet_Complex() { ranged_ctor_non_associative_impl>(); } void ranged_ctor_QSet_duplicates_strategy() { non_associative_container_duplicates_strategy(); } + // associative + void ranged_ctor_std_map_int() { ranged_ctor_associative_impl>(); } + void ranged_ctor_std_map_Movable() { ranged_ctor_associative_impl>(); } + void ranged_ctor_std_map_Complex() { ranged_ctor_associative_impl>(); } + + void ranged_ctor_std_multimap_int() { ranged_ctor_associative_impl>(); } + void ranged_ctor_std_multimap_Movable() { ranged_ctor_associative_impl>(); } + void ranged_ctor_std_multimap_Complex() { ranged_ctor_associative_impl>(); } + + void ranged_ctor_unordered_map_int() { +#if COMPILER_HAS_STDLIB_INCLUDE() + ranged_ctor_associative_impl>(); +#else + QSKIP(" is needed for this test"); +#endif + } + + void ranged_ctor_unordered_map_Movable() { +#if COMPILER_HAS_STDLIB_INCLUDE() + ranged_ctor_associative_impl>(); +#else + QSKIP(" is needed for this test"); +#endif + } + + void ranged_ctor_unordered_map_Complex() { +#if COMPILER_HAS_STDLIB_INCLUDE() + ranged_ctor_associative_impl>(); +#else + QSKIP(" is needed for this test"); +#endif + } + + void ranged_ctor_QHash_int() { ranged_ctor_associative_impl>(); } + void ranged_ctor_QHash_Movable() { ranged_ctor_associative_impl>(); } + void ranged_ctor_QHash_Complex() { ranged_ctor_associative_impl>(); } + + void ranged_ctor_unordered_multimap_int() { +#if COMPILER_HAS_STDLIB_INCLUDE() + ranged_ctor_associative_impl>(); +#else + QSKIP(" is needed for this test"); +#endif + } + + void ranged_ctor_unordered_multimap_Movable() { +#if COMPILER_HAS_STDLIB_INCLUDE() + ranged_ctor_associative_impl>(); +#else + QSKIP(" is needed for this test"); +#endif + } + + void ranged_ctor_unordered_multimap_Complex() { +#if COMPILER_HAS_STDLIB_INCLUDE() + ranged_ctor_associative_impl>(); +#else + QSKIP(" is needed for this test"); +#endif + } + + void ranged_ctor_QMultiHash_int() { ranged_ctor_associative_impl>(); } + void ranged_ctor_QMultiHash_Movable() { ranged_ctor_associative_impl>(); } + void ranged_ctor_QMultiHash_Complex() { ranged_ctor_associative_impl>(); } + private: template void front_back_impl() const; @@ -651,6 +724,73 @@ void tst_ContainerApiSymmetry::non_associative_container_duplicates_strategy() c } #endif // Q_COMPILER_INITIALIZER_LISTS +template +void tst_ContainerApiSymmetry::ranged_ctor_associative_impl() const +{ + using K = typename Container::key_type; + using V = typename Container::mapped_type; + + // The double K(0) is deliberate. The order of the elements matters: + // * for unique-key STL containers, the first one should be the one inserted (cf. LWG 2844) + // * for unique-key Qt containers, the last one should be the one inserted + // * for multi-key sorted containers, the order of insertion of identical keys is also the + // iteration order (which establishes the equality of the containers) + // (although nothing of this is being tested here, that deserves its own testing) + const Container reference{ + { K(0), V(1000) }, + { K(1), V(1001) }, + { K(2), V(1002) }, + { K(0), V(1003) } + }; + + // Note that using anything not convertible to std::pair doesn't work for + // std containers. Their ranged construction is defined in terms of + // insert(value_type), which for std associative containers is + // std::pair. + + // plain array + const std::pair values1[] = { + std::make_pair(K(0), V(1000)), + std::make_pair(K(1), V(1001)), + std::make_pair(K(2), V(1002)), + std::make_pair(K(0), V(1003)) + }; + + const Container c1(values1, values1 + sizeof(values1)/sizeof(values1[0])); + + // from QList + QList> l2; + l2 << std::make_pair(K(0), V(1000)) + << std::make_pair(K(1), V(1001)) + << std::make_pair(K(2), V(1002)) + << std::make_pair(K(0), V(1003)); + + const Container c2a(l2.begin(), l2.end()); + const Container c2b(l2.cbegin(), l2.cend()); + + // from std::list + std::list> l3; + l3.push_back(std::make_pair(K(0), V(1000))); + l3.push_back(std::make_pair(K(1), V(1001))); + l3.push_back(std::make_pair(K(2), V(1002))); + l3.push_back(std::make_pair(K(0), V(1003))); + const Container c3a(l3.begin(), l3.end()); + + // from const std::list + const std::list> l3c = l3; + const Container c3b(l3c.begin(), l3c.end()); + + // from itself + const Container c4(reference.begin(), reference.end()); + + QCOMPARE(c1, reference); + QCOMPARE(c2a, reference); + QCOMPARE(c2b, reference); + QCOMPARE(c3a, reference); + QCOMPARE(c3b, reference); + QCOMPARE(c4, reference); +} + template Container make(int size) { From 0c404fd6f34c7ca75400324e95e44842152bdd87 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Wed, 6 Feb 2019 13:12:35 +0100 Subject: [PATCH 206/292] Add image layer on windows The docker-compose files were trying to use volume sharing, which is not supported on Windows in conjunction with docker-machine. Hence create a separate layer on Windows, which copies the configuration files to the target. Change-Id: Ifeacc56198ffc8fb2eb31c14ab91334e22e916f5 Reviewed-by: Maurice Kalinowski Reviewed-by: Edward Welbourne --- tests/testserver/Dockerfile | 11 +++++ .../testserver/docker-compose-for-windows.yml | 45 ++++++++++--------- 2 files changed, 36 insertions(+), 20 deletions(-) create mode 100644 tests/testserver/Dockerfile diff --git a/tests/testserver/Dockerfile b/tests/testserver/Dockerfile new file mode 100644 index 0000000000..a4db873a5d --- /dev/null +++ b/tests/testserver/Dockerfile @@ -0,0 +1,11 @@ +# This Dockerfile is used on windows as volume sharing / mounting does not work in conjunction +# docker-machine. Windows Update 1809 might solve some of those issues when using docker0 +# network switch, but nothing has been reported in regards to the combination with docker-machine. + +ARG provisioningImage +FROM $provisioningImage + +# Common is used for all test images so far, no need for a variable +COPY ./common /common +ARG servicedir +COPY $servicedir /service diff --git a/tests/testserver/docker-compose-for-windows.yml b/tests/testserver/docker-compose-for-windows.yml index aa610dfb88..4867413361 100644 --- a/tests/testserver/docker-compose-for-windows.yml +++ b/tests/testserver/docker-compose-for-windows.yml @@ -12,12 +12,13 @@ version: '3.4' services: apache2: - image: qt-test-server-apache2:537fe302f61851d1663f41495230d8e3554a4a13 container_name: qt-test-server-apache2 domainname: ${TEST_DOMAIN} - volumes: - - ./common:/common:ro - - ./apache2:/service:ro + build: + context: . + args: + provisioningImage: qt-test-server-apache2:537fe302f61851d1663f41495230d8e3554a4a13 + servicedir: ./apache2 entrypoint: common/startup.sh command: [common/ssl.sh, service/apache2.sh] network_mode: "host" @@ -28,14 +29,15 @@ services: - test_cert="qt-test-server-host-network-cacert.pem" squid: - image: qt-test-server-squid:9c32f41b19aca3d778733c4d8fb0ecc5955e893c container_name: qt-test-server-squid domainname: ${TEST_DOMAIN} depends_on: - apache2 - volumes: - - ./common:/common:ro - - ./squid:/service:ro + build: + context: . + args: + provisioningImage: qt-test-server-squid:9c32f41b19aca3d778733c4d8fb0ecc5955e893c + servicedir: ./squid entrypoint: common/startup.sh command: service/squid.sh network_mode: "host" @@ -45,12 +47,13 @@ services: - test_domain=${TEST_DOMAIN} vsftpd: - image: qt-test-server-vsftpd:f3a9c8d793a77cc007c0e4e481bec01f9e3eeb7e container_name: qt-test-server-vsftpd domainname: ${TEST_DOMAIN} - volumes: - - ./common:/common:ro - - ./vsftpd:/service:ro + build: + context: . + args: + provisioningImage: qt-test-server-vsftpd:f3a9c8d793a77cc007c0e4e481bec01f9e3eeb7e + servicedir: ./vsftpd entrypoint: common/startup.sh command: service/vsftpd.sh network_mode: "host" @@ -60,14 +63,15 @@ services: - test_domain=${TEST_DOMAIN} ftp-proxy: - image: qt-test-server-ftp-proxy:d7de8b28392d173db512a558ccc84ead8bece2ae container_name: qt-test-server-ftp-proxy domainname: ${TEST_DOMAIN} depends_on: - vsftpd - volumes: - - ./common:/common:ro - - ./ftp-proxy:/service:ro + build: + context: . + args: + provisioningImage: qt-test-server-ftp-proxy:d7de8b28392d173db512a558ccc84ead8bece2ae + servicedir: ./ftp-proxy entrypoint: common/startup.sh command: service/ftp-proxy.sh network_mode: "host" @@ -77,16 +81,17 @@ services: - test_domain=${TEST_DOMAIN} danted: - image: qt-test-server-danted:35607f9b790524cf9690c7d12a9a401696b7b6b5 container_name: qt-test-server-danted domainname: ${TEST_DOMAIN} depends_on: - apache2 - vsftpd - ftp-proxy - volumes: - - ./common:/common:ro - - ./danted:/service:ro + build: + context: . + args: + provisioningImage: qt-test-server-danted:35607f9b790524cf9690c7d12a9a401696b7b6b5 + servicedir: ./danted entrypoint: common/startup.sh command: service/danted.sh network_mode: "host" From 713f77176e5de34503bd265e00f665b7f6ef05b4 Mon Sep 17 00:00:00 2001 From: Ryan Chu Date: Fri, 22 Mar 2019 16:20:52 +0100 Subject: [PATCH 207/292] Support multi-stage builds to provision the configurations and test data In order to reuse the test server to the external modules, it is much easier to share the common configurations (scripts) and test data via Dockerfile. In addition, the external module can create more layers depending on their needs. Therefore, supporting multi-stage builds is needed. The disadvantage is that the docker-compose needs to re-build the images every time. However, it is just a one-time effort. If the Dockerfile doesn't get changed, the extra build time can be ignored. Because of multi-stage builds, the test server will keep a Dockerfile at least. Therefore, the volume sharing is no more needed. The test data of a service can be added into the images by using COPY/ADD commands. NOTE: This patch relies on docker-compose v1.21.0 (docker-compose build now supports the use of Dockerfile from outside the build context). Change-Id: Ib3f6a5fcf6979732ae8a40a494a1360fca4ac7bf Reviewed-by: Maurice Kalinowski Reviewed-by: Edward Welbourne --- tests/auto/Dockerfile | 27 ++++ tests/auto/testserver.pri | 5 +- tests/testserver/Dockerfile | 11 -- tests/testserver/common/startup.sh | 17 +-- tests/testserver/docker-compose-for-macOS.yml | 81 +++++++----- .../testserver/docker-compose-for-windows.yml | 46 ++++--- tests/testserver/docker-compose.yml | 124 +++++++++++------- 7 files changed, 185 insertions(+), 126 deletions(-) create mode 100644 tests/auto/Dockerfile delete mode 100644 tests/testserver/Dockerfile diff --git a/tests/auto/Dockerfile b/tests/auto/Dockerfile new file mode 100644 index 0000000000..8fb664a1d2 --- /dev/null +++ b/tests/auto/Dockerfile @@ -0,0 +1,27 @@ +# This Dockerfile is used to provision the shared scripts (e.g. startup.sh) and configurations. It +# relies on the arguments passed by docker-compose file to build additional images for each service. +# To lean more how it works, please check the topic "Use multi-stage builds". +# https://docs.docker.com/develop/develop-images/multistage-build/ + +ARG provisioningImage +FROM $provisioningImage as testserver_tier2 + +# Add and merge the testdata into service folder +ARG serviceDir +ARG shareDir=$serviceDir +COPY $serviceDir $shareDir service/ + +# create the shared script of testserver +RUN echo "#!/usr/bin/env bash\n" \ + "set -ex\n" \ + "for RUN_CMD; do \$RUN_CMD; done\n" \ + "service dbus restart\n" \ + "service avahi-daemon restart\n" \ + "sleep infinity\n" > startup.sh +RUN chmod +x startup.sh + +# rewrite the default configurations of avahi-daemon +ARG test_domain +RUN sed -i -e "s,#domain-name=local,domain-name=${test_domain:-test-net.qt.local}," \ + -e "s,#publish-aaaa-on-ipv4=yes,publish-aaaa-on-ipv4=no," \ + /etc/avahi/avahi-daemon.conf diff --git a/tests/auto/testserver.pri b/tests/auto/testserver.pri index 455f88fa5d..1b7ccf5757 100644 --- a/tests/auto/testserver.pri +++ b/tests/auto/testserver.pri @@ -102,6 +102,7 @@ isEmpty(TESTSERVER_VERSION) { # The environment variables passed to the docker-compose file TEST_ENV = 'MACHINE_IP=$(shell docker-machine ip qt-test-server)' TEST_ENV += 'TEST_DOMAIN=$$DNSDOMAIN' + TEST_ENV += 'SHARED_DATA=$$PWD' TEST_CMD = env } else:equals(QMAKE_HOST.os, Windows) { # There is no docker bridge on Windows. It is impossible to ping a container. @@ -115,6 +116,7 @@ isEmpty(TESTSERVER_VERSION) { # The environment variables passed to the docker-compose file TEST_ENV = '\$\$env:MACHINE_IP = docker-machine ip qt-test-server;' TEST_ENV += '\$\$env:TEST_DOMAIN = $$shell_quote(\"$$DNSDOMAIN\");' + TEST_ENV += '\$\$env:SHARED_DATA = $$shell_quote(\"$$PWD\");' # Docker-compose CLI environment variables: # Enable path conversion from Windows-style to Unix-style in volume definitions. @@ -127,6 +129,7 @@ isEmpty(TESTSERVER_VERSION) { $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose.yml # The environment variables passed to the docker-compose file TEST_ENV = 'TEST_DOMAIN=$$DNSDOMAIN' + TEST_ENV += 'SHARED_DATA=$$PWD' TEST_CMD = env } !exists($$TESTSERVER_COMPOSE_FILE): error("Invalid TESTSERVER_COMPOSE_FILE specified") @@ -200,7 +203,7 @@ isEmpty(TESTSERVER_VERSION) { # Bring up test servers and make sure the services are ready. !isEmpty(TEST_CMD): testserver_test.commands = $$TEST_CMD $$TEST_ENV testserver_test.commands += docker-compose $$MACHINE_CONFIG -f $$TESTSERVER_COMPOSE_FILE up \ - --detach --force-recreate --timeout 1 $${QT_TEST_SERVER_LIST} && + --build -d --force-recreate --timeout 1 $${QT_TEST_SERVER_LIST} && # Check test cases with docker-based test servers. testserver_test.commands += $(MAKE) -f $(MAKEFILE) check_network && diff --git a/tests/testserver/Dockerfile b/tests/testserver/Dockerfile deleted file mode 100644 index a4db873a5d..0000000000 --- a/tests/testserver/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -# This Dockerfile is used on windows as volume sharing / mounting does not work in conjunction -# docker-machine. Windows Update 1809 might solve some of those issues when using docker0 -# network switch, but nothing has been reported in regards to the combination with docker-machine. - -ARG provisioningImage -FROM $provisioningImage - -# Common is used for all test images so far, no need for a variable -COPY ./common /common -ARG servicedir -COPY $servicedir /service diff --git a/tests/testserver/common/startup.sh b/tests/testserver/common/startup.sh index 74990a47f6..1386314e38 100755 --- a/tests/testserver/common/startup.sh +++ b/tests/testserver/common/startup.sh @@ -34,7 +34,7 @@ set -ex # export variables export USER=qt-test-server export PASS=password -export CONFIG=common/testdata +export CONFIG=service/testdata export TESTDATA=service/testdata # add users @@ -43,17 +43,4 @@ useradd -m -s /bin/bash $USER; echo "$USER:$PASS" | chpasswd # install configurations and test data su $USER -c "cp $CONFIG/system/passwords ~/" -# modules initialization (apache2.sh, ftp-proxy.sh ...) -for RUN_CMD -do $RUN_CMD -done - -# start multicast DNS service discovery (mDNS) -sed -i -e "s,#domain-name=local,domain-name=${test_domain:-test-net.qt.local}," \ - -e "s,#publish-aaaa-on-ipv4=yes,publish-aaaa-on-ipv4=no," \ - /etc/avahi/avahi-daemon.conf -service dbus restart -service avahi-daemon restart - -# keep-alive in docker detach mode -sleep infinity +./startup.sh "$@" diff --git a/tests/testserver/docker-compose-for-macOS.yml b/tests/testserver/docker-compose-for-macOS.yml index aa610dfb88..c5348e27b6 100644 --- a/tests/testserver/docker-compose-for-macOS.yml +++ b/tests/testserver/docker-compose-for-macOS.yml @@ -12,82 +12,95 @@ version: '3.4' services: apache2: - image: qt-test-server-apache2:537fe302f61851d1663f41495230d8e3554a4a13 container_name: qt-test-server-apache2 domainname: ${TEST_DOMAIN} - volumes: - - ./common:/common:ro - - ./apache2:/service:ro - entrypoint: common/startup.sh - command: [common/ssl.sh, service/apache2.sh] + build: + context: . + dockerfile: ${SHARED_DATA}/Dockerfile + args: + provisioningImage: qt-test-server-apache2:537fe302f61851d1663f41495230d8e3554a4a13 + shareDir: ./common + serviceDir: ./apache2 + test_domain: ${TEST_DOMAIN} + entrypoint: service/startup.sh + command: [service/ssl.sh, service/apache2.sh] network_mode: "host" extra_hosts: - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}" environment: - - test_domain=${TEST_DOMAIN} - test_cert="qt-test-server-host-network-cacert.pem" squid: - image: qt-test-server-squid:9c32f41b19aca3d778733c4d8fb0ecc5955e893c container_name: qt-test-server-squid domainname: ${TEST_DOMAIN} depends_on: - apache2 - volumes: - - ./common:/common:ro - - ./squid:/service:ro - entrypoint: common/startup.sh + build: + context: . + dockerfile: ${SHARED_DATA}/Dockerfile + args: + provisioningImage: qt-test-server-squid:9c32f41b19aca3d778733c4d8fb0ecc5955e893c + shareDir: ./common + serviceDir: ./squid + test_domain: ${TEST_DOMAIN} + entrypoint: service/startup.sh command: service/squid.sh network_mode: "host" extra_hosts: - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}" - environment: - - test_domain=${TEST_DOMAIN} vsftpd: - image: qt-test-server-vsftpd:f3a9c8d793a77cc007c0e4e481bec01f9e3eeb7e container_name: qt-test-server-vsftpd domainname: ${TEST_DOMAIN} - volumes: - - ./common:/common:ro - - ./vsftpd:/service:ro - entrypoint: common/startup.sh + build: + context: . + dockerfile: ${SHARED_DATA}/Dockerfile + args: + provisioningImage: qt-test-server-vsftpd:f3a9c8d793a77cc007c0e4e481bec01f9e3eeb7e + shareDir: ./common + serviceDir: ./vsftpd + test_domain: ${TEST_DOMAIN} + entrypoint: service/startup.sh command: service/vsftpd.sh network_mode: "host" extra_hosts: - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}" - environment: - - test_domain=${TEST_DOMAIN} ftp-proxy: - image: qt-test-server-ftp-proxy:d7de8b28392d173db512a558ccc84ead8bece2ae container_name: qt-test-server-ftp-proxy domainname: ${TEST_DOMAIN} depends_on: - vsftpd - volumes: - - ./common:/common:ro - - ./ftp-proxy:/service:ro - entrypoint: common/startup.sh + build: + context: . + dockerfile: ${SHARED_DATA}/Dockerfile + args: + provisioningImage: qt-test-server-ftp-proxy:d7de8b28392d173db512a558ccc84ead8bece2ae + shareDir: ./common + serviceDir: ./ftp-proxy + test_domain: ${TEST_DOMAIN} + entrypoint: service/startup.sh command: service/ftp-proxy.sh network_mode: "host" extra_hosts: - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}" - environment: - - test_domain=${TEST_DOMAIN} danted: - image: qt-test-server-danted:35607f9b790524cf9690c7d12a9a401696b7b6b5 container_name: qt-test-server-danted domainname: ${TEST_DOMAIN} depends_on: - apache2 - vsftpd - ftp-proxy - volumes: - - ./common:/common:ro - - ./danted:/service:ro - entrypoint: common/startup.sh + build: + context: . + dockerfile: ${SHARED_DATA}/Dockerfile + args: + provisioningImage: qt-test-server-danted:35607f9b790524cf9690c7d12a9a401696b7b6b5 + shareDir: ./common + serviceDir: ./danted + test_domain: ${TEST_DOMAIN} + entrypoint: service/startup.sh command: service/danted.sh network_mode: "host" extra_hosts: @@ -97,4 +110,4 @@ services: - danted_external=${MACHINE_IP} - danted_auth_internal=${MACHINE_IP} - danted_auth_external=${MACHINE_IP} - - test_domain=${TEST_DOMAIN} + diff --git a/tests/testserver/docker-compose-for-windows.yml b/tests/testserver/docker-compose-for-windows.yml index 4867413361..c5348e27b6 100644 --- a/tests/testserver/docker-compose-for-windows.yml +++ b/tests/testserver/docker-compose-for-windows.yml @@ -16,16 +16,18 @@ services: domainname: ${TEST_DOMAIN} build: context: . + dockerfile: ${SHARED_DATA}/Dockerfile args: provisioningImage: qt-test-server-apache2:537fe302f61851d1663f41495230d8e3554a4a13 - servicedir: ./apache2 - entrypoint: common/startup.sh - command: [common/ssl.sh, service/apache2.sh] + shareDir: ./common + serviceDir: ./apache2 + test_domain: ${TEST_DOMAIN} + entrypoint: service/startup.sh + command: [service/ssl.sh, service/apache2.sh] network_mode: "host" extra_hosts: - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}" environment: - - test_domain=${TEST_DOMAIN} - test_cert="qt-test-server-host-network-cacert.pem" squid: @@ -35,32 +37,34 @@ services: - apache2 build: context: . + dockerfile: ${SHARED_DATA}/Dockerfile args: provisioningImage: qt-test-server-squid:9c32f41b19aca3d778733c4d8fb0ecc5955e893c - servicedir: ./squid - entrypoint: common/startup.sh + shareDir: ./common + serviceDir: ./squid + test_domain: ${TEST_DOMAIN} + entrypoint: service/startup.sh command: service/squid.sh network_mode: "host" extra_hosts: - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}" - environment: - - test_domain=${TEST_DOMAIN} vsftpd: container_name: qt-test-server-vsftpd domainname: ${TEST_DOMAIN} build: context: . + dockerfile: ${SHARED_DATA}/Dockerfile args: provisioningImage: qt-test-server-vsftpd:f3a9c8d793a77cc007c0e4e481bec01f9e3eeb7e - servicedir: ./vsftpd - entrypoint: common/startup.sh + shareDir: ./common + serviceDir: ./vsftpd + test_domain: ${TEST_DOMAIN} + entrypoint: service/startup.sh command: service/vsftpd.sh network_mode: "host" extra_hosts: - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}" - environment: - - test_domain=${TEST_DOMAIN} ftp-proxy: container_name: qt-test-server-ftp-proxy @@ -69,16 +73,17 @@ services: - vsftpd build: context: . + dockerfile: ${SHARED_DATA}/Dockerfile args: provisioningImage: qt-test-server-ftp-proxy:d7de8b28392d173db512a558ccc84ead8bece2ae - servicedir: ./ftp-proxy - entrypoint: common/startup.sh + shareDir: ./common + serviceDir: ./ftp-proxy + test_domain: ${TEST_DOMAIN} + entrypoint: service/startup.sh command: service/ftp-proxy.sh network_mode: "host" extra_hosts: - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}" - environment: - - test_domain=${TEST_DOMAIN} danted: container_name: qt-test-server-danted @@ -89,10 +94,13 @@ services: - ftp-proxy build: context: . + dockerfile: ${SHARED_DATA}/Dockerfile args: provisioningImage: qt-test-server-danted:35607f9b790524cf9690c7d12a9a401696b7b6b5 - servicedir: ./danted - entrypoint: common/startup.sh + shareDir: ./common + serviceDir: ./danted + test_domain: ${TEST_DOMAIN} + entrypoint: service/startup.sh command: service/danted.sh network_mode: "host" extra_hosts: @@ -102,4 +110,4 @@ services: - danted_external=${MACHINE_IP} - danted_auth_internal=${MACHINE_IP} - danted_auth_external=${MACHINE_IP} - - test_domain=${TEST_DOMAIN} + diff --git a/tests/testserver/docker-compose.yml b/tests/testserver/docker-compose.yml index 962daad3c9..75e8a0fea2 100644 --- a/tests/testserver/docker-compose.yml +++ b/tests/testserver/docker-compose.yml @@ -12,18 +12,21 @@ version: '3.4' services: apache2: - image: qt-test-server-apache2:537fe302f61851d1663f41495230d8e3554a4a13 container_name: qt-test-server-apache2 domainname: ${TEST_DOMAIN} hostname: apache2 - volumes: - - ./common:/common:ro - - ./apache2:/service:ro - entrypoint: common/startup.sh - command: [common/ssl.sh, service/apache2.sh] + build: + context: . + dockerfile: ${SHARED_DATA}/Dockerfile + args: + provisioningImage: qt-test-server-apache2:537fe302f61851d1663f41495230d8e3554a4a13 + shareDir: ./common + serviceDir: ./apache2 + test_domain: ${TEST_DOMAIN} + entrypoint: service/startup.sh + command: [service/ssl.sh, service/apache2.sh] squid: - image: qt-test-server-squid:9c32f41b19aca3d778733c4d8fb0ecc5955e893c container_name: qt-test-server-squid domainname: ${TEST_DOMAIN} hostname: squid @@ -35,25 +38,33 @@ services: - iptables:iptables.${TEST_DOMAIN} - vsftpd:vsftpd.${TEST_DOMAIN} - echo:echo.${TEST_DOMAIN} - volumes: - - ./common:/common:ro - - ./squid:/service:ro - entrypoint: common/startup.sh + build: + context: . + dockerfile: ${SHARED_DATA}/Dockerfile + args: + provisioningImage: qt-test-server-squid:9c32f41b19aca3d778733c4d8fb0ecc5955e893c + shareDir: ./common + serviceDir: ./squid + test_domain: ${TEST_DOMAIN} + entrypoint: service/startup.sh command: service/squid.sh vsftpd: - image: qt-test-server-vsftpd:f3a9c8d793a77cc007c0e4e481bec01f9e3eeb7e container_name: qt-test-server-vsftpd domainname: ${TEST_DOMAIN} hostname: vsftpd - volumes: - - ./common:/common:ro - - ./vsftpd:/service:ro - entrypoint: common/startup.sh + build: + context: . + dockerfile: ${SHARED_DATA}/Dockerfile + args: + provisioningImage: qt-test-server-vsftpd:f3a9c8d793a77cc007c0e4e481bec01f9e3eeb7e + shareDir: ./common + serviceDir: ./vsftpd + test_domain: ${TEST_DOMAIN} + entrypoint: service/startup.sh command: service/vsftpd.sh ftp-proxy: - image: qt-test-server-ftp-proxy:d7de8b28392d173db512a558ccc84ead8bece2ae container_name: qt-test-server-ftp-proxy domainname: ${TEST_DOMAIN} hostname: ftp-proxy @@ -61,14 +72,18 @@ services: - vsftpd external_links: - vsftpd:vsftpd.${TEST_DOMAIN} - volumes: - - ./common:/common:ro - - ./ftp-proxy:/service:ro - entrypoint: common/startup.sh + build: + context: . + dockerfile: ${SHARED_DATA}/Dockerfile + args: + provisioningImage: qt-test-server-ftp-proxy:d7de8b28392d173db512a558ccc84ead8bece2ae + shareDir: ./common + serviceDir: ./ftp-proxy + test_domain: ${TEST_DOMAIN} + entrypoint: service/startup.sh command: service/ftp-proxy.sh danted: - image: qt-test-server-danted:35607f9b790524cf9690c7d12a9a401696b7b6b5 container_name: qt-test-server-danted domainname: ${TEST_DOMAIN} hostname: danted @@ -82,44 +97,61 @@ services: - ftp-proxy:ftp-proxy.${TEST_DOMAIN} - cyrus:cyrus.${TEST_DOMAIN} - echo:echo.${TEST_DOMAIN} - volumes: - - ./common:/common:ro - - ./danted:/service:ro - entrypoint: common/startup.sh + build: + context: . + dockerfile: ${SHARED_DATA}/Dockerfile + args: + provisioningImage: qt-test-server-danted:35607f9b790524cf9690c7d12a9a401696b7b6b5 + shareDir: ./common + serviceDir: ./danted + test_domain: ${TEST_DOMAIN} + entrypoint: service/startup.sh command: service/danted.sh cyrus: - image: qt-test-server-cyrus:c8d72754abc0e501afd624ce838e4df35505abc9 container_name: qt-test-server-cyrus domainname: ${TEST_DOMAIN} hostname: cyrus - volumes: - - ./common:/common:ro - - ./cyrus:/service:ro - entrypoint: common/startup.sh - command: [common/ssl.sh, service/cyrus.sh] + build: + context: . + dockerfile: ${SHARED_DATA}/Dockerfile + args: + provisioningImage: qt-test-server-cyrus:c8d72754abc0e501afd624ce838e4df35505abc9 + shareDir: ./common + serviceDir: ./cyrus + test_domain: ${TEST_DOMAIN} + entrypoint: service/startup.sh + command: [service/ssl.sh, service/cyrus.sh] iptables: - image: qt-test-server-iptables:cb7a8bd6d28602085a88c8ced7d67e28e75781e2 container_name: qt-test-server-iptables domainname: ${TEST_DOMAIN} hostname: iptables - volumes: - - ./common:/common:ro - - ./iptables:/service:ro - entrypoint: common/startup.sh + build: + context: . + dockerfile: ${SHARED_DATA}/Dockerfile + args: + provisioningImage: qt-test-server-iptables:cb7a8bd6d28602085a88c8ced7d67e28e75781e2 + shareDir: ./common + serviceDir: ./iptables + test_domain: ${TEST_DOMAIN} + entrypoint: service/startup.sh command: service/iptables.sh cap_add: - NET_ADMIN - NET_RAW echo: - image: qt-test-server-echo:b29ad409e746a834c1055fd0f7a55fd5056da6ea - container_name: qt-test-server-echo - domainname: ${TEST_DOMAIN} - hostname: echo - volumes: - - ./common:/common:ro - - ./echo:/service:ro - entrypoint: common/startup.sh - command: service/echo.sh + container_name: qt-test-server-echo + domainname: ${TEST_DOMAIN} + hostname: echo + build: + context: . + dockerfile: ${SHARED_DATA}/Dockerfile + args: + provisioningImage: qt-test-server-echo:b29ad409e746a834c1055fd0f7a55fd5056da6ea + shareDir: ./common + serviceDir: ./echo + test_domain: ${TEST_DOMAIN} + entrypoint: service/startup.sh + command: service/echo.sh From 658f12d7354e82ae552703fa928e1c94315c3a6a Mon Sep 17 00:00:00 2001 From: Ryan Chu Date: Mon, 25 Mar 2019 18:04:26 +0100 Subject: [PATCH 208/292] Expose docker test server as an internal config to all modules Before testserver becomes a stable feature, let's keep testserver.prf in "mkspecs/features/unsupported". The test server's shared files will be stored in "mkspecs/features/data/testserver". Because the path of testserver has been changed, all the tests relying on the docker servers should be updated as well. Change-Id: Id2494d2b58ee2a9522d99ae61c6236021506b876 Reviewed-by: Maurice Kalinowski Reviewed-by: Edward Welbourne --- {tests/auto => mkspecs/features/data/testserver}/Dockerfile | 0 .../features/unsupported/testserver.prf | 6 +++--- .../access/qabstractnetworkcache/qabstractnetworkcache.pro | 2 +- .../qhttpnetworkconnection/qhttpnetworkconnection.pro | 3 +-- tests/auto/network/access/qnetworkreply/test/test.pro | 2 +- .../network/socket/qhttpsocketengine/qhttpsocketengine.pro | 2 +- .../socket/qsocks5socketengine/qsocks5socketengine.pro | 2 +- tests/auto/network/socket/qtcpserver/test/test.pro | 2 +- tests/auto/network/socket/qtcpsocket/test/test.pro | 2 +- tests/auto/network/socket/qudpsocket/test/test.pro | 2 +- tests/auto/network/ssl/qsslsocket/qsslsocket.pro | 2 +- .../qsslsocket_onDemandCertificates_member.pro | 2 +- .../qsslsocket_onDemandCertificates_static.pro | 2 +- 13 files changed, 14 insertions(+), 15 deletions(-) rename {tests/auto => mkspecs/features/data/testserver}/Dockerfile (100%) rename tests/auto/testserver.pri => mkspecs/features/unsupported/testserver.prf (98%) diff --git a/tests/auto/Dockerfile b/mkspecs/features/data/testserver/Dockerfile similarity index 100% rename from tests/auto/Dockerfile rename to mkspecs/features/data/testserver/Dockerfile diff --git a/tests/auto/testserver.pri b/mkspecs/features/unsupported/testserver.prf similarity index 98% rename from tests/auto/testserver.pri rename to mkspecs/features/unsupported/testserver.prf index 1b7ccf5757..6507a360c5 100644 --- a/tests/auto/testserver.pri +++ b/mkspecs/features/unsupported/testserver.prf @@ -102,7 +102,7 @@ isEmpty(TESTSERVER_VERSION) { # The environment variables passed to the docker-compose file TEST_ENV = 'MACHINE_IP=$(shell docker-machine ip qt-test-server)' TEST_ENV += 'TEST_DOMAIN=$$DNSDOMAIN' - TEST_ENV += 'SHARED_DATA=$$PWD' + TEST_ENV += 'SHARED_DATA=$$PWD/../data/testserver' TEST_CMD = env } else:equals(QMAKE_HOST.os, Windows) { # There is no docker bridge on Windows. It is impossible to ping a container. @@ -116,7 +116,7 @@ isEmpty(TESTSERVER_VERSION) { # The environment variables passed to the docker-compose file TEST_ENV = '\$\$env:MACHINE_IP = docker-machine ip qt-test-server;' TEST_ENV += '\$\$env:TEST_DOMAIN = $$shell_quote(\"$$DNSDOMAIN\");' - TEST_ENV += '\$\$env:SHARED_DATA = $$shell_quote(\"$$PWD\");' + TEST_ENV += '\$\$env:SHARED_DATA = $$shell_quote(\"$$PWD/../data/testserver\");' # Docker-compose CLI environment variables: # Enable path conversion from Windows-style to Unix-style in volume definitions. @@ -129,7 +129,7 @@ isEmpty(TESTSERVER_VERSION) { $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose.yml # The environment variables passed to the docker-compose file TEST_ENV = 'TEST_DOMAIN=$$DNSDOMAIN' - TEST_ENV += 'SHARED_DATA=$$PWD' + TEST_ENV += 'SHARED_DATA=$$PWD/../data/testserver' TEST_CMD = env } !exists($$TESTSERVER_COMPOSE_FILE): error("Invalid TESTSERVER_COMPOSE_FILE specified") diff --git a/tests/auto/network/access/qabstractnetworkcache/qabstractnetworkcache.pro b/tests/auto/network/access/qabstractnetworkcache/qabstractnetworkcache.pro index bdd9d4eb7e..c722100ead 100644 --- a/tests/auto/network/access/qabstractnetworkcache/qabstractnetworkcache.pro +++ b/tests/auto/network/access/qabstractnetworkcache/qabstractnetworkcache.pro @@ -5,5 +5,5 @@ SOURCES += tst_qabstractnetworkcache.cpp TESTDATA += tests/* +CONFIG += unsupported/testserver QT_TEST_SERVER_LIST = apache2 -include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) diff --git a/tests/auto/network/access/qhttpnetworkconnection/qhttpnetworkconnection.pro b/tests/auto/network/access/qhttpnetworkconnection/qhttpnetworkconnection.pro index 69a4a50144..84e6f857a1 100644 --- a/tests/auto/network/access/qhttpnetworkconnection/qhttpnetworkconnection.pro +++ b/tests/auto/network/access/qhttpnetworkconnection/qhttpnetworkconnection.pro @@ -5,6 +5,5 @@ requires(qtConfig(private_tests)) QT = core-private network-private testlib +CONFIG += unsupported/testserver QT_TEST_SERVER_LIST = apache2 -include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) - diff --git a/tests/auto/network/access/qnetworkreply/test/test.pro b/tests/auto/network/access/qnetworkreply/test/test.pro index 9d36352abc..4cc1f6431e 100644 --- a/tests/auto/network/access/qnetworkreply/test/test.pro +++ b/tests/auto/network/access/qnetworkreply/test/test.pro @@ -15,5 +15,5 @@ TESTDATA += ../empty ../rfc3252.txt ../resource ../bigfile ../*.jpg ../certs \ !android:!winrt: TEST_HELPER_INSTALLS = ../echo/echo +CONFIG += unsupported/testserver QT_TEST_SERVER_LIST = vsftpd apache2 ftp-proxy danted squid -include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) diff --git a/tests/auto/network/socket/qhttpsocketengine/qhttpsocketengine.pro b/tests/auto/network/socket/qhttpsocketengine/qhttpsocketengine.pro index 492bb6aa8d..63f41f4eb7 100644 --- a/tests/auto/network/socket/qhttpsocketengine/qhttpsocketengine.pro +++ b/tests/auto/network/socket/qhttpsocketengine/qhttpsocketengine.pro @@ -12,6 +12,6 @@ QT = core-private network-private testlib # TODO: For now linux-only, because cyrus is linux-only atm ... linux { + CONFIG += unsupported/testserver QT_TEST_SERVER_LIST = squid danted cyrus apache2 - include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) } diff --git a/tests/auto/network/socket/qsocks5socketengine/qsocks5socketengine.pro b/tests/auto/network/socket/qsocks5socketengine/qsocks5socketengine.pro index ca9e44873c..243eab9480 100644 --- a/tests/auto/network/socket/qsocks5socketengine/qsocks5socketengine.pro +++ b/tests/auto/network/socket/qsocks5socketengine/qsocks5socketengine.pro @@ -14,6 +14,6 @@ requires(qtConfig(private_tests)) # Only on Linux until cyrus has been added to docker-compose-for-{windows,macOS}.yml and tested linux { + CONFIG += unsupported/testserver QT_TEST_SERVER_LIST = danted apache2 cyrus - include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) } diff --git a/tests/auto/network/socket/qtcpserver/test/test.pro b/tests/auto/network/socket/qtcpserver/test/test.pro index ac4ed9a989..de02fb032d 100644 --- a/tests/auto/network/socket/qtcpserver/test/test.pro +++ b/tests/auto/network/socket/qtcpserver/test/test.pro @@ -19,6 +19,6 @@ MOC_DIR=tmp # Only on Linux until cyrus has been added to docker-compose-for-{windows,macOS}.yml and tested linux { + CONFIG += unsupported/testserver QT_TEST_SERVER_LIST = danted cyrus squid ftp-proxy - include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) } diff --git a/tests/auto/network/socket/qtcpsocket/test/test.pro b/tests/auto/network/socket/qtcpsocket/test/test.pro index 29d9414b03..05699bbe4e 100644 --- a/tests/auto/network/socket/qtcpsocket/test/test.pro +++ b/tests/auto/network/socket/qtcpsocket/test/test.pro @@ -18,6 +18,6 @@ win32 { # Only on Linux until cyrus has been added to docker-compose-for-{windows,macOS}.yml and tested linux { + CONFIG += unsupported/testserver QT_TEST_SERVER_LIST = danted squid apache2 ftp-proxy vsftpd iptables cyrus - include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) } diff --git a/tests/auto/network/socket/qudpsocket/test/test.pro b/tests/auto/network/socket/qudpsocket/test/test.pro index 0fdb97ba27..969e4d72cf 100644 --- a/tests/auto/network/socket/qudpsocket/test/test.pro +++ b/tests/auto/network/socket/qudpsocket/test/test.pro @@ -20,6 +20,6 @@ TARGET = tst_qudpsocket # Only on Linux until 'echo' has been added to docker-compose-for-{windows,macOS}.yml and tested linux { + CONFIG += unsupported/testserver QT_TEST_SERVER_LIST = danted echo - include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) } diff --git a/tests/auto/network/ssl/qsslsocket/qsslsocket.pro b/tests/auto/network/ssl/qsslsocket/qsslsocket.pro index 03fbe89002..51fcff9a8d 100644 --- a/tests/auto/network/ssl/qsslsocket/qsslsocket.pro +++ b/tests/auto/network/ssl/qsslsocket/qsslsocket.pro @@ -22,6 +22,6 @@ requires(qtConfig(private_tests)) # DOCKERTODO: it's 'linux' because it requires cyrus, which # is linux-only for now ... linux { + CONFIG += unsupported/testserver QT_TEST_SERVER_LIST = squid danted cyrus apache2 echo - include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) } diff --git a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro index 3e3ebeb358..8585a3c861 100644 --- a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro +++ b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro @@ -20,6 +20,6 @@ requires(qtConfig(private_tests)) # DOCKERTODO: linux, docker is disabled on macOS/Windows. linux { + CONFIG += unsupported/testserver QT_TEST_SERVER_LIST = squid danted - include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) } diff --git a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro index 1ad42b309e..158ecbee37 100644 --- a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro +++ b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro @@ -19,6 +19,6 @@ requires(qtConfig(private_tests)) #DOCKERTODO Linux, docker is disabled on macOS and Windows. linux { + CONFIG += unsupported/testserver QT_TEST_SERVER_LIST = squid danted - include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) } From 220028d37c38835987b817193ecaf0e2a1ad066b Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Tue, 5 Mar 2019 22:39:27 +0100 Subject: [PATCH 209/292] QtBase: introduce QT_DEPRECATED_VERSION/QT_DEPRECATED_VERSION_X QT_DEPRECATED_VERSION(major, minor) and QT_DEPRECATED_VERSION_X(major, minor, text) outputs a deprecation warning if QT_DEPRECATED_WARNINGS_SINCE is equal or greater than the version specified as major, minor. This allows the user to hide deprecation warnings which can't yet be fixed for their codebase because the minimum required Qt version does not provide the replacement function. If QT_DEPRECATED_WARNINGS_SINCE is not set by the user, it's set to QT_DISABLE_DEPRECATED_BEFORE if available, otherwise to QT_VERSION. [ChangeLog][QtCore][QtGlobal] Add new macros QT_DEPRECATED_VERSION and QT_DEPRECATED_VERSION_X to conditionally display deprecation warnings Change-Id: I61b1a7624c9b870695c9e3274313de636f804b5d Reviewed-by: Konstantin Shegunov Reviewed-by: Edward Welbourne Reviewed-by: hjk --- mkspecs/features/qt_module.prf | 1 + src/corelib/global/qglobal.h | 53 +++++++++++++++++++++++++++++++++ src/widgets/widgets/qcombobox.h | 6 ++-- 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/mkspecs/features/qt_module.prf b/mkspecs/features/qt_module.prf index 51b5bde67a..8bd2d92421 100644 --- a/mkspecs/features/qt_module.prf +++ b/mkspecs/features/qt_module.prf @@ -317,5 +317,6 @@ win32 { # On other platforms, Qt's own compilation goes needs to compile the Qt 5.0 API DEFINES *= QT_DISABLE_DEPRECATED_BEFORE=0x050000 } +DEFINES *= QT_DEPRECATED_WARNINGS_SINCE=0x060000 TARGET = $$qt5LibraryTarget($$TARGET$$QT_LIBINFIX) # Do this towards the end diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index a0207b483d..3c17bbb2d4 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -307,6 +307,14 @@ typedef double qreal; # define QT_DEPRECATED_CONSTRUCTOR #endif +#ifndef QT_DEPRECATED_WARNINGS_SINCE +# ifdef QT_DISABLE_DEPRECATED_BEFORE +# define QT_DEPRECATED_WARNINGS_SINCE QT_DISABLE_DEPRECATED_BEFORE +# else +# define QT_DEPRECATED_WARNINGS_SINCE QT_VERSION +# endif +#endif + #ifndef QT_DISABLE_DEPRECATED_BEFORE #define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(5, 0, 0) #endif @@ -329,6 +337,51 @@ typedef double qreal; #define QT_DEPRECATED_SINCE(major, minor) 0 #endif +/* + QT_DEPRECATED_VERSION(major, minor) and QT_DEPRECATED_VERSION_X(major, minor, text) + outputs a deprecation warning if QT_DEPRECATED_WARNINGS_SINCE is equal or greater + than the version specified as major, minor. This makes it possible to deprecate a + function without annoying a user who needs to stick at a specified minimum version + and therefore can't use the new function. +*/ +#if QT_DEPRECATED_WARNINGS_SINCE >= QT_VERSION_CHECK(5, 12, 0) +# define QT_DEPRECATED_VERSION_X_5_12(text) QT_DEPRECATED_X(text) +# define QT_DEPRECATED_VERSION_5_12 QT_DEPRECATED +#else +# define QT_DEPRECATED_VERSION_X_5_12(text) +# define QT_DEPRECATED_VERSION_5_12 +#endif + +#if QT_DEPRECATED_WARNINGS_SINCE >= QT_VERSION_CHECK(5, 13, 0) +# define QT_DEPRECATED_VERSION_X_5_13(text) QT_DEPRECATED_X(text) +# define QT_DEPRECATED_VERSION_5_13 QT_DEPRECATED +#else +# define QT_DEPRECATED_VERSION_X_5_13(text) +# define QT_DEPRECATED_VERSION_5_13 +#endif + +#if QT_DEPRECATED_WARNINGS_SINCE >= QT_VERSION_CHECK(5, 14, 0) +# define QT_DEPRECATED_VERSION_X_5_14(text) QT_DEPRECATED_X(text) +# define QT_DEPRECATED_VERSION_5_14 QT_DEPRECATED +#else +# define QT_DEPRECATED_VERSION_X_5_14(text) +# define QT_DEPRECATED_VERSION_5_14 +#endif + +#if QT_DEPRECATED_WARNINGS_SINCE >= QT_VERSION_CHECK(5, 15, 0) +# define QT_DEPRECATED_VERSION_X_5_15(text) QT_DEPRECATED_X(text) +# define QT_DEPRECATED_VERSION_5_15 QT_DEPRECATED +#else +# define QT_DEPRECATED_VERSION_X_5_15(text) +# define QT_DEPRECATED_VERSION_5_15 +#endif + +#define QT_DEPRECATED_VERSION_X_5(minor, text) QT_DEPRECATED_VERSION_X_5_##minor(text) +#define QT_DEPRECATED_VERSION_X(major, minor, text) QT_DEPRECATED_VERSION_X_##major(minor, text) + +#define QT_DEPRECATED_VERSION_5(minor) QT_DEPRECATED_VERSION_5_##minor() +#define QT_DEPRECATED_VERSION(major, minor) QT_DEPRECATED_VERSION_##major(minor) + /* The Qt modules' export macros. The options are: diff --git a/src/widgets/widgets/qcombobox.h b/src/widgets/widgets/qcombobox.h index 6a87a675a4..37b155774d 100644 --- a/src/widgets/widgets/qcombobox.h +++ b/src/widgets/widgets/qcombobox.h @@ -226,13 +226,13 @@ Q_SIGNALS: void currentIndexChanged(int index); void currentTextChanged(const QString &); #if QT_DEPRECATED_SINCE(5, 13) - QT_DEPRECATED_X("Use currentTextChanged() instead") + QT_DEPRECATED_VERSION_X(5, 13, "Use currentTextChanged() instead") void currentIndexChanged(const QString &); #endif #if QT_DEPRECATED_SINCE(5, 15) - QT_DEPRECATED_X("Use textActivated() instead") + QT_DEPRECATED_VERSION_X(5, 15, "Use textActivated() instead") void activated(const QString &); - QT_DEPRECATED_X("Use textHighlighted() instead") + QT_DEPRECATED_VERSION_X(5, 15, "Use textHighlighted() instead") void highlighted(const QString &); #endif From c530ca1c170798159c3d84029841a1224d1cdc65 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 3 Mar 2019 12:14:43 +0100 Subject: [PATCH 210/292] QLineF: add intersects() as a replacement for intersect() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QLineF::intersect() does not follow the naming rules for functions. Therefore add a replacement function intersects() instead and also rename the return type from IntersectType to IntersectionType [ChangeLog][QtCore][QLineF] added QLineF::intersects() as a replacement for QLineF::intersect() Change-Id: I744b960ea339cb817facb12f296f78cca3e7d938 Reviewed-by: Jędrzej Nowacki Reviewed-by: Konstantin Shegunov --- .../graphicsview/diagramscene/arrow.cpp | 12 ++++----- src/corelib/tools/qline.cpp | 26 ++++++++++++++++++- src/corelib/tools/qline.h | 6 +++-- src/gui/painting/qstroker.cpp | 2 +- tests/auto/corelib/tools/qline/tst_qline.cpp | 2 +- 5 files changed, 36 insertions(+), 12 deletions(-) diff --git a/examples/widgets/graphicsview/diagramscene/arrow.cpp b/examples/widgets/graphicsview/diagramscene/arrow.cpp index 88160d9399..525e0b3fbb 100644 --- a/examples/widgets/graphicsview/diagramscene/arrow.cpp +++ b/examples/widgets/graphicsview/diagramscene/arrow.cpp @@ -113,15 +113,13 @@ void Arrow::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QLineF centerLine(myStartItem->pos(), myEndItem->pos()); QPolygonF endPolygon = myEndItem->polygon(); QPointF p1 = endPolygon.first() + myEndItem->pos(); - QPointF p2; QPointF intersectPoint; - QLineF polyLine; for (int i = 1; i < endPolygon.count(); ++i) { - p2 = endPolygon.at(i) + myEndItem->pos(); - polyLine = QLineF(p1, p2); - QLineF::IntersectType intersectType = - polyLine.intersect(centerLine, &intersectPoint); - if (intersectType == QLineF::BoundedIntersection) + QPointF p2 = endPolygon.at(i) + myEndItem->pos(); + QLineF polyLine = QLineF(p1, p2); + QLineF::IntersectionType intersectionType = + polyLine.intersects(centerLine, &intersectPoint); + if (intersectionType == QLineF::BoundedIntersection) break; p1 = p2; } diff --git a/src/corelib/tools/qline.cpp b/src/corelib/tools/qline.cpp index 6f3c22a6ec..3afd23d76b 100644 --- a/src/corelib/tools/qline.cpp +++ b/src/corelib/tools/qline.cpp @@ -347,7 +347,7 @@ QDataStream &operator>>(QDataStream &stream, QLine &line) function to determine whether the QLineF represents a valid line or a null line. - The intersect() function determines the IntersectType for this + The intersects() function determines the IntersectionType for this line and a given line, while the angleTo() function returns the angle between the lines. In addition, the unitVector() function returns a line that has the same starting point as this line, but @@ -370,6 +370,11 @@ QDataStream &operator>>(QDataStream &stream, QLine &line) /*! \enum QLineF::IntersectType + \obsolete Use QLineF::IntersectionType instead +*/ + +/*! + \enum QLineF::IntersectionType Describes the intersection between two lines. @@ -657,8 +662,10 @@ QLineF QLineF::unitVector() const return f; } +#if QT_DEPRECATED_SINCE(5, 14) /*! \fn QLineF::IntersectType QLineF::intersect(const QLineF &line, QPointF *intersectionPoint) const + \obsolete Use intersects() instead Returns a value indicating whether or not \e this line intersects with the given \a line. @@ -669,6 +676,23 @@ QLineF QLineF::unitVector() const */ QLineF::IntersectType QLineF::intersect(const QLineF &l, QPointF *intersectionPoint) const +{ + return intersects(l, intersectionPoint); +} +#endif + +/*! + \fn QLineF::IntersectionType QLineF::intersects(const QLineF &line, QPointF *intersectionPoint) const + \since 5.14 + + Returns a value indicating whether or not \e this line intersects + with the given \a line. + + The actual intersection point is extracted to \a intersectionPoint + (if the pointer is valid). If the lines are parallel, the + intersection point is undefined. +*/ +QLineF::IntersectionType QLineF::intersects(const QLineF &l, QPointF *intersectionPoint) const { // ipmlementation is based on Graphics Gems III's "Faster Line Segment Intersection" const QPointF a = pt2 - pt1; diff --git a/src/corelib/tools/qline.h b/src/corelib/tools/qline.h index 14980b60a0..c96d624afd 100644 --- a/src/corelib/tools/qline.h +++ b/src/corelib/tools/qline.h @@ -215,6 +215,7 @@ class Q_CORE_EXPORT QLineF { public: enum IntersectType { NoIntersection, BoundedIntersection, UnboundedIntersection }; + using IntersectionType = IntersectType; Q_DECL_CONSTEXPR inline QLineF(); Q_DECL_CONSTEXPR inline QLineF(const QPointF &pt1, const QPointF &pt2); @@ -248,10 +249,11 @@ public: Q_REQUIRED_RESULT QLineF unitVector() const; Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QLineF normalVector() const; - // ### Qt 6: rename intersects() or intersection() and rename IntersectType IntersectionType - IntersectType intersect(const QLineF &l, QPointF *intersectionPoint) const; + IntersectionType intersects(const QLineF &l, QPointF *intersectionPoint) const; #if QT_DEPRECATED_SINCE(5, 14) + QT_DEPRECATED_VERSION_X(5, 14, "Use intersects() instead") + IntersectType intersect(const QLineF &l, QPointF *intersectionPoint) const; QT_DEPRECATED_X("Use angleTo() instead, take care that the return value is between 0 and 360 degree.") qreal angle(const QLineF &l) const; #endif diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp index f8f8d72d14..f158222f82 100644 --- a/src/gui/painting/qstroker.cpp +++ b/src/gui/painting/qstroker.cpp @@ -456,7 +456,7 @@ void QStroker::joinPoints(qfixed focal_x, qfixed focal_y, const QLineF &nextLine QLineF prevLine(qt_fixed_to_real(m_back2X), qt_fixed_to_real(m_back2Y), qt_fixed_to_real(m_back1X), qt_fixed_to_real(m_back1Y)); QPointF isect; - QLineF::IntersectType type = prevLine.intersect(nextLine, &isect); + QLineF::IntersectionType type = prevLine.intersects(nextLine, &isect); if (join == FlatJoin) { QLineF shortCut(prevLine.p2(), nextLine.p1()); diff --git a/tests/auto/corelib/tools/qline/tst_qline.cpp b/tests/auto/corelib/tools/qline/tst_qline.cpp index ae65d8f697..915a24a1f6 100644 --- a/tests/auto/corelib/tools/qline/tst_qline.cpp +++ b/tests/auto/corelib/tools/qline/tst_qline.cpp @@ -205,7 +205,7 @@ void tst_QLine::testIntersection() QPointF ip; - QLineF::IntersectType itype = a.intersect(b, &ip); + QLineF::IntersectionType itype = a.intersect(b, &ip); QCOMPARE(int(itype), type); if (type != QLineF::NoIntersection) { From e092b32922ef650d49167aaf48f9d33190191f9f Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 23 Apr 2019 07:48:50 +0200 Subject: [PATCH 211/292] QTextMarkdownImporter: insert list items into the correct list There was a bug when handling situations like 1. first 1) subfirst 2. second It was always inserting items into the list where the cursor already was, but it needs to insert the "second" list item into the list which is currently the top of m_listStack. Change-Id: Id0899032efafb2e2b9e7c45a6fb9f2c5221fc4df Reviewed-by: Gatis Paeglis --- src/gui/text/qtextmarkdownimporter.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp index 6bff337ff4..2477e0bc74 100644 --- a/src/gui/text/qtextmarkdownimporter.cpp +++ b/src/gui/text/qtextmarkdownimporter.cpp @@ -165,13 +165,14 @@ int QTextMarkdownImporter::cbEnterBlock(MD_BLOCKTYPE type, void *det) } break; case MD_BLOCK_LI: { MD_BLOCK_LI_DETAIL *detail = static_cast(det); - QTextBlockFormat bfmt = m_cursor->blockFormat(); + QTextList *list = m_listStack.top(); + QTextBlockFormat bfmt = list->item(list->count() - 1).blockFormat(); bfmt.setMarker(detail->is_task ? (detail->task_mark == ' ' ? QTextBlockFormat::Unchecked : QTextBlockFormat::Checked) : QTextBlockFormat::NoMarker); if (!m_emptyList) { m_cursor->insertBlock(bfmt, QTextCharFormat()); - m_listStack.top()->add(m_cursor->block()); + list->add(m_cursor->block()); } m_cursor->setBlockFormat(bfmt); m_emptyList = false; // Avoid insertBlock for the first item (because insertList already did that) From 8059762565d1ed6b7aaee2729d3a637efcd671d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Thu, 25 Apr 2019 17:30:36 +0200 Subject: [PATCH 212/292] Set 'originalRequest' in QNetworkReplyImpl It's what's returned when calling request() on a QNetworkReply, but for QNetworkReplyImpl (the implementation used for e.g. FTP) it was not set, so it returned a default object. Change-Id: Id82f7920e4268c1a7743e681fc503bcd28889b6e Reviewed-by: Thiago Macieira Reviewed-by: Markus Goetz (Woboq GmbH) Reviewed-by: Edward Welbourne --- src/network/access/qnetworkreplyimpl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index a794b492e7..f5bb4d5887 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -368,6 +368,7 @@ void QNetworkReplyImplPrivate::setup(QNetworkAccessManager::Operation op, const outgoingData = data; request = req; + originalRequest = req; url = request.url(); operation = op; From 9a6a84731131b205f74b10f866ae212e0895bd4a Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Tue, 18 Dec 2018 16:41:39 +0100 Subject: [PATCH 213/292] Add RISC-V detection Change-Id: I0203c88e0944064841c9f6fe9f8a7888d6c421d1 Reviewed-by: Giuseppe D'Angelo Reviewed-by: Thiago Macieira --- src/corelib/global/archdetect.cpp | 4 +++ src/corelib/global/qglobal.cpp | 36 ++++++++++++++++++++++++ src/corelib/global/qprocessordetection.h | 14 +++++++++ 3 files changed, 54 insertions(+) diff --git a/src/corelib/global/archdetect.cpp b/src/corelib/global/archdetect.cpp index 66a5e074f6..1d00b7f5a5 100644 --- a/src/corelib/global/archdetect.cpp +++ b/src/corelib/global/archdetect.cpp @@ -67,6 +67,10 @@ # define ARCH_PROCESSOR "power" #elif defined(Q_PROCESSOR_POWER_64) # define ARCH_PROCESSOR "power64" +#elif defined(Q_PROCESSOR_RISCV_32) +# define ARCH_PROCESSOR "riscv32" +#elif defined(Q_PROCESSOR_RISCV_64) +# define ARCH_PROCESSOR "riscv64" #elif defined(Q_PROCESSOR_S390_X) # define ARCH_PROCESSOR "s390x" #elif defined(Q_PROCESSOR_S390) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index d95064af27..16d8d8b8ac 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1883,6 +1883,42 @@ bool qSharedBuild() noexcept \sa QSysInfo::buildCpuArchitecture() */ +/*! + \macro Q_PROCESSOR_RISCV + \relates + \since 5.13 + + Defined if the application is compiled for RISC-V processors. Qt currently + supports two RISC-V variants: \l Q_PROCESSOR_RISCV_32 and \l + Q_PROCESSOR_RISCV_64. + + \sa QSysInfo::buildCpuArchitecture() +*/ + +/*! + \macro Q_PROCESSOR_RISCV_32 + \relates + \since 5.13 + + Defined if the application is compiled for 32-bit RISC-V processors. The \l + Q_PROCESSOR_RISCV macro is also defined when Q_PROCESSOR_RISCV_32 is + defined. + + \sa QSysInfo::buildCpuArchitecture() +*/ + +/*! + \macro Q_PROCESSOR_RISCV_64 + \relates + \since 5.13 + + Defined if the application is compiled for 64-bit RISC-V processors. The \l + Q_PROCESSOR_RISCV macro is also defined when Q_PROCESSOR_RISCV_64 is + defined. + + \sa QSysInfo::buildCpuArchitecture() +*/ + /*! \macro Q_PROCESSOR_S390 \relates diff --git a/src/corelib/global/qprocessordetection.h b/src/corelib/global/qprocessordetection.h index 1f327c352e..8d65720850 100644 --- a/src/corelib/global/qprocessordetection.h +++ b/src/corelib/global/qprocessordetection.h @@ -281,6 +281,20 @@ # endif // Q_BYTE_ORDER not defined, use endianness auto-detection +/* + RISC-V family, known variants: 32- and 64-bit + + RISC-V is little-endian. +*/ +#elif defined(__riscv) +# define Q_PROCESSOR_RISCV +# if __riscv_xlen == 64 +# define Q_PROCESSOR_RISCV_64 +# else +# define Q_PROCESSOR_RISCV_32 +# endif +# define Q_BYTE_ORDER Q_LITTLE_ENDIAN + /* S390 family, known variant: S390X (64-bit) From 8e82e536cdbf2b6c36a7eabd6fba1a85613973f8 Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Tue, 19 Mar 2019 11:41:53 +0100 Subject: [PATCH 214/292] FTP: Workaround for servers without HELP command support Ignores errors produced by the HELP command. It will continue executing the commands sent to QFtp when a server does not have a HELP command implemented. Commands SIZE, MDTM, and PWD are not going to be used if the HELP command failed. [ChangeLog][QtNetwork][QNetworkAccessManager] Don't fail when FTP does not implement the HELP command. Task-number: QTBUG-69477 Change-Id: I0ebd51b134535730c6bef83de1abf1a427b8d2ce Reviewed-by: Thiago Macieira Reviewed-by: Edward Welbourne --- src/network/access/qftp.cpp | 11 +++++++++++ src/network/access/qftp_p.h | 3 +++ src/network/access/qnetworkaccessftpbackend.cpp | 7 ++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp index 4e399f018f..b6b721030b 100644 --- a/src/network/access/qftp.cpp +++ b/src/network/access/qftp.cpp @@ -2122,6 +2122,17 @@ void QFtp::abort() d_func()->pi.abort(); } +/*! + \internal + Clears the last error. + + \sa currentCommand() +*/ +void QFtp::clearError() +{ + d_func()->error = NoError; +} + /*! \internal Returns the identifier of the FTP command that is being executed diff --git a/src/network/access/qftp_p.h b/src/network/access/qftp_p.h index 91d78d1351..a55429933b 100644 --- a/src/network/access/qftp_p.h +++ b/src/network/access/qftp_p.h @@ -157,6 +157,9 @@ Q_SIGNALS: void commandFinished(int, bool); void done(bool); +protected: + void clearError(); + private: Q_DISABLE_COPY_MOVE(QFtp) Q_DECLARE_PRIVATE(QFtp) diff --git a/src/network/access/qnetworkaccessftpbackend.cpp b/src/network/access/qnetworkaccessftpbackend.cpp index 5ad820eba0..51ed2f5a55 100644 --- a/src/network/access/qnetworkaccessftpbackend.cpp +++ b/src/network/access/qnetworkaccessftpbackend.cpp @@ -99,6 +99,8 @@ public: connect(this, SIGNAL(done(bool)), this, SLOT(deleteLater())); close(); } + + using QFtp::clearError; }; QNetworkAccessFtpBackend::QNetworkAccessFtpBackend() @@ -282,7 +284,10 @@ void QNetworkAccessFtpBackend::ftpDone() } // check for errors: - if (ftp->error() != QFtp::NoError) { + if (state == CheckingFeatures && ftp->error() == QFtp::UnknownError) { + qWarning("QNetworkAccessFtpBackend: HELP command failed, ignoring it"); + ftp->clearError(); + } else if (ftp->error() != QFtp::NoError) { QString msg; if (operation() == QNetworkAccessManager::GetOperation) msg = tr("Error while downloading %1: %2"); From 8e2895557471538afc4610c4340701a39d59a851 Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Tue, 2 Oct 2018 11:44:49 +0200 Subject: [PATCH 215/292] Plug and paint example: Fix -Wweak-tables Fixes warning: 'BrushInterface' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit Change-Id: I2e693ac60e9eba1976665546e1c9c4a92e6ff63b Reviewed-by: Paul Wicking Reviewed-by: Richard Moe Gustavsen --- examples/widgets/tools/plugandpaint/app/interfaces.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/widgets/tools/plugandpaint/app/interfaces.h b/examples/widgets/tools/plugandpaint/app/interfaces.h index a1e91e13ff..705e578809 100644 --- a/examples/widgets/tools/plugandpaint/app/interfaces.h +++ b/examples/widgets/tools/plugandpaint/app/interfaces.h @@ -68,7 +68,7 @@ QT_END_NAMESPACE class BrushInterface { public: - virtual ~BrushInterface() {} + virtual ~BrushInterface() = default; virtual QStringList brushes() const = 0; virtual QRect mousePress(const QString &brush, QPainter &painter, @@ -84,7 +84,7 @@ public: class ShapeInterface { public: - virtual ~ShapeInterface() {} + virtual ~ShapeInterface() = default; virtual QStringList shapes() const = 0; virtual QPainterPath generateShape(const QString &shape, @@ -96,7 +96,7 @@ public: class FilterInterface { public: - virtual ~FilterInterface() {} + virtual ~FilterInterface() = default; virtual QStringList filters() const = 0; virtual QImage filterImage(const QString &filter, const QImage &image, From d647cf85fa3813a65921266a9998cd2e54e5f2f9 Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Fri, 5 Oct 2018 14:53:18 +0200 Subject: [PATCH 216/292] Tests: Simplify MyCookieJar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't reimplement the protected functions in the base class just override the access with the using keyword. Change-Id: I323487d9ddb1d458d5faca020c3eb4d931a9b226 Reviewed-by: Mårten Nordheim Reviewed-by: Edward Welbourne --- .../access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp index 45abb6aa05..1ef2c118b9 100644 --- a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp +++ b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp @@ -61,10 +61,8 @@ class MyCookieJar: public QNetworkCookieJar { public: ~MyCookieJar() override; - inline QList allCookies() const - { return QNetworkCookieJar::allCookies(); } - inline void setAllCookies(const QList &cookieList) - { QNetworkCookieJar::setAllCookies(cookieList); } + using QNetworkCookieJar::allCookies; + using QNetworkCookieJar::setAllCookies; }; MyCookieJar::~MyCookieJar() = default; From dc3e5c48380ff564df9a232b13e2cf1fab65f66d Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 24 Apr 2019 17:06:15 +0200 Subject: [PATCH 217/292] Consolidate Unix and Windows implementations of QHostInfo::fromName The implementations were practically identical, so we can just move the code into qhostinfo.cpp, cleaning up things along the way. Since QHostInfoAgent is an internal class, add the shared code as additional static helper functions. And since half the code already used QCoreApplication::translate anyway, we can remove the QObject inheritance which was only added for getting a tr(). Change-Id: I58eafbdc3e7d06d2e898486a1add63cd63d98c96 Reviewed-by: Thiago Macieira --- src/network/kernel/qhostinfo.cpp | 168 ++++++++++++++++++++++++++ src/network/kernel/qhostinfo_p.h | 7 +- src/network/kernel/qhostinfo_unix.cpp | 139 +-------------------- src/network/kernel/qhostinfo_win.cpp | 111 +---------------- 4 files changed, 178 insertions(+), 247 deletions(-) diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index d3fe85f5d5..9374728244 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -37,8 +37,11 @@ ** ****************************************************************************/ +//#define QHOSTINFO_DEBUG + #include "qhostinfo.h" #include "qhostinfo_p.h" +#include #include "QtCore/qscopedpointer.h" #include @@ -53,6 +56,15 @@ #ifdef Q_OS_UNIX # include +# include +# include +# if defined(AI_ADDRCONFIG) +# define Q_ADDRCONFIG AI_ADDRCONFIG +# endif +#elif defined Q_OS_WIN +# include + +# define QT_SOCKLEN_T int #endif QT_BEGIN_NAMESPACE @@ -412,6 +424,162 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName, QSharedPointer(&sa4); + saSize = sizeof(sa4); + memset(&sa4, 0, sizeof(sa4)); + sa4.sin_family = AF_INET; + sa4.sin_addr.s_addr = htonl(address.toIPv4Address()); + } else { + sa = reinterpret_cast(&sa6); + saSize = sizeof(sa6); + memset(&sa6, 0, sizeof(sa6)); + sa6.sin6_family = AF_INET6; + memcpy(&sa6.sin6_addr, address.toIPv6Address().c, sizeof(sa6.sin6_addr)); + } + + char hbuf[NI_MAXHOST]; + if (sa && getnameinfo(sa, saSize, hbuf, sizeof(hbuf), nullptr, 0, 0) == 0) + results.setHostName(QString::fromLatin1(hbuf)); + + if (results.hostName().isEmpty()) + results.setHostName(address.toString()); + results.setAddresses(QList() << address); + + return results; +} + +/* + Call getaddrinfo, and returns the results as QHostInfo::addresses +*/ +QHostInfo QHostInfoAgent::lookup(const QString &hostName) +{ + QHostInfo results; + + // IDN support + QByteArray aceHostname = QUrl::toAce(hostName); + results.setHostName(hostName); + if (aceHostname.isEmpty()) { + results.setError(QHostInfo::HostNotFound); + results.setErrorString(hostName.isEmpty() ? + QCoreApplication::translate("QHostInfoAgent", "No host name given") : + QCoreApplication::translate("QHostInfoAgent", "Invalid hostname")); + return results; + } + + addrinfo *res = 0; + struct addrinfo hints; + memset(&hints, 0, sizeof(hints)); + hints.ai_family = PF_UNSPEC; +#ifdef Q_ADDRCONFIG + hints.ai_flags = Q_ADDRCONFIG; +#endif + + int result = getaddrinfo(aceHostname.constData(), nullptr, &hints, &res); +# ifdef Q_ADDRCONFIG + if (result == EAI_BADFLAGS) { + // if the lookup failed with AI_ADDRCONFIG set, try again without it + hints.ai_flags = 0; + result = getaddrinfo(aceHostname.constData(), nullptr, &hints, &res); + } +# endif + + if (result == 0) { + addrinfo *node = res; + QList addresses; + while (node) { +#ifdef QHOSTINFO_DEBUG + qDebug() << "getaddrinfo node: flags:" << node->ai_flags << "family:" << node->ai_family + << "ai_socktype:" << node->ai_socktype << "ai_protocol:" << node->ai_protocol + << "ai_addrlen:" << node->ai_addrlen; +#endif + switch (node->ai_family) { + case AF_INET: { + QHostAddress addr; + addr.setAddress(ntohl(((sockaddr_in *) node->ai_addr)->sin_addr.s_addr)); + if (!addresses.contains(addr)) + addresses.append(addr); + break; + } + case AF_INET6: { + QHostAddress addr; + sockaddr_in6 *sa6 = (sockaddr_in6 *) node->ai_addr; + addr.setAddress(sa6->sin6_addr.s6_addr); + if (sa6->sin6_scope_id) + addr.setScopeId(QString::number(sa6->sin6_scope_id)); + if (!addresses.contains(addr)) + addresses.append(addr); + break; + } + default: + results.setError(QHostInfo::UnknownError); + results.setErrorString(QCoreApplication::translate("QHostInfoAgent", "Unknown address type")); + } + node = node->ai_next; + } + if (addresses.isEmpty()) { + // Reached the end of the list, but no addresses were found; this + // means the list contains one or more unknown address types. + results.setError(QHostInfo::UnknownError); + results.setErrorString(QCoreApplication::translate("QHostInfoAgent", "Unknown address type")); + } + + results.setAddresses(addresses); + freeaddrinfo(res); + } else { + switch (result) { +#ifdef Q_OS_WIN + case WSAHOST_NOT_FOUND: //authoritative not found + case WSATRY_AGAIN: //non authoritative not found + case WSANO_DATA: //valid name, no associated address +#else + case EAI_NONAME: + case EAI_FAIL: +# ifdef EAI_NODATA // EAI_NODATA is deprecated in RFC 3493 + case EAI_NODATA: +# endif +#endif + results.setError(QHostInfo::HostNotFound); + results.setErrorString(QCoreApplication::translate("QHostInfoAgent", "Host not found")); + break; + default: + results.setError(QHostInfo::UnknownError); +#ifdef Q_OS_WIN + results.setErrorString(QString::fromWCharArray(gai_strerror(result))); +#else + results.setErrorString(QString::fromLocal8Bit(gai_strerror(result))); +#endif + break; + } + } + +#if defined(QHOSTINFO_DEBUG) + if (results.error() != QHostInfo::NoError) { + qDebug("QHostInfoAgent::fromName(): error #%d %s", + h_errno, results.errorString().toLatin1().constData()); + } else { + QString tmp; + QList addresses = results.addresses(); + for (int i = 0; i < addresses.count(); ++i) { + if (i != 0) tmp += QLatin1String(", "); + tmp += addresses.at(i).toString(); + } + qDebug("QHostInfoAgent::fromName(): found %i entries for \"%s\": {%s}", + addresses.count(), aceHostname.constData(), + tmp.toLatin1().constData()); + } +#endif + + return results; +} /*! \enum QHostInfo::HostInfoError diff --git a/src/network/kernel/qhostinfo_p.h b/src/network/kernel/qhostinfo_p.h index da02163ddf..3c0ee2a0d8 100644 --- a/src/network/kernel/qhostinfo_p.h +++ b/src/network/kernel/qhostinfo_p.h @@ -127,15 +127,16 @@ Q_SIGNALS: void resultsReady(const QHostInfo &info); }; -// needs to be QObject because fromName calls tr() -class QHostInfoAgent : public QObject +class QHostInfoAgent { - Q_OBJECT public: static QHostInfo fromName(const QString &hostName); #ifndef QT_NO_BEARERMANAGEMENT static QHostInfo fromName(const QString &hostName, QSharedPointer networkSession); #endif +private: + static QHostInfo lookup(const QString &hostName); + static QHostInfo reverseLookup(const QHostAddress &address); }; class QHostInfoPrivate diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp index e4810d68ee..78a05f8407 100644 --- a/src/network/kernel/qhostinfo_unix.cpp +++ b/src/network/kernel/qhostinfo_unix.cpp @@ -72,17 +72,6 @@ QT_BEGIN_NAMESPACE -// Almost always the same. If not, specify in qplatformdefs.h. -#if !defined(QT_SOCKOPTLEN_T) -# define QT_SOCKOPTLEN_T QT_SOCKLEN_T -#endif - -// HP-UXi has a bug in getaddrinfo(3) that makes it thread-unsafe -// with this flag. So disable it in that platform. -#if defined(AI_ADDRCONFIG) && !defined(Q_OS_HPUX) -# define Q_ADDRCONFIG AI_ADDRCONFIG -#endif - enum LibResolvFeature { NeedResInit, NeedResNInit @@ -197,132 +186,10 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName) local_res_init(); QHostAddress address; - if (address.setAddress(hostName)) { - // Reverse lookup - sockaddr_in sa4; - sockaddr_in6 sa6; - sockaddr *sa = 0; - QT_SOCKLEN_T saSize = 0; - if (address.protocol() == QAbstractSocket::IPv4Protocol) { - sa = (sockaddr *)&sa4; - saSize = sizeof(sa4); - memset(&sa4, 0, sizeof(sa4)); - sa4.sin_family = AF_INET; - sa4.sin_addr.s_addr = htonl(address.toIPv4Address()); - } - else { - sa = (sockaddr *)&sa6; - saSize = sizeof(sa6); - memset(&sa6, 0, sizeof(sa6)); - sa6.sin6_family = AF_INET6; - memcpy(sa6.sin6_addr.s6_addr, address.toIPv6Address().c, sizeof(sa6.sin6_addr.s6_addr)); - } + if (address.setAddress(hostName)) + return reverseLookup(address); - char hbuf[NI_MAXHOST]; - if (sa && getnameinfo(sa, saSize, hbuf, sizeof(hbuf), 0, 0, 0) == 0) - results.setHostName(QString::fromLatin1(hbuf)); - - if (results.hostName().isEmpty()) - results.setHostName(address.toString()); - results.setAddresses(QList() << address); - return results; - } - - // IDN support - QByteArray aceHostname = QUrl::toAce(hostName); - results.setHostName(hostName); - if (aceHostname.isEmpty()) { - results.setError(QHostInfo::HostNotFound); - results.setErrorString(hostName.isEmpty() ? - QCoreApplication::translate("QHostInfoAgent", "No host name given") : - QCoreApplication::translate("QHostInfoAgent", "Invalid hostname")); - return results; - } - - // Call getaddrinfo, and place all IPv4 addresses at the start and - // the IPv6 addresses at the end of the address list in results. - addrinfo *res = 0; - struct addrinfo hints; - memset(&hints, 0, sizeof(hints)); - hints.ai_family = PF_UNSPEC; -#ifdef Q_ADDRCONFIG - hints.ai_flags = Q_ADDRCONFIG; -#endif - - int result = getaddrinfo(aceHostname.constData(), 0, &hints, &res); -# ifdef Q_ADDRCONFIG - if (result == EAI_BADFLAGS) { - // if the lookup failed with AI_ADDRCONFIG set, try again without it - hints.ai_flags = 0; - result = getaddrinfo(aceHostname.constData(), 0, &hints, &res); - } -# endif - - if (result == 0) { - addrinfo *node = res; - QList addresses; - while (node) { -#ifdef QHOSTINFO_DEBUG - qDebug() << "getaddrinfo node: flags:" << node->ai_flags << "family:" << node->ai_family << "ai_socktype:" << node->ai_socktype << "ai_protocol:" << node->ai_protocol << "ai_addrlen:" << node->ai_addrlen; -#endif - if (node->ai_family == AF_INET) { - QHostAddress addr; - addr.setAddress(ntohl(((sockaddr_in *) node->ai_addr)->sin_addr.s_addr)); - if (!addresses.contains(addr)) - addresses.append(addr); - } - else if (node->ai_family == AF_INET6) { - QHostAddress addr; - sockaddr_in6 *sa6 = (sockaddr_in6 *) node->ai_addr; - addr.setAddress(sa6->sin6_addr.s6_addr); - if (sa6->sin6_scope_id) - addr.setScopeId(QString::number(sa6->sin6_scope_id)); - if (!addresses.contains(addr)) - addresses.append(addr); - } - node = node->ai_next; - } - if (addresses.isEmpty() && node == 0) { - // Reached the end of the list, but no addresses were found; this - // means the list contains one or more unknown address types. - results.setError(QHostInfo::UnknownError); - results.setErrorString(tr("Unknown address type")); - } - - results.setAddresses(addresses); - freeaddrinfo(res); - } else if (result == EAI_NONAME - || result == EAI_FAIL -#ifdef EAI_NODATA - // EAI_NODATA is deprecated in RFC 3493 - || result == EAI_NODATA -#endif - ) { - results.setError(QHostInfo::HostNotFound); - results.setErrorString(tr("Host not found")); - } else { - results.setError(QHostInfo::UnknownError); - results.setErrorString(QString::fromLocal8Bit(gai_strerror(result))); - } - - -#if defined(QHOSTINFO_DEBUG) - if (results.error() != QHostInfo::NoError) { - qDebug("QHostInfoAgent::fromName(): error #%d %s", - h_errno, results.errorString().toLatin1().constData()); - } else { - QString tmp; - QList addresses = results.addresses(); - for (int i = 0; i < addresses.count(); ++i) { - if (i != 0) tmp += ", "; - tmp += addresses.at(i).toString(); - } - qDebug("QHostInfoAgent::fromName(): found %i entries for \"%s\": {%s}", - addresses.count(), hostName.toLatin1().constData(), - tmp.toLatin1().constData()); - } -#endif - return results; + return lookup(hostName); } QString QHostInfo::localDomainName() diff --git a/src/network/kernel/qhostinfo_win.cpp b/src/network/kernel/qhostinfo_win.cpp index ef7cff46f1..0b5cc98970 100644 --- a/src/network/kernel/qhostinfo_win.cpp +++ b/src/network/kernel/qhostinfo_win.cpp @@ -51,27 +51,10 @@ QT_BEGIN_NAMESPACE //#define QHOSTINFO_DEBUG //### -#define QT_SOCKLEN_T int #ifndef NI_MAXHOST // already defined to 1025 in ws2tcpip.h? #define NI_MAXHOST 1024 #endif -static void translateWSAError(int error, QHostInfo *results) -{ - switch (error) { - case WSAHOST_NOT_FOUND: //authoritative not found - case WSATRY_AGAIN: //non authoritative not found - case WSANO_DATA: //valid name, no associated address - results->setError(QHostInfo::HostNotFound); - results->setErrorString(QHostInfoAgent::tr("Host not found")); - return; - default: - results->setError(QHostInfo::UnknownError); - results->setErrorString(QHostInfoAgent::tr("Unknown error (%1)").arg(error)); - return; - } -} - QHostInfo QHostInfoAgent::fromName(const QString &hostName) { QSysInfo::machineHostName(); // this initializes ws2_32.dll @@ -84,98 +67,10 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName) #endif QHostAddress address; - if (address.setAddress(hostName)) { - // Reverse lookup - sockaddr_in sa4; - sockaddr_in6 sa6; - sockaddr *sa; - QT_SOCKLEN_T saSize; - if (address.protocol() == QAbstractSocket::IPv4Protocol) { - sa = reinterpret_cast(&sa4); - saSize = sizeof(sa4); - memset(&sa4, 0, sizeof(sa4)); - sa4.sin_family = AF_INET; - sa4.sin_addr.s_addr = htonl(address.toIPv4Address()); - } else { - sa = reinterpret_cast(&sa6); - saSize = sizeof(sa6); - memset(&sa6, 0, sizeof(sa6)); - sa6.sin6_family = AF_INET6; - memcpy(&sa6.sin6_addr, address.toIPv6Address().c, sizeof(sa6.sin6_addr)); - } + if (address.setAddress(hostName)) + return reverseLookup(address); - char hbuf[NI_MAXHOST]; - if (getnameinfo(sa, saSize, hbuf, sizeof(hbuf), 0, 0, 0) == 0) - results.setHostName(QString::fromLatin1(hbuf)); - - if (results.hostName().isEmpty()) - results.setHostName(address.toString()); - results.setAddresses(QList() << address); - return results; - } - - // IDN support - QByteArray aceHostname = QUrl::toAce(hostName); - results.setHostName(hostName); - if (aceHostname.isEmpty()) { - results.setError(QHostInfo::HostNotFound); - results.setErrorString(hostName.isEmpty() ? tr("No host name given") : tr("Invalid hostname")); - return results; - } - - addrinfo *res; - int err = getaddrinfo(aceHostname.constData(), 0, 0, &res); - if (err == 0) { - QList addresses; - for (addrinfo *p = res; p != 0; p = p->ai_next) { -#ifdef QHOSTINFO_DEBUG - qDebug() << "getaddrinfo node: flags:" << p->ai_flags << "family:" << p->ai_family - << "ai_socktype:" << p->ai_socktype << "ai_protocol:" << p->ai_protocol - << "ai_addrlen:" << p->ai_addrlen; -#endif - - switch (p->ai_family) { - case AF_INET: { - QHostAddress addr; - addr.setAddress(ntohl(reinterpret_cast(p->ai_addr)->sin_addr.s_addr)); - if (!addresses.contains(addr)) - addresses.append(addr); - } - break; - case AF_INET6: { - QHostAddress addr; - addr.setAddress(reinterpret_cast(p->ai_addr)->sin6_addr.s6_addr); - if (!addresses.contains(addr)) - addresses.append(addr); - } - break; - default: - results.setError(QHostInfo::UnknownError); - results.setErrorString(tr("Unknown address type")); - } - } - results.setAddresses(addresses); - freeaddrinfo(res); - } else { - translateWSAError(WSAGetLastError(), &results); - } - -#if defined(QHOSTINFO_DEBUG) - if (results.error() != QHostInfo::NoError) { - qDebug("QHostInfoAgent::run(): error (%s)", - results.errorString().toLatin1().constData()); - } else { - QString tmp; - QList addresses = results.addresses(); - for (int i = 0; i < addresses.count(); ++i) { - if (i != 0) tmp += QLatin1String(", "); - tmp += addresses.at(i).toString(); - } - qDebug("QHostInfoAgent::run(): found %i entries: {%s}", - addresses.count(), tmp.toLatin1().constData()); - } -#endif - return results; + return lookup(hostName); } // QString QHostInfo::localDomainName() defined in qnetworkinterface_win.cpp From abd2cf3b0a8c862d09f8163278424ca54297f854 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 26 Apr 2019 11:47:00 +0200 Subject: [PATCH 218/292] Remove extraneous sodipodi/inkskape cruft from Qt SVG Change-Id: Ib2d77331b33cac97e819e8273362703fcd80886c Reviewed-by: Allan Sandfeld Jensen --- src/plugins/platforms/wasm/qtlogo.svg | 29 +-------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/src/plugins/platforms/wasm/qtlogo.svg b/src/plugins/platforms/wasm/qtlogo.svg index cb8989bb79..ad7c7776bf 100644 --- a/src/plugins/platforms/wasm/qtlogo.svg +++ b/src/plugins/platforms/wasm/qtlogo.svg @@ -5,15 +5,10 @@ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="462pt" height="339pt" viewBox="0 0 462 339" - version="1.1" - id="svg2" - inkscape:version="0.91 r13725" - sodipodi:docname="TheQtCompany_logo_2.svg"> + version="1.1"> @@ -26,28 +21,6 @@ - - Date: Tue, 30 Apr 2019 09:44:18 +0200 Subject: [PATCH 219/292] QList: do not call std::swap directly; use ADL Change-Id: Iaf6b965dd123f39436ba134ea1065d8dc4278c1e Reviewed-by: Thiago Macieira --- src/corelib/tools/qlist.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index dfb8a8a4ab..48a71b0ecf 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -709,7 +709,8 @@ inline void QList::swapItemsAt(int i, int j) Q_ASSERT_X(i >= 0 && i < p.size() && j >= 0 && j < p.size(), "QList::swap", "index out of range"); detach(); - std::swap(d->array[d->begin + i], d->array[d->begin + j]); + using std::swap; + swap(d->array[d->begin + i], d->array[d->begin + j]); } template From 9ec564b0bfc94c2d33f02b24ca081b64ff9ebb9b Mon Sep 17 00:00:00 2001 From: James McDonnell Date: Fri, 4 May 2018 14:23:51 -0400 Subject: [PATCH 220/292] Basic foreign window support for QNX Requires a screen with working context permission parsing. Currently, all context permission requests fail because the parsing is incorrect. A context permission is added temporarily to prevent CLOSE/CREATE events when Qt reparents foreign windows. Qt does this temporarily when a foreign window is wrapped in a widget. Change-Id: I84c18e70d43239286fcd53715332d7015cf1a826 Reviewed-by: Rafael Roquetto --- .../widgets/qnx/foreignwindows/collector.cpp | 176 ++++++++++++++++++ .../widgets/qnx/foreignwindows/collector.h | 75 ++++++++ .../qnx/foreignwindows/foreignwindows.pro | 11 ++ examples/widgets/qnx/foreignwindows/main.cpp | 53 ++++++ src/plugins/platforms/qnx/qnx.pro | 2 + .../platforms/qnx/qqnxforeignwindow.cpp | 65 +++++++ src/plugins/platforms/qnx/qqnxforeignwindow.h | 61 ++++++ src/plugins/platforms/qnx/qqnxintegration.cpp | 27 ++- src/plugins/platforms/qnx/qqnxintegration.h | 7 +- .../platforms/qnx/qqnxscreeneventhandler.cpp | 49 +++++ src/plugins/platforms/qnx/qqnxscreentraits.h | 127 +++++++++++++ src/plugins/platforms/qnx/qqnxwindow.cpp | 96 +++++++++- src/plugins/platforms/qnx/qqnxwindow.h | 8 +- 13 files changed, 747 insertions(+), 10 deletions(-) create mode 100644 examples/widgets/qnx/foreignwindows/collector.cpp create mode 100644 examples/widgets/qnx/foreignwindows/collector.h create mode 100644 examples/widgets/qnx/foreignwindows/foreignwindows.pro create mode 100644 examples/widgets/qnx/foreignwindows/main.cpp create mode 100644 src/plugins/platforms/qnx/qqnxforeignwindow.cpp create mode 100644 src/plugins/platforms/qnx/qqnxforeignwindow.h create mode 100644 src/plugins/platforms/qnx/qqnxscreentraits.h diff --git a/examples/widgets/qnx/foreignwindows/collector.cpp b/examples/widgets/qnx/foreignwindows/collector.cpp new file mode 100644 index 0000000000..4b9e774945 --- /dev/null +++ b/examples/widgets/qnx/foreignwindows/collector.cpp @@ -0,0 +1,176 @@ +/*************************************************************************** +** +** Copyright (C) 2018 QNX Software Systems. All rights reserved. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +#include +#include + +#include "collector.h" + +constexpr int MANAGER_EVENT_NAME_SUGGESTION = 9999; + +Collector::Collector(QWidget *parent) + : QWidget(parent) +{ + QApplication::instance()->installNativeEventFilter(this); + + QLayout *layout = new QHBoxLayout(this); + setLayout(layout); +} + +Collector::~Collector() +{ + QApplication::instance()->removeNativeEventFilter(this); +} + +bool Collector::nativeEventFilter(const QByteArray &eventType, void *message, long *result) +{ + Q_UNUSED(result); + + if (eventType == QByteArrayLiteral("screen_event_t")) + return filterQnxScreenEvent(static_cast(message)); + + return false; +} + +bool Collector::filterQnxScreenEvent(screen_event_t event) +{ + int objectType = SCREEN_OBJECT_TYPE_CONTEXT; + screen_get_event_property_iv(event, SCREEN_PROPERTY_OBJECT_TYPE, &objectType); + + if (objectType == SCREEN_OBJECT_TYPE_WINDOW) + return filterQnxScreenWindowEvent(event); + + return false; +} + +bool Collector::filterQnxScreenWindowEvent(screen_event_t event) +{ + int eventType = SCREEN_EVENT_NONE; + screen_get_event_property_iv(event, SCREEN_PROPERTY_TYPE, &eventType); + screen_window_t window = nullptr; + screen_get_event_property_pv(event, + SCREEN_PROPERTY_WINDOW, + reinterpret_cast(&window)); + + if (eventType == SCREEN_EVENT_CREATE) + return filterQnxScreenWindowCreateEvent(window, event); + else if (eventType == SCREEN_EVENT_CLOSE) + return filterQnxScreenWindowCloseEvent(window, event); + else if (eventType == SCREEN_EVENT_MANAGER) + return filterQnxScreenWindowManagerEvent(window, event); + + return false; +} + +bool Collector::filterQnxScreenWindowCreateEvent(screen_window_t window, screen_event_t event) +{ + Q_UNUSED(event); + WId winId = reinterpret_cast(window); + + QByteArray parentGroup(256, 0); + screen_get_window_property_cv(window, + SCREEN_PROPERTY_PARENT, + parentGroup.length(), + parentGroup.data()); + parentGroup.resize(strlen(parentGroup.constData())); + + QByteArray group(256, 0); + screen_get_window_property_cv(reinterpret_cast(windowHandle()->winId()), + SCREEN_PROPERTY_GROUP, + group.length(), + group.data()); + group.resize(strlen(group.constData())); + + if (parentGroup != group) + return false; + + Collectible collectible; + collectible.window = QWindow::fromWinId(winId); + collectible.widget = QWidget::createWindowContainer(collectible.window, this); + layout()->addWidget(collectible.widget); + m_collectibles.append(collectible); + + return false; +} + +bool Collector::filterQnxScreenWindowCloseEvent(screen_window_t window, screen_event_t event) +{ + Q_UNUSED(event); + WId winId = reinterpret_cast(window); + auto it = std::find_if(m_collectibles.begin(), m_collectibles.end(), + [winId] (const Collectible &collectible) { + return collectible.window->winId() == winId; + }); + if (it != m_collectibles.end()) { + delete it->widget; + // it->window is deleted by it->widget. + m_collectibles.erase(it); + } + + return false; +} + +bool Collector::filterQnxScreenWindowManagerEvent(screen_window_t window, screen_event_t event) +{ + int managerEventType = 0; + screen_get_event_property_iv(event, SCREEN_PROPERTY_SUBTYPE, &managerEventType); + + if (managerEventType == MANAGER_EVENT_NAME_SUGGESTION) + return filterQnxScreenWindowManagerNameEvent(window, event); + + return false; +} + +bool Collector::filterQnxScreenWindowManagerNameEvent(screen_window_t window, screen_event_t event) +{ + Q_UNUSED(window); + int dataSize = 0; + screen_get_event_property_iv(event, SCREEN_PROPERTY_SIZE, &dataSize); + if (dataSize > 0) { + QByteArray data(dataSize, 0); + screen_get_event_property_cv(event, SCREEN_PROPERTY_USER_DATA, data.size(), data.data()); + } + + return false; +} diff --git a/examples/widgets/qnx/foreignwindows/collector.h b/examples/widgets/qnx/foreignwindows/collector.h new file mode 100644 index 0000000000..2b1ed499ff --- /dev/null +++ b/examples/widgets/qnx/foreignwindows/collector.h @@ -0,0 +1,75 @@ +/*************************************************************************** +** +** Copyright (C) 2018 QNX Software Systems. All rights reserved. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef COLLECTOR_H_ +#define COLLECTOR_H_ + +#include +#include +#include + +#include + +class Collector : public QWidget, public QAbstractNativeEventFilter +{ +public: + explicit Collector(QWidget *parent = nullptr); + ~Collector() override; + + bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override; + +private: + struct Collectible + { + QWindow *window; + QWidget *widget; + }; + QVector m_collectibles; + + bool filterQnxScreenEvent(screen_event_t event); + bool filterQnxScreenWindowEvent(screen_event_t event); + bool filterQnxScreenWindowCreateEvent(screen_window_t window, screen_event_t event); + bool filterQnxScreenWindowCloseEvent(screen_window_t window, screen_event_t event); + bool filterQnxScreenWindowManagerEvent(screen_window_t window, screen_event_t event); + bool filterQnxScreenWindowManagerNameEvent(screen_window_t window, + screen_event_t event); +}; + + +#endif /* COLLECTOR_H_ */ diff --git a/examples/widgets/qnx/foreignwindows/foreignwindows.pro b/examples/widgets/qnx/foreignwindows/foreignwindows.pro new file mode 100644 index 0000000000..09ff8633eb --- /dev/null +++ b/examples/widgets/qnx/foreignwindows/foreignwindows.pro @@ -0,0 +1,11 @@ +TEMPLATE = app + +HEADERS += collector.h +SOURCES += main.cpp collector.cpp +LIBS += -lscreen + +QT += widgets + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/widgets/qnx/foreignwindows +INSTALLS += target diff --git a/examples/widgets/qnx/foreignwindows/main.cpp b/examples/widgets/qnx/foreignwindows/main.cpp new file mode 100644 index 0000000000..128e93cf88 --- /dev/null +++ b/examples/widgets/qnx/foreignwindows/main.cpp @@ -0,0 +1,53 @@ +/*************************************************************************** +** +** Copyright (C) 2018 QNX Software Systems. All rights reserved. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "collector.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + Collector collector; + collector.resize(640, 480); + collector.show(); + + return app.exec(); +} diff --git a/src/plugins/platforms/qnx/qnx.pro b/src/plugins/platforms/qnx/qnx.pro index 96bfa1dd19..bfd56e8d13 100644 --- a/src/plugins/platforms/qnx/qnx.pro +++ b/src/plugins/platforms/qnx/qnx.pro @@ -33,6 +33,7 @@ QT += \ SOURCES = main.cpp \ qqnxbuffer.cpp \ + qqnxforeignwindow.cpp \ qqnxintegration.cpp \ qqnxscreen.cpp \ qqnxwindow.cpp \ @@ -50,6 +51,7 @@ SOURCES = main.cpp \ HEADERS = main.h \ qqnxbuffer.h \ + qqnxforeignwindow.h \ qqnxkeytranslator.h \ qqnxintegration.h \ qqnxscreen.h \ diff --git a/src/plugins/platforms/qnx/qqnxforeignwindow.cpp b/src/plugins/platforms/qnx/qqnxforeignwindow.cpp new file mode 100644 index 0000000000..94608215dc --- /dev/null +++ b/src/plugins/platforms/qnx/qqnxforeignwindow.cpp @@ -0,0 +1,65 @@ +/*************************************************************************** +** +** Copyright (C) 2018 QNX Software Systems. All rights reserved. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqnxforeignwindow.h" +#include "qqnxintegration.h" + +QT_BEGIN_NAMESPACE + +QQnxForeignWindow::QQnxForeignWindow(QWindow *window, + screen_context_t context, + screen_window_t screenWindow) + : QQnxWindow(window, context, screenWindow) +{ + initWindow(); +} + +bool QQnxForeignWindow::isForeignWindow() const +{ + return true; +} + +int QQnxForeignWindow::pixelFormat() const +{ + int result = SCREEN_FORMAT_RGBA8888; + screen_get_window_property_iv(nativeHandle(), SCREEN_PROPERTY_FORMAT, &result); + return result; +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxforeignwindow.h b/src/plugins/platforms/qnx/qqnxforeignwindow.h new file mode 100644 index 0000000000..22dde643e4 --- /dev/null +++ b/src/plugins/platforms/qnx/qqnxforeignwindow.h @@ -0,0 +1,61 @@ +/*************************************************************************** +** +** Copyright (C) 2018 QNX Software Systems. All rights reserved. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQNXFOREIGNWINDOW_H +#define QQNXFOREIGNWINDOW_H + +#include "qqnxwindow.h" + +QT_BEGIN_NAMESPACE + +class QQnxForeignWindow : public QQnxWindow +{ +public: + QQnxForeignWindow(QWindow *window, + screen_context_t context, + screen_window_t screenWindow); + + bool isForeignWindow() const override; + int pixelFormat() const override; + void resetBuffers() override {} +}; + +QT_END_NAMESPACE + +#endif // QQNXFOREIGNWINDOW_H diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp index a45dcabeb7..d9120256b3 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.cpp +++ b/src/plugins/platforms/qnx/qqnxintegration.cpp @@ -51,6 +51,7 @@ #include "qqnxabstractvirtualkeyboard.h" #include "qqnxservices.h" +#include "qqnxforeignwindow.h" #include "qqnxrasterwindow.h" #if !defined(QT_NO_OPENGL) #include "qqnxeglwindow.h" @@ -147,6 +148,7 @@ static inline int getContextCapabilities(const QStringList ¶mList) QQnxIntegration::QQnxIntegration(const QStringList ¶mList) : QPlatformIntegration() + , m_screenContextId(256, 0) , m_screenEventThread(0) , m_navigatorEventHandler(new QQnxNavigatorEventHandler()) , m_virtualKeyboard(0) @@ -178,6 +180,11 @@ QQnxIntegration::QQnxIntegration(const QStringList ¶mList) qFatal("%s - Screen: Failed to create screen context - Error: %s (%i)", Q_FUNC_INFO, strerror(errno), errno); } + screen_get_context_property_cv(m_screenContext, + SCREEN_PROPERTY_ID, + m_screenContextId.size(), + m_screenContextId.data()); + m_screenContextId.resize(strlen(m_screenContextId.constData())); #if QT_CONFIG(qqnx_pps) // Create/start navigator event notifier @@ -310,6 +317,7 @@ bool QQnxIntegration::hasCapability(QPlatformIntegration::Capability cap) const qIntegrationDebug(); switch (cap) { case MultipleWindows: + case ForeignWindows: case ThreadedPixmaps: return true; #if !defined(QT_NO_OPENGL) @@ -323,6 +331,18 @@ bool QQnxIntegration::hasCapability(QPlatformIntegration::Capability cap) const } } +QPlatformWindow *QQnxIntegration::createForeignWindow(QWindow *window, WId nativeHandle) const +{ + screen_window_t screenWindow = reinterpret_cast(nativeHandle); + if (this->window(screenWindow)) { + qWarning() << "QWindow already created for foreign window" + << screenWindow; + return nullptr; + } + + return new QQnxForeignWindow(window, m_screenContext, screenWindow); +} + QPlatformWindow *QQnxIntegration::createPlatformWindow(QWindow *window) const { qIntegrationDebug(); @@ -478,7 +498,7 @@ QPlatformServices * QQnxIntegration::services() const return m_services; } -QWindow *QQnxIntegration::window(screen_window_t qnxWindow) +QWindow *QQnxIntegration::window(screen_window_t qnxWindow) const { qIntegrationDebug(); QMutexLocker locker(&m_windowMapperMutex); @@ -706,6 +726,11 @@ screen_context_t QQnxIntegration::screenContext() return m_screenContext; } +QByteArray QQnxIntegration::screenContextId() +{ + return m_screenContextId; +} + QQnxNavigatorEventHandler *QQnxIntegration::navigatorEventHandler() { return m_navigatorEventHandler; diff --git a/src/plugins/platforms/qnx/qqnxintegration.h b/src/plugins/platforms/qnx/qqnxintegration.h index 366556dc4b..0bf37880d1 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.h +++ b/src/plugins/platforms/qnx/qqnxintegration.h @@ -92,6 +92,7 @@ public: bool hasCapability(QPlatformIntegration::Capability cap) const override; + QPlatformWindow *createForeignWindow(QWindow *window, WId nativeHandle) const override; QPlatformWindow *createPlatformWindow(QWindow *window) const override; QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const override; @@ -123,7 +124,7 @@ public: QPlatformServices *services() const override; - QWindow *window(screen_window_t qnxWindow); + QWindow *window(screen_window_t qnxWindow) const; QQnxScreen *screenForNative(screen_display_t qnxScreen) const; @@ -132,6 +133,7 @@ public: QQnxScreen *primaryDisplay() const; Options options() const; screen_context_t screenContext(); + QByteArray screenContextId(); QQnxNavigatorEventHandler *navigatorEventHandler(); @@ -145,6 +147,7 @@ private: int displayCount); screen_context_t m_screenContext; + QByteArray m_screenContextId; QQnxScreenEventThread *m_screenEventThread; QQnxNavigatorEventHandler *m_navigatorEventHandler; QQnxAbstractVirtualKeyboard *m_virtualKeyboard; @@ -168,7 +171,7 @@ private: QSimpleDrag *m_drag; #endif QQnxWindowMapper m_windowMapper; - QMutex m_windowMapperMutex; + mutable QMutex m_windowMapperMutex; Options m_options; diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp index c2471751f5..56131dcc48 100644 --- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp +++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp @@ -45,6 +45,7 @@ #include "qqnxkeytranslator.h" #include "qqnxscreen.h" #include "qqnxscreeneventfilter.h" +#include "qqnxscreentraits.h" #include #include @@ -89,6 +90,51 @@ static QString capKeyString(int cap, int modifiers, int key) return QString(); } +template +static void finishCloseEvent(screen_event_t event) +{ + T t; + screen_get_event_property_pv(event, + screen_traits::propertyName, + reinterpret_cast(&t)); + screen_traits::destroy(t); +} + +static void finishCloseEvent(screen_event_t event) +{ + // Let libscreen know that we're finished with anything that may have been acquired. + int objectType = SCREEN_OBJECT_TYPE_CONTEXT; + screen_get_event_property_iv(event, SCREEN_PROPERTY_OBJECT_TYPE, &objectType); + switch (objectType) { + case SCREEN_OBJECT_TYPE_CONTEXT: + finishCloseEvent(event); + break; + case SCREEN_OBJECT_TYPE_DEVICE: + finishCloseEvent(event); + break; + case SCREEN_OBJECT_TYPE_DISPLAY: + // no screen_destroy_display + break; + case SCREEN_OBJECT_TYPE_GROUP: + finishCloseEvent(event); + break; + case SCREEN_OBJECT_TYPE_PIXMAP: + finishCloseEvent(event); + break; + case SCREEN_OBJECT_TYPE_SESSION: + finishCloseEvent(event); + break; +#if _SCREEN_VERSION >= _SCREEN_MAKE_VERSION(2, 0, 0) + case SCREEN_OBJECT_TYPE_STREAM: + finishCloseEvent(event); + break; +#endif + case SCREEN_OBJECT_TYPE_WINDOW: + finishCloseEvent(event); + break; + } +} + QT_BEGIN_NAMESPACE QQnxScreenEventHandler::QQnxScreenEventHandler(QQnxIntegration *integration) @@ -251,6 +297,9 @@ void QQnxScreenEventHandler::processEvents() bool handled = dispatcher && dispatcher->filterNativeEvent(QByteArrayLiteral("screen_event_t"), event, &result); if (!handled) handleEvent(event); + + if (type == SCREEN_EVENT_CLOSE) + finishCloseEvent(event); } m_eventThread->armEventsPending(count); diff --git a/src/plugins/platforms/qnx/qqnxscreentraits.h b/src/plugins/platforms/qnx/qqnxscreentraits.h new file mode 100644 index 0000000000..ebd74141f2 --- /dev/null +++ b/src/plugins/platforms/qnx/qqnxscreentraits.h @@ -0,0 +1,127 @@ +/*************************************************************************** +** +** Copyright (C) 2018 QNX Software Systems. All rights reserved. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQNXSCREENTRAITS_H +#define QQNXSCREENTRAITS_H + +#include + +QT_BEGIN_NAMESPACE + +template +class screen_traits +{ +}; + +template <> +class screen_traits +{ +public: + typedef screen_context_t screen_type; + static const int propertyName = SCREEN_PROPERTY_CONTEXT; + static int destroy(screen_context_t context) { return screen_destroy_context(context); } +}; + +template <> +class screen_traits +{ +public: + typedef screen_device_t screen_type; + static const int propertyName = SCREEN_PROPERTY_DEVICE; + static int destroy(screen_device_t device) { return screen_destroy_device(device); } +}; + +template <> +class screen_traits +{ +public: + typedef screen_display_t screen_type; + static const int propertyName = SCREEN_PROPERTY_DISPLAY; +}; + +template <> +class screen_traits +{ +public: + typedef screen_group_t screen_type; + static const int propertyName = SCREEN_PROPERTY_GROUP; + static int destroy(screen_group_t group) { return screen_destroy_group(group); } +}; + +template <> +class screen_traits +{ +public: + typedef screen_pixmap_t screen_type; + static const int propertyName = SCREEN_PROPERTY_PIXMAP; + static int destroy(screen_pixmap_t pixmap) { return screen_destroy_pixmap(pixmap); } +}; + +template <> +class screen_traits +{ +public: + typedef screen_session_t screen_type; + static const int propertyName = SCREEN_PROPERTY_SESSION; + static int destroy(screen_session_t session) { return screen_destroy_session(session); } +}; + +#if _SCREEN_VERSION >= _SCREEN_MAKE_VERSION(2, 0, 0) +template <> +class screen_traits +{ +public: + typedef screen_stream_t screen_type; + static const int propertyName = SCREEN_PROPERTY_STREAM; + static int destroy(screen_stream_t stream) { return screen_destroy_stream(stream); } +}; +#endif + +template <> +class screen_traits +{ +public: + typedef screen_window_t screen_type; + static const int propertyName = SCREEN_PROPERTY_WINDOW; + static int destroy(screen_window_t window) { return screen_destroy_window(window); } +}; + +QT_END_NAMESPACE + +#endif // QQNXSCREENTRAITS_H diff --git a/src/plugins/platforms/qnx/qqnxwindow.cpp b/src/plugins/platforms/qnx/qqnxwindow.cpp index 7644e28b44..1d3d609017 100644 --- a/src/plugins/platforms/qnx/qqnxwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxwindow.cpp @@ -155,6 +155,7 @@ QQnxWindow::QQnxWindow(QWindow *window, screen_context_t context, bool needRootW m_parentWindow(0), m_visible(false), m_exposed(true), + m_foreign(false), m_windowState(Qt::WindowNoState), m_mmRendererWindow(0), m_firstActivateHandled(false) @@ -254,6 +255,39 @@ QQnxWindow::QQnxWindow(QWindow *window, screen_context_t context, bool needRootW } } +QQnxWindow::QQnxWindow(QWindow *window, screen_context_t context, screen_window_t screenWindow) + : QPlatformWindow(window) + , m_screenContext(context) + , m_window(screenWindow) + , m_screen(0) + , m_parentWindow(0) + , m_visible(false) + , m_exposed(true) + , m_foreign(true) + , m_windowState(Qt::WindowNoState) + , m_mmRendererWindow(0) + , m_parentGroupName(256, 0) + , m_isTopLevel(false) +{ + qWindowDebug() << "window =" << window << ", size =" << window->size(); + + collectWindowGroup(); + + screen_get_window_property_cv(m_window, + SCREEN_PROPERTY_PARENT, + m_parentGroupName.size(), + m_parentGroupName.data()); + m_parentGroupName.resize(strlen(m_parentGroupName.constData())); + + // If a window group has been provided join it now. If it's an empty string that's OK too, + // it'll cause us not to join a group (the app will presumably join at some future time). + QVariant parentGroup = window->property("qnxInitialWindowGroup"); + if (!parentGroup.isValid()) + parentGroup = window->property("_q_platform_qnxParentGroup"); + if (parentGroup.isValid() && parentGroup.canConvert()) + joinWindowGroup(parentGroup.toByteArray()); +} + QQnxWindow::~QQnxWindow() { qWindowDebug() << "window =" << window(); @@ -270,7 +304,11 @@ QQnxWindow::~QQnxWindow() m_screen->updateHierarchy(); // Cleanup QNX window and its buffers - screen_destroy_window(m_window); + // Foreign windows are cleaned up externally after the CLOSE event has been handled. + if (m_foreign) + removeContextPermission(); + else + screen_destroy_window(m_window); } void QQnxWindow::setGeometry(const QRect &rect) @@ -793,14 +831,24 @@ void QQnxWindow::initWindow() setGeometryHelper(shouldMakeFullScreen() ? screen()->geometry() : window()->geometry()); } +void QQnxWindow::collectWindowGroup() +{ + QByteArray groupName(256, 0); + Q_SCREEN_CHECKERROR(screen_get_window_property_cv(m_window, + SCREEN_PROPERTY_GROUP, + groupName.size(), + groupName.data()), + "Failed to retrieve window group"); + groupName.resize(strlen(groupName.constData())); + m_windowGroupName = groupName; +} + void QQnxWindow::createWindowGroup() { - // Generate a random window group name - m_windowGroupName = QUuid::createUuid().toByteArray(); - - // Create window group so child windows can be parented by container window - Q_SCREEN_CHECKERROR(screen_create_window_group(m_window, m_windowGroupName.constData()), + Q_SCREEN_CHECKERROR(screen_create_window_group(m_window, nullptr), "Failed to create window group"); + + collectWindowGroup(); } void QQnxWindow::joinWindowGroup(const QByteArray &groupName) @@ -809,6 +857,17 @@ void QQnxWindow::joinWindowGroup(const QByteArray &groupName) qWindowDebug() << "group:" << groupName; + // screen has this annoying habit of generating a CLOSE/CREATE when the owner context of + // the parent group moves a foreign window to another group that it also owns. The + // CLOSE/CREATE changes the identity of the foreign window. Usually, this is undesirable. + // To prevent this CLOSE/CREATE when changing the parent group, we temporarily add a + // context permission for the Qt context. screen won't send a CLOSE/CREATE when the + // context has some permission other than the PARENT permission. If there isn't a new + // group (the window has no parent), this context permission is left in place. + + if (m_foreign && !m_parentGroupName.isEmpty())\ + addContextPermission(); + if (!groupName.isEmpty()) { if (groupName != m_parentGroupName) { screen_join_window_group(m_window, groupName); @@ -827,6 +886,9 @@ void QQnxWindow::joinWindowGroup(const QByteArray &groupName) m_parentGroupName = ""; } + if (m_foreign && !groupName.isEmpty()) + removeContextPermission(); + if (changed) screen_flush_context(m_screenContext, 0); } @@ -899,4 +961,26 @@ bool QQnxWindow::focusable() const return (window()->flags() & Qt::WindowDoesNotAcceptFocus) != Qt::WindowDoesNotAcceptFocus; } +void QQnxWindow::addContextPermission() +{ + QByteArray grantString("context:"); + grantString.append(QQnxIntegration::instance()->screenContextId()); + grantString.append(":rw-"); + screen_set_window_property_cv(m_window, + SCREEN_PROPERTY_PERMISSIONS, + grantString.length(), + grantString.data()); +} + +void QQnxWindow::removeContextPermission() +{ + QByteArray revokeString("context:"); + revokeString.append(QQnxIntegration::instance()->screenContextId()); + revokeString.append(":---"); + screen_set_window_property_cv(m_window, + SCREEN_PROPERTY_PERMISSIONS, + revokeString.length(), + revokeString.data()); +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxwindow.h b/src/plugins/platforms/qnx/qqnxwindow.h index 20c38cb4b7..9040619c41 100644 --- a/src/plugins/platforms/qnx/qqnxwindow.h +++ b/src/plugins/platforms/qnx/qqnxwindow.h @@ -64,7 +64,8 @@ class QQnxWindow : public QPlatformWindow { friend class QQnxScreen; public: - QQnxWindow(QWindow *window, screen_context_t context, bool needRootWindow); + explicit QQnxWindow(QWindow *window, screen_context_t context, bool needRootWindow); + explicit QQnxWindow(QWindow *window, screen_context_t context, screen_window_t screenWindow); virtual ~QQnxWindow(); void setGeometry(const QRect &rect) override; @@ -124,6 +125,7 @@ protected: screen_context_t m_screenContext; private: + void collectWindowGroup(); void createWindowGroup(); void setGeometryHelper(const QRect &rect); void removeFromParent(); @@ -135,6 +137,9 @@ private: bool showWithoutActivating() const; bool focusable() const; + void addContextPermission(); + void removeContextPermission(); + screen_window_t m_window; QSize m_bufferSize; @@ -144,6 +149,7 @@ private: QScopedPointer m_cover; bool m_visible; bool m_exposed; + bool m_foreign; QRect m_unmaximizedGeometry; Qt::WindowStates m_windowState; QString m_mmRendererWindowName; From 23c2da3cc23a2e04a0b3b3c8ad7fa9cc6126ff23 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 19 Dec 2017 15:25:55 +0100 Subject: [PATCH 221/292] Add QTextMarkdownWriter, QTextEdit::markdown property etc. A QTextDocument can now be written out in Markdown format. - Add the QTextMarkdownWriter as a private class for now - Add QTextDocument::toMarkdown() - QTextDocumentWriter uses QTextMarkdownWriter if setFormat("markdown") is called or if the file suffix is .md or .mkd - Add QTextEdit::toMarkdown() and the markdown property [ChangeLog][QtGui][Text] Markdown (CommonMark or GitHub dialect) is now a supported format for reading into and writing from QTextDocument. Change-Id: I663a77017fac7ae1b3f9a400f5cd357bb40750af Reviewed-by: Gatis Paeglis --- src/gui/configure.json | 8 +- src/gui/text/qtextdocument.cpp | 34 +- src/gui/text/qtextdocument.h | 8 +- src/gui/text/qtextdocumentwriter.cpp | 19 + src/gui/text/qtextmarkdownwriter.cpp | 363 ++++++++++++++++++ src/gui/text/qtextmarkdownwriter_p.h | 78 ++++ src/gui/text/text.pri | 7 + src/widgets/widgets/qtextedit.cpp | 62 ++- src/widgets/widgets/qtextedit.h | 8 +- src/widgets/widgets/qwidgettextcontrol.cpp | 7 + src/widgets/widgets/qwidgettextcontrol_p.h | 3 + .../gui/text/qtextmarkdownwriter/BLACKLIST | 3 + .../text/qtextmarkdownwriter/data/example.md | 95 +++++ .../qtextmarkdownwriter.pro | 7 + .../tst_qtextmarkdownwriter.cpp | 360 +++++++++++++++++ tests/auto/gui/text/text.pro | 3 + tests/manual/markdown/html2md.cpp | 64 +++ tests/manual/markdown/html2md.pro | 6 + 18 files changed, 1124 insertions(+), 11 deletions(-) create mode 100644 src/gui/text/qtextmarkdownwriter.cpp create mode 100644 src/gui/text/qtextmarkdownwriter_p.h create mode 100644 tests/auto/gui/text/qtextmarkdownwriter/BLACKLIST create mode 100644 tests/auto/gui/text/qtextmarkdownwriter/data/example.md create mode 100644 tests/auto/gui/text/qtextmarkdownwriter/qtextmarkdownwriter.pro create mode 100644 tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp create mode 100644 tests/manual/markdown/html2md.cpp create mode 100644 tests/manual/markdown/html2md.pro diff --git a/src/gui/configure.json b/src/gui/configure.json index d7c0da4640..9e76fc455e 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -1611,6 +1611,12 @@ "condition": "libs.libmd4c", "output": [ "publicFeature" ] }, + "textmarkdownwriter": { + "label": "MarkdownWriter", + "purpose": "Provides a Markdown (CommonMark) writer", + "section": "Kernel", + "output": [ "publicFeature" ] + }, "textodfwriter": { "label": "OdfWriter", "purpose": "Provides an ODF writer.", @@ -1892,7 +1898,7 @@ QMAKE_LIBDIR_OPENGL[_ES2] and QMAKE_LIBS_OPENGL[_ES2] in the mkspec for your pla { "section": "Text formats", "entries": [ - "texthtmlparser", "cssparser", "textodfwriter", "textmarkdownreader", "system-textmarkdownreader" + "texthtmlparser", "cssparser", "textodfwriter", "textmarkdownreader", "system-textmarkdownreader", "textmarkdownwriter" ] }, "egl", diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 87c8f1ba8a..0a59bfb838 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -73,6 +73,9 @@ #if QT_CONFIG(textmarkdownreader) #include #endif +#if QT_CONFIG(textmarkdownwriter) +#include +#endif #include @@ -3288,6 +3291,22 @@ QString QTextDocument::toHtml(const QByteArray &encoding) const } #endif // QT_NO_TEXTHTMLPARSER +/*! + Returns a string containing a Markdown representation of the document, + or an empty string if writing fails for any reason. +*/ +#if QT_CONFIG(textmarkdownwriter) +QString QTextDocument::toMarkdown(QTextDocument::MarkdownFeatures features) const +{ + QString ret; + QTextStream s(&ret); + QTextMarkdownWriter w(s, features); + if (w.writeAll(*this)) + return ret; + return QString(); +} +#endif + /*! Replaces the entire contents of the document with the given Markdown-formatted text in the \a markdown string, with the given @@ -3301,8 +3320,19 @@ QString QTextDocument::toHtml(const QByteArray &encoding) const Parsing of HTML included in the \a markdown string is handled in the same way as in \l setHtml; however, Markdown formatting inside HTML blocks is - not supported. The \c MarkdownNoHTML feature flag can be set to disable - HTML parsing. + not supported. + + Some features of the parser can be enabled or disabled via the \a features + argument: + + \value MarkdownNoHTML + Any HTML tags in the Markdown text will be discarded + \value MarkdownDialectCommonMark + The parser supports only the features standardized by CommonMark + \value MarkdownDialectGitHub + The parser supports the GitHub dialect + + The default is \c MarkdownDialectGitHub. The undo/redo history is reset when this function is called. */ diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h index ade67999ad..31c06976a5 100644 --- a/src/gui/text/qtextdocument.h +++ b/src/gui/text/qtextdocument.h @@ -151,7 +151,7 @@ public: void setHtml(const QString &html); #endif -#if QT_CONFIG(textmarkdownreader) +#if QT_CONFIG(textmarkdownwriter) || QT_CONFIG(textmarkdownreader) // Must be in sync with QTextMarkdownImporter::Features, should be in sync with #define MD_FLAG_* in md4c enum MarkdownFeature { MarkdownNoHTML = 0x0020 | 0x0040, @@ -160,7 +160,13 @@ public: }; Q_DECLARE_FLAGS(MarkdownFeatures, MarkdownFeature) Q_FLAG(MarkdownFeatures) +#endif +#if QT_CONFIG(textmarkdownwriter) + QString toMarkdown(MarkdownFeatures features = MarkdownDialectGitHub) const; +#endif + +#if QT_CONFIG(textmarkdownreader) void setMarkdown(const QString &markdown, MarkdownFeatures features = MarkdownDialectGitHub); #endif diff --git a/src/gui/text/qtextdocumentwriter.cpp b/src/gui/text/qtextdocumentwriter.cpp index 42e623153a..c82ff873cd 100644 --- a/src/gui/text/qtextdocumentwriter.cpp +++ b/src/gui/text/qtextdocumentwriter.cpp @@ -51,6 +51,9 @@ #include "qtextdocumentfragment_p.h" #include "qtextodfwriter_p.h" +#if QT_CONFIG(textmarkdownwriter) +#include "qtextmarkdownwriter_p.h" +#endif #include @@ -267,6 +270,18 @@ bool QTextDocumentWriter::write(const QTextDocument *document) } #endif // QT_NO_TEXTODFWRITER +#if QT_CONFIG(textmarkdownwriter) + if (format == "md" || format == "mkd" || format == "markdown") { + if (!d->device->isWritable() && !d->device->open(QIODevice::WriteOnly)) { + qWarning("QTextDocumentWriter::write: the device can not be opened for writing"); + return false; + } + QTextStream s(d->device); + QTextMarkdownWriter writer(s, QTextDocument::MarkdownDialectGitHub); + return writer.writeAll(*document); + } +#endif // textmarkdownwriter + #ifndef QT_NO_TEXTHTMLPARSER if (format == "html" || format == "htm") { if (!d->device->isWritable() && ! d->device->open(QIODevice::WriteOnly)) { @@ -348,6 +363,7 @@ QTextCodec *QTextDocumentWriter::codec() const \header \li Format \li Description \row \li plaintext \li Plain text \row \li HTML \li HyperText Markup Language + \row \li markdown \li Markdown (CommonMark or GitHub dialects) \row \li ODF \li OpenDocument Format \endtable @@ -364,6 +380,9 @@ QList QTextDocumentWriter::supportedDocumentFormats() #ifndef QT_NO_TEXTODFWRITER answer << "ODF"; #endif // QT_NO_TEXTODFWRITER +#if QT_CONFIG(textmarkdownwriter) + answer << "markdown"; +#endif std::sort(answer.begin(), answer.end()); return answer; diff --git a/src/gui/text/qtextmarkdownwriter.cpp b/src/gui/text/qtextmarkdownwriter.cpp new file mode 100644 index 0000000000..c91248757a --- /dev/null +++ b/src/gui/text/qtextmarkdownwriter.cpp @@ -0,0 +1,363 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qtextmarkdownwriter_p.h" +#include "qtextdocumentlayout_p.h" +#include "qfontinfo.h" +#include "qfontmetrics.h" +#include "qtextdocument_p.h" +#include "qtextlist.h" +#include "qtexttable.h" +#include "qtextcursor.h" +#include "qtextimagehandler_p.h" + +QT_BEGIN_NAMESPACE + +static const QChar Space = QLatin1Char(' '); +static const QChar Newline = QLatin1Char('\n'); +static const QChar Backtick = QLatin1Char('`'); + +QTextMarkdownWriter::QTextMarkdownWriter(QTextStream &stream, QTextDocument::MarkdownFeatures features) + : m_stream(stream), m_features(features) +{ +} + +bool QTextMarkdownWriter::writeAll(const QTextDocument &document) +{ + writeFrame(document.rootFrame()); + return true; +} + +void QTextMarkdownWriter::writeFrame(const QTextFrame *frame) +{ + Q_ASSERT(frame); + const QTextTable *table = qobject_cast (frame); + QTextFrame::iterator iterator = frame->begin(); + QTextFrame *child = 0; + int tableRow = -1; + bool lastWasList = false; + QVector tableColumnWidths; + if (table) { + tableColumnWidths.resize(table->columns()); + for (int col = 0; col < table->columns(); ++col) { + for (int row = 0; row < table->rows(); ++ row) { + QTextTableCell cell = table->cellAt(row, col); + int cellTextLen = 0; + auto it = cell.begin(); + while (it != cell.end()) { + QTextBlock block = it.currentBlock(); + if (block.isValid()) + cellTextLen += block.text().length(); + ++it; + } + if (cell.columnSpan() == 1 && tableColumnWidths[col] < cellTextLen) + tableColumnWidths[col] = cellTextLen; + } + } + } + while (!iterator.atEnd()) { + if (iterator.currentFrame() && child != iterator.currentFrame()) + writeFrame(iterator.currentFrame()); + else { // no frame, it's a block + QTextBlock block = iterator.currentBlock(); + if (table) { + QTextTableCell cell = table->cellAt(block.position()); + if (tableRow < cell.row()) { + if (tableRow == 0) { + m_stream << Newline; + for (int col = 0; col < tableColumnWidths.length(); ++col) + m_stream << '|' << QString(tableColumnWidths[col], QLatin1Char('-')); + m_stream << '|'; + } + m_stream << Newline << "|"; + tableRow = cell.row(); + } + } else if (!block.textList()) { + if (lastWasList) + m_stream << Newline; + } + int endingCol = writeBlock(block, !table, table && tableRow == 0); + if (table) { + QTextTableCell cell = table->cellAt(block.position()); + int paddingLen = -endingCol; + int spanEndCol = cell.column() + cell.columnSpan(); + for (int col = cell.column(); col < spanEndCol; ++col) + paddingLen += tableColumnWidths[col]; + if (paddingLen > 0) + m_stream << QString(paddingLen, Space); + for (int col = cell.column(); col < spanEndCol; ++col) + m_stream << "|"; + } else if (block.textList()) { + m_stream << Newline; + } else if (endingCol > 0) { + m_stream << Newline << Newline; + } + lastWasList = block.textList(); + } + child = iterator.currentFrame(); + ++iterator; + } + if (table) + m_stream << Newline << Newline; +} + +static int nearestWordWrapIndex(const QString &s, int before) +{ + before = qMin(before, s.length()); + for (int i = before - 1; i >= 0; --i) { + if (s.at(i).isSpace()) + return i; + } + return -1; +} + +static int adjacentBackticksCount(const QString &s) +{ + int start = -1, len = s.length(); + int ret = 0; + for (int i = 0; i < len; ++i) { + if (s.at(i) == Backtick) { + if (start < 0) + start = i; + } else if (start >= 0) { + ret = qMax(ret, i - start); + start = -1; + } + } + if (s.at(len - 1) == Backtick) + ret = qMax(ret, len - start); + return ret; +} + +static void maybeEscapeFirstChar(QString &s) +{ + QString sTrimmed = s.trimmed(); + if (sTrimmed.isEmpty()) + return; + char firstChar = sTrimmed.at(0).toLatin1(); + if (firstChar == '*' || firstChar == '+' || firstChar == '-') { + int i = s.indexOf(QLatin1Char(firstChar)); + s.insert(i, QLatin1Char('\\')); + } +} + +int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ignoreFormat) +{ + int ColumnLimit = 80; + int wrapIndent = 0; + if (block.textList()) { // it's a list-item + auto fmt = block.textList()->format(); + const int listLevel = fmt.indent(); + const int number = block.textList()->itemNumber(block) + 1; + QByteArray bullet = " "; + bool numeric = false; + switch (fmt.style()) { + case QTextListFormat::ListDisc: bullet = "-"; break; + case QTextListFormat::ListCircle: bullet = "*"; break; + case QTextListFormat::ListSquare: bullet = "+"; break; + case QTextListFormat::ListStyleUndefined: break; + case QTextListFormat::ListDecimal: + case QTextListFormat::ListLowerAlpha: + case QTextListFormat::ListUpperAlpha: + case QTextListFormat::ListLowerRoman: + case QTextListFormat::ListUpperRoman: + numeric = true; + break; + } + switch (block.blockFormat().marker()) { + case QTextBlockFormat::Checked: + bullet += " [x]"; + break; + case QTextBlockFormat::Unchecked: + bullet += " [ ]"; + break; + default: + break; + } + QString prefix((listLevel - 1) * (numeric ? 4 : 2), Space); + if (numeric) + prefix += QString::number(number) + fmt.numberSuffix() + Space; + else + prefix += QLatin1String(bullet) + Space; + m_stream << prefix; + wrapIndent = prefix.length(); + } + + if (block.blockFormat().headingLevel()) + m_stream << QByteArray(block.blockFormat().headingLevel(), '#') << ' '; + + QString wrapIndentString(wrapIndent, Space); + // It would be convenient if QTextStream had a lineCharPos() accessor, + // to keep track of how many characters (not bytes) have been written on the current line, + // but it doesn't. So we have to keep track with this col variable. + int col = wrapIndent; + bool mono = false; + bool startsOrEndsWithBacktick = false; + bool bold = false; + bool italic = false; + bool underline = false; + bool strikeOut = false; + QString backticks(Backtick); + for (QTextBlock::Iterator frag = block.begin(); !frag.atEnd(); ++frag) { + QString fragmentText = frag.fragment().text(); + while (fragmentText.endsWith(QLatin1Char('\n'))) + fragmentText.chop(1); + startsOrEndsWithBacktick |= fragmentText.startsWith(Backtick) || fragmentText.endsWith(Backtick); + QTextCharFormat fmt = frag.fragment().charFormat(); + if (fmt.isImageFormat()) { + QTextImageFormat ifmt = fmt.toImageFormat(); + QString s = QLatin1String("![image](") + ifmt.name() + QLatin1Char(')'); + if (wrap && col + s.length() > ColumnLimit) { + m_stream << Newline << wrapIndentString; + col = wrapIndent; + } + m_stream << s; + col += s.length(); + } else if (fmt.hasProperty(QTextFormat::AnchorHref)) { + QString s = QLatin1Char('[') + fragmentText + QLatin1String("](") + + fmt.property(QTextFormat::AnchorHref).toString() + QLatin1Char(')'); + if (wrap && col + s.length() > ColumnLimit) { + m_stream << Newline << wrapIndentString; + col = wrapIndent; + } + m_stream << s; + col += s.length(); + } else { + QFontInfo fontInfo(fmt.font()); + bool monoFrag = fontInfo.fixedPitch(); + QString markers; + if (!ignoreFormat) { + if (monoFrag != mono) { + if (monoFrag) + backticks = QString::fromLatin1(QByteArray(adjacentBackticksCount(fragmentText) + 1, '`')); + markers += backticks; + if (startsOrEndsWithBacktick) + markers += Space; + mono = monoFrag; + } + if (!block.blockFormat().headingLevel() && !mono) { + if (fmt.font().bold() != bold) { + markers += QLatin1String("**"); + bold = fmt.font().bold(); + } + if (fmt.font().italic() != italic) { + markers += QLatin1Char('*'); + italic = fmt.font().italic(); + } + if (fmt.font().strikeOut() != strikeOut) { + markers += QLatin1String("~~"); + strikeOut = fmt.font().strikeOut(); + } + if (fmt.font().underline() != underline) { + // Markdown doesn't support underline, but the parser will treat a single underline + // the same as a single asterisk, and the marked fragment will be rendered in italics. + // That will have to do. + markers += QLatin1Char('_'); + underline = fmt.font().underline(); + } + } + } + if (wrap && col + markers.length() * 2 + fragmentText.length() > ColumnLimit) { + int i = 0; + int fragLen = fragmentText.length(); + bool breakingLine = false; + while (i < fragLen) { + int j = i + ColumnLimit - col; + if (j < fragLen) { + int wi = nearestWordWrapIndex(fragmentText, j); + if (wi < 0) { + j = fragLen; + } else { + j = wi; + breakingLine = true; + } + } else { + j = fragLen; + breakingLine = false; + } + QString subfrag = fragmentText.mid(i, j - i); + if (!i) { + m_stream << markers; + col += markers.length(); + } + if (col == wrapIndent) + maybeEscapeFirstChar(subfrag); + m_stream << subfrag; + if (breakingLine) { + m_stream << Newline << wrapIndentString; + col = wrapIndent; + } else { + col += subfrag.length(); + } + i = j + 1; + } + } else { + m_stream << markers << fragmentText; + col += markers.length() + fragmentText.length(); + } + } + } + if (mono) { + if (startsOrEndsWithBacktick) { + m_stream << Space; + col += 1; + } + m_stream << backticks; + col += backticks.size(); + } + if (bold) { + m_stream << "**"; + col += 2; + } + if (italic) { + m_stream << "*"; + col += 1; + } + if (underline) { + m_stream << "_"; + col += 1; + } + if (strikeOut) { + m_stream << "~~"; + col += 2; + } + return col; +} + +QT_END_NAMESPACE diff --git a/src/gui/text/qtextmarkdownwriter_p.h b/src/gui/text/qtextmarkdownwriter_p.h new file mode 100644 index 0000000000..9845355259 --- /dev/null +++ b/src/gui/text/qtextmarkdownwriter_p.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTEXTMARKDOWNWRITER_P_H +#define QTEXTMARKDOWNWRITER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +#include "qtextdocument_p.h" +#include "qtextdocumentwriter.h" + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QTextMarkdownWriter +{ +public: + QTextMarkdownWriter(QTextStream &stream, QTextDocument::MarkdownFeatures features); + bool writeAll(const QTextDocument &document); + + int writeBlock(const QTextBlock &block, bool table, bool ignoreFormat); + void writeFrame(const QTextFrame *frame); + +private: + QTextStream &m_stream; + QTextDocument::MarkdownFeatures m_features; +}; + +QT_END_NAMESPACE + +#endif // QTEXTMARKDOWNWRITER_P_H diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri index b35a231747..5e97b312f1 100644 --- a/src/gui/text/text.pri +++ b/src/gui/text/text.pri @@ -109,6 +109,13 @@ qtConfig(textmarkdownreader) { text/qtextmarkdownimporter.cpp } +qtConfig(textmarkdownwriter) { + HEADERS += \ + text/qtextmarkdownwriter_p.h + SOURCES += \ + text/qtextmarkdownwriter.cpp +} + qtConfig(cssparser) { HEADERS += \ text/qcssparser_p.h diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index 9e134493b5..5f734258b2 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -366,8 +366,8 @@ void QTextEditPrivate::_q_ensureVisible(const QRectF &_rect) \section1 Introduction and Concepts QTextEdit is an advanced WYSIWYG viewer/editor supporting rich - text formatting using HTML-style tags. It is optimized to handle - large documents and to respond quickly to user input. + text formatting using HTML-style tags, or Markdown format. It is optimized + to handle large documents and to respond quickly to user input. QTextEdit works on paragraphs and characters. A paragraph is a formatted string which is word-wrapped to fit into the width of @@ -381,7 +381,7 @@ void QTextEditPrivate::_q_ensureVisible(const QRectF &_rect) QTextEdit can display images, lists and tables. If the text is too large to view within the text edit's viewport, scroll bars will appear. The text edit can load both plain text and rich text files. - Rich text is described using a subset of HTML 4 markup, refer to the + Rich text can be described using a subset of HTML 4 markup; refer to the \l {Supported HTML Subset} page for more information. If you just need to display a small piece of rich text use QLabel. @@ -401,12 +401,19 @@ void QTextEditPrivate::_q_ensureVisible(const QRectF &_rect) QTextEdit can display a large HTML subset, including tables and images. - The text is set or replaced using setHtml() which deletes any + The text can be set or replaced using \l setHtml() which deletes any existing text and replaces it with the text passed in the setHtml() call. If you call setHtml() with legacy HTML, and then call toHtml(), the text that is returned may have different markup, but will render the same. The entire text can be deleted with clear(). + Text can also be set or replaced using \l setMarkdown(), and the same + caveats apply: if you then call \l toMarkdown(), the text that is returned + may be different, but the meaning is preserved as much as possible. + Markdown with some embedded HTML can be parsed, with the same limitations + that \l setHtml() has; but \l toMarkdown() only writes "pure" Markdown, + without any embedded HTML. + Text itself can be inserted using the QTextCursor class or using the convenience functions insertHtml(), insertPlainText(), append() or paste(). QTextCursor is also able to insert complex objects like tables @@ -1213,11 +1220,54 @@ QString QTextEdit::toHtml() const } #endif +#if QT_CONFIG(textmarkdownreader) && QT_CONFIG(textmarkdownwriter) +/*! + \property QTextEdit::markdown + + This property provides a Markdown interface to the text of the text edit. + + \c toMarkdown() returns the text of the text edit as "pure" Markdown, + without any embedded HTML formatting. Some features that QTextDocument + supports (such as the use of specific colors and named fonts) cannot be + expressed in "pure" Markdown, and they will be omitted. + + \c setMarkdown() changes the text of the text edit. Any previous text is + removed and the undo/redo history is cleared. The input text is + interpreted as rich text in Markdown format. + + Parsing of HTML included in the \a markdown string is handled in the same + way as in \l setHtml; however, Markdown formatting inside HTML blocks is + not supported. + + Some features of the parser can be enabled or disabled via the \a features + argument: + + \value MarkdownNoHTML + Any HTML tags in the Markdown text will be discarded + \value MarkdownDialectCommonMark + The parser supports only the features standardized by CommonMark + \value MarkdownDialectGitHub + The parser supports the GitHub dialect + + The default is \c MarkdownDialectGitHub. + + \sa plainText, html, QTextDocument::toMarkdown(), QTextDocument::setMarkdown() +*/ +#endif + #if QT_CONFIG(textmarkdownreader) -void QTextEdit::setMarkdown(const QString &text) +void QTextEdit::setMarkdown(const QString &markdown) { Q_D(const QTextEdit); - d->control->setMarkdown(text); + d->control->setMarkdown(markdown); +} +#endif + +#if QT_CONFIG(textmarkdownwriter) +QString QTextEdit::toMarkdown(QTextDocument::MarkdownFeatures features) const +{ + Q_D(const QTextEdit); + return d->control->toMarkdown(features); } #endif diff --git a/src/widgets/widgets/qtextedit.h b/src/widgets/widgets/qtextedit.h index f20bd936c4..3b7e610786 100644 --- a/src/widgets/widgets/qtextedit.h +++ b/src/widgets/widgets/qtextedit.h @@ -71,6 +71,9 @@ class Q_WIDGETS_EXPORT QTextEdit : public QAbstractScrollArea QDOC_PROPERTY(QTextOption::WrapMode wordWrapMode READ wordWrapMode WRITE setWordWrapMode) Q_PROPERTY(int lineWrapColumnOrWidth READ lineWrapColumnOrWidth WRITE setLineWrapColumnOrWidth) Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly) +#if QT_CONFIG(textmarkdownreader) && QT_CONFIG(textmarkdownwriter) + Q_PROPERTY(QString markdown READ toMarkdown WRITE setMarkdown NOTIFY textChanged) +#endif #ifndef QT_NO_TEXTHTMLPARSER Q_PROPERTY(QString html READ toHtml WRITE setHtml NOTIFY textChanged USER true) #endif @@ -174,6 +177,9 @@ public: #ifndef QT_NO_TEXTHTMLPARSER QString toHtml() const; #endif +#if QT_CONFIG(textmarkdownwriter) + QString toMarkdown(QTextDocument::MarkdownFeatures features = QTextDocument::MarkdownDialectGitHub) const; +#endif void ensureCursorVisible(); @@ -239,7 +245,7 @@ public Q_SLOTS: void setHtml(const QString &text); #endif #if QT_CONFIG(textmarkdownreader) - void setMarkdown(const QString &text); + void setMarkdown(const QString &markdown); #endif void setText(const QString &text); diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index 5744d43cbf..209156b901 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -3130,6 +3130,13 @@ QString QWidgetTextControl::toHtml() const } #endif +#ifndef QT_NO_TEXTHTMLPARSER +QString QWidgetTextControl::toMarkdown(QTextDocument::MarkdownFeatures features) const +{ + return document()->toMarkdown(features); +} +#endif + void QWidgetTextControlPrivate::append(const QString &text, Qt::TextFormat format) { QTextCursor tmp(doc); diff --git a/src/widgets/widgets/qwidgettextcontrol_p.h b/src/widgets/widgets/qwidgettextcontrol_p.h index 4c9e47dfc9..e521e7b356 100644 --- a/src/widgets/widgets/qwidgettextcontrol_p.h +++ b/src/widgets/widgets/qwidgettextcontrol_p.h @@ -128,6 +128,9 @@ public: #ifndef QT_NO_TEXTHTMLPARSER QString toHtml() const; #endif +#if QT_CONFIG(textmarkdownwriter) + QString toMarkdown(QTextDocument::MarkdownFeatures features = QTextDocument::MarkdownDialectGitHub) const; +#endif virtual void ensureCursorVisible(); diff --git a/tests/auto/gui/text/qtextmarkdownwriter/BLACKLIST b/tests/auto/gui/text/qtextmarkdownwriter/BLACKLIST new file mode 100644 index 0000000000..fc9e5a9efe --- /dev/null +++ b/tests/auto/gui/text/qtextmarkdownwriter/BLACKLIST @@ -0,0 +1,3 @@ +[rewriteDocument] +winrt # QTBUG-54623 + diff --git a/tests/auto/gui/text/qtextmarkdownwriter/data/example.md b/tests/auto/gui/text/qtextmarkdownwriter/data/example.md new file mode 100644 index 0000000000..3c63f209a2 --- /dev/null +++ b/tests/auto/gui/text/qtextmarkdownwriter/data/example.md @@ -0,0 +1,95 @@ +# QTextEdit + +The QTextEdit widget is an advanced editor that supports formatted rich text. +It can be used to display HTML and other rich document formats. Internally, +QTextEdit uses the QTextDocument class to describe both the high-level +structure of each document and the low-level formatting of paragraphs. + +If you are viewing this document in the textedit example, you can edit this +document to explore Qt's rich text editing features. We have included some +comments in each of the following sections to encourage you to experiment. + +## Font and Paragraph Styles + +QTextEdit supports **bold**, *italic*, and ~~strikethrough~~ font styles, and can +display multicolored text. Font families such as Times New Roman and `Courier` +can also be used directly. *If you place the cursor in a region of styled text, +the controls in the tool bars will change to reflect the current style.* + +Paragraphs can be formatted so that the text is left-aligned, right-aligned, +centered, or fully justified. + +*Try changing the alignment of some text and resize the editor to see how the +text layout changes.* + +## Lists + +Different kinds of lists can be included in rich text documents. Standard +bullet lists can be nested, using different symbols for each level of the list: + +* Disc symbols are typically used for top-level list items. + - Circle symbols can be used to distinguish between items in lower-level + lists. + + Square symbols provide a reasonable alternative to discs and circles. + +Ordered lists can be created that can be used for tables of contents. Different +characters can be used to enumerate items, and we can use both Roman and Arabic +numerals in the same list structure: + +1. Introduction +2. Qt Tools + 1) Qt Assistant + 2) Qt Designer + 1. Form Editor + 2. Component Architecture + 3) Qt Linguist + +The list will automatically be renumbered if you add or remove items. *Try +adding new sections to the above list or removing existing item to see the +numbers change.* + +## Images + +Inline images are treated like ordinary ranges of characters in the text +editor, so they flow with the surrounding text. Images can also be selected in +the same way as text, making it easy to cut, copy, and paste them. + +![image](images/logo32.png) *Try to select this image by clicking and dragging +over it with the mouse, or use the text cursor to select it by holding down +Shift and using the arrow keys. You can then cut or copy it, and paste it into +different parts of this document.* + +## Tables + +QTextEdit can arrange and format tables, supporting features such as row and +column spans, text formatting within cells, and size constraints for columns. + + +| |Development Tools |Programming Techniques |Graphical User Interfaces| +|-------------|------------------------------------|---------------------------|-------------------------| +|9:00 - 11:00 |Introduction to Qt ||| +|11:00 - 13:00|Using qmake |Object-oriented Programming|Layouts in Qt | +|13:00 - 15:00|Qt Designer Tutorial |Extreme Programming |Writing Custom Styles | +|15:00 - 17:00|Qt Linguist and Internationalization|  |  | + +*Try adding text to the cells in the table and experiment with the alignment of +the paragraphs.* + +## Hyperlinks + +QTextEdit is designed to support hyperlinks between documents, and this feature +is used extensively in +[Qt Assistant](http://doc.qt.io/qt-5/qtassistant-index.html). Hyperlinks are +automatically created when an HTML file is imported into an editor. Since the +rich text framework supports hyperlinks natively, they can also be created +programatically. + +## Undo and Redo + +Full support for undo and redo operations is built into QTextEdit and the +underlying rich text framework. Operations on a document can be packaged +together to make editing a more comfortable experience for the user. + +*Try making changes to this document and press `Ctrl+Z` to undo them. You can +always recover the original contents of the document.* + diff --git a/tests/auto/gui/text/qtextmarkdownwriter/qtextmarkdownwriter.pro b/tests/auto/gui/text/qtextmarkdownwriter/qtextmarkdownwriter.pro new file mode 100644 index 0000000000..04cf7ef5dd --- /dev/null +++ b/tests/auto/gui/text/qtextmarkdownwriter/qtextmarkdownwriter.pro @@ -0,0 +1,7 @@ +CONFIG += testcase +TARGET = tst_qtextmarkdownwriter +QT += core-private gui-private testlib +SOURCES += tst_qtextmarkdownwriter.cpp +TESTDATA += data/example.md + +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp new file mode 100644 index 0000000000..bf7c9708de --- /dev/null +++ b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp @@ -0,0 +1,360 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** 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 +#include +#include +#include +#include +#include +#include +#include + +#include + +// #define DEBUG_WRITE_OUTPUT + +class tst_QTextMarkdownWriter : public QObject +{ + Q_OBJECT +public slots: + void init(); + void cleanup(); + +private slots: + void testWriteParagraph_data(); + void testWriteParagraph(); + void testWriteList(); + void testWriteNestedBulletLists(); + void testWriteNestedNumericLists(); + void testWriteTable(); + void rewriteDocument(); + void fromHtml_data(); + void fromHtml(); + +private: + QString documentToUnixMarkdown(); + +private: + QTextDocument *document; +}; + +void tst_QTextMarkdownWriter::init() +{ + document = new QTextDocument(); +} + +void tst_QTextMarkdownWriter::cleanup() +{ + delete document; +} + +void tst_QTextMarkdownWriter::testWriteParagraph_data() +{ + QTest::addColumn("input"); + QTest::addColumn("output"); + + QTest::newRow("empty") << "" << + ""; + QTest::newRow("spaces") << "foobar word" << + "foobar word\n\n"; + QTest::newRow("starting spaces") << " starting spaces" << + " starting spaces\n\n"; + QTest::newRow("trailing spaces") << "trailing spaces " << + "trailing spaces \n\n"; + QTest::newRow("tab") << "word\ttab x" << + "word\ttab x\n\n"; + QTest::newRow("tab2") << "word\t\ttab\tx" << + "word\t\ttab\tx\n\n"; + QTest::newRow("misc") << "foobar word\ttab x" << + "foobar word\ttab x\n\n"; + QTest::newRow("misc2") << "\t \tFoo" << + "\t \tFoo\n\n"; +} + +void tst_QTextMarkdownWriter::testWriteParagraph() +{ + QFETCH(QString, input); + QFETCH(QString, output); + + QTextCursor cursor(document); + cursor.insertText(input); + + QCOMPARE(documentToUnixMarkdown(), output); +} + +void tst_QTextMarkdownWriter::testWriteList() +{ + QTextCursor cursor(document); + QTextList *list = cursor.createList(QTextListFormat::ListDisc); + cursor.insertText("ListItem 1"); + list->add(cursor.block()); + cursor.insertBlock(); + cursor.insertText("ListItem 2"); + list->add(cursor.block()); + + QCOMPARE(documentToUnixMarkdown(), QString::fromLatin1( + "- ListItem 1\n- ListItem 2\n")); +} + +void tst_QTextMarkdownWriter::testWriteNestedBulletLists() +{ + QTextCursor cursor(document); + + QTextList *list1 = cursor.createList(QTextListFormat::ListDisc); + cursor.insertText("ListItem 1"); + list1->add(cursor.block()); + + QTextListFormat fmt2; + fmt2.setStyle(QTextListFormat::ListCircle); + fmt2.setIndent(2); + QTextList *list2 = cursor.insertList(fmt2); + cursor.insertText("ListItem 2"); + + QTextListFormat fmt3; + fmt3.setStyle(QTextListFormat::ListSquare); + fmt3.setIndent(3); + cursor.insertList(fmt3); + cursor.insertText("ListItem 3"); + + cursor.insertBlock(); + cursor.insertText("ListItem 4"); + list1->add(cursor.block()); + + cursor.insertBlock(); + cursor.insertText("ListItem 5"); + list2->add(cursor.block()); + + QCOMPARE(documentToUnixMarkdown(), QString::fromLatin1( + "- ListItem 1\n * ListItem 2\n + ListItem 3\n- ListItem 4\n * ListItem 5\n")); +} + +void tst_QTextMarkdownWriter::testWriteNestedNumericLists() +{ + QTextCursor cursor(document); + + QTextList *list1 = cursor.createList(QTextListFormat::ListDecimal); + cursor.insertText("ListItem 1"); + list1->add(cursor.block()); + + QTextListFormat fmt2; + fmt2.setStyle(QTextListFormat::ListLowerAlpha); + fmt2.setNumberSuffix(QLatin1String(")")); + fmt2.setIndent(2); + QTextList *list2 = cursor.insertList(fmt2); + cursor.insertText("ListItem 2"); + + QTextListFormat fmt3; + fmt3.setStyle(QTextListFormat::ListDecimal); + fmt3.setIndent(3); + cursor.insertList(fmt3); + cursor.insertText("ListItem 3"); + + cursor.insertBlock(); + cursor.insertText("ListItem 4"); + list1->add(cursor.block()); + + cursor.insertBlock(); + cursor.insertText("ListItem 5"); + list2->add(cursor.block()); + + // There's no QTextList API to set the starting number so we hard-coded all lists to start at 1 (QTBUG-65384) + QCOMPARE(documentToUnixMarkdown(), QString::fromLatin1( + "1 ListItem 1\n 1) ListItem 2\n 1 ListItem 3\n2 ListItem 4\n 2) ListItem 5\n")); +} + +void tst_QTextMarkdownWriter::testWriteTable() +{ + QTextCursor cursor(document); + QTextTable * table = cursor.insertTable(4, 3); + cursor = table->cellAt(0, 0).firstCursorPosition(); + // valid Markdown tables need headers, but QTextTable doesn't make that distinction + // so QTextMarkdownWriter assumes the first row of any table is a header + cursor.insertText("one"); + cursor.movePosition(QTextCursor::NextCell); + cursor.insertText("two"); + cursor.movePosition(QTextCursor::NextCell); + cursor.insertText("three"); + cursor.movePosition(QTextCursor::NextCell); + + cursor.insertText("alice"); + cursor.movePosition(QTextCursor::NextCell); + cursor.insertText("bob"); + cursor.movePosition(QTextCursor::NextCell); + cursor.insertText("carl"); + cursor.movePosition(QTextCursor::NextCell); + + cursor.insertText("dennis"); + cursor.movePosition(QTextCursor::NextCell); + cursor.insertText("eric"); + cursor.movePosition(QTextCursor::NextCell); + cursor.insertText("fiona"); + cursor.movePosition(QTextCursor::NextCell); + + cursor.insertText("gina"); + /* + |one |two |three| + |------|----|-----| + |alice |bob |carl | + |dennis|eric|fiona| + |gina | | | + */ + + QString md = documentToUnixMarkdown(); + +#ifdef DEBUG_WRITE_OUTPUT + { + QFile out("/tmp/table.md"); + out.open(QFile::WriteOnly); + out.write(md.toUtf8()); + out.close(); + } +#endif + + QString expected = QString::fromLatin1( + "\n|one |two |three|\n|------|----|-----|\n|alice |bob |carl |\n|dennis|eric|fiona|\n|gina | | |\n\n"); + QCOMPARE(md, expected); + + // create table with merged cells + document->clear(); + cursor = QTextCursor(document); + table = cursor.insertTable(3, 3); + table->mergeCells(0, 0, 1, 2); + table->mergeCells(1, 1, 1, 2); + cursor = table->cellAt(0, 0).firstCursorPosition(); + cursor.insertText("a"); + cursor.movePosition(QTextCursor::NextCell); + cursor.insertText("b"); + cursor.movePosition(QTextCursor::NextCell); + cursor.insertText("c"); + cursor.movePosition(QTextCursor::NextCell); + cursor.insertText("d"); + cursor.movePosition(QTextCursor::NextCell); + cursor.insertText("e"); + cursor.movePosition(QTextCursor::NextCell); + cursor.insertText("f"); + /* + +---+-+ + |a |b| + +---+-+ + |c| d| + +-+-+-+ + |e|f| | + +-+-+-+ + + generates + + |a ||b| + |-|-|-| + |c|d || + |e|f| | + + */ + + md = documentToUnixMarkdown(); + +#ifdef DEBUG_WRITE_OUTPUT + { + QFile out("/tmp/table-merged-cells.md"); + out.open(QFile::WriteOnly); + out.write(md.toUtf8()); + out.close(); + } +#endif + + QCOMPARE(md, QString::fromLatin1("\n|a ||b|\n|-|-|-|\n|c|d ||\n|e|f| |\n\n")); +} + +void tst_QTextMarkdownWriter::rewriteDocument() +{ + QTextDocument doc; + QFile f(QFINDTESTDATA("data/example.md")); + QVERIFY(f.open(QFile::ReadOnly | QIODevice::Text)); + QString orig = QString::fromUtf8(f.readAll()); + f.close(); + doc.setMarkdown(orig); + QString md = doc.toMarkdown(); + +#ifdef DEBUG_WRITE_OUTPUT + QFile out("/tmp/rewrite.md"); + out.open(QFile::WriteOnly); + out.write(md.toUtf8()); + out.close(); +#endif + + QCOMPARE(md, orig); +} + +void tst_QTextMarkdownWriter::fromHtml_data() +{ + QTest::addColumn("input"); + QTest::addColumn("output"); + + QTest::newRow("long URL") << + "https://www.example.com/dir/subdir/subsubdir/subsubsubdir/subsubsubsubdir/subsubsubsubsubdir/" << + "*https://www.example.com/dir/subdir/subsubdir/subsubsubdir/subsubsubsubdir/subsubsubsubsubdir/*\n\n"; + QTest::newRow("non-emphasis inline asterisk") << "3 * 4" << "3 * 4\n\n"; + QTest::newRow("arithmetic") << "(2 * a * x + b)^2 = b^2 - 4 * a * c" << "(2 * a * x + b)^2 = b^2 - 4 * a * c\n\n"; + QTest::newRow("escaped asterisk after newline") << + "The first sentence of this paragraph holds 80 characters, then there's a star. * This is wrapped, but is not a bullet point." << + "The first sentence of this paragraph holds 80 characters, then there's a star.\n\\* This is wrapped, but is *not* a bullet point.\n\n"; + QTest::newRow("escaped plus after newline") << + "The first sentence of this paragraph holds 80 characters, then there's a plus. + This is wrapped, but is not a bullet point." << + "The first sentence of this paragraph holds 80 characters, then there's a plus.\n\\+ This is wrapped, but is *not* a bullet point.\n\n"; + QTest::newRow("escaped hyphen after newline") << + "The first sentence of this paragraph holds 80 characters, then there's a minus. - This is wrapped, but is not a bullet point." << + "The first sentence of this paragraph holds 80 characters, then there's a minus.\n\\- This is wrapped, but is *not* a bullet point.\n\n"; + // TODO +// QTest::newRow("escaped number and paren after double newline") << +// "

    (The first sentence of this paragraph is a line, the next paragraph has a number

    13) but that's not part of an ordered list" << +// "(The first sentence of this paragraph is a line, the next paragraph has a number\n\n13\\) but that's not part of an ordered list\n\n"; +// QTest::newRow("preformats with embedded backticks") << +// "
    none `one` ``two``
    ```three``` ````four````
    plain" << +// "``` none `one` ``two`` ```\n\n````` ```three``` ````four```` `````\n\nplain\n\n"; +} + +void tst_QTextMarkdownWriter::fromHtml() +{ + QFETCH(QString, input); + QFETCH(QString, output); + + document->setHtml(input); + QCOMPARE(documentToUnixMarkdown(), output); +} + +QString tst_QTextMarkdownWriter::documentToUnixMarkdown() +{ + QString ret; + QTextStream ts(&ret, QIODevice::WriteOnly); + QTextMarkdownWriter writer(ts, QTextDocument::MarkdownDialectGitHub); + writer.writeAll(*document); + return ret; +} + +QTEST_MAIN(tst_QTextMarkdownWriter) +#include "tst_qtextmarkdownwriter.moc" diff --git a/tests/auto/gui/text/text.pro b/tests/auto/gui/text/text.pro index 6b033fb506..a98debe35c 100644 --- a/tests/auto/gui/text/text.pro +++ b/tests/auto/gui/text/text.pro @@ -28,12 +28,15 @@ SUBDIRS=\ win32:SUBDIRS -= qtextpiecetable +qtConfig(textmarkdownwriter): SUBDIRS += qtextmarkdownwriter + !qtConfig(private_tests): SUBDIRS -= \ qfontcache \ qcssparser \ qtextlayout \ qtextpiecetable \ qzip \ + qtextmarkdownwriter \ qtextodfwriter !qtHaveModule(xml): SUBDIRS -= \ diff --git a/tests/manual/markdown/html2md.cpp b/tests/manual/markdown/html2md.cpp new file mode 100644 index 0000000000..19d6ff06af --- /dev/null +++ b/tests/manual/markdown/html2md.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** + ** + ** Copyright (C) 2019 The Qt Company Ltd. + ** 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 +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + QGuiApplication::setApplicationVersion(QT_VERSION_STR); + QCommandLineParser parser; + parser.setApplicationDescription("Converts the Qt-supported subset of HTML to Markdown."); + parser.addHelpOption(); + parser.addVersionOption(); + parser.addPositionalArgument(QGuiApplication::translate("main", "input"), + QGuiApplication::translate("main", "input file")); + parser.addPositionalArgument(QGuiApplication::translate("main", "output"), + QGuiApplication::translate("main", "output file")); + parser.process(app); + if (parser.positionalArguments().count() != 2) + parser.showHelp(1); + + QFile inFile(parser.positionalArguments().first()); + if (!inFile.open(QIODevice::ReadOnly)) { + qFatal("failed to open %s for reading", parser.positionalArguments().first().toLocal8Bit().data()); + exit(2); + } + QFile outFile(parser.positionalArguments().at(1)); + if (!outFile.open(QIODevice::WriteOnly)) { + qFatal("failed to open %s for writing", parser.positionalArguments().at(1).toLocal8Bit().data()); + exit(2); + } + QTextDocument doc; + doc.setHtml(QString::fromUtf8(inFile.readAll())); + outFile.write(doc.toMarkdown().toUtf8()); +} diff --git a/tests/manual/markdown/html2md.pro b/tests/manual/markdown/html2md.pro new file mode 100644 index 0000000000..4d6254e5a0 --- /dev/null +++ b/tests/manual/markdown/html2md.pro @@ -0,0 +1,6 @@ +TEMPLATE = app +TARGET = html2md +INCLUDEPATH += . +#QT += gui-private +SOURCES += html2md.cpp + From d4435a37cae43abfbdb247b7d4a3a950aced2751 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 30 Apr 2019 12:39:22 +0200 Subject: [PATCH 222/292] Add qobject_cast operators for std::shared_ptr Mimicking what we currently have for QSharedPointer, but also adding * snake_case version (matching the ones in std) * rvalue-overloaded versions (matching the C++2a overloads). [ChangeLog][QtCore][QSharedPointer] Overloads of qSharedPointerObjectCast have been added to work on std::shared_ptr. Change-Id: I26ddffd82b000bf876e7c141fdce86a7b8c1d75a Reviewed-by: Thiago Macieira --- src/corelib/tools/qsharedpointer.cpp | 51 +++++++++++++++++ src/corelib/tools/qsharedpointer_impl.h | 42 ++++++++++++++ .../qsharedpointer/tst_qsharedpointer.cpp | 55 +++++++++++++++++++ 3 files changed, 148 insertions(+) diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp index 62b76c5bb7..0aedf4c6d6 100644 --- a/src/corelib/tools/qsharedpointer.cpp +++ b/src/corelib/tools/qsharedpointer.cpp @@ -1299,6 +1299,57 @@ \sa QSharedPointer::objectCast(), qSharedPointerCast(), qSharedPointerConstCast() */ +/*! + \fn template std::shared_ptr qSharedPointerObjectCast(const std::shared_ptr &src) + \relates QSharedPointer + \since 5.14 + + Returns a shared pointer to the pointer held by \a src, using a + \l qobject_cast() to type \tt X to obtain an internal pointer of the + appropriate type. If the \tt qobject_cast fails, the object + returned will be null. + + Note that \tt X must have the same cv-qualifiers (\tt const and + \tt volatile) that \tt T has, or the code will fail to + compile. Use const_pointer_cast to cast away the constness. +*/ + +/*! + \fn template std::shared_ptr qobject_pointer_cast(const std::shared_ptr &src) + \relates QSharedPointer + \since 5.14 + + Same as qSharedPointerObjectCast(). This function is provided for STL + compatibility. +*/ + +/*! + \fn template std::shared_ptr qSharedPointerObjectCast(std::shared_ptr &&src) + \relates QSharedPointer + \since 5.14 + + Returns a shared pointer to the pointer held by \a src, using a + \l qobject_cast() to type \tt X to obtain an internal pointer of the + appropriate type. + + If the \tt qobject_cast succeeds, the function will return a valid shared + pointer, and \a src is reset to null. If the \tt qobject_cast fails, the + object returned will be null, and \a src will not be modified. + + Note that \tt X must have the same cv-qualifiers (\tt const and + \tt volatile) that \tt T has, or the code will fail to + compile. Use const_pointer_cast to cast away the constness. +*/ + +/*! + \fn template std::shared_ptr qobject_pointer_cast(std::shared_ptr &&src) + \relates QSharedPointer + \since 5.14 + + Same as qSharedPointerObjectCast(). This function is provided for STL + compatibility. +*/ + /*! \fn template template QSharedPointer qSharedPointerObjectCast(const QWeakPointer &src) \relates QSharedPointer diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 81d8dcd839..0851121ff2 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -67,6 +67,8 @@ QT_END_NAMESPACE #endif #include +#include + QT_BEGIN_NAMESPACE @@ -996,6 +998,46 @@ qSharedPointerFromVariant(const QVariant &variant) return qSharedPointerObjectCast(QtSharedPointer::sharedPointerFromVariant_internal(variant)); } +// std::shared_ptr helpers + +template +std::shared_ptr qobject_pointer_cast(const std::shared_ptr &src) +{ + using element_type = typename std::shared_ptr::element_type; + return std::shared_ptr(src, qobject_cast(src.get())); +} + +template +std::shared_ptr qobject_pointer_cast(std::shared_ptr &&src) +{ + using element_type = typename std::shared_ptr::element_type; + auto castResult = qobject_cast(src.get()); + if (castResult) { + auto result = std::shared_ptr(std::move(src), castResult); +#if __cplusplus <= 201703L + // C++2a's move aliasing constructor will leave src empty. + // Before C++2a we don't really know if the compiler has support for it. + // The move aliasing constructor is the resolution for LWG2996, + // which does not impose a feature-testing macro. So: clear src. + src.reset(); +#endif + return result; + } + return std::shared_ptr(); +} + +template +std::shared_ptr qSharedPointerObjectCast(const std::shared_ptr &src) +{ + return qobject_pointer_cast(src); +} + +template +std::shared_ptr qSharedPointerObjectCast(std::shared_ptr &&src) +{ + return qobject_pointer_cast(std::move(src)); +} + #endif template Q_DECLARE_TYPEINFO_BODY(QWeakPointer, Q_MOVABLE_TYPE); diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index 19b2aa02f3..3e87a506bf 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -78,6 +78,7 @@ private slots: void sharedPointerFromQObjectWithWeak(); void weakQObjectFromSharedPointer(); void objectCast(); + void objectCastStdSharedPtr(); void differentPointers(); void virtualBaseDifferentPointers(); #ifndef QTEST_NO_RTTI @@ -1113,6 +1114,60 @@ void tst_QSharedPointer::objectCast() safetyCheck(); } + +void tst_QSharedPointer::objectCastStdSharedPtr() +{ + { + OtherObject *data = new OtherObject; + std::shared_ptr baseptr = std::shared_ptr(data); + QVERIFY(baseptr.get() == data); + + // perform successful object cast + std::shared_ptr ptr = qobject_pointer_cast(baseptr); + QVERIFY(ptr.get()); + QVERIFY(ptr.get() == data); + + QVERIFY(baseptr.get() == data); + } + + { + OtherObject *data = new OtherObject; + std::shared_ptr baseptr = std::shared_ptr(data); + QVERIFY(baseptr.get() == data); + + // perform successful object cast + std::shared_ptr ptr = qobject_pointer_cast(std::move(baseptr)); + QVERIFY(ptr.get()); + QVERIFY(ptr.get() == data); + + QVERIFY(!baseptr.get()); + } + + { + QObject *data = new QObject; + std::shared_ptr baseptr = std::shared_ptr(data); + QVERIFY(baseptr.get() == data); + + // perform unsuccessful object cast + std::shared_ptr ptr = qobject_pointer_cast(baseptr); + QVERIFY(!ptr.get()); + + QVERIFY(baseptr.get() == data); + } + + { + QObject *data = new QObject; + std::shared_ptr baseptr = std::shared_ptr(data); + QVERIFY(baseptr.get() == data); + + // perform unsuccessful object cast + std::shared_ptr ptr = qobject_pointer_cast(std::move(baseptr)); + QVERIFY(!ptr.get()); + + QVERIFY(baseptr.get() == data); + } +} + void tst_QSharedPointer::differentPointers() { { From 2ded0043ca5115ddec41c15b2b98481f45bf0eba Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 30 Apr 2019 11:16:25 +0200 Subject: [PATCH 223/292] Moc: compile generate_keywords with corelib only It does not depend on QtGui. Change-Id: If7b01d1a6d2ce3945562f4480177ce883abfdbf4 Reviewed-by: Thiago Macieira Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/tools/moc/util/generate_keywords.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tools/moc/util/generate_keywords.pro b/src/tools/moc/util/generate_keywords.pro index 2bbc3ced61..e29738c18a 100644 --- a/src/tools/moc/util/generate_keywords.pro +++ b/src/tools/moc/util/generate_keywords.pro @@ -1,4 +1,5 @@ CONFIG -= moc CONFIG += cmdline +QT = core SOURCES += generate_keywords.cpp From b32b61f17eb6f816d854d6177e70df9c9e8fb895 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 30 Apr 2019 17:16:17 +0200 Subject: [PATCH 224/292] Remove handling of missing Q_COMPILER_RVALUE_REFS Remove remaining handling of missing support for rvalue refs. Change-Id: I78bab8bccfeeb9c76f464f345874364a37e4840a Reviewed-by: Edward Welbourne Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal.h | 5 +---- src/corelib/mimetypes/qmimetype_p.h | 19 ------------------- src/corelib/tools/qdatetime.h | 2 -- src/corelib/tools/qeasingcurve.h | 2 -- src/corelib/tools/qhash.h | 4 ---- src/corelib/tools/qlinkedlist.h | 2 -- src/corelib/tools/qlist.h | 2 -- src/corelib/tools/qlocale.h | 2 -- src/corelib/tools/qmap.h | 4 ---- src/corelib/tools/qpair.h | 2 -- src/corelib/tools/qregexp.h | 2 -- src/corelib/tools/qregularexpression.h | 8 -------- src/corelib/tools/qshareddata.h | 4 ---- src/corelib/tools/qsharedpointer_impl.h | 5 ----- src/corelib/tools/qstring.h | 4 ---- src/corelib/tools/qstringlist.h | 4 ---- src/corelib/tools/qtimezone.h | 2 -- src/corelib/tools/qvector.h | 8 -------- src/corelib/tools/qversionnumber.h | 4 ---- src/dbus/qdbusargument.h | 2 -- src/dbus/qdbusconnection.h | 2 -- src/dbus/qdbuserror.h | 2 -- src/dbus/qdbusextratypes.h | 6 ------ src/dbus/qdbusmessage.h | 2 -- src/dbus/qdbuspendingcall.h | 2 -- src/dbus/qdbusunixfiledescriptor.h | 6 +----- src/gui/image/qicon.h | 4 ---- src/gui/image/qimage.h | 4 ---- src/gui/image/qpicture.h | 2 -- src/gui/image/qpixmap.h | 4 ---- src/gui/image/qpixmapcache.h | 2 -- src/gui/kernel/qcursor.h | 2 -- src/gui/kernel/qevent.h | 2 -- src/gui/kernel/qkeysequence.h | 2 -- src/gui/kernel/qpalette.h | 2 -- src/gui/opengl/qopengldebug.h | 2 -- src/gui/opengl/qopenglpixeltransferoptions.h | 2 -- src/gui/painting/qbrush.h | 2 -- src/gui/painting/qcolor.h | 2 -- src/gui/painting/qpagelayout.h | 2 -- src/gui/painting/qpagesize.h | 2 -- src/gui/painting/qpainterpath.h | 2 -- src/gui/painting/qpen.h | 2 -- src/gui/painting/qpolygon.h | 8 -------- src/gui/painting/qregion.h | 2 -- src/gui/text/qfont.h | 2 -- src/gui/text/qfontmetrics.h | 4 ---- src/gui/text/qglyphrun.h | 2 -- src/gui/text/qrawfont.h | 2 -- src/gui/text/qstatictext.h | 2 -- src/gui/text/qtextcursor.h | 2 -- src/network/access/qabstractnetworkcache.h | 2 -- src/network/access/qhttpmultipart.h | 2 -- src/network/access/qnetworkcookie.h | 2 -- src/network/access/qnetworkrequest.h | 2 -- src/network/bearer/qnetworkconfiguration.h | 2 -- src/network/kernel/qdnslookup.h | 10 ---------- src/network/kernel/qhostaddress.h | 3 --- src/network/kernel/qnetworkinterface.h | 4 ---- src/network/kernel/qnetworkproxy.h | 4 ---- src/network/ssl/qsslcertificate.h | 2 -- src/network/ssl/qsslcertificateextension.h | 2 -- src/network/ssl/qsslcipher.h | 2 -- src/network/ssl/qsslconfiguration.h | 2 -- src/network/ssl/qsslerror.h | 2 -- .../ssl/qsslpresharedkeyauthenticator.h | 2 -- src/printsupport/kernel/qprintdevice_p.h | 2 -- .../corelib/global/qglobal/tst_qglobal.cpp | 4 ---- .../qsignalblocker/tst_qsignalblocker.cpp | 5 ----- .../mimetypes/qmimetype/tst_qmimetype.cpp | 4 ---- .../tools/qarraydata/tst_qarraydata.cpp | 4 ---- .../corelib/tools/qcollator/tst_qcollator.cpp | 6 ------ .../tools/qeasingcurve/tst_qeasingcurve.cpp | 6 +----- .../qsharedpointer/tst_qsharedpointer.cpp | 6 ------ .../corelib/tools/qvector/tst_qvector.cpp | 4 ---- .../qversionnumber/tst_qversionnumber.cpp | 5 ----- .../auto/gui/kernel/qpalette/tst_qpalette.cpp | 4 ---- 77 files changed, 3 insertions(+), 261 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 3c17bbb2d4..ceae0583ee 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -509,11 +509,8 @@ namespace QtPrivate { template struct AlignOf : AlignOf_Default { }; template struct AlignOf : AlignOf {}; - template struct AlignOf : AlignOf {}; - -#ifdef Q_COMPILER_RVALUE_REFS template struct AlignOf : AlignOf {}; -#endif + template struct AlignOf : AlignOf {}; #if defined(Q_PROCESSOR_X86_32) && !defined(Q_OS_WIN) template struct AlignOf_WorkaroundForI386Abi { enum { Value = sizeof(T) }; }; diff --git a/src/corelib/mimetypes/qmimetype_p.h b/src/corelib/mimetypes/qmimetype_p.h index 2918309ad7..0d6b4b4b12 100644 --- a/src/corelib/mimetypes/qmimetype_p.h +++ b/src/corelib/mimetypes/qmimetype_p.h @@ -84,25 +84,6 @@ public: QT_END_NAMESPACE -#define QMIMETYPE_BUILDER \ - QT_BEGIN_NAMESPACE \ - static QMimeType buildQMimeType ( \ - const QString &name, \ - const QString &genericIconName, \ - const QString &iconName, \ - const QStringList &globPatterns \ - ) \ - { \ - QMimeTypePrivate qMimeTypeData; \ - qMimeTypeData.name = name; \ - qMimeTypeData.loaded = true; \ - qMimeTypeData.genericIconName = genericIconName; \ - qMimeTypeData.iconName = iconName; \ - qMimeTypeData.globPatterns = globPatterns; \ - return QMimeType(qMimeTypeData); \ - } \ - QT_END_NAMESPACE - #define QMIMETYPE_BUILDER_FROM_RVALUE_REFS \ QT_BEGIN_NAMESPACE \ static QMimeType buildQMimeType ( \ diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h index 8873651f17..79fd25d762 100644 --- a/src/corelib/tools/qdatetime.h +++ b/src/corelib/tools/qdatetime.h @@ -278,9 +278,7 @@ public: QDateTime(QDateTime &&other) noexcept; ~QDateTime(); -#ifdef Q_COMPILER_RVALUE_REFS QDateTime &operator=(QDateTime &&other) noexcept { swap(other); return *this; } -#endif QDateTime &operator=(const QDateTime &other) noexcept; void swap(QDateTime &other) noexcept { qSwap(d.d, other.d.d); } diff --git a/src/corelib/tools/qeasingcurve.h b/src/corelib/tools/qeasingcurve.h index 1791f19199..725ddd5dcc 100644 --- a/src/corelib/tools/qeasingcurve.h +++ b/src/corelib/tools/qeasingcurve.h @@ -80,11 +80,9 @@ public: QEasingCurve &operator=(const QEasingCurve &other) { if ( this != &other ) { QEasingCurve copy(other); swap(copy); } return *this; } -#ifdef Q_COMPILER_RVALUE_REFS QEasingCurve(QEasingCurve &&other) noexcept : d_ptr(other.d_ptr) { other.d_ptr = nullptr; } QEasingCurve &operator=(QEasingCurve &&other) noexcept { qSwap(d_ptr, other.d_ptr); return *this; } -#endif void swap(QEasingCurve &other) noexcept { qSwap(d_ptr, other.d_ptr); } diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index a757e85386..0078bbbee9 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -255,11 +255,9 @@ public: ~QHash() { if (!d->ref.deref()) freeData(d); } QHash &operator=(const QHash &other); -#ifdef Q_COMPILER_RVALUE_REFS QHash(QHash &&other) noexcept : d(other.d) { other.d = const_cast(&QHashData::shared_null); } QHash &operator=(QHash &&other) noexcept { QHash moved(std::move(other)); swap(moved); return *this; } -#endif #ifdef Q_QDOC template QHash(InputIterator f, InputIterator l); @@ -1076,9 +1074,7 @@ public: // compiler-generated destructor is fine! QMultiHash(const QHash &other) : QHash(other) {} -#ifdef Q_COMPILER_RVALUE_REFS QMultiHash(QHash &&other) noexcept : QHash(std::move(other)) {} -#endif void swap(QMultiHash &other) noexcept { QHash::swap(other); } // prevent QMultiHash<->QHash swaps inline typename QHash::iterator replace(const Key &key, const T &value) diff --git a/src/corelib/tools/qlinkedlist.h b/src/corelib/tools/qlinkedlist.h index 83f70deceb..0c8a99e258 100644 --- a/src/corelib/tools/qlinkedlist.h +++ b/src/corelib/tools/qlinkedlist.h @@ -95,12 +95,10 @@ public: } ~QLinkedList(); QLinkedList &operator=(const QLinkedList &); -#ifdef Q_COMPILER_RVALUE_REFS QLinkedList(QLinkedList &&other) noexcept : d(other.d) { other.d = const_cast(&QLinkedListData::shared_null); } QLinkedList &operator=(QLinkedList &&other) noexcept { QLinkedList moved(std::move(other)); swap(moved); return *this; } -#endif inline void swap(QLinkedList &other) noexcept { qSwap(d, other.d); } bool operator==(const QLinkedList &l) const; inline bool operator!=(const QLinkedList &l) const { return !(*this == l); } diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 48a71b0ecf..59578b1e61 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -161,12 +161,10 @@ public: QList(const QList &l); ~QList(); QList &operator=(const QList &l); -#ifdef Q_COMPILER_RVALUE_REFS inline QList(QList &&other) noexcept : d(other.d) { other.d = const_cast(&QListData::shared_null); } inline QList &operator=(QList &&other) noexcept { QList moved(std::move(other)); swap(moved); return *this; } -#endif inline void swap(QList &other) noexcept { qSwap(d, other.d); } #ifdef Q_COMPILER_INITIALIZER_LISTS inline QList(std::initializer_list args) diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h index 3dc5ee0a01..977c4c6c9c 100644 --- a/src/corelib/tools/qlocale.h +++ b/src/corelib/tools/qlocale.h @@ -939,9 +939,7 @@ public: QLocale(Language language, Country country = AnyCountry); QLocale(Language language, Script script, Country country); QLocale(const QLocale &other); -#ifdef Q_COMPILER_RVALUE_REFS QLocale &operator=(QLocale &&other) noexcept { swap(other); return *this; } -#endif QLocale &operator=(const QLocale &other); ~QLocale(); diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index 103124f4ad..3b8aad9a33 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -339,7 +339,6 @@ public: inline ~QMap() { if (!d->ref.deref()) d->destroy(); } QMap &operator=(const QMap &other); -#ifdef Q_COMPILER_RVALUE_REFS inline QMap(QMap &&other) noexcept : d(other.d) { @@ -349,7 +348,6 @@ public: inline QMap &operator=(QMap &&other) noexcept { QMap moved(std::move(other)); swap(moved); return *this; } -#endif inline void swap(QMap &other) noexcept { qSwap(d, other.d); } explicit QMap(const typename std::map &other); std::map toStdMap() const; @@ -1196,9 +1194,7 @@ public: } #endif QMultiMap(const QMap &other) : QMap(other) {} -#ifdef Q_COMPILER_RVALUE_REFS QMultiMap(QMap &&other) noexcept : QMap(std::move(other)) {} -#endif void swap(QMultiMap &other) noexcept { QMap::swap(other); } inline typename QMap::iterator replace(const Key &key, const T &value) diff --git a/src/corelib/tools/qpair.h b/src/corelib/tools/qpair.h index 6d1e67efb7..9ebf88bc8f 100644 --- a/src/corelib/tools/qpair.h +++ b/src/corelib/tools/qpair.h @@ -71,7 +71,6 @@ struct QPair noexcept((std::is_nothrow_assignable::value && std::is_nothrow_assignable::value)) { first = p.first; second = p.second; return *this; } -#ifdef Q_COMPILER_RVALUE_REFS template Q_DECL_CONSTEXPR QPair(QPair &&p) noexcept((std::is_nothrow_constructible::value && @@ -83,7 +82,6 @@ struct QPair noexcept((std::is_nothrow_assignable::value && std::is_nothrow_assignable::value)) { first = std::move(p.first); second = std::move(p.second); return *this; } -#endif Q_DECL_RELAXED_CONSTEXPR void swap(QPair &other) noexcept(noexcept(qSwap(other.first, other.first)) && noexcept(qSwap(other.second, other.second))) diff --git a/src/corelib/tools/qregexp.h b/src/corelib/tools/qregexp.h index c043a06496..8f6de24c74 100644 --- a/src/corelib/tools/qregexp.h +++ b/src/corelib/tools/qregexp.h @@ -73,9 +73,7 @@ public: QRegExp(const QRegExp &rx); ~QRegExp(); QRegExp &operator=(const QRegExp &rx); -#ifdef Q_COMPILER_RVALUE_REFS QRegExp &operator=(QRegExp &&other) noexcept { swap(other); return *this; } -#endif void swap(QRegExp &other) noexcept { qSwap(priv, other.priv); } bool operator==(const QRegExp &rx) const; diff --git a/src/corelib/tools/qregularexpression.h b/src/corelib/tools/qregularexpression.h index f16b7e91be..f799a38ae4 100644 --- a/src/corelib/tools/qregularexpression.h +++ b/src/corelib/tools/qregularexpression.h @@ -86,11 +86,8 @@ public: QRegularExpression(const QRegularExpression &re); ~QRegularExpression(); QRegularExpression &operator=(const QRegularExpression &re); - -#ifdef Q_COMPILER_RVALUE_REFS QRegularExpression &operator=(QRegularExpression &&re) noexcept { d.swap(re.d); return *this; } -#endif void swap(QRegularExpression &other) noexcept { d.swap(other.d); } @@ -186,11 +183,8 @@ public: ~QRegularExpressionMatch(); QRegularExpressionMatch(const QRegularExpressionMatch &match); QRegularExpressionMatch &operator=(const QRegularExpressionMatch &match); - -#ifdef Q_COMPILER_RVALUE_REFS QRegularExpressionMatch &operator=(QRegularExpressionMatch &&match) noexcept { d.swap(match.d); return *this; } -#endif void swap(QRegularExpressionMatch &other) noexcept { d.swap(other.d); } QRegularExpression regularExpression() const; @@ -257,10 +251,8 @@ public: ~QRegularExpressionMatchIterator(); QRegularExpressionMatchIterator(const QRegularExpressionMatchIterator &iterator); QRegularExpressionMatchIterator &operator=(const QRegularExpressionMatchIterator &iterator); -#ifdef Q_COMPILER_RVALUE_REFS QRegularExpressionMatchIterator &operator=(QRegularExpressionMatchIterator &&iterator) noexcept { d.swap(iterator.d); return *this; } -#endif void swap(QRegularExpressionMatchIterator &other) noexcept { d.swap(other.d); } bool isValid() const; diff --git a/src/corelib/tools/qshareddata.h b/src/corelib/tools/qshareddata.h index cbaa1aa3c4..04051472d6 100644 --- a/src/corelib/tools/qshareddata.h +++ b/src/corelib/tools/qshareddata.h @@ -112,7 +112,6 @@ public: } return *this; } -#ifdef Q_COMPILER_RVALUE_REFS QSharedDataPointer(QSharedDataPointer &&o) noexcept : d(o.d) { o.d = nullptr; } inline QSharedDataPointer &operator=(QSharedDataPointer &&other) noexcept { @@ -120,7 +119,6 @@ public: swap(moved); return *this; } -#endif inline bool operator!() const { return !d; } @@ -218,7 +216,6 @@ public: } return *this; } -#ifdef Q_COMPILER_RVALUE_REFS inline QExplicitlySharedDataPointer(QExplicitlySharedDataPointer &&o) noexcept : d(o.d) { o.d = nullptr; } inline QExplicitlySharedDataPointer &operator=(QExplicitlySharedDataPointer &&other) noexcept { @@ -226,7 +223,6 @@ public: swap(moved); return *this; } -#endif inline bool operator!() const { return !d; } diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 0851121ff2..9fb452da6b 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -337,7 +337,6 @@ public: swap(copy); return *this; } -#ifdef Q_COMPILER_RVALUE_REFS QSharedPointer(QSharedPointer &&other) noexcept : value(other.value), d(other.d) { @@ -367,8 +366,6 @@ public: return *this; } -#endif - template QSharedPointer(const QSharedPointer &other) noexcept : value(other.value), d(other.d) { if (d) ref(); } @@ -590,7 +587,6 @@ public: QWeakPointer(const QWeakPointer &other) noexcept : d(other.d), value(other.value) { if (d) d->weakref.ref(); } -#ifdef Q_COMPILER_RVALUE_REFS QWeakPointer(QWeakPointer &&other) noexcept : d(other.d), value(other.value) { @@ -599,7 +595,6 @@ public: } QWeakPointer &operator=(QWeakPointer &&other) noexcept { QWeakPointer moved(std::move(other)); swap(moved); return *this; } -#endif QWeakPointer &operator=(const QWeakPointer &other) noexcept { QWeakPointer copy(other); diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index a526a6537a..e4798eb51b 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -230,11 +230,9 @@ public: QString &operator=(QChar c); QString &operator=(const QString &) noexcept; QString &operator=(QLatin1String latin1); -#ifdef Q_COMPILER_RVALUE_REFS inline QString(QString && other) noexcept : d(other.d) { other.d = Data::sharedNull(); } inline QString &operator=(QString &&other) noexcept { qSwap(d, other.d); return *this; } -#endif inline void swap(QString &other) noexcept { qSwap(d, other.d); } inline int size() const { return d->size; } inline int count() const { return d->size; } @@ -1437,10 +1435,8 @@ public: QStringRef(const QStringRef &other) noexcept :m_string(other.m_string), m_position(other.m_position), m_size(other.m_size) {} -#ifdef Q_COMPILER_RVALUE_REFS QStringRef(QStringRef &&other) noexcept : m_string(other.m_string), m_position(other.m_position), m_size(other.m_size) {} QStringRef &operator=(QStringRef &&other) noexcept { return *this = other; } -#endif QStringRef &operator=(const QStringRef &other) noexcept { m_string = other.m_string; m_position = other.m_position; diff --git a/src/corelib/tools/qstringlist.h b/src/corelib/tools/qstringlist.h index 5ad01a0658..73ac737643 100644 --- a/src/corelib/tools/qstringlist.h +++ b/src/corelib/tools/qstringlist.h @@ -104,9 +104,7 @@ public: inline QStringList() noexcept { } inline explicit QStringList(const QString &i) { append(i); } inline QStringList(const QList &l) : QList(l) { } -#ifdef Q_COMPILER_RVALUE_REFS inline QStringList(QList &&l) noexcept : QList(std::move(l)) { } -#endif #ifdef Q_COMPILER_INITIALIZER_LISTS inline QStringList(std::initializer_list args) : QList(args) { } #endif @@ -116,10 +114,8 @@ public: QStringList &operator=(const QList &other) { QList::operator=(other); return *this; } -#ifdef Q_COMPILER_RVALUE_REFS QStringList &operator=(QList &&other) noexcept { QList::operator=(std::move(other)); return *this; } -#endif #if QT_STRINGVIEW_LEVEL < 2 inline bool contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; diff --git a/src/corelib/tools/qtimezone.h b/src/corelib/tools/qtimezone.h index ca98986ec1..62ecee49bb 100644 --- a/src/corelib/tools/qtimezone.h +++ b/src/corelib/tools/qtimezone.h @@ -99,9 +99,7 @@ public: ~QTimeZone(); QTimeZone &operator=(const QTimeZone &other); - #ifdef Q_COMPILER_RVALUE_REFS QTimeZone &operator=(QTimeZone &&other) noexcept { swap(other); return *this; } -#endif void swap(QTimeZone &other) noexcept { d.swap(other.d); } diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 6cbf794c6c..7e14a0c9b2 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -72,11 +72,9 @@ public: inline QVector(const QVector &v); inline ~QVector() { if (!d->ref.deref()) freeData(d); } QVector &operator=(const QVector &v); -#if defined(Q_COMPILER_RVALUE_REFS) || defined(Q_CLANG_QDOC) QVector(QVector &&other) noexcept : d(other.d) { other.d = Data::sharedNull(); } QVector &operator=(QVector &&other) noexcept { QVector moved(std::move(other)); swap(moved); return *this; } -#endif void swap(QVector &other) noexcept { qSwap(d, other.d); } #ifdef Q_COMPILER_INITIALIZER_LISTS inline QVector(std::initializer_list args); @@ -143,9 +141,7 @@ public: T &operator[](int i); const T &operator[](int i) const; void append(const T &t); -#if defined(Q_COMPILER_RVALUE_REFS) || defined(Q_CLANG_QDOC) void append(T &&t); -#endif inline void append(const QVector &l) { *this += l; } void prepend(T &&t); void prepend(const T &t); @@ -268,10 +264,8 @@ public: typedef const_iterator ConstIterator; typedef int size_type; inline void push_back(const T &t) { append(t); } -#if defined(Q_COMPILER_RVALUE_REFS) || defined(Q_CLANG_QDOC) void push_back(T &&t) { append(std::move(t)); } void push_front(T &&t) { prepend(std::move(t)); } -#endif inline void push_front(const T &t) { prepend(t); } void pop_back() { removeLast(); } void pop_front() { removeFirst(); } @@ -799,7 +793,6 @@ void QVector::append(const T &t) ++d->size; } -#ifdef Q_COMPILER_RVALUE_REFS template void QVector::append(T &&t) { @@ -813,7 +806,6 @@ void QVector::append(T &&t) ++d->size; } -#endif template void QVector::removeLast() diff --git a/src/corelib/tools/qversionnumber.h b/src/corelib/tools/qversionnumber.h index d51947c091..1488014d38 100644 --- a/src/corelib/tools/qversionnumber.h +++ b/src/corelib/tools/qversionnumber.h @@ -119,7 +119,6 @@ class QVersionNumber return *this; } -#ifdef Q_COMPILER_RVALUE_REFS SegmentStorage(SegmentStorage &&other) noexcept : dummy(other.dummy) { @@ -139,7 +138,6 @@ class QVersionNumber else pointer_segments = new QVector(std::move(seg)); } -#endif #ifdef Q_COMPILER_INITIALIZER_LISTS SegmentStorage(std::initializer_list args) { @@ -227,11 +225,9 @@ public: // compiler-generated copy/move ctor/assignment operators and the destructor are ok -#ifdef Q_COMPILER_RVALUE_REFS explicit QVersionNumber(QVector &&seg) : m_segments(std::move(seg)) {} -#endif #ifdef Q_COMPILER_INITIALIZER_LISTS inline QVersionNumber(std::initializer_list args) diff --git a/src/dbus/qdbusargument.h b/src/dbus/qdbusargument.h index 7f4bd269a9..b7cd4c8989 100644 --- a/src/dbus/qdbusargument.h +++ b/src/dbus/qdbusargument.h @@ -76,10 +76,8 @@ public: QDBusArgument(); QDBusArgument(const QDBusArgument &other); -#ifdef Q_COMPILER_RVALUE_REFS QDBusArgument(QDBusArgument &&other) noexcept : d(other.d) { other.d = nullptr; } QDBusArgument &operator=(QDBusArgument &&other) noexcept { swap(other); return *this; } -#endif QDBusArgument &operator=(const QDBusArgument &other); ~QDBusArgument(); diff --git a/src/dbus/qdbusconnection.h b/src/dbus/qdbusconnection.h index a880a7a939..368f811602 100644 --- a/src/dbus/qdbusconnection.h +++ b/src/dbus/qdbusconnection.h @@ -131,10 +131,8 @@ public: explicit QDBusConnection(const QString &name); QDBusConnection(const QDBusConnection &other); -#ifdef Q_COMPILER_RVALUE_REFS QDBusConnection(QDBusConnection &&other) noexcept : d(other.d) { other.d = nullptr; } QDBusConnection &operator=(QDBusConnection &&other) noexcept { swap(other); return *this; } -#endif QDBusConnection &operator=(const QDBusConnection &other); ~QDBusConnection(); diff --git a/src/dbus/qdbuserror.h b/src/dbus/qdbuserror.h index 5a68a417c4..bcf68dbcdc 100644 --- a/src/dbus/qdbuserror.h +++ b/src/dbus/qdbuserror.h @@ -98,12 +98,10 @@ public: #endif QDBusError(ErrorType error, const QString &message); QDBusError(const QDBusError &other); -#ifdef Q_COMPILER_RVALUE_REFS QDBusError(QDBusError &&other) noexcept : code(other.code), msg(std::move(other.msg)), nm(std::move(other.nm)) {} QDBusError &operator=(QDBusError &&other) noexcept { swap(other); return *this; } -#endif QDBusError &operator=(const QDBusError &other); #ifndef QT_BOOTSTRAPPED QDBusError &operator=(const QDBusMessage &msg); diff --git a/src/dbus/qdbusextratypes.h b/src/dbus/qdbusextratypes.h index e2430ad6f2..fdac917947 100644 --- a/src/dbus/qdbusextratypes.h +++ b/src/dbus/qdbusextratypes.h @@ -66,9 +66,7 @@ public: inline explicit QDBusObjectPath(const char *path); inline explicit QDBusObjectPath(QLatin1String path); inline explicit QDBusObjectPath(const QString &path); -#ifdef Q_COMPILER_RVALUE_REFS explicit QDBusObjectPath(QString &&p) : m_path(std::move(p)) { doCheck(); } -#endif void swap(QDBusObjectPath &other) noexcept { qSwap(m_path, other.m_path); } @@ -121,9 +119,7 @@ public: inline explicit QDBusSignature(const char *signature); inline explicit QDBusSignature(QLatin1String signature); inline explicit QDBusSignature(const QString &signature); -#ifdef Q_COMPILER_RVALUE_REFS explicit QDBusSignature(QString &&sig) : m_signature(std::move(sig)) { doCheck(); } -#endif void swap(QDBusSignature &other) noexcept { qSwap(m_signature, other.m_signature); } @@ -173,9 +169,7 @@ public: // compiler-generated destructor is ok! inline explicit QDBusVariant(const QVariant &variant); -#ifdef Q_COMPILER_RVALUE_REFS explicit QDBusVariant(QVariant &&v) noexcept : m_variant(std::move(v)) {} -#endif void swap(QDBusVariant &other) noexcept { qSwap(m_variant, other.m_variant); } diff --git a/src/dbus/qdbusmessage.h b/src/dbus/qdbusmessage.h index 3e73db70de..41845317c4 100644 --- a/src/dbus/qdbusmessage.h +++ b/src/dbus/qdbusmessage.h @@ -68,9 +68,7 @@ public: QDBusMessage(); QDBusMessage(const QDBusMessage &other); -#ifdef Q_COMPILER_RVALUE_REFS QDBusMessage &operator=(QDBusMessage &&other) noexcept { swap(other); return *this; } -#endif QDBusMessage &operator=(const QDBusMessage &other); ~QDBusMessage(); diff --git a/src/dbus/qdbuspendingcall.h b/src/dbus/qdbuspendingcall.h index c521b7d163..dd99346301 100644 --- a/src/dbus/qdbuspendingcall.h +++ b/src/dbus/qdbuspendingcall.h @@ -60,9 +60,7 @@ class Q_DBUS_EXPORT QDBusPendingCall public: QDBusPendingCall(const QDBusPendingCall &other); ~QDBusPendingCall(); -#ifdef Q_COMPILER_RVALUE_REFS QDBusPendingCall &operator=(QDBusPendingCall &&other) noexcept { swap(other); return *this; } -#endif QDBusPendingCall &operator=(const QDBusPendingCall &other); void swap(QDBusPendingCall &other) noexcept { qSwap(d, other.d); } diff --git a/src/dbus/qdbusunixfiledescriptor.h b/src/dbus/qdbusunixfiledescriptor.h index 6b264a6b86..fcd73b2ec5 100644 --- a/src/dbus/qdbusunixfiledescriptor.h +++ b/src/dbus/qdbusunixfiledescriptor.h @@ -46,9 +46,7 @@ #ifndef QT_NO_DBUS -#ifdef Q_COMPILER_RVALUE_REFS -# include -#endif +#include QT_BEGIN_NAMESPACE @@ -61,9 +59,7 @@ public: QDBusUnixFileDescriptor(); explicit QDBusUnixFileDescriptor(int fileDescriptor); QDBusUnixFileDescriptor(const QDBusUnixFileDescriptor &other); -#if defined(Q_COMPILER_RVALUE_REFS) QDBusUnixFileDescriptor &operator=(QDBusUnixFileDescriptor &&other) noexcept { swap(other); return *this; } -#endif QDBusUnixFileDescriptor &operator=(const QDBusUnixFileDescriptor &other); ~QDBusUnixFileDescriptor(); diff --git a/src/gui/image/qicon.h b/src/gui/image/qicon.h index 0f834fc2cb..735a3e134d 100644 --- a/src/gui/image/qicon.h +++ b/src/gui/image/qicon.h @@ -61,19 +61,15 @@ public: QIcon() noexcept; QIcon(const QPixmap &pixmap); QIcon(const QIcon &other); -#ifdef Q_COMPILER_RVALUE_REFS QIcon(QIcon &&other) noexcept : d(other.d) { other.d = nullptr; } -#endif explicit QIcon(const QString &fileName); // file or resource name explicit QIcon(QIconEngine *engine); ~QIcon(); QIcon &operator=(const QIcon &other); -#ifdef Q_COMPILER_RVALUE_REFS inline QIcon &operator=(QIcon &&other) noexcept { swap(other); return *this; } -#endif inline void swap(QIcon &other) noexcept { qSwap(d, other.d); } diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index 9d177142d9..7c68168be8 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -151,18 +151,14 @@ public: explicit QImage(const QString &fileName, const char *format = nullptr); QImage(const QImage &); -#ifdef Q_COMPILER_RVALUE_REFS inline QImage(QImage &&other) noexcept : QPaintDevice(), d(nullptr) { qSwap(d, other.d); } -#endif ~QImage(); QImage &operator=(const QImage &); -#ifdef Q_COMPILER_RVALUE_REFS inline QImage &operator=(QImage &&other) noexcept { qSwap(d, other.d); return *this; } -#endif inline void swap(QImage &other) noexcept { qSwap(d, other.d); } diff --git a/src/gui/image/qpicture.h b/src/gui/image/qpicture.h index cac2ef5dfc..189e57b9a3 100644 --- a/src/gui/image/qpicture.h +++ b/src/gui/image/qpicture.h @@ -78,10 +78,8 @@ public: void setBoundingRect(const QRect &r); QPicture& operator=(const QPicture &p); -#ifdef Q_COMPILER_RVALUE_REFS inline QPicture &operator=(QPicture &&other) noexcept { qSwap(d_ptr, other.d_ptr); return *this; } -#endif inline void swap(QPicture &other) noexcept { d_ptr.swap(other.d_ptr); } void detach(); diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index 2103fcc58c..8c1395857e 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -73,10 +73,8 @@ public: ~QPixmap(); QPixmap &operator=(const QPixmap &); -#ifdef Q_COMPILER_RVALUE_REFS inline QPixmap &operator=(QPixmap &&other) noexcept { qSwap(data, other.data); return *this; } -#endif inline void swap(QPixmap &other) noexcept { qSwap(data, other.data); } @@ -139,12 +137,10 @@ public: QImage toImage() const; static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags = Qt::AutoColor); static QPixmap fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags = Qt::AutoColor); -#ifdef Q_COMPILER_RVALUE_REFS static QPixmap fromImage(QImage &&image, Qt::ImageConversionFlags flags = Qt::AutoColor) { return fromImageInPlace(image, flags); } -#endif bool load(const QString& fileName, const char *format = nullptr, Qt::ImageConversionFlags flags = Qt::AutoColor); bool loadFromData(const uchar *buf, uint len, const char* format = nullptr, Qt::ImageConversionFlags flags = Qt::AutoColor); diff --git a/src/gui/image/qpixmapcache.h b/src/gui/image/qpixmapcache.h index c5bedb27ab..55af35a5d9 100644 --- a/src/gui/image/qpixmapcache.h +++ b/src/gui/image/qpixmapcache.h @@ -55,10 +55,8 @@ public: public: Key(); Key(const Key &other); -#ifdef Q_COMPILER_RVALUE_REFS Key(Key &&other) noexcept : d(other.d) { other.d = nullptr; } Key &operator =(Key &&other) noexcept { swap(other); return *this; } -#endif ~Key(); bool operator ==(const Key &key) const; inline bool operator !=(const Key &key) const diff --git a/src/gui/kernel/qcursor.h b/src/gui/kernel/qcursor.h index ced166dc29..7966e35840 100644 --- a/src/gui/kernel/qcursor.h +++ b/src/gui/kernel/qcursor.h @@ -86,11 +86,9 @@ public: QCursor(const QCursor &cursor); ~QCursor(); QCursor &operator=(const QCursor &cursor); -#ifdef Q_COMPILER_RVALUE_REFS QCursor(QCursor &&other) noexcept : d(other.d) { other.d = nullptr; } inline QCursor &operator=(QCursor &&other) noexcept { swap(other); return *this; } -#endif void swap(QCursor &other) noexcept { qSwap(d, other.d); } diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index aeefb53819..eb0a6208a9 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -855,13 +855,11 @@ public: explicit TouchPoint(int id = -1); TouchPoint(const TouchPoint &other); -#ifdef Q_COMPILER_RVALUE_REFS TouchPoint(TouchPoint &&other) noexcept : d(nullptr) { qSwap(d, other.d); } TouchPoint &operator=(TouchPoint &&other) noexcept { qSwap(d, other.d); return *this; } -#endif ~TouchPoint(); TouchPoint &operator=(const TouchPoint &other) diff --git a/src/gui/kernel/qkeysequence.h b/src/gui/kernel/qkeysequence.h index 5630bdda58..3dcbbe5941 100644 --- a/src/gui/kernel/qkeysequence.h +++ b/src/gui/kernel/qkeysequence.h @@ -186,9 +186,7 @@ public: operator QVariant() const; int operator[](uint i) const; QKeySequence &operator=(const QKeySequence &other); -#ifdef Q_COMPILER_RVALUE_REFS QKeySequence &operator=(QKeySequence &&other) noexcept { swap(other); return *this; } -#endif void swap(QKeySequence &other) noexcept { qSwap(d, other.d); } bool operator==(const QKeySequence &other) const; diff --git a/src/gui/kernel/qpalette.h b/src/gui/kernel/qpalette.h index a463245d4d..d3a840d9ad 100644 --- a/src/gui/kernel/qpalette.h +++ b/src/gui/kernel/qpalette.h @@ -67,7 +67,6 @@ public: QPalette(const QPalette &palette); ~QPalette(); QPalette &operator=(const QPalette &palette); -#ifdef Q_COMPILER_RVALUE_REFS QPalette(QPalette &&other) noexcept : d(other.d), data(other.data) { other.d = nullptr; } @@ -76,7 +75,6 @@ public: for_faster_swapping_dont_use = other.for_faster_swapping_dont_use; qSwap(d, other.d); return *this; } -#endif void swap(QPalette &other) noexcept { diff --git a/src/gui/opengl/qopengldebug.h b/src/gui/opengl/qopengldebug.h index 1ba3ef91ac..7363985d60 100644 --- a/src/gui/opengl/qopengldebug.h +++ b/src/gui/opengl/qopengldebug.h @@ -110,9 +110,7 @@ public: QOpenGLDebugMessage(const QOpenGLDebugMessage &debugMessage); QOpenGLDebugMessage &operator=(const QOpenGLDebugMessage &debugMessage); -#ifdef Q_COMPILER_RVALUE_REFS QOpenGLDebugMessage &operator=(QOpenGLDebugMessage &&other) noexcept { swap(other); return *this; } -#endif ~QOpenGLDebugMessage(); void swap(QOpenGLDebugMessage &other) noexcept { qSwap(d, other.d); } diff --git a/src/gui/opengl/qopenglpixeltransferoptions.h b/src/gui/opengl/qopenglpixeltransferoptions.h index be60e66e71..195543ae90 100644 --- a/src/gui/opengl/qopenglpixeltransferoptions.h +++ b/src/gui/opengl/qopenglpixeltransferoptions.h @@ -55,10 +55,8 @@ class Q_GUI_EXPORT QOpenGLPixelTransferOptions public: QOpenGLPixelTransferOptions(); QOpenGLPixelTransferOptions(const QOpenGLPixelTransferOptions &); -#ifdef Q_COMPILER_RVALUE_REFS QOpenGLPixelTransferOptions &operator=(QOpenGLPixelTransferOptions &&other) noexcept { swap(other); return *this; } -#endif QOpenGLPixelTransferOptions &operator=(const QOpenGLPixelTransferOptions &); ~QOpenGLPixelTransferOptions(); diff --git a/src/gui/painting/qbrush.h b/src/gui/painting/qbrush.h index 27d710eca6..ef8f7a18de 100644 --- a/src/gui/painting/qbrush.h +++ b/src/gui/painting/qbrush.h @@ -79,10 +79,8 @@ public: ~QBrush(); QBrush &operator=(const QBrush &brush); -#ifdef Q_COMPILER_RVALUE_REFS inline QBrush &operator=(QBrush &&other) noexcept { qSwap(d, other.d); return *this; } -#endif inline void swap(QBrush &other) noexcept { qSwap(d, other.d); } diff --git a/src/gui/painting/qcolor.h b/src/gui/painting/qcolor.h index 77b2d43c40..e3c267f97d 100644 --- a/src/gui/painting/qcolor.h +++ b/src/gui/painting/qcolor.h @@ -82,11 +82,9 @@ public: #if QT_VERSION < QT_VERSION_CHECK(6,0,0) inline QColor(const QColor &color) noexcept; // ### Qt 6: remove all of these, the trivial ones are fine. -# ifdef Q_COMPILER_RVALUE_REFS QColor(QColor &&other) noexcept : cspec(other.cspec), ct(other.ct) {} QColor &operator=(QColor &&other) noexcept { cspec = other.cspec; ct = other.ct; return *this; } -# endif QColor &operator=(const QColor &) noexcept; #endif // Qt < 6 diff --git a/src/gui/painting/qpagelayout.h b/src/gui/painting/qpagelayout.h index faf0827c1a..7ee0ce7a76 100644 --- a/src/gui/painting/qpagelayout.h +++ b/src/gui/painting/qpagelayout.h @@ -82,9 +82,7 @@ public: const QMarginsF &margins, Unit units = Point, const QMarginsF &minMargins = QMarginsF(0, 0, 0, 0)); QPageLayout(const QPageLayout &other); -#ifdef Q_COMPILER_RVALUE_REFS QPageLayout &operator=(QPageLayout &&other) noexcept { swap(other); return *this; } -#endif QPageLayout &operator=(const QPageLayout &other); ~QPageLayout(); diff --git a/src/gui/painting/qpagesize.h b/src/gui/painting/qpagesize.h index a2ea691677..133274760f 100644 --- a/src/gui/painting/qpagesize.h +++ b/src/gui/painting/qpagesize.h @@ -236,9 +236,7 @@ public: const QString &name = QString(), SizeMatchPolicy matchPolicy = FuzzyMatch); QPageSize(const QPageSize &other); -#ifdef Q_COMPILER_RVALUE_REFS QPageSize &operator=(QPageSize &&other) noexcept { swap(other); return *this; } -#endif QPageSize &operator=(const QPageSize &other); ~QPageSize(); diff --git a/src/gui/painting/qpainterpath.h b/src/gui/painting/qpainterpath.h index 2785669260..ed5be667b7 100644 --- a/src/gui/painting/qpainterpath.h +++ b/src/gui/painting/qpainterpath.h @@ -92,10 +92,8 @@ public: explicit QPainterPath(const QPointF &startPoint); QPainterPath(const QPainterPath &other); QPainterPath &operator=(const QPainterPath &other); -#ifdef Q_COMPILER_RVALUE_REFS inline QPainterPath &operator=(QPainterPath &&other) noexcept { qSwap(d_ptr, other.d_ptr); return *this; } -#endif ~QPainterPath(); inline void swap(QPainterPath &other) noexcept { d_ptr.swap(other.d_ptr); } diff --git a/src/gui/painting/qpen.h b/src/gui/painting/qpen.h index 884ec8cdfa..10b11d1d85 100644 --- a/src/gui/painting/qpen.h +++ b/src/gui/painting/qpen.h @@ -70,12 +70,10 @@ public: ~QPen(); QPen &operator=(const QPen &pen) noexcept; -#ifdef Q_COMPILER_RVALUE_REFS QPen(QPen &&other) noexcept : d(other.d) { other.d = nullptr; } QPen &operator=(QPen &&other) noexcept { qSwap(d, other.d); return *this; } -#endif void swap(QPen &other) noexcept { qSwap(d, other.d); } Qt::PenStyle style() const; diff --git a/src/gui/painting/qpolygon.h b/src/gui/painting/qpolygon.h index 118861c0f2..93fab55aa1 100644 --- a/src/gui/painting/qpolygon.h +++ b/src/gui/painting/qpolygon.h @@ -60,16 +60,12 @@ public: inline ~QPolygon() {} inline explicit QPolygon(int size); inline /*implicit*/ QPolygon(const QVector &v) : QVector(v) {} -#ifdef Q_COMPILER_RVALUE_REFS /*implicit*/ QPolygon(QVector &&v) noexcept : QVector(std::move(v)) {} -#endif QPolygon(const QRect &r, bool closed=false); QPolygon(int nPoints, const int *points); QPolygon(const QPolygon &other) : QVector(other) {} -#ifdef Q_COMPILER_RVALUE_REFS QPolygon(QPolygon &&other) noexcept : QVector(std::move(other)) {} QPolygon &operator=(QPolygon &&other) noexcept { swap(other); return *this; } -#endif QPolygon &operator=(const QPolygon &other) { QVector::operator=(other); return *this; } void swap(QPolygon &other) noexcept { QVector::swap(other); } // prevent QVector<->QPolygon swaps @@ -145,16 +141,12 @@ public: inline ~QPolygonF() {} inline explicit QPolygonF(int size); inline /*implicit*/ QPolygonF(const QVector &v) : QVector(v) {} -#ifdef Q_COMPILER_RVALUE_REFS /* implicit */ QPolygonF(QVector &&v) noexcept : QVector(std::move(v)) {} -#endif QPolygonF(const QRectF &r); /*implicit*/ QPolygonF(const QPolygon &a); inline QPolygonF(const QPolygonF &a) : QVector(a) {} -#ifdef Q_COMPILER_RVALUE_REFS QPolygonF(QPolygonF &&other) noexcept : QVector(std::move(other)) {} QPolygonF &operator=(QPolygonF &&other) noexcept { swap(other); return *this; } -#endif QPolygonF &operator=(const QPolygonF &other) { QVector::operator=(other); return *this; } inline void swap(QPolygonF &other) { QVector::swap(other); } // prevent QVector<->QPolygonF swaps diff --git a/src/gui/painting/qregion.h b/src/gui/painting/qregion.h index 9b6b25d743..54de916198 100644 --- a/src/gui/painting/qregion.h +++ b/src/gui/painting/qregion.h @@ -74,10 +74,8 @@ public: QRegion(const QBitmap &bitmap); ~QRegion(); QRegion &operator=(const QRegion &); -#ifdef Q_COMPILER_RVALUE_REFS inline QRegion &operator=(QRegion &&other) noexcept { qSwap(d, other.d); return *this; } -#endif inline void swap(QRegion &other) noexcept { qSwap(d, other.d); } bool isEmpty() const; bool isNull() const; diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h index 16685ed9e8..683aa3bf65 100644 --- a/src/gui/text/qfont.h +++ b/src/gui/text/qfont.h @@ -261,10 +261,8 @@ public: bool operator<(const QFont &) const; operator QVariant() const; bool isCopyOf(const QFont &) const; -#ifdef Q_COMPILER_RVALUE_REFS inline QFont &operator=(QFont &&other) noexcept { qSwap(d, other.d); qSwap(resolve_mask, other.resolve_mask); return *this; } -#endif #if QT_DEPRECATED_SINCE(5, 3) // needed for X11 diff --git a/src/gui/text/qfontmetrics.h b/src/gui/text/qfontmetrics.h index 761cadde47..a92ee9ed2f 100644 --- a/src/gui/text/qfontmetrics.h +++ b/src/gui/text/qfontmetrics.h @@ -76,10 +76,8 @@ public: ~QFontMetrics(); QFontMetrics &operator=(const QFontMetrics &); -#ifdef Q_COMPILER_RVALUE_REFS inline QFontMetrics &operator=(QFontMetrics &&other) noexcept { qSwap(d, other.d); return *this; } -#endif void swap(QFontMetrics &other) noexcept { qSwap(d, other.d); } @@ -172,10 +170,8 @@ public: QFontMetricsF &operator=(const QFontMetricsF &); QFontMetricsF &operator=(const QFontMetrics &); -#ifdef Q_COMPILER_RVALUE_REFS inline QFontMetricsF &operator=(QFontMetricsF &&other) { qSwap(d, other.d); return *this; } -#endif void swap(QFontMetricsF &other) { qSwap(d, other.d); } diff --git a/src/gui/text/qglyphrun.h b/src/gui/text/qglyphrun.h index 9bb1d3c820..15e315bea2 100644 --- a/src/gui/text/qglyphrun.h +++ b/src/gui/text/qglyphrun.h @@ -66,9 +66,7 @@ public: QGlyphRun(); QGlyphRun(const QGlyphRun &other); -#ifdef Q_COMPILER_RVALUE_REFS QGlyphRun &operator=(QGlyphRun &&other) noexcept { swap(other); return *this; } -#endif QGlyphRun &operator=(const QGlyphRun &other); ~QGlyphRun(); diff --git a/src/gui/text/qrawfont.h b/src/gui/text/qrawfont.h index 3b84f642d3..c6289d6c93 100644 --- a/src/gui/text/qrawfont.h +++ b/src/gui/text/qrawfont.h @@ -79,9 +79,7 @@ public: qreal pixelSize, QFont::HintingPreference hintingPreference = QFont::PreferDefaultHinting); QRawFont(const QRawFont &other); -#ifdef Q_COMPILER_RVALUE_REFS QRawFont &operator=(QRawFont &&other) noexcept { swap(other); return *this; } -#endif QRawFont &operator=(const QRawFont &other); ~QRawFont(); diff --git a/src/gui/text/qstatictext.h b/src/gui/text/qstatictext.h index c6a0d158c1..e8c94a6add 100644 --- a/src/gui/text/qstatictext.h +++ b/src/gui/text/qstatictext.h @@ -64,9 +64,7 @@ public: QStaticText(); explicit QStaticText(const QString &text); QStaticText(const QStaticText &other); -#ifdef Q_COMPILER_RVALUE_REFS QStaticText &operator=(QStaticText &&other) noexcept { swap(other); return *this; } -#endif QStaticText &operator=(const QStaticText &); ~QStaticText(); diff --git a/src/gui/text/qtextcursor.h b/src/gui/text/qtextcursor.h index 4a9c614887..7cad3cc5e8 100644 --- a/src/gui/text/qtextcursor.h +++ b/src/gui/text/qtextcursor.h @@ -73,9 +73,7 @@ public: explicit QTextCursor(QTextFrame *frame); explicit QTextCursor(const QTextBlock &block); QTextCursor(const QTextCursor &cursor); -#ifdef Q_COMPILER_RVALUE_REFS QTextCursor &operator=(QTextCursor &&other) noexcept { swap(other); return *this; } -#endif QTextCursor &operator=(const QTextCursor &other); ~QTextCursor(); diff --git a/src/network/access/qabstractnetworkcache.h b/src/network/access/qabstractnetworkcache.h index b604323c41..e357dfe58f 100644 --- a/src/network/access/qabstractnetworkcache.h +++ b/src/network/access/qabstractnetworkcache.h @@ -67,9 +67,7 @@ public: QNetworkCacheMetaData(const QNetworkCacheMetaData &other); ~QNetworkCacheMetaData(); -#ifdef Q_COMPILER_RVALUE_REFS QNetworkCacheMetaData &operator=(QNetworkCacheMetaData &&other) noexcept { swap(other); return *this; } -#endif QNetworkCacheMetaData &operator=(const QNetworkCacheMetaData &other); void swap(QNetworkCacheMetaData &other) noexcept diff --git a/src/network/access/qhttpmultipart.h b/src/network/access/qhttpmultipart.h index f718d51d0c..56db83779a 100644 --- a/src/network/access/qhttpmultipart.h +++ b/src/network/access/qhttpmultipart.h @@ -60,9 +60,7 @@ public: QHttpPart(); QHttpPart(const QHttpPart &other); ~QHttpPart(); -#ifdef Q_COMPILER_RVALUE_REFS QHttpPart &operator=(QHttpPart &&other) noexcept { swap(other); return *this; } -#endif QHttpPart &operator=(const QHttpPart &other); void swap(QHttpPart &other) noexcept { qSwap(d, other.d); } diff --git a/src/network/access/qnetworkcookie.h b/src/network/access/qnetworkcookie.h index 58c504f9ae..b712b63849 100644 --- a/src/network/access/qnetworkcookie.h +++ b/src/network/access/qnetworkcookie.h @@ -66,9 +66,7 @@ public: explicit QNetworkCookie(const QByteArray &name = QByteArray(), const QByteArray &value = QByteArray()); QNetworkCookie(const QNetworkCookie &other); ~QNetworkCookie(); -#ifdef Q_COMPILER_RVALUE_REFS QNetworkCookie &operator=(QNetworkCookie &&other) noexcept { swap(other); return *this; } -#endif QNetworkCookie &operator=(const QNetworkCookie &other); void swap(QNetworkCookie &other) noexcept { qSwap(d, other.d); } diff --git a/src/network/access/qnetworkrequest.h b/src/network/access/qnetworkrequest.h index 2515ff6ead..de27b9fede 100644 --- a/src/network/access/qnetworkrequest.h +++ b/src/network/access/qnetworkrequest.h @@ -130,9 +130,7 @@ public: explicit QNetworkRequest(const QUrl &url = QUrl()); QNetworkRequest(const QNetworkRequest &other); ~QNetworkRequest(); -#ifdef Q_COMPILER_RVALUE_REFS QNetworkRequest &operator=(QNetworkRequest &&other) noexcept { swap(other); return *this; } -#endif QNetworkRequest &operator=(const QNetworkRequest &other); void swap(QNetworkRequest &other) noexcept { qSwap(d, other.d); } diff --git a/src/network/bearer/qnetworkconfiguration.h b/src/network/bearer/qnetworkconfiguration.h index 41b6e6f020..048abc2fc8 100644 --- a/src/network/bearer/qnetworkconfiguration.h +++ b/src/network/bearer/qnetworkconfiguration.h @@ -55,9 +55,7 @@ class Q_NETWORK_EXPORT QNetworkConfiguration public: QNetworkConfiguration(); QNetworkConfiguration(const QNetworkConfiguration& other); -#ifdef Q_COMPILER_RVALUE_REFS QNetworkConfiguration &operator=(QNetworkConfiguration &&other) noexcept { swap(other); return *this; } -#endif QNetworkConfiguration &operator=(const QNetworkConfiguration &other); ~QNetworkConfiguration(); diff --git a/src/network/kernel/qdnslookup.h b/src/network/kernel/qdnslookup.h index 79a476b98f..110a74da44 100644 --- a/src/network/kernel/qdnslookup.h +++ b/src/network/kernel/qdnslookup.h @@ -64,9 +64,7 @@ class Q_NETWORK_EXPORT QDnsDomainNameRecord public: QDnsDomainNameRecord(); QDnsDomainNameRecord(const QDnsDomainNameRecord &other); -#ifdef Q_COMPILER_RVALUE_REFS QDnsDomainNameRecord &operator=(QDnsDomainNameRecord &&other) noexcept { swap(other); return *this; } -#endif QDnsDomainNameRecord &operator=(const QDnsDomainNameRecord &other); ~QDnsDomainNameRecord(); @@ -88,9 +86,7 @@ class Q_NETWORK_EXPORT QDnsHostAddressRecord public: QDnsHostAddressRecord(); QDnsHostAddressRecord(const QDnsHostAddressRecord &other); -#ifdef Q_COMPILER_RVALUE_REFS QDnsHostAddressRecord &operator=(QDnsHostAddressRecord &&other) noexcept { swap(other); return *this; } -#endif QDnsHostAddressRecord &operator=(const QDnsHostAddressRecord &other); ~QDnsHostAddressRecord(); @@ -112,9 +108,7 @@ class Q_NETWORK_EXPORT QDnsMailExchangeRecord public: QDnsMailExchangeRecord(); QDnsMailExchangeRecord(const QDnsMailExchangeRecord &other); -#ifdef Q_COMPILER_RVALUE_REFS QDnsMailExchangeRecord &operator=(QDnsMailExchangeRecord &&other) noexcept { swap(other); return *this; } -#endif QDnsMailExchangeRecord &operator=(const QDnsMailExchangeRecord &other); ~QDnsMailExchangeRecord(); @@ -137,9 +131,7 @@ class Q_NETWORK_EXPORT QDnsServiceRecord public: QDnsServiceRecord(); QDnsServiceRecord(const QDnsServiceRecord &other); -#ifdef Q_COMPILER_RVALUE_REFS QDnsServiceRecord &operator=(QDnsServiceRecord &&other) noexcept { swap(other); return *this; } -#endif QDnsServiceRecord &operator=(const QDnsServiceRecord &other); ~QDnsServiceRecord(); @@ -164,9 +156,7 @@ class Q_NETWORK_EXPORT QDnsTextRecord public: QDnsTextRecord(); QDnsTextRecord(const QDnsTextRecord &other); -#ifdef Q_COMPILER_RVALUE_REFS QDnsTextRecord &operator=(QDnsTextRecord &&other) noexcept { swap(other); return *this; } -#endif QDnsTextRecord &operator=(const QDnsTextRecord &other); ~QDnsTextRecord(); diff --git a/src/network/kernel/qhostaddress.h b/src/network/kernel/qhostaddress.h index f20da3304f..799247695e 100644 --- a/src/network/kernel/qhostaddress.h +++ b/src/network/kernel/qhostaddress.h @@ -102,11 +102,8 @@ public: QHostAddress(SpecialAddress address); ~QHostAddress(); -#ifdef Q_COMPILER_RVALUE_REFS QHostAddress &operator=(QHostAddress &&other) noexcept { swap(other); return *this; } -#endif - QHostAddress &operator=(const QHostAddress &other); #if QT_DEPRECATED_SINCE(5, 8) QT_DEPRECATED_X("use = QHostAddress(string) instead") diff --git a/src/network/kernel/qnetworkinterface.h b/src/network/kernel/qnetworkinterface.h index 1d3286118e..4caedaa38f 100644 --- a/src/network/kernel/qnetworkinterface.h +++ b/src/network/kernel/qnetworkinterface.h @@ -64,9 +64,7 @@ public: QNetworkAddressEntry(); QNetworkAddressEntry(const QNetworkAddressEntry &other); -#ifdef Q_COMPILER_RVALUE_REFS QNetworkAddressEntry &operator=(QNetworkAddressEntry &&other) noexcept { swap(other); return *this; } -#endif QNetworkAddressEntry &operator=(const QNetworkAddressEntry &other); ~QNetworkAddressEntry(); @@ -142,9 +140,7 @@ public: QNetworkInterface(); QNetworkInterface(const QNetworkInterface &other); -#ifdef Q_COMPILER_RVALUE_REFS QNetworkInterface &operator=(QNetworkInterface &&other) noexcept { swap(other); return *this; } -#endif QNetworkInterface &operator=(const QNetworkInterface &other); ~QNetworkInterface(); diff --git a/src/network/kernel/qnetworkproxy.h b/src/network/kernel/qnetworkproxy.h index 0b1bc02695..302a2ce6ca 100644 --- a/src/network/kernel/qnetworkproxy.h +++ b/src/network/kernel/qnetworkproxy.h @@ -89,9 +89,7 @@ public: QueryType queryType = TcpServer); #endif QNetworkProxyQuery(const QNetworkProxyQuery &other); -#ifdef Q_COMPILER_RVALUE_REFS QNetworkProxyQuery &operator=(QNetworkProxyQuery &&other) noexcept { swap(other); return *this; } -#endif QNetworkProxyQuery &operator=(const QNetworkProxyQuery &other); ~QNetworkProxyQuery(); @@ -161,9 +159,7 @@ public: QNetworkProxy(ProxyType type, const QString &hostName = QString(), quint16 port = 0, const QString &user = QString(), const QString &password = QString()); QNetworkProxy(const QNetworkProxy &other); -#ifdef Q_COMPILER_RVALUE_REFS QNetworkProxy &operator=(QNetworkProxy &&other) noexcept { swap(other); return *this; } -#endif QNetworkProxy &operator=(const QNetworkProxy &other); ~QNetworkProxy(); diff --git a/src/network/ssl/qsslcertificate.h b/src/network/ssl/qsslcertificate.h index a6acfa2cc3..69901b526c 100644 --- a/src/network/ssl/qsslcertificate.h +++ b/src/network/ssl/qsslcertificate.h @@ -88,9 +88,7 @@ public: explicit QSslCertificate(const QByteArray &data = QByteArray(), QSsl::EncodingFormat format = QSsl::Pem); QSslCertificate(const QSslCertificate &other); ~QSslCertificate(); -#ifdef Q_COMPILER_RVALUE_REFS QSslCertificate &operator=(QSslCertificate &&other) noexcept { swap(other); return *this; } -#endif QSslCertificate &operator=(const QSslCertificate &other); void swap(QSslCertificate &other) noexcept diff --git a/src/network/ssl/qsslcertificateextension.h b/src/network/ssl/qsslcertificateextension.h index f862015312..7cc8a888be 100644 --- a/src/network/ssl/qsslcertificateextension.h +++ b/src/network/ssl/qsslcertificateextension.h @@ -55,9 +55,7 @@ class Q_NETWORK_EXPORT QSslCertificateExtension public: QSslCertificateExtension(); QSslCertificateExtension(const QSslCertificateExtension &other); -#ifdef Q_COMPILER_RVALUE_REFS QSslCertificateExtension &operator=(QSslCertificateExtension &&other) noexcept { swap(other); return *this; } -#endif QSslCertificateExtension &operator=(const QSslCertificateExtension &other); ~QSslCertificateExtension(); diff --git a/src/network/ssl/qsslcipher.h b/src/network/ssl/qsslcipher.h index 430fe9aa7c..6994f590ae 100644 --- a/src/network/ssl/qsslcipher.h +++ b/src/network/ssl/qsslcipher.h @@ -59,9 +59,7 @@ public: explicit QSslCipher(const QString &name); QSslCipher(const QString &name, QSsl::SslProtocol protocol); QSslCipher(const QSslCipher &other); -#ifdef Q_COMPILER_RVALUE_REFS QSslCipher &operator=(QSslCipher &&other) noexcept { swap(other); return *this; } -#endif QSslCipher &operator=(const QSslCipher &other); ~QSslCipher(); diff --git a/src/network/ssl/qsslconfiguration.h b/src/network/ssl/qsslconfiguration.h index 16704ba17b..c25c2686de 100644 --- a/src/network/ssl/qsslconfiguration.h +++ b/src/network/ssl/qsslconfiguration.h @@ -85,9 +85,7 @@ public: QSslConfiguration(); QSslConfiguration(const QSslConfiguration &other); ~QSslConfiguration(); -#ifdef Q_COMPILER_RVALUE_REFS QSslConfiguration &operator=(QSslConfiguration &&other) noexcept { swap(other); return *this; } -#endif QSslConfiguration &operator=(const QSslConfiguration &other); void swap(QSslConfiguration &other) noexcept diff --git a/src/network/ssl/qsslerror.h b/src/network/ssl/qsslerror.h index a9c46c8571..c4a0d52193 100644 --- a/src/network/ssl/qsslerror.h +++ b/src/network/ssl/qsslerror.h @@ -107,9 +107,7 @@ public: { qSwap(d, other.d); } ~QSslError(); -#ifdef Q_COMPILER_RVALUE_REFS QSslError &operator=(QSslError &&other) noexcept { swap(other); return *this; } -#endif QSslError &operator=(const QSslError &other); bool operator==(const QSslError &other) const; inline bool operator!=(const QSslError &other) const diff --git a/src/network/ssl/qsslpresharedkeyauthenticator.h b/src/network/ssl/qsslpresharedkeyauthenticator.h index 29d647b121..5d714dc34e 100644 --- a/src/network/ssl/qsslpresharedkeyauthenticator.h +++ b/src/network/ssl/qsslpresharedkeyauthenticator.h @@ -59,9 +59,7 @@ public: Q_NETWORK_EXPORT QSslPreSharedKeyAuthenticator(const QSslPreSharedKeyAuthenticator &authenticator); Q_NETWORK_EXPORT QSslPreSharedKeyAuthenticator &operator=(const QSslPreSharedKeyAuthenticator &authenticator); -#ifdef Q_COMPILER_RVALUE_REFS QSslPreSharedKeyAuthenticator &operator=(QSslPreSharedKeyAuthenticator &&other) noexcept { swap(other); return *this; } -#endif void swap(QSslPreSharedKeyAuthenticator &other) noexcept { qSwap(d, other.d); } diff --git a/src/printsupport/kernel/qprintdevice_p.h b/src/printsupport/kernel/qprintdevice_p.h index a2b18f08cf..9e76c37617 100644 --- a/src/printsupport/kernel/qprintdevice_p.h +++ b/src/printsupport/kernel/qprintdevice_p.h @@ -76,9 +76,7 @@ public: ~QPrintDevice(); QPrintDevice &operator=(const QPrintDevice &other); - #ifdef Q_COMPILER_RVALUE_REFS QPrintDevice &operator=(QPrintDevice &&other) { swap(other); return *this; } -#endif void swap(QPrintDevice &other) { d.swap(other.d); } diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index 56da047147..5e5492de59 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -456,12 +456,8 @@ typedef int (Empty::*memFun) (); } while (false) \ /**/ -#ifdef Q_COMPILER_RVALUE_REFS #define TEST_AlignOf_RValueRef(type, alignment) \ TEST_AlignOf_impl(type, alignment) -#else -#define TEST_AlignOf_RValueRef(type, alignment) do {} while (false) -#endif #define TEST_AlignOf_impl(type, alignment) \ do { \ diff --git a/tests/auto/corelib/kernel/qsignalblocker/tst_qsignalblocker.cpp b/tests/auto/corelib/kernel/qsignalblocker/tst_qsignalblocker.cpp index fd18f00cd0..39b03ade61 100644 --- a/tests/auto/corelib/kernel/qsignalblocker/tst_qsignalblocker.cpp +++ b/tests/auto/corelib/kernel/qsignalblocker/tst_qsignalblocker.cpp @@ -66,7 +66,6 @@ void tst_QSignalBlocker::signalBlocking() void tst_QSignalBlocker::moveAssignment() { -#ifdef Q_COMPILER_RVALUE_REFS QObject o1, o2; // move-assignment: both block other objects @@ -157,10 +156,6 @@ void tst_QSignalBlocker::moveAssignment() QVERIFY(!o1.signalsBlocked()); QVERIFY(!o2.signalsBlocked()); - -#else - QSKIP("This compiler is not in C++11 mode or doesn't support move semantics"); -#endif // Q_COMPILER_RVALUE_REFS } QTEST_MAIN(tst_QSignalBlocker) diff --git a/tests/auto/corelib/mimetypes/qmimetype/tst_qmimetype.cpp b/tests/auto/corelib/mimetypes/qmimetype/tst_qmimetype.cpp index c74bce3b5b..e1357245f3 100644 --- a/tests/auto/corelib/mimetypes/qmimetype/tst_qmimetype.cpp +++ b/tests/auto/corelib/mimetypes/qmimetype/tst_qmimetype.cpp @@ -91,11 +91,7 @@ static QStringList qMimeTypeGlobPatterns() // ------------------------------------------------------------------------------------------------ -#ifndef Q_COMPILER_RVALUE_REFS -QMIMETYPE_BUILDER -#else QMIMETYPE_BUILDER_FROM_RVALUE_REFS -#endif // ------------------------------------------------------------------------------------------------ diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp index 2d1ae07b35..6ae2aab5b9 100644 --- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp +++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp @@ -79,9 +79,7 @@ private slots: void fromRawData(); void literals(); void variadicLiterals(); -#ifdef Q_COMPILER_RVALUE_REFS void rValueReferences(); -#endif void grow(); }; @@ -1678,7 +1676,6 @@ void tst_QArrayData::variadicLiterals() } } -#ifdef Q_COMPILER_RVALUE_REFS // std::remove_reference is in C++11, but requires library support template struct RemoveReference { typedef T Type; }; template struct RemoveReference { typedef T Type; }; @@ -1761,7 +1758,6 @@ void tst_QArrayData::rValueReferences() QCOMPARE(v3.size(), size_t(1)); QCOMPARE(v3.front(), 42); } -#endif void tst_QArrayData::grow() { diff --git a/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp b/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp index 72f88a235d..2ae9c6e159 100644 --- a/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp +++ b/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp @@ -47,7 +47,6 @@ private Q_SLOTS: void state(); }; -#ifdef Q_COMPILER_RVALUE_REFS static bool dpointer_is_null(QCollator &c) { char mem[sizeof c]; @@ -58,11 +57,9 @@ static bool dpointer_is_null(QCollator &c) return false; return true; } -#endif void tst_QCollator::moveSemantics() { -#ifdef Q_COMPILER_RVALUE_REFS const QLocale de_AT(QLocale::German, QLocale::Austria); QCollator c1(de_AT); @@ -78,9 +75,6 @@ void tst_QCollator::moveSemantics() c1 = std::move(c2); QCOMPARE(c1.locale(), de_AT); QVERIFY(dpointer_is_null(c2)); -#else - QSKIP("The compiler is not in C++11 mode or does not support move semantics."); -#endif } diff --git a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp index c21d0afacb..3af6132695 100644 --- a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp +++ b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp @@ -30,9 +30,7 @@ #include -#ifdef Q_COMPILER_RVALUE_REFS // cpp11() slot -# include // for std::move() -#endif +#include // for std::move() class tst_QEasingCurve : public QObject { @@ -794,7 +792,6 @@ void tst_QEasingCurve::testCbrtFloat() void tst_QEasingCurve::cpp11() { -#ifdef Q_COMPILER_RVALUE_REFS { QEasingCurve ec( QEasingCurve::InOutBack ); QEasingCurve copy = std::move(ec); // move ctor @@ -809,7 +806,6 @@ void tst_QEasingCurve::cpp11() QCOMPARE( copy.type(), QEasingCurve::InOutBack ); QCOMPARE( ec.type(), type ); } -#endif } void tst_QEasingCurve::quadraticEquation() { diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index 3e87a506bf..42792b5310 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -225,13 +225,11 @@ struct NoDefaultConstructorConstRef2 NoDefaultConstructorConstRef2(const QByteArray &ba, int i = 42) : str(QString::fromLatin1(ba)), i(i) {} }; -#ifdef Q_COMPILER_RVALUE_REFS struct NoDefaultConstructorRRef1 { int &i; NoDefaultConstructorRRef1(int &&i) : i(i) {} }; -#endif void tst_QSharedPointer::basics_data() { @@ -500,7 +498,6 @@ void tst_QSharedPointer::swap() void tst_QSharedPointer::moveSemantics() { -#ifdef Q_COMPILER_RVALUE_REFS QSharedPointer p1, p2(new int(42)), control = p2; QVERIFY(p1 != control); QVERIFY(p1.isNull()); @@ -553,9 +550,6 @@ void tst_QSharedPointer::moveSemantics() QVERIFY(w1.isNull()); QVERIFY(w2.isNull()); QVERIFY(w3.isNull()); -#else - QSKIP("This test requires C++11 rvalue/move semantics support in the compiler."); -#endif } void tst_QSharedPointer::useOfForwardDeclared() diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp index 2278e0ba13..f7e7c3e3ae 100644 --- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp +++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp @@ -709,7 +709,6 @@ void tst_QVector::appendCustom() const void tst_QVector::appendRvalue() const { -#ifdef Q_COMPILER_RVALUE_REFS QVector v; v.append("hello"); QString world = "world"; @@ -717,9 +716,6 @@ void tst_QVector::appendRvalue() const QVERIFY(world.isEmpty()); QCOMPARE(v.front(), QString("hello")); QCOMPARE(v.back(), QString("world")); -#else - QSKIP("This test requires that C++11 move semantics support is enabled in the compiler"); -#endif } void tst_QVector::at() const diff --git a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp index aaf40a9c2e..9bc8c84ee4 100644 --- a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp +++ b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp @@ -586,7 +586,6 @@ void tst_QVersionNumber::serialize() void tst_QVersionNumber::moveSemantics() { -#ifdef Q_COMPILER_RVALUE_REFS // QVersionNumber(QVersionNumber &&) { QVersionNumber v1(1, 2, 3); @@ -609,7 +608,6 @@ void tst_QVersionNumber::moveSemantics() QVERIFY(!v2.isNull()); QCOMPARE(v1, v2); } -#endif #ifdef Q_COMPILER_REF_QUALIFIERS // normalized() { @@ -636,9 +634,6 @@ void tst_QVersionNumber::moveSemantics() QVERIFY(!segments.empty()); } #endif -#if !defined(Q_COMPILER_RVALUE_REFS) && !defined(Q_COMPILER_REF_QUALIFIERS) - QSKIP("This test requires C++11 move semantics support in the compiler."); -#endif } void tst_QVersionNumber::qtVersion() diff --git a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp index 234793a7cf..6ce6422f48 100644 --- a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp +++ b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp @@ -141,7 +141,6 @@ void tst_QPalette::copySemantics() void tst_QPalette::moveSemantics() { -#ifdef Q_COMPILER_RVALUE_REFS QPalette src(Qt::red), dst; const QPalette control = src; QVERIFY(src != dst); @@ -163,9 +162,6 @@ void tst_QPalette::moveSemantics() QVERIFY(dst2.isCopyOf(dst)); QVERIFY(dst2.isCopyOf(control)); // check moved-from 'src' can still be destroyed (doesn't crash) -#else - QSKIP("Compiler doesn't support C++11 move semantics"); -#endif } void tst_QPalette::setBrush() From deae75ae093d11714dd2f05a40dcfcdb6bb8e10e Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 18 Dec 2017 11:28:33 +0100 Subject: [PATCH 225/292] TextEdit example: add Markdown as a supported format Also use QT_CONFIG to disable features gracefully if Qt is configured without them. Change-Id: I38e92bf5fd70f77fc4d5158769d590619be8905f Reviewed-by: Gatis Paeglis --- examples/widgets/richtext/textedit/example.md | 96 +++++++++++++++++++ .../widgets/richtext/textedit/textedit.cpp | 33 ++++++- 2 files changed, 125 insertions(+), 4 deletions(-) create mode 100644 examples/widgets/richtext/textedit/example.md diff --git a/examples/widgets/richtext/textedit/example.md b/examples/widgets/richtext/textedit/example.md new file mode 100644 index 0000000000..70aeaf7649 --- /dev/null +++ b/examples/widgets/richtext/textedit/example.md @@ -0,0 +1,96 @@ +# QTextEdit + +The QTextEdit widget is an advanced editor that supports formatted rich text. +It can be used to display HTML and other rich document formats. Internally, +QTextEdit uses the QTextDocument class to describe both the high-level +structure of each document and the low-level formatting of paragraphs. + +If you are viewing this document in the textedit example, you can edit this +document to explore Qt's rich text editing features. We have included some +comments in each of the following sections to encourage you to experiment. + +## Font and Paragraph Styles + +QTextEdit supports **bold**, *italic*, & ~~strikethrough~~ font styles, and +can display multicolored text. Font families such as Times New Roman and `Courier` +can also be used directly. *If you place the cursor in a region of styled text, +the controls in the tool bars will change to reflect the current style.* + +Paragraphs can be formatted so that the text is left-aligned, right-aligned, +centered, or fully justified. + +*Try changing the alignment of some text and resize the editor to see how the +text layout changes.* + +## Lists + +Different kinds of lists can be included in rich text documents. Standard +bullet lists can be nested, using different symbols for each level of the list: + +- Disc symbols are typically used for top-level list items. + * Circle symbols can be used to distinguish between items in lower-level + lists. + + Square symbols provide a reasonable alternative to discs and circles. + +Ordered lists can be created that can be used for tables of contents. Different +characters can be used to enumerate items, and we can use both Roman and Arabic +numerals in the same list structure: + +1. Introduction +2. Qt Tools + 1) Qt Assistant + 2) Qt Designer + 1. Form Editor + 2. Component Architecture + 3) Qt Linguist + +The list will automatically be renumbered if you add or remove items. *Try +adding new sections to the above list or removing existing item to see the +numbers change.* + +## Images + +Inline images are treated like ordinary ranges of characters in the text +editor, so they flow with the surrounding text. Images can also be selected in +the same way as text, making it easy to cut, copy, and paste them. + +![logo](images/logo32.png "logo") *Try to select this image by clicking and +dragging over it with the mouse, or use the text cursor to select it by holding +down Shift and using the arrow keys. You can then cut or copy it, and paste it +into different parts of this document.* + +## Tables + +QTextEdit can arrange and format tables, supporting features such as row and +column spans, text formatting within cells, and size constraints for columns. + +| | Development Tools | Programming Techniques | Graphical User Interfaces | +| ------------: | ----------------- | ---------------------- | ------------------------- | +| 9:00 - 11:00 | Introduction to Qt ||| +| 11:00 - 13:00 | Using qmake | Object-oriented Programming | Layouts in Qt | +| 13:00 - 15:00 | Qt Designer Tutorial | Extreme Programming | Writing Custom Styles | +| 15:00 - 17:00 | Qt Linguist and Internationalization |   |   | + +*Try adding text to the cells in the table and experiment with the alignment of +the paragraphs.* + +## Hyperlinks + +QTextEdit is designed to support hyperlinks between documents, and this feature +is used extensively in +[Qt Assistant](http://doc.qt.io/qt-5/qtassistant-index.html). Hyperlinks are +automatically created when an HTML file is imported into an editor. Since the +rich text framework supports hyperlinks natively, they can also be created +programatically. + +## Undo and Redo + +Full support for undo and redo operations is built into QTextEdit and the +underlying rich text framework. Operations on a document can be packaged +together to make editing a more comfortable experience for the user. + +*Try making changes to this document and press `Ctrl+Z` to undo them. You can +always recover the original contents of the document.* + diff --git a/examples/widgets/richtext/textedit/textedit.cpp b/examples/widgets/richtext/textedit/textedit.cpp index 3ad9f48b67..7b8c242cfc 100644 --- a/examples/widgets/richtext/textedit/textedit.cpp +++ b/examples/widgets/richtext/textedit/textedit.cpp @@ -71,6 +71,7 @@ #include #include #include +#include #if defined(QT_PRINTSUPPORT_LIB) #include #if QT_CONFIG(printer) @@ -395,11 +396,18 @@ bool TextEdit::load(const QString &f) QByteArray data = file.readAll(); QTextCodec *codec = Qt::codecForHtml(data); QString str = codec->toUnicode(data); + QUrl baseUrl = (f.front() == QLatin1Char(':') ? QUrl(f) : QUrl::fromLocalFile(f)).adjusted(QUrl::RemoveFilename); + textEdit->document()->setBaseUrl(baseUrl); if (Qt::mightBeRichText(str)) { textEdit->setHtml(str); } else { - str = QString::fromLocal8Bit(data); - textEdit->setPlainText(str); +#if QT_CONFIG(textmarkdownreader) + QMimeDatabase db; + if (db.mimeTypeForFileNameAndData(f, data).name() == QLatin1String("text/markdown")) + textEdit->setMarkdown(str); + else +#endif + textEdit->setPlainText(QString::fromLocal8Bit(data)); } setCurrentFileName(f); @@ -451,7 +459,15 @@ void TextEdit::fileOpen() QFileDialog fileDialog(this, tr("Open File...")); fileDialog.setAcceptMode(QFileDialog::AcceptOpen); fileDialog.setFileMode(QFileDialog::ExistingFile); - fileDialog.setMimeTypeFilters(QStringList() << "text/html" << "text/plain"); + fileDialog.setMimeTypeFilters(QStringList() +#if QT_CONFIG(texthtmlparser) + << "text/html" +#endif +#if QT_CONFIG(textmarkdownreader) + + << "text/markdown" +#endif + << "text/plain"); if (fileDialog.exec() != QDialog::Accepted) return; const QString fn = fileDialog.selectedFiles().first(); @@ -485,9 +501,18 @@ bool TextEdit::fileSaveAs() QFileDialog fileDialog(this, tr("Save as...")); fileDialog.setAcceptMode(QFileDialog::AcceptSave); QStringList mimeTypes; - mimeTypes << "application/vnd.oasis.opendocument.text" << "text/html" << "text/plain"; + mimeTypes << "text/plain" +#if QT_CONFIG(textodfwriter) + << "application/vnd.oasis.opendocument.text" +#endif +#if QT_CONFIG(textmarkdownwriter) + << "text/markdown" +#endif + << "text/html"; fileDialog.setMimeTypeFilters(mimeTypes); +#if QT_CONFIG(textodfwriter) fileDialog.setDefaultSuffix("odt"); +#endif if (fileDialog.exec() != QDialog::Accepted) return false; const QString fn = fileDialog.selectedFiles().first(); From 75256d62d2462103180b368aa79b933acf71f444 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 6 Feb 2019 17:10:42 +0100 Subject: [PATCH 226/292] Render markdown task lists (checkboxes instead of bullets) in QTextEdit Checkboxes are right-aligned with any bullets that are in the same QTextList so that there is enough space to make them larger than bullets. But hopefully mixing bullets and checkboxes will be a rarely-used feature. Change-Id: I28e274d1f7883aa093df29eb4988e99641e87a71 Reviewed-by: Gatis Paeglis --- examples/widgets/richtext/textedit/example.md | 6 ++++ src/gui/text/qtextdocumentlayout.cpp | 32 +++++++++++++++---- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/examples/widgets/richtext/textedit/example.md b/examples/widgets/richtext/textedit/example.md index 70aeaf7649..a16a9197b4 100644 --- a/examples/widgets/richtext/textedit/example.md +++ b/examples/widgets/richtext/textedit/example.md @@ -50,6 +50,12 @@ The list will automatically be renumbered if you add or remove items. *Try adding new sections to the above list or removing existing item to see the numbers change.* +Task lists can be used to track progress on projects: + +- [ ] This is not yet done +- This is just a bullet point +- [x] This is done + ## Images Inline images are treated like ordinary ranges of characters in the text diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index bed0a2c450..7873faf2cb 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -1436,6 +1436,21 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p QBrush brush = context.palette.brush(QPalette::Text); + bool marker = bl.blockFormat().marker() != QTextBlockFormat::NoMarker; + if (marker) { + int adj = fontMetrics.lineSpacing() / 6; + r.adjust(-adj, 0, -adj, 0); + if (bl.blockFormat().marker() == QTextBlockFormat::Checked) { + // ### Qt6: render with QStyle / PE_IndicatorCheckBox. We don't currently + // have access to that here, because it would be a widget dependency. + painter->setPen(QPen(painter->pen().color(), 2)); + painter->drawLine(r.topLeft(), r.bottomRight()); + painter->drawLine(r.topRight(), r.bottomLeft()); + painter->setPen(QPen(painter->pen().color(), 0)); + } + painter->drawRect(r.adjusted(-adj, -adj, adj, adj)); + } + switch (style) { case QTextListFormat::ListDecimal: case QTextListFormat::ListLowerAlpha: @@ -1456,16 +1471,21 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p break; } case QTextListFormat::ListSquare: - painter->fillRect(r, brush); + if (!marker) + painter->fillRect(r, brush); break; case QTextListFormat::ListCircle: - painter->setPen(QPen(brush, 0)); - painter->drawEllipse(r.translated(0.5, 0.5)); // pixel align for sharper rendering + if (!marker) { + painter->setPen(QPen(brush, 0)); + painter->drawEllipse(r.translated(0.5, 0.5)); // pixel align for sharper rendering + } break; case QTextListFormat::ListDisc: - painter->setBrush(brush); - painter->setPen(Qt::NoPen); - painter->drawEllipse(r); + if (!marker) { + painter->setBrush(brush); + painter->setPen(Qt::NoPen); + painter->drawEllipse(r); + } break; case QTextListFormat::ListStyleUndefined: break; From 0df30ff22e50aa301791fc72f106ab15ce385a6a Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 18 Feb 2019 15:40:04 +0100 Subject: [PATCH 227/292] Add task list checkbox manipulation features to the TextEdit example Change-Id: I5f0b8cb94d1af609ec531f9765d58be65b1129a3 Reviewed-by: Gatis Paeglis --- .../textedit/images/mac/checkbox-checked.png | Bin 0 -> 1167 bytes .../richtext/textedit/images/mac/checkbox.png | Bin 0 -> 779 bytes .../textedit/images/win/checkbox-checked.png | Bin 0 -> 1167 bytes .../richtext/textedit/images/win/checkbox.png | Bin 0 -> 779 bytes .../widgets/richtext/textedit/textedit.cpp | 70 +++++++++++++++--- examples/widgets/richtext/textedit/textedit.h | 2 + .../widgets/richtext/textedit/textedit.qrc | 4 + 7 files changed, 64 insertions(+), 12 deletions(-) create mode 100644 examples/widgets/richtext/textedit/images/mac/checkbox-checked.png create mode 100644 examples/widgets/richtext/textedit/images/mac/checkbox.png create mode 100644 examples/widgets/richtext/textedit/images/win/checkbox-checked.png create mode 100644 examples/widgets/richtext/textedit/images/win/checkbox.png diff --git a/examples/widgets/richtext/textedit/images/mac/checkbox-checked.png b/examples/widgets/richtext/textedit/images/mac/checkbox-checked.png new file mode 100644 index 0000000000000000000000000000000000000000..a072d7fb5cf6f50faee3024265d421423eebd2fd GIT binary patch literal 1167 zcmZvbe=ys37{|X^qB2^SolQ;MX1(ol({W{5HtJX7N2tssL)BCfq)3oNqC`TpMV+&C zSgSibv!nESw41hwpV1%$(I6@s5+Z0435obI`=XR0ZR5q&5S+;P(B@;LBvNglAfis)1uag79NX zKr{tQN~X}RW#a)Fjpj@srjZk`W#XMl*(tRuFFUa4Q&SO+KuN~~K}1pp-T|ANkw8i( zBs!oINkj)+Dn0{W(ePyp06_Y~FW~~fmjBhrn=O!YCS*O6a@pq2;X8pup)>xsK0UAa z2u4I+0TUPucI3gPn)|=m*xG(zZM~&8fcA9g)n6miPlrW+k4%I1Y;^X#myf4kKx#Jq z#rRy8P~zzycmajx2qn+^c^u&aCMvdXTIzK%*e5V_U}nh=jqwk`fXTi3#`ZDspjaLr z6OW5aq86}U&dCSF@=?*;utdR|S9DJ;G=1}oHQR~AoTN-TfmQ&LZs9^wCXJB8NTajTa|^}G8wnZI)EowpQGA_N z077DZaW<4w$zt5hVwF(Xcc{hX3+r0dwvkd)26~=Ul}gPAr}1T* zV{+}-vTjkWU*6owV%{bfmQadHUrb0kg>N{brJm`fzS)(5*GlfZa!C4iSh_K?q#luN z@?{#nTstaLkIJ>*D&go4bdnx3{lfSR|pkp|Pi@x3{lZMMyu0pZEbCvq&LZ6FzlFQG#Yo0w70i^aPW^w+;7i!g72yfjq<~J z@TpVFSNr1;<{B(Ao`>T4_7MXH`?)Gr;9##xrN@;Y&ZJnir_|1OUg%LvQaUpL#C_L& z-Jg%9#P!iq$E@+2acfRB5V$y($J>m=Q!!nqt9N{#Sng2@e)_%X>|w7>*SUVcdo7>5 zaU)kyQQhpe7j2p1v0BSu^IiKYq>Ovbc2Uw(o~Pf+Z`r$0J~zO7REFL- zrVN^QW0?=#M4l|f!M`!1w>8wPxFO7{LRmqY-1nH(fzS!T-BgjYo)7V1uSEe9&e_Jt zl@~jXx03B=C-R_715zA)3)Y%ApN}-eZ5=`kI&@A5bkRuggIxFdW#~gz60;rwaF{W4 z)>kLZ%)Q$@6Ml{*4o=m@mb2}hS}()WWe990Qb`-9H-)=PKXY3mBe2htE1CK^We8Q{ z((WfT*Qf6PQRQRRVx=BDW9|FV()Ur=yJN{MZ83Z&o6t7#gSwz*Bkbxf6!>))N%B!s nnfC5{Ui7nqhmY>CbF7tzW`fdv2D{GV-7iN6U{H_!j-)B8 z0003gP)t-s00000000000LtI=0002J(Br?+26BG3I_w@Gnv&hu6%GR^V)wRmjwaV7F%-Cphc)8Eoywcsh(%rbi$Gy_t zPFGyP*5Jd};=|YCnWCq*&Dq7-s_+~=yj$ivv<)#&o5yvIaMQs?jUvd7Z8&e`bj^|Hs(zS7>=K_;G)SbAgC-f{D4%-MiA? zzt-Z&;O)ua?8@Tr%H#3N`R%w=`r@z0zz`?@A$;-{o&d<@*)z;S6*x1_I-QC{f z=jiF_>gww2>+tgP^Yrxe_4W4o`uh6&{Qdp@{{H^{2kVo$0002aNklG&tA*5LgfR=B*eUQbm&`F*xHh()`#G?bZ%2;GXi%w0Pgn^UVt+$d{W;Mp2ZL zcswS{awHTAN|GdHU-?-y1IE-yblzdn2>=GqX=9+T|8(g!1Ah+JTb+9Ru~z^9002ov JPDHLkV1k{Ct#JSV literal 0 HcmV?d00001 diff --git a/examples/widgets/richtext/textedit/images/win/checkbox-checked.png b/examples/widgets/richtext/textedit/images/win/checkbox-checked.png new file mode 100644 index 0000000000000000000000000000000000000000..a072d7fb5cf6f50faee3024265d421423eebd2fd GIT binary patch literal 1167 zcmZvbe=ys37{|X^qB2^SolQ;MX1(ol({W{5HtJX7N2tssL)BCfq)3oNqC`TpMV+&C zSgSibv!nESw41hwpV1%$(I6@s5+Z0435obI`=XR0ZR5q&5S+;P(B@;LBvNglAfis)1uag79NX zKr{tQN~X}RW#a)Fjpj@srjZk`W#XMl*(tRuFFUa4Q&SO+KuN~~K}1pp-T|ANkw8i( zBs!oINkj)+Dn0{W(ePyp06_Y~FW~~fmjBhrn=O!YCS*O6a@pq2;X8pup)>xsK0UAa z2u4I+0TUPucI3gPn)|=m*xG(zZM~&8fcA9g)n6miPlrW+k4%I1Y;^X#myf4kKx#Jq z#rRy8P~zzycmajx2qn+^c^u&aCMvdXTIzK%*e5V_U}nh=jqwk`fXTi3#`ZDspjaLr z6OW5aq86}U&dCSF@=?*;utdR|S9DJ;G=1}oHQR~AoTN-TfmQ&LZs9^wCXJB8NTajTa|^}G8wnZI)EowpQGA_N z077DZaW<4w$zt5hVwF(Xcc{hX3+r0dwvkd)26~=Ul}gPAr}1T* zV{+}-vTjkWU*6owV%{bfmQadHUrb0kg>N{brJm`fzS)(5*GlfZa!C4iSh_K?q#luN z@?{#nTstaLkIJ>*D&go4bdnx3{lfSR|pkp|Pi@x3{lZMMyu0pZEbCvq&LZ6FzlFQG#Yo0w70i^aPW^w+;7i!g72yfjq<~J z@TpVFSNr1;<{B(Ao`>T4_7MXH`?)Gr;9##xrN@;Y&ZJnir_|1OUg%LvQaUpL#C_L& z-Jg%9#P!iq$E@+2acfRB5V$y($J>m=Q!!nqt9N{#Sng2@e)_%X>|w7>*SUVcdo7>5 zaU)kyQQhpe7j2p1v0BSu^IiKYq>Ovbc2Uw(o~Pf+Z`r$0J~zO7REFL- zrVN^QW0?=#M4l|f!M`!1w>8wPxFO7{LRmqY-1nH(fzS!T-BgjYo)7V1uSEe9&e_Jt zl@~jXx03B=C-R_715zA)3)Y%ApN}-eZ5=`kI&@A5bkRuggIxFdW#~gz60;rwaF{W4 z)>kLZ%)Q$@6Ml{*4o=m@mb2}hS}()WWe990Qb`-9H-)=PKXY3mBe2htE1CK^We8Q{ z((WfT*Qf6PQRQRRVx=BDW9|FV()Ur=yJN{MZ83Z&o6t7#gSwz*Bkbxf6!>))N%B!s nnfC5{Ui7nqhmY>CbF7tzW`fdv2D{GV-7iN6U{H_!j-)B8 z0003gP)t-s00000000000LtI=0002J(Br?+26BG3I_w@Gnv&hu6%GR^V)wRmjwaV7F%-Cphc)8Eoywcsh(%rbi$Gy_t zPFGyP*5Jd};=|YCnWCq*&Dq7-s_+~=yj$ivv<)#&o5yvIaMQs?jUvd7Z8&e`bj^|Hs(zS7>=K_;G)SbAgC-f{D4%-MiA? zzt-Z&;O)ua?8@Tr%H#3N`R%w=`r@z0zz`?@A$;-{o&d<@*)z;S6*x1_I-QC{f z=jiF_>gww2>+tgP^Yrxe_4W4o`uh6&{Qdp@{{H^{2kVo$0002aNklG&tA*5LgfR=B*eUQbm&`F*xHh()`#G?bZ%2;GXi%w0Pgn^UVt+$d{W;Mp2ZL zcswS{awHTAN|GdHU-?-y1IE-yblzdn2>=GqX=9+T|8(g!1Ah+JTb+9Ru~z^9002ov JPDHLkV1k{Ct#JSV literal 0 HcmV?d00001 diff --git a/examples/widgets/richtext/textedit/textedit.cpp b/examples/widgets/richtext/textedit/textedit.cpp index 7b8c242cfc..683e441fce 100644 --- a/examples/widgets/richtext/textedit/textedit.cpp +++ b/examples/widgets/richtext/textedit/textedit.cpp @@ -343,6 +343,15 @@ void TextEdit::setupTextActions() actionTextColor = menu->addAction(pix, tr("&Color..."), this, &TextEdit::textColor); tb->addAction(actionTextColor); + menu->addSeparator(); + + const QIcon checkboxIcon = QIcon::fromTheme("status-checkbox-checked", QIcon(rsrcPath + "/checkbox-checked.png")); + actionToggleCheckState = menu->addAction(checkboxIcon, tr("Chec&ked"), this, &TextEdit::setChecked); + actionToggleCheckState->setShortcut(Qt::CTRL + Qt::Key_K); + actionToggleCheckState->setCheckable(true); + actionToggleCheckState->setPriority(QAction::LowPriority); + tb->addAction(actionToggleCheckState); + tb = addToolBar(tr("Format Actions")); tb->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea); addToolBarBreak(Qt::TopToolBarArea); @@ -354,6 +363,8 @@ void TextEdit::setupTextActions() comboStyle->addItem("Bullet List (Disc)"); comboStyle->addItem("Bullet List (Circle)"); comboStyle->addItem("Bullet List (Square)"); + comboStyle->addItem("Task List (Unchecked)"); + comboStyle->addItem("Task List (Checked)"); comboStyle->addItem("Ordered List (Decimal)"); comboStyle->addItem("Ordered List (Alpha lower)"); comboStyle->addItem("Ordered List (Alpha upper)"); @@ -617,6 +628,7 @@ void TextEdit::textStyle(int styleIndex) { QTextCursor cursor = textEdit->textCursor(); QTextListFormat::Style style = QTextListFormat::ListStyleUndefined; + QTextBlockFormat::MarkerType marker = QTextBlockFormat::NoMarker; switch (styleIndex) { case 1: @@ -629,18 +641,32 @@ void TextEdit::textStyle(int styleIndex) style = QTextListFormat::ListSquare; break; case 4: - style = QTextListFormat::ListDecimal; + if (cursor.currentList()) + style = cursor.currentList()->format().style(); + else + style = QTextListFormat::ListDisc; + marker = QTextBlockFormat::Unchecked; break; case 5: - style = QTextListFormat::ListLowerAlpha; + if (cursor.currentList()) + style = cursor.currentList()->format().style(); + else + style = QTextListFormat::ListDisc; + marker = QTextBlockFormat::Checked; break; case 6: - style = QTextListFormat::ListUpperAlpha; + style = QTextListFormat::ListDecimal; break; case 7: - style = QTextListFormat::ListLowerRoman; + style = QTextListFormat::ListLowerAlpha; break; case 8: + style = QTextListFormat::ListUpperAlpha; + break; + case 9: + style = QTextListFormat::ListLowerRoman; + break; + case 10: style = QTextListFormat::ListUpperRoman; break; default: @@ -665,6 +691,8 @@ void TextEdit::textStyle(int styleIndex) cursor.mergeCharFormat(fmt); textEdit->mergeCurrentCharFormat(fmt); } else { + blockFmt.setMarker(marker); + cursor.setBlockFormat(blockFmt); QTextListFormat listFmt; if (cursor.currentList()) { listFmt = cursor.currentList()->format(); @@ -703,6 +731,11 @@ void TextEdit::textAlign(QAction *a) textEdit->setAlignment(Qt::AlignJustify); } +void TextEdit::setChecked(bool checked) +{ + textStyle(checked ? 5 : 4); +} + void TextEdit::currentCharFormatChanged(const QTextCharFormat &format) { fontChanged(format.font()); @@ -725,24 +758,37 @@ void TextEdit::cursorPositionChanged() comboStyle->setCurrentIndex(3); break; case QTextListFormat::ListDecimal: - comboStyle->setCurrentIndex(4); - break; - case QTextListFormat::ListLowerAlpha: - comboStyle->setCurrentIndex(5); - break; - case QTextListFormat::ListUpperAlpha: comboStyle->setCurrentIndex(6); break; - case QTextListFormat::ListLowerRoman: + case QTextListFormat::ListLowerAlpha: comboStyle->setCurrentIndex(7); break; - case QTextListFormat::ListUpperRoman: + case QTextListFormat::ListUpperAlpha: comboStyle->setCurrentIndex(8); break; + case QTextListFormat::ListLowerRoman: + comboStyle->setCurrentIndex(9); + break; + case QTextListFormat::ListUpperRoman: + comboStyle->setCurrentIndex(10); + break; default: comboStyle->setCurrentIndex(-1); break; } + switch (textEdit->textCursor().block().blockFormat().marker()) { + case QTextBlockFormat::NoMarker: + actionToggleCheckState->setChecked(false); + break; + case QTextBlockFormat::Unchecked: + comboStyle->setCurrentIndex(4); + actionToggleCheckState->setChecked(false); + break; + case QTextBlockFormat::Checked: + comboStyle->setCurrentIndex(5); + actionToggleCheckState->setChecked(true); + break; + } } else { int headingLevel = textEdit->textCursor().blockFormat().headingLevel(); comboStyle->setCurrentIndex(headingLevel ? headingLevel + 8 : 0); diff --git a/examples/widgets/richtext/textedit/textedit.h b/examples/widgets/richtext/textedit/textedit.h index ae0b13a4cc..c253548a4f 100644 --- a/examples/widgets/richtext/textedit/textedit.h +++ b/examples/widgets/richtext/textedit/textedit.h @@ -96,6 +96,7 @@ private slots: void textStyle(int styleIndex); void textColor(); void textAlign(QAction *a); + void setChecked(bool checked); void currentCharFormatChanged(const QTextCharFormat &format); void cursorPositionChanged(); @@ -125,6 +126,7 @@ private: QAction *actionAlignCenter; QAction *actionAlignRight; QAction *actionAlignJustify; + QAction *actionToggleCheckState; QAction *actionUndo; QAction *actionRedo; #ifndef QT_NO_CLIPBOARD diff --git a/examples/widgets/richtext/textedit/textedit.qrc b/examples/widgets/richtext/textedit/textedit.qrc index 7d6efd7d67..8016a07ca0 100644 --- a/examples/widgets/richtext/textedit/textedit.qrc +++ b/examples/widgets/richtext/textedit/textedit.qrc @@ -1,6 +1,8 @@ images/logo32.png + images/mac/checkbox.png + images/mac/checkbox-checked.png images/mac/editcopy.png images/mac/editcut.png images/mac/editpaste.png @@ -20,6 +22,8 @@ images/mac/textunder.png images/mac/zoomin.png images/mac/zoomout.png + images/win/checkbox.png + images/win/checkbox-checked.png images/win/editcopy.png images/win/editcut.png images/win/editpaste.png From 355ecfb11c838b4c9facc9a631e04a52531a2127 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 18 Dec 2018 00:56:37 +0100 Subject: [PATCH 228/292] Add QTextMarkdownWriter::writeTable(QAbstractTableModel) This provides the ability to write live data from a table to Markdown, which can be useful to load it into a text document or a wiki. But so far QTextMarkdownWriter is still a private class, intended to be used experimentally from QtQuick and perhaps later exposed in other ways. Change-Id: I0de4673987e4172178604e49b5a024a05d4486ba Reviewed-by: Richard Moe Gustavsen --- src/gui/text/qtextmarkdownwriter.cpp | 31 ++++++++++++++++ src/gui/text/qtextmarkdownwriter_p.h | 2 ++ .../itemviews/qtableview/tst_qtableview.cpp | 35 +++++++++++++++++++ 3 files changed, 68 insertions(+) diff --git a/src/gui/text/qtextmarkdownwriter.cpp b/src/gui/text/qtextmarkdownwriter.cpp index c91248757a..fed4a7b766 100644 --- a/src/gui/text/qtextmarkdownwriter.cpp +++ b/src/gui/text/qtextmarkdownwriter.cpp @@ -64,6 +64,37 @@ bool QTextMarkdownWriter::writeAll(const QTextDocument &document) return true; } +void QTextMarkdownWriter::writeTable(const QAbstractTableModel &table) +{ + QVector tableColumnWidths(table.columnCount()); + for (int col = 0; col < table.columnCount(); ++col) { + tableColumnWidths[col] = table.headerData(col, Qt::Horizontal).toString().length(); + for (int row = 0; row < table.rowCount(); ++row) { + tableColumnWidths[col] = qMax(tableColumnWidths[col], + table.data(table.index(row, col)).toString().length()); + } + } + + // write the header and separator + for (int col = 0; col < table.columnCount(); ++col) { + QString s = table.headerData(col, Qt::Horizontal).toString(); + m_stream << "|" << s << QString(tableColumnWidths[col] - s.length(), Space); + } + m_stream << "|" << endl; + for (int col = 0; col < tableColumnWidths.length(); ++col) + m_stream << '|' << QString(tableColumnWidths[col], QLatin1Char('-')); + m_stream << '|'<< endl; + + // write the body + for (int row = 0; row < table.rowCount(); ++row) { + for (int col = 0; col < table.columnCount(); ++col) { + QString s = table.data(table.index(row, col)).toString(); + m_stream << "|" << s << QString(tableColumnWidths[col] - s.length(), Space); + } + m_stream << '|'<< endl; + } +} + void QTextMarkdownWriter::writeFrame(const QTextFrame *frame) { Q_ASSERT(frame); diff --git a/src/gui/text/qtextmarkdownwriter_p.h b/src/gui/text/qtextmarkdownwriter_p.h index 9845355259..2a9388ca2d 100644 --- a/src/gui/text/qtextmarkdownwriter_p.h +++ b/src/gui/text/qtextmarkdownwriter_p.h @@ -56,6 +56,7 @@ #include "qtextdocument_p.h" #include "qtextdocumentwriter.h" +#include "QAbstractTableModel" QT_BEGIN_NAMESPACE @@ -64,6 +65,7 @@ class Q_GUI_EXPORT QTextMarkdownWriter public: QTextMarkdownWriter(QTextStream &stream, QTextDocument::MarkdownFeatures features); bool writeAll(const QTextDocument &document); + void writeTable(const QAbstractTableModel &table); int writeBlock(const QTextBlock &block, bool table, bool ignoreFormat); void writeFrame(const QTextFrame *frame); diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp index b1ddc6e7a2..e7822ef7de 100644 --- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp +++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp @@ -32,6 +32,9 @@ #include #include #include "private/qapplication_p.h" +#if QT_CONFIG(textmarkdownwriter) +#include "private/qtextmarkdownwriter_p.h" +#endif #include @@ -196,6 +199,10 @@ private slots: void viewOptions(); void taskQTBUG_7232_AllowUserToControlSingleStep(); + +#if QT_CONFIG(textmarkdownwriter) + void markdownWriter(); +#endif }; // Testing get/set functions @@ -4560,5 +4567,33 @@ void tst_QTableView::taskQTBUG_50171_selectRowAfterSwapColumns() } } +// This has nothing to do with QTableView, but it's convenient to reuse the QtTestTableModel +#if QT_CONFIG(textmarkdownwriter) + +// #define DEBUG_WRITE_OUTPUT + +void tst_QTableView::markdownWriter() +{ + QtTestTableModel model(2, 3); + QString md; + { + QTextStream stream(&md); + QTextMarkdownWriter writer(stream, QTextDocument::MarkdownDialectGitHub); + writer.writeTable(model); + } + +#ifdef DEBUG_WRITE_OUTPUT + { + QFile out("/tmp/table.md"); + out.open(QFile::WriteOnly); + out.write(md.toUtf8()); + out.close(); + } +#endif + + QCOMPARE(md, QString::fromLatin1("|1 |2 |3 |\n|-------|-------|-------|\n|[0,0,0]|[0,1,0]|[0,2,0]|\n|[1,0,0]|[1,1,0]|[1,2,0]|\n")); +} +#endif + QTEST_MAIN(tst_QTableView) #include "tst_qtableview.moc" From 402cb62d5db7516e4d8d77d972e55e90cb855679 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Fri, 15 Mar 2019 12:05:38 +0100 Subject: [PATCH 229/292] Introduce QNetworkConnection/Status/Monitor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Private classes to replace broken or even not working at all 'session management' and 'bearer manager' (on at least two major platforms we support). This implementation is macOS/iOS-specific and uses SystemConfiguration framework, or more precisely SCNetworkReachability's part of it. Task-number: QTBUG-40332 Change-Id: Iac5f44c4063c4092b93b8cf2bde3fb2c524855b3 Reviewed-by: Mårten Nordheim --- src/network/access/qhttpnetworkconnection.cpp | 38 +- src/network/access/qhttpnetworkconnection_p.h | 13 + .../access/qhttpnetworkconnectionchannel.cpp | 12 + src/network/access/qnetworkaccessmanager.cpp | 153 ++++-- src/network/access/qnetworkaccessmanager.h | 2 +- src/network/access/qnetworkaccessmanager_p.h | 8 +- src/network/access/qnetworkreplyhttpimpl.cpp | 15 +- src/network/access/qnetworkreplyimpl.cpp | 2 - src/network/access/qnetworkreplyimpl_p.h | 2 - src/network/kernel/kernel.pri | 12 +- src/network/kernel/qnetconmonitor_darwin.mm | 434 ++++++++++++++++++ src/network/kernel/qnetconmonitor_p.h | 126 +++++ src/network/kernel/qnetconmonitor_stub.cpp | 141 ++++++ 13 files changed, 903 insertions(+), 55 deletions(-) create mode 100644 src/network/kernel/qnetconmonitor_darwin.mm create mode 100644 src/network/kernel/qnetconmonitor_p.h create mode 100644 src/network/kernel/qnetconmonitor_stub.cpp diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 0a37122fc6..cb4c722eb5 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -1320,6 +1320,10 @@ QHttpNetworkConnection::QHttpNetworkConnection(const QString &hostName, quint16 Q_D(QHttpNetworkConnection); d->networkSession = std::move(networkSession); d->init(); + if (QNetworkStatusMonitor::isEnabled()) { + connect(&d->connectionMonitor, &QNetworkConnectionMonitor::reachabilityChanged, + this, &QHttpNetworkConnection::onlineStateChanged, Qt::QueuedConnection); + } } QHttpNetworkConnection::QHttpNetworkConnection(quint16 connectionCount, const QString &hostName, @@ -1332,6 +1336,10 @@ QHttpNetworkConnection::QHttpNetworkConnection(quint16 connectionCount, const QS Q_D(QHttpNetworkConnection); d->networkSession = std::move(networkSession); d->init(); + if (QNetworkStatusMonitor::isEnabled()) { + connect(&d->connectionMonitor, &QNetworkConnectionMonitor::reachabilityChanged, + this, &QHttpNetworkConnection::onlineStateChanged, Qt::QueuedConnection); + } } #else QHttpNetworkConnection::QHttpNetworkConnection(const QString &hostName, quint16 port, bool encrypt, @@ -1340,6 +1348,10 @@ QHttpNetworkConnection::QHttpNetworkConnection(const QString &hostName, quint16 { Q_D(QHttpNetworkConnection); d->init(); + if (QNetworkStatusMonitor::isEnabled()) { + connect(&d->connectionMonitor, &QNetworkConnectionMonitor::reachabilityChanged, + this, &QHttpNetworkConnection::onlineStateChanged, Qt::QueuedConnection); + } } QHttpNetworkConnection::QHttpNetworkConnection(quint16 connectionCount, const QString &hostName, @@ -1350,8 +1362,12 @@ QHttpNetworkConnection::QHttpNetworkConnection(quint16 connectionCount, const QS { Q_D(QHttpNetworkConnection); d->init(); + if (QNetworkStatusMonitor::isEnabled()) { + connect(&d->connectionMonitor, &QNetworkConnectionMonitor::reachabilityChanged, + this, &QHttpNetworkConnection::onlineStateChanged, Qt::QueuedConnection); + } } -#endif +#endif // QT_NO_BEARERMANAGEMENT QHttpNetworkConnection::~QHttpNetworkConnection() { @@ -1531,6 +1547,26 @@ void QHttpNetworkConnection::setPeerVerifyName(const QString &peerName) d->peerVerifyName = peerName; } +void QHttpNetworkConnection::onlineStateChanged(bool isOnline) +{ + Q_D(QHttpNetworkConnection); + + if (isOnline) { + // If we did not have any 'isOffline' previously - well, good + // to know, we are 'online' apparently. + return; + } + + for (int i = 0; i < d->activeChannelCount; i++) { + auto &channel = d->channels[i]; + channel.emitFinishedWithError(QNetworkReply::TemporaryNetworkFailureError, "Temporary network failure."); + channel.close(); + } + + // We don't care, this connection is broken from our POV. + d->connectionMonitor.stopMonitoring(); +} + #ifndef QT_NO_NETWORKPROXY // only called from QHttpNetworkConnectionChannel::_q_proxyAuthenticationRequired, not // from QHttpNetworkConnectionChannel::handleAuthenticationChallenge diff --git a/src/network/access/qhttpnetworkconnection_p.h b/src/network/access/qhttpnetworkconnection_p.h index 2f3c334248..85d89f20c2 100644 --- a/src/network/access/qhttpnetworkconnection_p.h +++ b/src/network/access/qhttpnetworkconnection_p.h @@ -67,6 +67,7 @@ #include #include #include +#include #include #include @@ -156,6 +157,10 @@ public: QString peerVerifyName() const; void setPeerVerifyName(const QString &peerName); + +public slots: + void onlineStateChanged(bool isOnline); + private: Q_DECLARE_PRIVATE(QHttpNetworkConnection) Q_DISABLE_COPY_MOVE(QHttpNetworkConnection) @@ -292,6 +297,14 @@ public: Http2::ProtocolParameters http2Parameters; QString peerVerifyName; + // If network status monitoring is enabled, we activate connectionMonitor + // as soons as one of channels managed to connect to host (and we + // have a pair of addresses (us,peer). + // NETMONTODO: consider activating a monitor on a change from + // HostLookUp state to ConnectingState (means we have both + // local/remote addresses known and can start monitoring this + // early). + QNetworkConnectionMonitor connectionMonitor; friend class QHttpNetworkConnectionChannel; }; diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index f79a4d1dc6..9309d718e4 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -59,6 +59,8 @@ #include "private/qnetworksession_p.h" #endif +#include "private/qnetconmonitor_p.h" + QT_BEGIN_NAMESPACE namespace @@ -896,6 +898,16 @@ void QHttpNetworkConnectionChannel::_q_connected() pipeliningSupported = QHttpNetworkConnectionChannel::PipeliningSupportUnknown; + if (QNetworkStatusMonitor::isEnabled()) { + auto connectionPrivate = connection->d_func(); + if (!connectionPrivate->connectionMonitor.isMonitoring()) { + // Now that we have a pair of addresses, we can start monitoring the + // connection status to handle its loss properly. + if (connectionPrivate->connectionMonitor.setTargets(socket->localAddress(), socket->peerAddress())) + connectionPrivate->connectionMonitor.startMonitoring(); + } + } + // ### FIXME: if the server closes the connection unexpectedly, we shouldn't send the same broken request again! //channels[i].reconnectAttempts = 2; if (ssl || pendingEncrypt) { // FIXME: Didn't work properly with pendingEncrypt only, we should refactor this into an EncrypingState diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index 50b9488594..8bd630ad9d 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -90,6 +90,8 @@ #include "qnetworkreplywasmimpl_p.h" #endif +#include "qnetconmonitor_p.h" + QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC(QNetworkAccessFileBackendFactory, fileBackend) @@ -486,18 +488,25 @@ QNetworkAccessManager::QNetworkAccessManager(QObject *parent) qRegisterMetaType(); qRegisterMetaType >(); -#ifndef QT_NO_BEARERMANAGEMENT Q_D(QNetworkAccessManager); - // if a session is required, we track online state through - // the QNetworkSession's signals if a request is already made. - // we need to track current accessibility state by default - // - connect(&d->networkConfigurationManager, SIGNAL(onlineStateChanged(bool)), - SLOT(_q_onlineStateChanged(bool))); - connect(&d->networkConfigurationManager, SIGNAL(configurationChanged(QNetworkConfiguration)), - SLOT(_q_configurationChanged(QNetworkConfiguration))); - -#endif + if (QNetworkStatusMonitor::isEnabled()) { + connect(&d->statusMonitor, SIGNAL(onlineStateChanged(bool)), + SLOT(_q_onlineStateChanged(bool))); +#ifdef QT_NO_BEARERMANAGEMENT + d->networkAccessible = d->statusMonitor.isNetworkAccesible(); +#else + d->networkAccessible = d->statusMonitor.isNetworkAccesible() ? Accessible : NotAccessible; + } else { + // if a session is required, we track online state through + // the QNetworkSession's signals if a request is already made. + // we need to track current accessibility state by default + // + connect(&d->networkConfigurationManager, SIGNAL(onlineStateChanged(bool)), + SLOT(_q_onlineStateChanged(bool))); + connect(&d->networkConfigurationManager, SIGNAL(configurationChanged(QNetworkConfiguration)), + SLOT(_q_configurationChanged(QNetworkConfiguration))); +#endif // QT_NO_BEARERMANAGEMENT + } } /*! @@ -1030,9 +1039,13 @@ QNetworkReply *QNetworkAccessManager::deleteResource(const QNetworkRequest &requ void QNetworkAccessManager::setConfiguration(const QNetworkConfiguration &config) { Q_D(QNetworkAccessManager); - d->networkConfiguration = config; - d->customNetworkConfiguration = true; - d->createSession(config); + if (!d->statusMonitor.isEnabled()) { + d->networkConfiguration = config; + d->customNetworkConfiguration = true; + d->createSession(config); + } else { + qWarning(lcNetMon, "No network configuration can be set with network status monitor enabled"); + } } /*! @@ -1048,7 +1061,7 @@ QNetworkConfiguration QNetworkAccessManager::configuration() const Q_D(const QNetworkAccessManager); QSharedPointer session(d->getNetworkSession()); - if (session) { + if (session && !d->statusMonitor.isEnabled()) { return session->configuration(); } else { return d->networkConfigurationManager.defaultConfiguration(); @@ -1075,7 +1088,7 @@ QNetworkConfiguration QNetworkAccessManager::activeConfiguration() const Q_D(const QNetworkAccessManager); QSharedPointer networkSession(d->getNetworkSession()); - if (networkSession) { + if (networkSession && !d->statusMonitor.isEnabled()) { return d->networkConfigurationManager.configurationFromIdentifier( networkSession->sessionProperty(QLatin1String("ActiveConfiguration")).toString()); } else { @@ -1094,6 +1107,11 @@ void QNetworkAccessManager::setNetworkAccessible(QNetworkAccessManager::NetworkA { Q_D(QNetworkAccessManager); + if (d->statusMonitor.isEnabled()) { + qWarning(lcNetMon, "Can not manually set network accessibility with the network status monitor enabled"); + return; + } + d->defaultAccessControl = accessible == NotAccessible ? false : true; if (d->networkAccessible != accessible) { @@ -1114,6 +1132,12 @@ QNetworkAccessManager::NetworkAccessibility QNetworkAccessManager::networkAccess { Q_D(const QNetworkAccessManager); + if (d->statusMonitor.isEnabled()) { + if (!d->statusMonitor.isMonitoring()) + d->statusMonitor.start(); + return d->networkAccessible; + } + if (d->customNetworkConfiguration && d->networkConfiguration.state().testFlag(QNetworkConfiguration::Undefined)) return UnknownAccessibility; @@ -1434,35 +1458,57 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera } } + if (d->statusMonitor.isEnabled()) { + // See the code in ctor - QNetworkStatusMonitor allows us to + // immediately set 'networkAccessible' even before we start + // the monitor. +#ifdef QT_NO_BEARERMANAGEMENT + if (d->networkAccessible +#else + if (d->networkAccessible == NotAccessible +#endif // QT_NO_BEARERMANAGEMENT + && !isLocalFile) { + QHostAddress dest; + QString host = req.url().host().toLower(); + if (!(dest.setAddress(host) && dest.isLoopback()) + && host != QLatin1String("localhost") + && host != QHostInfo::localHostName().toLower()) { + return new QDisabledNetworkReply(this, req, op); + } + } + + if (!d->statusMonitor.isMonitoring() && !d->statusMonitor.start()) + qWarning(lcNetMon, "failed to start network status monitoring"); + } else { #ifndef QT_NO_BEARERMANAGEMENT - - // Return a disabled network reply if network access is disabled. - // Except if the scheme is empty or file:// or if the host resolves to a loopback address. - if (d->networkAccessible == NotAccessible && !isLocalFile) { - QHostAddress dest; - QString host = req.url().host().toLower(); - if (!(dest.setAddress(host) && dest.isLoopback()) && host != QLatin1String("localhost") + // Return a disabled network reply if network access is disabled. + // Except if the scheme is empty or file:// or if the host resolves to a loopback address. + if (d->networkAccessible == NotAccessible && !isLocalFile) { + QHostAddress dest; + QString host = req.url().host().toLower(); + if (!(dest.setAddress(host) && dest.isLoopback()) && host != QLatin1String("localhost") && host != QHostInfo::localHostName().toLower()) { - return new QDisabledNetworkReply(this, req, op); + return new QDisabledNetworkReply(this, req, op); + } } - } - if (!d->networkSessionStrongRef && (d->initializeSession || !d->networkConfiguration.identifier().isEmpty())) { - if (!d->networkConfiguration.identifier().isEmpty()) { - if ((d->networkConfiguration.state() & QNetworkConfiguration::Defined) - && d->networkConfiguration != d->networkConfigurationManager.defaultConfiguration()) - d->createSession(d->networkConfigurationManager.defaultConfiguration()); - else - d->createSession(d->networkConfiguration); + if (!d->networkSessionStrongRef && (d->initializeSession || !d->networkConfiguration.identifier().isEmpty())) { + if (!d->networkConfiguration.identifier().isEmpty()) { + if ((d->networkConfiguration.state() & QNetworkConfiguration::Defined) + && d->networkConfiguration != d->networkConfigurationManager.defaultConfiguration()) + d->createSession(d->networkConfigurationManager.defaultConfiguration()); + else + d->createSession(d->networkConfiguration); - } else { - if (d->networkSessionRequired) - d->createSession(d->networkConfigurationManager.defaultConfiguration()); - else - d->initializeSession = false; + } else { + if (d->networkSessionRequired) + d->createSession(d->networkConfigurationManager.defaultConfiguration()); + else + d->initializeSession = false; + } } - } #endif + } QNetworkRequest request = req; if (!request.header(QNetworkRequest::ContentLengthHeader).isValid() && @@ -1509,8 +1555,10 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera #endif QNetworkReplyHttpImpl *reply = new QNetworkReplyHttpImpl(this, request, op, outgoingData); #ifndef QT_NO_BEARERMANAGEMENT - connect(this, SIGNAL(networkSessionConnected()), - reply, SLOT(_q_networkSessionConnected())); + if (!d->statusMonitor.isEnabled()) { + connect(this, SIGNAL(networkSessionConnected()), + reply, SLOT(_q_networkSessionConnected())); + } #endif return reply; } @@ -1519,7 +1567,9 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera // first step: create the reply QNetworkReplyImpl *reply = new QNetworkReplyImpl(this); #ifndef QT_NO_BEARERMANAGEMENT - if (!isLocalFile) { + // NETMONTODO: network reply impl must be augmented to use the same monitoring + // capabilities as http network reply impl does. + if (!isLocalFile && !d->statusMonitor.isEnabled()) { connect(this, SIGNAL(networkSessionConnected()), reply, SLOT(_q_networkSessionConnected())); } @@ -1988,7 +2038,13 @@ void QNetworkAccessManagerPrivate::_q_networkSessionStateChanged(QNetworkSession void QNetworkAccessManagerPrivate::_q_onlineStateChanged(bool isOnline) { - Q_Q(QNetworkAccessManager); + Q_Q(QNetworkAccessManager); + + if (statusMonitor.isEnabled()) { + networkAccessible = isOnline ? QNetworkAccessManager::Accessible : QNetworkAccessManager::NotAccessible; + return; + } + // if the user set a config, we only care whether this one is active. // Otherwise, this QNAM is online if there is an online config. @@ -2018,6 +2074,9 @@ void QNetworkAccessManagerPrivate::_q_onlineStateChanged(bool isOnline) void QNetworkAccessManagerPrivate::_q_configurationChanged(const QNetworkConfiguration &configuration) { + if (statusMonitor.isEnabled()) + return; + const QString id = configuration.identifier(); if (configuration.state().testFlag(QNetworkConfiguration::Active)) { if (!onlineConfigurations.contains(id)) { @@ -2050,6 +2109,9 @@ void QNetworkAccessManagerPrivate::_q_configurationChanged(const QNetworkConfigu void QNetworkAccessManagerPrivate::_q_networkSessionFailed(QNetworkSession::SessionError) { + if (statusMonitor.isEnabled()) + return; + const auto cfgs = networkConfigurationManager.allConfigurations(); for (const QNetworkConfiguration &cfg : cfgs) { if (cfg.state().testFlag(QNetworkConfiguration::Active)) { @@ -2061,6 +2123,13 @@ void QNetworkAccessManagerPrivate::_q_networkSessionFailed(QNetworkSession::Sess } } +#else + +void QNetworkAccessManagerPrivate::_q_onlineStateChanged(bool isOnline) +{ + networkAccessible = isOnline; +} + #endif // QT_NO_BEARERMANAGEMENT #if QT_CONFIG(http) diff --git a/src/network/access/qnetworkaccessmanager.h b/src/network/access/qnetworkaccessmanager.h index 7e2f7683d0..fa23537c68 100644 --- a/src/network/access/qnetworkaccessmanager.h +++ b/src/network/access/qnetworkaccessmanager.h @@ -209,10 +209,10 @@ private: #ifndef QT_NO_BEARERMANAGEMENT Q_PRIVATE_SLOT(d_func(), void _q_networkSessionClosed()) Q_PRIVATE_SLOT(d_func(), void _q_networkSessionStateChanged(QNetworkSession::State)) - Q_PRIVATE_SLOT(d_func(), void _q_onlineStateChanged(bool)) Q_PRIVATE_SLOT(d_func(), void _q_configurationChanged(const QNetworkConfiguration &)) Q_PRIVATE_SLOT(d_func(), void _q_networkSessionFailed(QNetworkSession::SessionError)) #endif + Q_PRIVATE_SLOT(d_func(), void _q_onlineStateChanged(bool)) }; QT_END_NAMESPACE diff --git a/src/network/access/qnetworkaccessmanager_p.h b/src/network/access/qnetworkaccessmanager_p.h index 5cab4928e4..d3a3936533 100644 --- a/src/network/access/qnetworkaccessmanager_p.h +++ b/src/network/access/qnetworkaccessmanager_p.h @@ -55,6 +55,7 @@ #include "qnetworkaccessmanager.h" #include "qnetworkaccesscache_p.h" #include "qnetworkaccessbackend_p.h" +#include "qnetconmonitor_p.h" #include "qnetworkrequest.h" #include "qhsts_p.h" #include "private/qobject_p.h" @@ -151,6 +152,7 @@ public: QNetworkAccessBackend *findBackend(QNetworkAccessManager::Operation op, const QNetworkRequest &request); QStringList backendSupportedSchemes() const; + void _q_onlineStateChanged(bool isOnline); #ifndef QT_NO_BEARERMANAGEMENT void createSession(const QNetworkConfiguration &config); QSharedPointer getNetworkSession() const; @@ -160,12 +162,11 @@ public: void _q_networkSessionPreferredConfigurationChanged(const QNetworkConfiguration &config, bool isSeamless); void _q_networkSessionStateChanged(QNetworkSession::State state); - void _q_onlineStateChanged(bool isOnline); + void _q_configurationChanged(const QNetworkConfiguration &configuration); void _q_networkSessionFailed(QNetworkSession::SessionError error); QSet onlineConfigurations; - #endif #if QT_CONFIG(http) @@ -199,6 +200,8 @@ public: int activeReplyCount; bool online; bool initializeSession; +#else + bool networkAccessible = true; #endif bool cookieJarCreated; @@ -222,6 +225,7 @@ public: QScopedPointer stsStore; #endif // QT_CONFIG(settings) bool stsEnabled = false; + mutable QNetworkStatusMonitor statusMonitor; #ifndef QT_NO_BEARERMANAGEMENT Q_AUTOTEST_EXPORT static const QWeakPointer getNetworkSession(const QNetworkAccessManager *manager); diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp index f801ef0c88..b9651b35d2 100644 --- a/src/network/access/qnetworkreplyhttpimpl.cpp +++ b/src/network/access/qnetworkreplyhttpimpl.cpp @@ -59,6 +59,7 @@ #include #include "qnetworkcookiejar.h" +#include "qnetconmonitor_p.h" #include // for strchr @@ -166,6 +167,11 @@ static QHash parseHttpOptionHeader(const QByteArray &hea #if QT_CONFIG(bearermanagement) static bool isSessionNeeded(const QUrl &url) { + if (QNetworkStatusMonitor::isEnabled()) { + // In case QNetworkStatus/QNetConManager are in business, + // no session, no bearer manager are involved. + return false; + } // Connections to the local machine does not require a session QString host = url.host().toLower(); return !QHostAddress(host).isLoopback() && host != QLatin1String("localhost") @@ -796,7 +802,8 @@ void QNetworkReplyHttpImplPrivate::postRequest(const QNetworkRequest &newHttpReq if (blob.isValid() && blob.canConvert()) delegate->http2Parameters = blob.value(); #ifndef QT_NO_BEARERMANAGEMENT - delegate->networkSession = managerPrivate->getNetworkSession(); + if (!QNetworkStatusMonitor::isEnabled()) + delegate->networkSession = managerPrivate->getNetworkSession(); #endif // For the synchronous HTTP, this is the normal way the delegate gets deleted @@ -1807,7 +1814,7 @@ bool QNetworkReplyHttpImplPrivate::start(const QNetworkRequest &newHttpRequest) { #ifndef QT_NO_BEARERMANAGEMENT QSharedPointer networkSession(managerPrivate->getNetworkSession()); - if (!networkSession) { + if (!networkSession || QNetworkStatusMonitor::isEnabled()) { #endif postRequest(newHttpRequest); return true; @@ -1895,7 +1902,7 @@ void QNetworkReplyHttpImplPrivate::_q_startOperation() // state changes. if (!startWaitForSession(session)) return; - } else if (session) { + } else if (session && !QNetworkStatusMonitor::isEnabled()) { QObject::connect(session.data(), SIGNAL(stateChanged(QNetworkSession::State)), q, SLOT(_q_networkSessionStateChanged(QNetworkSession::State)), Qt::QueuedConnection); @@ -2184,7 +2191,7 @@ void QNetworkReplyHttpImplPrivate::finished() #ifndef QT_NO_BEARERMANAGEMENT Q_ASSERT(managerPrivate); QSharedPointer session = managerPrivate->getNetworkSession(); - if (session && session->state() == QNetworkSession::Roaming && + if (!QNetworkStatusMonitor::isEnabled() && session && session->state() == QNetworkSession::Roaming && state == Working && errorCode != QNetworkReply::OperationCanceledError) { // only content with a known size will fail with a temporary network failure error if (!totalSize.isNull()) { diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index f5bb4d5887..1a02938de9 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -1117,7 +1117,6 @@ bool QNetworkReplyImplPrivate::migrateBackend() return true; } -#ifndef QT_NO_BEARERMANAGEMENT QDisabledNetworkReply::QDisabledNetworkReply(QObject *parent, const QNetworkRequest &req, QNetworkAccessManager::Operation op) @@ -1142,7 +1141,6 @@ QDisabledNetworkReply::QDisabledNetworkReply(QObject *parent, QDisabledNetworkReply::~QDisabledNetworkReply() { } -#endif QT_END_NAMESPACE diff --git a/src/network/access/qnetworkreplyimpl_p.h b/src/network/access/qnetworkreplyimpl_p.h index 4881e84e9c..85f5b862a8 100644 --- a/src/network/access/qnetworkreplyimpl_p.h +++ b/src/network/access/qnetworkreplyimpl_p.h @@ -209,7 +209,6 @@ public: }; Q_DECLARE_TYPEINFO(QNetworkReplyImplPrivate::InternalNotifications, Q_PRIMITIVE_TYPE); -#ifndef QT_NO_BEARERMANAGEMENT class QDisabledNetworkReply : public QNetworkReply { Q_OBJECT @@ -223,7 +222,6 @@ public: protected: qint64 readData(char *, qint64) override { return -1; } }; -#endif QT_END_NAMESPACE diff --git a/src/network/kernel/kernel.pri b/src/network/kernel/kernel.pri index b86119b200..0e4cef5e74 100644 --- a/src/network/kernel/kernel.pri +++ b/src/network/kernel/kernel.pri @@ -16,7 +16,8 @@ HEADERS += kernel/qtnetworkglobal.h \ kernel/qnetworkinterface.h \ kernel/qnetworkinterface_p.h \ kernel/qnetworkinterface_unix_p.h \ - kernel/qnetworkproxy.h + kernel/qnetworkproxy.h \ + kernel/qnetconmonitor_p.h SOURCES += kernel/qauthenticator.cpp \ kernel/qhostaddress.cpp \ @@ -71,6 +72,15 @@ mac { !uikit: LIBS_PRIVATE += -framework CoreServices -framework SystemConfiguration } +macos | ios { + OBJECTIVE_SOURCES += \ + kernel/qnetconmonitor_darwin.mm + + LIBS_PRIVATE += -framework SystemConfiguration +} else { + SOURCES += kernel/qnetconmonitor_stub.cpp +} + qtConfig(gssapi): LIBS_PRIVATE += -lgssapi_krb5 uikit:HEADERS += kernel/qnetworkinterface_uikit_p.h diff --git a/src/network/kernel/qnetconmonitor_darwin.mm b/src/network/kernel/qnetconmonitor_darwin.mm new file mode 100644 index 0000000000..322c87cb4b --- /dev/null +++ b/src/network/kernel/qnetconmonitor_darwin.mm @@ -0,0 +1,434 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtNetwork module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "private/qnativesocketengine_p.h" +#include "private/qnetconmonitor_p.h" + +#include "private/qobject_p.h" + +#include +#include + +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +Q_LOGGING_CATEGORY(lcNetMon, "qt.network.monitor"); + +namespace { + +class ReachabilityDispatchQueue +{ +public: + ReachabilityDispatchQueue() + { + queue = dispatch_queue_create("qt-network-reachability-queue", nullptr); + if (!queue) + qCWarning(lcNetMon, "Failed to create a dispatch queue for reachability probes"); + } + + ~ReachabilityDispatchQueue() + { + if (queue) + dispatch_release(queue); + } + + dispatch_queue_t data() const + { + return queue; + } + +private: + dispatch_queue_t queue = nullptr; + + Q_DISABLE_COPY_MOVE(ReachabilityDispatchQueue) +}; + +dispatch_queue_t qt_reachability_queue() +{ + static const ReachabilityDispatchQueue reachabilityQueue; + return reachabilityQueue.data(); +} + +qt_sockaddr qt_hostaddress_to_sockaddr(const QHostAddress &src) +{ + if (src.isNull()) + return {}; + + qt_sockaddr dst; + if (src.protocol() == QAbstractSocket::IPv4Protocol) { + dst.a4 = sockaddr_in{}; + dst.a4.sin_family = AF_INET; + dst.a4.sin_addr.s_addr = htonl(src.toIPv4Address()); + dst.a4.sin_len = sizeof(sockaddr_in); + } else if (src.protocol() == QAbstractSocket::IPv6Protocol) { + dst.a6 = sockaddr_in6{}; + dst.a6.sin6_family = AF_INET6; + dst.a6.sin6_len = sizeof(sockaddr_in6); + const Q_IPV6ADDR ipv6 = src.toIPv6Address(); + std::memcpy(&dst.a6.sin6_addr, &ipv6, sizeof ipv6); + } else { + Q_UNREACHABLE(); + } + + return dst; +} + +} // unnamed namespace + +class QNetworkConnectionMonitorPrivate : public QObjectPrivate +{ +public: + SCNetworkReachabilityRef probe = nullptr; + SCNetworkReachabilityFlags state = kSCNetworkReachabilityFlagsIsLocalAddress; + bool scheduled = false; + + void updateState(SCNetworkReachabilityFlags newState); + void reset(); + bool isReachable() const; + + static void probeCallback(SCNetworkReachabilityRef probe, SCNetworkReachabilityFlags flags, void *info); + + Q_DECLARE_PUBLIC(QNetworkConnectionMonitor) +}; + +void QNetworkConnectionMonitorPrivate::updateState(SCNetworkReachabilityFlags newState) +{ + // To be executed only on the reachability queue. + Q_Q(QNetworkConnectionMonitor); + + // NETMONTODO: for now, 'online' for us means kSCNetworkReachabilityFlagsReachable + // is set. There are more possible flags that require more tests/some special + // setup. So in future this part and related can change/be extended. + const bool wasReachable = isReachable(); + state = newState; + if (wasReachable != isReachable()) + emit q->reachabilityChanged(isReachable()); +} + +void QNetworkConnectionMonitorPrivate::reset() +{ + if (probe) { + CFRelease(probe); + probe = nullptr; + } + + state = kSCNetworkReachabilityFlagsIsLocalAddress; + scheduled = false; +} + +bool QNetworkConnectionMonitorPrivate::isReachable() const +{ + return !!(state & kSCNetworkReachabilityFlagsReachable); +} + +void QNetworkConnectionMonitorPrivate::probeCallback(SCNetworkReachabilityRef probe, SCNetworkReachabilityFlags flags, void *info) +{ + // To be executed only on the reachability queue. + Q_UNUSED(probe); + + auto monitorPrivate = static_cast(info); + Q_ASSERT(monitorPrivate); + monitorPrivate->updateState(flags); +} + +QNetworkConnectionMonitor::QNetworkConnectionMonitor() + : QObject(*new QNetworkConnectionMonitorPrivate) +{ +} + +QNetworkConnectionMonitor::QNetworkConnectionMonitor(const QHostAddress &local, const QHostAddress &remote) + : QObject(*new QNetworkConnectionMonitorPrivate) +{ + setTargets(local, remote); +} + +QNetworkConnectionMonitor::~QNetworkConnectionMonitor() +{ + Q_D(QNetworkConnectionMonitor); + + stopMonitoring(); + d->reset(); +} + +bool QNetworkConnectionMonitor::setTargets(const QHostAddress &local, const QHostAddress &remote) +{ + Q_D(QNetworkConnectionMonitor); + + if (isMonitoring()) { + qCWarning(lcNetMon, "Monitor is already active, call stopMonitoring() first"); + return false; + } + + if (local.isNull()) { + qCWarning(lcNetMon, "Invalid (null) local address, cannot create a reachability target"); + return false; + } + + // Clear the old target if needed: + d->reset(); + + qt_sockaddr client = qt_hostaddress_to_sockaddr(local); + if (remote.isNull()) { + // That's a special case our QNetworkStatusMonitor is using (AnyIpv4/6 address to check an overall status). + d->probe = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, reinterpret_cast(&client)); + } else { + qt_sockaddr target = qt_hostaddress_to_sockaddr(remote); + d->probe = SCNetworkReachabilityCreateWithAddressPair(kCFAllocatorDefault, + reinterpret_cast(&client), + reinterpret_cast(&target)); + } + + if (d->probe) { + // Let's read the initial state so that callback coming later can + // see a difference. Ignore errors though. + SCNetworkReachabilityGetFlags(d->probe, &d->state); + }else { + qCWarning(lcNetMon, "Failed to create network reachability probe"); + return false; + } + + return true; +} + +bool QNetworkConnectionMonitor::startMonitoring() +{ + Q_D(QNetworkConnectionMonitor); + + if (isMonitoring()) { + qCWarning(lcNetMon, "Monitor is already active, call stopMonitoring() first"); + return false; + } + + if (!d->probe) { + qCWarning(lcNetMon, "Can not start monitoring, set targets first"); + return false; + } + + auto queue = qt_reachability_queue(); + if (!queue) { + qWarning(lcNetMon, "Failed to create a dispatch queue to schedule a probe on"); + return false; + } + + SCNetworkReachabilityContext context = {}; + context.info = d; + if (!SCNetworkReachabilitySetCallback(d->probe, QNetworkConnectionMonitorPrivate::probeCallback, &context)) { + qWarning(lcNetMon, "Failed to set a reachability callback"); + return false; + } + + + if (!SCNetworkReachabilitySetDispatchQueue(d->probe, queue)) { + qWarning(lcNetMon, "Failed to schedule a reachability callback on a queue"); + return false; + } + + return d->scheduled = true; +} + +bool QNetworkConnectionMonitor::isMonitoring() const +{ + Q_D(const QNetworkConnectionMonitor); + + return d->scheduled; +} + +void QNetworkConnectionMonitor::stopMonitoring() +{ + Q_D(QNetworkConnectionMonitor); + + if (d->scheduled) { + Q_ASSERT(d->probe); + SCNetworkReachabilitySetDispatchQueue(d->probe, nullptr); + SCNetworkReachabilitySetCallback(d->probe, nullptr, nullptr); + d->scheduled = false; + } +} + +bool QNetworkConnectionMonitor::isReachable() +{ + Q_D(QNetworkConnectionMonitor); + + if (isMonitoring()) { + qCWarning(lcNetMon, "Calling isReachable() is unsafe after the monitoring started"); + return false; + } + + if (!d->probe) { + qCWarning(lcNetMon, "Reachability is unknown, set the target first"); + return false; + } + + return d->isReachable(); +} + +class QNetworkStatusMonitorPrivate : public QObjectPrivate +{ +public: + QNetworkConnectionMonitor ipv4Probe; + bool isOnlineIpv4 = false; + QNetworkConnectionMonitor ipv6Probe; + bool isOnlineIpv6 = false; + + static bool enabled; + static void readEnv(); +}; + +bool QNetworkStatusMonitorPrivate::enabled = false; + +void QNetworkStatusMonitorPrivate::readEnv() +{ + bool envOk = false; + const int env = qEnvironmentVariableIntValue("QT_USE_NETWORK_MONITOR", &envOk); + enabled = envOk && env > 0; +} + +QNetworkStatusMonitor::QNetworkStatusMonitor() + : QObject(*new QNetworkStatusMonitorPrivate) +{ + Q_D(QNetworkStatusMonitor); + + if (d->ipv4Probe.setTargets(QHostAddress::AnyIPv4, {})) { + // We manage to create SCNetworkReachabilityRef for IPv4, let's + // read the last known state then! + d->isOnlineIpv4 = d->ipv4Probe.isReachable(); + } + + if (d->ipv6Probe.setTargets(QHostAddress::AnyIPv6, {})) { + // We manage to create SCNetworkReachability ref for IPv6, let's + // read the last known state then! + d->isOnlineIpv6 = d->ipv6Probe.isReachable(); + } + + + connect(&d->ipv4Probe, &QNetworkConnectionMonitor::reachabilityChanged, this, + &QNetworkStatusMonitor::reachabilityChanged, Qt::QueuedConnection); + connect(&d->ipv6Probe, &QNetworkConnectionMonitor::reachabilityChanged, this, + &QNetworkStatusMonitor::reachabilityChanged, Qt::QueuedConnection); +} + +QNetworkStatusMonitor::~QNetworkStatusMonitor() +{ + Q_D(QNetworkStatusMonitor); + + d->ipv4Probe.disconnect(); + d->ipv4Probe.stopMonitoring(); + d->ipv6Probe.disconnect(); + d->ipv6Probe.stopMonitoring(); +} + +bool QNetworkStatusMonitor::start() +{ + Q_D(QNetworkStatusMonitor); + + if (isMonitoring()) { + qCWarning(lcNetMon, "Network status monitor is already active"); + return true; + } + + d->ipv4Probe.startMonitoring(); + d->ipv6Probe.startMonitoring(); + + return isMonitoring(); +} + +void QNetworkStatusMonitor::stop() +{ + Q_D(QNetworkStatusMonitor); + + if (d->ipv4Probe.isMonitoring()) + d->ipv4Probe.stopMonitoring(); + if (d->ipv6Probe.isMonitoring()) + d->ipv6Probe.stopMonitoring(); +} + +bool QNetworkStatusMonitor::isMonitoring() const +{ + Q_D(const QNetworkStatusMonitor); + + return d->ipv4Probe.isMonitoring() || d->ipv6Probe.isMonitoring(); +} + +bool QNetworkStatusMonitor::isNetworkAccesible() +{ + // This function is to be executed on the thread that created + // and uses 'this'. + Q_D(QNetworkStatusMonitor); + + return d->isOnlineIpv4 || d->isOnlineIpv6; +} + +bool QNetworkStatusMonitor::isEnabled() +{ + static std::once_flag envRead = {}; + std::call_once(envRead, QNetworkStatusMonitorPrivate::readEnv); + return QNetworkStatusMonitorPrivate::enabled; +} + +void QNetworkStatusMonitor::reachabilityChanged(bool online) +{ + // This function is executed on the thread that created/uses 'this', + // not on the reachability queue. + Q_D(QNetworkStatusMonitor); + + auto probe = qobject_cast(sender()); + if (!probe) + return; + + const bool isIpv4 = probe == &d->ipv4Probe; + bool &probeOnline = isIpv4 ? d->isOnlineIpv4 : d->isOnlineIpv6; + bool otherOnline = isIpv4 ? d->isOnlineIpv6 : d->isOnlineIpv4; + + if (probeOnline == online) { + // We knew this already? + return; + } + + probeOnline = online; + if (!otherOnline) { + // We either just lost or got a network access. + emit onlineStateChanged(probeOnline); + } +} + +QT_END_NAMESPACE diff --git a/src/network/kernel/qnetconmonitor_p.h b/src/network/kernel/qnetconmonitor_p.h new file mode 100644 index 0000000000..74ee56d422 --- /dev/null +++ b/src/network/kernel/qnetconmonitor_p.h @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtNetwork module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QNETCONMONITOR_P_H +#define QNETCONMONITOR_P_H + +#include + +#include +#include +#include +#include + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QNetworkConnectionMonitorPrivate; +class QNetworkConnectionMonitor : public QObject +{ + Q_OBJECT + +public: + QNetworkConnectionMonitor(); + QNetworkConnectionMonitor(const QHostAddress &local, const QHostAddress &remote = {}); + ~QNetworkConnectionMonitor(); + + bool setTargets(const QHostAddress &local, const QHostAddress &remote); + bool isReachable(); + + // Important: on Darwin you should not call isReachable() after + // startMonitoring(), you have to listen to reachabilityChanged() + // signal instead. + bool startMonitoring(); + bool isMonitoring() const; + void stopMonitoring(); + +Q_SIGNALS: + // Important: connect to this using QueuedConnection. On Darwin + // callback is coming on a special dispatch queue. + void reachabilityChanged(bool isOnline); + +private: + Q_DECLARE_PRIVATE(QNetworkConnectionMonitor) + Q_DISABLE_COPY_MOVE(QNetworkConnectionMonitor) +}; + +class QNetworkStatusMonitorPrivate; +class QNetworkStatusMonitor : public QObject +{ + Q_OBJECT + +public: + QNetworkStatusMonitor(); + ~QNetworkStatusMonitor(); + + bool isNetworkAccesible(); + + bool start(); + void stop(); + bool isMonitoring() const; + + static bool isEnabled(); + +Q_SIGNALS: + // Unlike QNetworkConnectionMonitor, this can be connected to directly. + void onlineStateChanged(bool isOnline); + +private slots: + void reachabilityChanged(bool isOnline); + +private: + Q_DECLARE_PRIVATE(QNetworkStatusMonitor) + Q_DISABLE_COPY_MOVE(QNetworkStatusMonitor) +}; + +Q_DECLARE_LOGGING_CATEGORY(lcNetMon) + +QT_END_NAMESPACE + +#endif // QNETCONMONITOR_P_H diff --git a/src/network/kernel/qnetconmonitor_stub.cpp b/src/network/kernel/qnetconmonitor_stub.cpp new file mode 100644 index 0000000000..7f3a0c44c6 --- /dev/null +++ b/src/network/kernel/qnetconmonitor_stub.cpp @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtNetwork module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qnetconmonitor_p.h" + +#include "private/qobject_p.h" + +QT_BEGIN_NAMESPACE + +Q_LOGGING_CATEGORY(lcNetMon, "qt.network.monitor"); + +// Note: this 'stub' version is never enabled (see QNetworkStatusMonitor::isEnabled below) +// and thus should never affect QNAM in any unusuall way. Having this 'stub' version is similar +// to building Qt with bearer management configured out. + +class QNetworkConnectionMonitorPrivate : public QObjectPrivate +{ +}; + +QNetworkConnectionMonitor::QNetworkConnectionMonitor() + : QObject(*new QNetworkConnectionMonitorPrivate) +{ +} + +QNetworkConnectionMonitor::QNetworkConnectionMonitor(const QHostAddress &local, const QHostAddress &remote) + : QObject(*new QNetworkConnectionMonitorPrivate) +{ + Q_UNUSED(local) + Q_UNUSED(remote) +} + +QNetworkConnectionMonitor::~QNetworkConnectionMonitor() +{ +} + +bool QNetworkConnectionMonitor::setTargets(const QHostAddress &local, const QHostAddress &remote) +{ + Q_UNUSED(local) + Q_UNUSED(remote) + + return false; +} + +bool QNetworkConnectionMonitor::startMonitoring() +{ + return false; +} + +bool QNetworkConnectionMonitor::isMonitoring() const +{ + return false; +} + +void QNetworkConnectionMonitor::stopMonitoring() +{ +} + +bool QNetworkConnectionMonitor::isReachable() +{ + return false; +} + +class QNetworkStatusMonitorPrivate : public QObjectPrivate +{ +}; + +QNetworkStatusMonitor::QNetworkStatusMonitor() + : QObject(*new QNetworkStatusMonitorPrivate) +{ +} + +QNetworkStatusMonitor::~QNetworkStatusMonitor() +{ +} + +bool QNetworkStatusMonitor::start() +{ + return false; +} + +void QNetworkStatusMonitor::stop() +{ +} + +bool QNetworkStatusMonitor::isMonitoring() const +{ + return false; +} + +bool QNetworkStatusMonitor::isNetworkAccesible() +{ + return false; +} + +bool QNetworkStatusMonitor::isEnabled() +{ + return false; +} + +void QNetworkStatusMonitor::reachabilityChanged(bool online) +{ + Q_UNUSED(online) +} + +QT_END_NAMESPACE From c940ca50ce0db76e12b06eb9cefd13c0876c0938 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 30 Apr 2019 11:55:55 +0200 Subject: [PATCH 230/292] Remove spurious class-name prefixes in its own methods Change-Id: I13093e02b251a084e468a50471cf1b9256555e40 Reviewed-by: Jesus Fernandez Reviewed-by: Thiago Macieira --- src/corelib/tools/qlocale_p.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index 16ded7650c..15398ded32 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -359,9 +359,9 @@ public: QByteArray bcp47Name(char separator = '-') const; - inline QLatin1String languageCode() const { return QLocalePrivate::languageToCode(QLocale::Language(m_data->m_language_id)); } - inline QLatin1String scriptCode() const { return QLocalePrivate::scriptToCode(QLocale::Script(m_data->m_script_id)); } - inline QLatin1String countryCode() const { return QLocalePrivate::countryToCode(QLocale::Country(m_data->m_country_id)); } + inline QLatin1String languageCode() const { return languageToCode(QLocale::Language(m_data->m_language_id)); } + inline QLatin1String scriptCode() const { return scriptToCode(QLocale::Script(m_data->m_script_id)); } + inline QLatin1String countryCode() const { return countryToCode(QLocale::Country(m_data->m_country_id)); } static QLatin1String languageToCode(QLocale::Language language); static QLatin1String scriptToCode(QLocale::Script script); From 7a0d4b39daa1beed7070ceb43414eb55934f1266 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 30 Apr 2019 16:58:38 +0200 Subject: [PATCH 231/292] Doc-fix: mention FP_ZERO as a possible return of qFpClassify() This follows up on commit 84aea6c091d020a37c2b452a6f56ca27b3b2c7cb, in which I forgot to mention this possible return value. Change-Id: I109bed66bc0fd63d7ee289bfaea65b3d05c6560c Reviewed-by: Giuseppe D'Angelo Reviewed-by: Thiago Macieira --- src/corelib/global/qnumeric.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/global/qnumeric.cpp b/src/corelib/global/qnumeric.cpp index e6ba62f530..11440f40a4 100644 --- a/src/corelib/global/qnumeric.cpp +++ b/src/corelib/global/qnumeric.cpp @@ -110,6 +110,7 @@ Q_CORE_EXPORT double qInf() { return qt_inf(); } \list \li FP_NAN not a number \li FP_INFINITE infinities (positive or negative) + \li FP_ZERO zero (positive or negative) \li FP_NORMAL finite with a full mantissa \li FP_SUBNORMAL finite with a reduced mantissa \endlist From a2b38f64e6def1538b9d153ec4c6589fa9b6d3c0 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 30 Apr 2019 17:53:53 +0200 Subject: [PATCH 232/292] Remove handling of missing =delete and =default support Change-Id: I006dfd0b7cfa3bda5e5ab01bcefa851f031dfe0e Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal.h | 6 +++--- src/corelib/kernel/qmetaobject.h | 2 +- src/corelib/kernel/qmetatype.h | 2 +- src/corelib/kernel/qvariant.h | 14 +++++++------- src/corelib/thread/qatomic_cxx11.h | 2 +- src/corelib/thread/qbasicatomic.h | 2 +- src/corelib/thread/qthread.h | 2 -- src/corelib/tools/qmap.h | 2 +- src/corelib/tools/qsharedpointer_impl.h | 12 ++++-------- src/corelib/tools/qstringbuilder.h | 4 ++-- src/gui/image/qiconengine.h | 2 +- src/widgets/kernel/qtooltip.h | 2 +- src/widgets/kernel/qwhatsthis.h | 2 +- src/xml/sax/qxml.h | 2 -- 14 files changed, 24 insertions(+), 32 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index ceae0583ee..4817acb48f 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -422,8 +422,8 @@ typedef double qreal; operator to disable copying (the compiler gives an error message). */ #define Q_DISABLE_COPY(Class) \ - Class(const Class &) Q_DECL_EQ_DELETE;\ - Class &operator=(const Class &) Q_DECL_EQ_DELETE; + Class(const Class &) = delete;\ + Class &operator=(const Class &) = delete; #define Q_DISABLE_MOVE(Class) \ Class(Class &&) = delete; \ @@ -1021,7 +1021,7 @@ template Q_DECL_CONSTEXPR typename std::add_const::type &qAsConst(T &t) noexcept { return t; } // prevent rvalue arguments: template -void qAsConst(const T &&) Q_DECL_EQ_DELETE; +void qAsConst(const T &&) = delete; #ifndef QT_NO_FOREACH diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h index 6c5f78d208..10b14a7e03 100644 --- a/src/corelib/kernel/qmetaobject.h +++ b/src/corelib/kernel/qmetaobject.h @@ -183,7 +183,7 @@ private: // signature() has been renamed to methodSignature() in Qt 5. // Warning, that function returns a QByteArray; check the life time if // you convert to char*. - char *signature(struct renamedInQt5_warning_checkTheLifeTime * = nullptr) Q_DECL_EQ_DELETE; + char *signature(struct renamedInQt5_warning_checkTheLifeTime * = nullptr) = delete; #endif static QMetaMethod fromSignalImpl(const QMetaObject *, void **); diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index a47fbfe28d..79ee5eec11 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -849,7 +849,7 @@ struct VariantData const uint flags; private: // copy constructor allowed to be implicit to silence level 4 warning from MSVC - VariantData &operator=(const VariantData &) Q_DECL_EQ_DELETE; + VariantData &operator=(const VariantData &) = delete; }; template diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 2247c7adc8..924cfa1e1a 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -483,27 +483,27 @@ public: private: // force compile error, prevent QVariant(bool) to be called - inline QVariant(void *) Q_DECL_EQ_DELETE; + inline QVariant(void *) = delete; // QVariant::Type is marked as \obsolete, but we don't want to // provide a constructor from its intended replacement, // QMetaType::Type, instead, because the idea behind these // constructors is flawed in the first place. But we also don't // want QVariant(QMetaType::String) to compile and falsely be an // int variant, so delete this constructor: - QVariant(QMetaType::Type) Q_DECL_EQ_DELETE; + QVariant(QMetaType::Type) = delete; // These constructors don't create QVariants of the type associcated // with the enum, as expected, but they would create a QVariant of // type int with the value of the enum value. // Use QVariant v = QColor(Qt::red) instead of QVariant v = Qt::red for // example. - QVariant(Qt::GlobalColor) Q_DECL_EQ_DELETE; - QVariant(Qt::BrushStyle) Q_DECL_EQ_DELETE; - QVariant(Qt::PenStyle) Q_DECL_EQ_DELETE; - QVariant(Qt::CursorShape) Q_DECL_EQ_DELETE; + QVariant(Qt::GlobalColor) = delete; + QVariant(Qt::BrushStyle) = delete; + QVariant(Qt::PenStyle) = delete; + QVariant(Qt::CursorShape) = delete; #ifdef QT_NO_CAST_FROM_ASCII // force compile error when implicit conversion is not wanted - inline QVariant(const char *) Q_DECL_EQ_DELETE; + inline QVariant(const char *) = delete; #endif public: typedef Private DataPtr; diff --git a/src/corelib/thread/qatomic_cxx11.h b/src/corelib/thread/qatomic_cxx11.h index 32d27734fc..2851bae73e 100644 --- a/src/corelib/thread/qatomic_cxx11.h +++ b/src/corelib/thread/qatomic_cxx11.h @@ -462,7 +462,7 @@ template struct QAtomicOps } }; -#if defined(Q_COMPILER_CONSTEXPR) && defined(Q_COMPILER_DEFAULT_MEMBERS) && defined(Q_COMPILER_DELETE_MEMBERS) +#if defined(Q_COMPILER_CONSTEXPR) # define Q_BASIC_ATOMIC_INITIALIZER(a) { a } #else # define Q_BASIC_ATOMIC_INITIALIZER(a) { ATOMIC_VAR_INIT(a) } diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h index 4c3c1fc01f..7d2e06a499 100644 --- a/src/corelib/thread/qbasicatomic.h +++ b/src/corelib/thread/qbasicatomic.h @@ -75,7 +75,7 @@ QT_END_NAMESPACE // New atomics -#if defined(Q_COMPILER_CONSTEXPR) && defined(Q_COMPILER_DEFAULT_MEMBERS) && defined(Q_COMPILER_DELETE_MEMBERS) +#if defined(Q_COMPILER_CONSTEXPR) # if defined(Q_CC_CLANG) && Q_CC_CLANG < 303 /* Do not define QT_BASIC_ATOMIC_HAS_CONSTRUCTORS for Clang before version 3.3. diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h index 8e92d75401..c7a6dc8f1a 100644 --- a/src/corelib/thread/qthread.h +++ b/src/corelib/thread/qthread.h @@ -209,7 +209,6 @@ struct Callable { } -#if defined(Q_COMPILER_DEFAULT_MEMBERS) && defined(Q_COMPILER_DELETE_MEMBERS) // Apply the same semantics of a lambda closure type w.r.t. the special // member functions, if possible: delete the copy assignment operator, // bring back all the others as per the RO5 (cf. §8.1.5.1/11 [expr.prim.lambda.closure]) @@ -218,7 +217,6 @@ struct Callable Callable(Callable &&) = default; Callable &operator=(const Callable &) = delete; Callable &operator=(Callable &&) = default; -#endif void operator()() { diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index 3b8aad9a33..2d01a75a42 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -142,7 +142,7 @@ private: rightNode()->destroySubTree(); } - QMapNode() Q_DECL_EQ_DELETE; + QMapNode() = delete; Q_DISABLE_COPY(QMapNode) }; diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 9fb452da6b..c219d310dc 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -235,8 +235,8 @@ namespace QtSharedPointer { } private: // prevent construction - ExternalRefCountWithCustomDeleter() Q_DECL_EQ_DELETE; - ~ExternalRefCountWithCustomDeleter() Q_DECL_EQ_DELETE; + ExternalRefCountWithCustomDeleter() = delete; + ~ExternalRefCountWithCustomDeleter() = delete; Q_DISABLE_COPY(ExternalRefCountWithCustomDeleter) }; @@ -280,8 +280,8 @@ namespace QtSharedPointer { private: // prevent construction - ExternalRefCountWithContiguousData() Q_DECL_EQ_DELETE; - ~ExternalRefCountWithContiguousData() Q_DECL_EQ_DELETE; + ExternalRefCountWithContiguousData() = delete; + ~ExternalRefCountWithContiguousData() = delete; Q_DISABLE_COPY(ExternalRefCountWithContiguousData) }; @@ -705,11 +705,7 @@ template class QEnableSharedFromThis { protected: -#ifdef Q_COMPILER_DEFAULT_MEMBERS QEnableSharedFromThis() = default; -#else - Q_DECL_CONSTEXPR QEnableSharedFromThis() {} -#endif QEnableSharedFromThis(const QEnableSharedFromThis &) {} QEnableSharedFromThis &operator=(const QEnableSharedFromThis &) { return *this; } diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h index 79ed10c7a8..b3cf2f695e 100644 --- a/src/corelib/tools/qstringbuilder.h +++ b/src/corelib/tools/qstringbuilder.h @@ -150,7 +150,7 @@ class QStringBuilder : public QStringBuilderBase @@ -167,7 +167,7 @@ class QStringBuilder : public QStringBuilderBase Date: Wed, 24 Apr 2019 18:03:59 +0200 Subject: [PATCH 233/292] Increase entityCharacterLimit to 4096 The previous fix to decrease the limit to 1024 breaks the parsing for some files. The limit is arbitrary, so increasing it to 4096, which is what some linux distros have been working with. Change-Id: I131f15278aa99c3f91db2e1ec2d14156ceed4775 Fixes: QTBUG-35459 Reviewed-by: Mitch Curtis Reviewed-by: David Faure --- src/xml/sax/qxml_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xml/sax/qxml_p.h b/src/xml/sax/qxml_p.h index 98dc2aea0c..eb6135db04 100644 --- a/src/xml/sax/qxml_p.h +++ b/src/xml/sax/qxml_p.h @@ -229,7 +229,7 @@ private: // for the DTD currently being parsed. static const int dtdRecursionLimit = 2; // The maximum amount of characters an entity value may contain, after expansion. - static const int entityCharacterLimit = 1024; + static const int entityCharacterLimit = 4096; const QString &string(); void stringClear(); From 343528841e72adf36a37d9afd7260e260a9342eb Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 30 Apr 2019 12:51:36 +0200 Subject: [PATCH 234/292] Prefix textstream operators with Qt:: As the non prefixed variants are deprecated Change-Id: I2ba09d71b9cea5203b54297a3f2332e6d44fedcf Reviewed-by: Allan Sandfeld Jensen --- .../serialization/convert/cborconverter.cpp | 2 +- .../serialization/convert/textconverter.cpp | 6 +- examples/xml/htmlinfo/main.cpp | 18 +- qmake/generators/mac/pbuilder_pbx.cpp | 28 +- qmake/generators/makefile.cpp | 156 ++++----- qmake/generators/projectgenerator.cpp | 14 +- qmake/generators/unix/unixmake2.cpp | 160 ++++----- qmake/generators/win32/mingw_make.cpp | 24 +- qmake/generators/win32/msvc_nmake.cpp | 12 +- qmake/generators/win32/msvc_objectmodel.h | 2 +- qmake/generators/win32/winmakefile.cpp | 108 +++--- qmake/generators/xmloutput.cpp | 6 +- src/3rdparty/harfbuzz/src/harfbuzz-indic.cpp | 2 +- src/3rdparty/harfbuzz/tests/shaping/main.cpp | 4 +- .../doc/snippets/code/doc_src_qset.cpp | 4 +- .../code/src_corelib_io_qtextstream.cpp | 4 +- .../code/src_corelib_thread_qfuture.cpp | 2 +- .../code/src_corelib_tools_qbytearray.cpp | 6 +- .../snippets/code/src_corelib_tools_qhash.cpp | 28 +- .../code/src_corelib_tools_qlinkedlist.cpp | 8 +- .../code/src_corelib_tools_qlistdata.cpp | 8 +- .../snippets/code/src_corelib_tools_qmap.cpp | 30 +- .../code/src_corelib_tools_qqueue.cpp | 2 +- .../src_corelib_tools_qstringiterator.cpp | 6 +- .../code/src_corelib_tools_qvector.cpp | 4 +- src/corelib/doc/snippets/qstack/main.cpp | 2 +- src/corelib/doc/snippets/qstringlist/main.cpp | 6 +- src/corelib/io/qdebug.cpp | 6 +- src/corelib/io/qdebug.h | 2 +- src/corelib/io/qfilesystemwatcher_inotify.cpp | 2 +- src/corelib/io/qfilesystemwatcher_win.cpp | 4 +- src/corelib/kernel/qeventdispatcher_cf.mm | 2 +- src/corelib/kernel/qtimerinfo_unix.cpp | 8 +- src/corelib/plugin/qfactoryloader.cpp | 2 +- src/corelib/serialization/qcborvalue.cpp | 2 +- src/corelib/serialization/qjsonparser.cpp | 2 +- src/corelib/serialization/qtextstream.cpp | 4 +- src/corelib/tools/qstring.cpp | 6 +- src/gui/accessible/qaccessible.cpp | 4 +- .../doc/snippets/textdocumentendsnippet.cpp | 2 +- src/gui/image/qicon.cpp | 2 +- src/gui/image/qpixmap.cpp | 2 +- src/gui/image/qxpmhandler.cpp | 10 +- src/gui/kernel/qevent.cpp | 10 +- src/gui/kernel/qpalette.cpp | 4 +- src/gui/kernel/qscreen.cpp | 2 +- src/gui/kernel/qwindow.cpp | 4 +- src/gui/math3d/qgenericmatrix.h | 4 +- src/gui/math3d/qmatrix4x4.cpp | 10 +- src/gui/opengl/qopengl.cpp | 2 +- src/gui/painting/qblendfunctions_p.h | 16 +- src/gui/painting/qpaintengine_raster.cpp | 4 +- src/gui/painting/qpaintengineex.cpp | 2 +- src/gui/painting/qpainterpath.cpp | 4 +- src/gui/text/qfontengine.cpp | 2 +- src/gui/text/qfontengine_qpf2.cpp | 6 +- src/gui/text/qtextengine.cpp | 8 +- .../freetype/qfreetypefontdatabase.cpp | 2 +- src/plugins/bearer/nla/qnlaengine.cpp | 30 +- .../platforms/android/androidjnimain.cpp | 2 +- .../platforms/cocoa/qcocoaaccessibility.mm | 2 +- .../platforms/cocoa/qnsview_gestures.mm | 10 +- src/plugins/platforms/cocoa/qnsview_touch.mm | 8 +- .../eglfs_kms/qeglfskmsgbmscreen.cpp | 2 +- .../platforms/windows/qwindowscontext.cpp | 4 +- .../windows/qwindowsdialoghelpers.cpp | 6 +- .../platforms/windows/qwindowsdrag.cpp | 8 +- .../platforms/windows/qwindowsglcontext.cpp | 8 +- .../windows/qwindowsinputcontext.cpp | 4 +- .../platforms/windows/qwindowsintegration.cpp | 6 +- .../platforms/windows/qwindowskeymapper.cpp | 6 +- .../platforms/windows/qwindowsmenu.cpp | 6 +- .../windows/qwindowsmousehandler.cpp | 4 +- src/plugins/platforms/windows/qwindowsole.cpp | 6 +- .../windows/qwindowsopengltester.cpp | 8 +- .../windows/qwindowspointerhandler.cpp | 20 +- .../windows/qwindowstabletsupport.cpp | 12 +- .../platforms/windows/qwindowswindow.cpp | 6 +- .../platforms/xcb/qxcbnativeinterface.cpp | 8 +- src/plugins/platforms/xcb/qxcbscreen.cpp | 6 +- .../doc/snippets/sqldatabase/sqldatabase.cpp | 4 +- src/sql/kernel/qsqlrecord.cpp | 2 +- src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp | 328 +++++++++--------- src/tools/qlalr/cppgenerator.cpp | 188 +++++----- src/tools/qlalr/dotgraph.cpp | 22 +- src/tools/qlalr/lalr.cpp | 20 +- src/tools/qlalr/lalr.g | 12 +- src/tools/qlalr/main.cpp | 24 +- src/tools/qlalr/parsetable.cpp | 26 +- src/tools/qlalr/recognizer.cpp | 12 +- src/tools/uic/cpp/cppwriteinitialization.cpp | 10 +- src/widgets/itemviews/qtableview.cpp | 8 +- src/widgets/kernel/qwidget.cpp | 4 +- src/widgets/widgets/qsplitter.cpp | 2 +- .../doc/snippets/code/src_xml_dom_qdom.cpp | 8 +- src/xml/dom/qdom.cpp | 18 +- 96 files changed, 826 insertions(+), 826 deletions(-) diff --git a/examples/corelib/serialization/convert/cborconverter.cpp b/examples/corelib/serialization/convert/cborconverter.cpp index ad69983eb1..f907bb0af6 100644 --- a/examples/corelib/serialization/convert/cborconverter.cpp +++ b/examples/corelib/serialization/convert/cborconverter.cpp @@ -226,7 +226,7 @@ void CborDiagnosticDumper::saveFile(QIODevice *f, const QVariant &contents, cons QTextStream out(f); out << convertFromVariant(contents, Double).toDiagnosticNotation(opts) - << endl; + << Qt::endl; } CborConverter::CborConverter() diff --git a/examples/corelib/serialization/convert/textconverter.cpp b/examples/corelib/serialization/convert/textconverter.cpp index e80e69a0b5..7aed08f96c 100644 --- a/examples/corelib/serialization/convert/textconverter.cpp +++ b/examples/corelib/serialization/convert/textconverter.cpp @@ -66,7 +66,7 @@ static void dumpVariant(QTextStream &out, const QVariant &v) case QVariant::String: { const QStringList list = v.toStringList(); for (const QString &s : list) - out << s << endl; + out << s << Qt::endl; break; } @@ -80,11 +80,11 @@ static void dumpVariant(QTextStream &out, const QVariant &v) } case QMetaType::Nullptr: - out << "(null)" << endl; + out << "(null)" << Qt::endl; break; default: - out << v.toString() << endl; + out << v.toString() << Qt::endl; break; } } diff --git a/examples/xml/htmlinfo/main.cpp b/examples/xml/htmlinfo/main.cpp index 22bf36f33c..bc19ae4a82 100644 --- a/examples/xml/htmlinfo/main.cpp +++ b/examples/xml/htmlinfo/main.cpp @@ -54,10 +54,10 @@ void parseHtmlFile(QTextStream &out, const QString &fileName) { QFile file(fileName); - out << "Analysis of HTML file: " << fileName << endl; + out << "Analysis of HTML file: " << fileName << Qt::endl; if (!file.open(QIODevice::ReadOnly)) { - out << " Couldn't open the file." << endl << endl << endl; + out << " Couldn't open the file." << Qt::endl << Qt::endl << Qt::endl; return; } @@ -85,22 +85,22 @@ void parseHtmlFile(QTextStream &out, const QString &fileName) //! [2] if (reader.hasError()) { out << " The HTML file isn't well-formed: " << reader.errorString() - << endl << endl << endl; + << Qt::endl << Qt::endl << Qt::endl; return; } //! [2] - out << " Title: \"" << title << '"' << endl - << " Number of paragraphs: " << paragraphCount << endl - << " Number of links: " << links.size() << endl - << " Showing first few links:" << endl; + out << " Title: \"" << title << '"' << Qt::endl + << " Number of paragraphs: " << paragraphCount << Qt::endl + << " Number of links: " << links.size() << Qt::endl + << " Showing first few links:" << Qt::endl; while (links.size() > 5) links.removeLast(); for (const QString &link : qAsConst(links)) - out << " " << link << endl; - out << endl << endl; + out << " " << link << Qt::endl; + out << Qt::endl << Qt::endl; } int main(int argc, char **argv) diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp index 07832041a7..3bed28afdf 100644 --- a/qmake/generators/mac/pbuilder_pbx.cpp +++ b/qmake/generators/mac/pbuilder_pbx.cpp @@ -541,7 +541,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) debug_msg(1, "pbuilder: Creating file: %s", mkfile.toLatin1().constData()); QTextStream mkt(&mkf); writeHeader(mkt); - mkt << "QMAKE = " << var("QMAKE_QMAKE") << endl; + mkt << "QMAKE = " << var("QMAKE_QMAKE") << Qt::endl; project->values("QMAKE_MAKE_QMAKE_EXTRA_COMMANDS") << "@echo 'warning: Xcode project has been regenerated, custom settings have been lost. " \ "Use CONFIG+=no_autoqmake to prevent this behavior in the future, " \ @@ -740,15 +740,15 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) debug_msg(1, "pbuilder: Creating file: %s", mkfile.toLatin1().constData()); QTextStream mkt(&mkf); writeHeader(mkt); - mkt << "MOC = " << var("QMAKE_MOC") << endl; - mkt << "UIC = " << var("QMAKE_UIC") << endl; - mkt << "LEX = " << var("QMAKE_LEX") << endl; - mkt << "LEXFLAGS = " << var("QMAKE_LEXFLAGS") << endl; - mkt << "YACC = " << var("QMAKE_YACC") << endl; - mkt << "YACCFLAGS = " << var("QMAKE_YACCFLAGS") << endl; + mkt << "MOC = " << var("QMAKE_MOC") << Qt::endl; + mkt << "UIC = " << var("QMAKE_UIC") << Qt::endl; + mkt << "LEX = " << var("QMAKE_LEX") << Qt::endl; + mkt << "LEXFLAGS = " << var("QMAKE_LEXFLAGS") << Qt::endl; + mkt << "YACC = " << var("QMAKE_YACC") << Qt::endl; + mkt << "YACCFLAGS = " << var("QMAKE_YACCFLAGS") << Qt::endl; mkt << "DEFINES = " << varGlue("PRL_EXPORT_DEFINES","-D"," -D"," ") - << varGlue("DEFINES","-D"," -D","") << endl; + << varGlue("DEFINES","-D"," -D","") << Qt::endl; mkt << "INCPATH ="; { const ProStringList &incs = project->values("INCLUDEPATH"); @@ -757,9 +757,9 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) } if(!project->isEmpty("QMAKE_FRAMEWORKPATH_FLAGS")) mkt << " " << var("QMAKE_FRAMEWORKPATH_FLAGS"); - mkt << endl; - mkt << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; - mkt << "MOVE = " << var("QMAKE_MOVE") << endl << endl; + mkt << Qt::endl; + mkt << "DEL_FILE = " << var("QMAKE_DEL_FILE") << Qt::endl; + mkt << "MOVE = " << var("QMAKE_MOVE") << Qt::endl << Qt::endl; mkt << "preprocess: compilers\n"; mkt << "clean preprocess_clean: compiler_clean\n\n"; writeExtraTargets(mkt); @@ -789,7 +789,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) } } } - mkt << endl; + mkt << Qt::endl; writeExtraCompilerTargets(mkt); writingUnixMakefileGenerator = false; } @@ -994,12 +994,12 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) tmp = project->values("SUBLIBS"); for(int i = 0; i < tmp.count(); i++) t << escapeFilePath("tmp/lib" + tmp[i] + ".a") << ' '; - t << endl << endl; + t << Qt::endl << Qt::endl; mkt << "sublibs: $(SUBLIBS)\n\n"; tmp = project->values("SUBLIBS"); for(int i = 0; i < tmp.count(); i++) t << escapeFilePath("tmp/lib" + tmp[i] + ".a") + ":\n\t" - << var(ProKey("MAKELIB" + tmp[i])) << endl << endl; + << var(ProKey("MAKELIB" + tmp[i])) << Qt::endl << Qt::endl; mkt.flush(); mkf.close(); writingUnixMakefileGenerator = false; diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index b634ec622b..aae5a44e21 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -994,25 +994,25 @@ MakefileGenerator::writePrlFile(QTextStream &t) QString bdir = Option::output_dir; if(bdir.isEmpty()) bdir = qmake_getpwd(); - t << "QMAKE_PRL_BUILD_DIR =" << qv(bdir) << endl; + t << "QMAKE_PRL_BUILD_DIR =" << qv(bdir) << Qt::endl; - t << "QMAKE_PRO_INPUT =" << qv(project->projectFile().section('/', -1)) << endl; + t << "QMAKE_PRO_INPUT =" << qv(project->projectFile().section('/', -1)) << Qt::endl; if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) - t << "QMAKE_PRL_SOURCE_DIR =" << qv(project->first("QMAKE_ABSOLUTE_SOURCE_PATH")) << endl; - t << "QMAKE_PRL_TARGET =" << qv(project->first("LIB_TARGET")) << endl; + t << "QMAKE_PRL_SOURCE_DIR =" << qv(project->first("QMAKE_ABSOLUTE_SOURCE_PATH")) << Qt::endl; + t << "QMAKE_PRL_TARGET =" << qv(project->first("LIB_TARGET")) << Qt::endl; if(!project->isEmpty("PRL_EXPORT_DEFINES")) - t << "QMAKE_PRL_DEFINES =" << qv(project->values("PRL_EXPORT_DEFINES")) << endl; + t << "QMAKE_PRL_DEFINES =" << qv(project->values("PRL_EXPORT_DEFINES")) << Qt::endl; if(!project->isEmpty("PRL_EXPORT_CFLAGS")) - t << "QMAKE_PRL_CFLAGS =" << qv(project->values("PRL_EXPORT_CFLAGS")) << endl; + t << "QMAKE_PRL_CFLAGS =" << qv(project->values("PRL_EXPORT_CFLAGS")) << Qt::endl; if(!project->isEmpty("PRL_EXPORT_CXXFLAGS")) - t << "QMAKE_PRL_CXXFLAGS =" << qv(project->values("PRL_EXPORT_CXXFLAGS")) << endl; + t << "QMAKE_PRL_CXXFLAGS =" << qv(project->values("PRL_EXPORT_CXXFLAGS")) << Qt::endl; if(!project->isEmpty("CONFIG")) - t << "QMAKE_PRL_CONFIG =" << qv(project->values("CONFIG")) << endl; + t << "QMAKE_PRL_CONFIG =" << qv(project->values("CONFIG")) << Qt::endl; if(!project->isEmpty("TARGET_VERSION_EXT")) - t << "QMAKE_PRL_VERSION = " << project->first("TARGET_VERSION_EXT") << endl; + t << "QMAKE_PRL_VERSION = " << project->first("TARGET_VERSION_EXT") << Qt::endl; else if(!project->isEmpty("VERSION")) - t << "QMAKE_PRL_VERSION = " << project->first("VERSION") << endl; + t << "QMAKE_PRL_VERSION = " << project->first("VERSION") << Qt::endl; if(project->isActiveConfig("staticlib") || project->isActiveConfig("explicitlib")) { ProStringList libs; if (!project->isActiveConfig("staticlib")) @@ -1022,7 +1022,7 @@ MakefileGenerator::writePrlFile(QTextStream &t) t << "QMAKE_PRL_LIBS ="; for (ProStringList::Iterator it = libs.begin(); it != libs.end(); ++it) t << qv(project->values((*it).toKey())); - t << endl; + t << Qt::endl; } } @@ -1055,15 +1055,15 @@ MakefileGenerator::writeProjectMakefile() t << "install: "; for(it = targets.begin(); it != targets.end(); ++it) t << (*it)->target << "-install "; - t << endl; + t << Qt::endl; //uninstall t << "uninstall: "; for(it = targets.begin(); it != targets.end(); ++it) t << (*it)->target << "-uninstall "; - t << endl; + t << Qt::endl; } else { - t << "first: " << targets.first()->target << endl + t << "first: " << targets.first()->target << Qt::endl << "install: " << targets.first()->target << "-install\n" << "uninstall: " << targets.first()->target << "-uninstall\n"; } @@ -1072,7 +1072,7 @@ MakefileGenerator::writeProjectMakefile() if(!project->isActiveConfig("no_autoqmake")) { QString mkf = escapeDependencyPath(fileFixify(Option::output.fileName())); for(QList::Iterator it = targets.begin(); it != targets.end(); ++it) - t << escapeDependencyPath((*it)->makefile) << ": " << mkf << endl; + t << escapeDependencyPath((*it)->makefile) << ": " << mkf << Qt::endl; } qDeleteAll(targets); return true; @@ -1186,7 +1186,7 @@ MakefileGenerator::writeObj(QTextStream &t, const char *src) p.replace(stringObj, escapeFilePath(dstf)); t << "\n\t" << p; } - t << endl << endl; + t << Qt::endl << Qt::endl; } } @@ -1380,14 +1380,14 @@ MakefileGenerator::writeInstalls(QTextStream &t, bool noBuild) QString tmp_dst = fileFixify((*pit).toQString(), FileFixifyAbsolute, false); t << mkdir_p_asstring(filePrefixRoot(root, tmp_dst)) << "\n\t"; } - t << target << endl << endl; + t << target << Qt::endl << Qt::endl; if(!uninst.isEmpty()) { t << "uninstall_" << (*it) << ": FORCE"; for (int i = uninst.size(); --i >= 0; ) t << "\n\t" << uninst.at(i); t << "\n\t-$(DEL_DIR) " << escapeFilePath(filePrefixRoot(root, dst)) << " \n\n"; } - t << endl; + t << Qt::endl; if (installConfigValues.indexOf("no_default_install") == -1) { all_installs += QString("install_") + (*it) + " "; @@ -1824,7 +1824,7 @@ MakefileGenerator::writeExtraTargets(QTextStream &t) t << escapeDependencyPath(targ) << ":" << deps; if(!cmd.isEmpty()) t << "\n\t" << cmd; - t << endl << endl; + t << Qt::endl << Qt::endl; } } @@ -1916,7 +1916,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t) FileFixifyFromOutdir)); } } - t << endl; + t << Qt::endl; if (config.indexOf("no_clean") == -1) { QStringList raw_clean = project->values(ProKey(*it + ".clean")).toQStringList(); @@ -1981,7 +1981,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t) } } } - t << endl; + t << Qt::endl; } QStringList tmp_dep = project->values(ProKey(*it + ".depends")).toQStringList(); if (config.indexOf("combine") != -1) { @@ -2065,7 +2065,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t) } else { t << " " << valList(escapeDependencyPaths(inputs)) << " " << valList(finalizeDependencyPaths(deps)); } - t << "\n\t" << cmd << endl << endl; + t << "\n\t" << cmd << Qt::endl << Qt::endl; continue; } for (ProStringList::ConstIterator input = tmp_inputs.cbegin(); input != tmp_inputs.cend(); ++input) { @@ -2177,10 +2177,10 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t) ++i; } t << escapeDependencyPath(out) << ": " << valList(finalizeDependencyPaths(deps)) << "\n\t" - << cmd << endl << endl; + << cmd << Qt::endl << Qt::endl; } } - t << "compiler_clean: " << clean_targets << endl << endl; + t << "compiler_clean: " << clean_targets << Qt::endl << Qt::endl; } void @@ -2196,17 +2196,17 @@ MakefileGenerator::writeExtraCompilerVariables(QTextStream &t) first = false; } t << "QMAKE_COMP_" << (*varit) << " = " - << valList(project->values((*varit).toKey())) << endl; + << valList(project->values((*varit).toKey())) << Qt::endl; } } if(!first) - t << endl; + t << Qt::endl; } void MakefileGenerator::writeExtraVariables(QTextStream &t) { - t << endl; + t << Qt::endl; ProStringList outlist; const ProValueMap &vars = project->variables(); @@ -2220,7 +2220,7 @@ MakefileGenerator::writeExtraVariables(QTextStream &t) } if (!outlist.isEmpty()) { t << "####### Custom Variables\n"; - t << outlist.join('\n') << endl << endl; + t << outlist.join('\n') << Qt::endl << Qt::endl; } } @@ -2236,11 +2236,11 @@ MakefileGenerator::writeExportedVariables(QTextStream &t) const ProString &name = project->first(ProKey(exp + ".name")); const ProString &value = project->first(ProKey(exp + ".value")); if (!value.isEmpty()) - t << name << " = " << value << endl; + t << name << " = " << value << Qt::endl; else t << name << " =\n"; } - t << endl; + t << Qt::endl; } bool @@ -2248,7 +2248,7 @@ MakefileGenerator::writeDummyMakefile(QTextStream &t) { if (project->values("QMAKE_FAILED_REQUIREMENTS").isEmpty()) return false; - t << "QMAKE = " << var("QMAKE_QMAKE") << endl; + t << "QMAKE = " << var("QMAKE_QMAKE") << Qt::endl; const ProStringList &qut = project->values("QMAKE_EXTRA_TARGETS"); for (ProStringList::ConstIterator it = qut.begin(); it != qut.end(); ++it) t << *it << " "; @@ -2264,7 +2264,7 @@ MakefileGenerator::writeDummyMakefile(QTextStream &t) bool MakefileGenerator::writeStubMakefile(QTextStream &t) { - t << "QMAKE = " << var("QMAKE_QMAKE") << endl; + t << "QMAKE = " << var("QMAKE_QMAKE") << Qt::endl; const ProStringList &qut = project->values("QMAKE_EXTRA_TARGETS"); for (ProStringList::ConstIterator it = qut.begin(); it != qut.end(); ++it) t << *it << " "; @@ -2293,22 +2293,22 @@ MakefileGenerator::writeMakefile(QTextStream &t) void MakefileGenerator::writeDefaultVariables(QTextStream &t) { - t << "QMAKE = " << var("QMAKE_QMAKE") << endl; - t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; - t << "CHK_DIR_EXISTS= " << var("QMAKE_CHK_DIR_EXISTS") << endl; - t << "MKDIR = " << var("QMAKE_MKDIR") << endl; - t << "COPY = " << var("QMAKE_COPY") << endl; - t << "COPY_FILE = " << var("QMAKE_COPY_FILE") << endl; - t << "COPY_DIR = " << var("QMAKE_COPY_DIR") << endl; - t << "INSTALL_FILE = " << var("QMAKE_INSTALL_FILE") << endl; - t << "INSTALL_PROGRAM = " << var("QMAKE_INSTALL_PROGRAM") << endl; - t << "INSTALL_DIR = " << var("QMAKE_INSTALL_DIR") << endl; - t << "QINSTALL = " << var("QMAKE_QMAKE") << " -install qinstall" << endl; - t << "QINSTALL_PROGRAM = " << var("QMAKE_QMAKE") << " -install qinstall -exe" << endl; - t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; - t << "SYMLINK = " << var("QMAKE_SYMBOLIC_LINK") << endl; - t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl; - t << "MOVE = " << var("QMAKE_MOVE") << endl; + t << "QMAKE = " << var("QMAKE_QMAKE") << Qt::endl; + t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << Qt::endl; + t << "CHK_DIR_EXISTS= " << var("QMAKE_CHK_DIR_EXISTS") << Qt::endl; + t << "MKDIR = " << var("QMAKE_MKDIR") << Qt::endl; + t << "COPY = " << var("QMAKE_COPY") << Qt::endl; + t << "COPY_FILE = " << var("QMAKE_COPY_FILE") << Qt::endl; + t << "COPY_DIR = " << var("QMAKE_COPY_DIR") << Qt::endl; + t << "INSTALL_FILE = " << var("QMAKE_INSTALL_FILE") << Qt::endl; + t << "INSTALL_PROGRAM = " << var("QMAKE_INSTALL_PROGRAM") << Qt::endl; + t << "INSTALL_DIR = " << var("QMAKE_INSTALL_DIR") << Qt::endl; + t << "QINSTALL = " << var("QMAKE_QMAKE") << " -install qinstall" << Qt::endl; + t << "QINSTALL_PROGRAM = " << var("QMAKE_QMAKE") << " -install qinstall -exe" << Qt::endl; + t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << Qt::endl; + t << "SYMLINK = " << var("QMAKE_SYMBOLIC_LINK") << Qt::endl; + t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << Qt::endl; + t << "MOVE = " << var("QMAKE_MOVE") << Qt::endl; } QString MakefileGenerator::buildArgs(bool withExtra) @@ -2349,18 +2349,18 @@ void MakefileGenerator::writeHeader(QTextStream &t) { t << "#############################################################################\n"; - t << "# Makefile for building: " << escapeFilePath(var("TARGET")) << endl; + t << "# Makefile for building: " << escapeFilePath(var("TARGET")) << Qt::endl; t << "# Generated by qmake (" QMAKE_VERSION_STR ") (Qt " QT_VERSION_STR ")\n"; - t << "# Project: " << fileFixify(project->projectFile()) << endl; - t << "# Template: " << var("TEMPLATE") << endl; + t << "# Project: " << fileFixify(project->projectFile()) << Qt::endl; + t << "# Template: " << var("TEMPLATE") << Qt::endl; if(!project->isActiveConfig("build_pass")) - t << "# Command: " << build_args().replace(QLatin1String("$(QMAKE)"), var("QMAKE_QMAKE")) << endl; + t << "# Command: " << build_args().replace(QLatin1String("$(QMAKE)"), var("QMAKE_QMAKE")) << Qt::endl; t << "#############################################################################\n"; - t << endl; + t << Qt::endl; QString ofile = Option::fixPathToTargetOS(Option::output.fileName()); if (ofile.lastIndexOf(Option::dir_sep) != -1) ofile.remove(0, ofile.lastIndexOf(Option::dir_sep) +1); - t << "MAKEFILE = " << escapeFilePath(ofile) << endl << endl; + t << "MAKEFILE = " << escapeFilePath(ofile) << Qt::endl << Qt::endl; t << "EQ = =\n\n"; } @@ -2492,7 +2492,7 @@ MakefileGenerator::writeSubDirs(QTextStream &t) void MakefileGenerator::writeSubMakeCall(QTextStream &t, const QString &callPrefix, const QString &makeArguments) { - t << callPrefix << "$(MAKE)" << makeArguments << endl; + t << callPrefix << "$(MAKE)" << makeArguments << Qt::endl; } void @@ -2517,14 +2517,14 @@ MakefileGenerator::writeSubTargets(QTextStream &t, QListvalues("QMAKE_EXTRA_INCLUDES"); for (ProStringList::ConstIterator qeui_it = qeui.begin(); qeui_it != qeui.end(); ++qeui_it) - t << "include " << (*qeui_it) << endl; + t << "include " << (*qeui_it) << Qt::endl; if (!(flags & SubTargetSkipDefaultVariables)) { writeDefaultVariables(t); t << "SUBTARGETS = "; // subtargets are sub-directory for(int target = 0; target < targets.size(); ++target) t << " \\\n\t\t" << targets.at(target)->target; - t << endl << endl; + t << Qt::endl << Qt::endl; } writeExtraVariables(t); @@ -2580,7 +2580,7 @@ MakefileGenerator::writeSubTargets(QTextStream &t, QListvalues(ProKey(*qut_it + ".depends")); for (ProStringList::ConstIterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) { @@ -2758,7 +2758,7 @@ MakefileGenerator::writeSubTargets(QTextStream &t, QListisEmpty("QMAKE_FAILED_REQUIREMENTS") && !project->isEmpty("QMAKE_INTERNAL_PRL_FILE")) { QStringList files = escapeFilePaths(fileFixify(Option::mkfile::project_files)); t << escapeDependencyPath(project->first("QMAKE_INTERNAL_PRL_FILE").toQString()) << ": \n\t" - << "@$(QMAKE) -prl " << files.join(' ') << ' ' << buildArgs(true) << endl; + << "@$(QMAKE) -prl " << files.join(' ') << ' ' << buildArgs(true) << Qt::endl; } QString qmake = build_args(); @@ -2795,10 +2795,10 @@ MakefileGenerator::writeMakeQmake(QTextStream &t, bool noDummyQmakeAll) } const ProStringList &included = escapeDependencyPaths(project->values("QMAKE_INTERNAL_INCLUDED_FILES")); t << included.join(QString(" \\\n\t\t")) << "\n\t" - << qmake << endl; + << qmake << Qt::endl; const ProStringList &extraCommands = project->values("QMAKE_MAKE_QMAKE_EXTRA_COMMANDS"); if (!extraCommands.isEmpty()) - t << "\t" << extraCommands.join(QString("\n\t")) << endl; + t << "\t" << extraCommands.join(QString("\n\t")) << Qt::endl; for(int include = 0; include < included.size(); ++include) { const ProString &i = included.at(include); if(!i.isEmpty()) @@ -2806,7 +2806,7 @@ MakefileGenerator::writeMakeQmake(QTextStream &t, bool noDummyQmakeAll) } } if(project->first("QMAKE_ORIG_TARGET") != "qmake") { - t << "qmake: FORCE\n\t@" << qmake << endl << endl; + t << "qmake: FORCE\n\t@" << qmake << Qt::endl << Qt::endl; if (!noDummyQmakeAll) t << "qmake_all: FORCE\n\n"; } @@ -3298,11 +3298,11 @@ MakefileGenerator::writePkgConfigFile() if(includeDir.isEmpty()) includeDir = prefix + "/include"; - t << "prefix=" << prefix << endl; + t << "prefix=" << prefix << Qt::endl; t << "exec_prefix=${prefix}\n" << "libdir=" << pkgConfigFixPath(libDir) << "\n" - << "includedir=" << pkgConfigFixPath(includeDir) << endl; - t << endl; + << "includedir=" << pkgConfigFixPath(includeDir) << Qt::endl; + t << Qt::endl; //extra PKGCONFIG variables const ProStringList &pkgconfig_vars = project->values("QMAKE_PKGCONFIG_VARIABLES"); @@ -3323,17 +3323,17 @@ MakefileGenerator::writePkgConfigFile() } } if (!val.isEmpty()) - t << var << "=" << val << endl; + t << var << "=" << val << Qt::endl; } - t << endl; + t << Qt::endl; QString name = project->first("QMAKE_PKGCONFIG_NAME").toQString(); if(name.isEmpty()) { name = project->first("QMAKE_ORIG_TARGET").toQString().toLower(); name.replace(0, 1, name[0].toUpper()); } - t << "Name: " << name << endl; + t << "Name: " << name << Qt::endl; QString desc = project->values("QMAKE_PKGCONFIG_DESCRIPTION").join(' '); if(desc.isEmpty()) { if(name.isEmpty()) { @@ -3351,12 +3351,12 @@ MakefileGenerator::writePkgConfigFile() desc += " Application"; } } - t << "Description: " << desc << endl; + t << "Description: " << desc << Qt::endl; ProString version = project->first("QMAKE_PKGCONFIG_VERSION"); if (version.isEmpty()) version = project->first("VERSION"); if (!version.isEmpty()) - t << "Version: " << version << endl; + t << "Version: " << version << Qt::endl; // libs t << "Libs: "; @@ -3393,7 +3393,7 @@ MakefileGenerator::writePkgConfigFile() t << "Libs.private:"; for (ProStringList::ConstIterator it = libs.cbegin(); it != libs.cend(); ++it) t << ' ' << fixLibFlags((*it).toKey()).join(' '); - t << endl; + t << Qt::endl; } // flags @@ -3411,15 +3411,15 @@ MakefileGenerator::writePkgConfigFile() && libDir != QLatin1String("/Library/Frameworks")) { t << " -F${libdir}"; } - t << endl; + t << Qt::endl; // requires const QString requires = project->values("QMAKE_PKGCONFIG_REQUIRES").join(' '); if (!requires.isEmpty()) { - t << "Requires: " << requires << endl; + t << "Requires: " << requires << Qt::endl; } - t << endl; + t << Qt::endl; } static QString windowsifyPath(const QString &str) diff --git a/qmake/generators/projectgenerator.cpp b/qmake/generators/projectgenerator.cpp index ef34955eb1..f729ec89ef 100644 --- a/qmake/generators/projectgenerator.cpp +++ b/qmake/generators/projectgenerator.cpp @@ -324,14 +324,14 @@ ProjectGenerator::init() bool ProjectGenerator::writeMakefile(QTextStream &t) { - t << "######################################################################" << endl; - t << "# Automatically generated by qmake (" QMAKE_VERSION_STR ") " << QDateTime::currentDateTime().toString() << endl; - t << "######################################################################" << endl << endl; + t << "######################################################################" << Qt::endl; + t << "# Automatically generated by qmake (" QMAKE_VERSION_STR ") " << QDateTime::currentDateTime().toString() << Qt::endl; + t << "######################################################################" << Qt::endl << Qt::endl; if (!Option::globals->extra_cmds[QMakeEvalBefore].isEmpty()) - t << Option::globals->extra_cmds[QMakeEvalBefore] << endl; + t << Option::globals->extra_cmds[QMakeEvalBefore] << Qt::endl; t << getWritableVar("TEMPLATE_ASSIGN", false); if(project->first("TEMPLATE_ASSIGN") == "subdirs") { - t << endl << "# Directories" << "\n" + t << Qt::endl << "# Directories" << "\n" << getWritableVar("SUBDIRS"); } else { //figure out target @@ -343,7 +343,7 @@ ProjectGenerator::writeMakefile(QTextStream &t) t << getWritableVar("TARGET_ASSIGN") << getWritableVar("CONFIG", false) << getWritableVar("CONFIG_REMOVE", false) - << getWritableVar("INCLUDEPATH") << endl; + << getWritableVar("INCLUDEPATH") << Qt::endl; t << "# You can make your code fail to compile if you use deprecated APIs.\n" "# In order to do so, uncomment the following line.\n" @@ -362,7 +362,7 @@ ProjectGenerator::writeMakefile(QTextStream &t) << getWritableVar("TRANSLATIONS"); } if (!Option::globals->extra_cmds[QMakeEvalAfter].isEmpty()) - t << Option::globals->extra_cmds[QMakeEvalAfter] << endl; + t << Option::globals->extra_cmds[QMakeEvalAfter] << Qt::endl; return true; } diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp index 7d8c70ec3b..a384439aac 100644 --- a/qmake/generators/unix/unixmake2.cpp +++ b/qmake/generators/unix/unixmake2.cpp @@ -83,8 +83,8 @@ void UnixMakefileGenerator::writeDefaultVariables(QTextStream &t) { MakefileGenerator::writeDefaultVariables(t); - t << "TAR = " << var("QMAKE_TAR") << endl; - t << "COMPRESS = " << var("QMAKE_GZIP") << endl; + t << "TAR = " << var("QMAKE_TAR") << Qt::endl; + t << "COMPRESS = " << var("QMAKE_GZIP") << Qt::endl; if (project->isEmpty("QMAKE_DISTNAME")) { ProString distname = project->first("QMAKE_ORIG_TARGET"); @@ -92,13 +92,13 @@ UnixMakefileGenerator::writeDefaultVariables(QTextStream &t) distname += project->first("VERSION"); project->values("QMAKE_DISTNAME") = distname; } - t << "DISTNAME = " << fileVar("QMAKE_DISTNAME") << endl; + t << "DISTNAME = " << fileVar("QMAKE_DISTNAME") << Qt::endl; if (project->isEmpty("QMAKE_DISTDIR")) project->values("QMAKE_DISTDIR") = project->first("QMAKE_DISTNAME"); t << "DISTDIR = " << escapeFilePath(fileFixify( (project->isEmpty("OBJECTS_DIR") ? ProString(".tmp/") : project->first("OBJECTS_DIR")) + project->first("QMAKE_DISTDIR"), - FileFixifyFromOutdir | FileFixifyAbsolute)) << endl; + FileFixifyFromOutdir | FileFixifyAbsolute)) << Qt::endl; } void @@ -106,10 +106,10 @@ UnixMakefileGenerator::writeSubTargets(QTextStream &t, QListfirst("QMAKE_ABSOLUTE_SOURCE_PATH").toQString(); for (int target = 0; target < targets.size(); ++target) { @@ -151,7 +151,7 @@ UnixMakefileGenerator::writeSubTargets(QTextStream &t, QListtarget << "-distdir: FORCE"; writeSubTargetCall(t, in_directory, in, out_directory, escapeFilePath(out), out_directory_cdin, makefilein); - t << endl; + t << Qt::endl; } } @@ -183,11 +183,11 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) writeExportedVariables(t); t << "####### Compiler, tools and options\n\n"; - t << "CC = " << var("QMAKE_CC") << endl; - t << "CXX = " << var("QMAKE_CXX") << endl; + t << "CC = " << var("QMAKE_CC") << Qt::endl; + t << "CXX = " << var("QMAKE_CXX") << Qt::endl; t << "DEFINES = " << varGlue("PRL_EXPORT_DEFINES","-D"," -D"," ") - << varGlue("DEFINES","-D"," -D","") << endl; + << varGlue("DEFINES","-D"," -D","") << Qt::endl; t << "CFLAGS = " << var("QMAKE_CFLAGS") << " $(DEFINES)\n"; t << "CXXFLAGS = " << var("QMAKE_CXXFLAGS") << " $(DEFINES)\n"; t << "INCPATH ="; @@ -208,38 +208,38 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) } if(!project->isEmpty("QMAKE_FRAMEWORKPATH_FLAGS")) t << " " << var("QMAKE_FRAMEWORKPATH_FLAGS"); - t << endl; + t << Qt::endl; writeDefaultVariables(t); if(!project->isActiveConfig("staticlib")) { - t << "LINK = " << var("QMAKE_LINK") << endl; - t << "LFLAGS = " << var("QMAKE_LFLAGS") << endl; + t << "LINK = " << var("QMAKE_LINK") << Qt::endl; + t << "LFLAGS = " << var("QMAKE_LFLAGS") << Qt::endl; t << "LIBS = $(SUBLIBS) " << fixLibFlags("LIBS").join(' ') << ' ' << fixLibFlags("LIBS_PRIVATE").join(' ') << ' ' << fixLibFlags("QMAKE_LIBS").join(' ') << ' ' - << fixLibFlags("QMAKE_LIBS_PRIVATE").join(' ') << endl; + << fixLibFlags("QMAKE_LIBS_PRIVATE").join(' ') << Qt::endl; } - t << "AR = " << var("QMAKE_AR") << endl; - t << "RANLIB = " << var("QMAKE_RANLIB") << endl; - t << "SED = " << var("QMAKE_STREAM_EDITOR") << endl; - t << "STRIP = " << var("QMAKE_STRIP") << endl; + t << "AR = " << var("QMAKE_AR") << Qt::endl; + t << "RANLIB = " << var("QMAKE_RANLIB") << Qt::endl; + t << "SED = " << var("QMAKE_STREAM_EDITOR") << Qt::endl; + t << "STRIP = " << var("QMAKE_STRIP") << Qt::endl; - t << endl; + t << Qt::endl; t << "####### Output directory\n\n"; // This is used in commands by some .prf files. if (! project->values("OBJECTS_DIR").isEmpty()) - t << "OBJECTS_DIR = " << fileVar("OBJECTS_DIR") << endl; + t << "OBJECTS_DIR = " << fileVar("OBJECTS_DIR") << Qt::endl; else t << "OBJECTS_DIR = ./\n"; - t << endl; + t << Qt::endl; /* files */ t << "####### Files\n\n"; // This is used by the dist target. - t << "SOURCES = " << fileVarList("SOURCES") << ' ' << fileVarList("GENERATED_SOURCES") << endl; + t << "SOURCES = " << fileVarList("SOURCES") << ' ' << fileVarList("GENERATED_SOURCES") << Qt::endl; if(do_incremental) { const ProStringList &objs = project->values("OBJECTS"); const ProStringList &incrs = project->values("QMAKE_INCREMENTAL"); @@ -259,59 +259,59 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) t << "\\\n\t\t" << (*objit); } if(incrs_out.count() == objs.count()) { //we just switched places, no real incrementals to be done! - t << escapeFilePaths(incrs_out).join(QString(" \\\n\t\t")) << endl; + t << escapeFilePaths(incrs_out).join(QString(" \\\n\t\t")) << Qt::endl; } else if(!incrs_out.count()) { - t << endl; + t << Qt::endl; } else { src_incremental = true; - t << endl; + t << Qt::endl; t << "INCREMENTAL_OBJECTS = " - << escapeFilePaths(incrs_out).join(QString(" \\\n\t\t")) << endl; + << escapeFilePaths(incrs_out).join(QString(" \\\n\t\t")) << Qt::endl; } } else { // Used all over the place in both deps and commands. - t << "OBJECTS = " << valList(escapeDependencyPaths(project->values("OBJECTS"))) << endl; + t << "OBJECTS = " << valList(escapeDependencyPaths(project->values("OBJECTS"))) << Qt::endl; } if(do_incremental && !src_incremental) do_incremental = false; t << "DIST = " << valList(fileFixify(project->values("DISTFILES").toQStringList())) << " " - << fileVarList("HEADERS") << ' ' << fileVarList("SOURCES") << endl; - t << "QMAKE_TARGET = " << fileVar("QMAKE_ORIG_TARGET") << endl; + << fileVarList("HEADERS") << ' ' << fileVarList("SOURCES") << Qt::endl; + t << "QMAKE_TARGET = " << fileVar("QMAKE_ORIG_TARGET") << Qt::endl; QString destd = fileVar("DESTDIR"); // When building on non-MSys MinGW, the path ends with a backslash, which // GNU make will interpret that as a line continuation. Doubling the backslash // avoids the problem, at the cost of the variable containing *both* backslashes. if (destd.endsWith('\\')) destd += '\\'; - t << "DESTDIR = " << destd << endl; - t << "TARGET = " << fileVar("TARGET") << endl; + t << "DESTDIR = " << destd << Qt::endl; + t << "TARGET = " << fileVar("TARGET") << Qt::endl; if(project->isActiveConfig("plugin")) { - t << "TARGETD = " << fileVar("TARGET") << endl; + t << "TARGETD = " << fileVar("TARGET") << Qt::endl; } else if(!project->isActiveConfig("staticlib") && project->values("QMAKE_APP_FLAG").isEmpty()) { - t << "TARGETA = " << fileVar("TARGETA") << endl; + t << "TARGETA = " << fileVar("TARGETA") << Qt::endl; if(!project->isEmpty("QMAKE_BUNDLE")) { - t << "TARGETD = " << fileVar("TARGET_x.y") << endl; - t << "TARGET0 = " << fileVar("TARGET_") << endl; + t << "TARGETD = " << fileVar("TARGET_x.y") << Qt::endl; + t << "TARGET0 = " << fileVar("TARGET_") << Qt::endl; } else if (!project->isActiveConfig("unversioned_libname")) { - t << "TARGET0 = " << fileVar("TARGET_") << endl; + t << "TARGET0 = " << fileVar("TARGET_") << Qt::endl; if (project->isEmpty("QMAKE_HPUX_SHLIB")) { - t << "TARGETD = " << fileVar("TARGET_x.y.z") << endl; - t << "TARGET1 = " << fileVar("TARGET_x") << endl; - t << "TARGET2 = " << fileVar("TARGET_x.y") << endl; + t << "TARGETD = " << fileVar("TARGET_x.y.z") << Qt::endl; + t << "TARGET1 = " << fileVar("TARGET_x") << Qt::endl; + t << "TARGET2 = " << fileVar("TARGET_x.y") << Qt::endl; } else { - t << "TARGETD = " << fileVar("TARGET_x") << endl; + t << "TARGETD = " << fileVar("TARGET_x") << Qt::endl; } } } writeExtraCompilerVariables(t); writeExtraVariables(t); - t << endl; + t << Qt::endl; // blasted includes const ProStringList &qeui = project->values("QMAKE_EXTRA_INCLUDES"); ProStringList::ConstIterator it; for(it = qeui.begin(); it != qeui.end(); ++it) - t << "include " << escapeDependencyPath(*it) << endl; + t << "include " << escapeDependencyPath(*it) << Qt::endl; /* rules */ t << "first:" << (!project->isActiveConfig("no_default_goal_deps") ? " all" : "") << "\n"; @@ -321,7 +321,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) ProStringList objects = project->values("OBJECTS"); for (ProStringList::Iterator it = objects.begin(); it != objects.end(); ++it) { QString d_file = (*it).toQString().replace(QRegExp(Option::obj_ext + "$"), ".d"); - t << "-include " << escapeDependencyPath(d_file) << endl; + t << "-include " << escapeDependencyPath(d_file) << Qt::endl; project->values("QMAKE_DISTCLEAN") << d_file; } } else { @@ -379,8 +379,8 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) QStringList deps = findDependencies((*it).toQString()).filter(QRegExp( "((^|/)" + Option::h_moc_mod + "|" + Option::cpp_moc_ext + "$)")); if(!deps.isEmpty()) - t << d_file_d << ": " << finalizeDependencyPaths(deps).join(' ') << endl; - t << "-include " << d_file_d << endl; + t << d_file_d << ": " << finalizeDependencyPaths(deps).join(' ') << Qt::endl; + t << "-include " << d_file_d << Qt::endl; project->values("QMAKE_DISTCLEAN") += d_file; } } @@ -399,7 +399,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) for (ProStringList::ConstIterator it = l.begin(); it != l.end(); ++it) t << escapeFilePath(libdir + project->first("QMAKE_PREFIX_STATICLIB") + (*it) + '.' + project->first("QMAKE_EXTENSION_STATICLIB")) << ' '; - t << endl << endl; + t << Qt::endl << Qt::endl; } QString target_deps; if ((project->isActiveConfig("depend_prl") || project->isActiveConfig("fast_depend_prl")) @@ -504,7 +504,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) t << "$(LINK) $(LFLAGS) " << var("QMAKE_LINK_O_FLAG") << "$(TARGET) " << incr_deps << " " << incr_objs << " $(OBJCOMP) $(LIBS)"; if(!project->isEmpty("QMAKE_POST_LINK")) t << "\n\t" << var("QMAKE_POST_LINK"); - t << endl << endl; + t << Qt::endl << Qt::endl; } else { t << depVar("TARGET") << ": " << depVar("PRE_TARGETDEPS") << " $(OBJECTS) " << target_deps << ' ' << depVar("POST_TARGETDEPS") << "\n\t"; @@ -517,7 +517,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) if (!project->isEmpty("QMAKE_POST_LINK")) t << "\n\t" << var("QMAKE_POST_LINK"); } - t << endl << endl; + t << Qt::endl << Qt::endl; } allDeps = ' ' + depVar("TARGET"); } else if(!project->isActiveConfig("staticlib")) { @@ -548,7 +548,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) //actual target const QString link_deps = "$(OBJECTS) "; t << incr_target_dir_d << ": " << link_deps << "\n\t" - << "ld -r -o " << incr_target_dir_f << ' ' << link_deps << endl; + << "ld -r -o " << incr_target_dir_f << ' ' << link_deps << Qt::endl; //communicated below ProStringList &cmd = project->values("QMAKE_LINK_SHLIB_CMD"); cmd[0] = cmd.at(0).toQString().replace(QLatin1String("$(OBJECTS) "), QLatin1String("$(INCREMENTAL_OBJECTS)")); //ick @@ -606,7 +606,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) << "-$(MOVE) $(TARGET) " << destdir << "$(TARGET)"; if(!project->isEmpty("QMAKE_POST_LINK")) t << "\n\t" << var("QMAKE_POST_LINK"); - t << endl << endl; + t << Qt::endl << Qt::endl; } else if(!project->isEmpty("QMAKE_BUNDLE")) { bundledFiles << destdir_r + var("TARGET"); t << "\n\t" @@ -620,7 +620,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) " Versions/Current/$(TARGET) $(DESTDIR)$(TARGET0)") << "\n\t"; if(!project->isEmpty("QMAKE_POST_LINK")) t << "\n\t" << var("QMAKE_POST_LINK"); - t << endl << endl; + t << Qt::endl << Qt::endl; } else if(project->isEmpty("QMAKE_HPUX_SHLIB")) { t << "\n\t"; @@ -654,7 +654,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) } if(!project->isEmpty("QMAKE_POST_LINK")) t << "\n\t" << var("QMAKE_POST_LINK"); - t << endl << endl; + t << Qt::endl << Qt::endl; } else { t << "\n\t" << "-$(DEL_FILE) $(TARGET) $(TARGET0)\n\t" @@ -668,9 +668,9 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) << "-$(MOVE) $(TARGET0) " << destdir << "$(TARGET0)\n\t"; if(!project->isEmpty("QMAKE_POST_LINK")) t << "\n\t" << var("QMAKE_POST_LINK"); - t << endl << endl; + t << Qt::endl << Qt::endl; } - t << endl << endl; + t << Qt::endl << Qt::endl; if (! project->isActiveConfig("plugin")) { t << "staticlib: " << depVar("TARGETA") << "\n\n"; @@ -688,7 +688,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) t << "\n\t" << var("QMAKE_POST_LINK"); if(!project->isEmpty("QMAKE_RANLIB")) t << "\n\t$(RANLIB) $(TARGETA)"; - t << endl << endl; + t << Qt::endl << Qt::endl; } } else { QString destdir_r = project->first("DESTDIR").toQString(); @@ -708,7 +708,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) t << "\t" << var("QMAKE_POST_LINK") << "\n"; if (!project->isEmpty("QMAKE_RANLIB")) t << "\t$(RANLIB) " << destdir << "$(TARGET)\n"; - t << endl << endl; + t << Qt::endl << Qt::endl; } writeMakeQmake(t); @@ -722,7 +722,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) } if(!meta_files.isEmpty()) t << escapeDependencyPaths(meta_files).join(" ") << ": \n\t" - << "@$(QMAKE) -prl " << escapeFilePath(project->projectFile()) << ' ' << buildArgs(true) << endl; + << "@$(QMAKE) -prl " << escapeFilePath(project->projectFile()) << ' ' << buildArgs(true) << Qt::endl; } if (!project->isEmpty("QMAKE_BUNDLE")) { @@ -743,7 +743,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) << "@echo \"APPL" << (project->isEmpty("QMAKE_PKGINFO_TYPEINFO") ? QString::fromLatin1("????") : project->first("QMAKE_PKGINFO_TYPEINFO").left(4)) - << "\" > " << pkginfo_f << endl; + << "\" > " << pkginfo_f << Qt::endl; } if (!project->first("QMAKE_BUNDLE_RESOURCE_FILE").isEmpty()) { ProString resources = project->first("QMAKE_BUNDLE_RESOURCE_FILE"); @@ -852,7 +852,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) << "-e \"s,\\$${EXECUTABLE_NAME}," << (app_bundle_name.isEmpty() ? app_bundle_name : plugin_bundle_name) << ",g\" " << "-e \"s,@TYPEINFO@,"<< typeInfo << ",g\" " << "-e \"s,\\$${QMAKE_PKGINFO_TYPEINFO},"<< typeInfo << ",g\" " - << "" << info_plist << " >" << info_plist_out << endl; + << "" << info_plist << " >" << info_plist_out << Qt::endl; //copy the icon if (!project->isEmpty("ICON")) { QString dir = bundle_dir + "Contents/Resources/"; @@ -863,7 +863,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) t << escapeDependencyPath(icon_path) << ": " << escapeDependencyPath(icon) << "\n\t" << mkdir_p_asstring(dir) << "\n\t" << "@$(DEL_FILE) " << icon_path_f << "\n\t" - << "@$(COPY_FILE) " << escapeFilePath(icon) << ' ' << icon_path_f << endl; + << "@$(COPY_FILE) " << escapeFilePath(icon) << ' ' << icon_path_f << Qt::endl; } } else { ProString lib_bundle_name = var("QMAKE_FRAMEWORK_BUNDLE_NAME"); @@ -880,7 +880,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) << "-e \"s,\\$${EXECUTABLE_NAME}," << lib_bundle_name << ",g\" " << "-e \"s,@TYPEINFO@," << typeInfo << ",g\" " << "-e \"s,\\$${QMAKE_PKGINFO_TYPEINFO}," << typeInfo << ",g\" " - << "" << info_plist << " >" << info_plist_out << endl; + << "" << info_plist << " >" << info_plist_out << Qt::endl; } break; } // project->isActiveConfig("no_plist") @@ -924,10 +924,10 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) QFileInfo fi(fileInfo(fn)); if(fi.isDir()) t << "@$(DEL_FILE) -r " << dst << "\n\t" - << "@$(COPY_DIR) " << src << " " << dst << endl; + << "@$(COPY_DIR) " << src << " " << dst << Qt::endl; else t << "@$(DEL_FILE) " << dst << "\n\t" - << "@$(COPY_FILE) " << src << " " << dst << endl; + << "@$(COPY_FILE) " << src << " " << dst << Qt::endl; } } } @@ -940,7 +940,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) alldeps << symIt.key(); t << escapeDependencyPath(symIt.key()) << ":\n\t" << mkdir_p_asstring(bundle_dir) << "\n\t" - << "@$(SYMLINK) " << escapeFilePath(symIt.value()) << ' ' << bundle_dir_f << endl; + << "@$(SYMLINK) " << escapeFilePath(symIt.value()) << ' ' << bundle_dir_f << Qt::endl; } if (!project->isActiveConfig("shallow_bundle")) { @@ -952,24 +952,24 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) << mkdir_p_asstring(bundle_dir + "Versions") << "\n\t" << "@-$(DEL_FILE) " << currentLink_f << "\n\t" << "@$(SYMLINK) " << project->first("QMAKE_FRAMEWORK_VERSION") - << ' ' << currentLink_f << endl; + << ' ' << currentLink_f << Qt::endl; } } } - t << endl << "all: " << deps + t << Qt::endl << "all: " << deps << valGlue(escapeDependencyPaths(project->values("ALL_DEPS")), " \\\n\t\t", " \\\n\t\t", "") - << allDeps << endl << endl; + << allDeps << Qt::endl << Qt::endl; t << "dist: distdir FORCE\n\t"; t << "(cd `dirname $(DISTDIR)` && $(TAR) $(DISTNAME).tar $(DISTNAME) && $(COMPRESS) $(DISTNAME).tar)" " && $(MOVE) `dirname $(DISTDIR)`" << Option::dir_sep << "$(DISTNAME).tar.gz ." " && $(DEL_FILE) -r $(DISTDIR)"; - t << endl << endl; + t << Qt::endl << Qt::endl; t << "distdir: FORCE\n\t" << mkdir_p_asstring("$(DISTDIR)", false) << "\n\t" - << "$(COPY_FILE) --parents $(DIST) $(DISTDIR)" << Option::dir_sep << endl; + << "$(COPY_FILE) --parents $(DIST) $(DISTDIR)" << Option::dir_sep << Qt::endl; if(!project->isEmpty("QMAKE_EXTRA_COMPILERS")) { const ProStringList &quc = project->values("QMAKE_EXTRA_COMPILERS"); for (ProStringList::ConstIterator it = quc.begin(); it != quc.end(); ++it) { @@ -979,20 +979,20 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) if(val.isEmpty()) continue; t << "\t$(COPY_FILE) --parents " << escapeFilePaths(val).join(' ') - << " $(DISTDIR)" << Option::dir_sep << endl; + << " $(DISTDIR)" << Option::dir_sep << Qt::endl; } } } if(!project->isEmpty("TRANSLATIONS")) - t << "\t$(COPY_FILE) --parents " << fileVar("TRANSLATIONS") << " $(DISTDIR)" << Option::dir_sep << endl; - t << endl << endl; + t << "\t$(COPY_FILE) --parents " << fileVar("TRANSLATIONS") << " $(DISTDIR)" << Option::dir_sep << Qt::endl; + t << Qt::endl << Qt::endl; QString clean_targets = " compiler_clean " + depVar("CLEAN_DEPS"); if(do_incremental) { t << "incrclean:\n"; if(src_incremental) t << "\t-$(DEL_FILE) $(INCREMENTAL_OBJECTS)\n"; - t << endl; + t << Qt::endl; } t << "clean:" << clean_targets << "\n\t"; @@ -1060,7 +1060,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) t << "-$(DEL_FILE) $(INCREMENTAL_OBJECTS)\n\t"; t << fileVarGlue("QMAKE_CLEAN","-$(DEL_FILE) "," ","\n\t") << "-$(DEL_FILE) *~ core *.core\n" - << fileVarGlue("CLEAN_FILES","\t-$(DEL_FILE) "," ","") << endl << endl; + << fileVarGlue("CLEAN_FILES","\t-$(DEL_FILE) "," ","") << Qt::endl << Qt::endl; ProString destdir = project->first("DESTDIR"); if (!destdir.isEmpty() && !destdir.endsWith(Option::dir_sep)) @@ -1068,7 +1068,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) t << "distclean: clean " << depVar("DISTCLEAN_DEPS") << '\n'; if(!project->isEmpty("QMAKE_BUNDLE")) { QString bundlePath = escapeFilePath(destdir + project->first("QMAKE_BUNDLE")); - t << "\t-$(DEL_FILE) -r " << bundlePath << endl; + t << "\t-$(DEL_FILE) -r " << bundlePath << Qt::endl; } else if (project->isActiveConfig("staticlib") || project->isActiveConfig("plugin")) { t << "\t-$(DEL_FILE) " << escapeFilePath(destdir) << "$(TARGET) \n"; } else if (project->values("QMAKE_APP_FLAG").isEmpty()) { @@ -1087,9 +1087,9 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) { QString ofile = fileFixify(Option::output.fileName()); if(!ofile.isEmpty()) - t << "\t-$(DEL_FILE) " << escapeFilePath(ofile) << endl; + t << "\t-$(DEL_FILE) " << escapeFilePath(ofile) << Qt::endl; } - t << endl << endl; + t << Qt::endl << Qt::endl; t << "####### Sub-libraries\n\n"; if (!project->values("SUBLIBS").isEmpty()) { @@ -1100,7 +1100,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) for (it = l.begin(); it != l.end(); ++it) t << escapeDependencyPath(libdir + project->first("QMAKE_PREFIX_STATICLIB") + (*it) + '.' + project->first("QMAKE_EXTENSION_STATICLIB")) << ":\n\t" - << var(ProKey("MAKELIB" + *it)) << endl << endl; + << var(ProKey("MAKELIB" + *it)) << Qt::endl << Qt::endl; } if(doPrecompiledHeaders() && !project->isEmpty("PRECOMPILED_HEADER")) { @@ -1184,7 +1184,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) compilerExecutable = "$(CXX)"; // compile command - t << "\n\t" << compilerExecutable << cflags << " $(INCPATH) " << pchArchFlags << endl << endl; + t << "\n\t" << compilerExecutable << cflags << " $(INCPATH) " << pchArchFlags << Qt::endl << Qt::endl; } } } diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp index de7363e51b..eb771a695a 100644 --- a/qmake/generators/win32/mingw_make.cpp +++ b/qmake/generators/win32/mingw_make.cpp @@ -99,7 +99,7 @@ bool MingwMakefileGenerator::writeMakefile(QTextStream &t) writePkgConfigFile(); if(Option::mkfile::do_stub_makefile) { - t << "QMAKE = " << var("QMAKE_QMAKE") << endl; + t << "QMAKE = " << var("QMAKE_QMAKE") << Qt::endl; const ProStringList &qut = project->values("QMAKE_EXTRA_TARGETS"); for (ProStringList::ConstIterator it = qut.begin(); it != qut.end(); ++it) t << escapeDependencyPath(*it) << ' '; @@ -148,7 +148,7 @@ void createLdResponseFile(const QString &fileName, const ProStringList &objList) .replace(QLatin1Char('\t'), QLatin1String("\\\t")) .replace(QLatin1Char('"'), QLatin1String("\\\"")) .replace(QLatin1Char('\''), QLatin1String("\\'")); - t << path << endl; + t << path << Qt::endl; } t.flush(); file.close(); @@ -162,9 +162,9 @@ void createArObjectScriptFile(const QString &fileName, const QString &target, co if (file.open(QIODevice::WriteOnly | QIODevice::Text)) { QTextStream t(&file); // ### quoting? - t << "CREATE " << target << endl; + t << "CREATE " << target << Qt::endl; for (ProStringList::ConstIterator it = objList.constBegin(); it != objList.constEnd(); ++it) { - t << "ADDMOD " << *it << endl; + t << "ADDMOD " << *it << Qt::endl; } t << "SAVE\n"; t.flush(); @@ -183,13 +183,13 @@ void MingwMakefileGenerator::writeMingwParts(QTextStream &t) << finalizeDependencyPaths(findDependencies(header)).join(" \\\n\t\t") << "\n\t" << mkdir_p_asstring(preCompHeaderOut) << "\n\t$(CC) -x c-header -c $(CFLAGS) $(INCPATH) -o " << escapeFilePath(cHeader) - << ' ' << escapeFilePath(header) << endl << endl; + << ' ' << escapeFilePath(header) << Qt::endl << Qt::endl; QString cppHeader = preCompHeaderOut + Option::dir_sep + "c++"; t << escapeDependencyPath(cppHeader) << ": " << escapeDependencyPath(header) << " " << finalizeDependencyPaths(findDependencies(header)).join(" \\\n\t\t") << "\n\t" << mkdir_p_asstring(preCompHeaderOut) << "\n\t$(CXX) -x c++-header -c $(CXXFLAGS) $(INCPATH) -o " << escapeFilePath(cppHeader) - << ' ' << escapeFilePath(header) << endl << endl; + << ' ' << escapeFilePath(header) << Qt::endl << Qt::endl; } } @@ -274,21 +274,21 @@ void MingwMakefileGenerator::writeIncPart(QTextStream &t) t << "-I"; t << escapeFilePath(inc) << ' '; } - t << endl; + t << Qt::endl; } void MingwMakefileGenerator::writeLibsPart(QTextStream &t) { if(project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") { - t << "LIB = " << var("QMAKE_LIB") << endl; + t << "LIB = " << var("QMAKE_LIB") << Qt::endl; } else { - t << "LINKER = " << var("QMAKE_LINK") << endl; - t << "LFLAGS = " << var("QMAKE_LFLAGS") << endl; + t << "LINKER = " << var("QMAKE_LINK") << Qt::endl; + t << "LFLAGS = " << var("QMAKE_LFLAGS") << Qt::endl; t << "LIBS = " << fixLibFlags("LIBS").join(' ') << ' ' << fixLibFlags("LIBS_PRIVATE").join(' ') << ' ' << fixLibFlags("QMAKE_LIBS").join(' ') << ' ' - << fixLibFlags("QMAKE_LIBS_PRIVATE").join(' ') << endl; + << fixLibFlags("QMAKE_LIBS_PRIVATE").join(' ') << Qt::endl; } } @@ -350,7 +350,7 @@ void MingwMakefileGenerator::writeBuildRulesPart(QTextStream &t) } if(!project->isEmpty("QMAKE_POST_LINK")) t << "\n\t" <isActiveConfig("no_batch"); QSet source_directories; @@ -393,9 +393,9 @@ void NmakeMakefileGenerator::writeImplicitRulesPart(QTextStream &t) } } else { for(QStringList::Iterator cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) - t << (*cppit) << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; + t << (*cppit) << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CXX_IMP") << Qt::endl << Qt::endl; for(QStringList::Iterator cit = Option::c_ext.begin(); cit != Option::c_ext.end(); ++cit) - t << (*cit) << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl; + t << (*cit) << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CC_IMP") << Qt::endl << Qt::endl; } } @@ -498,7 +498,7 @@ void NmakeMakefileGenerator::writeBuildRulesPart(QTextStream &t) if(!project->isEmpty("QMAKE_POST_LINK")) { t << "\n\t" << var("QMAKE_POST_LINK"); } - t << endl; + t << Qt::endl; } void NmakeMakefileGenerator::writeLinkCommand(QTextStream &t, const QString &extraFlags, const QString &extraInlineFileContent) diff --git a/qmake/generators/win32/msvc_objectmodel.h b/qmake/generators/win32/msvc_objectmodel.h index b356f1bb73..33eff0d914 100644 --- a/qmake/generators/win32/msvc_objectmodel.h +++ b/qmake/generators/win32/msvc_objectmodel.h @@ -923,7 +923,7 @@ struct VCFilterFile inline QDebug operator<<(QDebug dbg, const VCFilterFile &p) { dbg.nospace() << "VCFilterFile(file(" << p.file - << ") excludeFromBuild(" << p.excludeFromBuild << "))" << endl; + << ") excludeFromBuild(" << p.excludeFromBuild << "))" << Qt::endl; return dbg.space(); } #endif diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp index 16f9361d13..8ee86ac395 100644 --- a/qmake/generators/win32/winmakefile.cpp +++ b/qmake/generators/win32/winmakefile.cpp @@ -320,11 +320,11 @@ void Win32MakefileGenerator::processRcFileVar() int rcCodePage = project->intValue("RC_CODEPAGE", 1200); // default: Unicode ts << "#include \n"; - ts << endl; + ts << Qt::endl; if (!rcIcons.isEmpty()) { for (int i = 0; i < rcIcons.size(); ++i) - ts << QString("IDI_ICON%1\tICON\tDISCARDABLE\t%2").arg(i + 1).arg(cQuoted(rcIcons[i])) << endl; - ts << endl; + ts << QString("IDI_ICON%1\tICON\tDISCARDABLE\t%2").arg(i + 1).arg(cQuoted(rcIcons[i])) << Qt::endl; + ts << Qt::endl; } if (!manifestFile.isEmpty()) { QString manifestResourceId; @@ -335,8 +335,8 @@ void Win32MakefileGenerator::processRcFileVar() ts << manifestResourceId << " RT_MANIFEST \"" << manifestFile << "\"\n"; } ts << "VS_VERSION_INFO VERSIONINFO\n"; - ts << "\tFILEVERSION " << QString(versionString).replace(".", ",") << endl; - ts << "\tPRODUCTVERSION " << QString(versionString).replace(".", ",") << endl; + ts << "\tFILEVERSION " << QString(versionString).replace(".", ",") << Qt::endl; + ts << "\tPRODUCTVERSION " << QString(versionString).replace(".", ",") << Qt::endl; ts << "\tFILEFLAGSMASK 0x3fL\n"; ts << "#ifdef _DEBUG\n"; ts << "\tFILEFLAGS VS_FF_DEBUG\n"; @@ -369,11 +369,11 @@ void Win32MakefileGenerator::processRcFileVar() ts << "\t\tBEGIN\n"; ts << "\t\t\tVALUE \"Translation\", " << QString("0x%1").arg(rcLang, 4, 16, QLatin1Char('0')) - << ", " << QString("%1").arg(rcCodePage, 4) << endl; + << ", " << QString("%1").arg(rcCodePage, 4) << Qt::endl; ts << "\t\tEND\n"; ts << "\tEND\n"; ts << "/* End of Version info */\n"; - ts << endl; + ts << Qt::endl; ts.flush(); @@ -470,7 +470,7 @@ void Win32MakefileGenerator::writeCleanParts(QTextStream &t) } } } - t << endl << endl; + t << Qt::endl << Qt::endl; t << "distclean: clean " << depVar("DISTCLEAN_DEPS"); { @@ -503,9 +503,9 @@ void Win32MakefileGenerator::writeCleanParts(QTextStream &t) { QString ofile = fileFixify(Option::output.fileName()); if(!ofile.isEmpty()) - t << "\t-$(DEL_FILE) " << escapeFilePath(ofile) << endl; + t << "\t-$(DEL_FILE) " << escapeFilePath(ofile) << Qt::endl; } - t << endl; + t << Qt::endl; } void Win32MakefileGenerator::writeIncPart(QTextStream &t) @@ -519,7 +519,7 @@ void Win32MakefileGenerator::writeIncPart(QTextStream &t) if(!inc.isEmpty()) t << "-I" << escapeFilePath(inc) << ' '; } - t << endl; + t << Qt::endl; } void Win32MakefileGenerator::writeStandardParts(QTextStream &t) @@ -527,51 +527,51 @@ void Win32MakefileGenerator::writeStandardParts(QTextStream &t) writeExportedVariables(t); t << "####### Compiler, tools and options\n\n"; - t << "CC = " << var("QMAKE_CC") << endl; - t << "CXX = " << var("QMAKE_CXX") << endl; + t << "CC = " << var("QMAKE_CC") << Qt::endl; + t << "CXX = " << var("QMAKE_CXX") << Qt::endl; t << "DEFINES = " << varGlue("PRL_EXPORT_DEFINES","-D"," -D"," ") - << varGlue("DEFINES","-D"," -D","") << endl; + << varGlue("DEFINES","-D"," -D","") << Qt::endl; t << "CFLAGS = " << var("QMAKE_CFLAGS") << " $(DEFINES)\n"; t << "CXXFLAGS = " << var("QMAKE_CXXFLAGS") << " $(DEFINES)\n"; writeIncPart(t); writeLibsPart(t); - t << "QMAKE = " << var("QMAKE_QMAKE") << endl; + t << "QMAKE = " << var("QMAKE_QMAKE") << Qt::endl; t << "IDC = " << (project->isEmpty("QMAKE_IDC") ? QString("idc") : var("QMAKE_IDC")) - << endl; + << Qt::endl; t << "IDL = " << (project->isEmpty("QMAKE_IDL") ? QString("midl") : var("QMAKE_IDL")) - << endl; - t << "ZIP = " << var("QMAKE_ZIP") << endl; - t << "DEF_FILE = " << fileVar("DEF_FILE") << endl; - t << "RES_FILE = " << fileVar("RES_FILE") << endl; // Not on mingw, can't see why not though... - t << "COPY = " << var("QMAKE_COPY") << endl; - t << "SED = " << var("QMAKE_STREAM_EDITOR") << endl; - t << "COPY_FILE = " << var("QMAKE_COPY_FILE") << endl; - t << "COPY_DIR = " << var("QMAKE_COPY_DIR") << endl; - t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; - t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl; - t << "MOVE = " << var("QMAKE_MOVE") << endl; - t << "CHK_DIR_EXISTS= " << var("QMAKE_CHK_DIR_EXISTS") << endl; - t << "MKDIR = " << var("QMAKE_MKDIR") << endl; - t << "INSTALL_FILE = " << var("QMAKE_INSTALL_FILE") << endl; - t << "INSTALL_PROGRAM = " << var("QMAKE_INSTALL_PROGRAM") << endl; - t << "INSTALL_DIR = " << var("QMAKE_INSTALL_DIR") << endl; - t << "QINSTALL = " << var("QMAKE_QMAKE") << " -install qinstall" << endl; - t << "QINSTALL_PROGRAM = " << var("QMAKE_QMAKE") << " -install qinstall -exe" << endl; - t << endl; + << Qt::endl; + t << "ZIP = " << var("QMAKE_ZIP") << Qt::endl; + t << "DEF_FILE = " << fileVar("DEF_FILE") << Qt::endl; + t << "RES_FILE = " << fileVar("RES_FILE") << Qt::endl; // Not on mingw, can't see why not though... + t << "COPY = " << var("QMAKE_COPY") << Qt::endl; + t << "SED = " << var("QMAKE_STREAM_EDITOR") << Qt::endl; + t << "COPY_FILE = " << var("QMAKE_COPY_FILE") << Qt::endl; + t << "COPY_DIR = " << var("QMAKE_COPY_DIR") << Qt::endl; + t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << Qt::endl; + t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << Qt::endl; + t << "MOVE = " << var("QMAKE_MOVE") << Qt::endl; + t << "CHK_DIR_EXISTS= " << var("QMAKE_CHK_DIR_EXISTS") << Qt::endl; + t << "MKDIR = " << var("QMAKE_MKDIR") << Qt::endl; + t << "INSTALL_FILE = " << var("QMAKE_INSTALL_FILE") << Qt::endl; + t << "INSTALL_PROGRAM = " << var("QMAKE_INSTALL_PROGRAM") << Qt::endl; + t << "INSTALL_DIR = " << var("QMAKE_INSTALL_DIR") << Qt::endl; + t << "QINSTALL = " << var("QMAKE_QMAKE") << " -install qinstall" << Qt::endl; + t << "QINSTALL_PROGRAM = " << var("QMAKE_QMAKE") << " -install qinstall -exe" << Qt::endl; + t << Qt::endl; t << "####### Output directory\n\n"; if(!project->values("OBJECTS_DIR").isEmpty()) - t << "OBJECTS_DIR = " << escapeFilePath(var("OBJECTS_DIR").remove(QRegExp("\\\\$"))) << endl; + t << "OBJECTS_DIR = " << escapeFilePath(var("OBJECTS_DIR").remove(QRegExp("\\\\$"))) << Qt::endl; else t << "OBJECTS_DIR = . \n"; - t << endl; + t << Qt::endl; t << "####### Files\n\n"; t << "SOURCES = " << valList(escapeFilePaths(project->values("SOURCES"))) - << " " << valList(escapeFilePaths(project->values("GENERATED_SOURCES"))) << endl; + << " " << valList(escapeFilePaths(project->values("GENERATED_SOURCES"))) << Qt::endl; // do this here so we can set DEST_TARGET to be the complete path to the final target if it is needed. QString orgDestDir = var("DESTDIR"); @@ -587,14 +587,14 @@ void Win32MakefileGenerator::writeStandardParts(QTextStream &t) writeExtraVariables(t); t << "DIST = " << fileVarList("DISTFILES") << ' ' - << fileVarList("HEADERS") << ' ' << fileVarList("SOURCES") << endl; - t << "QMAKE_TARGET = " << fileVar("QMAKE_ORIG_TARGET") << endl; // unused + << fileVarList("HEADERS") << ' ' << fileVarList("SOURCES") << Qt::endl; + t << "QMAKE_TARGET = " << fileVar("QMAKE_ORIG_TARGET") << Qt::endl; // unused // The comment is important to maintain variable compatibility with Unix // Makefiles, while not interpreting a trailing-slash as a linebreak t << "DESTDIR = " << escapeFilePath(destDir) << " #avoid trailing-slash linebreak\n"; - t << "TARGET = " << escapeFilePath(target) << endl; - t << "DESTDIR_TARGET = " << fileVar("DEST_TARGET") << endl; - t << endl; + t << "TARGET = " << escapeFilePath(target) << Qt::endl; + t << "DESTDIR_TARGET = " << fileVar("DEST_TARGET") << Qt::endl; + t << Qt::endl; writeImplicitRulesPart(t); @@ -606,10 +606,10 @@ void Win32MakefileGenerator::writeStandardParts(QTextStream &t) const ProStringList &dlldirs = project->values("DLLDESTDIR"); for (ProStringList::ConstIterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir) { t << "\t-$(COPY_FILE) $(DESTDIR_TARGET) " - << escapeFilePath(Option::fixPathToTargetOS((*dlldir).toQString(), false)) << endl; + << escapeFilePath(Option::fixPathToTargetOS((*dlldir).toQString(), false)) << Qt::endl; } } - t << endl; + t << Qt::endl; writeRcFilePart(t); } @@ -642,33 +642,33 @@ void Win32MakefileGenerator::writeStandardParts(QTextStream &t) } } } - t << endl << endl; + t << Qt::endl << Qt::endl; writeCleanParts(t); writeExtraTargets(t); writeExtraCompilerTargets(t); - t << endl << endl; + t << Qt::endl << Qt::endl; } void Win32MakefileGenerator::writeLibsPart(QTextStream &t) { if(project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") { - t << "LIBAPP = " << var("QMAKE_LIB") << endl; - t << "LIBFLAGS = " << var("QMAKE_LIBFLAGS") << endl; + t << "LIBAPP = " << var("QMAKE_LIB") << Qt::endl; + t << "LIBFLAGS = " << var("QMAKE_LIBFLAGS") << Qt::endl; } else { - t << "LINKER = " << var("QMAKE_LINK") << endl; - t << "LFLAGS = " << var("QMAKE_LFLAGS") << endl; + t << "LINKER = " << var("QMAKE_LINK") << Qt::endl; + t << "LFLAGS = " << var("QMAKE_LFLAGS") << Qt::endl; t << "LIBS = " << fixLibFlags("LIBS").join(' ') << ' ' << fixLibFlags("LIBS_PRIVATE").join(' ') << ' ' << fixLibFlags("QMAKE_LIBS").join(' ') << ' ' - << fixLibFlags("QMAKE_LIBS_PRIVATE").join(' ') << endl; + << fixLibFlags("QMAKE_LIBS_PRIVATE").join(' ') << Qt::endl; } } void Win32MakefileGenerator::writeObjectsPart(QTextStream &t) { // Used in both deps and commands. - t << "OBJECTS = " << valList(escapeDependencyPaths(project->values("OBJECTS"))) << endl; + t << "OBJECTS = " << valList(escapeDependencyPaths(project->values("OBJECTS"))) << Qt::endl; } void Win32MakefileGenerator::writeImplicitRulesPart(QTextStream &t) @@ -710,7 +710,7 @@ void Win32MakefileGenerator::writeRcFilePart(QTextStream &t) << var("QMAKE_RC") << (project->isActiveConfig("debug") ? " -D_DEBUG" : "") << defines << incPathStr << " -fo " << escapeFilePath(res_file) << ' ' << escapeFilePath(rc_file); - t << endl << endl; + t << Qt::endl << Qt::endl; } } diff --git a/qmake/generators/xmloutput.cpp b/qmake/generators/xmloutput.cpp index e92749a126..2f48763550 100644 --- a/qmake/generators/xmloutput.cpp +++ b/qmake/generators/xmloutput.cpp @@ -237,7 +237,7 @@ void XmlOutput::newTagOpen(const QString &tag) closeOpen(); if (format == NewLine) - xmlFile << endl << currentIndent; + xmlFile << Qt::endl << currentIndent; xmlFile << '<' << doConversion(tag); currentState = Attribute; tagStack.append(tag); @@ -271,7 +271,7 @@ void XmlOutput::closeTag() case Tag: decreaseIndent(); // <--- Pre-decrease indent if (format == NewLine) - xmlFile << endl << currentIndent; + xmlFile << Qt::endl << currentIndent; xmlFile << "'; tagStack.pop_back(); break; @@ -343,7 +343,7 @@ void XmlOutput::addAttribute(const QString &attribute, const QString &value) break; } if (format == NewLine) - xmlFile << endl; + xmlFile << Qt::endl; xmlFile << currentIndent << doConversion(attribute) << "=\"" << doConversion(value) << "\""; } diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-indic.cpp b/src/3rdparty/harfbuzz/src/harfbuzz-indic.cpp index 704ea9774a..de3bcb2bbf 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-indic.cpp +++ b/src/3rdparty/harfbuzz/src/harfbuzz-indic.cpp @@ -1471,7 +1471,7 @@ static bool indic_shape_syllable(HB_Bool openType, HB_ShaperItem *item, bool inv while (finalOrder[toMove].form && fixed < len-1) { IDEBUG(" fixed = %d, toMove=%d, moving form %d with pos %d", fixed, toMove, finalOrder[toMove].form, finalOrder[toMove].position); for (i = fixed; i < len; i++) { -// IDEBUG() << " i=" << i << "uc=" << hex << uc[i] << "form=" << form(uc[i]) +// IDEBUG() << " i=" << i << "uc=" << Qt::hex << uc[i] << "form=" << form(uc[i]) // << "position=" << position[i]; if (form(uc[i]) == finalOrder[toMove].form && position[i] == finalOrder[toMove].position) { diff --git a/src/3rdparty/harfbuzz/tests/shaping/main.cpp b/src/3rdparty/harfbuzz/tests/shaping/main.cpp index 10818c565c..16f469029b 100644 --- a/src/3rdparty/harfbuzz/tests/shaping/main.cpp +++ b/src/3rdparty/harfbuzz/tests/shaping/main.cpp @@ -370,7 +370,7 @@ void tst_QScriptEngine::greek() QString str; str.append(uc); if (str.normalized(QString::NormalizationForm_D).normalized(QString::NormalizationForm_C) != str) { - //qDebug() << "skipping" << hex << uc; + //qDebug() << "skipping" << Qt::hex << uc; continue; } if (uc == 0x1fc1 || uc == 0x1fed) @@ -389,7 +389,7 @@ void tst_QScriptEngine::greek() QString str; str.append(uc); if (str.normalized(QString::NormalizationForm_D).normalized(QString::NormalizationForm_C) != str) { - //qDebug() << "skipping" << hex << uc; + //qDebug() << "skipping" << Qt::hex << uc; continue; } if (uc == 0x1fc1 || uc == 0x1fed) diff --git a/src/corelib/doc/snippets/code/doc_src_qset.cpp b/src/corelib/doc/snippets/code/doc_src_qset.cpp index 4cd84d7330..7f7cec8b45 100644 --- a/src/corelib/doc/snippets/code/doc_src_qset.cpp +++ b/src/corelib/doc/snippets/code/doc_src_qset.cpp @@ -133,7 +133,7 @@ QSet set; ... QSet::iterator it = qFind(set.begin(), set.end(), "Jeanette"); if (it != set.end()) - cout << "Found Jeanette" << endl; + cout << "Found Jeanette" << Qt::endl; //! [10] @@ -152,7 +152,7 @@ QSet set; ... QSet::iterator it = qFind(set.begin(), set.end(), "Jeanette"); if (it != set.constEnd()) - cout << "Found Jeanette" << endl; + cout << "Found Jeanette" << Qt::endl; //! [12] diff --git a/src/corelib/doc/snippets/code/src_corelib_io_qtextstream.cpp b/src/corelib/doc/snippets/code/src_corelib_io_qtextstream.cpp index 625c1cf9bc..c30f13df5a 100644 --- a/src/corelib/doc/snippets/code/src_corelib_io_qtextstream.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_io_qtextstream.cpp @@ -124,12 +124,12 @@ in >> ch1 >> ch2 >> ch3; //! [8] QTextStream out(stdout); -out << "Qt rocks!" << endl; +out << "Qt rocks!" << Qt::endl; //! [8] //! [9] -stream << '\n' << flush; +stream << '\n' << Qt::flush; //! [9] diff --git a/src/corelib/doc/snippets/code/src_corelib_thread_qfuture.cpp b/src/corelib/doc/snippets/code/src_corelib_thread_qfuture.cpp index 382b08fdb7..dfa9b670e7 100644 --- a/src/corelib/doc/snippets/code/src_corelib_thread_qfuture.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_thread_qfuture.cpp @@ -53,7 +53,7 @@ QFuture future = ...; QFuture::const_iterator i; for (i = future.constBegin(); i != future.constEnd(); ++i) - cout << *i << endl; + cout << *i << Qt::endl; //! [0] diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp index 32fccbefbf..ec63e64fe9 100644 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp @@ -71,7 +71,7 @@ ba[4] = 0xca; //! [2] for (int i = 0; i < ba.size(); ++i) { if (ba.at(i) >= 'a' && ba.at(i) <= 'f') - cout << "Found character in range [a-f]" << endl; + cout << "Found character in range [a-f]" << Qt::endl; } //! [2] @@ -88,7 +88,7 @@ x.replace(5, 3, "&"); // x == "rock & roll" QByteArray ba("We must be bold, very bold"); int j = 0; while ((j = ba.indexOf("", j)) != -1) { - cout << "Found tag at index position " << j << endl; + cout << "Found tag at index position " << j << Qt::endl; ++j; } //! [4] @@ -126,7 +126,7 @@ QByteArray("abc").isEmpty(); // returns false QByteArray ba("Hello world"); char *data = ba.data(); while (*data) { - cout << "[" << *data << "]" << endl; + cout << "[" << *data << "]" << Qt::endl; ++data; } //! [8] diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp index a3d2dd7f9e..9813cc98d5 100644 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp @@ -89,7 +89,7 @@ QHash hash; ... for (int i = 0; i < 1000; ++i) { if (hash[i] == okButton) - cout << "Found button at index " << i << endl; + cout << "Found button at index " << i << Qt::endl; } //! [6] @@ -98,7 +98,7 @@ for (int i = 0; i < 1000; ++i) { QHashIterator i(hash); while (i.hasNext()) { i.next(); - cout << i.key() << ": " << i.value() << endl; + cout << i.key() << ": " << i.value() << Qt::endl; } //! [7] @@ -106,7 +106,7 @@ while (i.hasNext()) { //! [8] QHash::const_iterator i = hash.constBegin(); while (i != hash.constEnd()) { - cout << i.key() << ": " << i.value() << endl; + cout << i.key() << ": " << i.value() << Qt::endl; ++i; } //! [8] @@ -122,14 +122,14 @@ hash.insert("plenty", 2000); //! [10] QList values = hash.values("plenty"); for (int i = 0; i < values.size(); ++i) - cout << values.at(i) << endl; + cout << values.at(i) << Qt::endl; //! [10] //! [11] QHash::iterator i = hash.find("plenty"); while (i != hash.end() && i.key() == "plenty") { - cout << i.value() << endl; + cout << i.value() << Qt::endl; ++i; } //! [11] @@ -139,7 +139,7 @@ while (i != hash.end() && i.key() == "plenty") { QHash hash; ... foreach (int value, hash) - cout << value << endl; + cout << value << Qt::endl; //! [12] @@ -201,7 +201,7 @@ QHash hash; ... QHash::const_iterator i = hash.find("HDR"); while (i != hash.end() && i.key() == "HDR") { - cout << i.value() << endl; + cout << i.value() << Qt::endl; ++i; } //! [16] @@ -216,7 +216,7 @@ hash.insert("December", 12); QHash::iterator i; for (i = hash.begin(); i != hash.end(); ++i) - cout << i.key() << ": " << i.value() << endl; + cout << i.key() << ": " << i.value() << Qt::endl; //! [17] @@ -274,7 +274,7 @@ hash.insert("December", 12); QHash::const_iterator i; for (i = hash.constBegin(); i != hash.constEnd(); ++i) - cout << i.key() << ": " << i.value() << endl; + cout << i.key() << ": " << i.value() << Qt::endl; //! [23] @@ -296,23 +296,23 @@ hash3 = hash1 + hash2; //! [25] QList values = hash.values("plenty"); for (int i = 0; i < values.size(); ++i) - cout << values.at(i) << endl; + cout << values.at(i) << Qt::endl; //! [25] //! [26] QMultiHash::iterator i = hash.find("plenty"); while (i != hash.end() && i.key() == "plenty") { - cout << i.value() << endl; + cout << i.value() << Qt::endl; ++i; } //! [26] //! [27] for (QHash::const_iterator it = hash.cbegin(), end = hash.cend(); it != end; ++it) { - cout << "The key: " << it.key() << endl - cout << "The value: " << it.value() << endl; - cout << "Also the value: " << (*it) << endl; + cout << "The key: " << it.key() << Qt::endl + cout << "The value: " << it.value() << Qt::endl; + cout << "Also the value: " << (*it) << Qt::endl; } //! [27] diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qlinkedlist.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qlinkedlist.cpp index 7f743bbd25..e0d3c71dc5 100644 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qlinkedlist.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_tools_qlinkedlist.cpp @@ -112,7 +112,7 @@ list.append("December"); QLinkedList::iterator i; for (i = list.begin(); i != list.end(); ++i) - cout << *i << endl; + cout << *i << Qt::endl; //! [7] @@ -122,7 +122,7 @@ QLinkedList list; QLinkedList::iterator it = qFind(list.begin(), list.end(), "Joel"); if (it != list.end()) - cout << "Found Joel" << endl; + cout << "Found Joel" << Qt::endl; //! [8] @@ -182,7 +182,7 @@ list.append("December"); QLinkedList::const_iterator i; for (i = list.constBegin(); i != list.constEnd(); ++i) - cout << *i << endl; + cout << *i << Qt::endl; //! [14] @@ -192,7 +192,7 @@ QLinkedList list; QLinkedList::iterator it = qFind(list.constBegin(), list.constEnd(), "Joel"); if (it != list.constEnd()) - cout << "Found Joel" << endl; + cout << "Found Joel" << Qt::endl; //! [15] diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp index 0e746cd6e6..a24e599f2f 100644 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp @@ -73,7 +73,7 @@ if (list[0] == "Bob") //! [3] for (int i = 0; i < list.size(); ++i) { if (list.at(i) == "Jane") - cout << "Found Jane at position " << i << endl; + cout << "Found Jane at position " << i << Qt::endl; } //! [3] @@ -89,7 +89,7 @@ while (!list.isEmpty()) //! [5] int i = list.indexOf("Jane"); if (i != -1) - cout << "First occurrence of Jane is at position " << i << endl; + cout << "First occurrence of Jane is at position " << i << Qt::endl; //! [5] @@ -180,7 +180,7 @@ list.append("December"); QList::iterator i; for (i = list.begin(); i != list.end(); ++i) - cout << *i << endl; + cout << *i << Qt::endl; //! [15] @@ -213,7 +213,7 @@ list.append("December"); QList::const_iterator i; for (i = list.constBegin(); i != list.constEnd(); ++i) - cout << *i << endl; + cout << *i << Qt::endl; //! [19] diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qmap.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qmap.cpp index bd59758f71..506022f082 100644 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qmap.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_tools_qmap.cpp @@ -89,7 +89,7 @@ QMap map; ... for (int i = 0; i < 1000; ++i) { if (map[i] == okButton) - cout << "Found button at index " << i << endl; + cout << "Found button at index " << i << Qt::endl; } //! [6] @@ -98,7 +98,7 @@ for (int i = 0; i < 1000; ++i) { QMapIterator i(map); while (i.hasNext()) { i.next(); - cout << i.key() << ": " << i.value() << endl; + cout << i.key() << ": " << i.value() << Qt::endl; } //! [7] @@ -106,7 +106,7 @@ while (i.hasNext()) { //! [8] QMap::const_iterator i = map.constBegin(); while (i != map.constEnd()) { - cout << i.key() << ": " << i.value() << endl; + cout << i.key() << ": " << i.value() << Qt::endl; ++i; } //! [8] @@ -122,14 +122,14 @@ map.insert("plenty", 2000); //! [10] QList values = map.values("plenty"); for (int i = 0; i < values.size(); ++i) - cout << values.at(i) << endl; + cout << values.at(i) << Qt::endl; //! [10] //! [11] QMap::iterator i = map.find("plenty"); while (i != map.end() && i.key() == "plenty") { - cout << i.value() << endl; + cout << i.value() << Qt::endl; ++i; } //! [11] @@ -139,7 +139,7 @@ while (i != map.end() && i.key() == "plenty") { QMap map; ... foreach (int value, map) - cout << value << endl; + cout << value << Qt::endl; //! [12] @@ -175,7 +175,7 @@ QMap map; ... QMap::const_iterator i = map.find("HDR"); while (i != map.end() && i.key() == "HDR") { - cout << i.value() << endl; + cout << i.value() << Qt::endl; ++i; } //! [14] @@ -201,7 +201,7 @@ QMap map; QMap::const_iterator i = map.lowerBound("HDR"); QMap::const_iterator upperBound = map.upperBound("HDR"); while (i != upperBound) { - cout << i.value() << endl; + cout << i.value() << Qt::endl; ++i; } //! [16] @@ -230,7 +230,7 @@ map.insert("December", 12); QMap::iterator i; for (i = map.begin(); i != map.end(); ++i) - cout << i.key() << ": " << i.value() << endl; + cout << i.key() << ": " << i.value() << Qt::endl; //! [18] @@ -288,7 +288,7 @@ map.insert("December", 12); QMap::const_iterator i; for (i = map.constBegin(); i != map.constEnd(); ++i) - cout << i.key() << ": " << i.value() << endl; + cout << i.key() << ": " << i.value() << Qt::endl; //! [24] @@ -310,23 +310,23 @@ map3 = map1 + map2; //! [26] QList values = map.values("plenty"); for (int i = 0; i < values.size(); ++i) - cout << values.at(i) << endl; + cout << values.at(i) << Qt::endl; //! [26] //! [27] QMultiMap::iterator i = map.find("plenty"); while (i != map.end() && i.key() == "plenty") { - cout << i.value() << endl; + cout << i.value() << Qt::endl; ++i; } //! [27] //! [keyiterator1] for (QMap::const_iterator it = map.cbegin(), end = map.cend(); it != end; ++it) { - cout << "The key: " << it.key() << endl - cout << "The value: " << it.value() << endl; - cout << "Also the value: " << (*it) << endl; + cout << "The key: " << it.key() << Qt::endl + cout << "The value: " << it.value() << Qt::endl; + cout << "Also the value: " << (*it) << Qt::endl; } //! [keyiterator1] diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qqueue.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qqueue.cpp index b74ac31933..6046c73b0f 100644 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qqueue.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_tools_qqueue.cpp @@ -54,5 +54,5 @@ queue.enqueue(1); queue.enqueue(2); queue.enqueue(3); while (!queue.isEmpty()) - cout << queue.dequeue() << endl; + cout << queue.dequeue() << Qt::endl; //! [0] diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qstringiterator.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qstringiterator.cpp index 7a2b4812ef..eb09fb99e2 100644 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qstringiterator.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_tools_qstringiterator.cpp @@ -72,9 +72,9 @@ while (i.hasNext()) { //! [2] QStringIterator i(u"𝄞 is the G clef"); -qDebug() << hex << i.next(); // will print 1d11e (U+1D11E, MUSICAL SYMBOL G CLEF) -qDebug() << hex << i.next(); // will print 20 (U+0020, SPACE) -qDebug() << hex << i.next(); // will print 69 (U+0069, LATIN SMALL LETTER I) +qDebug() << Qt::hex << i.next(); // will print 1d11e (U+1D11E, MUSICAL SYMBOL G CLEF) +qDebug() << Qt::hex << i.next(); // will print 20 (U+0020, SPACE) +qDebug() << Qt::hex << i.next(); // will print 69 (U+0069, LATIN SMALL LETTER I) //! [2] } diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qvector.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qvector.cpp index 1f2af4a408..a05233049f 100644 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qvector.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_tools_qvector.cpp @@ -73,7 +73,7 @@ if (vector[0] == "Liz") //! [4] for (int i = 0; i < vector.size(); ++i) { if (vector.at(i) == "Alfonso") - cout << "Found Alfonso at position " << i << endl; + cout << "Found Alfonso at position " << i << Qt::endl; } //! [4] @@ -81,7 +81,7 @@ for (int i = 0; i < vector.size(); ++i) { //! [5] int i = vector.indexOf("Harumi"); if (i != -1) - cout << "First occurrence of Harumi is at position " << i << endl; + cout << "First occurrence of Harumi is at position " << i << Qt::endl; //! [5] diff --git a/src/corelib/doc/snippets/qstack/main.cpp b/src/corelib/doc/snippets/qstack/main.cpp index af6b960e57..66823bcb59 100644 --- a/src/corelib/doc/snippets/qstack/main.cpp +++ b/src/corelib/doc/snippets/qstack/main.cpp @@ -60,6 +60,6 @@ int main(int argc, char *argv[]) stack.push(2); stack.push(3); while (!stack.isEmpty()) - cout << stack.pop() << endl; + cout << stack.pop() << Qt::endl; //! [0] } diff --git a/src/corelib/doc/snippets/qstringlist/main.cpp b/src/corelib/doc/snippets/qstringlist/main.cpp index 55c60650fe..80788ccd76 100644 --- a/src/corelib/doc/snippets/qstringlist/main.cpp +++ b/src/corelib/doc/snippets/qstringlist/main.cpp @@ -71,20 +71,20 @@ Widget::Widget(QWidget *parent) //! [1] for (int i = 0; i < fonts.size(); ++i) - cout << fonts.at(i).toLocal8Bit().constData() << endl; + cout << fonts.at(i).toLocal8Bit().constData() << Qt::endl; //! [1] //! [2] QStringListIterator javaStyleIterator(fonts); while (javaStyleIterator.hasNext()) - cout << javaStyleIterator.next().toLocal8Bit().constData() << endl; + cout << javaStyleIterator.next().toLocal8Bit().constData() << Qt::endl; //! [2] //! [3] QStringList::const_iterator constIterator; for (constIterator = fonts.constBegin(); constIterator != fonts.constEnd(); ++constIterator) - cout << (*constIterator).toLocal8Bit().constData() << endl; + cout << (*constIterator).toLocal8Bit().constData() << Qt::endl; //! [3] //! [4] diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp index 15c5e0ce96..6dc12cd83f 100644 --- a/src/corelib/io/qdebug.cpp +++ b/src/corelib/io/qdebug.cpp @@ -166,7 +166,7 @@ void QDebug::putUcs4(uint ucs4) { maybeQuote('\''); if (ucs4 < 0x20) { - stream->ts << "\\x" << hex << ucs4 << reset; + stream->ts << "\\x" << Qt::hex << ucs4 << Qt::reset; } else if (ucs4 < 0x80) { stream->ts << char(ucs4); } else { @@ -174,7 +174,7 @@ void QDebug::putUcs4(uint ucs4) stream->ts << "\\u" << qSetFieldWidth(4); else stream->ts << "\\U" << qSetFieldWidth(8); - stream->ts << hex << qSetPadChar(QLatin1Char('0')) << ucs4 << reset; + stream->ts << Qt::hex << qSetPadChar(QLatin1Char('0')) << ucs4 << Qt::reset; } maybeQuote('\''); } @@ -834,7 +834,7 @@ QDebug &QDebug::resetFormat() that QDebugStateSaver stores for the duration of the current block. The settings of the internal QTextStream are also saved and restored, - so that using << hex in a QDebug operator doesn't affect other QDebug + so that using << Qt::hex in a QDebug operator doesn't affect other QDebug operators. \since 5.1 diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index f9dc4203db..889fb6b571 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -350,7 +350,7 @@ void qt_QMetaEnum_flagDebugOperator(QDebug &debug, size_t sizeofT, Int value) { const QDebugStateSaver saver(debug); debug.resetFormat(); - debug.nospace() << "QFlags(" << hex << showbase; + debug.nospace() << "QFlags(" << Qt::hex << Qt::showbase; bool needSeparator = false; for (uint i = 0; i < sizeofT * 8; ++i) { if (value & (Int(1) << i)) { diff --git a/src/corelib/io/qfilesystemwatcher_inotify.cpp b/src/corelib/io/qfilesystemwatcher_inotify.cpp index a5e629b646..9d008947ba 100644 --- a/src/corelib/io/qfilesystemwatcher_inotify.cpp +++ b/src/corelib/io/qfilesystemwatcher_inotify.cpp @@ -388,7 +388,7 @@ void QInotifyFileSystemWatcherEngine::readFromInotify() const inotify_event &event = **it; ++it; - // qDebug() << "inotify event, wd" << event.wd << "mask" << hex << event.mask; + // qDebug() << "inotify event, wd" << event.wd << "mask" << Qt::hex << event.mask; int id = event.wd; QString path = getPathFromID(id); diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp index 7f4f9d345b..eb626fd541 100644 --- a/src/corelib/io/qfilesystemwatcher_win.cpp +++ b/src/corelib/io/qfilesystemwatcher_win.cpp @@ -79,7 +79,7 @@ static Qt::HANDLE createChangeNotification(const QString &path, uint flags) nativePath.append(QLatin1Char('\\')); const HANDLE result = FindFirstChangeNotification(reinterpret_cast(nativePath.utf16()), FALSE, flags); - DEBUG() << __FUNCTION__ << nativePath << hex <" << flags; const Qt::HANDLE fileHandle = createChangeNotification(absolutePath, flags); if (fileHandle != INVALID_HANDLE_VALUE) { diff --git a/src/corelib/kernel/qeventdispatcher_cf.mm b/src/corelib/kernel/qeventdispatcher_cf.mm index b7b379e2c1..33c231987f 100644 --- a/src/corelib/kernel/qeventdispatcher_cf.mm +++ b/src/corelib/kernel/qeventdispatcher_cf.mm @@ -190,7 +190,7 @@ Q_ENUM_PRINTER(Result); QDebug operator<<(QDebug s, timespec tv) { - s << tv.tv_sec << "." << qSetFieldWidth(9) << qSetPadChar(QChar(48)) << tv.tv_nsec << reset; + s << tv.tv_sec << "." << qSetFieldWidth(9) << qSetPadChar(QChar(48)) << tv.tv_nsec << Qt::reset; return s; } diff --git a/src/corelib/kernel/qtimerinfo_unix.cpp b/src/corelib/kernel/qtimerinfo_unix.cpp index c3b8c86063..39010c19cb 100644 --- a/src/corelib/kernel/qtimerinfo_unix.cpp +++ b/src/corelib/kernel/qtimerinfo_unix.cpp @@ -215,7 +215,7 @@ static timespec roundToMillisecond(timespec val) QDebug operator<<(QDebug s, timeval tv) { QDebugStateSaver saver(s); - s.nospace() << tv.tv_sec << "." << qSetFieldWidth(6) << qSetPadChar(QChar(48)) << tv.tv_usec << reset; + s.nospace() << tv.tv_sec << "." << qSetFieldWidth(6) << qSetPadChar(QChar(48)) << tv.tv_usec << Qt::reset; return s; } QDebug operator<<(QDebug s, Qt::TimerType t) @@ -373,7 +373,7 @@ static void calculateNextTimeout(QTimerInfo *t, timespec currentTime) #ifdef QTIMERINFO_DEBUG if (t->timerType != Qt::PreciseTimer) - qDebug() << "timer" << t->timerType << hex << t->id << dec << "interval" << t->interval + qDebug() << "timer" << t->timerType << Qt::hex << t->id << Qt::dec << "interval" << t->interval << "originally expected at" << t->expected << "will fire at" << t->timeout << "or" << (t->timeout - t->expected) << "s late"; #endif @@ -500,7 +500,7 @@ void QTimerInfoList::registerTimer(int timerId, int interval, Qt::TimerType time t->cumulativeError = 0; t->count = 0; if (t->timerType != Qt::PreciseTimer) - qDebug() << "timer" << t->timerType << hex <id << dec << "interval" << t->interval << "expected at" + qDebug() << "timer" << t->timerType << Qt::hex <id << Qt::dec << "interval" << t->interval << "expected at" << t->expected << "will fire first at" << t->timeout; #endif } @@ -620,7 +620,7 @@ int QTimerInfoList::activateTimers() currentTimerInfo->cumulativeError += diff; ++currentTimerInfo->count; if (currentTimerInfo->timerType != Qt::PreciseTimer) - qDebug() << "timer" << currentTimerInfo->timerType << hex << currentTimerInfo->id << dec << "interval" + qDebug() << "timer" << currentTimerInfo->timerType << Qt::hex << currentTimerInfo->id << Qt::dec << "interval" << currentTimerInfo->interval << "firing at" << currentTime << "(orig" << currentTimerInfo->expected << "scheduled at" << currentTimerInfo->timeout << ") off by" << diff << "activation" << currentTimerInfo->count diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp index 35c64180d4..8e349f23ce 100644 --- a/src/corelib/plugin/qfactoryloader.cpp +++ b/src/corelib/plugin/qfactoryloader.cpp @@ -239,7 +239,7 @@ void QFactoryLoader::update() library = QLibraryPrivate::findOrCreate(QFileInfo(fileName).canonicalFilePath()); if (!library->isPlugin()) { if (qt_debug_component()) { - qDebug() << library->errorString << endl + qDebug() << library->errorString << Qt::endl << " not a plugin"; } library->release(); diff --git a/src/corelib/serialization/qcborvalue.cpp b/src/corelib/serialization/qcborvalue.cpp index d469735ae9..b2e0ba6d53 100644 --- a/src/corelib/serialization/qcborvalue.cpp +++ b/src/corelib/serialization/qcborvalue.cpp @@ -2941,7 +2941,7 @@ static QDebug debugContents(QDebug &dbg, const QCborValue &v) } if (v.isSimpleType()) return dbg << v.toSimpleType(); - return dbg << "'; + return dbg << "'; } QDebug operator<<(QDebug dbg, const QCborValue &v) { diff --git a/src/corelib/serialization/qjsonparser.cpp b/src/corelib/serialization/qjsonparser.cpp index bfba95520e..f29348d593 100644 --- a/src/corelib/serialization/qjsonparser.cpp +++ b/src/corelib/serialization/qjsonparser.cpp @@ -316,7 +316,7 @@ QJsonDocument Parser::parse(QJsonParseError *error) eatBOM(); char token = nextToken(); - DEBUG << hex << (uint)token; + DEBUG << Qt::hex << (uint)token; if (token == BeginArray) { if (!parseArray()) goto error; diff --git a/src/corelib/serialization/qtextstream.cpp b/src/corelib/serialization/qtextstream.cpp index 0d83bb6cd4..ef2a9c97ee 100644 --- a/src/corelib/serialization/qtextstream.cpp +++ b/src/corelib/serialization/qtextstream.cpp @@ -2356,7 +2356,7 @@ void QTextStreamPrivate::putNumber(qulonglong number, bool negative) } else if (negative) { // Workaround for backward compatibility for writing negative // numbers in octal and hex: - // QTextStream(result) << showbase << hex << -1 << oct << -1 + // QTextStream(result) << Qt::showbase << Qt::hex << -1 << oct << -1 // should output: -0x1 -0b1 result = dd->unsLongLongToString(number, -1, base, -1, flags); result.prepend(locale.negativeSign()); @@ -2978,7 +2978,7 @@ QTextStream ¢er(QTextStream &stream) */ QTextStream &endl(QTextStream &stream) { - return stream << QLatin1Char('\n') << flush; + return stream << QLatin1Char('\n') << Qt::flush; } /*! diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 029499039c..93d81b89b6 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -826,9 +826,9 @@ static int ucstricmp(const QChar *a, const QChar *ae, const QChar *b, const QCha uint alast = 0; uint blast = 0; while (a < e) { -// qDebug() << hex << alast << blast; -// qDebug() << hex << "*a=" << *a << "alast=" << alast << "folded=" << foldCase (*a, alast); -// qDebug() << hex << "*b=" << *b << "blast=" << blast << "folded=" << foldCase (*b, blast); +// qDebug() << Qt::hex << alast << blast; +// qDebug() << Qt::hex << "*a=" << *a << "alast=" << alast << "folded=" << foldCase (*a, alast); +// qDebug() << Qt::hex << "*b=" << *b << "blast=" << blast << "folded=" << foldCase (*b, blast); int diff = foldCase(a->unicode(), alast) - foldCase(b->unicode(), blast); if ((diff)) return diff; diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp index 46dec7f28d..de76d12a5e 100644 --- a/src/gui/accessible/qaccessible.cpp +++ b/src/gui/accessible/qaccessible.cpp @@ -1858,7 +1858,7 @@ Q_GUI_EXPORT QDebug operator<<(QDebug d, const QAccessibleInterface *iface) return d; } d.nospace(); - d << "QAccessibleInterface(" << hex << (const void *) iface << dec; + d << "QAccessibleInterface(" << Qt::hex << (const void *) iface << Qt::dec; if (iface->isValid()) { d << " name=" << iface->text(QAccessible::Name) << ' '; d << "role=" << qAccessibleRoleString(iface->role()) << ' '; @@ -1897,7 +1897,7 @@ QDebug operator<<(QDebug d, const QAccessibleEvent &ev) QDebugStateSaver saver(d); d.nospace() << "QAccessibleEvent("; if (ev.object()) { - d.nospace() << "object=" << hex << ev.object() << dec; + d.nospace() << "object=" << Qt::hex << ev.object() << Qt::dec; d.nospace() << "child=" << ev.child(); } else { d.nospace() << "no object, uniqueId=" << ev.uniqueId(); diff --git a/src/gui/doc/snippets/textdocumentendsnippet.cpp b/src/gui/doc/snippets/textdocumentendsnippet.cpp index c8de501838..cb7abd5ca7 100644 --- a/src/gui/doc/snippets/textdocumentendsnippet.cpp +++ b/src/gui/doc/snippets/textdocumentendsnippet.cpp @@ -59,7 +59,7 @@ int main(int argv, char **args) //! [0] for (QTextBlock it = doc->begin(); it != doc->end(); it = it.next()) - cout << it.text().toStdString() << endl; + cout << it.text().toStdString() << Qt::endl; //! [0] return 0; diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 892a686c89..2b47fb536b 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -1496,7 +1496,7 @@ QDebug operator<<(QDebug dbg, const QIcon &i) if (!i.name().isEmpty()) dbg << i.name() << ','; dbg << "availableSizes[normal,Off]=" << i.availableSizes() - << ",cacheKey=" << showbase << hex << i.cacheKey() << dec << noshowbase; + << ",cacheKey=" << Qt::showbase << Qt::hex << i.cacheKey() << Qt::dec << Qt::noshowbase; } dbg << ')'; return dbg; diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 5b4d218603..399ad7453d 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -1689,7 +1689,7 @@ QDebug operator<<(QDebug dbg, const QPixmap &r) } else { dbg << r.size() << ",depth=" << r.depth() << ",devicePixelRatio=" << r.devicePixelRatio() - << ",cacheKey=" << showbase << hex << r.cacheKey() << dec << noshowbase; + << ",cacheKey=" << Qt::showbase << Qt::hex << r.cacheKey() << Qt::dec << Qt::noshowbase; } dbg << ')'; return dbg; diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp index 7349a400a6..deff56aa58 100644 --- a/src/gui/image/qxpmhandler.cpp +++ b/src/gui/image/qxpmhandler.cpp @@ -1129,8 +1129,8 @@ static bool write_xpm_image(const QImage &sourceImage, QIODevice *device, const // write header QTextStream s(device); - s << "/* XPM */" << endl - << "static char *" << fbname(fileName) << "[]={" << endl + s << "/* XPM */" << Qt::endl + << "static char *" << fbname(fileName) << "[]={" << Qt::endl << '\"' << w << ' ' << h << ' ' << ncolors << ' ' << cpp << '\"'; // write palette @@ -1147,7 +1147,7 @@ static bool write_xpm_image(const QImage &sourceImage, QIODevice *device, const qGreen(color), qBlue(color)); ++c; - s << ',' << endl << line; + s << ',' << Qt::endl << line; } // write pixels, limit to 4 characters per pixel @@ -1169,9 +1169,9 @@ static bool write_xpm_image(const QImage &sourceImage, QIODevice *device, const } } } - s << ',' << endl << '\"' << line << '\"'; + s << ',' << Qt::endl << '\"' << line << '\"'; } - s << "};" << endl; + s << "};" << Qt::endl; return (s.status() == QTextStream::Ok); } diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index f6d1da45e3..563eab4655 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -3764,13 +3764,13 @@ static inline void formatTouchEvent(QDebug d, const QTouchEvent &t) static void formatUnicodeString(QDebug d, const QString &s) { - d << '"' << hex; + d << '"' << Qt::hex; for (int i = 0; i < s.size(); ++i) { if (i) d << ','; d << "U+" << s.at(i).unicode(); } - d << dec << '"'; + d << Qt::dec << '"'; } static inline void formatInputMethodEvent(QDebug d, const QInputMethodEvent *e) @@ -3807,8 +3807,8 @@ static inline void formatInputMethodQueryEvent(QDebug d, const QInputMethodQuery QDebugStateSaver saver(d); d.noquote(); const Qt::InputMethodQueries queries = e->queries(); - d << "QInputMethodQueryEvent(queries=" << showbase << hex << int(queries) - << noshowbase << dec << ", {"; + d << "QInputMethodQueryEvent(queries=" << Qt::showbase << Qt::hex << int(queries) + << Qt::noshowbase << Qt::dec << ", {"; for (unsigned mask = 1; mask <= Qt::ImInputItemClipRectangle; mask<<=1) { if (queries & mask) { const Qt::InputMethodQuery query = static_cast(mask); @@ -4001,7 +4001,7 @@ QDebug operator<<(QDebug dbg, const QTouchEvent::TouchPoint &tp) { QDebugStateSaver saver(dbg); dbg.nospace(); - dbg << "TouchPoint(" << hex << tp.id() << dec << " ("; + dbg << "TouchPoint(" << Qt::hex << tp.id() << Qt::dec << " ("; QtDebugUtils::formatQPoint(dbg, tp.pos()); dbg << ") "; QtDebugUtils::formatQEnum(dbg, tp.state()); diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp index b4383c5bfc..f6e5fa0a52 100644 --- a/src/gui/kernel/qpalette.cpp +++ b/src/gui/kernel/qpalette.cpp @@ -1204,7 +1204,7 @@ QDebug operator<<(QDebug dbg, const QPalette &p) QDebugStateSaver saver(dbg); QDebug nospace = dbg.nospace(); const uint mask = p.resolve(); - nospace << "QPalette(resolve=" << hex << showbase << mask << ','; + nospace << "QPalette(resolve=" << Qt::hex << Qt::showbase << mask << ','; for (int role = 0; role < (int)QPalette::NColorRoles; ++role) { if (mask & (1<isTopLevel()) debug << ", toplevel"; debug << ", " << geometry.width() << 'x' << geometry.height() - << forcesign << geometry.x() << geometry.y() << noforcesign; + << Qt::forcesign << geometry.x() << geometry.y() << Qt::noforcesign; const QMargins margins = window->frameMargins(); if (!margins.isNull()) debug << ", margins=" << margins; debug << ", devicePixelRatio=" << window->devicePixelRatio(); if (const QPlatformWindow *platformWindow = window->handle()) - debug << ", winId=0x" << hex << platformWindow->winId() << dec; + debug << ", winId=0x" << Qt::hex << platformWindow->winId() << Qt::dec; if (const QScreen *screen = window->screen()) debug << ", on " << screen->name(); } diff --git a/src/gui/math3d/qgenericmatrix.h b/src/gui/math3d/qgenericmatrix.h index 6a2a9e5bae..692c29c996 100644 --- a/src/gui/math3d/qgenericmatrix.h +++ b/src/gui/math3d/qgenericmatrix.h @@ -351,11 +351,11 @@ QDebug operator<<(QDebug dbg, const QGenericMatrix &m) QDebugStateSaver saver(dbg); dbg.nospace() << "QGenericMatrix<" << N << ", " << M << ", " << QTypeInfo::name() - << ">(" << endl << qSetFieldWidth(10); + << ">(" << Qt::endl << qSetFieldWidth(10); for (int row = 0; row < M; ++row) { for (int col = 0; col < N; ++col) dbg << m(row, col); - dbg << endl; + dbg << Qt::endl; } dbg << qSetFieldWidth(0) << ')'; return dbg; diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp index 045fa210c4..ad4cdfdbf4 100644 --- a/src/gui/math3d/qmatrix4x4.cpp +++ b/src/gui/math3d/qmatrix4x4.cpp @@ -2037,12 +2037,12 @@ QDebug operator<<(QDebug dbg, const QMatrix4x4 &m) } // Output in row-major order because it is more human-readable. - dbg.nospace() << "QMatrix4x4(type:" << bits.constData() << endl + dbg.nospace() << "QMatrix4x4(type:" << bits.constData() << Qt::endl << qSetFieldWidth(10) - << m(0, 0) << m(0, 1) << m(0, 2) << m(0, 3) << endl - << m(1, 0) << m(1, 1) << m(1, 2) << m(1, 3) << endl - << m(2, 0) << m(2, 1) << m(2, 2) << m(2, 3) << endl - << m(3, 0) << m(3, 1) << m(3, 2) << m(3, 3) << endl + << m(0, 0) << m(0, 1) << m(0, 2) << m(0, 3) << Qt::endl + << m(1, 0) << m(1, 1) << m(1, 2) << m(1, 3) << Qt::endl + << m(2, 0) << m(2, 1) << m(2, 2) << m(2, 3) << Qt::endl + << m(3, 0) << m(3, 1) << m(3, 2) << m(3, 3) << Qt::endl << qSetFieldWidth(0) << ')'; return dbg; } diff --git a/src/gui/opengl/qopengl.cpp b/src/gui/opengl/qopengl.cpp index 2b1e57a4bb..6b701fe52b 100644 --- a/src/gui/opengl/qopengl.cpp +++ b/src/gui/opengl/qopengl.cpp @@ -136,7 +136,7 @@ QDebug operator<<(QDebug d, const QOpenGLConfig::Gpu &g) d.nospace(); d << "Gpu("; if (g.isValid()) { - d << "vendor=" << hex << showbase <renderHints; + qDebug() << "QRasterPaintEngine::renderHintsChanged()" << Qt::hex << s->renderHints; #endif bool was_aa = s->flags.antialiased; @@ -1745,7 +1745,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush) QRectF rf = path.controlPointRect(); qDebug() << "QRasterPaintEngine::fill(): " << "size=" << path.elementCount() - << ", hints=" << hex << path.hints() + << ", hints=" << Qt::hex << path.hints() << rf << brush; #endif diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index 22d3fb3001..8314e8bc8a 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -140,7 +140,7 @@ QDebug Q_GUI_EXPORT &operator<<(QDebug &s, const QVectorPath &path) QDebugStateSaver saver(s); QRectF rf = path.controlPointRect(); s << "QVectorPath(size:" << path.elementCount() - << " hints:" << hex << path.hints() + << " hints:" << Qt::hex << path.hints() << rf << ')'; return s; } diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index 649cfd554b..7eaa4b6e3f 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -3576,10 +3576,10 @@ void QPainterPath::computeControlPointRect() const #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug s, const QPainterPath &p) { - s.nospace() << "QPainterPath: Element count=" << p.elementCount() << endl; + s.nospace() << "QPainterPath: Element count=" << p.elementCount() << Qt::endl; const char *types[] = {"MoveTo", "LineTo", "CurveTo", "CurveToData"}; for (int i=0; i " << types[p.elementAt(i).type] << "(x=" << p.elementAt(i).x << ", y=" << p.elementAt(i).y << ')' << endl; + s.nospace() << " -> " << types[p.elementAt(i).type] << "(x=" << p.elementAt(i).x << ", y=" << p.elementAt(i).y << ')' << Qt::endl; } return s; diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 1719855e68..99c9e1bfdc 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1213,7 +1213,7 @@ void QFontEngine::loadKerningPairs(QFixed scalingFactor) end: std::sort(kerning_pairs.begin(), kerning_pairs.end()); // for (int i = 0; i < kerning_pairs.count(); ++i) -// qDebug() << 'i' << i << "left_right" << hex << kerning_pairs.at(i).left_right; +// qDebug() << 'i' << i << "left_right" << Qt::hex << kerning_pairs.at(i).left_right; } diff --git a/src/gui/text/qfontengine_qpf2.cpp b/src/gui/text/qfontengine_qpf2.cpp index 110d512d39..409176d41b 100644 --- a/src/gui/text/qfontengine_qpf2.cpp +++ b/src/gui/text/qfontengine_qpf2.cpp @@ -140,9 +140,9 @@ static inline const uchar *verifyTag(const uchar *tagPtr, const uchar *endPtr) } #if defined(DEBUG_HEADER) if (length == 1) - qDebug() << "tag data" << hex << *tagPtr; + qDebug() << "tag data" << Qt::hex << *tagPtr; else if (length == 4) - qDebug() << "tag data" << hex << tagPtr[0] << tagPtr[1] << tagPtr[2] << tagPtr[3]; + qDebug() << "tag data" << Qt::hex << tagPtr[0] << tagPtr[1] << tagPtr[2] << tagPtr[3]; #endif } return tagPtr + length; @@ -367,7 +367,7 @@ bool QFontEngineQPF2::stringToCMap(const QChar *str, int len, QGlyphLayout *glyp #if 0 && defined(DEBUG_FONTENGINE) QChar c(uc); if (!findGlyph(glyphs[glyph_pos].glyph) && !seenGlyphs.contains(c)) - qDebug() << "glyph for character" << c << '/' << hex << uc << "is" << dec << glyphs[glyph_pos].glyph; + qDebug() << "glyph for character" << c << '/' << Qt::hex << uc << "is" << Qt::dec << glyphs[glyph_pos].glyph; seenGlyphs.insert(c); #endif diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 2616a42022..840448152f 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -990,7 +990,7 @@ struct QBidiAlgorithm { BIDI_DEBUG() << "before implicit level processing:"; IsolatedRunSequenceIterator it(runs, i); while (!it.atEnd()) { - BIDI_DEBUG() << " " << *it << hex << text[*it].unicode() << analysis[*it].bidiDirection; + BIDI_DEBUG() << " " << *it << Qt::hex << text[*it].unicode() << analysis[*it].bidiDirection; ++it; } } @@ -1003,7 +1003,7 @@ struct QBidiAlgorithm { BIDI_DEBUG() << "after W4/W5"; IsolatedRunSequenceIterator it(runs, i); while (!it.atEnd()) { - BIDI_DEBUG() << " " << *it << hex << text[*it].unicode() << analysis[*it].bidiDirection; + BIDI_DEBUG() << " " << *it << Qt::hex << text[*it].unicode() << analysis[*it].bidiDirection; ++it; } } @@ -1089,7 +1089,7 @@ struct QBidiAlgorithm { if (BidiDebugEnabled) { BIDI_DEBUG() << ">>>> start bidi, text length" << length; for (int i = 0; i < length; ++i) - BIDI_DEBUG() << hex << " (" << i << ")" << text[i].unicode() << text[i].direction(); + BIDI_DEBUG() << Qt::hex << " (" << i << ")" << text[i].unicode() << text[i].direction(); } { @@ -1158,7 +1158,7 @@ struct QBidiAlgorithm { if (BidiDebugEnabled) { BIDI_DEBUG() << "final resolved levels:"; for (int i = 0; i < length; ++i) - BIDI_DEBUG() << " " << i << hex << text[i].unicode() << dec << (int)analysis[i].bidiLevel; + BIDI_DEBUG() << " " << i << Qt::hex << text[i].unicode() << Qt::dec << (int)analysis[i].bidiLevel; } return true; diff --git a/src/platformsupport/fontdatabases/freetype/qfreetypefontdatabase.cpp b/src/platformsupport/fontdatabases/freetype/qfreetypefontdatabase.cpp index 4baba64de3..1028d8ec02 100644 --- a/src/platformsupport/fontdatabases/freetype/qfreetypefontdatabase.cpp +++ b/src/platformsupport/fontdatabases/freetype/qfreetypefontdatabase.cpp @@ -127,7 +127,7 @@ QStringList QFreeTypeFontDatabase::addTTFile(const QByteArray &fontData, const Q error = FT_New_Face(library, file.constData(), index, &face); } if (error != FT_Err_Ok) { - qDebug() << "FT_New_Face failed with index" << index << ':' << hex << error; + qDebug() << "FT_New_Face failed with index" << index << ':' << Qt::hex << error; break; } numFaces = face->num_faces; diff --git a/src/plugins/bearer/nla/qnlaengine.cpp b/src/plugins/bearer/nla/qnlaengine.cpp index 726e1efb92..bf10e0cc1f 100644 --- a/src/plugins/bearer/nla/qnlaengine.cpp +++ b/src/plugins/bearer/nla/qnlaengine.cpp @@ -75,38 +75,38 @@ QWindowsSockInit2::~QWindowsSockInit2() #ifdef BEARER_MANAGEMENT_DEBUG static void printBlob(NLA_BLOB *blob) { - qDebug() << "==== BEGIN NLA_BLOB ====" << endl + qDebug() << "==== BEGIN NLA_BLOB ====" << Qt::endl - << "type:" << blob->header.type << endl - << "size:" << blob->header.dwSize << endl + << "type:" << blob->header.type << Qt::endl + << "size:" << blob->header.dwSize << Qt::endl << "next offset:" << blob->header.nextOffset; switch (blob->header.type) { case NLA_RAW_DATA: - qDebug() << "Raw Data" << endl + qDebug() << "Raw Data" << Qt::endl << '\t' << blob->data.rawData; break; case NLA_INTERFACE: - qDebug() << "Interface" << endl - << "\ttype:" << blob->data.interfaceData.dwType << endl - << "\tspeed:" << blob->data.interfaceData.dwSpeed << endl + qDebug() << "Interface" << Qt::endl + << "\ttype:" << blob->data.interfaceData.dwType << Qt::endl + << "\tspeed:" << blob->data.interfaceData.dwSpeed << Qt::endl << "\tadapter:" << blob->data.interfaceData.adapterName; break; case NLA_802_1X_LOCATION: - qDebug() << "802.1x Location" << endl + qDebug() << "802.1x Location" << Qt::endl << '\t' << blob->data.locationData.information; break; case NLA_CONNECTIVITY: - qDebug() << "Connectivity" << endl - << "\ttype:" << blob->data.connectivity.type << endl + qDebug() << "Connectivity" << Qt::endl + << "\ttype:" << blob->data.connectivity.type << Qt::endl << "\tinternet:" << blob->data.connectivity.internet; break; case NLA_ICS: - qDebug() << "ICS" << endl - << "\tspeed:" << blob->data.ICS.remote.speed << endl - << "\ttype:" << blob->data.ICS.remote.type << endl - << "\tstate:" << blob->data.ICS.remote.state << endl - << "\tmachine name:" << blob->data.ICS.remote.machineName << endl + qDebug() << "ICS" << Qt::endl + << "\tspeed:" << blob->data.ICS.remote.speed << Qt::endl + << "\ttype:" << blob->data.ICS.remote.type << Qt::endl + << "\tstate:" << blob->data.ICS.remote.state << Qt::endl + << "\tmachine name:" << blob->data.ICS.remote.machineName << Qt::endl << "\tshared adapter name:" << blob->data.ICS.remote.sharedAdapterName; break; default: diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index 6ae429b24e..70dde46ffa 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -485,7 +485,7 @@ static jboolean startQtAndroidPlugin(JNIEnv *env, jobject /*object*/, jstring pa } if (Q_UNLIKELY(!m_main)) { - qCritical() << "dlsym failed:" << dlerror() << endl + qCritical() << "dlsym failed:" << dlerror() << Qt::endl << "Could not find main method"; return false; } diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm index 368cf56c80..db4ec251ae 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm @@ -177,7 +177,7 @@ NSString *macRole(QAccessibleInterface *interface) if (roleMap.isEmpty()) populateRoleMap(); - // MAC_ACCESSIBILTY_DEBUG() << "role for" << interface.object() << "interface role" << hex << qtRole; + // MAC_ACCESSIBILTY_DEBUG() << "role for" << interface.object() << "interface role" << Qt::hex << qtRole; if (roleMap.contains(qtRole)) { // MAC_ACCESSIBILTY_DEBUG() << "return" << roleMap[qtRole]; diff --git a/src/plugins/platforms/cocoa/qnsview_gestures.mm b/src/plugins/platforms/cocoa/qnsview_gestures.mm index 61d551ee0e..f6cd3af4da 100644 --- a/src/plugins/platforms/cocoa/qnsview_gestures.mm +++ b/src/plugins/platforms/cocoa/qnsview_gestures.mm @@ -70,7 +70,7 @@ Q_LOGGING_CATEGORY(lcQpaGestures, "qt.qpa.input.gestures") if ([self handleGestureAsBeginEnd:event]) return; - qCDebug(lcQpaGestures) << "magnifyWithEvent" << [event magnification] << "from device" << hex << [event deviceID]; + qCDebug(lcQpaGestures) << "magnifyWithEvent" << [event magnification] << "from device" << Qt::hex << [event deviceID]; const NSTimeInterval timestamp = [event timestamp]; QPointF windowPoint; QPointF screenPoint; @@ -85,7 +85,7 @@ Q_LOGGING_CATEGORY(lcQpaGestures, "qt.qpa.input.gestures") return; static bool zoomIn = true; - qCDebug(lcQpaGestures) << "smartMagnifyWithEvent" << zoomIn << "from device" << hex << [event deviceID]; + qCDebug(lcQpaGestures) << "smartMagnifyWithEvent" << zoomIn << "from device" << Qt::hex << [event deviceID]; const NSTimeInterval timestamp = [event timestamp]; QPointF windowPoint; QPointF screenPoint; @@ -116,7 +116,7 @@ Q_LOGGING_CATEGORY(lcQpaGestures, "qt.qpa.input.gestures") if (!m_platformWindow) return; - qCDebug(lcQpaGestures) << "swipeWithEvent" << [event deltaX] << [event deltaY] << "from device" << hex << [event deviceID]; + qCDebug(lcQpaGestures) << "swipeWithEvent" << [event deltaX] << [event deltaY] << "from device" << Qt::hex << [event deviceID]; const NSTimeInterval timestamp = [event timestamp]; QPointF windowPoint; QPointF screenPoint; @@ -145,7 +145,7 @@ Q_LOGGING_CATEGORY(lcQpaGestures, "qt.qpa.input.gestures") QPointF windowPoint; QPointF screenPoint; [self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; - qCDebug(lcQpaGestures) << "beginGestureWithEvent @" << windowPoint << "from device" << hex << [event deviceID]; + qCDebug(lcQpaGestures) << "beginGestureWithEvent @" << windowPoint << "from device" << Qt::hex << [event deviceID]; QWindowSystemInterface::handleGestureEvent(m_platformWindow->window(), QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), timestamp, Qt::BeginNativeGesture, windowPoint, screenPoint); } @@ -155,7 +155,7 @@ Q_LOGGING_CATEGORY(lcQpaGestures, "qt.qpa.input.gestures") if (!m_platformWindow) return; - qCDebug(lcQpaGestures) << "endGestureWithEvent" << "from device" << hex << [event deviceID]; + qCDebug(lcQpaGestures) << "endGestureWithEvent" << "from device" << Qt::hex << [event deviceID]; const NSTimeInterval timestamp = [event timestamp]; QPointF windowPoint; QPointF screenPoint; diff --git a/src/plugins/platforms/cocoa/qnsview_touch.mm b/src/plugins/platforms/cocoa/qnsview_touch.mm index e789213f70..9330844aec 100644 --- a/src/plugins/platforms/cocoa/qnsview_touch.mm +++ b/src/plugins/platforms/cocoa/qnsview_touch.mm @@ -60,7 +60,7 @@ Q_LOGGING_CATEGORY(lcQpaTouch, "qt.qpa.input.touch") const NSTimeInterval timestamp = [event timestamp]; const QList points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]); - qCDebug(lcQpaTouch) << "touchesBeganWithEvent" << points << "from device" << hex << [event deviceID]; + qCDebug(lcQpaTouch) << "touchesBeganWithEvent" << points << "from device" << Qt::hex << [event deviceID]; QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), points); } @@ -71,7 +71,7 @@ Q_LOGGING_CATEGORY(lcQpaTouch, "qt.qpa.input.touch") const NSTimeInterval timestamp = [event timestamp]; const QList points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]); - qCDebug(lcQpaTouch) << "touchesMovedWithEvent" << points << "from device" << hex << [event deviceID]; + qCDebug(lcQpaTouch) << "touchesMovedWithEvent" << points << "from device" << Qt::hex << [event deviceID]; QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), points); } @@ -82,7 +82,7 @@ Q_LOGGING_CATEGORY(lcQpaTouch, "qt.qpa.input.touch") const NSTimeInterval timestamp = [event timestamp]; const QList points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]); - qCDebug(lcQpaTouch) << "touchesEndedWithEvent" << points << "from device" << hex << [event deviceID]; + qCDebug(lcQpaTouch) << "touchesEndedWithEvent" << points << "from device" << Qt::hex << [event deviceID]; QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), points); } @@ -93,7 +93,7 @@ Q_LOGGING_CATEGORY(lcQpaTouch, "qt.qpa.input.touch") const NSTimeInterval timestamp = [event timestamp]; const QList points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]); - qCDebug(lcQpaTouch) << "touchesCancelledWithEvent" << points << "from device" << hex << [event deviceID]; + qCDebug(lcQpaTouch) << "touchesCancelledWithEvent" << points << "from device" << Qt::hex << [event deviceID]; QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), points); } diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp index 24051c352e..09a10bcc9c 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp @@ -157,7 +157,7 @@ gbm_surface *QEglFSKmsGbmScreen::createSurface(EGLConfig eglConfig) const auto gbmDevice = static_cast(device())->gbmDevice(); EGLint native_format = -1; EGLBoolean success = eglGetConfigAttrib(display(), eglConfig, EGL_NATIVE_VISUAL_ID, &native_format); - qCDebug(qLcEglfsKmsDebug) << "Got native format" << hex << native_format << dec << "from eglGetConfigAttrib() with return code" << bool(success); + qCDebug(qLcEglfsKmsDebug) << "Got native format" << Qt::hex << native_format << Qt::dec << "from eglGetConfigAttrib() with return code" << bool(success); if (success) m_gbm_surface = gbm_surface_create(gbmDevice, diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 073d6da536..9ab9c2708b 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -590,7 +590,7 @@ QString QWindowsContext::registerWindowClass(QString cname, d->m_registeredWindowClassNames.insert(cname); qCDebug(lcQpaWindows).nospace() << __FUNCTION__ << ' ' << cname - << " style=0x" << hex << style << dec + << " style=0x" << Qt::hex << style << Qt::dec << " brush=" << brush << " icon=" << icon << " atom=" << atom; return cname; } @@ -1570,7 +1570,7 @@ extern "C" LRESULT QT_WIN_CALLBACK qWindowsWndProc(HWND hwnd, UINT message, WPAR if (QWindowsContext::verbose > 1 && lcQpaEvents().isDebugEnabled()) { if (const char *eventName = QWindowsGuiEventDispatcher::windowsMessageName(message)) { qCDebug(lcQpaEvents).nospace() << "EVENT: hwd=" << hwnd << ' ' << eventName - << " msg=0x" << hex << message << " et=0x" << et << dec << " wp=" + << " msg=0x" << Qt::hex << message << " et=0x" << et << Qt::dec << " wp=" << int(wParam) << " at " << GET_X_LPARAM(lParam) << ',' << GET_Y_LPARAM(lParam) << " handled=" << handled; } diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index 9de3268fc8..e0bd38c951 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -736,7 +736,7 @@ QString QWindowsShellItem::libraryItemDefaultSaveFolder(IShellItem *item) #ifndef QT_NO_DEBUG_STREAM void QWindowsShellItem::format(QDebug &d) const { - d << "attributes=0x" << hex << attributes() << dec; + d << "attributes=0x" << Qt::hex << attributes() << Qt::dec; if (isFileSystem()) d << " [filesys]"; if (isDir()) @@ -972,7 +972,7 @@ void QWindowsNativeFileDialogBase::doExec(HWND owner) // gets a WM_CLOSE or the parent window is destroyed. const HRESULT hr = m_fileDialog->Show(owner); QWindowsDialogs::eatMouseMove(); - qCDebug(lcQpaDialogs) << '<' << __FUNCTION__ << " returns " << hex << hr; + qCDebug(lcQpaDialogs) << '<' << __FUNCTION__ << " returns " << Qt::hex << hr; // Emit accepted() only if there is a result as otherwise UI hangs occur. // For example, typing in invalid URLs results in empty result lists. if (hr == S_OK && !m_data.selectedFiles().isEmpty()) { @@ -1013,7 +1013,7 @@ void QWindowsNativeFileDialogBase::setMode(QFileDialogOptions::FileMode mode, } qCDebug(lcQpaDialogs) << __FUNCTION__ << "mode=" << mode << "acceptMode=" << acceptMode << "options=" << options - << "results in" << showbase << hex << flags; + << "results in" << Qt::showbase << Qt::hex << flags; if (FAILED(m_fileDialog->SetOptions(flags))) qErrnoWarning("%s: SetOptions() failed", __FUNCTION__); diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp index 322865b0f3..502c92ef59 100644 --- a/src/plugins/platforms/windows/qwindowsdrag.cpp +++ b/src/plugins/platforms/windows/qwindowsdrag.cpp @@ -428,7 +428,7 @@ QWindowsOleDropSource::QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState) if (QWindowsContext::verbose > 1 || result != S_OK) { qCDebug(lcQpaMime) << __FUNCTION__ << "fEscapePressed=" << fEscapePressed << "grfKeyState=" << grfKeyState << "buttons" << m_currentButtons - << "returns 0x" << hex << int(result) << dec; + << "returns 0x" << Qt::hex << int(result) << Qt::dec; } return ResultFromScode(result); } @@ -710,7 +710,7 @@ Qt::DropAction QWindowsDrag::drag(QDrag *drag) const Qt::DropActions possibleActions = drag->supportedActions(); const DWORD allowedEffects = translateToWinDragEffects(possibleActions); qCDebug(lcQpaMime) << '>' << __FUNCTION__ << "possible Actions=0x" - << hex << int(possibleActions) << "effects=0x" << allowedEffects << dec; + << Qt::hex << int(possibleActions) << "effects=0x" << allowedEffects << Qt::dec; // Indicate message handlers we are in DoDragDrop() event loop. QWindowsDrag::m_dragging = true; const HRESULT r = DoDragDrop(dropDataObject, windowDropSource, allowedEffects, &resultEffect); @@ -734,9 +734,9 @@ Qt::DropAction QWindowsDrag::drag(QDrag *drag) dropDataObject->releaseQt(); dropDataObject->Release(); // Will delete obj if refcount becomes 0 windowDropSource->Release(); // Will delete src if refcount becomes 0 - qCDebug(lcQpaMime) << '<' << __FUNCTION__ << hex << "allowedEffects=0x" << allowedEffects + qCDebug(lcQpaMime) << '<' << __FUNCTION__ << Qt::hex << "allowedEffects=0x" << allowedEffects << "reportedPerformedEffect=0x" << reportedPerformedEffect - << " resultEffect=0x" << resultEffect << "hr=0x" << int(r) << dec << "dropAction=" << dragResult; + << " resultEffect=0x" << resultEffect << "hr=0x" << int(r) << Qt::dec << "dropAction=" << dragResult; return dragResult; } diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp index e95eaef420..d534ce87cd 100644 --- a/src/plugins/platforms/windows/qwindowsglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp @@ -243,7 +243,7 @@ QDebug operator<<(QDebug d, const PIXELFORMATDESCRIPTOR &pd) QDebugStateSaver saver(d); d.nospace(); d << "PIXELFORMATDESCRIPTOR " - << "dwFlags=" << hex << showbase << pd.dwFlags << dec << noshowbase; + << "dwFlags=" << Qt::hex << Qt::showbase << pd.dwFlags << Qt::dec << Qt::noshowbase; if (pd.dwFlags & PFD_DRAW_TO_WINDOW) d << " PFD_DRAW_TO_WINDOW"; if (pd.dwFlags & PFD_DRAW_TO_BITMAP) d << " PFD_DRAW_TO_BITMAP"; if (pd.dwFlags & PFD_SUPPORT_GDI) d << " PFD_SUPPORT_GDI"; @@ -631,10 +631,10 @@ static int choosePixelFormat(HDC hdc, nsp << __FUNCTION__; if (sampleBuffersRequested) nsp << " samples=" << iAttributes[samplesValuePosition]; - nsp << " Attributes: " << hex << showbase; + nsp << " Attributes: " << Qt::hex << Qt::showbase; for (int ii = 0; ii < i; ++ii) nsp << iAttributes[ii] << ','; - nsp << noshowbase << dec << "\n obtained px #" << pixelFormat + nsp << Qt::noshowbase << Qt::dec << "\n obtained px #" << pixelFormat << " of " << numFormats << "\n " << *obtainedPfd; qCDebug(lcQpaGl) << message; } // Debug @@ -784,7 +784,7 @@ static HGLRC createContext(const QOpenGLStaticContext &staticContext, if (!result) { QString message; QDebug(&message).nospace() << __FUNCTION__ << ": wglCreateContextAttribsARB() failed (GL error code: 0x" - << hex << staticContext.opengl32.glGetError() << dec << ") for format: " << format << ", shared context: " << shared; + << Qt::hex << staticContext.opengl32.glGetError() << Qt::dec << ") for format: " << format << ", shared context: " << shared; qErrnoWarning("%s", qPrintable(message)); } return result; diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp index 878f55e56b..71ed33f85b 100644 --- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp @@ -657,9 +657,9 @@ void QWindowsInputContext::handleInputLanguageChanged(WPARAM wparam, LPARAM lpar m_locale = qt_localeFromLCID(m_languageId); emitLocaleChanged(); - qCDebug(lcQpaInputMethods) << __FUNCTION__ << hex << showbase + qCDebug(lcQpaInputMethods) << __FUNCTION__ << Qt::hex << Qt::showbase << oldLanguageId << "->" << newLanguageId << "Character set:" - << DWORD(wparam) << dec << noshowbase << m_locale; + << DWORD(wparam) << Qt::dec << Qt::noshowbase << m_locale; } /*! diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 2c90b0484e..e896f9f0ee 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -324,7 +324,7 @@ QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) cons if (window->type() == Qt::Desktop) { QWindowsDesktopWindow *result = new QWindowsDesktopWindow(window); qCDebug(lcQpaWindows) << "Desktop window:" << window - << showbase << hex << result->winId() << noshowbase << dec << result->geometry(); + << Qt::showbase << Qt::hex << result->winId() << Qt::noshowbase << Qt::dec << result->geometry(); return result; } @@ -373,8 +373,8 @@ QPlatformWindow *QWindowsIntegration::createForeignWindow(QWindow *window, WId n screen = pScreen->screen(); if (screen && screen != window->screen()) window->setScreen(screen); - qCDebug(lcQpaWindows) << "Foreign window:" << window << showbase << hex - << result->winId() << noshowbase << dec << obtainedGeometry << screen; + qCDebug(lcQpaWindows) << "Foreign window:" << window << Qt::showbase << Qt::hex + << result->winId() << Qt::noshowbase << Qt::dec << obtainedGeometry << screen; return result; } diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index c5af4d8042..44668cde78 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -554,7 +554,7 @@ QDebug operator<<(QDebug d, const KeyboardLayoutItem &k) if (const quint32 qtKey = k.qtKey[i]) { d << '[' << i << ' '; QtDebugUtils::formatQFlags(d, ModsTbl[i]); - d << ' ' << hex << showbase << qtKey << dec << noshowbase << ' '; + d << ' ' << Qt::hex << Qt::showbase << qtKey << Qt::dec << Qt::noshowbase << ' '; QtDebugUtils::formatQEnum(d, Qt::Key(qtKey)); if (qtKey >= 32 && qtKey < 128) d << " '" << char(qtKey) << '\''; @@ -776,7 +776,7 @@ void QWindowsKeyMapper::updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32 ::ToAscii(vk_key, scancode, kbdBuffer, reinterpret_cast(&buffer), 0); } qCDebug(lcQpaEvents) << __FUNCTION__ << "for virtual key=" - << hex << showbase << vk_key << dec << noshowbase << keyLayout[vk_key]; + << Qt::hex << Qt::showbase << vk_key << Qt::dec << Qt::noshowbase << keyLayout[vk_key]; } static inline QString messageKeyText(const MSG &msg) @@ -1384,7 +1384,7 @@ QList QWindowsKeyMapper::possibleKeys(const QKeyEvent *e) const } } qCDebug(lcQpaEvents) << __FUNCTION__ << e << "nativeVirtualKey=" - << showbase << hex << e->nativeVirtualKey() << dec << noshowbase + << Qt::showbase << Qt::hex << e->nativeVirtualKey() << Qt::dec << Qt::noshowbase << e->modifiers() << kbItem << "\n returns" << formatKeys(result); return result; } diff --git a/src/plugins/platforms/windows/qwindowsmenu.cpp b/src/plugins/platforms/windows/qwindowsmenu.cpp index 17a1b94101..e55e283fe1 100644 --- a/src/plugins/platforms/windows/qwindowsmenu.cpp +++ b/src/plugins/platforms/windows/qwindowsmenu.cpp @@ -896,8 +896,8 @@ void QWindowsMenuItem::formatDebug(QDebug &d) const d << ", parentMenu=" << static_cast(m_parentMenu); if (m_subMenu) d << ", subMenu=" << static_cast(m_subMenu); - d << ", tag=" << showbase << hex - << tag() << noshowbase << dec << ", id=" << m_id; + d << ", tag=" << Qt::showbase << Qt::hex + << tag() << Qt::noshowbase << Qt::dec << ", id=" << m_id; #if QT_CONFIG(shortcut) if (!m_shortcut.isEmpty()) d << ", shortcut=" << m_shortcut; @@ -933,7 +933,7 @@ void QWindowsMenu::formatDebug(QDebug &d) const if (m_parentMenu != nullptr) d << " [on menu]"; if (tag()) - d << ", tag=" << showbase << hex << tag() << noshowbase << dec; + d << ", tag=" << Qt::showbase << Qt::hex << tag() << Qt::noshowbase << Qt::dec; if (m_visible) d << " [visible]"; if (m_enabled) diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index 737fd1d2a9..c4d53855a5 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -124,8 +124,8 @@ static inline QTouchDevice *createTouchDevice() return nullptr; const int tabletPc = GetSystemMetrics(SM_TABLETPC); const int maxTouchPoints = GetSystemMetrics(SM_MAXIMUMTOUCHES); - qCDebug(lcQpaEvents) << "Digitizers:" << hex << showbase << (digitizers & ~NID_READY) - << "Ready:" << (digitizers & NID_READY) << dec << noshowbase + qCDebug(lcQpaEvents) << "Digitizers:" << Qt::hex << Qt::showbase << (digitizers & ~NID_READY) + << "Ready:" << (digitizers & NID_READY) << Qt::dec << Qt::noshowbase << "Tablet PC:" << tabletPc << "Max touch points:" << maxTouchPoints; QTouchDevice *result = new QTouchDevice; result->setType(digitizers & NID_INTEGRATED_TOUCH diff --git a/src/plugins/platforms/windows/qwindowsole.cpp b/src/plugins/platforms/windows/qwindowsole.cpp index e9c3f2cbf6..fb6a74581a 100644 --- a/src/plugins/platforms/windows/qwindowsole.cpp +++ b/src/plugins/platforms/windows/qwindowsole.cpp @@ -110,7 +110,7 @@ QWindowsOleDataObject::GetData(LPFORMATETC pformatetc, LPSTGMEDIUM pmedium) } if (QWindowsContext::verbose > 1 && lcQpaMime().isDebugEnabled()) - qCDebug(lcQpaMime) <<__FUNCTION__ << *pformatetc << "returns" << hex << showbase << quint64(hr); + qCDebug(lcQpaMime) <<__FUNCTION__ << *pformatetc << "returns" << Qt::hex << Qt::showbase << quint64(hr); return hr; } @@ -135,7 +135,7 @@ QWindowsOleDataObject::QueryGetData(LPFORMATETC pformatetc) ResultFromScode(S_OK) : ResultFromScode(S_FALSE); } if (QWindowsContext::verbose > 1) - qCDebug(lcQpaMime) << __FUNCTION__ << " returns 0x" << hex << int(hr); + qCDebug(lcQpaMime) << __FUNCTION__ << " returns 0x" << Qt::hex << int(hr); return hr; } @@ -163,7 +163,7 @@ QWindowsOleDataObject::SetData(LPFORMATETC pFormatetc, STGMEDIUM *pMedium, BOOL hr = ResultFromScode(S_OK); } if (QWindowsContext::verbose > 1) - qCDebug(lcQpaMime) << __FUNCTION__ << " returns 0x" << hex << int(hr); + qCDebug(lcQpaMime) << __FUNCTION__ << " returns 0x" << Qt::hex << int(hr); return hr; } diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp index 840a3a11c4..35418a18e7 100644 --- a/src/plugins/platforms/windows/qwindowsopengltester.cpp +++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp @@ -188,9 +188,9 @@ QDebug operator<<(QDebug d, const GpuDescription &gd) { QDebugStateSaver s(d); d.nospace(); - d << hex << showbase << "GpuDescription(vendorId=" << gd.vendorId + d << Qt::hex << Qt::showbase << "GpuDescription(vendorId=" << gd.vendorId << ", deviceId=" << gd.deviceId << ", subSysId=" << gd.subSysId - << dec << noshowbase << ", revision=" << gd.revision + << Qt::dec << Qt::noshowbase << ", revision=" << gd.revision << ", driver: " << gd.driverName << ", version=" << gd.driverVersion << ", " << gd.description << gd.gpuSuitableScreen << ')'; @@ -207,11 +207,11 @@ QString GpuDescription::toString() const << "\n Driver Name : " << driverName << "\n Driver Version : " << driverVersion.toString() << "\n Vendor ID : 0x" << qSetPadChar(QLatin1Char('0')) - << uppercasedigits << hex << qSetFieldWidth(4) << vendorId + << Qt::uppercasedigits << Qt::hex << qSetFieldWidth(4) << vendorId << "\n Device ID : 0x" << qSetFieldWidth(4) << deviceId << "\n SubSys ID : 0x" << qSetFieldWidth(8) << subSysId << "\n Revision ID : 0x" << qSetFieldWidth(4) << revision - << dec; + << Qt::dec; if (!gpuSuitableScreen.isEmpty()) str << "\nGL windows forced to screen: " << gpuSuitableScreen; return result; diff --git a/src/plugins/platforms/windows/qwindowspointerhandler.cpp b/src/plugins/platforms/windows/qwindowspointerhandler.cpp index 9a8b5d5121..7da87a32d5 100644 --- a/src/plugins/platforms/windows/qwindowspointerhandler.cpp +++ b/src/plugins/platforms/windows/qwindowspointerhandler.cpp @@ -315,8 +315,8 @@ static QTouchDevice *createTouchDevice() return nullptr; const int tabletPc = GetSystemMetrics(SM_TABLETPC); const int maxTouchPoints = GetSystemMetrics(SM_MAXIMUMTOUCHES); - qCDebug(lcQpaEvents) << "Digitizers:" << hex << showbase << (digitizers & ~NID_READY) - << "Ready:" << (digitizers & NID_READY) << dec << noshowbase + qCDebug(lcQpaEvents) << "Digitizers:" << Qt::hex << Qt::showbase << (digitizers & ~NID_READY) + << "Ready:" << (digitizers & NID_READY) << Qt::dec << Qt::noshowbase << "Tablet PC:" << tabletPc << "Max touch points:" << maxTouchPoints; QTouchDevice *result = new QTouchDevice; result->setType(digitizers & NID_INTEGRATED_TOUCH @@ -469,19 +469,19 @@ bool QWindowsPointerHandler::translateTouchEvent(QWindow *window, HWND hwnd, QList touchPoints; if (QWindowsContext::verbose > 1) - qCDebug(lcQpaEvents).noquote().nospace() << showbase + qCDebug(lcQpaEvents).noquote().nospace() << Qt::showbase << __FUNCTION__ - << " message=" << hex << msg.message - << " count=" << dec << count; + << " message=" << Qt::hex << msg.message + << " count=" << Qt::dec << count; Qt::TouchPointStates allStates = 0; for (quint32 i = 0; i < count; ++i) { if (QWindowsContext::verbose > 1) - qCDebug(lcQpaEvents).noquote().nospace() << showbase + qCDebug(lcQpaEvents).noquote().nospace() << Qt::showbase << " TouchPoint id=" << touchInfo[i].pointerInfo.pointerId << " frame=" << touchInfo[i].pointerInfo.frameId - << " flags=" << hex << touchInfo[i].pointerInfo.pointerFlags; + << " flags=" << Qt::hex << touchInfo[i].pointerInfo.pointerFlags; QWindowSystemInterface::TouchPoint touchPoint; const quint32 pointerId = touchInfo[i].pointerInfo.pointerId; @@ -563,11 +563,11 @@ bool QWindowsPointerHandler::translatePenEvent(QWindow *window, HWND hwnd, QtWin const int z = 0; if (QWindowsContext::verbose > 1) - qCDebug(lcQpaEvents).noquote().nospace() << showbase + qCDebug(lcQpaEvents).noquote().nospace() << Qt::showbase << __FUNCTION__ << " sourceDevice=" << sourceDevice << " globalPos=" << globalPos << " localPos=" << localPos << " hiResGlobalPos=" << hiResGlobalPos - << " message=" << hex << msg.message - << " flags=" << hex << penInfo->pointerInfo.pointerFlags; + << " message=" << Qt::hex << msg.message + << " flags=" << Qt::hex << penInfo->pointerInfo.pointerFlags; const QTabletEvent::TabletDevice device = QTabletEvent::Stylus; QTabletEvent::PointerType type; diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.cpp b/src/plugins/platforms/windows/qwindowstabletsupport.cpp index fa209f09c4..84c963af94 100644 --- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp +++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp @@ -146,13 +146,13 @@ QDebug operator<<(QDebug d, const LOGCONTEXT &lc) QDebugStateSaver saver(d); d.nospace(); d << "LOGCONTEXT(\"" << QString::fromWCharArray(lc.lcName) << "\", options=0x" - << hex << lc.lcOptions << dec; + << Qt::hex << lc.lcOptions << Qt::dec; formatOptions(d, lc.lcOptions); - d << ", status=0x" << hex << lc.lcStatus << ", device=0x" << lc.lcDevice - << dec << ", PktRate=" << lc.lcPktRate + d << ", status=0x" << Qt::hex << lc.lcStatus << ", device=0x" << lc.lcDevice + << Qt::dec << ", PktRate=" << lc.lcPktRate << ", PktData=" << lc.lcPktData << ", PktMode=" << lc.lcPktMode - << ", MoveMask=0x" << hex << lc.lcMoveMask << ", BtnDnMask=0x" << lc.lcBtnDnMask - << ", BtnUpMask=0x" << lc.lcBtnUpMask << dec << ", SysMode=" << lc.lcSysMode + << ", MoveMask=0x" << Qt::hex << lc.lcMoveMask << ", BtnDnMask=0x" << lc.lcBtnDnMask + << ", BtnUpMask=0x" << lc.lcBtnUpMask << Qt::dec << ", SysMode=" << lc.lcSysMode << ", InOrg=(" << lc.lcInOrgX << ", " << lc.lcInOrgY << ", " << lc.lcInOrgZ << "), InExt=(" << lc.lcInExtX << ", " << lc.lcInExtY << ", " << lc.lcInExtZ << ") OutOrg=(" << lc.lcOutOrgX << ", " << lc.lcOutOrgY << ", " @@ -305,7 +305,7 @@ QString QWindowsTabletSupport::description() const << '.' << (specificationVersion & 0xFF) << " implementation: v" << (implementationVersion >> 8) << '.' << (implementationVersion & 0xFF) << ' ' << devices << " device(s), " << cursors << " cursor(s), " - << extensions << " extensions" << ", options: 0x" << hex << opts << dec; + << extensions << " extensions" << ", options: 0x" << Qt::hex << opts << Qt::dec; formatOptions(str, opts); if (m_tiltSupport) str << " tilt"; diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 338e594c7b..d55545af42 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -238,7 +238,7 @@ QDebug operator<<(QDebug d, const WINDOWPLACEMENT &wp) QDebugStateSaver saver(d); d.nospace(); d.noquote(); - d << "WINDOWPLACEMENT(flags=0x" << hex << wp.flags << dec << ", showCmd=" + d << "WINDOWPLACEMENT(flags=0x" << Qt::hex << wp.flags << Qt::dec << ", showCmd=" << wp.showCmd << ", ptMinPosition=" << wp.ptMinPosition << ", ptMaxPosition=" << wp.ptMaxPosition << ", rcNormalPosition=" << wp.rcNormalPosition; return d; @@ -248,7 +248,7 @@ QDebug operator<<(QDebug d, const GUID &guid) { QDebugStateSaver saver(d); d.nospace(); - d << '{' << hex << uppercasedigits << qSetPadChar(QLatin1Char('0')) + d << '{' << Qt::hex << Qt::uppercasedigits << qSetPadChar(QLatin1Char('0')) << qSetFieldWidth(8) << guid.Data1 << qSetFieldWidth(0) << '-' << qSetFieldWidth(4) << guid.Data2 << qSetFieldWidth(0) << '-' << qSetFieldWidth(4) @@ -883,7 +883,7 @@ QMargins QWindowsGeometryHint::frame(DWORD style, DWORD exStyle) const QMargins result(qAbs(rect.left), qAbs(rect.top), qAbs(rect.right), qAbs(rect.bottom)); qCDebug(lcQpaWindows).nospace() << __FUNCTION__ << " style=" - << showbase << hex << style << " exStyle=" << exStyle << dec << noshowbase + << Qt::showbase << Qt::hex << style << " exStyle=" << exStyle << Qt::dec << Qt::noshowbase << ' ' << rect << ' ' << result; return result; } diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp index 899081e752..81b889a80f 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp @@ -636,13 +636,13 @@ static void dumpNativeWindowsRecursion(const QXcbConnection *connection, xcb_win const QChar oldPadChar =str.padChar(); str.setFieldWidth(8); str.setPadChar(QLatin1Char('0')); - str << hex << window; + str << Qt::hex << window; str.setFieldWidth(oldFieldWidth); str.setPadChar(oldPadChar); - str << dec << " \"" + str << Qt::dec << " \"" << QXcbWindow::windowTitle(connection, window) << "\" " - << geom.width() << 'x' << geom.height() << forcesign << geom.x() << geom.y() - << noforcesign << '\n'; + << geom.width() << 'x' << geom.height() << Qt::forcesign << geom.x() << geom.y() + << Qt::noforcesign << '\n'; auto reply = Q_XCB_REPLY(xcb_query_tree, conn, window); if (reply) { diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 0fa0e8cd7b..bfc105a040 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -915,7 +915,7 @@ QByteArray QXcbScreen::getEdid() const static inline void formatRect(QDebug &debug, const QRect r) { debug << r.width() << 'x' << r.height() - << forcesign << r.x() << r.y() << noforcesign; + << Qt::forcesign << r.x() << r.y() << Qt::noforcesign; } static inline void formatSizeF(QDebug &debug, const QSizeF s) @@ -929,7 +929,7 @@ QDebug operator<<(QDebug debug, const QXcbScreen *screen) debug.nospace(); debug << "QXcbScreen(" << (const void *)screen; if (screen) { - debug << fixed << qSetRealNumberPrecision(1); + debug << Qt::fixed << qSetRealNumberPrecision(1); debug << ", name=" << screen->name(); debug << ", geometry="; formatRect(debug, screen->geometry()); @@ -947,7 +947,7 @@ QDebug operator<<(QDebug debug, const QXcbScreen *screen) debug << "), orientation=" << screen->orientation(); debug << ", depth=" << screen->depth(); debug << ", refreshRate=" << screen->refreshRate(); - debug << ", root=" << hex << screen->root(); + debug << ", root=" << Qt::hex << screen->root(); debug << ", windowManagerName=" << screen->windowManagerName(); } debug << ')'; diff --git a/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp b/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp index a27feb1505..bba0487452 100644 --- a/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp +++ b/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp @@ -213,7 +213,7 @@ void QSqlQuery_snippets() while (i.hasNext()) { i.next(); cout << i.key().toUtf8().data() << ": " - << i.value().toString().toUtf8().data() << endl; + << i.value().toString().toUtf8().data() << Qt::endl; } //! [14] } @@ -223,7 +223,7 @@ void QSqlQuery_snippets() //! [15] QList list = query.boundValues().values(); for (int i = 0; i < list.size(); ++i) - cout << i << ": " << list.at(i).toString().toUtf8().data() << endl; + cout << i << ": " << list.at(i).toString().toUtf8().data() << Qt::endl; //! [15] } } diff --git a/src/sql/kernel/qsqlrecord.cpp b/src/sql/kernel/qsqlrecord.cpp index ecbe3eacdb..c4dc5d1adb 100644 --- a/src/sql/kernel/qsqlrecord.cpp +++ b/src/sql/kernel/qsqlrecord.cpp @@ -535,7 +535,7 @@ QDebug operator<<(QDebug dbg, const QSqlRecord &r) dbg << "QSqlRecord(" << count << ')'; for (int i = 0; i < count; ++i) { dbg.nospace(); - dbg << '\n' << qSetFieldWidth(2) << right << i << left << qSetFieldWidth(0) << ':'; + dbg << '\n' << qSetFieldWidth(2) << Qt::right << i << Qt::left << qSetFieldWidth(0) << ':'; dbg.space(); dbg << r.field(i) << r.value(i).toString(); } diff --git a/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp b/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp index ea410cd257..ce4232f3e8 100644 --- a/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp +++ b/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp @@ -161,22 +161,22 @@ static QString moc(const QString &name) static QTextStream &writeHeader(QTextStream &ts, bool changesWillBeLost) { - ts << "/*" << endl - << " * This file was generated by " PROGRAMNAME " version " PROGRAMVERSION << endl - << " * Command line was: " << commandLine << endl - << " *" << endl - << " * " PROGRAMNAME " is " PROGRAMCOPYRIGHT << endl - << " *" << endl - << " * This is an auto-generated file." << endl; + ts << "/*" << Qt::endl + << " * This file was generated by " PROGRAMNAME " version " PROGRAMVERSION << Qt::endl + << " * Command line was: " << commandLine << Qt::endl + << " *" << Qt::endl + << " * " PROGRAMNAME " is " PROGRAMCOPYRIGHT << Qt::endl + << " *" << Qt::endl + << " * This is an auto-generated file." << Qt::endl; if (changesWillBeLost) - ts << " * Do not edit! All changes made to it will be lost." << endl; + ts << " * Do not edit! All changes made to it will be lost." << Qt::endl; else - ts << " * This file may have been hand-edited. Look for HAND-EDIT comments" << endl - << " * before re-generating it." << endl; + ts << " * This file may have been hand-edited. Look for HAND-EDIT comments" << Qt::endl + << " * before re-generating it." << Qt::endl; - ts << " */" << endl - << endl; + ts << " */" << Qt::endl + << Qt::endl; return ts; } @@ -466,66 +466,66 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf } includeGuard = QString(QLatin1String("%1")) .arg(includeGuard); - hs << "#ifndef " << includeGuard << endl - << "#define " << includeGuard << endl - << endl; + hs << "#ifndef " << includeGuard << Qt::endl + << "#define " << includeGuard << Qt::endl + << Qt::endl; // include our stuff: - hs << "#include " << endl + hs << "#include " << Qt::endl << includeList - << "#include " << endl; + << "#include " << Qt::endl; for (const QString &include : qAsConst(includes)) { - hs << "#include \"" << include << "\"" << endl; + hs << "#include \"" << include << "\"" << Qt::endl; if (headerName.isEmpty()) - cs << "#include \"" << include << "\"" << endl; + cs << "#include \"" << include << "\"" << Qt::endl; } - hs << endl; + hs << Qt::endl; if (cppName != headerName) { if (!headerName.isEmpty() && headerName != QLatin1String("-")) - cs << "#include \"" << headerName << "\"" << endl << endl; + cs << "#include \"" << headerName << "\"" << Qt::endl << Qt::endl; } for (const QDBusIntrospection::Interface *interface : interfaces) { QString className = classNameForInterface(interface->name, Proxy); // comment: - hs << "/*" << endl - << " * Proxy class for interface " << interface->name << endl - << " */" << endl; - cs << "/*" << endl - << " * Implementation of interface class " << className << endl - << " */" << endl - << endl; + hs << "/*" << Qt::endl + << " * Proxy class for interface " << interface->name << Qt::endl + << " */" << Qt::endl; + cs << "/*" << Qt::endl + << " * Implementation of interface class " << className << Qt::endl + << " */" << Qt::endl + << Qt::endl; // class header: - hs << "class " << className << ": public QDBusAbstractInterface" << endl - << "{" << endl - << " Q_OBJECT" << endl; + hs << "class " << className << ": public QDBusAbstractInterface" << Qt::endl + << "{" << Qt::endl + << " Q_OBJECT" << Qt::endl; // the interface name - hs << "public:" << endl - << " static inline const char *staticInterfaceName()" << endl - << " { return \"" << interface->name << "\"; }" << endl - << endl; + hs << "public:" << Qt::endl + << " static inline const char *staticInterfaceName()" << Qt::endl + << " { return \"" << interface->name << "\"; }" << Qt::endl + << Qt::endl; // constructors/destructors: - hs << "public:" << endl - << " " << className << "(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = nullptr);" << endl - << endl - << " ~" << className << "();" << endl - << endl; - cs << className << "::" << className << "(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)" << endl - << " : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)" << endl - << "{" << endl - << "}" << endl - << endl - << className << "::~" << className << "()" << endl - << "{" << endl - << "}" << endl - << endl; + hs << "public:" << Qt::endl + << " " << className << "(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = nullptr);" << Qt::endl + << Qt::endl + << " ~" << className << "();" << Qt::endl + << Qt::endl; + cs << className << "::" << className << "(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)" << Qt::endl + << " : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)" << Qt::endl + << "{" << Qt::endl + << "}" << Qt::endl + << Qt::endl + << className << "::~" << className << "()" << Qt::endl + << "{" << Qt::endl + << "}" << Qt::endl + << Qt::endl; // properties: for (const QDBusIntrospection::Property &property : interface->properties) { @@ -545,27 +545,27 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf // it's writeable hs << " WRITE " << setter; - hs << ")" << endl; + hs << ")" << Qt::endl; // getter: if (property.access != QDBusIntrospection::Property::Write) { - hs << " inline " << type << " " << getter << "() const" << endl + hs << " inline " << type << " " << getter << "() const" << Qt::endl << " { return qvariant_cast< " << type << " >(property(\"" - << property.name << "\")); }" << endl; + << property.name << "\")); }" << Qt::endl; } // setter: if (property.access != QDBusIntrospection::Property::Read) { - hs << " inline void " << setter << "(" << constRefArg(type) << "value)" << endl + hs << " inline void " << setter << "(" << constRefArg(type) << "value)" << Qt::endl << " { setProperty(\"" << property.name - << "\", QVariant::fromValue(value)); }" << endl; + << "\", QVariant::fromValue(value)); }" << Qt::endl; } - hs << endl; + hs << Qt::endl; } // methods: - hs << "public Q_SLOTS: // METHODS" << endl; + hs << "public Q_SLOTS: // METHODS" << Qt::endl; for (const QDBusIntrospection::Method &method : interface->methods) { bool isDeprecated = method.annotations.value(QLatin1String("org.freedesktop.DBus.Deprecated")) == QLatin1String("true"); bool isNoReply = @@ -595,26 +595,26 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf QStringList argNames = makeArgNames(method.inputArgs); writeArgList(hs, argNames, method.annotations, method.inputArgs); - hs << ")" << endl - << " {" << endl - << " QList argumentList;" << endl; + hs << ")" << Qt::endl + << " {" << Qt::endl + << " QList argumentList;" << Qt::endl; if (!method.inputArgs.isEmpty()) { hs << " argumentList"; for (int argPos = 0; argPos < method.inputArgs.count(); ++argPos) hs << " << QVariant::fromValue(" << argNames.at(argPos) << ')'; - hs << ";" << endl; + hs << ";" << Qt::endl; } if (isNoReply) hs << " callWithArgumentList(QDBus::NoBlock, " - << "QStringLiteral(\"" << method.name << "\"), argumentList);" << endl; + << "QStringLiteral(\"" << method.name << "\"), argumentList);" << Qt::endl; else hs << " return asyncCallWithArgumentList(QStringLiteral(\"" - << method.name << "\"), argumentList);" << endl; + << method.name << "\"), argumentList);" << Qt::endl; // close the function: - hs << " }" << endl; + hs << " }" << Qt::endl; if (method.outputArgs.count() > 1) { // generate the old-form QDBusReply methods with multiple incoming parameters @@ -627,39 +627,39 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf QStringList argNames = makeArgNames(method.inputArgs, method.outputArgs); writeArgList(hs, argNames, method.annotations, method.inputArgs, method.outputArgs); - hs << ")" << endl - << " {" << endl - << " QList argumentList;" << endl; + hs << ")" << Qt::endl + << " {" << Qt::endl + << " QList argumentList;" << Qt::endl; int argPos = 0; if (!method.inputArgs.isEmpty()) { hs << " argumentList"; for (argPos = 0; argPos < method.inputArgs.count(); ++argPos) hs << " << QVariant::fromValue(" << argNames.at(argPos) << ')'; - hs << ";" << endl; + hs << ";" << Qt::endl; } hs << " QDBusMessage reply = callWithArgumentList(QDBus::Block, " - << "QStringLiteral(\"" << method.name << "\"), argumentList);" << endl; + << "QStringLiteral(\"" << method.name << "\"), argumentList);" << Qt::endl; argPos++; hs << " if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == " - << method.outputArgs.count() << ") {" << endl; + << method.outputArgs.count() << ") {" << Qt::endl; // yes, starting from 1 for (int i = 1; i < method.outputArgs.count(); ++i) hs << " " << argNames.at(argPos++) << " = qdbus_cast<" << templateArg(qtTypeName(method.outputArgs.at(i).type, method.annotations, i, "Out")) - << ">(reply.arguments().at(" << i << "));" << endl; - hs << " }" << endl - << " return reply;" << endl - << " }" << endl; + << ">(reply.arguments().at(" << i << "));" << Qt::endl; + hs << " }" << Qt::endl + << " return reply;" << Qt::endl + << " }" << Qt::endl; } - hs << endl; + hs << Qt::endl; } - hs << "Q_SIGNALS: // SIGNALS" << endl; + hs << "Q_SIGNALS: // SIGNALS" << Qt::endl; for (const QDBusIntrospection::Signal &signal : interface->signals_) { hs << " "; if (signal.annotations.value(QLatin1String("org.freedesktop.DBus.Deprecated")) == @@ -671,12 +671,12 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf QStringList argNames = makeArgNames(signal.outputArgs); writeSignalArgList(hs, argNames, signal.annotations, signal.outputArgs); - hs << ");" << endl; // finished for header + hs << ");" << Qt::endl; // finished for header } // close the class: - hs << "};" << endl - << endl; + hs << "};" << Qt::endl + << Qt::endl; } if (!skipNamespaces) { @@ -698,17 +698,17 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf // i parts matched // close last.arguments().count() - i namespaces: for (int j = i; j < last.count(); ++j) - hs << QString((last.count() - j - 1 + i) * 2, QLatin1Char(' ')) << "}" << endl; + hs << QString((last.count() - j - 1 + i) * 2, QLatin1Char(' ')) << "}" << Qt::endl; // open current.arguments().count() - i namespaces for (int j = i; j < current.count(); ++j) - hs << QString(j * 2, QLatin1Char(' ')) << "namespace " << current.at(j) << " {" << endl; + hs << QString(j * 2, QLatin1Char(' ')) << "namespace " << current.at(j) << " {" << Qt::endl; // add this class: if (!name.isEmpty()) { hs << QString(current.count() * 2, QLatin1Char(' ')) << "typedef ::" << classNameForInterface(it->constData()->name, Proxy) - << " " << name << ";" << endl; + << " " << name << ";" << Qt::endl; } if (it == interfaces.constEnd()) @@ -719,12 +719,12 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf } // close the include guard - hs << "#endif" << endl; + hs << "#endif" << Qt::endl; QString mocName = moc(filename); if (includeMocs && !mocName.isEmpty()) - cs << endl - << "#include \"" << mocName << "\"" << endl; + cs << Qt::endl + << "#include \"" << mocName << "\"" << Qt::endl; cs.flush(); hs.flush(); @@ -772,36 +772,36 @@ static void writeAdaptor(const QString &filename, const QDBusIntrospection::Inte } includeGuard = QString(QLatin1String("%1")) .arg(includeGuard); - hs << "#ifndef " << includeGuard << endl - << "#define " << includeGuard << endl - << endl; + hs << "#ifndef " << includeGuard << Qt::endl + << "#define " << includeGuard << Qt::endl + << Qt::endl; // include our stuff: - hs << "#include " << endl; + hs << "#include " << Qt::endl; if (cppName == headerName) - hs << "#include " << endl - << "#include " << endl; - hs << "#include " << endl; + hs << "#include " << Qt::endl + << "#include " << Qt::endl; + hs << "#include " << Qt::endl; for (const QString &include : qAsConst(includes)) { - hs << "#include \"" << include << "\"" << endl; + hs << "#include \"" << include << "\"" << Qt::endl; if (headerName.isEmpty()) - cs << "#include \"" << include << "\"" << endl; + cs << "#include \"" << include << "\"" << Qt::endl; } if (cppName != headerName) { if (!headerName.isEmpty() && headerName != QLatin1String("-")) - cs << "#include \"" << headerName << "\"" << endl; + cs << "#include \"" << headerName << "\"" << Qt::endl; - cs << "#include " << endl + cs << "#include " << Qt::endl << includeList - << endl; + << Qt::endl; hs << forwardDeclarations; } else { hs << includeList; } - hs << endl; + hs << Qt::endl; QString parent = parentClassName; if (parentClassName.isEmpty()) @@ -811,47 +811,47 @@ static void writeAdaptor(const QString &filename, const QDBusIntrospection::Inte QString className = classNameForInterface(interface->name, Adaptor); // comment: - hs << "/*" << endl - << " * Adaptor class for interface " << interface->name << endl - << " */" << endl; - cs << "/*" << endl - << " * Implementation of adaptor class " << className << endl - << " */" << endl - << endl; + hs << "/*" << Qt::endl + << " * Adaptor class for interface " << interface->name << Qt::endl + << " */" << Qt::endl; + cs << "/*" << Qt::endl + << " * Implementation of adaptor class " << className << Qt::endl + << " */" << Qt::endl + << Qt::endl; // class header: - hs << "class " << className << ": public QDBusAbstractAdaptor" << endl - << "{" << endl - << " Q_OBJECT" << endl - << " Q_CLASSINFO(\"D-Bus Interface\", \"" << interface->name << "\")" << endl - << " Q_CLASSINFO(\"D-Bus Introspection\", \"\"" << endl + hs << "class " << className << ": public QDBusAbstractAdaptor" << Qt::endl + << "{" << Qt::endl + << " Q_OBJECT" << Qt::endl + << " Q_CLASSINFO(\"D-Bus Interface\", \"" << interface->name << "\")" << Qt::endl + << " Q_CLASSINFO(\"D-Bus Introspection\", \"\"" << Qt::endl << stringify(interface->introspection) - << " \"\")" << endl - << "public:" << endl - << " " << className << "(" << parent << " *parent);" << endl - << " virtual ~" << className << "();" << endl - << endl; + << " \"\")" << Qt::endl + << "public:" << Qt::endl + << " " << className << "(" << parent << " *parent);" << Qt::endl + << " virtual ~" << className << "();" << Qt::endl + << Qt::endl; if (!parentClassName.isEmpty()) - hs << " inline " << parent << " *parent() const" << endl - << " { return static_cast<" << parent << " *>(QObject::parent()); }" << endl - << endl; + hs << " inline " << parent << " *parent() const" << Qt::endl + << " { return static_cast<" << parent << " *>(QObject::parent()); }" << Qt::endl + << Qt::endl; // constructor/destructor - cs << className << "::" << className << "(" << parent << " *parent)" << endl - << " : QDBusAbstractAdaptor(parent)" << endl - << "{" << endl - << " // constructor" << endl - << " setAutoRelaySignals(true);" << endl - << "}" << endl - << endl - << className << "::~" << className << "()" << endl - << "{" << endl - << " // destructor" << endl - << "}" << endl - << endl; + cs << className << "::" << className << "(" << parent << " *parent)" << Qt::endl + << " : QDBusAbstractAdaptor(parent)" << Qt::endl + << "{" << Qt::endl + << " // constructor" << Qt::endl + << " setAutoRelaySignals(true);" << Qt::endl + << "}" << Qt::endl + << Qt::endl + << className << "::~" << className << "()" << Qt::endl + << "{" << Qt::endl + << " // destructor" << Qt::endl + << "}" << Qt::endl + << Qt::endl; - hs << "public: // PROPERTIES" << endl; + hs << "public: // PROPERTIES" << Qt::endl; for (const QDBusIntrospection::Property &property : interface->properties) { QByteArray type = qtTypeName(property.type, property.annotations); QString constRefType = constRefArg(type); @@ -863,38 +863,38 @@ static void writeAdaptor(const QString &filename, const QDBusIntrospection::Inte hs << " READ " << getter; if (property.access != QDBusIntrospection::Property::Read) hs << " WRITE " << setter; - hs << ")" << endl; + hs << ")" << Qt::endl; // getter: if (property.access != QDBusIntrospection::Property::Write) { - hs << " " << type << " " << getter << "() const;" << endl; + hs << " " << type << " " << getter << "() const;" << Qt::endl; cs << type << " " - << className << "::" << getter << "() const" << endl - << "{" << endl - << " // get the value of property " << property.name << endl - << " return qvariant_cast< " << type <<" >(parent()->property(\"" << property.name << "\"));" << endl - << "}" << endl - << endl; + << className << "::" << getter << "() const" << Qt::endl + << "{" << Qt::endl + << " // get the value of property " << property.name << Qt::endl + << " return qvariant_cast< " << type <<" >(parent()->property(\"" << property.name << "\"));" << Qt::endl + << "}" << Qt::endl + << Qt::endl; } // setter if (property.access != QDBusIntrospection::Property::Read) { - hs << " void " << setter << "(" << constRefType << "value);" << endl; - cs << "void " << className << "::" << setter << "(" << constRefType << "value)" << endl - << "{" << endl - << " // set the value of property " << property.name << endl + hs << " void " << setter << "(" << constRefType << "value);" << Qt::endl; + cs << "void " << className << "::" << setter << "(" << constRefType << "value)" << Qt::endl + << "{" << Qt::endl + << " // set the value of property " << property.name << Qt::endl << " parent()->setProperty(\"" << property.name << "\", QVariant::fromValue(value"; if (constRefType.contains(QLatin1String("QDBusVariant"))) cs << ".variant()"; - cs << "));" << endl - << "}" << endl - << endl; + cs << "));" << Qt::endl + << "}" << Qt::endl + << Qt::endl; } - hs << endl; + hs << Qt::endl; } - hs << "public Q_SLOTS: // METHODS" << endl; + hs << "public Q_SLOTS: // METHODS" << Qt::endl; for (const QDBusIntrospection::Method &method : interface->methods) { bool isNoReply = method.annotations.value(QLatin1String(ANNOTATION_NO_WAIT)) == QLatin1String("true"); @@ -930,10 +930,10 @@ static void writeAdaptor(const QString &filename, const QDBusIntrospection::Inte writeArgList(hs, argNames, method.annotations, method.inputArgs, method.outputArgs); writeArgList(cs, argNames, method.annotations, method.inputArgs, method.outputArgs); - hs << ");" << endl; // finished for header - cs << ")" << endl - << "{" << endl - << " // handle method call " << interface->name << "." << methodName(method) << endl; + hs << ");" << Qt::endl; // finished for header + cs << ")" << Qt::endl + << "{" << Qt::endl + << " // handle method call " << interface->name << "." << methodName(method) << Qt::endl; // make the call bool usingInvokeMethod = false; @@ -945,7 +945,7 @@ static void writeAdaptor(const QString &filename, const QDBusIntrospection::Inte // we are using QMetaObject::invokeMethod if (!returnType.isEmpty()) cs << " " << returnType << " " << argNames.at(method.inputArgs.count()) - << ";" << endl; + << ";" << Qt::endl; static const char invoke[] = " QMetaObject::invokeMethod(parent(), \""; cs << invoke << name << "\""; @@ -966,10 +966,10 @@ static void writeAdaptor(const QString &filename, const QDBusIntrospection::Inte << argNames.at(i) << ")"; - cs << ");" << endl; + cs << ");" << Qt::endl; if (!returnType.isEmpty()) - cs << " return " << argNames.at(method.inputArgs.count()) << ";" << endl; + cs << " return " << argNames.at(method.inputArgs.count()) << ";" << Qt::endl; } else { if (parentClassName.isEmpty()) cs << " //"; @@ -997,13 +997,13 @@ static void writeAdaptor(const QString &filename, const QDBusIntrospection::Inte first = false; } - cs << ");" << endl; + cs << ");" << Qt::endl; } - cs << "}" << endl - << endl; + cs << "}" << Qt::endl + << Qt::endl; } - hs << "Q_SIGNALS: // SIGNALS" << endl; + hs << "Q_SIGNALS: // SIGNALS" << Qt::endl; for (const QDBusIntrospection::Signal &signal : interface->signals_) { hs << " "; if (signal.annotations.value(QLatin1String("org.freedesktop.DBus.Deprecated")) == @@ -1015,21 +1015,21 @@ static void writeAdaptor(const QString &filename, const QDBusIntrospection::Inte QStringList argNames = makeArgNames(signal.outputArgs); writeSignalArgList(hs, argNames, signal.annotations, signal.outputArgs); - hs << ");" << endl; // finished for header + hs << ");" << Qt::endl; // finished for header } // close the class: - hs << "};" << endl - << endl; + hs << "};" << Qt::endl + << Qt::endl; } // close the include guard - hs << "#endif" << endl; + hs << "#endif" << Qt::endl; QString mocName = moc(filename); if (includeMocs && !mocName.isEmpty()) - cs << endl - << "#include \"" << mocName << "\"" << endl; + cs << Qt::endl + << "#include \"" << mocName << "\"" << Qt::endl; cs.flush(); hs.flush(); diff --git a/src/tools/qlalr/cppgenerator.cpp b/src/tools/qlalr/cppgenerator.cpp index 508db696b1..10b2d173ab 100644 --- a/src/tools/qlalr/cppgenerator.cpp +++ b/src/tools/qlalr/cppgenerator.cpp @@ -43,7 +43,7 @@ void generateSeparator(int i, QTextStream &out) if (!(i % 10)) { if (i) out << ","; - out << endl << " "; + out << Qt::endl << " "; } else { out << ", "; } @@ -187,14 +187,14 @@ void CppGenerator::operator () () { if (verbose) qout() << "*** Warning. Found a reduce/reduce conflict in state " << q << " on token ``" << s << "'' between rule " - << r << " and " << -u << endl; + << r << " and " << -u << Qt::endl; ++reduce_reduce_conflict_count; u = qMax (u, -r); if (verbose) - qout() << "\tresolved using rule " << -u << endl; + qout() << "\tresolved using rule " << -u << Qt::endl; } else if (u > 0) @@ -227,7 +227,7 @@ void CppGenerator::operator () () ++shift_reduce_conflict_count; if (verbose) - qout() << "*** Warning. Found a shift/reduce conflict in state " << q << " on token ``" << s << "'' with rule " << r << endl; + qout() << "*** Warning. Found a shift/reduce conflict in state " << q << " on token ``" << s << "'' with rule " << r << Qt::endl; } } } @@ -238,11 +238,11 @@ void CppGenerator::operator () () { if (shift_reduce_conflict_count != grammar.expected_shift_reduce || reduce_reduce_conflict_count != grammar.expected_reduce_reduce) - qerr() << "*** Conflicts: " << shift_reduce_conflict_count << " shift/reduce, " << reduce_reduce_conflict_count << " reduce/reduce" << endl; + qerr() << "*** Conflicts: " << shift_reduce_conflict_count << " shift/reduce, " << reduce_reduce_conflict_count << " reduce/reduce" << Qt::endl; if (verbose) - qout() << endl << "*** Conflicts: " << shift_reduce_conflict_count << " shift/reduce, " << reduce_reduce_conflict_count << " reduce/reduce" << endl - << endl; + qout() << Qt::endl << "*** Conflicts: " << shift_reduce_conflict_count << " shift/reduce, " << reduce_reduce_conflict_count << " reduce/reduce" << Qt::endl + << Qt::endl; } QBitArray used_rules (grammar.rules.count ()); @@ -266,7 +266,7 @@ void CppGenerator::operator () () RulePointer rule = grammar.rules.begin () + i; if (rule != grammar.goal) - qerr() << "*** Warning: Rule ``" << *rule << "'' is useless!" << endl; + qerr() << "*** Warning: Rule ``" << *rule << "'' is useless!" << Qt::endl; } } @@ -348,26 +348,26 @@ void CppGenerator::operator () () { out << copyrightHeader() << privateCopyrightHeader() - << endl; + << Qt::endl; } out << "// This file was generated by qlalr - DO NOT EDIT!\n"; - out << startIncludeGuard(grammar.merged_output) << endl; + out << startIncludeGuard(grammar.merged_output) << Qt::endl; if (copyright) { - out << "#if defined(ERROR)" << endl - << "# undef ERROR" << endl - << "#endif" << endl << endl; + out << "#if defined(ERROR)" << Qt::endl + << "# undef ERROR" << Qt::endl + << "#endif" << Qt::endl << Qt::endl; } generateDecl (out); generateImpl (out); out << p.decls(); out << p.impls(); - out << endl; + out << Qt::endl; - out << endIncludeGuard(grammar.merged_output) << endl; + out << endIncludeGuard(grammar.merged_output) << Qt::endl; return; } @@ -388,24 +388,24 @@ void CppGenerator::operator () () { out << copyrightHeader() << privateCopyrightHeader() - << endl; + << Qt::endl; } out << "// This file was generated by qlalr - DO NOT EDIT!\n"; - out << "#ifndef " << prot << endl - << "#define " << prot << endl - << endl; + out << "#ifndef " << prot << Qt::endl + << "#define " << prot << Qt::endl + << Qt::endl; if (copyright) { - out << "#include " << endl << endl; - out << "QT_BEGIN_NAMESPACE" << endl << endl; + out << "#include " << Qt::endl << Qt::endl; + out << "QT_BEGIN_NAMESPACE" << Qt::endl << Qt::endl; } generateDecl (out); if (copyright) - out << "QT_END_NAMESPACE" << endl; + out << "QT_END_NAMESPACE" << Qt::endl; - out << "#endif // " << prot << endl << endl; + out << "#endif // " << prot << Qt::endl << Qt::endl; } // end decls { // bits... @@ -419,12 +419,12 @@ void CppGenerator::operator () () out << "// This file was generated by qlalr - DO NOT EDIT!\n"; - out << "#include \"" << declFileName << "\"" << endl << endl; + out << "#include \"" << declFileName << "\"" << Qt::endl << Qt::endl; if (copyright) - out << "QT_BEGIN_NAMESPACE" << endl << endl; + out << "QT_BEGIN_NAMESPACE" << Qt::endl << Qt::endl; generateImpl(out); if (copyright) - out << "QT_END_NAMESPACE" << endl; + out << "QT_END_NAMESPACE" << Qt::endl; } // end bits @@ -455,10 +455,10 @@ QString CppGenerator::debugInfoProt() const void CppGenerator::generateDecl (QTextStream &out) { - out << "class " << grammar.table_name << endl - << "{" << endl - << "public:" << endl - << " enum VariousConstants {" << endl; + out << "class " << grammar.table_name << Qt::endl + << "{" << Qt::endl + << "public:" << Qt::endl + << " enum VariousConstants {" << Qt::endl; for (const Name &t : qAsConst(grammar.terminals)) { @@ -474,62 +474,62 @@ void CppGenerator::generateDecl (QTextStream &out) else name.prepend (grammar.token_prefix); - out << " " << name << " = " << value << "," << endl; + out << " " << name << " = " << value << "," << Qt::endl; } - out << endl - << " ACCEPT_STATE = " << accept_state << "," << endl - << " RULE_COUNT = " << grammar.rules.size () << "," << endl - << " STATE_COUNT = " << state_count << "," << endl - << " TERMINAL_COUNT = " << terminal_count << "," << endl - << " NON_TERMINAL_COUNT = " << non_terminal_count << "," << endl - << endl - << " GOTO_INDEX_OFFSET = " << compressed_action.index.size () << "," << endl - << " GOTO_INFO_OFFSET = " << compressed_action.info.size () << "," << endl - << " GOTO_CHECK_OFFSET = " << compressed_action.check.size () << endl - << " };" << endl - << endl - << " static const char *const spell[];" << endl - << " static const short lhs[];" << endl - << " static const short rhs[];" << endl; + out << Qt::endl + << " ACCEPT_STATE = " << accept_state << "," << Qt::endl + << " RULE_COUNT = " << grammar.rules.size () << "," << Qt::endl + << " STATE_COUNT = " << state_count << "," << Qt::endl + << " TERMINAL_COUNT = " << terminal_count << "," << Qt::endl + << " NON_TERMINAL_COUNT = " << non_terminal_count << "," << Qt::endl + << Qt::endl + << " GOTO_INDEX_OFFSET = " << compressed_action.index.size () << "," << Qt::endl + << " GOTO_INFO_OFFSET = " << compressed_action.info.size () << "," << Qt::endl + << " GOTO_CHECK_OFFSET = " << compressed_action.check.size () << Qt::endl + << " };" << Qt::endl + << Qt::endl + << " static const char *const spell[];" << Qt::endl + << " static const short lhs[];" << Qt::endl + << " static const short rhs[];" << Qt::endl; if (debug_info) { QString prot = debugInfoProt(); - out << endl << "#ifndef " << prot << endl - << " static const int rule_index[];" << endl - << " static const int rule_info[];" << endl - << "#endif // " << prot << endl << endl; + out << Qt::endl << "#ifndef " << prot << Qt::endl + << " static const int rule_index[];" << Qt::endl + << " static const int rule_info[];" << Qt::endl + << "#endif // " << prot << Qt::endl << Qt::endl; } - out << " static const short goto_default[];" << endl - << " static const short action_default[];" << endl - << " static const short action_index[];" << endl - << " static const short action_info[];" << endl - << " static const short action_check[];" << endl - << endl - << " static inline int nt_action (int state, int nt)" << endl - << " {" << endl - << " const int yyn = action_index [GOTO_INDEX_OFFSET + state] + nt;" << endl - << " if (yyn < 0 || action_check [GOTO_CHECK_OFFSET + yyn] != nt)" << endl - << " return goto_default [nt];" << endl - << endl - << " return action_info [GOTO_INFO_OFFSET + yyn];" << endl - << " }" << endl - << endl - << " static inline int t_action (int state, int token)" << endl - << " {" << endl - << " const int yyn = action_index [state] + token;" << endl - << endl - << " if (yyn < 0 || action_check [yyn] != token)" << endl - << " return - action_default [state];" << endl - << endl - << " return action_info [yyn];" << endl - << " }" << endl - << "};" << endl - << endl - << endl; + out << " static const short goto_default[];" << Qt::endl + << " static const short action_default[];" << Qt::endl + << " static const short action_index[];" << Qt::endl + << " static const short action_info[];" << Qt::endl + << " static const short action_check[];" << Qt::endl + << Qt::endl + << " static inline int nt_action (int state, int nt)" << Qt::endl + << " {" << Qt::endl + << " const int yyn = action_index [GOTO_INDEX_OFFSET + state] + nt;" << Qt::endl + << " if (yyn < 0 || action_check [GOTO_CHECK_OFFSET + yyn] != nt)" << Qt::endl + << " return goto_default [nt];" << Qt::endl + << Qt::endl + << " return action_info [GOTO_INFO_OFFSET + yyn];" << Qt::endl + << " }" << Qt::endl + << Qt::endl + << " static inline int t_action (int state, int token)" << Qt::endl + << " {" << Qt::endl + << " const int yyn = action_index [state] + token;" << Qt::endl + << Qt::endl + << " if (yyn < 0 || action_check [yyn] != token)" << Qt::endl + << " return - action_default [state];" << Qt::endl + << Qt::endl + << " return action_info [yyn];" << Qt::endl + << " }" << Qt::endl + << "};" << Qt::endl + << Qt::endl + << Qt::endl; } void CppGenerator::generateImpl (QTextStream &out) @@ -568,16 +568,16 @@ void CppGenerator::generateImpl (QTextStream &out) { first_nt = false; QString prot = debugInfoProt(); - out << endl << "#ifndef " << prot << endl; + out << Qt::endl << "#ifndef " << prot << Qt::endl; } out << "\"" << *t << "\""; } } if (debug_info) - out << endl << "#endif // " << debugInfoProt() << endl; + out << Qt::endl << "#endif // " << debugInfoProt() << Qt::endl; - out << endl << "};" << endl << endl; + out << Qt::endl << "};" << Qt::endl << Qt::endl; out << "const short " << grammar.table_name << "::lhs [] = {"; idx = 0; @@ -587,7 +587,7 @@ void CppGenerator::generateImpl (QTextStream &out) out << aut.id (rule->lhs); } - out << endl << "};" << endl << endl; + out << Qt::endl << "};" << Qt::endl << Qt::endl; out << "const short " << grammar.table_name << "::rhs [] = {"; idx = 0; @@ -597,13 +597,13 @@ void CppGenerator::generateImpl (QTextStream &out) out << rule->rhs.size (); } - out << endl << "};" << endl << endl; + out << Qt::endl << "};" << Qt::endl << Qt::endl; if (debug_info) { QString prot = debugInfoProt(); - out << endl << "#ifndef " << prot << endl; + out << Qt::endl << "#ifndef " << prot << Qt::endl; out << "const int " << grammar.table_name << "::rule_info [] = {"; idx = 0; for (auto rule = grammar.rules.cbegin (); rule != grammar.rules.cend (); ++rule, ++idx) @@ -615,7 +615,7 @@ void CppGenerator::generateImpl (QTextStream &out) for (const Name &n : rule->rhs) out << ", " << name_ids.value (n); } - out << endl << "};" << endl << endl; + out << Qt::endl << "};" << Qt::endl << Qt::endl; out << "const int " << grammar.table_name << "::rule_index [] = {"; idx = 0; @@ -627,8 +627,8 @@ void CppGenerator::generateImpl (QTextStream &out) out << offset; offset += rule->rhs.size () + 1; } - out << endl << "};" << endl - << "#endif // " << prot << endl << endl; + out << Qt::endl << "};" << Qt::endl + << "#endif // " << prot << Qt::endl << Qt::endl; } out << "const short " << grammar.table_name << "::action_default [] = {"; @@ -642,27 +642,27 @@ void CppGenerator::generateImpl (QTextStream &out) else out << "0"; } - out << endl << "};" << endl << endl; + out << Qt::endl << "};" << Qt::endl << Qt::endl; out << "const short " << grammar.table_name << "::goto_default [] = {"; generateList(defgoto, out); - out << endl << "};" << endl << endl; + out << Qt::endl << "};" << Qt::endl << Qt::endl; out << "const short " << grammar.table_name << "::action_index [] = {"; generateList(compressed_action.index, out); - out << "," << endl; + out << "," << Qt::endl; generateList(compressed_goto.index, out); - out << endl << "};" << endl << endl; + out << Qt::endl << "};" << Qt::endl << Qt::endl; out << "const short " << grammar.table_name << "::action_info [] = {"; generateList(compressed_action.info, out); - out << "," << endl; + out << "," << Qt::endl; generateList(compressed_goto.info, out); - out << endl << "};" << endl << endl; + out << Qt::endl << "};" << Qt::endl << Qt::endl; out << "const short " << grammar.table_name << "::action_check [] = {"; generateList(compressed_action.check, out); - out << "," << endl; + out << "," << Qt::endl; generateList(compressed_goto.check, out); - out << endl << "};" << endl << endl; + out << Qt::endl << "};" << Qt::endl << Qt::endl; } diff --git a/src/tools/qlalr/dotgraph.cpp b/src/tools/qlalr/dotgraph.cpp index 1fa0a1ac77..1d479af2b2 100644 --- a/src/tools/qlalr/dotgraph.cpp +++ b/src/tools/qlalr/dotgraph.cpp @@ -41,9 +41,9 @@ void DotGraph::operator () (Automaton *aut) { Grammar *g = aut->_M_grammar; - out << "digraph {" << endl << endl; + out << "digraph {" << Qt::endl << Qt::endl; - out << "subgraph Includes {" << endl; + out << "subgraph Includes {" << Qt::endl; for (Automaton::IncludesGraph::iterator incl = Automaton::IncludesGraph::begin_nodes (); incl != Automaton::IncludesGraph::end_nodes (); ++incl) { @@ -53,14 +53,14 @@ void DotGraph::operator () (Automaton *aut) out << "\t->\t"; out << "\"(" << aut->id ((*edge)->data.state) << ", " << (*edge)->data.nt << ")\"\t"; out << "[label=\"" << incl->data.state->follows [incl->data.nt] << "\"]"; - out << endl; + out << Qt::endl; } } - out << "}" << endl << endl; + out << "}" << Qt::endl << Qt::endl; - out << "subgraph LRA {" << endl; - //out << "node [shape=record];" << endl << endl; + out << "subgraph LRA {" << Qt::endl; + //out << "node [shape=record];" << Qt::endl << Qt::endl; for (StatePointer q = aut->states.begin (); q != aut->states.end (); ++q) { @@ -74,16 +74,16 @@ void DotGraph::operator () (Automaton *aut) for (ItemPointer item = q->kernel.begin (); item != q->kernel.end (); ++item) out << "| <" << index++ << "> " << *item; - out << "}\"]" << endl; + out << "}\"]" << Qt::endl; for (Bundle::iterator a = q->bundle.begin (); a != q->bundle.end (); ++a) { const char *clr = g->isTerminal (a.key ()) ? "blue" : "red"; - out << "\t" << state << "\t->\t" << aut->id (*a) << "\t[color=\"" << clr << "\",label=\"" << a.key () << "\"]" << endl; + out << "\t" << state << "\t->\t" << aut->id (*a) << "\t[color=\"" << clr << "\",label=\"" << a.key () << "\"]" << Qt::endl; } - out << endl; + out << Qt::endl; } - out << "}" << endl; - out << endl << endl << "}" << endl; + out << "}" << Qt::endl; + out << Qt::endl << Qt::endl << "}" << Qt::endl; } diff --git a/src/tools/qlalr/lalr.cpp b/src/tools/qlalr/lalr.cpp index ec960925aa..2a82eb154e 100644 --- a/src/tools/qlalr/lalr.cpp +++ b/src/tools/qlalr/lalr.cpp @@ -313,7 +313,7 @@ void Automaton::buildNullables () } #ifndef QLALR_NO_DEBUG_NULLABLES - qerr() << "nullables = {" << nullables << endl; + qerr() << "nullables = {" << nullables << Qt::endl; #endif } @@ -456,7 +456,7 @@ void Automaton::buildLookbackSets () lookbacks.insert (item, Lookback (p, A)); #ifndef QLALR_NO_DEBUG_LOOKBACKS - qerr() << "*** (" << id (q) << ", " << *rule << ") lookback (" << id (p) << ", " << *A << ")" << endl; + qerr() << "*** (" << id (q) << ", " << *rule << ") lookback (" << id (p) << ", " << *A << ")" << Qt::endl; #endif } } @@ -487,7 +487,7 @@ void Automaton::buildDirectReads () #ifndef QLALR_NO_DEBUG_DIRECT_READS for (QMap::iterator dr = q->reads.begin (); dr != q->reads.end (); ++dr) - qerr() << "*** DR(" << id (q) << ", " << dr.key () << ") = " << dr.value () << endl; + qerr() << "*** DR(" << id (q) << ", " << dr.key () << ") = " << dr.value () << Qt::endl; #endif } } @@ -520,7 +520,7 @@ void Automaton::buildReadsDigraph () dump (qerr(), source); qerr() << " reads "; dump (qerr(), target); - qerr() << endl; + qerr() << Qt::endl; #endif } } @@ -555,7 +555,7 @@ void Automaton::visitReadNode (ReadNode node) _M_reads_stack.push (node); #ifndef QLALR_NO_DEBUG_INCLUDES - // qerr() << "*** Debug. visit node (" << id (node->data.state) << ", " << node->data.nt << ") N = " << N << endl; + // qerr() << "*** Debug. visit node (" << id (node->data.state) << ", " << node->data.nt << ") N = " << N << Qt::endl; #endif for (ReadsGraph::edge_iterator edge = node->begin (); edge != node->end (); ++edge) @@ -635,7 +635,7 @@ void Automaton::buildIncludesDigraph () source->insertEdge (target); #ifndef QLALR_NO_DEBUG_INCLUDES - qerr() << "*** (" << id (p) << ", " << *A << ") includes (" << id (pp) << ", " << *name << ")" << endl; + qerr() << "*** (" << id (p) << ", " << *A << ") includes (" << id (pp) << ", " << *name << ")" << Qt::endl; #endif // QLALR_NO_DEBUG_INCLUDES continue; @@ -657,7 +657,7 @@ void Automaton::buildIncludesDigraph () source->insertEdge (target); #ifndef QLALR_NO_DEBUG_INCLUDES - qerr() << "*** (" << id (p) << ", " << *A << ") includes (" << id (pp) << ", " << *name << ")" << endl; + qerr() << "*** (" << id (p) << ", " << *A << ") includes (" << id (pp) << ", " << *name << ")" << Qt::endl; #endif // QLALR_NO_DEBUG_INCLUDES } } @@ -674,7 +674,7 @@ void Automaton::visitIncludeNode (IncludeNode node) _M_includes_stack.push (node); #ifndef QLALR_NO_DEBUG_INCLUDES - // qerr() << "*** Debug. visit node (" << id (node->data.state) << ", " << node->data.nt << ") N = " << N << endl; + // qerr() << "*** Debug. visit node (" << id (node->data.state) << ", " << node->data.nt << ") N = " << N << Qt::endl; #endif for (IncludesGraph::edge_iterator edge = node->begin (); edge != node->end (); ++edge) @@ -690,7 +690,7 @@ void Automaton::visitIncludeNode (IncludeNode node) dump (qerr(), node); qerr() << " += follows"; dump (qerr(), r); - qerr() << endl; + qerr() << Qt::endl; #endif NameSet &dst = node->data.state->follows [node->data.nt]; @@ -726,7 +726,7 @@ void Automaton::buildLookaheads () #ifndef QLALR_NO_DEBUG_LOOKAHEADS qerr() << "(" << id (p) << ", " << *item->rule << ") lookbacks "; dump (qerr(), lookback); - qerr() << " with follows (" << id (q) << ", " << lookback.nt << ") = " << q->follows [lookback.nt] << endl; + qerr() << " with follows (" << id (q) << ", " << lookback.nt << ") = " << q->follows [lookback.nt] << Qt::endl; #endif lookaheads [item].insert (q->follows [lookback.nt].begin (), q->follows [lookback.nt].end ()); diff --git a/src/tools/qlalr/lalr.g b/src/tools/qlalr/lalr.g index 05d30c21fd..a849800dd5 100644 --- a/src/tools/qlalr/lalr.g +++ b/src/tools/qlalr/lalr.g @@ -261,7 +261,7 @@ int Recognizer::nextToken() if (ch == QLatin1Char ('"')) inp (); else - qerr() << _M_input_file << ":" << _M_line << ": Warning. Expected `\"'" << endl; + qerr() << _M_input_file << ":" << _M_line << ": Warning. Expected `\"'" << Qt::endl; _M_current_value = text; return (token = STRING_LITERAL); @@ -314,7 +314,7 @@ int Recognizer::nextToken() return (token = PREC); else { - qerr() << _M_input_file << ":" << _M_line << ": Unknown keyword `" << text << "'" << endl; + qerr() << _M_input_file << ":" << _M_line << ": Unknown keyword `" << text << "'" << Qt::endl; exit (EXIT_FAILURE); return (token = ERROR); } @@ -659,7 +659,7 @@ case $rule_number: { if (_M_grammar->terminals.find (_M_current_rule->lhs) != _M_grammar->terminals.end ()) { - qerr() << _M_input_file << ":" << _M_line << ": Invalid non terminal `" << *_M_current_rule->lhs << "'" << endl; + qerr() << _M_input_file << ":" << _M_line << ": Invalid non terminal `" << *_M_current_rule->lhs << "'" << Qt::endl; return false; } @@ -683,7 +683,7 @@ case $rule_number: { if (_M_grammar->terminals.find (_M_current_rule->lhs) != _M_grammar->terminals.end ()) { - qerr() << _M_input_file << ":" << _M_line << ": Invalid non terminal `" << *_M_current_rule->lhs << "'" << endl; + qerr() << _M_input_file << ":" << _M_line << ": Invalid non terminal `" << *_M_current_rule->lhs << "'" << Qt::endl; return false; } @@ -712,7 +712,7 @@ case $rule_number: { Name tok = _M_grammar->intern (sym(2)); if (! _M_grammar->isTerminal (tok)) { - qerr() << _M_input_file << ":" << _M_line << ": `" << *tok << " is not a terminal symbol" << endl; + qerr() << _M_input_file << ":" << _M_line << ": `" << *tok << " is not a terminal symbol" << Qt::endl; _M_current_rule->prec = _M_grammar->names.end (); } else @@ -758,7 +758,7 @@ case $rule_number: { } } - qerr() << _M_input_file << ":" << _M_line << ": Syntax error" << endl; + qerr() << _M_input_file << ":" << _M_line << ": Syntax error" << Qt::endl; return false; } diff --git a/src/tools/qlalr/main.cpp b/src/tools/qlalr/main.cpp index 5971eb201d..a920b13c85 100644 --- a/src/tools/qlalr/main.cpp +++ b/src/tools/qlalr/main.cpp @@ -44,15 +44,15 @@ static void help_me () { - qerr() << "Usage: qlalr [options] [input file name]" << endl - << endl - << " --help, -h\t\tdisplay this help and exit" << endl - << " --verbose, -v\t\tverbose output" << endl - << " --no-debug\t\tno debug information" << endl - << " --no-lines\t\tno #line directives" << endl - << " --dot\t\t\tgenerate a graph" << endl - << " --qt\t\tadd the Qt copyright header and Qt-specific types and macros" << endl - << endl; + qerr() << "Usage: qlalr [options] [input file name]" << Qt::endl + << Qt::endl + << " --help, -h\t\tdisplay this help and exit" << Qt::endl + << " --verbose, -v\t\tverbose output" << Qt::endl + << " --no-debug\t\tno debug information" << Qt::endl + << " --no-lines\t\tno #line directives" << Qt::endl + << " --dot\t\t\tgenerate a graph" << Qt::endl + << " --qt\t\tadd the Qt copyright header and Qt-specific types and macros" << Qt::endl + << Qt::endl; exit (0); } @@ -91,7 +91,7 @@ int main (int argc, char *argv[]) file_name = arg; else - qerr() << "*** Warning. Ignore argument `" << arg << "'" << endl; + qerr() << "*** Warning. Ignore argument `" << arg << "'" << Qt::endl; } if (file_name.isEmpty ()) @@ -108,13 +108,13 @@ int main (int argc, char *argv[]) if (grammar.rules.isEmpty ()) { - qerr() << "*** Fatal. No rules!" << endl; + qerr() << "*** Fatal. No rules!" << Qt::endl; exit (EXIT_FAILURE); } else if (grammar.start == grammar.names.end ()) { - qerr() << "*** Fatal. No start symbol!" << endl; + qerr() << "*** Fatal. No start symbol!" << Qt::endl; exit (EXIT_FAILURE); } diff --git a/src/tools/qlalr/parsetable.cpp b/src/tools/qlalr/parsetable.cpp index c88ac1291e..9e71acebb4 100644 --- a/src/tools/qlalr/parsetable.cpp +++ b/src/tools/qlalr/parsetable.cpp @@ -43,13 +43,13 @@ void ParseTable::operator () (Automaton *aut) int rindex = 1; for (RulePointer rule = g->rules.begin (); rule != g->rules.end (); ++rule) - out << rindex++ << ")\t" << *rule << endl; - out << endl << endl; + out << rindex++ << ")\t" << *rule << Qt::endl; + out << Qt::endl << Qt::endl; int index = 0; for (StatePointer state = aut->states.begin (); state != aut->states.end (); ++state) { - out << "state " << index++ << endl << endl; + out << "state " << index++ << Qt::endl << Qt::endl; for (ItemPointer item = state->kernel.begin (); item != state->kernel.end (); ++item) { @@ -58,7 +58,7 @@ void ParseTable::operator () (Automaton *aut) if (item->dot == item->end_rhs ()) out << " " << aut->lookaheads [item]; - out << endl; + out << Qt::endl; } bool first = true; @@ -68,11 +68,11 @@ void ParseTable::operator () (Automaton *aut) continue; if (first) - out << endl; + out << Qt::endl; first = false; - out << " " << *arrow.key () << " shift, and go to state " << std::distance (aut->states.begin (), *arrow) << endl; + out << " " << *arrow.key () << " shift, and go to state " << std::distance (aut->states.begin (), *arrow) << Qt::endl; } first = true; @@ -82,13 +82,13 @@ void ParseTable::operator () (Automaton *aut) continue; if (first) - out << endl; + out << Qt::endl; first = false; const auto lookaheads = aut->lookaheads.value(item); for (const Name &la : lookaheads) - out << " " << *la << " reduce using rule " << aut->id (item->rule) << " (" << *item->rule->lhs << ")" << endl; + out << " " << *la << " reduce using rule " << aut->id (item->rule) << " (" << *item->rule->lhs << ")" << Qt::endl; } first = true; @@ -98,19 +98,19 @@ void ParseTable::operator () (Automaton *aut) continue; if (first) - out << endl; + out << Qt::endl; first = false; - out << " " << *arrow.key () << " go to state " << std::distance (aut->states.begin (), *arrow) << endl; + out << " " << *arrow.key () << " go to state " << std::distance (aut->states.begin (), *arrow) << Qt::endl; } if (state->defaultReduce != g->rules.end ()) { - out << endl - << " $default reduce using rule " << aut->id (state->defaultReduce) << " (" << *state->defaultReduce->lhs << ")" << endl; + out << Qt::endl + << " $default reduce using rule " << aut->id (state->defaultReduce) << " (" << *state->defaultReduce->lhs << ")" << Qt::endl; } - out << endl; + out << Qt::endl; } } diff --git a/src/tools/qlalr/recognizer.cpp b/src/tools/qlalr/recognizer.cpp index ab797c85d0..3da54c0c6a 100644 --- a/src/tools/qlalr/recognizer.cpp +++ b/src/tools/qlalr/recognizer.cpp @@ -97,7 +97,7 @@ int Recognizer::nextToken() if (ch == QLatin1Char ('"')) inp (); else - qerr() << _M_input_file << ":" << _M_line << ": Warning. Expected `\"'" << endl; + qerr() << _M_input_file << ":" << _M_line << ": Warning. Expected `\"'" << Qt::endl; _M_current_value = text; return (token = STRING_LITERAL); @@ -150,7 +150,7 @@ int Recognizer::nextToken() return (token = PREC); else { - qerr() << _M_input_file << ":" << _M_line << ": Unknown keyword `" << text << "'" << endl; + qerr() << _M_input_file << ":" << _M_line << ": Unknown keyword `" << text << "'" << Qt::endl; exit (EXIT_FAILURE); return (token = ERROR); } @@ -405,7 +405,7 @@ case 34: { if (_M_grammar->terminals.find (_M_current_rule->lhs) != _M_grammar->terminals.end ()) { - qerr() << _M_input_file << ":" << _M_line << ": Invalid non terminal `" << *_M_current_rule->lhs << "'" << endl; + qerr() << _M_input_file << ":" << _M_line << ": Invalid non terminal `" << *_M_current_rule->lhs << "'" << Qt::endl; return false; } @@ -420,7 +420,7 @@ case 38: { if (_M_grammar->terminals.find (_M_current_rule->lhs) != _M_grammar->terminals.end ()) { - qerr() << _M_input_file << ":" << _M_line << ": Invalid non terminal `" << *_M_current_rule->lhs << "'" << endl; + qerr() << _M_input_file << ":" << _M_line << ": Invalid non terminal `" << *_M_current_rule->lhs << "'" << Qt::endl; return false; } @@ -443,7 +443,7 @@ case 40: { Name tok = _M_grammar->intern (sym(2)); if (! _M_grammar->isTerminal (tok)) { - qerr() << _M_input_file << ":" << _M_line << ": `" << *tok << " is not a terminal symbol" << endl; + qerr() << _M_input_file << ":" << _M_line << ": `" << *tok << " is not a terminal symbol" << Qt::endl; _M_current_rule->prec = _M_grammar->names.end (); } else @@ -474,7 +474,7 @@ case 43: { } } - qerr() << _M_input_file << ":" << _M_line << ": Syntax error" << endl; + qerr() << _M_input_file << ":" << _M_line << ": Syntax error" << Qt::endl; return false; } diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index b8ff91f354..a1ff26ba04 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -1626,7 +1626,7 @@ QString WriteInitialization::writeFontProperties(const DomFont *f) } if (f->hasElementWeight() && f->elementWeight() > 0) { m_output << m_indent << fontName << ".setWeight(" - << f->elementWeight() << ");" << endl; + << f->elementWeight() << ");" << Qt::endl; } if (f->hasElementStrikeOut()) { m_output << m_indent << fontName << ".setStrikeOut(" @@ -2614,7 +2614,7 @@ static void generateMultiDirectiveBegin(QTextStream &outputStream, const QSet &directives) @@ -2622,7 +2622,7 @@ static void generateMultiDirectiveEnd(QTextStream &outputStream, const QSetisWindow()) debug << ", window"; debug << ", " << geometry.width() << 'x' << geometry.height() - << forcesign << geometry.x() << geometry.y() << noforcesign; + << Qt::forcesign << geometry.x() << geometry.y() << Qt::noforcesign; if (frameGeometry != geometry) { const QMargins margins(geometry.x() - frameGeometry.x(), geometry.y() - frameGeometry.y(), @@ -13190,7 +13190,7 @@ QDebug operator<<(QDebug debug, const QWidget *widget) } debug << ", devicePixelRatio=" << widget->devicePixelRatioF(); if (const WId wid = widget->internalWinId()) - debug << ", winId=0x" << hex << wid << dec; + debug << ", winId=0x" << Qt::hex << wid << Qt::dec; } debug << ')'; } else { diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp index de838a8f93..4e251de501 100644 --- a/src/widgets/widgets/qsplitter.cpp +++ b/src/widgets/widgets/qsplitter.cpp @@ -1793,7 +1793,7 @@ void QSplitter::setStretchFactor(int index, int stretch) QTextStream& operator<<(QTextStream& ts, const QSplitter& splitter) { - ts << splitter.saveState() << endl; + ts << splitter.saveState() << Qt::endl; return ts; } diff --git a/src/xml/doc/snippets/code/src_xml_dom_qdom.cpp b/src/xml/doc/snippets/code/src_xml_dom_qdom.cpp index 2d18e0e537..f7d81f676f 100644 --- a/src/xml/doc/snippets/code/src_xml_dom_qdom.cpp +++ b/src/xml/doc/snippets/code/src_xml_dom_qdom.cpp @@ -74,7 +74,7 @@ QDomNode n = d.firstChild(); while (!n.isNull()) { if (n.isElement()) { QDomElement e = n.toElement(); - cout << "Element name: " << e.tagName() << endl; + cout << "Element name: " << e.tagName() << Qt::endl; break; } n = n.nextSibling(); @@ -126,10 +126,10 @@ QDomElement element4 = document.createElement("MyElement"); QDomElement e = //... //... QDomAttr a = e.attributeNode("href"); -cout << a.value() << endl; // prints "http://qt-project.org" +cout << a.value() << Qt::endl; // prints "http://qt-project.org" a.setValue("http://qt-project.org/doc"); // change the node's attribute QDomAttr a2 = e.attributeNode("href"); -cout << a2.value() << endl; // prints "http://qt-project.org/doc" +cout << a2.value() << Qt::endl; // prints "http://qt-project.org/doc" //! [8] @@ -201,7 +201,7 @@ QDomNode n = docElem.firstChild(); while(!n.isNull()) { QDomElement e = n.toElement(); // try to convert the node to an element. if(!e.isNull()) { - cout << qPrintable(e.tagName()) << endl; // the node really is an element. + cout << qPrintable(e.tagName()) << Qt::endl; // the node really is an element. } n = n.nextSibling(); } diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index cffc1974af..fedd53f3a9 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -3598,7 +3598,7 @@ void QDomDocumentTypePrivate::save(QTextStream& s, int, int indent) const } if (entities->length()>0 || notations->length()>0) { - s << " [" << endl; + s << " [" << Qt::endl; QHash::const_iterator it2 = notations->map.constBegin(); for (; it2 != notations->map.constEnd(); ++it2) @@ -3611,7 +3611,7 @@ void QDomDocumentTypePrivate::save(QTextStream& s, int, int indent) const s << ']'; } - s << '>' << endl; + s << '>' << Qt::endl; } /************************************************************** @@ -4627,7 +4627,7 @@ void QDomElementPrivate::save(QTextStream& s, int depth, int indent) const /* -1 disables new lines. */ if (indent != -1) - s << endl; + s << Qt::endl; } QDomNodePrivate::save(s, depth + 1, indent); if (!last->isText()) s << QString(indent < 1 ? 0 : depth * indent, QLatin1Char(' ')); @@ -4639,7 +4639,7 @@ void QDomElementPrivate::save(QTextStream& s, int depth, int indent) const if (!(next && next->isText())) { /* -1 disables new lines. */ if (indent != -1) - s << endl; + s << Qt::endl; } } @@ -5329,7 +5329,7 @@ void QDomCommentPrivate::save(QTextStream& s, int depth, int indent) const s << "-->"; if (!(next && next->isText())) - s << endl; + s << Qt::endl; } /************************************************************** @@ -5552,7 +5552,7 @@ void QDomNotationPrivate::save(QTextStream& s, int, int) const } else { s << "SYSTEM " << quotedValue(m_sys); } - s << '>' << endl; + s << '>' << Qt::endl; } /************************************************************** @@ -5733,7 +5733,7 @@ void QDomEntityPrivate::save(QTextStream& s, int, int) const _name = QLatin1String("% ") + _name.mid(1); if (m_sys.isNull() && m_pub.isNull()) { - s << "" << endl; + s << "" << Qt::endl; } else { s << "' << endl; + s << '>' << Qt::endl; } } @@ -6014,7 +6014,7 @@ QDomNodePrivate* QDomProcessingInstructionPrivate::cloneNode(bool deep) void QDomProcessingInstructionPrivate::save(QTextStream& s, int, int) const { - s << "" << endl; + s << "" << Qt::endl; } /************************************************************** From 415c435d605827cf4f4d9d0f723ed27c9b6baba5 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 30 Apr 2019 12:53:42 +0200 Subject: [PATCH 235/292] Compile when bumping the Qt version to 6.0 Change-Id: Idae1a2df144598df3921ef9a12e0e0b740fd723d Reviewed-by: Allan Sandfeld Jensen --- src/corelib/serialization/qxmlstream.cpp | 12 +++++++++++- src/corelib/serialization/qxmlstream.h | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/corelib/serialization/qxmlstream.cpp b/src/corelib/serialization/qxmlstream.cpp index 0170be7602..d43d9c4e14 100644 --- a/src/corelib/serialization/qxmlstream.cpp +++ b/src/corelib/serialization/qxmlstream.cpp @@ -2285,12 +2285,14 @@ QXmlStreamAttribute::QXmlStreamAttribute() m_isDefault = false; } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) /*! Destructs an attribute. */ QXmlStreamAttribute::~QXmlStreamAttribute() { } +#endif /*! Constructs an attribute in the namespace described with \a namespaceUri with \a name and value \a value. @@ -2366,6 +2368,7 @@ QXmlStreamAttribute::QXmlStreamAttribute(const QString &qualifiedName, const QSt */ +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) /*! Creates a copy of \a other. */ @@ -2386,7 +2389,7 @@ QXmlStreamAttribute& QXmlStreamAttribute::operator=(const QXmlStreamAttribute &o m_isDefault = other.m_isDefault; return *this; } - +#endif /*! \class QXmlStreamAttributes @@ -2442,6 +2445,8 @@ QXmlStreamAttribute& QXmlStreamAttribute::operator=(const QXmlStreamAttribute &o QXmlStreamNotationDeclaration::QXmlStreamNotationDeclaration() { } + +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) /*! Creates a copy of \a other. */ @@ -2467,6 +2472,7 @@ Destructs this notation declaration. QXmlStreamNotationDeclaration::~QXmlStreamNotationDeclaration() { } +#endif /*! \fn QStringRef QXmlStreamNotationDeclaration::name() const @@ -2539,6 +2545,7 @@ QXmlStreamNamespaceDeclaration::QXmlStreamNamespaceDeclaration(const QString &pr m_namespaceUri = namespaceUri; } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) /*! Creates a copy of \a other. */ @@ -2562,6 +2569,7 @@ Destructs this namespace declaration. QXmlStreamNamespaceDeclaration::~QXmlStreamNamespaceDeclaration() { } +#endif /*! \fn QStringRef QXmlStreamNamespaceDeclaration::prefix() const @@ -2609,6 +2617,7 @@ QXmlStreamEntityDeclaration::QXmlStreamEntityDeclaration() { } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) /*! Creates a copy of \a other. */ @@ -2636,6 +2645,7 @@ QXmlStreamEntityDeclaration& QXmlStreamEntityDeclaration::operator=(const QXmlSt QXmlStreamEntityDeclaration::~QXmlStreamEntityDeclaration() { } +#endif /*! \fn QXmlStreamStringRef::swap(QXmlStreamStringRef &other) \since 5.6 diff --git a/src/corelib/serialization/qxmlstream.h b/src/corelib/serialization/qxmlstream.h index 55dcc4e4e8..7d0aa64570 100644 --- a/src/corelib/serialization/qxmlstream.h +++ b/src/corelib/serialization/qxmlstream.h @@ -104,8 +104,8 @@ class Q_CORE_EXPORT QXmlStreamAttribute { public: QXmlStreamAttribute(); QXmlStreamAttribute(const QString &qualifiedName, const QString &value); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QXmlStreamAttribute(const QString &namespaceUri, const QString &name, const QString &value); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QXmlStreamAttribute(const QXmlStreamAttribute &); QXmlStreamAttribute(QXmlStreamAttribute &&other) noexcept // = default; : m_name(std::move(other.m_name)), @@ -191,6 +191,7 @@ class Q_CORE_EXPORT QXmlStreamNamespaceDeclaration { friend class QXmlStreamReaderPrivate; public: QXmlStreamNamespaceDeclaration(); + QXmlStreamNamespaceDeclaration(const QString &prefix, const QString &namespaceUri); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QXmlStreamNamespaceDeclaration(const QXmlStreamNamespaceDeclaration &); QXmlStreamNamespaceDeclaration(QXmlStreamNamespaceDeclaration &&other) noexcept // = default @@ -207,7 +208,6 @@ public: qSwap(reserved, other.reserved); return *this; } - QXmlStreamNamespaceDeclaration(const QString &prefix, const QString &namespaceUri); ~QXmlStreamNamespaceDeclaration(); QXmlStreamNamespaceDeclaration& operator=(const QXmlStreamNamespaceDeclaration &); #endif // < Qt 6 From a08c0ca94974142af77ec30eee715a5eb9a2faf5 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 30 Apr 2019 13:25:33 +0200 Subject: [PATCH 236/292] Prepare QDataStream for Qt 6.0 Add the required datastream versions for 6.0. Of course the number for 5.15 and 6.0 is still something we can bump. Change-Id: I676385817befc06ea8d0ff1e9eba9c94cb4698b0 Reviewed-by: Allan Sandfeld Jensen --- src/corelib/serialization/qdatastream.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/corelib/serialization/qdatastream.h b/src/corelib/serialization/qdatastream.h index 2acf7d8c4b..60d429d707 100644 --- a/src/corelib/serialization/qdatastream.h +++ b/src/corelib/serialization/qdatastream.h @@ -102,9 +102,17 @@ public: Qt_5_13 = 19, Qt_5_14 = Qt_5_13, #if QT_VERSION >= 0x050f00 + Qt_5_15 = Qt_5_14, + Qt_DefaultCompiledVersion = Qt_5_15 +#elif QT_VERSION >= 0x060000 + Qt_6_0 = Qt_5_15, + Qt_DefaultCompiledVersion = Qt_6_0 +#else + Qt_DefaultCompiledVersion = Qt_5_14 +#endif +#if QT_VERSION >= 0x060100 #error Add the datastream version for this Qt version and update Qt_DefaultCompiledVersion #endif - Qt_DefaultCompiledVersion = Qt_5_14 }; enum ByteOrder { From 93d3248ed0c81cbe162781a3fac1243c774a7574 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 30 Apr 2019 14:13:06 +0200 Subject: [PATCH 237/292] Compile for Qt 6 Change-Id: I3069081d1c706980a8133b06d46588c4310cb304 Reviewed-by: Allan Sandfeld Jensen --- src/corelib/kernel/qobject.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 73b655cb36..eaf35adb90 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -4031,6 +4031,7 @@ static void dumpRecursive(int level, const QObject *object) } } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) /*! \overload \obsolete @@ -4044,6 +4045,7 @@ void QObject::dumpObjectTree() { const_cast(this)->dumpObjectTree(); } +#endif /*! Dumps a tree of children to the debug output. @@ -4058,6 +4060,7 @@ void QObject::dumpObjectTree() const dumpRecursive(0, this); } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) /*! \overload \obsolete @@ -4072,6 +4075,7 @@ void QObject::dumpObjectInfo() { const_cast(this)->dumpObjectInfo(); } +#endif /*! Dumps information about signal connections, etc. for this object From 857a83259d8f1cfe7d3673c15f5a3436be89b432 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 30 Apr 2019 14:42:55 +0200 Subject: [PATCH 238/292] Compile with Qt 6 Change-Id: Ie45f4dc6d44723c8992872e6c4c2e30d7257ca0c Reviewed-by: Allan Sandfeld Jensen --- src/gui/image/qimagereader.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp index 61f20e0c65..ae433ff651 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -1115,8 +1115,10 @@ bool QImageReader::autoTransform() const case QImageReaderPrivate::DoNotApplyTransform: return false; case QImageReaderPrivate::UsePluginDefault: +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) if (d->initHandler()) return d->handler->supportsOption(QImageIOHandler::TransformedByDefault); +#endif Q_FALLTHROUGH(); default: break; From c7a5cdb98ca4694fa8364c79b5cf53adf7bf19b9 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 30 Apr 2019 14:43:05 +0200 Subject: [PATCH 239/292] Compile with Qt 6 Change-Id: I2cd5f93d01b2a7645bf6bccede484fc301209007 Reviewed-by: Allan Sandfeld Jensen --- src/gui/painting/qtransform.cpp | 8 ++++++++ src/gui/painting/qtransform.h | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index 6110a548fd..7696da7d45 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -265,7 +265,9 @@ QTransform::QTransform() , m_13(0), m_23(0), m_33(1) , m_type(TxNone) , m_dirty(TxNone) +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) , d(nullptr) +#endif { } @@ -284,7 +286,9 @@ QTransform::QTransform(qreal h11, qreal h12, qreal h13, , m_13(h13), m_23(h23), m_33(h33) , m_type(TxNone) , m_dirty(TxProject) +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) , d(nullptr) +#endif { } @@ -301,7 +305,9 @@ QTransform::QTransform(qreal h11, qreal h12, qreal h21, , m_13(0), m_23(0), m_33(1) , m_type(TxNone) , m_dirty(TxShear) +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) , d(nullptr) +#endif { } @@ -317,7 +323,9 @@ QTransform::QTransform(const QMatrix &mtx) m_13(0), m_23(0), m_33(1) , m_type(TxNone) , m_dirty(TxShear) +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) , d(nullptr) +#endif { } diff --git a/src/gui/painting/qtransform.h b/src/gui/painting/qtransform.h index 18c53f4a6f..b220770144 100644 --- a/src/gui/painting/qtransform.h +++ b/src/gui/painting/qtransform.h @@ -176,7 +176,9 @@ private: , m_13(h13), m_23(h23), m_33(h33) , m_type(TxNone) , m_dirty(TxProject) +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) , d(nullptr) +#endif { } inline QTransform(bool) @@ -184,7 +186,9 @@ private: , m_13(0), m_23(0), m_33(1) , m_type(TxNone) , m_dirty(TxNone) +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) , d(nullptr) +#endif { } inline TransformationType inline_type() const; From 1e4042d03f798aa088fea5d340342d56363d07ca Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 30 Apr 2019 14:43:13 +0200 Subject: [PATCH 240/292] Compile with Qt 6 Change-Id: I6d8d562a871a2f49db5db8630a08f53a14c0f7d3 Reviewed-by: Allan Sandfeld Jensen --- src/sql/models/qsqltablemodel.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp index 98d6ddf882..11d30ab2e8 100644 --- a/src/sql/models/qsqltablemodel.cpp +++ b/src/sql/models/qsqltablemodel.cpp @@ -50,6 +50,7 @@ #include "qsqltablemodel_p.h" #include +#include QT_BEGIN_NAMESPACE @@ -611,7 +612,7 @@ bool QSqlTableModel::setData(const QModelIndex &index, const QVariant &value, in /*! \reimp */ -bool QStringListModel::clearItemData(const QModelIndex &index) +bool QSqlTableModel::clearItemData(const QModelIndex &index) { return setData(index, QVariant(), Qt::EditRole); } From 9c04e7c61ebc87904c0fc40d5e421e862b406a58 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 30 Apr 2019 14:57:31 +0200 Subject: [PATCH 241/292] Fix API for Qt 6 Change-Id: Ic07b5cf09ed410a27ca95f106747f98de4d86d68 Reviewed-by: Allan Sandfeld Jensen --- src/widgets/kernel/qwidget.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h index aec3eee639..e47deb5d0d 100644 --- a/src/widgets/kernel/qwidget.h +++ b/src/widgets/kernel/qwidget.h @@ -555,7 +555,7 @@ public: void addAction(QAction *action); #if QT_VERSION >= QT_VERSION_CHECK(6,0,0) void addActions(const QList &actions); - void insertActions(const QAction *before, const QList &actions); + void insertActions(QAction *before, const QList &actions); #else void addActions(QList actions); void insertActions(QAction *before, QList actions); From 91b3099d713b25367aafaf0aa8b719b7bd316155 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 30 Apr 2019 15:19:19 +0200 Subject: [PATCH 242/292] Compile with Qt 6 Change-Id: I6efa420acab070e625f99b49eee08076d4a6a9ff Reviewed-by: Allan Sandfeld Jensen --- src/plugins/platforms/xcb/nativepainting/qpixmap_x11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/xcb/nativepainting/qpixmap_x11.cpp b/src/plugins/platforms/xcb/nativepainting/qpixmap_x11.cpp index b1ce39f363..f86bedbdcd 100644 --- a/src/plugins/platforms/xcb/nativepainting/qpixmap_x11.cpp +++ b/src/plugins/platforms/xcb/nativepainting/qpixmap_x11.cpp @@ -2017,7 +2017,7 @@ QImage QX11PlatformPixmap::toImage(const QXImageWrapper &xiWrapper, const QRect } } else if (xi->bits_per_pixel == d) { // compatible depth char *xidata = xi->data; // copy each scanline - int bpl = qMin(image.bytesPerLine(),xi->bytes_per_line); + int bpl = qMin(int(image.bytesPerLine()),xi->bytes_per_line); for (int y=0; yheight; y++) { memcpy(image.scanLine(y), xidata, bpl); xidata += xi->bytes_per_line; From 936632c9c1e92de899bb17596a66167e8d515bc4 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Thu, 2 May 2019 11:46:32 +0200 Subject: [PATCH 243/292] QList: fix regression in swapItemsAt Commit e0d2b50249839d10ecf87abc296b8020046d1d75 makes swapItemsAt use ADL to find swap(). Problem is, QList has a swap() function (that swaps the elements at the specificed _indices_); that function will be found before ADL kicks in. So do the second best thing: use qSwap instead. Change-Id: Icf2b4e3ce09117e4056acbad3e2d8a625861d807 Reviewed-by: Lars Knoll --- src/corelib/tools/qlist.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 59578b1e61..b916dcfd24 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -707,8 +707,7 @@ inline void QList::swapItemsAt(int i, int j) Q_ASSERT_X(i >= 0 && i < p.size() && j >= 0 && j < p.size(), "QList::swap", "index out of range"); detach(); - using std::swap; - swap(d->array[d->begin + i], d->array[d->begin + j]); + qSwap(d->array[d->begin + i], d->array[d->begin + j]); } template From 884dc0be7f85e08d2f25d48d728db69b9557ce04 Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Mon, 29 Apr 2019 12:14:22 +0200 Subject: [PATCH 244/292] Remove redundant file from tests Change-Id: Icb398f1ba32dd1cc3a1e042818750c253539fae3 Reviewed-by: Lars Knoll --- .../xml/sax/qxmlsimplereader/xmldocs/valid/sa/089.xml.bak | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/sa/089.xml.bak diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/sa/089.xml.bak b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/sa/089.xml.bak deleted file mode 100644 index 2d80c8f3fb..0000000000 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/sa/089.xml.bak +++ /dev/null @@ -1,5 +0,0 @@ - - -]> -&e; From 0d39cf6865301c96b69cfdc0df587f5962252e8e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 2 May 2019 11:55:36 +0200 Subject: [PATCH 245/292] QTextMarkdownImporter: Fix deprecation warning Use QTextCharFormat::setAnchorNames(), fixing: text/qtextmarkdownimporter.cpp:322:36: warning: 'void QTextCharFormat::setAnchorName(const QString&)' is deprecated: Use setAnchorNames() instead [-Wdeprecated-declarations] Amends 65314b6ce88cdbb28a22be0cab9856ec9bc9604b. Task-number: QTBUG-72349 Change-Id: I7f909d1fcc5c4045c738b5a5c491b2ac1de6eac5 Reviewed-by: Shawn Rutledge --- src/gui/text/qtextmarkdownimporter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp index 2477e0bc74..bcb0b777d4 100644 --- a/src/gui/text/qtextmarkdownimporter.cpp +++ b/src/gui/text/qtextmarkdownimporter.cpp @@ -319,7 +319,7 @@ int QTextMarkdownImporter::cbEnterSpan(MD_SPANTYPE type, void *det) QString url = QString::fromLatin1(detail->href.text, detail->href.size); QString title = QString::fromLatin1(detail->title.text, detail->title.size); charFmt.setAnchorHref(url); - charFmt.setAnchorName(title); + charFmt.setAnchorNames(QStringList(title)); charFmt.setForeground(m_palette.link()); qCDebug(lcMD) << "anchor" << url << title; } break; From 1b16f79bf2a4efa5c8f60ae48adbf563fa819611 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Thu, 2 May 2019 18:14:20 +0200 Subject: [PATCH 246/292] QSharedData: delete the copy assignment operator Do not merely declare it as private, use C++11's = delete. This has the nice side effect that subclasses are no longer implicitly copy assignable either (they shouldn't be). Change-Id: Icd03f71006c31baf7d079365fa3bea1a2a9d559b Reviewed-by: Thiago Macieira --- src/corelib/tools/qshareddata.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/corelib/tools/qshareddata.h b/src/corelib/tools/qshareddata.h index 04051472d6..c29a509209 100644 --- a/src/corelib/tools/qshareddata.h +++ b/src/corelib/tools/qshareddata.h @@ -60,9 +60,8 @@ public: inline QSharedData() : ref(0) { } inline QSharedData(const QSharedData &) : ref(0) { } -private: // using the assignment operator would lead to corruption in the ref-counting - QSharedData &operator=(const QSharedData &); + QSharedData &operator=(const QSharedData &) = delete; }; template class QSharedDataPointer From fe57936d8c6e1bdafea5ba3260cc05c137a88ead Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sat, 27 Apr 2019 22:10:17 +0200 Subject: [PATCH 247/292] qIsNull: redo implementation The reason for using type-punning through an integer was to avoid compiler warnings about float comparisons. We have now a better mechanism to suppress such warnings, so there is no need to be "clever" and trigger UB because of the union usage. Drive-by change: add constexpr+noexcept because now there's no longer UB. Change-Id: I29f7514e39055658d4ef6c431daf5abfc660df16 Reviewed-by: Edward Welbourne Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal.h | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 4817acb48f..a1f191516a 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -902,38 +902,22 @@ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qFuzzyIsNul return qAbs(f) <= 0.00001f; } -/* - This function tests a double for a null value. It doesn't - check whether the actual value is 0 or close to 0, but whether - it is binary 0, disregarding sign. -*/ -Q_REQUIRED_RESULT static inline Q_DECL_UNUSED bool qIsNull(double d) +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wfloat-equal") +QT_WARNING_DISABLE_GCC("-Wfloat-equal") + +Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qIsNull(double d) noexcept { - union U { - double d; - quint64 u; - }; - U val; - val.d = d; - return (val.u & Q_UINT64_C(0x7fffffffffffffff)) == 0; + return d == 0.0; } -/* - This function tests a float for a null value. It doesn't - check whether the actual value is 0 or close to 0, but whether - it is binary 0, disregarding sign. -*/ -Q_REQUIRED_RESULT static inline Q_DECL_UNUSED bool qIsNull(float f) +Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qIsNull(float f) noexcept { - union U { - float f; - quint32 u; - }; - U val; - val.f = f; - return (val.u & 0x7fffffff) == 0; + return f == 0.0f; } +QT_WARNING_POP + /* Compilers which follow outdated template instantiation rules require a class to have a comparison operator to exist when From 78a7e54f8f5c4ca6ce1ee6b0ac82c42b21738ac5 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 3 Dec 2018 16:03:17 +0100 Subject: [PATCH 248/292] Custom color-space based on chromaticities Change-Id: I7fa6efa8993aa2b79ea60b6a21bf57c4f67a120f Reviewed-by: Eirik Aavitsland --- src/gui/painting/qcolormatrix_p.h | 45 ++++- src/gui/painting/qcolorspace.cpp | 155 +++++++++++++++--- src/gui/painting/qcolorspace.h | 3 + src/gui/painting/qcolorspace_p.h | 26 +++ .../painting/qcolorspace/tst_qcolorspace.cpp | 68 ++++++++ 5 files changed, 269 insertions(+), 28 deletions(-) diff --git a/src/gui/painting/qcolormatrix_p.h b/src/gui/painting/qcolormatrix_p.h index 3d1dca6222..66db95df7e 100644 --- a/src/gui/painting/qcolormatrix_p.h +++ b/src/gui/painting/qcolormatrix_p.h @@ -52,6 +52,7 @@ // #include +#include #include QT_BEGIN_NAMESPACE @@ -61,7 +62,13 @@ class QColorVector { public: QColorVector() = default; - constexpr QColorVector(float x, float y, float z) : x(x), y(y), z(z), _unused(0.0f) { } + Q_DECL_CONSTEXPR QColorVector(float x, float y, float z) : x(x), y(y), z(z), _unused(0.0f) { } + explicit Q_DECL_CONSTEXPR QColorVector(const QPointF &chr) // from XY chromaticity + : x(chr.x() / chr.y()) + , y(1.0f) + , z((1.0 - chr.x() - chr.y()) / chr.y()) + , _unused(0.0f) + { } float x; // X, x or red float y; // Y, y or green float z; // Z, Y or blue @@ -69,11 +76,28 @@ public: friend inline bool operator==(const QColorVector &v1, const QColorVector &v2); friend inline bool operator!=(const QColorVector &v1, const QColorVector &v2); + bool isNull() const + { + return !x && !y && !z; + } - static constexpr QColorVector null() { return QColorVector(0.0f, 0.0f, 0.0f); } - // Common whitepoints on normalized XYZ form: - static constexpr QColorVector D50() { return QColorVector(0.96421f, 1.0f, 0.82519f); } - static constexpr QColorVector D65() { return QColorVector(0.95043f, 1.0f, 1.08890f); } + static Q_DECL_CONSTEXPR QColorVector null() { return QColorVector(0.0f, 0.0f, 0.0f); } + static bool isValidChromaticity(const QPointF &chr) + { + if (chr.x() < qreal(0.0) || chr.x() > qreal(1.0)) + return false; + if (chr.y() <= qreal(0.0) || chr.y() > qreal(1.0)) + return false; + if (chr.x() + chr.y() > qreal(1.0)) + return false; + return true; + } + + // Common whitepoints: + static Q_DECL_CONSTEXPR QPointF D50Chromaticity() { return QPointF(0.34567, 0.35850); } + static Q_DECL_CONSTEXPR QPointF D65Chromaticity() { return QPointF(0.31271, 0.32902); } + static Q_DECL_CONSTEXPR QColorVector D50() { return QColorVector(D50Chromaticity()); } + static Q_DECL_CONSTEXPR QColorVector D65() { return QColorVector(D65Chromaticity()); } }; inline bool operator==(const QColorVector &v1, const QColorVector &v2) @@ -102,6 +126,10 @@ public: friend inline bool operator==(const QColorMatrix &m1, const QColorMatrix &m2); friend inline bool operator!=(const QColorMatrix &m1, const QColorMatrix &m2); + bool isNull() const + { + return r.isNull() && g.isNull() && b.isNull(); + } bool isValid() const { // A color matrix must be invertible @@ -167,6 +195,13 @@ public: { return { { 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 1.0f } }; } + static QColorMatrix fromScale(QColorVector v) + { + return QColorMatrix { { v.x, 0.0f, 0.0f }, + { 0.0f, v.y, 0.0f }, + { 0.0f, 0.0f, v.z } }; + } + // These are used to recognize matrices from ICC profiles: static QColorMatrix toXyzFromSRgb() { return QColorMatrix { { 0.4360217452f, 0.2224751115f, 0.0139281144f }, diff --git a/src/gui/painting/qcolorspace.cpp b/src/gui/painting/qcolorspace.cpp index 24785f7b61..c98c31fe05 100644 --- a/src/gui/painting/qcolorspace.cpp +++ b/src/gui/painting/qcolorspace.cpp @@ -53,6 +53,102 @@ QT_BEGIN_NAMESPACE +QColorSpacePrimaries::QColorSpacePrimaries(QColorSpace::Gamut gamut) +{ + switch (gamut) { + case QColorSpace::Gamut::SRgb: + redPoint = QPointF(0.640, 0.330); + greenPoint = QPointF(0.300, 0.600); + bluePoint = QPointF(0.150, 0.060); + whitePoint = QColorVector::D65Chromaticity(); + break; + case QColorSpace::Gamut::DciP3D65: + redPoint = QPointF(0.680, 0.320); + greenPoint = QPointF(0.265, 0.690); + bluePoint = QPointF(0.150, 0.060); + whitePoint = QColorVector::D65Chromaticity(); + break; + case QColorSpace::Gamut::Bt2020: + redPoint = QPointF(0.708, 0.292); + greenPoint = QPointF(0.190, 0.797); + bluePoint = QPointF(0.131, 0.046); + whitePoint = QColorVector::D65Chromaticity(); + break; + case QColorSpace::Gamut::AdobeRgb: + redPoint = QPointF(0.640, 0.330); + greenPoint = QPointF(0.210, 0.710); + bluePoint = QPointF(0.150, 0.060); + whitePoint = QColorVector::D65Chromaticity(); + break; + case QColorSpace::Gamut::ProPhotoRgb: + redPoint = QPointF(0.7347, 0.2653); + greenPoint = QPointF(0.1596, 0.8404); + bluePoint = QPointF(0.0366, 0.0001); + whitePoint = QColorVector::D50Chromaticity(); + break; + default: + Q_UNREACHABLE(); + } +} + +bool QColorSpacePrimaries::areValid() const +{ + if (!QColorVector::isValidChromaticity(redPoint)) + return false; + if (!QColorVector::isValidChromaticity(greenPoint)) + return false; + if (!QColorVector::isValidChromaticity(bluePoint)) + return false; + if (!QColorVector::isValidChromaticity(whitePoint)) + return false; + return true; +} + +QColorMatrix QColorSpacePrimaries::toXyzMatrix() const +{ + // This converts to XYZ in some undefined scale. + QColorMatrix toXyz = { QColorVector(redPoint), + QColorVector(greenPoint), + QColorVector(bluePoint) }; + + // Since the white point should be (1.0, 1.0, 1.0) in the + // input, we can figure out the scale by using the + // inverse conversion on the white point. + QColorVector wXyz(whitePoint); + QColorVector whiteScale = toXyz.inverted().map(wXyz); + + // Now we have scaled conversion to XYZ relative to the given whitepoint + toXyz = toXyz * QColorMatrix::fromScale(whiteScale); + + // But we want a conversion to XYZ relative to D50 + QColorVector wXyzD50 = QColorVector::D50(); + + if (wXyz != wXyzD50) { + // Do chromatic adaptation to map our white point to XYZ D50. + + // The Bradford method chromatic adaptation matrix: + QColorMatrix abrad = { { 0.8951f, -0.7502f, 0.0389f }, + { 0.2664f, 1.7135f, -0.0685f }, + { -0.1614f, 0.0367f, 1.0296f } }; + QColorMatrix abradinv = { { 0.9869929f, 0.4323053f, -0.0085287f }, + { -0.1470543f, 0.5183603f, 0.0400428f }, + { 0.1599627f, 0.0492912f, 0.9684867f } }; + + QColorVector srcCone = abrad.map(wXyz); + QColorVector dstCone = abrad.map(wXyzD50); + + QColorMatrix wToD50 = { { dstCone.x / srcCone.x, 0, 0 }, + { 0, dstCone.y / srcCone.y, 0 }, + { 0, 0, dstCone.z / srcCone.z } }; + + + QColorMatrix chromaticAdaptation = abradinv * (wToD50 * abrad); + toXyz = chromaticAdaptation * toXyz; + } + + return toXyz; +} + QColorSpacePrivate::QColorSpacePrivate() : id(QColorSpace::Unknown) , gamut(QColorSpace::Gamut::Custom) @@ -128,6 +224,21 @@ QColorSpacePrivate::QColorSpacePrivate(QColorSpace::Gamut gamut, QColorSpace::Tr initialize(); } +QColorSpacePrivate::QColorSpacePrivate(const QColorSpacePrimaries &primaries, + QColorSpace::TransferFunction fun, + float gamma) + : gamut(QColorSpace::Gamut::Custom) + , transferFunction(fun) + , gamma(gamma) +{ + Q_ASSERT(primaries.areValid()); + toXyz = primaries.toXyzMatrix(); + whitePoint = QColorVector(primaries.whitePoint); + if (!identifyColorSpace()) + id = QColorSpace::Unknown; + setTransferFunction(); +} + bool QColorSpacePrivate::identifyColorSpace() { switch (gamut) { @@ -195,33 +306,14 @@ void QColorSpacePrivate::initialize() void QColorSpacePrivate::setToXyzMatrix() { - switch (gamut) { - case QColorSpace::Gamut::SRgb: - toXyz = QColorMatrix::toXyzFromSRgb(); - whitePoint = QColorVector::D65(); - return; - case QColorSpace::Gamut::AdobeRgb: - toXyz = QColorMatrix::toXyzFromAdobeRgb(); - whitePoint = QColorVector::D65(); - return; - case QColorSpace::Gamut::DciP3D65: - toXyz = QColorMatrix::toXyzFromDciP3D65(); - whitePoint = QColorVector::D65(); - return; - case QColorSpace::Gamut::ProPhotoRgb: - toXyz = QColorMatrix::toXyzFromProPhotoRgb(); - whitePoint = QColorVector::D50(); - return; - case QColorSpace::Gamut::Bt2020: - toXyz = QColorMatrix::toXyzFromBt2020(); - whitePoint = QColorVector::D65(); - return; - case QColorSpace::Gamut::Custom: + if (gamut == QColorSpace::Gamut::Custom) { toXyz = QColorMatrix::null(); whitePoint = QColorVector::D50(); return; } - Q_UNREACHABLE(); + QColorSpacePrimaries primaries(gamut); + toXyz = primaries.toXyzMatrix(); + whitePoint = QColorVector(primaries.whitePoint); } void QColorSpacePrivate::setTransferFunction() @@ -386,6 +478,23 @@ QColorSpace::QColorSpace(QColorSpace::Gamut gamut, float gamma) { } +/*! + Creates a custom colorspace with a gamut based on the chromaticities of the primary colors \a whitePoint, + \a redPoint, \a greenPoint and \a bluePoint, and using the transfer function \a fun and optionally \a gamma. + */ +QColorSpace::QColorSpace(const QPointF &whitePoint, const QPointF &redPoint, + const QPointF &greenPoint, const QPointF &bluePoint, + QColorSpace::TransferFunction fun, float gamma) +{ + QColorSpacePrimaries primaries(whitePoint, redPoint, greenPoint, bluePoint); + if (!primaries.areValid()) { + qWarning() << "QColorSpace attempted constructed from invalid primaries:" << whitePoint << redPoint << greenPoint << bluePoint; + d_ptr = QColorSpace(QColorSpace::Undefined).d_ptr; + return; + } + d_ptr = new QColorSpacePrivate(primaries, fun, gamma); +} + QColorSpace::~QColorSpace() { } diff --git a/src/gui/painting/qcolorspace.h b/src/gui/painting/qcolorspace.h index 923546ec6f..56676826a9 100644 --- a/src/gui/painting/qcolorspace.h +++ b/src/gui/painting/qcolorspace.h @@ -85,6 +85,9 @@ public: QColorSpace(ColorSpaceId colorSpaceId = Undefined); QColorSpace(Gamut gamut, TransferFunction fun, float gamma = 0.0f); QColorSpace(Gamut gamut, float gamma); + QColorSpace(const QPointF &whitePoint, const QPointF &redPoint, + const QPointF &greenPoint, const QPointF &bluePoint, + TransferFunction fun, float gamma = 0.0f); ~QColorSpace(); QColorSpace(QColorSpace &&colorSpace); diff --git a/src/gui/painting/qcolorspace_p.h b/src/gui/painting/qcolorspace_p.h index 91107a9a89..21260a281d 100644 --- a/src/gui/painting/qcolorspace_p.h +++ b/src/gui/painting/qcolorspace_p.h @@ -57,15 +57,41 @@ #include "qcolortrclut_p.h" #include +#include QT_BEGIN_NAMESPACE +class Q_GUI_EXPORT QColorSpacePrimaries +{ +public: + QColorSpacePrimaries() = default; + QColorSpacePrimaries(QColorSpace::Gamut gamut); + QColorSpacePrimaries(QPointF whitePoint, + QPointF redPoint, + QPointF greenPoint, + QPointF bluePoint) + : whitePoint(whitePoint) + , redPoint(redPoint) + , greenPoint(greenPoint) + , bluePoint(bluePoint) + { } + + QColorMatrix toXyzMatrix() const; + bool areValid() const; + + QPointF whitePoint; + QPointF redPoint; + QPointF greenPoint; + QPointF bluePoint; +}; + class QColorSpacePrivate : public QSharedData { public: QColorSpacePrivate(); QColorSpacePrivate(QColorSpace::ColorSpaceId colorSpaceId); QColorSpacePrivate(QColorSpace::Gamut gamut, QColorSpace::TransferFunction fun, float gamma); + QColorSpacePrivate(const QColorSpacePrimaries &primaries, QColorSpace::TransferFunction fun, float gamma); QColorSpacePrivate(const QColorSpacePrivate &other) = default; QColorSpacePrivate &operator=(const QColorSpacePrivate &other) = default; diff --git a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp index 35bca58854..7a88eb18b2 100644 --- a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp +++ b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp @@ -33,6 +33,8 @@ #include #include +#include + Q_DECLARE_METATYPE(QColorSpace::ColorSpaceId) Q_DECLARE_METATYPE(QColorSpace::Gamut) Q_DECLARE_METATYPE(QColorSpace::TransferFunction) @@ -59,6 +61,10 @@ private slots: void loadImage(); void gamut(); + void primariesXyz(); + void primaries2_data(); + void primaries2(); + void invalidPrimaries(); }; tst_QColorSpace::tst_QColorSpace() @@ -289,5 +295,67 @@ void tst_QColorSpace::gamut() QVERIFY(tgreen.blueF() > 0.2); } +void tst_QColorSpace::primariesXyz() +{ + QColorSpace sRgb = QColorSpace::SRgb; + QColorSpace adobeRgb = QColorSpace::AdobeRgb; + QColorSpace displayP3 = QColorSpace::DisplayP3; + QColorSpace proPhotoRgb = QColorSpace::ProPhotoRgb; + QColorSpace bt2020 = QColorSpace::Bt2020; + + // Check if our calculated matrices, match the precalculated ones. + QCOMPARE(sRgb.d_func()->toXyz, QColorMatrix::toXyzFromSRgb()); + QCOMPARE(adobeRgb.d_func()->toXyz, QColorMatrix::toXyzFromAdobeRgb()); + QCOMPARE(displayP3.d_func()->toXyz, QColorMatrix::toXyzFromDciP3D65()); + QCOMPARE(proPhotoRgb.d_func()->toXyz, QColorMatrix::toXyzFromProPhotoRgb()); + QCOMPARE(bt2020.d_func()->toXyz, QColorMatrix::toXyzFromBt2020()); +} + +void tst_QColorSpace::primaries2_data() +{ + QTest::addColumn("gamut"); + + QTest::newRow("sRGB") << QColorSpace::Gamut::SRgb; + QTest::newRow("DCI-P3 (D65)") << QColorSpace::Gamut::DciP3D65; + QTest::newRow("Adobe RGB (1998)") << QColorSpace::Gamut::AdobeRgb; + QTest::newRow("ProPhoto RGB") << QColorSpace::Gamut::ProPhotoRgb; + QTest::newRow("BT.2020") << QColorSpace::Gamut::Bt2020; +} + +void tst_QColorSpace::primaries2() +{ + QFETCH(QColorSpace::Gamut, gamut); + QColorSpacePrimaries primaries(gamut); + + QColorSpace original(gamut, QColorSpace::TransferFunction::Linear); + QColorSpace custom1(primaries.whitePoint, primaries.redPoint, + primaries.greenPoint, primaries.bluePoint, QColorSpace::TransferFunction::Linear); + QCOMPARE(original, custom1); + + // A custom color swizzled color-space: + QColorSpace custom2(primaries.whitePoint, primaries.bluePoint, + primaries.greenPoint, primaries.redPoint, QColorSpace::TransferFunction::Linear); + + QVERIFY(custom1 != custom2); + QColor color1(255, 127, 63); + QColor color2 = custom1.transformationToColorSpace(custom2).map(color1); + QCOMPARE(color2.red(), color1.blue()); + QCOMPARE(color2.green(), color1.green()); + QCOMPARE(color2.blue(), color1.red()); + QCOMPARE(color2.alpha(), color1.alpha()); + QColor color3 = custom2.transformationToColorSpace(custom1).map(color2); + QCOMPARE(color3.red(), color1.red()); + QCOMPARE(color3.green(), color1.green()); + QCOMPARE(color3.blue(), color1.blue()); + QCOMPARE(color3.alpha(), color1.alpha()); +} + +void tst_QColorSpace::invalidPrimaries() +{ + QColorSpace custom(QPointF(), QPointF(), QPointF(), QPointF(), QColorSpace::TransferFunction::Linear); + QVERIFY(!custom.isValid()); + QCOMPARE(custom.colorSpaceId(), QColorSpace::Undefined); +} + QTEST_MAIN(tst_QColorSpace) #include "tst_qcolorspace.moc" From d775b1fcb3fc7bd41af37f5d0a4d999320b62364 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 4 Apr 2019 18:13:32 +0200 Subject: [PATCH 249/292] Remove handling of missing Q_COMPILER_INITIALIZER_LISTS Change-Id: Id65b39c787235a051262544932e6717d076f1ea0 Reviewed-by: Edward Welbourne Reviewed-by: Thiago Macieira --- .../widgets/widgets/icons/iconpreviewarea.cpp | 40 ------------------- src/corelib/global/qflags.h | 6 --- .../global/qoperatingsystemversion.cpp | 2 - src/corelib/global/qoperatingsystemversion.h | 2 - src/corelib/serialization/qjsonarray.h | 4 -- src/corelib/serialization/qjsonobject.h | 4 -- src/corelib/tools/qhash.h | 9 +---- src/corelib/tools/qlinkedlist.h | 10 +---- src/corelib/tools/qlist.h | 9 +---- src/corelib/tools/qmap.h | 11 +---- src/corelib/tools/qset.h | 5 --- src/corelib/tools/qstringlist.h | 2 - src/corelib/tools/qvarlengtharray.h | 12 ++---- src/corelib/tools/qvector.h | 16 +++----- src/corelib/tools/qversionnumber.h | 4 -- .../qtconcurrentrun/tst_qtconcurrentrun.cpp | 4 -- .../auto/corelib/global/qflags/tst_qflags.cpp | 5 --- .../corelib/serialization/json/tst_qtjson.cpp | 8 ---- .../tst_containerapisymmetry.cpp | 10 ----- .../qbytearraylist/tst_qbytearraylist.cpp | 4 -- .../tst_qcommandlineparser.cpp | 2 +- tests/auto/corelib/tools/qhash/tst_qhash.cpp | 4 -- .../tools/qlinkedlist/tst_qlinkedlist.cpp | 2 - tests/auto/corelib/tools/qlist/tst_qlist.cpp | 2 - tests/auto/corelib/tools/qmap/tst_qmap.cpp | 4 -- tests/auto/corelib/tools/qset/tst_qset.cpp | 12 ------ .../tools/qstringlist/tst_qstringlist.cpp | 5 --- .../qvarlengtharray/tst_qvarlengtharray.cpp | 4 -- .../corelib/tools/qvector/tst_qvector.cpp | 6 --- .../qversionnumber/tst_qversionnumber.cpp | 2 - 30 files changed, 16 insertions(+), 194 deletions(-) diff --git a/examples/widgets/widgets/icons/iconpreviewarea.cpp b/examples/widgets/widgets/icons/iconpreviewarea.cpp index 1a2f514ba8..7a73a137cd 100644 --- a/examples/widgets/widgets/icons/iconpreviewarea.cpp +++ b/examples/widgets/widgets/icons/iconpreviewarea.cpp @@ -79,8 +79,6 @@ IconPreviewArea::IconPreviewArea(QWidget *parent) } //! [0] -#ifdef Q_COMPILER_INITIALIZER_LISTS - //! [42] QVector IconPreviewArea::iconModes() { @@ -107,44 +105,6 @@ QStringList IconPreviewArea::iconStateNames() } //! [42] -#else // Q_COMPILER_INITIALIZER_LISTS - -//! [43] -QVector IconPreviewArea::iconModes() -{ - static QVector result; - if (result.isEmpty()) - result << QIcon::Normal << QIcon::Active << QIcon::Disabled << QIcon::Selected; - return result; -} -//! [43] - -QVector IconPreviewArea::iconStates() -{ - static QVector result; - if (result.isEmpty()) - result << QIcon::Off << QIcon::On; - return result; -} - -QStringList IconPreviewArea::iconModeNames() -{ - static QStringList result; - if (result.isEmpty()) - result << tr("Normal") << tr("Active") << tr("Disabled") << tr("Selected"); - return result; -} - -QStringList IconPreviewArea::iconStateNames() -{ - static QStringList result; - if (result.isEmpty()) - result << tr("Off") << tr("On"); - return result; -} - -#endif // !Q_COMPILER_INITIALIZER_LISTS - //! [1] void IconPreviewArea::setIcon(const QIcon &icon) { diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h index 65f4892472..bd3c219968 100644 --- a/src/corelib/global/qflags.h +++ b/src/corelib/global/qflags.h @@ -42,9 +42,7 @@ #ifndef QFLAGS_H #define QFLAGS_H -#ifdef Q_COMPILER_INITIALIZER_LISTS #include -#endif QT_BEGIN_NAMESPACE @@ -121,10 +119,8 @@ public: Q_DECL_CONSTEXPR inline QFlags(Zero = nullptr) noexcept : i(0) {} Q_DECL_CONSTEXPR inline QFlags(QFlag flag) noexcept : i(flag) {} -#ifdef Q_COMPILER_INITIALIZER_LISTS Q_DECL_CONSTEXPR inline QFlags(std::initializer_list flags) noexcept : i(initializer_list_helper(flags.begin(), flags.end())) {} -#endif Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator&=(int mask) noexcept { i &= mask; return *this; } Q_DECL_RELAXED_CONSTEXPR inline QFlags &operator&=(uint mask) noexcept { i &= mask; return *this; } @@ -154,14 +150,12 @@ public: } private: -#ifdef Q_COMPILER_INITIALIZER_LISTS Q_DECL_CONSTEXPR static inline Int initializer_list_helper(typename std::initializer_list::const_iterator it, typename std::initializer_list::const_iterator end) noexcept { return (it == end ? Int(0) : (Int(*it) | initializer_list_helper(it + 1, end))); } -#endif Int i; }; diff --git a/src/corelib/global/qoperatingsystemversion.cpp b/src/corelib/global/qoperatingsystemversion.cpp index 94dc261b41..42a1275621 100644 --- a/src/corelib/global/qoperatingsystemversion.cpp +++ b/src/corelib/global/qoperatingsystemversion.cpp @@ -340,7 +340,6 @@ QString QOperatingSystemVersion::name() const } } -#ifdef Q_COMPILER_INITIALIZER_LISTS /*! \fn bool QOperatingSystemVersion::isAnyOfType(std::initializer_list types) const @@ -355,7 +354,6 @@ bool QOperatingSystemVersion::isAnyOfType(std::initializer_list types) c } return false; } -#endif /*! \variable QOperatingSystemVersion::Windows7 diff --git a/src/corelib/global/qoperatingsystemversion.h b/src/corelib/global/qoperatingsystemversion.h index df01e5438a..e99e4f8997 100644 --- a/src/corelib/global/qoperatingsystemversion.h +++ b/src/corelib/global/qoperatingsystemversion.h @@ -119,9 +119,7 @@ public: Q_DECL_CONSTEXPR int segmentCount() const { return m_micro >= 0 ? 3 : m_minor >= 0 ? 2 : m_major >= 0 ? 1 : 0; } -#ifdef Q_COMPILER_INITIALIZER_LISTS bool isAnyOfType(std::initializer_list types) const; -#endif Q_DECL_CONSTEXPR OSType type() const { return m_os; } QString name() const; diff --git a/src/corelib/serialization/qjsonarray.h b/src/corelib/serialization/qjsonarray.h index 86b7bf9d76..983a6753b5 100644 --- a/src/corelib/serialization/qjsonarray.h +++ b/src/corelib/serialization/qjsonarray.h @@ -42,9 +42,7 @@ #include #include -#if defined(Q_COMPILER_INITIALIZER_LISTS) #include -#endif QT_BEGIN_NAMESPACE @@ -58,14 +56,12 @@ class Q_CORE_EXPORT QJsonArray public: QJsonArray(); -#if defined(Q_COMPILER_INITIALIZER_LISTS) || defined(Q_QDOC) QJsonArray(std::initializer_list args) { initialize(); for (std::initializer_list::const_iterator i = args.begin(); i != args.end(); ++i) append(*i); } -#endif ~QJsonArray(); diff --git a/src/corelib/serialization/qjsonobject.h b/src/corelib/serialization/qjsonobject.h index 92d45cc838..d8e2ab9ca7 100644 --- a/src/corelib/serialization/qjsonobject.h +++ b/src/corelib/serialization/qjsonobject.h @@ -42,10 +42,8 @@ #include #include -#ifdef Q_COMPILER_INITIALIZER_LISTS #include #include -#endif QT_BEGIN_NAMESPACE @@ -60,14 +58,12 @@ class Q_CORE_EXPORT QJsonObject public: QJsonObject(); -#if defined(Q_COMPILER_INITIALIZER_LISTS) || defined(Q_QDOC) QJsonObject(std::initializer_list > args) { initialize(); for (std::initializer_list >::const_iterator i = args.begin(); i != args.end(); ++i) insert(i->first, i->second); } -#endif ~QJsonObject(); diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index 0078bbbee9..4b4cb2d5f0 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -48,11 +48,8 @@ #include #include -#ifdef Q_COMPILER_INITIALIZER_LISTS -#include -#endif - #include +#include #if defined(Q_CC_MSVC) #pragma warning( push ) @@ -242,7 +239,6 @@ class QHash public: inline QHash() noexcept : d(const_cast(&QHashData::shared_null)) { } -#ifdef Q_COMPILER_INITIALIZER_LISTS inline QHash(std::initializer_list > list) : d(const_cast(&QHashData::shared_null)) { @@ -250,7 +246,6 @@ public: for (typename std::initializer_list >::const_iterator it = list.begin(); it != list.end(); ++it) insert(it->first, it->second); } -#endif QHash(const QHash &other) : d(other.d) { d->ref.ref(); if (!d->sharable) detach(); } ~QHash() { if (!d->ref.deref()) freeData(d); } @@ -1042,14 +1037,12 @@ class QMultiHash : public QHash { public: QMultiHash() noexcept {} -#ifdef Q_COMPILER_INITIALIZER_LISTS inline QMultiHash(std::initializer_list > list) { this->reserve(int(list.size())); for (typename std::initializer_list >::const_iterator it = list.begin(); it != list.end(); ++it) insert(it->first, it->second); } -#endif #ifdef Q_QDOC template QMultiHash(InputIterator f, InputIterator l); diff --git a/src/corelib/tools/qlinkedlist.h b/src/corelib/tools/qlinkedlist.h index 0c8a99e258..8994449fbf 100644 --- a/src/corelib/tools/qlinkedlist.h +++ b/src/corelib/tools/qlinkedlist.h @@ -44,15 +44,11 @@ #include #include +#include +#include #include #include -#include - -#if defined(Q_COMPILER_INITIALIZER_LISTS) -# include -#endif - QT_BEGIN_NAMESPACE @@ -83,10 +79,8 @@ class QLinkedList public: inline QLinkedList() noexcept : d(const_cast(&QLinkedListData::shared_null)) { } inline QLinkedList(const QLinkedList &l) : d(l.d) { d->ref.ref(); if (!d->sharable) detach(); } -#if defined(Q_COMPILER_INITIALIZER_LISTS) inline QLinkedList(std::initializer_list list) : QLinkedList(list.begin(), list.end()) {} -#endif template = true> inline QLinkedList(InputIterator first, InputIterator last) : QLinkedList() diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index b916dcfd24..27868f7313 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -48,12 +48,10 @@ #include #include +#include +#include #include #include -#include -#ifdef Q_COMPILER_INITIALIZER_LISTS -#include -#endif #include #include @@ -166,13 +164,10 @@ public: inline QList &operator=(QList &&other) noexcept { QList moved(std::move(other)); swap(moved); return *this; } inline void swap(QList &other) noexcept { qSwap(d, other.d); } -#ifdef Q_COMPILER_INITIALIZER_LISTS inline QList(std::initializer_list args) : QList(args.begin(), args.end()) {} -#endif template = true> QList(InputIterator first, InputIterator last); - bool operator==(const QList &l) const; inline bool operator!=(const QList &l) const { return !(*this == l); } diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index 2d01a75a42..18c681581f 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -49,13 +49,10 @@ #include #endif +#include +#include #include #include -#include - -#ifdef Q_COMPILER_INITIALIZER_LISTS -#include -#endif QT_BEGIN_NAMESPACE @@ -326,14 +323,12 @@ class QMap public: inline QMap() noexcept : d(static_cast *>(const_cast(&QMapDataBase::shared_null))) { } -#ifdef Q_COMPILER_INITIALIZER_LISTS inline QMap(std::initializer_list > list) : d(static_cast *>(const_cast(&QMapDataBase::shared_null))) { for (typename std::initializer_list >::const_iterator it = list.begin(); it != list.end(); ++it) insert(it->first, it->second); } -#endif QMap(const QMap &other); inline ~QMap() { if (!d->ref.deref()) d->destroy(); } @@ -1186,13 +1181,11 @@ class QMultiMap : public QMap { public: QMultiMap() noexcept {} -#ifdef Q_COMPILER_INITIALIZER_LISTS inline QMultiMap(std::initializer_list > list) { for (typename std::initializer_list >::const_iterator it = list.begin(); it != list.end(); ++it) insert(it->first, it->second); } -#endif QMultiMap(const QMap &other) : QMap(other) {} QMultiMap(QMap &&other) noexcept : QMap(std::move(other)) {} void swap(QMultiMap &other) noexcept { QMap::swap(other); } diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h index 7ae715d247..8b31de71a9 100644 --- a/src/corelib/tools/qset.h +++ b/src/corelib/tools/qset.h @@ -43,10 +43,7 @@ #include #include -#ifdef Q_COMPILER_INITIALIZER_LISTS #include -#endif - #include QT_BEGIN_NAMESPACE @@ -59,10 +56,8 @@ class QSet public: inline QSet() noexcept {} -#ifdef Q_COMPILER_INITIALIZER_LISTS inline QSet(std::initializer_list list) : QSet(list.begin(), list.end()) {} -#endif template = true> inline QSet(InputIterator first, InputIterator last) { diff --git a/src/corelib/tools/qstringlist.h b/src/corelib/tools/qstringlist.h index 73ac737643..cf136a64c6 100644 --- a/src/corelib/tools/qstringlist.h +++ b/src/corelib/tools/qstringlist.h @@ -105,9 +105,7 @@ public: inline explicit QStringList(const QString &i) { append(i); } inline QStringList(const QList &l) : QList(l) { } inline QStringList(QList &&l) noexcept : QList(std::move(l)) { } -#ifdef Q_COMPILER_INITIALIZER_LISTS inline QStringList(std::initializer_list args) : QList(args) { } -#endif template = true> inline QStringList(InputIterator first, InputIterator last) : QList(first, last) { } diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index c81af68593..01fc63b677 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -45,14 +45,12 @@ #include #include +#include +#include +#include #include #include #include -#include -#ifdef Q_COMPILER_INITIALIZER_LISTS -#include -#endif -#include QT_BEGIN_NAMESPACE @@ -70,12 +68,10 @@ public: append(other.constData(), other.size()); } -#ifdef Q_COMPILER_INITIALIZER_LISTS QVarLengthArray(std::initializer_list args) : QVarLengthArray(args.begin(), args.end()) { } -#endif template = true> inline QVarLengthArray(InputIterator first, InputIterator last) @@ -103,7 +99,6 @@ public: return *this; } -#ifdef Q_COMPILER_INITIALIZER_LISTS QVarLengthArray &operator=(std::initializer_list list) { resize(list.size()); @@ -111,7 +106,6 @@ public: QT_MAKE_CHECKED_ARRAY_ITERATOR(this->begin(), this->size())); return *this; } -#endif inline void removeLast() { Q_ASSERT(s > 0); diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 7e14a0c9b2..d6baa76a30 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -48,12 +48,10 @@ #include #include +#include #include #include #include -#ifdef Q_COMPILER_INITIALIZER_LISTS -#include -#endif #include @@ -76,10 +74,8 @@ public: QVector &operator=(QVector &&other) noexcept { QVector moved(std::move(other)); swap(moved); return *this; } void swap(QVector &other) noexcept { qSwap(d, other.d); } -#ifdef Q_COMPILER_INITIALIZER_LISTS inline QVector(std::initializer_list args); QVector &operator=(std::initializer_list args); -#endif template = true> inline QVector(InputIterator first, InputIterator last); @@ -521,11 +517,10 @@ QVector::QVector(int asize, const T &t) } } -#ifdef Q_COMPILER_INITIALIZER_LISTS -# if defined(Q_CC_MSVC) +#if defined(Q_CC_MSVC) QT_WARNING_PUSH QT_WARNING_DISABLE_MSVC(4127) // conditional expression is constant -# endif // Q_CC_MSVC +#endif // Q_CC_MSVC template QVector::QVector(std::initializer_list args) @@ -550,10 +545,9 @@ QVector &QVector::operator=(std::initializer_list args) return *this; } -# if defined(Q_CC_MSVC) +#if defined(Q_CC_MSVC) QT_WARNING_POP -# endif // Q_CC_MSVC -#endif // Q_COMPILER_INITIALIZER_LISTS +#endif // Q_CC_MSVC template template > diff --git a/src/corelib/tools/qversionnumber.h b/src/corelib/tools/qversionnumber.h index 1488014d38..d43b86ba51 100644 --- a/src/corelib/tools/qversionnumber.h +++ b/src/corelib/tools/qversionnumber.h @@ -138,7 +138,6 @@ class QVersionNumber else pointer_segments = new QVector(std::move(seg)); } -#ifdef Q_COMPILER_INITIALIZER_LISTS SegmentStorage(std::initializer_list args) { if (dataFitsInline(args.begin(), int(args.size()))) { @@ -147,7 +146,6 @@ class QVersionNumber pointer_segments = new QVector(args); } } -#endif ~SegmentStorage() { if (isUsingPointer()) delete pointer_segments; } @@ -229,11 +227,9 @@ public: : m_segments(std::move(seg)) {} -#ifdef Q_COMPILER_INITIALIZER_LISTS inline QVersionNumber(std::initializer_list args) : m_segments(args) {} -#endif inline explicit QVersionNumber(int maj) { m_segments.setSegments(1, maj); } diff --git a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp index 8506d18dae..39d17e0a24 100644 --- a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp +++ b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp @@ -710,14 +710,12 @@ void tst_QtConcurrentRun::lambda() QCOMPARE(QtConcurrent::run([](int a, double b){ return a + b; }, 12, 15).result(), double(12+15)); QCOMPARE(QtConcurrent::run([](int a , int, int, int, int b){ return a + b; }, 1, 2, 3, 4, 5).result(), 1 + 5); -#ifdef Q_COMPILER_INITIALIZER_LISTS { QString str { "Hello World Foo" }; QFuture f1 = QtConcurrent::run([&](){ return str.split(' '); }); auto r = f1.result(); QCOMPARE(r, QStringList({"Hello", "World", "Foo"})); } -#endif // and now with explicit pool: QThreadPool pool; @@ -726,14 +724,12 @@ void tst_QtConcurrentRun::lambda() QCOMPARE(QtConcurrent::run(&pool, [](int a, double b){ return a + b; }, 12, 15).result(), double(12+15)); QCOMPARE(QtConcurrent::run(&pool, [](int a , int, int, int, int b){ return a + b; }, 1, 2, 3, 4, 5).result(), 1 + 5); -#ifdef Q_COMPILER_INITIALIZER_LISTS { QString str { "Hello World Foo" }; QFuture f1 = QtConcurrent::run(&pool, [&](){ return str.split(' '); }); auto r = f1.result(); QCOMPARE(r, QStringList({"Hello", "World", "Foo"})); } -#endif } QTEST_MAIN(tst_QtConcurrentRun) diff --git a/tests/auto/corelib/global/qflags/tst_qflags.cpp b/tests/auto/corelib/global/qflags/tst_qflags.cpp index 8265d21350..1568855032 100644 --- a/tests/auto/corelib/global/qflags/tst_qflags.cpp +++ b/tests/auto/corelib/global/qflags/tst_qflags.cpp @@ -258,7 +258,6 @@ void tst_QFlags::classEnum() void tst_QFlags::initializerLists() { -#if defined(Q_COMPILER_INITIALIZER_LISTS) Qt::MouseButtons bts = { Qt::LeftButton, Qt::RightButton }; QVERIFY(bts.testFlag(Qt::LeftButton)); QVERIFY(bts.testFlag(Qt::RightButton)); @@ -268,10 +267,6 @@ void tst_QFlags::initializerLists() QVERIFY(flags.testFlag(MyStrictNoOpEnum::StrictOne)); QVERIFY(flags.testFlag(MyStrictNoOpEnum::StrictFour)); QVERIFY(!flags.testFlag(MyStrictNoOpEnum::StrictTwo)); - -#else - QSKIP("This test requires C++11 initializer_list support."); -#endif // Q_COMPILER_INITIALIZER_LISTS } void tst_QFlags::testSetFlags() diff --git a/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/tests/auto/corelib/serialization/json/tst_qtjson.cpp index 083e78375a..548b6d0059 100644 --- a/tests/auto/corelib/serialization/json/tst_qtjson.cpp +++ b/tests/auto/corelib/serialization/json/tst_qtjson.cpp @@ -2754,9 +2754,6 @@ void tst_QtJson::testJsonValueRefDefault() void tst_QtJson::arrayInitializerList() { -#ifndef Q_COMPILER_INITIALIZER_LISTS - QSKIP("initializer_list is enabled only with c++11 support"); -#else QVERIFY(QJsonArray{}.isEmpty()); QCOMPARE(QJsonArray{"one"}.count(), 1); QCOMPARE(QJsonArray{1}.count(), 1); @@ -2802,14 +2799,10 @@ void tst_QtJson::arrayInitializerList() QCOMPARE(QJsonValue(a43["one"]), QJsonValue(1)); } } -#endif } void tst_QtJson::objectInitializerList() { -#ifndef Q_COMPILER_INITIALIZER_LISTS - QSKIP("initializer_list is enabled only with c++11 support"); -#else QVERIFY(QJsonObject{}.isEmpty()); { // one property @@ -2849,7 +2842,6 @@ void tst_QtJson::objectInitializerList() QCOMPARE(QJsonValue(nested[0]), QJsonValue("innerValue")); QCOMPARE(QJsonValue(nested[1]), QJsonValue(2.1)); } -#endif } void tst_QtJson::unicodeKeys() diff --git a/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp b/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp index 7df220acf9..4b085d387d 100644 --- a/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp +++ b/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp @@ -233,13 +233,11 @@ public: { } -#ifdef Q_COMPILER_INITIALIZER_LISTS VarLengthArray(std::initializer_list args) : QVarLengthArray(args) { } #endif -#endif }; class tst_ContainerApiSymmetry : public QObject @@ -614,7 +612,6 @@ struct ContainerDuplicatedValuesStrategy> : Contai template struct ContainerDuplicatedValuesStrategy> : ContainerRejectsDuplicateValues {}; -#if defined(Q_COMPILER_INITIALIZER_LISTS) template void non_associative_container_check_duplicates_impl(const std::initializer_list &reference, const Container &c, ContainerAcceptsDuplicateValues) { @@ -716,13 +713,6 @@ void tst_ContainerApiSymmetry::non_associative_container_duplicates_strategy() c Container c2{reference.begin(), reference.end()}; non_associative_container_check_duplicates(reference, c2); } -#else -template class Container> -void tst_ContainerApiSymmetry::non_associative_container_duplicates_strategy() const -{ - QSKIP("Test requires a better compiler"); -} -#endif // Q_COMPILER_INITIALIZER_LISTS template void tst_ContainerApiSymmetry::ranged_ctor_associative_impl() const diff --git a/tests/auto/corelib/tools/qbytearraylist/tst_qbytearraylist.cpp b/tests/auto/corelib/tools/qbytearraylist/tst_qbytearraylist.cpp index a28bbc12c8..09ce41337e 100644 --- a/tests/auto/corelib/tools/qbytearraylist/tst_qbytearraylist.cpp +++ b/tests/auto/corelib/tools/qbytearraylist/tst_qbytearraylist.cpp @@ -287,7 +287,6 @@ void tst_QByteArrayList::indexOf() const void tst_QByteArrayList::initializerList() const { -#ifdef Q_COMPILER_INITIALIZER_LISTS // constructor QByteArrayList v1 = {QByteArray("hello"),"world",QByteArray("plop")}; QCOMPARE(v1, (QByteArrayList() << "hello" << "world" << "plop")); @@ -296,9 +295,6 @@ void tst_QByteArrayList::initializerList() const QByteArrayList v2; v2 = {QByteArray("hello"),"world",QByteArray("plop")}; QCOMPARE(v2, v1); -#else - QSKIP("This test requires C++11 initializer_list support in the compiler."); -#endif } QTEST_APPLESS_MAIN(tst_QByteArrayList) diff --git a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp index 811e9a0010..de51c866e1 100644 --- a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp +++ b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp @@ -499,7 +499,7 @@ void tst_QCommandLineParser::testSingleDashWordOptionModes() void tst_QCommandLineParser::testCpp11StyleInitialization() { -#if defined(Q_COMPILER_INITIALIZER_LISTS) && defined(Q_COMPILER_UNIFORM_INIT) +#if defined(Q_COMPILER_UNIFORM_INIT) QCoreApplication app(empty_argc, empty_argv); QCommandLineParser parser; diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp index 0015efacfa..d70d488e96 100644 --- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp +++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp @@ -1480,7 +1480,6 @@ void tst_QHash::twoArguments_qHash() void tst_QHash::initializerList() { -#ifdef Q_COMPILER_INITIALIZER_LISTS QHash hash = {{1, "bar"}, {1, "hello"}, {2, "initializer_list"}}; QCOMPARE(hash.count(), 2); QCOMPARE(hash[1], QString("hello")); @@ -1507,9 +1506,6 @@ void tst_QHash::initializerList() QMultiHash emptyPairs2{{}, {}}; QVERIFY(!emptyPairs2.isEmpty()); -#else - QSKIP("Compiler doesn't support initializer lists"); -#endif } void tst_QHash::eraseValidIteratorOnSharedHash() diff --git a/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp b/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp index f17d6695f0..deb3b68c5c 100644 --- a/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp +++ b/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp @@ -1005,7 +1005,6 @@ void tst_QLinkedList::testSTLIteratorsComplex() const void tst_QLinkedList::initializeList() const { -#ifdef Q_COMPILER_INITIALIZER_LISTS QLinkedList v1 { 2, 3, 4 }; QCOMPARE(v1, QLinkedList() << 2 << 3 << 4); QCOMPARE(v1, (QLinkedList { 2, 3, 4})); @@ -1014,7 +1013,6 @@ void tst_QLinkedList::initializeList() const QLinkedList> v3; v3 << v1 << (QLinkedList() << 1) << QLinkedList() << v1; QCOMPARE(v3, v2); -#endif } diff --git a/tests/auto/corelib/tools/qlist/tst_qlist.cpp b/tests/auto/corelib/tools/qlist/tst_qlist.cpp index b3f8130d27..16fb291bd2 100644 --- a/tests/auto/corelib/tools/qlist/tst_qlist.cpp +++ b/tests/auto/corelib/tools/qlist/tst_qlist.cpp @@ -1871,7 +1871,6 @@ void tst_QList::testSTLIteratorsComplex() const void tst_QList::initializeList() const { -#ifdef Q_COMPILER_INITIALIZER_LISTS QList v1{2,3,4}; QCOMPARE(v1, QList() << 2 << 3 << 4); QCOMPARE(v1, (QList{2,3,4})); @@ -1880,7 +1879,6 @@ void tst_QList::initializeList() const QList> v3; v3 << v1 << (QList() << 1) << QList() << v1; QCOMPARE(v3, v2); -#endif } template diff --git a/tests/auto/corelib/tools/qmap/tst_qmap.cpp b/tests/auto/corelib/tools/qmap/tst_qmap.cpp index b39444e76f..d66fd28779 100644 --- a/tests/auto/corelib/tools/qmap/tst_qmap.cpp +++ b/tests/auto/corelib/tools/qmap/tst_qmap.cpp @@ -1319,7 +1319,6 @@ void tst_QMap::checkMostLeftNode() void tst_QMap::initializerList() { -#ifdef Q_COMPILER_INITIALIZER_LISTS QMap map = {{1, "bar"}, {1, "hello"}, {2, "initializer_list"}}; QCOMPARE(map.count(), 2); QCOMPARE(map[1], QString("hello")); @@ -1346,9 +1345,6 @@ void tst_QMap::initializerList() QMultiMap emptyPairs2{{}, {}}; QVERIFY(!emptyPairs2.isEmpty()); -#else - QSKIP("Compiler doesn't support initializer lists"); -#endif } void tst_QMap::testInsertWithHint() diff --git a/tests/auto/corelib/tools/qset/tst_qset.cpp b/tests/auto/corelib/tools/qset/tst_qset.cpp index 0b60350380..31b4c0449e 100644 --- a/tests/auto/corelib/tools/qset/tst_qset.cpp +++ b/tests/auto/corelib/tools/qset/tst_qset.cpp @@ -955,7 +955,6 @@ void tst_QSet::makeSureTheComfortFunctionsCompile() void tst_QSet::initializerList() { -#ifdef Q_COMPILER_INITIALIZER_LISTS QSet set = {1, 1, 2, 3, 4, 5}; QCOMPARE(set.count(), 5); QVERIFY(set.contains(1)); @@ -976,9 +975,6 @@ void tst_QSet::initializerList() QSet set3{{}, {}, {}}; QVERIFY(!set3.isEmpty()); -#else - QSKIP("Compiler doesn't support initializer lists"); -#endif } void tst_QSet::qhash() @@ -1011,15 +1007,7 @@ void tst_QSet::qhash() // check that sets of sets work: // { -#ifdef Q_COMPILER_INITIALIZER_LISTS QSet > intSetSet = { { 0, 1, 2 }, { 0, 1 }, { 1, 2 } }; -#else - QSet > intSetSet; - QSet intSet01, intSet12; - intSet01 << 0 << 1; - intSet12 << 1 << 2; - intSetSet << intSet01 << intSet12 << (intSet01|intSet12); -#endif QCOMPARE(intSetSet.size(), 3); } } diff --git a/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp b/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp index 37368c3dfc..2b5aa8e98b 100644 --- a/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp +++ b/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp @@ -63,9 +63,7 @@ private slots: void joinChar() const; void joinChar_data() const; -#ifdef Q_COMPILER_INITIALIZER_LISTS void initializeList() const; -#endif }; extern const char email[]; @@ -519,8 +517,6 @@ void tst_QStringList::joinEmptiness() const QVERIFY(string.isNull()); } -#ifdef Q_COMPILER_INITIALIZER_LISTS -// C++0x support is required void tst_QStringList::initializeList() const { @@ -528,7 +524,6 @@ void tst_QStringList::initializeList() const QCOMPARE(v1, (QStringList() << "hello" << "world" << "plop")); QCOMPARE(v1, (QStringList{"hello","world","plop"})); } -#endif QTEST_APPLESS_MAIN(tst_QStringList) #include "tst_qstringlist.moc" diff --git a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp index 5737db760c..fff8c75a90 100644 --- a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp +++ b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp @@ -908,7 +908,6 @@ void tst_QVarLengthArray::initializeListComplex() template void tst_QVarLengthArray::initializeList() { -#ifdef Q_COMPILER_INITIALIZER_LISTS T val1(110); T val2(105); T val3(101); @@ -945,9 +944,6 @@ void tst_QVarLengthArray::initializeList() v6 = {}; // assign empty QCOMPARE(v6.size(), 0); -#else - QSKIP("This tests requires a compiler that supports initializer lists."); -#endif } void tst_QVarLengthArray::insertMove() diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp index f7e7c3e3ae..172b03a445 100644 --- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp +++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp @@ -549,7 +549,6 @@ void tst_QVector::assignmentCustom() const template void tst_QVector::assignFromInitializerList() const { -#ifdef Q_COMPILER_INITIALIZER_LISTS T val1(SimpleValue::at(1)); T val2(SimpleValue::at(2)); T val3(SimpleValue::at(3)); @@ -560,9 +559,6 @@ void tst_QVector::assignFromInitializerList() const v1 = {}; QCOMPARE(v1.size(), 0); -#else - QSKIP("This test requires support for C++11 initializer lists."); -#endif } void tst_QVector::assignFromInitializerListInt() const @@ -2553,7 +2549,6 @@ void tst_QVector::reallocAfterCopy() template void tst_QVector::initializeList() { -#ifdef Q_COMPILER_INITIALIZER_LISTS T val1(SimpleValue::at(1)); T val2(SimpleValue::at(2)); T val3(SimpleValue::at(3)); @@ -2570,7 +2565,6 @@ void tst_QVector::initializeList() QVector v4({}); QCOMPARE(v4.size(), 0); -#endif } void tst_QVector::initializeListInt() diff --git a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp index 9bc8c84ee4..7c4d1071ce 100644 --- a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp +++ b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp @@ -260,12 +260,10 @@ void tst_QVersionNumber::constructorExplicit() QCOMPARE(v5.segments(), v6.segments()); -#ifdef Q_COMPILER_INITIALIZER_LISTS QVersionNumber v7(4, 5, 6); QVersionNumber v8 = {4, 5, 6}; QCOMPARE(v7.segments(), v8.segments()); -#endif } void tst_QVersionNumber::constructorCopy_data() From f5de7896d78bb73eecbf65c2ac6864ccd8a86e0a Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 3 May 2019 10:17:04 +0200 Subject: [PATCH 250/292] Use -Wextra instead -W -W is a really old way of writing -Wextra. Change-Id: Ibc531749293fab9b03e404fe751fc1c7b4a7e6db Reviewed-by: Joerg Bornemann --- mkspecs/common/gcc-base.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/common/gcc-base.conf b/mkspecs/common/gcc-base.conf index 44b4267207..4d82321cba 100644 --- a/mkspecs/common/gcc-base.conf +++ b/mkspecs/common/gcc-base.conf @@ -38,7 +38,7 @@ QMAKE_CFLAGS_OPTIMIZE_SIZE = -Os !equals(QMAKE_HOST.os, Windows): QMAKE_CFLAGS += -pipe QMAKE_CFLAGS_DEPS += -M -QMAKE_CFLAGS_WARN_ON += -Wall -W +QMAKE_CFLAGS_WARN_ON += -Wall -Wextra QMAKE_CFLAGS_WARN_OFF += -w QMAKE_CFLAGS_RELEASE += $$QMAKE_CFLAGS_OPTIMIZE QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_OPTIMIZE -g From f27f89f3357326f8cc3b6bbc560160e909af7ead Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 2 May 2019 08:53:24 +0200 Subject: [PATCH 251/292] Don't use deprecated API Change-Id: Ic56c22a1be5e69b371991c3e9ad98a1106848e78 Reviewed-by: Thiago Macieira --- .../tools/collections/tst_collections.cpp | 42 +++++++++---------- tests/auto/corelib/tools/qlist/tst_qlist.cpp | 4 +- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/tests/auto/corelib/tools/collections/tst_collections.cpp b/tests/auto/corelib/tools/collections/tst_collections.cpp index 104de4d783..9bd90d21cd 100644 --- a/tests/auto/corelib/tools/collections/tst_collections.cpp +++ b/tests/auto/corelib/tools/collections/tst_collections.cpp @@ -580,73 +580,73 @@ void tst_Collections::list() list1 << 0 << 1 << 2 << 3; list1.removeFirst(); - list1.swap(0, 0); + list1.swapItemsAt(0, 0); QVERIFY(list1 == QList() << 1 << 2 << 3); - list1.swap(1, 1); + list1.swapItemsAt(1, 1); QVERIFY(list1 == QList() << 1 << 2 << 3); - list1.swap(2, 2); + list1.swapItemsAt(2, 2); QVERIFY(list1 == QList() << 1 << 2 << 3); - list1.swap(0, 1); + list1.swapItemsAt(0, 1); QVERIFY(list1 == QList() << 2 << 1 << 3); - list1.swap(0, 2); + list1.swapItemsAt(0, 2); QVERIFY(list1 == QList() << 3 << 1 << 2); - list1.swap(1, 2); + list1.swapItemsAt(1, 2); QVERIFY(list1 == QList() << 3 << 2 << 1); - list1.swap(1, 2); + list1.swapItemsAt(1, 2); QVERIFY(list1 == QList() << 3 << 1 << 2); QList list2; list2 << "1" << "2" << "3"; - list2.swap(0, 0); + list2.swapItemsAt(0, 0); QVERIFY(list2 == QList() << "1" << "2" << "3"); - list2.swap(1, 1); + list2.swapItemsAt(1, 1); QVERIFY(list2 == QList() << "1" << "2" << "3"); - list2.swap(2, 2); + list2.swapItemsAt(2, 2); QVERIFY(list2 == QList() << "1" << "2" << "3"); - list2.swap(0, 1); + list2.swapItemsAt(0, 1); QVERIFY(list2 == QList() << "2" << "1" << "3"); - list2.swap(0, 2); + list2.swapItemsAt(0, 2); QVERIFY(list2 == QList() << "3" << "1" << "2"); - list2.swap(1, 2); + list2.swapItemsAt(1, 2); QVERIFY(list2 == QList() << "3" << "2" << "1"); - list2.swap(1, 2); + list2.swapItemsAt(1, 2); QVERIFY(list2 == QList() << "3" << "1" << "2"); QList list3; list3 << 1.0 << 2.0 << 3.0; - list3.swap(0, 0); + list3.swapItemsAt(0, 0); QVERIFY(list3 == QList() << 1.0 << 2.0 << 3.0); - list3.swap(1, 1); + list3.swapItemsAt(1, 1); QVERIFY(list3 == QList() << 1.0 << 2.0 << 3.0); - list3.swap(2, 2); + list3.swapItemsAt(2, 2); QVERIFY(list3 == QList() << 1.0 << 2.0 << 3.0); - list3.swap(0, 1); + list3.swapItemsAt(0, 1); QVERIFY(list3 == QList() << 2.0 << 1.0 << 3.0); - list3.swap(0, 2); + list3.swapItemsAt(0, 2); QVERIFY(list3 == QList() << 3.0 << 1.0 << 2.0); - list3.swap(1, 2); + list3.swapItemsAt(1, 2); QVERIFY(list3 == QList() << 3.0 << 2.0 << 1.0); - list3.swap(1, 2); + list3.swapItemsAt(1, 2); QVERIFY(list3 == QList() << 3.0 << 1.0 << 2.0); } diff --git a/tests/auto/corelib/tools/qlist/tst_qlist.cpp b/tests/auto/corelib/tools/qlist/tst_qlist.cpp index 16fb291bd2..995aa245d1 100644 --- a/tests/auto/corelib/tools/qlist/tst_qlist.cpp +++ b/tests/auto/corelib/tools/qlist/tst_qlist.cpp @@ -1457,11 +1457,11 @@ void tst_QList::swap() const list << T_FOO << T_BAR << T_BAZ; // swap - list.swap(0, 2); + list.swapItemsAt(0, 2); QCOMPARE(list, QList() << T_BAZ << T_BAR << T_FOO); // swap again - list.swap(1, 2); + list.swapItemsAt(1, 2); QCOMPARE(list, QList() << T_BAZ << T_FOO << T_BAR); QList list2; From e3b55616e2334570fed3855e1855216bd9f85769 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 2 May 2019 09:24:11 +0200 Subject: [PATCH 252/292] Prefix QTextStream operators with Qt:: in tests Change-Id: I852f016fcb619a9e634deee6efb1fe7930d974c8 Reviewed-by: Allan Sandfeld Jensen --- tests/auto/corelib/io/qdebug/tst_qdebug.cpp | 8 +++--- tests/auto/corelib/io/qfile/tst_qfile.cpp | 4 +-- .../corelib/io/qfileinfo/tst_qfileinfo.cpp | 2 +- .../qloggingcategory/tst_qloggingcategory.cpp | 2 +- .../qtextstream/readLineStdinProcess/main.cpp | 2 +- .../qtextstream/tst_qtextstream.cpp | 16 +++++------ .../qxmlstream/tst_qxmlstream.cpp | 28 +++++++++---------- .../tools/qalgorithms/tst_qalgorithms.cpp | 22 +++++++-------- .../gui/kernel/qkeyevent/tst_qkeyevent.cpp | 2 +- .../gui/text/qstatictext/tst_qstatictext.cpp | 2 +- .../socket/qlocalsocket/tst_qlocalsocket.cpp | 4 +-- .../qgraphicsitem/tst_qgraphicsitem.cpp | 2 +- .../xml/sax/qxmlsimplereader/parser/main.cpp | 4 +-- 13 files changed, 49 insertions(+), 49 deletions(-) diff --git a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp index 7b8b1df166..a818c6c09d 100644 --- a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp +++ b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp @@ -309,7 +309,7 @@ void tst_QDebug::stateSaver() const QDebug d = qDebug(); { QDebugStateSaver saver(d); - d.nospace() << hex << right << qSetFieldWidth(3) << qSetPadChar('0') << 42; + d.nospace() << Qt::hex << Qt::right << qSetFieldWidth(3) << qSetPadChar('0') << 42; } d << 42; } @@ -327,7 +327,7 @@ void tst_QDebug::stateSaver() const { QDebug d = qDebug(); - d.noquote().nospace() << QStringLiteral("Hello") << hex << 42; + d.noquote().nospace() << QStringLiteral("Hello") << Qt::hex << 42; { QDebugStateSaver saver(d); d.resetFormat(); @@ -660,7 +660,7 @@ void tst_QDebug::textStreamModifiers() const QString file, function; int line = 0; MessageHandlerSetter mhs(myMessageHandler); - { qDebug() << hex << short(0xf) << int(0xf) << unsigned(0xf) << long(0xf) << qint64(0xf) << quint64(0xf); } + { qDebug() << Qt::hex << short(0xf) << int(0xf) << unsigned(0xf) << long(0xf) << qint64(0xf) << quint64(0xf); } #ifndef QT_NO_MESSAGELOGCONTEXT file = __FILE__; line = __LINE__ - 2; function = Q_FUNC_INFO; #endif @@ -678,7 +678,7 @@ void tst_QDebug::resetFormat() const MessageHandlerSetter mhs(myMessageHandler); { QDebug d = qDebug(); - d.nospace().noquote() << hex << int(0xf); + d.nospace().noquote() << Qt::hex << int(0xf); d.resetFormat() << int(0xf) << QStringLiteral("foo"); } #ifndef QT_NO_MESSAGELOGCONTEXT diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 678a80c3f7..4f010f37c2 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -2099,7 +2099,7 @@ void tst_QFile::i18nFileName() QVERIFY2(file.open(QFile::WriteOnly | QFile::Text), msgOpenFailed(file).constData()); QTextStream ts(&file); ts.setCodec("UTF-8"); - ts << fileName << endl; + ts << fileName << Qt::endl; } { QFile file(fileName); @@ -2149,7 +2149,7 @@ void tst_QFile::longFileName() QFile file(fileName); QVERIFY2(file.open(QFile::WriteOnly | QFile::Text), msgOpenFailed(file).constData()); QTextStream ts(&file); - ts << fileName << endl; + ts << fileName << Qt::endl; } { QFile file(fileName); diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index a92b4bd1cb..64075a94f0 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -1182,7 +1182,7 @@ void tst_QFileInfo::fileTimes() QTest::qSleep(sleepTime); beforeWrite = QDateTime::currentDateTime().addMSecs(-fsClockSkew); QTextStream ts(&file); - ts << fileName << endl; + ts << fileName << Qt::endl; } { QFileInfo fileInfo(fileName); diff --git a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp index 08635d34c5..79ac6b0fc4 100644 --- a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp +++ b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp @@ -104,7 +104,7 @@ public: for (int a = 0; a < _configitemEntryOrder.count(); a++) { out << _configitemEntryOrder[a] << " = " - << _values.value(_configitemEntryOrder[a]) << endl; + << _values.value(_configitemEntryOrder[a]) << Qt::endl; } out.flush(); return ret.toLatin1(); diff --git a/tests/auto/corelib/serialization/qtextstream/readLineStdinProcess/main.cpp b/tests/auto/corelib/serialization/qtextstream/readLineStdinProcess/main.cpp index 41ea5e56f0..2d4aa452ca 100644 --- a/tests/auto/corelib/serialization/qtextstream/readLineStdinProcess/main.cpp +++ b/tests/auto/corelib/serialization/qtextstream/readLineStdinProcess/main.cpp @@ -41,7 +41,7 @@ int main(int argc, char **argv) do { line = qin.readLine(); if (!line.isNull()) - qerr << line << flush; + qerr << line << Qt::flush; } while (!line.isNull()); return 0; } diff --git a/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp index af97d4a003..c4fb623130 100644 --- a/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp @@ -245,7 +245,7 @@ private: void runOnExit() { QByteArray buffer; - QTextStream(&buffer) << "This will try to use QTextCodec::codecForLocale" << endl; + QTextStream(&buffer) << "This will try to use QTextCodec::codecForLocale" << Qt::endl; } Q_DESTRUCTOR_FUNCTION(runOnExit) @@ -1506,9 +1506,9 @@ void tst_QTextStream::readStdin() stdinProcess.setReadChannel(QProcess::StandardError); QTextStream stream(&stdinProcess); - stream << "1" << endl; - stream << "2" << endl; - stream << "3" << endl; + stream << "1" << Qt::endl; + stream << "2" << Qt::endl; + stream << "3" << Qt::endl; stdinProcess.closeWriteChannel(); @@ -1534,7 +1534,7 @@ void tst_QTextStream::readAllFromStdin() QTextStream stream(&stdinProcess); stream.setCodec("ISO-8859-1"); - stream << "hello world" << flush; + stream << "hello world" << Qt::flush; stdinProcess.closeWriteChannel(); @@ -1824,7 +1824,7 @@ void tst_QTextStream::utf8IncompleteAtBufferBoundary() out.setFieldWidth(3); for (int i = 0; i < 1000; ++i) { - out << i << lineContents << endl; + out << i << lineContents << Qt::endl; } } data.close(); @@ -2726,7 +2726,7 @@ void tst_QTextStream::generateBOM() QTextStream stream(&file); stream.setCodec(QTextCodec::codecForName("UTF-16LE")); - stream << "Hello" << endl; + stream << "Hello" << Qt::endl; file.close(); QVERIFY(file.open(QFile::ReadOnly)); @@ -2740,7 +2740,7 @@ void tst_QTextStream::generateBOM() QTextStream stream(&file); stream.setCodec(QTextCodec::codecForName("UTF-16LE")); - stream << bom << "Hello" << endl; + stream << Qt::bom << "Hello" << Qt::endl; file.close(); QVERIFY(file.open(QFile::ReadOnly)); diff --git a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp index e4d50607b7..92a0d8bbfa 100644 --- a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp +++ b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp @@ -115,7 +115,7 @@ static QByteArray makeCanonical(const QString &filename, writeDtd << "'; - writeDtd << endl; + writeDtd << Qt::endl; } writeDtd << "]>"; - writeDtd << endl; + writeDtd << Qt::endl; writer.writeDTD(dtd); } } else if (reader.isStartElement()) { @@ -740,7 +740,7 @@ QByteArray tst_QXmlStream::readFile(const QString &filename) const auto attributes = reader.attributes(); if (attributes.size()) { for (const QXmlStreamAttribute &attribute : attributes) { - writer << endl << " Attribute("; + writer << Qt::endl << " Attribute("; if (!attribute.name().isEmpty()) writer << " name=\"" << attribute.name().toString() << '"'; if (!attribute.namespaceUri().isEmpty()) @@ -751,37 +751,37 @@ QByteArray tst_QXmlStream::readFile(const QString &filename) writer << " prefix=\"" << attribute.prefix().toString() << '"'; if (!attribute.value().isEmpty()) writer << " value=\"" << attribute.value().toString() << '"'; - writer << " )" << endl; + writer << " )" << Qt::endl; } } const auto namespaceDeclarations = reader.namespaceDeclarations(); if (namespaceDeclarations.size()) { for (const QXmlStreamNamespaceDeclaration &namespaceDeclaration : namespaceDeclarations) { - writer << endl << " NamespaceDeclaration("; + writer << Qt::endl << " NamespaceDeclaration("; if (!namespaceDeclaration.prefix().isEmpty()) writer << " prefix=\"" << namespaceDeclaration.prefix().toString() << '"'; if (!namespaceDeclaration.namespaceUri().isEmpty()) writer << " namespaceUri=\"" << namespaceDeclaration.namespaceUri().toString() << '"'; - writer << " )" << endl; + writer << " )" << Qt::endl; } } const auto notationDeclarations = reader.notationDeclarations(); if (notationDeclarations.size()) { for (const QXmlStreamNotationDeclaration ¬ationDeclaration : notationDeclarations) { - writer << endl << " NotationDeclaration("; + writer << Qt::endl << " NotationDeclaration("; if (!notationDeclaration.name().isEmpty()) writer << " name=\"" << notationDeclaration.name().toString() << '"'; if (!notationDeclaration.systemId().isEmpty()) writer << " systemId=\"" << notationDeclaration.systemId().toString() << '"'; if (!notationDeclaration.publicId().isEmpty()) writer << " publicId=\"" << notationDeclaration.publicId().toString() << '"'; - writer << " )" << endl; + writer << " )" << Qt::endl; } } const auto entityDeclarations = reader.entityDeclarations(); if (entityDeclarations.size()) { for (const QXmlStreamEntityDeclaration &entityDeclaration : entityDeclarations) { - writer << endl << " EntityDeclaration("; + writer << Qt::endl << " EntityDeclaration("; if (!entityDeclaration.name().isEmpty()) writer << " name=\"" << entityDeclaration.name().toString() << '"'; if (!entityDeclaration.notationName().isEmpty()) @@ -792,13 +792,13 @@ QByteArray tst_QXmlStream::readFile(const QString &filename) writer << " publicId=\"" << entityDeclaration.publicId().toString() << '"'; if (!entityDeclaration.value().isEmpty()) writer << " value=\"" << entityDeclaration.value().toString() << '"'; - writer << " )" << endl; + writer << " )" << Qt::endl; } } - writer << " )" << endl; + writer << " )" << Qt::endl; } if (reader.hasError()) - writer << "ERROR: " << reader.errorString() << endl; + writer << "ERROR: " << reader.errorString() << Qt::endl; return outarray; } @@ -1169,7 +1169,7 @@ int main(int argc, char *argv[]) bool error = false; QByteArray canonical = makeCanonical(argv[2], "doc", error); QTextStream myStdOut(stdout); - myStdOut << canonical << endl; + myStdOut << canonical << Qt::endl; exit(0); } diff --git a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp index 72299402f0..06db0e8546 100644 --- a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp +++ b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp @@ -208,7 +208,7 @@ void printHeader(QStringList &headers) for (int h = 0; h < headers.count(); ++h) { cout << setw(20) << setiosflags(ios_base::left) << headers.at(h).toLatin1().constData(); } - cout << endl; + cout << Qt::endl; } template @@ -220,7 +220,7 @@ void print(ContainerType testContainer) cout << value << " "; } - cout << endl; + cout << Qt::endl; } template @@ -252,7 +252,7 @@ void testAlgorithm(Algorithm algorithm, QStringList &dataSetTypes) lessThan << setiosflags(ios_base::left) << setw(10) << result.lessThanRefCount / result.numSorts; cout << numSorts.str() << lessThan.str(); } - cout << endl; + cout << Qt::endl; } } #endif @@ -765,21 +765,21 @@ public: #if Q_TEST_PERFORMANCE void tst_QAlgorithms::performance() { - cout << endl << "Quick sort" << endl; + cout << Qt::endl << "Quick sort" << Qt::endl; testAlgorithm, TestInt>(QuickSortHelper(), dataSetTypes); - cout << endl << "stable sort" << endl; + cout << Qt::endl << "stable sort" << Qt::endl; testAlgorithm, TestInt>(StableSortHelper(), dataSetTypes); - cout << endl << "std::sort" << endl; + cout << Qt::endl << "std::sort" << Qt::endl; testAlgorithm, TestInt>(StlSortHelper(), dataSetTypes); - cout << endl << "std::stable_sort" << endl; + cout << Qt::endl << "std::stable_sort" << Qt::endl; testAlgorithm, TestInt>(StlStableSortHelper(), dataSetTypes); /* - cout << endl << "Sorting lists of ints" << endl; - cout << endl << "Quick sort" << endl; + cout << Qt::endl << "Sorting lists of ints" << Qt::endl; + cout << Qt::endl << "Quick sort" << Qt::endl; testAlgorithm, int>(QuickSortHelper(), dataSetTypes); - cout << endl << "std::sort" << endl; + cout << Qt::endl << "std::sort" << Qt::endl; testAlgorithm, int>(StlSortHelper(), dataSetTypes); - cout << endl << "std::stable_sort" << endl; + cout << Qt::endl << "std::stable_sort" << Qt::endl; testAlgorithm, int>(StlStableSortHelper(), dataSetTypes); */ } diff --git a/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp b/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp index bad021c3b0..9a4c560a08 100644 --- a/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp +++ b/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp @@ -121,7 +121,7 @@ static QByteArray modifiersTestRowName(const QString &keySequence) if (uc > 32 && uc < 128) str << '"' << c << '"'; else - str << "U+" << hex << uc << dec; + str << "U+" << Qt::hex << uc << Qt::dec; if (i < size - 1) str << ','; } diff --git a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp index d00dc251d8..b091edb64d 100644 --- a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp +++ b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp @@ -681,7 +681,7 @@ static bool checkPixels(const QImage &image, if (pixel != expectedRgb1 && pixel != expectedRgb2) { QString message; QDebug(&message) << "Color mismatch in image" << image - << "at" << x << ',' << y << ':' << showbase << hex << pixel + << "at" << x << ',' << y << ':' << Qt::showbase << Qt::hex << pixel << "(expected: " << expectedRgb1 << ',' << expectedRgb2 << ')'; *errorMessage = message.toLocal8Bit(); return false; diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp index 45ab275510..f53c75c6a4 100644 --- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp @@ -552,7 +552,7 @@ void tst_QLocalSocket::sendData() QCOMPARE(serverSocket->state(), QLocalSocket::ConnectedState); QTextStream out(serverSocket); QTextStream in(&socket); - out << testLine << endl; + out << testLine << Qt::endl; bool wrote = serverSocket->waitForBytesWritten(3000); if (!socket.canReadLine()) { @@ -877,7 +877,7 @@ public: QLocalSocket *serverSocket = server.nextPendingConnection(); QVERIFY(serverSocket); QTextStream out(serverSocket); - out << testLine << endl; + out << testLine << Qt::endl; QCOMPARE(serverSocket->state(), QLocalSocket::ConnectedState); QVERIFY2(serverSocket->waitForBytesWritten(), serverSocket->errorString().toLatin1().constData()); QCOMPARE(serverSocket->errorString(), QString("Unknown error")); diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index bca664c05b..0cfdecbcab 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -8386,7 +8386,7 @@ void tst_QGraphicsItem::focusProxy() QString err; QTextStream stream(&err); stream << "QGraphicsItem::setFocusProxy: " - << (void*)item << " is already in the focus proxy chain" << flush; + << (void*)item << " is already in the focus proxy chain" << Qt::flush; QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData()); item2->setFocusProxy(item); // fails QCOMPARE(item->focusProxy(), (QGraphicsItem *)item2); diff --git a/tests/auto/xml/sax/qxmlsimplereader/parser/main.cpp b/tests/auto/xml/sax/qxmlsimplereader/parser/main.cpp index 15f10232bd..b5d9fea315 100644 --- a/tests/auto/xml/sax/qxmlsimplereader/parser/main.cpp +++ b/tests/auto/xml/sax/qxmlsimplereader/parser/main.cpp @@ -72,7 +72,7 @@ int main(int argc, const char *argv[]) QFile in_file(file_name); if (!in_file.open(QIODevice::ReadOnly)) { - qerr << "Could not open " << file_name << ": " << strerror(errno) << endl; + qerr << "Could not open " << file_name << ": " << strerror(errno) << Qt::endl; return 1; } @@ -87,7 +87,7 @@ int main(int argc, const char *argv[]) } else { _out_file.setFileName(out_file_name); if (!_out_file.open(QIODevice::WriteOnly | QIODevice::Truncate)) { - qerr << "Could not open " << out_file_name << ": " << strerror(errno) << endl; + qerr << "Could not open " << out_file_name << ": " << strerror(errno) << Qt::endl; return 1; } _out_stream.setDevice(&_out_file); From 1f1e04f29f93401c8d0aa0941f92cc1e4a6c7688 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 2 May 2019 14:31:34 +0200 Subject: [PATCH 253/292] Deprecate providing a function as a property flag Property flags such as SCRIPTABLE should not get controlled by a function. I can't see this feature being used anywhere and it leads to additional overhead that I'd like to get rid of for Qt 6. Change-Id: Iaa10b2b3bfb7eec11401f7b6bb887c9467b67183 Reviewed-by: Thiago Macieira Reviewed-by: Simon Hausmann --- src/tools/moc/moc.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 7f43917f7e..2f0ea633fa 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -1194,6 +1194,15 @@ void Moc::createPropertyDef(PropertyDef &propDef) propDef.type = type; + auto checkIsFunction = [&](const QByteArray &def, const char *name) { + if (def.endsWith(')')) { + QByteArray msg = "Providing a function for "; + msg += name; + msg += " in a property declaration is deprecated and will not be supported in Qt 6 anymore."; + warning(msg.constData()); + } + }; + next(); propDef.name = lexem(); while (test(IDENTIFIER)) { @@ -1243,11 +1252,13 @@ void Moc::createPropertyDef(PropertyDef &propDef) error(2); break; case 'S': - if (l == "SCRIPTABLE") + if (l == "SCRIPTABLE") { propDef.scriptable = v + v2; - else if (l == "STORED") + checkIsFunction(propDef.scriptable, "SCRIPTABLE"); + } else if (l == "STORED") { propDef.stored = v + v2; - else + checkIsFunction(propDef.stored, "STORED"); + } else error(2); break; case 'W': if (l != "WRITE") error(2); @@ -1255,15 +1266,18 @@ void Moc::createPropertyDef(PropertyDef &propDef) break; case 'D': if (l != "DESIGNABLE") error(2); propDef.designable = v + v2; + checkIsFunction(propDef.designable, "DESIGNABLE"); break; case 'E': if (l != "EDITABLE") error(2); propDef.editable = v + v2; + checkIsFunction(propDef.editable, "EDITABLE"); break; case 'N': if (l != "NOTIFY") error(2); propDef.notify = v; break; case 'U': if (l != "USER") error(2); propDef.user = v + v2; + checkIsFunction(propDef.user, "USER"); break; default: error(2); From e929808c83e4a473135590c69413a98f36a3500a Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 3 May 2019 11:43:03 +0200 Subject: [PATCH 254/292] Prefix QTextStream operators with Qt:: Change-Id: I128769cb78abb8168f0bf29cef8c693073793ced Reviewed-by: Allan Sandfeld Jensen --- src/gui/text/qtextmarkdownwriter.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/text/qtextmarkdownwriter.cpp b/src/gui/text/qtextmarkdownwriter.cpp index fed4a7b766..313d62bb8a 100644 --- a/src/gui/text/qtextmarkdownwriter.cpp +++ b/src/gui/text/qtextmarkdownwriter.cpp @@ -80,10 +80,10 @@ void QTextMarkdownWriter::writeTable(const QAbstractTableModel &table) QString s = table.headerData(col, Qt::Horizontal).toString(); m_stream << "|" << s << QString(tableColumnWidths[col] - s.length(), Space); } - m_stream << "|" << endl; + m_stream << "|" << Qt::endl; for (int col = 0; col < tableColumnWidths.length(); ++col) m_stream << '|' << QString(tableColumnWidths[col], QLatin1Char('-')); - m_stream << '|'<< endl; + m_stream << '|'<< Qt::endl; // write the body for (int row = 0; row < table.rowCount(); ++row) { @@ -91,7 +91,7 @@ void QTextMarkdownWriter::writeTable(const QAbstractTableModel &table) QString s = table.data(table.index(row, col)).toString(); m_stream << "|" << s << QString(tableColumnWidths[col] - s.length(), Space); } - m_stream << '|'<< endl; + m_stream << '|'<< Qt::endl; } } From b5547e49cd1760ba5d100dcc720e6366cbd23f06 Mon Sep 17 00:00:00 2001 From: Kevin Funk Date: Thu, 25 Apr 2019 16:33:20 +0200 Subject: [PATCH 255/292] Fix minor compiler warning from Clang Fixes: .../qcolorspace_p.h:70:25: warning: explicitly defaulted copy assignment operator is implicitly deleted [-Wdefaulted-function-deleted] QColorSpacePrivate &operator=(const QColorSpacePrivate &other) = default; ^ .../qcolorspace_p.h:63:28: note: copy assignment operator of 'QColorSpacePrivate' is implicitly deleted because base class 'QSharedData' has an inaccessible copy assignment operator class QColorSpacePrivate : public QSharedData ^ Change-Id: I20d453279ec2cb8b9b9d1364762c6e560d6f843d Reviewed-by: Simon Hausmann --- src/gui/painting/qcolorspace_p.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/painting/qcolorspace_p.h b/src/gui/painting/qcolorspace_p.h index 21260a281d..a6ab2ab5cd 100644 --- a/src/gui/painting/qcolorspace_p.h +++ b/src/gui/painting/qcolorspace_p.h @@ -93,7 +93,6 @@ public: QColorSpacePrivate(QColorSpace::Gamut gamut, QColorSpace::TransferFunction fun, float gamma); QColorSpacePrivate(const QColorSpacePrimaries &primaries, QColorSpace::TransferFunction fun, float gamma); QColorSpacePrivate(const QColorSpacePrivate &other) = default; - QColorSpacePrivate &operator=(const QColorSpacePrivate &other) = default; void initialize(); void setToXyzMatrix(); From 82ddecfb17158c35de1d0740dd7ecd5562d41726 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 3 May 2019 11:53:18 +0200 Subject: [PATCH 256/292] Deprecate {to,from}Std{List,Vector} ask our users to use the range constructors instead. This will allow us to remove the include dependency towards and in Qt 6. Change-Id: Id90f2058432e19941de1fa847100a7920432ad71 Reviewed-by: Thiago Macieira --- src/corelib/tools/qlist.h | 6 ++++++ src/corelib/tools/qvector.h | 6 ++++++ tests/auto/corelib/tools/qlist/tst_qlist.cpp | 6 ++++++ tests/auto/corelib/tools/qvector/tst_qvector.cpp | 8 +++++++- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 27868f7313..513d7eafe1 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -51,7 +51,9 @@ #include #include #include +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) #include +#endif #include #include @@ -403,10 +405,14 @@ public: static QList fromVector(const QVector &vector); static QList fromSet(const QSet &set); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) + Q_DECL_DEPRECATED_X("Use QList(list.begin(), list.end()) instead.") static inline QList fromStdList(const std::list &list) { QList tmp; std::copy(list.begin(), list.end(), std::back_inserter(tmp)); return tmp; } + Q_DECL_DEPRECATED_X("Use std::list(list.begin(), list.end()) instead.") inline std::list toStdList() const { std::list tmp; std::copy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; } +#endif private: Node *detach_helper_grow(int i, int n); diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index d6baa76a30..4e148c9c55 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -49,7 +49,9 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) #include +#endif #include #include @@ -292,10 +294,14 @@ public: static QVector fromList(const QList &list); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) + Q_DECL_DEPRECATED_X("Use QVector(vector.begin(), vector.end()) instead.") static inline QVector fromStdVector(const std::vector &vector) { QVector tmp; tmp.reserve(int(vector.size())); std::copy(vector.begin(), vector.end(), std::back_inserter(tmp)); return tmp; } + Q_DECL_DEPRECATED_X("Use std::vector(vector.begin(), vector.end()) instead.") inline std::vector toStdVector() const { return std::vector(d->begin(), d->end()); } +#endif private: // ### Qt6: remove methods, they are unused void reallocData(const int size, const int alloc, QArrayData::AllocationOptions options = QArrayData::Default); diff --git a/tests/auto/corelib/tools/qlist/tst_qlist.cpp b/tests/auto/corelib/tools/qlist/tst_qlist.cpp index 995aa245d1..7fb3e67462 100644 --- a/tests/auto/corelib/tools/qlist/tst_qlist.cpp +++ b/tests/auto/corelib/tools/qlist/tst_qlist.cpp @@ -367,9 +367,11 @@ private slots: void toSetOptimal() const; void toSetMovable() const; void toSetComplex() const; +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) void toStdListOptimal() const; void toStdListMovable() const; void toStdListComplex() const; +#endif void toVectorOptimal() const; void toVectorMovable() const; void toVectorComplex() const; @@ -427,7 +429,9 @@ private: template void takeFirst() const; template void takeLast() const; template void toSet() const; +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) template void toStdList() const; +#endif template void toVector() const; template void value() const; @@ -1633,6 +1637,7 @@ void tst_QList::toSetComplex() const QCOMPARE(liveCount, Complex::getLiveCount()); } +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) template void tst_QList::toStdList() const { @@ -1669,6 +1674,7 @@ void tst_QList::toStdListComplex() const toStdList(); QCOMPARE(liveCount, Complex::getLiveCount()); } +#endif template void tst_QList::toVector() const diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp index 172b03a445..f81ce11510 100644 --- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp +++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp @@ -257,7 +257,6 @@ private slots: void fromListInt() const; void fromListMovable() const; void fromListCustom() const; - void fromStdVector() const; void indexOf() const; void insertInt() const; void insertMovable() const; @@ -296,7 +295,10 @@ private slots: void swapMovable() const; void swapCustom() const; void toList() const; +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) + void fromStdVector() const; void toStdVector() const; +#endif void value() const; void testOperators() const; @@ -1426,6 +1428,7 @@ void tst_QVector::fromListCustom() const QCOMPARE(instancesCount, Custom::counter.loadAcquire()); } +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) void tst_QVector::fromStdVector() const { // stl = :( @@ -1439,6 +1442,7 @@ void tst_QVector::fromStdVector() const // test it converts ok QCOMPARE(myvec, QVector() << "aaa" << "bbb" << "ninjas" << "pirates"); } +#endif void tst_QVector::indexOf() const { @@ -2331,6 +2335,7 @@ void tst_QVector::toList() const QCOMPARE(myvec, QVector() << "A" << "B" << "C"); } +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) void tst_QVector::toStdVector() const { QVector myvec; @@ -2343,6 +2348,7 @@ void tst_QVector::toStdVector() const QCOMPARE(myvec, QVector() << "A" << "B" << "C"); } +#endif void tst_QVector::value() const { From 08101b2b27f7f2177993ddb62c15187c169ccd19 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 30 Apr 2019 14:13:22 +0200 Subject: [PATCH 257/292] Fix qplugin.h for Qt 6 Change-Id: I3ae6594a2982f990a5b3851a063b0b2f02d16bd9 Reviewed-by: Thiago Macieira --- src/corelib/plugin/qplugin.h | 32 +++++++++++++++---- .../qguiapplication/tst_qguiapplication.cpp | 4 +++ tests/auto/tools/moc/tst_moc.cpp | 11 +++++++ 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/corelib/plugin/qplugin.h b/src/corelib/plugin/qplugin.h index 676b5047d6..c176155c28 100644 --- a/src/corelib/plugin/qplugin.h +++ b/src/corelib/plugin/qplugin.h @@ -75,7 +75,12 @@ typedef QObject *(*QtPluginInstanceFunction)(); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) typedef const char *(*QtPluginMetaDataFunction)(); #else -typedef QPair (*QtPluginMetaDataFunction)(); +struct QPluginMetaData +{ + const uchar *data; + size_t size; +}; +typedef QPluginMetaData (*QtPluginMetaDataFunction)(); #endif @@ -84,12 +89,14 @@ struct Q_CORE_EXPORT QStaticPlugin #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) public: constexpr QStaticPlugin(QtPluginInstanceFunction i, QtPluginMetaDataFunction m) - : instance(i), rawMetaData(m().first), rawMetaDataSize(m().second) + : instance(i), rawMetaData(m().data), rawMetaDataSize(m().size) + {} QtPluginInstanceFunction instance; private: // ### Qt 6: revise, as this is not standard-layout const void *rawMetaData; - qsizetype rawMetaDataSize + qsizetype rawMetaDataSize; +public: #elif !defined(Q_QDOC) // Note: This struct is initialized using an initializer list. // As such, it cannot have any new constructors or variables. @@ -154,6 +161,16 @@ void Q_CORE_EXPORT qRegisterStaticPluginFunction(QStaticPlugin staticPlugin); #if defined(QT_STATICPLUGIN) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +# define QT_MOC_EXPORT_PLUGIN(PLUGINCLASS, PLUGINCLASSNAME) \ + static QT_PREPEND_NAMESPACE(QObject) *qt_plugin_instance_##PLUGINCLASSNAME() \ + Q_PLUGIN_INSTANCE(PLUGINCLASS) \ + static QPluginMetaData qt_plugin_query_metadata_##PLUGINCLASSNAME() \ + { return { qt_pluginMetaData, sizeof qt_pluginMetaData }; } \ + const QT_PREPEND_NAMESPACE(QStaticPlugin) qt_static_plugin_##PLUGINCLASSNAME() { \ + return { qt_plugin_instance_##PLUGINCLASSNAME, qt_plugin_query_metadata_##PLUGINCLASSNAME}; \ + } +#else # define QT_MOC_EXPORT_PLUGIN(PLUGINCLASS, PLUGINCLASSNAME) \ static QT_PREPEND_NAMESPACE(QObject) *qt_plugin_instance_##PLUGINCLASSNAME() \ Q_PLUGIN_INSTANCE(PLUGINCLASS) \ @@ -162,13 +179,15 @@ void Q_CORE_EXPORT qRegisterStaticPluginFunction(QStaticPlugin staticPlugin); QT_PREPEND_NAMESPACE(QStaticPlugin) plugin = { qt_plugin_instance_##PLUGINCLASSNAME, qt_plugin_query_metadata_##PLUGINCLASSNAME}; \ return plugin; \ } +#endif -#elif QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +#else +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) # define QT_MOC_EXPORT_PLUGIN(PLUGINCLASS, PLUGINCLASSNAME) \ Q_EXTERN_C Q_DECL_EXPORT \ - auto qt_plugin_query_metadata() \ - { return qMakePair(qt_pluginMetaData, sizeof qt_pluginMetaData); } \ + QPluginMetaData qt_plugin_query_metadata() \ + { return { qt_pluginMetaData, sizeof qt_pluginMetaData }; } \ Q_EXTERN_C Q_DECL_EXPORT QT_PREPEND_NAMESPACE(QObject) *qt_plugin_instance() \ Q_PLUGIN_INSTANCE(PLUGINCLASS) @@ -183,6 +202,7 @@ void Q_CORE_EXPORT qRegisterStaticPluginFunction(QStaticPlugin staticPlugin); #endif +#endif #define Q_EXPORT_PLUGIN(PLUGIN) \ Q_EXPORT_PLUGIN2(PLUGIN, PLUGIN) diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index a304981cd1..09fec89de4 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -989,9 +989,13 @@ void tst_QGuiApplication::genericPluginsAndWindowSystemEvents() QCoreApplication::postEvent(&testReceiver, new QEvent(QEvent::User)); QCOMPARE(testReceiver.customEvents, 0); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QStaticPlugin testPluginInfo(qt_plugin_instance, qt_plugin_query_metadata); +#else QStaticPlugin testPluginInfo; testPluginInfo.instance = qt_plugin_instance; testPluginInfo.rawMetaData = qt_plugin_query_metadata; +#endif qRegisterStaticPluginFunction(testPluginInfo); int argc = 3; char *argv[] = { const_cast(QTest::currentAppName()), const_cast("-plugin"), const_cast("testplugin") }; diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index f12df578f4..6b7aaf7c0a 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -1425,6 +1425,16 @@ void tst_Moc::environmentIncludePaths() // plugin_metadata.h contains a plugin which we register here. Since we're not building this // application as a plugin, we need top copy some of the initializer code found in qplugin.h: extern "C" QObject *qt_plugin_instance(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +extern "C" QPluginMetaData qt_plugin_query_metadata(); +class StaticPluginInstance{ +public: + StaticPluginInstance() { + QStaticPlugin plugin(qt_plugin_instance, qt_plugin_query_metadata); + qRegisterStaticPluginFunction(plugin); + } +}; +#else extern "C" const char *qt_plugin_query_metadata(); class StaticPluginInstance{ public: @@ -1433,6 +1443,7 @@ public: qRegisterStaticPluginFunction(plugin); } }; +#endif static StaticPluginInstance staticInstance; void tst_Moc::specifyMetaTagsFromCmdline() { From 298ab596a1e1fb147fde6d3c0d6c859d1e045781 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 5 May 2019 10:57:38 +0200 Subject: [PATCH 258/292] QtSql: mark QSqlite2 plugin as obsolete Mark QSqlite2 plugin as obsolete so it can be removed with Qt6. The last sqlite2 release was 2005 so it's time to remove this plugin in Qt6. [ChangeLog][QtSql][SQlite2] Marked QSQLITE2 plugin as obsolete - it will be removed with Qt6 together with the QTDS plugin Change-Id: I9861331d4eb2b13f38b9e0e09ad9472b70e9b6e2 Reviewed-by: Lars Knoll --- src/plugins/sqldrivers/sqlite2/smain.cpp | 1 + src/plugins/sqldrivers/tds/main.cpp | 1 + src/sql/doc/src/sql-driver.qdoc | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/sqldrivers/sqlite2/smain.cpp b/src/plugins/sqldrivers/sqlite2/smain.cpp index 3a5734f8c9..7d971d6e5a 100644 --- a/src/plugins/sqldrivers/sqlite2/smain.cpp +++ b/src/plugins/sqldrivers/sqlite2/smain.cpp @@ -43,6 +43,7 @@ QT_BEGIN_NAMESPACE +// ### Qt6: remove, obsolete since 5.14 class QSQLite2DriverPlugin : public QSqlDriverPlugin { Q_OBJECT diff --git a/src/plugins/sqldrivers/tds/main.cpp b/src/plugins/sqldrivers/tds/main.cpp index 4aa1444608..18efb22ea4 100644 --- a/src/plugins/sqldrivers/tds/main.cpp +++ b/src/plugins/sqldrivers/tds/main.cpp @@ -50,6 +50,7 @@ QT_BEGIN_NAMESPACE +// ### Qt6: remove, obsolete since 4.7 class QTDSDriverPlugin : public QSqlDriverPlugin { Q_OBJECT diff --git a/src/sql/doc/src/sql-driver.qdoc b/src/sql/doc/src/sql-driver.qdoc index cccce48bb3..c6ac4d17ff 100644 --- a/src/sql/doc/src/sql-driver.qdoc +++ b/src/sql/doc/src/sql-driver.qdoc @@ -54,9 +54,9 @@ \li Open Database Connectivity (ODBC) - Microsoft SQL Server and other ODBC-compliant databases \row \li \l{#QPSQL}{QPSQL} \li PostgreSQL (versions 7.3 and above) - \row \li \l{#QSQLITE2}{QSQLITE2} \li SQLite version 2 + \row \li \l{#QSQLITE2}{QSQLITE2} \li SQLite version 2 \note obsolete since Qt 5.14 \row \li \l{#QSQLITE}{QSQLITE} \li SQLite version 3 - \row \li \l{#QTDS}{QTDS} \li Sybase Adaptive Server \note obsolete from Qt 4.7 + \row \li \l{#QTDS}{QTDS} \li Sybase Adaptive Server \note obsolete since Qt 4.7 \endtable SQLite is the in-process database system with the best test coverage From a43c3b456a9b0c341b05ac7bee07b863ebca3b7c Mon Sep 17 00:00:00 2001 From: Mikhail Svetkin Date: Mon, 19 Mar 2018 11:59:11 +0100 Subject: [PATCH 259/292] rtems: add mkspecs for new operation system RTEMS Change-Id: Idd01ccd69c296df1a67a90260fc4e5547acf3079 Reviewed-by: Volker Hilsheimer Reviewed-by: Ryan Chu --- mkspecs/common/rtems-base.conf | 73 ++++++++++++++++++++++++++++ mkspecs/common/rtems/qplatformdefs.h | 70 ++++++++++++++++++++++++++ 2 files changed, 143 insertions(+) create mode 100644 mkspecs/common/rtems-base.conf create mode 100644 mkspecs/common/rtems/qplatformdefs.h diff --git a/mkspecs/common/rtems-base.conf b/mkspecs/common/rtems-base.conf new file mode 100644 index 0000000000..0a015c3173 --- /dev/null +++ b/mkspecs/common/rtems-base.conf @@ -0,0 +1,73 @@ +# +# Base qmake configuration for GCC on RTEMS +# +# +# +MAKEFILE_GENERATOR = UNIX + +QMAKE_PLATFORM = rtems + +include(unix.conf) +include(gcc-base-unix.conf) +include(g++-unix.conf) + +rtems_bsp = $$(RTEMS_BSP) +isEmpty(rtems_bsp) { + error("This qmakespec requires $RTEMS_BSP to be set") +} + +rtems_compiler = $$(RTEMS_COMPILER) +isEmpty(rtems_compiler) { + error("This qmakespec requires $RTEMS_COMPILER to be set") +} + +isEmpty(RTEMS_CPU_FLAGS) { + error("The qmakespec is expected to set \$\$RTEMS_CPU_FLAGS") +} + +RTEMS_FLAGS = \ + -B$$rtems_bsp \ + -specs bsp_specs \ + -qrtems \ + $$RTEMS_CPU_FLAGS + +QMAKE_CFLAGS_OPTIMIZE_FULL = $$QMAKE_CFLAGS_OPTIMIZE +QMAKE_CFLAGS_OPTIMIZE_DEBUG = -O0 -g + +QMAKE_CFLAGS_DEBUG = $$QMAKE_CFLAGS_OPTIMIZE_DEBUG +QMAKE_CFLAGS_WARN_ON = -Wall +QMAKE_CFLAGS_PIC = +QMAKE_CFLAGS_SHLIB = +QMAKE_CFLAGS_STATIC_LIB = +QMAKE_CFLAGS_APP = +QMAKE_CFLAGS += $$RTEMS_FLAGS + +QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG +QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON +QMAKE_CXXFLAGS_SHLIB = +QMAKE_CXXFLAGS_STATIC_LIB = +QMAKE_CXXFLAGS_APP = +QMAKE_CXXFLAGS += $$RTEMS_FLAGS + +QMAKE_CXXFLAGS_CXX11 = +QMAKE_CXXFLAGS_CXX14 = +QMAKE_CXXFLAGS_CXX1Z = + +QMAKE_LFLAGS_GCSECTIONS = -Wl,--gc-sections +QMAKE_LFLAGS += $$RTEMS_FLAGS $$QMAKE_LFLAGS_GCSECTIONS + +QMAKE_CC = $${rtems_compiler}-gcc +QMAKE_CXX = $${rtems_compiler}-g++ +QMAKE_AR = $${rtems_compiler}-ar cqs +QMAKE_OBJCOPY = $${rtems_compiler}-objcopy +QMAKE_NM = $${rtems_compiler}-nm -P +QMAKE_RANLIB = $${rtems_compiler}-ranlib +QMAKE_STRIP = $${rtems_compiler}-strip + +QMAKE_LINK_C = $$QMAKE_CC +QMAKE_LINK_C_SHLIB = + +QMAKE_LINK = $$QMAKE_CXX +QMAKE_LINK_SHLIB = + +load(qt_config) diff --git a/mkspecs/common/rtems/qplatformdefs.h b/mkspecs/common/rtems/qplatformdefs.h new file mode 100644 index 0000000000..1baa7c7d74 --- /dev/null +++ b/mkspecs/common/rtems/qplatformdefs.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company. All rights reserved. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the qmake spec of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef Q_RTEMS_PLATFORMDEFS_H +#define Q_RTEMS_PLATFORMDEFS_H + +// Get Qt defines/settings + +#include "qglobal.h" + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include "../posix/qplatformdefs.h" + + +#ifdef __STRICT_ANSI__ +#undef __STRICT_ANSI__ +#endif + +#undef QT_OPEN_LARGEFILE +#define QT_OPEN_LARGEFILE 0 + +#endif // Q_RTEMS_PLATFORMDEFS_H From 5146582b8d0bb0cde518d57c379e5b97047c6c27 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 3 May 2019 15:57:15 +0200 Subject: [PATCH 260/292] Compile-fix: add private/ prefix to qnetconmonitor_p.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Build was failing without it. Change-Id: I23a6e8a359e6208f78fa9ef571b8b27f8ecb3628 Reviewed-by: Mårten Nordheim --- src/network/access/qnetworkaccessmanager_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/access/qnetworkaccessmanager_p.h b/src/network/access/qnetworkaccessmanager_p.h index d3a3936533..dfd747a767 100644 --- a/src/network/access/qnetworkaccessmanager_p.h +++ b/src/network/access/qnetworkaccessmanager_p.h @@ -55,7 +55,7 @@ #include "qnetworkaccessmanager.h" #include "qnetworkaccesscache_p.h" #include "qnetworkaccessbackend_p.h" -#include "qnetconmonitor_p.h" +#include "private/qnetconmonitor_p.h" #include "qnetworkrequest.h" #include "qhsts_p.h" #include "private/qobject_p.h" From b922c97c9c65ce28f4ea18106f384adf1bbf605a Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Sat, 4 May 2019 08:48:41 +0200 Subject: [PATCH 261/292] TextEdit example: add indent/unindent feature It was not possible to interactively create the example text without this feature; and in general it's necessary to work with nested lists. But currently it does not deal with all possible changes of list nesting, because the API seems incomplete for that purpose. Task-number: QTBUG-75589 Change-Id: I3e29ca15a2e7c37300a0103ceb90670716472ffb Reviewed-by: Gatis Paeglis --- .../images/mac/format-indent-less.png | Bin 0 -> 1201 bytes .../images/mac/format-indent-more.png | Bin 0 -> 993 bytes .../images/win/format-indent-less.png | Bin 0 -> 1201 bytes .../images/win/format-indent-more.png | Bin 0 -> 993 bytes .../widgets/richtext/textedit/textedit.cpp | 46 ++++++++++++++++++ examples/widgets/richtext/textedit/textedit.h | 5 ++ .../widgets/richtext/textedit/textedit.qrc | 4 ++ 7 files changed, 55 insertions(+) create mode 100644 examples/widgets/richtext/textedit/images/mac/format-indent-less.png create mode 100644 examples/widgets/richtext/textedit/images/mac/format-indent-more.png create mode 100644 examples/widgets/richtext/textedit/images/win/format-indent-less.png create mode 100644 examples/widgets/richtext/textedit/images/win/format-indent-more.png diff --git a/examples/widgets/richtext/textedit/images/mac/format-indent-less.png b/examples/widgets/richtext/textedit/images/mac/format-indent-less.png new file mode 100644 index 0000000000000000000000000000000000000000..e38074e78b78b384a1f7e8ab680fdd35175c0347 GIT binary patch literal 1201 zcmV;i1Wx;jP)1#w$1 zXjCZr%@it11(#rA5Tld5kx6d)ZG*GWj8c>B%)OlRyxmtH&S{Qq=8j^0$Qz#L!}HwF zb6@xM|NpQ5eTk~_Uk<~6Je*QLsBLP_xPhcbKhxqZ8MEW&%MJdcpa~~TmmEOOBlXU% z7Oo9}wGf6Di(-mP#bO38uwX5*n1eCk`(O;H7A|9yL;`8qyrrsS2vikgz=;&Lcji|p zOGH2*>KM*k02_vsmpOdfOf)ei#RSQA zhqJ}xj!w0X-9d4>s5jJ`mjAs9q^5Cu#tkH;<7izvtCLZiZrlG>bxAVJd8BsjX`ydG z@q>^lNe9;t$$O=F7{M`yQ<;!>^wwDIdhSgZ>}ZsRvrUn%&PMsB z^I2Icm3134PJA@0uP3=wR{O)*bjR19-VlP$)v_fq=YbvbUp-3De~Iols(x~QIJSHK z9cNmrn2rp4r!J^mKX2WKNRY+7d=7>1j?3`J21&-_9GtnNZpEBcJCSTR16?OMe{`Q8 zc)8_L)3`m8A5+`^&U)DdDgd-Brs*ReyjeYo#b-D%j#oVXd}T%L%jh59(RVJ*`Sue7 z8ie%^9n^Lw=aJgIr-gjJ0Dl--qES<1xFrY*N)Um80hfEG$K|zGw%nBMC+p>2Yxwg1 z2;6xx|;Fn$p z&`Ghq7Z~s$clA8>?0ZNgPIBQg1_Q&eKZ^2|bsKw}_>_5LRUjrpe(-7$4juhgyb`lU6CD1We?oKENSZEL!nnx^I+ zH;{Qu;01}OEkdHjS~Fe|$*88=_W!dYnw!-E8xAd#i|J#XJ02bii7$Q*gg@o6r?=}z z`&zLUTsOpVB3M<72-X%3AI1nlXfa~2s)&GEh(=-Ui(9q*@XkrQ>fu^>N@0Tv*!O5D`@E2rOf~K>gut`nJvkcl&};Kd5PJ&bZ-t@3^j-3Dp9{KH#$hZ&%+| z0C}I(p#v@WL7_Z{R*4uP47H#T1Y=|*F13mn!7(b0YsY)YE%XJpKvPx1KkH literal 0 HcmV?d00001 diff --git a/examples/widgets/richtext/textedit/images/mac/format-indent-more.png b/examples/widgets/richtext/textedit/images/mac/format-indent-more.png new file mode 100644 index 0000000000000000000000000000000000000000..1bdeabd354fa5274c69cd70b281c2ee9276d5f6b GIT binary patch literal 993 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyoCO|{#S9GG!XV7ZFl&wkP>{XE z)7O>#F)Irjvt)p8j1&U{@lwp-Sh+G@Qus?`lqaVZW zV1^4(3`@NjmU%Ipj$~Ns&2ToB;aoI`3q%mc*%*dpo(w?Jz&^sjA=1zxDk!NcI2nkl zgOh83TqDP5W9OLQl$wx~n$XnRbFs`oz2||tyckY_jXD>@u)&XEZwN>PXwJq!roEvI zYXUjW#4_84Ry#%3Z;0f-n9OPBm1XXgWgAdn8wf;&&f#Uw;pHyj-E1|@BZIzvAR9Q>-Ot^x8MA`1494r zy#Igi?f?7l{@;K9@BaJ$4|>|9;l zeM7=3DyB|dw|)-<>;;1Z2M-@Tdg9d8t2b^ufBxyyw{O3G{eyw)*Kha&O=C>*c6VXu zV3qX%vh6)x978NlCnqeBSYh?+cXf63?;pQ@{rdUyCv)Rsn=YpIU9aA3`m^cFjwLr{ z9GUXu$C4>U>>{k&c$ZpEOkFxt@#RcM&XorvGZR_OG`Oa$nKQ@6cCU@iox68qV&}}A zJ7>)j$qe=ogIX2m6Yga^cdW9S3|P%(*lkL?@Z#lpfkv%>BOfL%RcUs-K1Z@O$!CYG zTEa!c?5eda+Etx?mxTvvCx%appA?WbzPn6ir|& yv^?{$NP>$=LGSoH^#fdB%He>>qavwioD3RaUB_kZ*z`V literal 0 HcmV?d00001 diff --git a/examples/widgets/richtext/textedit/images/win/format-indent-less.png b/examples/widgets/richtext/textedit/images/win/format-indent-less.png new file mode 100644 index 0000000000000000000000000000000000000000..e38074e78b78b384a1f7e8ab680fdd35175c0347 GIT binary patch literal 1201 zcmV;i1Wx;jP)1#w$1 zXjCZr%@it11(#rA5Tld5kx6d)ZG*GWj8c>B%)OlRyxmtH&S{Qq=8j^0$Qz#L!}HwF zb6@xM|NpQ5eTk~_Uk<~6Je*QLsBLP_xPhcbKhxqZ8MEW&%MJdcpa~~TmmEOOBlXU% z7Oo9}wGf6Di(-mP#bO38uwX5*n1eCk`(O;H7A|9yL;`8qyrrsS2vikgz=;&Lcji|p zOGH2*>KM*k02_vsmpOdfOf)ei#RSQA zhqJ}xj!w0X-9d4>s5jJ`mjAs9q^5Cu#tkH;<7izvtCLZiZrlG>bxAVJd8BsjX`ydG z@q>^lNe9;t$$O=F7{M`yQ<;!>^wwDIdhSgZ>}ZsRvrUn%&PMsB z^I2Icm3134PJA@0uP3=wR{O)*bjR19-VlP$)v_fq=YbvbUp-3De~Iols(x~QIJSHK z9cNmrn2rp4r!J^mKX2WKNRY+7d=7>1j?3`J21&-_9GtnNZpEBcJCSTR16?OMe{`Q8 zc)8_L)3`m8A5+`^&U)DdDgd-Brs*ReyjeYo#b-D%j#oVXd}T%L%jh59(RVJ*`Sue7 z8ie%^9n^Lw=aJgIr-gjJ0Dl--qES<1xFrY*N)Um80hfEG$K|zGw%nBMC+p>2Yxwg1 z2;6xx|;Fn$p z&`Ghq7Z~s$clA8>?0ZNgPIBQg1_Q&eKZ^2|bsKw}_>_5LRUjrpe(-7$4juhgyb`lU6CD1We?oKENSZEL!nnx^I+ zH;{Qu;01}OEkdHjS~Fe|$*88=_W!dYnw!-E8xAd#i|J#XJ02bii7$Q*gg@o6r?=}z z`&zLUTsOpVB3M<72-X%3AI1nlXfa~2s)&GEh(=-Ui(9q*@XkrQ>fu^>N@0Tv*!O5D`@E2rOf~K>gut`nJvkcl&};Kd5PJ&bZ-t@3^j-3Dp9{KH#$hZ&%+| z0C}I(p#v@WL7_Z{R*4uP47H#T1Y=|*F13mn!7(b0YsY)YE%XJpKvPx1KkH literal 0 HcmV?d00001 diff --git a/examples/widgets/richtext/textedit/images/win/format-indent-more.png b/examples/widgets/richtext/textedit/images/win/format-indent-more.png new file mode 100644 index 0000000000000000000000000000000000000000..1bdeabd354fa5274c69cd70b281c2ee9276d5f6b GIT binary patch literal 993 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyoCO|{#S9GG!XV7ZFl&wkP>{XE z)7O>#F)Irjvt)p8j1&U{@lwp-Sh+G@Qus?`lqaVZW zV1^4(3`@NjmU%Ipj$~Ns&2ToB;aoI`3q%mc*%*dpo(w?Jz&^sjA=1zxDk!NcI2nkl zgOh83TqDP5W9OLQl$wx~n$XnRbFs`oz2||tyckY_jXD>@u)&XEZwN>PXwJq!roEvI zYXUjW#4_84Ry#%3Z;0f-n9OPBm1XXgWgAdn8wf;&&f#Uw;pHyj-E1|@BZIzvAR9Q>-Ot^x8MA`1494r zy#Igi?f?7l{@;K9@BaJ$4|>|9;l zeM7=3DyB|dw|)-<>;;1Z2M-@Tdg9d8t2b^ufBxyyw{O3G{eyw)*Kha&O=C>*c6VXu zV3qX%vh6)x978NlCnqeBSYh?+cXf63?;pQ@{rdUyCv)Rsn=YpIU9aA3`m^cFjwLr{ z9GUXu$C4>U>>{k&c$ZpEOkFxt@#RcM&XorvGZR_OG`Oa$nKQ@6cCU@iox68qV&}}A zJ7>)j$qe=ogIX2m6Yga^cdW9S3|P%(*lkL?@Z#lpfkv%>BOfL%RcUs-K1Z@O$!CYG zTEa!c?5eda+Etx?mxTvvCx%appA?WbzPn6ir|& yv^?{$NP>$=LGSoH^#fdB%He>>qavwioD3RaUB_kZ*z`V literal 0 HcmV?d00001 diff --git a/examples/widgets/richtext/textedit/textedit.cpp b/examples/widgets/richtext/textedit/textedit.cpp index 683e441fce..ced77a62ce 100644 --- a/examples/widgets/richtext/textedit/textedit.cpp +++ b/examples/widgets/richtext/textedit/textedit.cpp @@ -317,6 +317,14 @@ void TextEdit::setupTextActions() actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J); actionAlignJustify->setCheckable(true); actionAlignJustify->setPriority(QAction::LowPriority); + const QIcon indentMoreIcon = QIcon::fromTheme("format-indent-more", QIcon(rsrcPath + "/format-indent-more.png")); + actionIndentMore = menu->addAction(indentMoreIcon, tr("&Indent"), this, &TextEdit::indent); + actionIndentMore->setShortcut(Qt::CTRL + Qt::Key_BracketRight); + actionIndentMore->setPriority(QAction::LowPriority); + const QIcon indentLessIcon = QIcon::fromTheme("format-indent-less", QIcon(rsrcPath + "/format-indent-less.png")); + actionIndentLess = menu->addAction(indentLessIcon, tr("&Unindent"), this, &TextEdit::unindent); + actionIndentLess->setShortcut(Qt::CTRL + Qt::Key_BracketLeft); + actionIndentLess->setPriority(QAction::LowPriority); // Make sure the alignLeft is always left of the alignRight QActionGroup *alignGroup = new QActionGroup(this); @@ -335,6 +343,10 @@ void TextEdit::setupTextActions() tb->addActions(alignGroup->actions()); menu->addActions(alignGroup->actions()); + tb->addAction(actionIndentMore); + tb->addAction(actionIndentLess); + menu->addAction(actionIndentMore); + menu->addAction(actionIndentLess); menu->addSeparator(); @@ -736,6 +748,40 @@ void TextEdit::setChecked(bool checked) textStyle(checked ? 5 : 4); } +void TextEdit::indent() +{ + modifyIndentation(1); +} + +void TextEdit::unindent() +{ + modifyIndentation(-1); +} + +void TextEdit::modifyIndentation(int amount) +{ + QTextCursor cursor = textEdit->textCursor(); + cursor.beginEditBlock(); + if (cursor.currentList()) { + QTextListFormat listFmt = cursor.currentList()->format(); + // See whether the line above is the list we want to move this item into, + // or whether we need a new list. + QTextCursor above(cursor); + above.movePosition(QTextCursor::Up); + if (above.currentList() && listFmt.indent() + amount == above.currentList()->format().indent()) { + above.currentList()->add(cursor.block()); + } else { + listFmt.setIndent(listFmt.indent() + amount); + cursor.createList(listFmt); + } + } else { + QTextBlockFormat blockFmt = cursor.blockFormat(); + blockFmt.setIndent(blockFmt.indent() + amount); + cursor.setBlockFormat(blockFmt); + } + cursor.endEditBlock(); +} + void TextEdit::currentCharFormatChanged(const QTextCharFormat &format) { fontChanged(format.font()); diff --git a/examples/widgets/richtext/textedit/textedit.h b/examples/widgets/richtext/textedit/textedit.h index c253548a4f..9e50166c6f 100644 --- a/examples/widgets/richtext/textedit/textedit.h +++ b/examples/widgets/richtext/textedit/textedit.h @@ -97,6 +97,8 @@ private slots: void textColor(); void textAlign(QAction *a); void setChecked(bool checked); + void indent(); + void unindent(); void currentCharFormatChanged(const QTextCharFormat &format); void cursorPositionChanged(); @@ -111,6 +113,7 @@ private: void setupTextActions(); bool maybeSave(); void setCurrentFileName(const QString &fileName); + void modifyIndentation(int amount); void mergeFormatOnWordOrSelection(const QTextCharFormat &format); void fontChanged(const QFont &f); @@ -126,6 +129,8 @@ private: QAction *actionAlignCenter; QAction *actionAlignRight; QAction *actionAlignJustify; + QAction *actionIndentLess; + QAction *actionIndentMore; QAction *actionToggleCheckState; QAction *actionUndo; QAction *actionRedo; diff --git a/examples/widgets/richtext/textedit/textedit.qrc b/examples/widgets/richtext/textedit/textedit.qrc index 8016a07ca0..1641acc207 100644 --- a/examples/widgets/richtext/textedit/textedit.qrc +++ b/examples/widgets/richtext/textedit/textedit.qrc @@ -13,6 +13,8 @@ images/mac/fileopen.png images/mac/fileprint.png images/mac/filesave.png + images/mac/format-indent-less.png + images/mac/format-indent-more.png images/mac/textbold.png images/mac/textcenter.png images/mac/textitalic.png @@ -34,6 +36,8 @@ images/win/fileopen.png images/win/fileprint.png images/win/filesave.png + images/win/format-indent-less.png + images/win/format-indent-more.png images/win/textbold.png images/win/textcenter.png images/win/textitalic.png From 1b8a1e04efb4ea71803edf8c122db2837fe23af9 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 6 May 2019 17:03:45 +0200 Subject: [PATCH 262/292] Fix heading level in style combobox in TextEdit example Amends 0df30ff22e50aa301791fc72f106ab15ce385a6a: when adding the checked and unchecked styles to the combobox, it changed the offsets for the heading styles; so the combobox stopped changing to the correct index when clicking on a heading, and also changed the heading two sizes smaller than it should when attempting to select a different heading level. Change-Id: Ib3f61987c786e34f32a81bf7b3ebc5ca730f40df Reviewed-by: Gatis Paeglis --- examples/widgets/richtext/textedit/textedit.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/widgets/richtext/textedit/textedit.cpp b/examples/widgets/richtext/textedit/textedit.cpp index ced77a62ce..996bb8e0a4 100644 --- a/examples/widgets/richtext/textedit/textedit.cpp +++ b/examples/widgets/richtext/textedit/textedit.cpp @@ -691,7 +691,7 @@ void TextEdit::textStyle(int styleIndex) if (style == QTextListFormat::ListStyleUndefined) { blockFmt.setObjectIndex(-1); - int headingLevel = styleIndex >= 9 ? styleIndex - 9 + 1 : 0; // H1 to H6, or Standard + int headingLevel = styleIndex >= 11 ? styleIndex - 11 + 1 : 0; // H1 to H6, or Standard blockFmt.setHeadingLevel(headingLevel); cursor.setBlockFormat(blockFmt); @@ -837,7 +837,7 @@ void TextEdit::cursorPositionChanged() } } else { int headingLevel = textEdit->textCursor().blockFormat().headingLevel(); - comboStyle->setCurrentIndex(headingLevel ? headingLevel + 8 : 0); + comboStyle->setCurrentIndex(headingLevel ? headingLevel + 10 : 0); } } From 5ced1ff9fcf85b43983bf4667c308bd1daaab379 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 2 May 2019 09:21:38 +0200 Subject: [PATCH 263/292] Fix compilation with Qt 6 Change-Id: Ie165ab2f17740a996112b7e918b595d5873674a1 Reviewed-by: Simon Hausmann --- .../qstandarditemmodel/tst_qstandarditemmodel.cpp | 10 +++++----- .../widgets/itemviews/qlistwidget/tst_qlistwidget.cpp | 4 ++-- .../itemviews/qtablewidget/tst_qtablewidget.cpp | 4 ++-- .../widgets/itemviews/qtreewidget/tst_qtreewidget.cpp | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp index 550f70890e..bc8bc38da6 100644 --- a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp +++ b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp @@ -734,7 +734,7 @@ void tst_QStandardItemModel::data() currentRoles.clear(); // bad args m_model->setData(QModelIndex(), "bla", Qt::DisplayRole); - QCOMPARE(currentRoles, {}); + QCOMPARE(currentRoles, QVector{}); QIcon icon; for (int r=0; r < m_model->rowCount(); ++r) { @@ -742,9 +742,9 @@ void tst_QStandardItemModel::data() m_model->setData(m_model->index(r,c), "initialitem", Qt::DisplayRole); QCOMPARE(currentRoles, QVector({Qt::DisplayRole, Qt::EditRole})); m_model->setData(m_model->index(r,c), "tooltip", Qt::ToolTipRole); - QCOMPARE(currentRoles, {Qt::ToolTipRole}); + QCOMPARE(currentRoles, QVector{Qt::ToolTipRole}); m_model->setData(m_model->index(r,c), icon, Qt::DecorationRole); - QCOMPARE(currentRoles, {Qt::DecorationRole}); + QCOMPARE(currentRoles, QVector{Qt::DecorationRole}); } } @@ -761,7 +761,7 @@ void tst_QStandardItemModel::clearItemData() { currentRoles.clear(); QVERIFY(!m_model->clearItemData(QModelIndex())); - QCOMPARE(currentRoles, {}); + QCOMPARE(currentRoles, QVector{}); const QModelIndex idx = m_model->index(0, 0); const QMap oldData = m_model->itemData(idx); m_model->setData(idx, QLatin1String("initialitem"), Qt::DisplayRole); @@ -773,7 +773,7 @@ void tst_QStandardItemModel::clearItemData() QCOMPARE(idx.data(Qt::ToolTipRole), QVariant()); QCOMPARE(idx.data(Qt::DisplayRole), QVariant()); QCOMPARE(idx.data(Qt::EditRole), QVariant()); - QCOMPARE(currentRoles, {}); + QCOMPARE(currentRoles, QVector{}); m_model->setItemData(idx, oldData); currentRoles.clear(); } diff --git a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp index 91088aeeca..fe2ede4183 100644 --- a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp +++ b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp @@ -1525,11 +1525,11 @@ void tst_QListWidget::itemData() item.setData(Qt::DisplayRole, QString("0")); QCOMPARE(widget.currentRoles, QVector({Qt::DisplayRole, Qt::EditRole})); item.setData(Qt::CheckStateRole, Qt::PartiallyChecked); - QCOMPARE(widget.currentRoles, {Qt::CheckStateRole}); + QCOMPARE(widget.currentRoles, QVector{Qt::CheckStateRole}); for (int i = 0; i < 4; ++i) { item.setData(Qt::UserRole + i, QString::number(i + 1)); - QCOMPARE(widget.currentRoles, {Qt::UserRole + i}); + QCOMPARE(widget.currentRoles, QVector{Qt::UserRole + i}); } QMap flags = widget.model()->itemData(widget.model()->index(0, 0)); QCOMPARE(flags.count(), 6); diff --git a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp index c2de5c2761..6184962d93 100644 --- a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp +++ b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp @@ -1383,11 +1383,11 @@ void tst_QTableWidget::itemData() item->setData(Qt::DisplayRole, QString("0")); QCOMPARE(widget.currentRoles, QVector({Qt::DisplayRole, Qt::EditRole})); item->setData(Qt::CheckStateRole, Qt::PartiallyChecked); - QCOMPARE(widget.currentRoles, {Qt::CheckStateRole}); + QCOMPARE(widget.currentRoles, QVector{Qt::CheckStateRole}); for (int i = 0; i < 4; ++i) { item->setData(Qt::UserRole + i, QString::number(i + 1)); - QCOMPARE(widget.currentRoles, {Qt::UserRole + i}); + QCOMPARE(widget.currentRoles, QVector{Qt::UserRole + i}); } QMap flags = widget.model()->itemData(widget.model()->index(0, 0)); QCOMPARE(flags.count(), 6); diff --git a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp index 33d4f3bf91..0d97974b90 100644 --- a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp +++ b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp @@ -1999,10 +1999,10 @@ void tst_QTreeWidget::itemData() item.setData(0, Qt::DisplayRole, QString("0")); QCOMPARE(widget.currentRoles, QVector({Qt::DisplayRole, Qt::EditRole})); item.setData(0, Qt::CheckStateRole, Qt::PartiallyChecked); - QCOMPARE(widget.currentRoles, {Qt::CheckStateRole}); + QCOMPARE(widget.currentRoles, QVector{Qt::CheckStateRole}); for (int i = 0; i < 4; ++i) { item.setData(0, Qt::UserRole + i, QString::number(i + 1)); - QCOMPARE(widget.currentRoles, {Qt::UserRole + i}); + QCOMPARE(widget.currentRoles, QVector{Qt::UserRole + i}); } QMap flags = widget.model()->itemData(widget.model()->index(0, 0)); QCOMPARE(flags.count(), 6); From 0b373c2e36a68aedf3731fcb3cd84fd010c2d67c Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 2 May 2019 09:23:52 +0200 Subject: [PATCH 264/292] Don't rely on functions that are deprecated Change-Id: I4150368e44b43e45f3604bf0fc7dab38a15e5ec9 Reviewed-by: Simon Hausmann --- tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp index 68664cdd2f..8d197dc616 100644 --- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp +++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp @@ -198,8 +198,8 @@ void tst_QFontDatabase::widthTwoTimes() f.setPixelSize(pixelSize); QFontMetrics fm(f); - int w1 = fm.charWidth(text, 0); - int w2 = fm.charWidth(text, 0); + int w1 = fm.horizontalAdvance(text, 0); + int w2 = fm.horizontalAdvance(text, 0); QCOMPARE(w1, w2); } From aea6ff4f57135b0f2f076e86e22cb87c0a7014fe Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 7 May 2019 01:35:04 +0200 Subject: [PATCH 265/292] Fix the generation of docs for qobject_pointer_cast QSharedPointer uses a dummy header for qdoc; the functions were implemented and documented as qdoc comments, but not added to the dummy header. Change-Id: Iec78e3566a528631557067fbeb5606916ea74f2d Reviewed-by: Martin Smith --- src/corelib/tools/qsharedpointer.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/corelib/tools/qsharedpointer.h b/src/corelib/tools/qsharedpointer.h index 98b38b97d3..80d0618402 100644 --- a/src/corelib/tools/qsharedpointer.h +++ b/src/corelib/tools/qsharedpointer.h @@ -48,6 +48,8 @@ # include #else +#include // for std::shared_ptr + QT_BEGIN_NAMESPACE @@ -167,6 +169,10 @@ template QSharedPointer qSharedPointerConstCast(const QSha template QSharedPointer qSharedPointerConstCast(const QWeakPointer &src); template QSharedPointer qSharedPointerObjectCast(const QSharedPointer &src); template QSharedPointer qSharedPointerObjectCast(const QWeakPointer &src); +template std::shared_ptr qobject_pointer_cast(const std::shared_ptr &src); +template std::shared_ptr qobject_pointer_cast(std::shared_ptr &&src); +template std::shared_ptr qSharedPointerObjectCast(const std::shared_ptr &src); +template std::shared_ptr qSharedPointerObjectCast(std::shared_ptr &&src); template QWeakPointer qWeakPointerCast(const QWeakPointer &src); From 587bdd144b7e574e57f17167808774fa9783ee78 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 13 Nov 2018 10:26:50 +0100 Subject: [PATCH 266/292] Add QUrl to bootstrap set The QML language server needs to use QUrl as that is what the language server protocol uses to specify files. As we cannot implicitly cast char to QChar in the bootstrap library, we need to apply a build fix in qipaddress.cpp. Change-Id: Ifaf8421457b1f734402b5aad965ecdec764a73e8 Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qipaddress.cpp | 2 +- src/tools/bootstrap/bootstrap.pro | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qipaddress.cpp b/src/corelib/io/qipaddress.cpp index 039e291b43..d9f7916dd4 100644 --- a/src/corelib/io/qipaddress.cpp +++ b/src/corelib/io/qipaddress.cpp @@ -253,7 +253,7 @@ const QChar *parseIp6(IPv6Address &address, const QChar *begin, const QChar *end static inline QChar toHex(uchar c) { - return QtMiscUtils::toHexLower(c); + return QChar::fromLatin1(QtMiscUtils::toHexLower(c)); } void toString(QString &appendTo, IPv6Address address) diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro index 1662e99674..708211279c 100644 --- a/src/tools/bootstrap/bootstrap.pro +++ b/src/tools/bootstrap/bootstrap.pro @@ -42,6 +42,7 @@ SOURCES += \ ../../corelib/io/qfsfileengine.cpp \ ../../corelib/io/qfsfileengine_iterator.cpp \ ../../corelib/io/qiodevice.cpp \ + ../../corelib/io/qipaddress.cpp \ ../../corelib/io/qfiledevice.cpp \ ../../corelib/io/qresource.cpp \ ../../corelib/io/qtemporarydir.cpp \ @@ -50,6 +51,9 @@ SOURCES += \ ../../corelib/io/qstandardpaths.cpp \ ../../corelib/io/qloggingcategory.cpp \ ../../corelib/io/qloggingregistry.cpp \ + ../../corelib/io/qurl.cpp \ + ../../corelib/io/qurlidna.cpp \ + ../../corelib/io/qurlrecode.cpp \ ../../corelib/kernel/qcoreapplication.cpp \ ../../corelib/kernel/qcoreglobaldata.cpp \ ../../corelib/kernel/qmetatype.cpp \ From d510e1e7f919e01a3b875ff5a575b818e5ee03e8 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 10 Oct 2018 08:51:04 +0200 Subject: [PATCH 267/292] Add swapItemsAt() to QVector This closes one compatibility gap with QList, to make it easier to replace QList with QVector in Qt6. Change-Id: I5655bc4cd2150a6f09a1ed68c0742f3b42ca47e4 Reviewed-by: Simon Hausmann --- src/corelib/tools/qvector.h | 7 +++++++ src/corelib/tools/qvector.qdoc | 10 ++++++++++ .../corelib/tools/qvector/tst_qvector.cpp | 19 +++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 4e148c9c55..b763d6e7e2 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -251,6 +251,13 @@ public: T value(int i) const; T value(int i, const T &defaultValue) const; + void swapItemsAt(int i, int j) { + Q_ASSERT_X(i >= 0 && i < size() && j >= 0 && j < size(), + "QVector::swap", "index out of range"); + detach(); + qSwap(d->begin()[i], d->begin()[j]); + } + // STL compatibility typedef T value_type; typedef value_type* pointer; diff --git a/src/corelib/tools/qvector.qdoc b/src/corelib/tools/qvector.qdoc index cb47d36356..c1b5054f93 100644 --- a/src/corelib/tools/qvector.qdoc +++ b/src/corelib/tools/qvector.qdoc @@ -288,6 +288,16 @@ never fails. */ +/*! \fn template void QVector::swapItemsAt(int i, int j) + \since 5.14 + + Exchange the item at index position \a i with the item at index + position \a j. This function assumes that both \a i and \a j are + at least 0 but less than size(). To avoid failure, test that both + \a i and \a j are at least 0 and less than size(). +*/ + + /*! \fn template bool QVector::operator==(const QVector &other) const Returns \c true if \a other is equal to this vector; otherwise diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp index f81ce11510..11c255b184 100644 --- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp +++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp @@ -331,6 +331,8 @@ private slots: void insertMove() const; + void swapItemsAt() const; + private: template void copyConstructor() const; template void add() const; @@ -2990,5 +2992,22 @@ void tst_QVector::insertMove() const QCOMPARE(Movable::counter.loadAcquire(), instancesCount); } +void tst_QVector::swapItemsAt() const +{ + QVector v; + v << 0 << 1 << 2 << 3; + + v.swapItemsAt(0, 2); + QCOMPARE(v.at(0), 2); + QCOMPARE(v.at(2), 0); + + auto copy = v; + copy.swapItemsAt(0, 2); + QCOMPARE(v.at(0), 2); + QCOMPARE(v.at(2), 0); + QCOMPARE(copy.at(0), 0); + QCOMPARE(copy.at(2), 2); +} + QTEST_MAIN(tst_QVector) #include "tst_qvector.moc" From 92f984273262531f909ede17a324f546fe502b5c Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 6 May 2019 14:00:53 +0200 Subject: [PATCH 268/292] Deprecate conversion functions between QList and QSet Users should use range constructors instead to do the conversion. Keep conversion methods between QList and QVector as these will turn into a no-op in Qt 6, whereas forcing people to use range constructors would lead to deep copies of the data. Change-Id: Id9fc9e4d007044e019826da523e8418857c91283 Reviewed-by: Simon Hausmann --- examples/opengl/contextinfo/widget.cpp | 2 +- .../painting/pathstroke/pathstroke.cpp | 3 +- .../widgets/painting/shared/hoverpoints.cpp | 3 +- qmake/generators/makefile.cpp | 3 +- qmake/generators/win32/msvc_nmake.cpp | 2 +- src/corelib/statemachine/qstatemachine.cpp | 13 ++++--- src/corelib/tools/qlist.h | 10 +++-- src/corelib/tools/qset.h | 13 +++++-- src/corelib/tools/qvector.h | 3 +- src/gui/opengl/qopengl.cpp | 2 +- src/gui/text/qtextodfwriter.cpp | 2 +- .../ssl/qsslsocket_openssl_symbols.cpp | 2 +- src/tools/uic/cpp/cppwriteinitialization.cpp | 2 +- .../graphicsview/qgraphicsanchorlayout_p.cpp | 2 +- src/widgets/graphicsview/qgraphicsscene.cpp | 10 ++--- src/widgets/graphicsview/qsimplex_p.cpp | 2 +- src/widgets/itemviews/qtableview.cpp | 4 +- src/widgets/kernel/qapplication.cpp | 2 +- src/widgets/kernel/qgesturemanager.cpp | 2 +- .../tools/collections/tst_collections.cpp | 37 +++++++++++++++++-- tests/auto/corelib/tools/qlist/tst_qlist.cpp | 6 +-- .../gui/qopenglconfig/tst_qopenglconfig.cpp | 6 +-- .../kernel/qapplication/tst_qapplication.cpp | 8 +++- .../tst_qabstractscrollarea.cpp | 10 ++++- 24 files changed, 99 insertions(+), 50 deletions(-) diff --git a/examples/opengl/contextinfo/widget.cpp b/examples/opengl/contextinfo/widget.cpp index b1b7076503..0762c91662 100644 --- a/examples/opengl/contextinfo/widget.cpp +++ b/examples/opengl/contextinfo/widget.cpp @@ -384,7 +384,7 @@ void Widget::renderWindowReady() m_output->append(tr("Qt OpenGL library handle: %1") .arg(QString::number(qintptr(QOpenGLContext::openGLModuleHandle()), 16))); - QList extensionList = context->extensions().toList(); + QList extensionList = context->extensions().values(); std::sort(extensionList.begin(), extensionList.end()); m_extensions->append(tr("Found %1 extensions:").arg(extensionList.count())); for (const QByteArray &ext : qAsConst(extensionList)) diff --git a/examples/widgets/painting/pathstroke/pathstroke.cpp b/examples/widgets/painting/pathstroke/pathstroke.cpp index 03e55bb2a2..e4009f0b1a 100644 --- a/examples/widgets/painting/pathstroke/pathstroke.cpp +++ b/examples/widgets/painting/pathstroke/pathstroke.cpp @@ -611,7 +611,8 @@ bool PathStrokeRenderer::event(QEvent *e) case Qt::TouchPointPressed: { // find the point, move it - QSet activePoints = QSet::fromList(m_fingerPointMapping.values()); + const auto mappedPoints = m_fingerPointMapping.values(); + QSet activePoints = QSet(mappedPoints.begin(), mappedPoints.end()); int activePoint = -1; qreal distance = -1; const int pointsCount = m_points.size(); diff --git a/examples/widgets/painting/shared/hoverpoints.cpp b/examples/widgets/painting/shared/hoverpoints.cpp index 74c78088ad..2032fb5a2c 100644 --- a/examples/widgets/painting/shared/hoverpoints.cpp +++ b/examples/widgets/painting/shared/hoverpoints.cpp @@ -180,7 +180,8 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event) case Qt::TouchPointPressed: { // find the point, move it - QSet activePoints = QSet::fromList(m_fingerPointMapping.values()); + const auto mappedPoints = m_fingerPointMapping.values(); + QSet activePoints = QSet(mappedPoints.begin(), mappedPoints.end()); int activePoint = -1; qreal distance = -1; const int pointsCount = m_points.size(); diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index aae5a44e21..1a7a7a4322 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -2696,7 +2696,8 @@ MakefileGenerator::writeSubTargets(QTextStream &t, QList recurse; const ProKey rkey(*qut_it + ".recurse"); if (project->isSet(rkey)) { - recurse = project->values(rkey).toQStringList().toSet(); + const QStringList values = project->values(rkey).toQStringList(); + recurse = QSet(values.begin(), values.end()); } else { for(int target = 0; target < targets.size(); ++target) recurse.insert(targets.at(target)->name); diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index 9c2e789932..f48eea9202 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -346,7 +346,7 @@ void NmakeMakefileGenerator::writeImplicitRulesPart(QTextStream &t) QHash fileNames; bool duplicatesFound = false; const QStringList sourceFilesFilter = sourceFilesForImplicitRulesFilter(); - QStringList fixifiedSourceDirs = fileFixify(source_directories.toList(), FileFixifyAbsolute); + QStringList fixifiedSourceDirs = fileFixify(QList(source_directories.constBegin(), source_directories.constEnd()), FileFixifyAbsolute); fixifiedSourceDirs.removeDuplicates(); for (const QString &sourceDir : qAsConst(fixifiedSourceDirs)) { QDirIterator dit(sourceDir, sourceFilesFilter, QDir::Files | QDir::NoDotAndDotDot); diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index ee3f7be279..be48dbc92f 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -370,10 +370,11 @@ static QList getEffectiveTargetStates(QAbstractTransition *tra QList historyConfiguration = QHistoryStatePrivate::get(historyState)->configuration; if (!historyConfiguration.isEmpty()) { // There is a saved history, so apply that. - targets.unite(historyConfiguration.toSet()); + targets.unite(QSet(historyConfiguration.constBegin(), historyConfiguration.constEnd())); } else if (QAbstractTransition *defaultTransition = historyState->defaultTransition()) { // No saved history, take all default transition targets. - targets.unite(defaultTransition->targetStates().toSet()); + const auto &targetStates = defaultTransition->targetStates(); + targets.unite(QSet(targetStates.constBegin(), targetStates.constEnd())); } else { // Woops, we found a history state without a default state. That's not valid! QStateMachinePrivate *m = QStateMachinePrivate::get(historyState->machine()); @@ -384,7 +385,7 @@ static QList getEffectiveTargetStates(QAbstractTransition *tra } } - targetsList = targets.toList(); + targetsList = targets.values(); cache->insert(transition, targetsList); return targetsList; } @@ -740,7 +741,7 @@ QList QStateMachinePrivate::computeExitSet(const QList statesToExit_sorted = computeExitSet_Unordered(enabledTransitions, cache).toList(); + QList statesToExit_sorted = computeExitSet_Unordered(enabledTransitions, cache).values(); std::sort(statesToExit_sorted.begin(), statesToExit_sorted.end(), stateExitLessThan); return statesToExit_sorted; } @@ -777,7 +778,7 @@ QSet QStateMachinePrivate::computeExitSet_Unordered(QAbstractTr // makes the state machine invalid. if (error == QStateMachine::NoError) setError(QStateMachine::NoCommonAncestorForTransitionError, t->sourceState()); - QList lst = pendingErrorStates.toList(); + QList lst = pendingErrorStates.values(); lst.prepend(t->sourceState()); domain = findLCCA(lst); @@ -879,7 +880,7 @@ QList QStateMachinePrivate::computeEntrySet(const QList statesToEnter_sorted = statesToEnter.toList(); + QList statesToEnter_sorted = statesToEnter.values(); std::sort(statesToEnter_sorted.begin(), statesToEnter_sorted.end(), stateEntryLessThan); return statesToEnter_sorted; } diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 25380d45ec..04c1f12f5f 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -403,13 +403,15 @@ public: inline QList &operator<<(const QList &l) { *this += l; return *this; } - QVector toVector() const; - QSet toSet() const; - static QList fromVector(const QVector &vector); - static QList fromSet(const QSet &set); + QVector toVector() const; #if QT_VERSION < QT_VERSION_CHECK(6,0,0) + Q_DECL_DEPRECATED_X("Use QList(set.begin(), set.end()) instead.") + static QList fromSet(const QSet &set); + Q_DECL_DEPRECATED_X("Use QSet(list.begin(), list.end()) instead.") + QSet toSet() const; + Q_DECL_DEPRECATED_X("Use QList(list.begin(), list.end()) instead.") static inline QList fromStdList(const std::list &list) { QList tmp; std::copy(list.begin(), list.end(), std::back_inserter(tmp)); return tmp; } diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h index 8b31de71a9..83e574bf1c 100644 --- a/src/corelib/tools/qset.h +++ b/src/corelib/tools/qset.h @@ -245,10 +245,13 @@ public: inline QSet operator-(const QSet &other) const { QSet result = *this; result -= other; return result; } - QList toList() const; - inline QList values() const { return toList(); } - + QList values() const; +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) + Q_DECL_DEPRECATED_X("Use values() instead.") + QList toList() const { return values(); } + Q_DECL_DEPRECATED_X("Use QSet(list.begin(), list.end()) instead.") static QSet fromList(const QList &list); +#endif private: Hash q_hash; @@ -368,7 +371,7 @@ Q_INLINE_TEMPLATE bool QSet::contains(const QSet &other) const } template -Q_OUTOFLINE_TEMPLATE QList QSet::toList() const +Q_OUTOFLINE_TEMPLATE QList QSet::values() const { QList result; result.reserve(size()); @@ -380,6 +383,7 @@ Q_OUTOFLINE_TEMPLATE QList QSet::toList() const return result; } +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) template Q_OUTOFLINE_TEMPLATE QSet QList::toSet() const { @@ -401,6 +405,7 @@ QList QList::fromSet(const QSet &set) { return set.toList(); } +#endif Q_DECLARE_SEQUENTIAL_ITERATOR(Set) diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index b763d6e7e2..492afeac75 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -297,9 +297,8 @@ public: inline QVector &operator<<(T &&t) { append(std::move(t)); return *this; } - QList toList() const; - static QVector fromList(const QList &list); + QList toList() const; #if QT_VERSION < QT_VERSION_CHECK(6,0,0) Q_DECL_DEPRECATED_X("Use QVector(vector.begin(), vector.end()) instead.") diff --git a/src/gui/opengl/qopengl.cpp b/src/gui/opengl/qopengl.cpp index 6b701fe52b..667d16317f 100644 --- a/src/gui/opengl/qopengl.cpp +++ b/src/gui/opengl/qopengl.cpp @@ -80,7 +80,7 @@ QOpenGLExtensionMatcher::QOpenGLExtensionMatcher() if (extensionStr) { QByteArray ba(extensionStr); QList extensions = ba.split(' '); - m_extensions = extensions.toSet(); + m_extensions = QSet(extensions.constBegin(), extensions.constEnd()); } else { #ifdef QT_OPENGL_3 // clear error state diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp index a62e7e425a..8eaad403d0 100644 --- a/src/gui/text/qtextodfwriter.cpp +++ b/src/gui/text/qtextodfwriter.cpp @@ -1007,7 +1007,7 @@ bool QTextOdfWriter::writeAll() // add objects for lists, frames and tables const QVector allFormats = m_document->allFormats(); - const QList copy = formats.toList(); + const QList copy = formats.values(); for (auto index : copy) { QTextObject *object = m_document->objectForFormat(allFormats[index]); if (object) { diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp index e04d45c10c..6f935a02e4 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols.cpp +++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp @@ -693,7 +693,7 @@ static QStringList libraryPathList() // discover paths of already loaded libraries QSet loadedPaths; dl_iterate_phdr(dlIterateCallback, &loadedPaths); - paths.append(loadedPaths.toList()); + paths.append(loadedPaths.values()); #endif return paths; diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index a1ff26ba04..2510fd0edc 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -2607,7 +2607,7 @@ static void generateMultiDirectiveBegin(QTextStream &outputStream, const QSet getVariables(const QList &constraints) for (auto it = c->variables.cbegin(), end = c->variables.cend(); it != end; ++it) variableSet.insert(static_cast(it.key())); } - return variableSet.toList(); + return variableSet.values(); } /*! diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index 3897823e98..e5bd65d61e 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -6352,7 +6352,7 @@ void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event) << "delivering override to" << item.data() << gestures; // send gesture override - QGestureEvent ev(gestures.toList()); + QGestureEvent ev(gestures.values()); ev.t = QEvent::GestureOverride; ev.setWidget(event->widget()); // mark event and individual gestures as ignored @@ -6442,7 +6442,7 @@ void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event) DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:" << "delivering to" << receiver.data() << gestures; - QGestureEvent ev(gestures.toList()); + QGestureEvent ev(gestures.values()); ev.setWidget(event->widget()); sendEvent(receiver.data(), &ev); QSet ignoredGestures; @@ -6473,7 +6473,7 @@ void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event) // look for new potential targets for gestures that were ignored // and should be propagated. - QSet targetsSet = cachedTargetItems.toSet(); + QSet targetsSet(cachedTargetItems.constBegin(), cachedTargetItems.constEnd()); if (receiver) { // first if the gesture should be propagated to parents only @@ -6505,7 +6505,7 @@ void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event) gestureTargetsAtHotSpots(ignoredGestures, Qt::ReceivePartialGestures, &cachedItemGestures, &targetsSet, 0, 0); - cachedTargetItems = targetsSet.toList(); + cachedTargetItems = targetsSet.values(); std::sort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst); DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:" << "new targets:" << cachedTargetItems; @@ -6583,7 +6583,7 @@ void QGraphicsScenePrivate::cancelGesturesForChildren(QGesture *original) } Q_ASSERT(target); - const QList list = gestures.toList(); + const QList list = gestures.values(); QGestureEvent ev(list); sendEvent(target, &ev); diff --git a/src/widgets/graphicsview/qsimplex_p.cpp b/src/widgets/graphicsview/qsimplex_p.cpp index e6ffa856f1..e18f1fa4c4 100644 --- a/src/widgets/graphicsview/qsimplex_p.cpp +++ b/src/widgets/graphicsview/qsimplex_p.cpp @@ -164,7 +164,7 @@ bool QSimplex::setConstraints(const QList &newConstraints) for (auto it = v.cbegin(), end = v.cend(); it != end; ++it) variablesSet.insert(it.key()); } - variables = variablesSet.toList(); + variables = variablesSet.values(); // Set Variables reverse mapping // We also need to be able to find the index for a given variable, to do that diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index 9e9aa63b53..0e03ff2a97 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -191,7 +191,7 @@ QList QSpanCollection::spansInRect(int x, int y, int w, break; --it_y; } - return list.toList(); + return list.values(); } #undef DEBUG_SPAN_UPDATE @@ -875,7 +875,7 @@ void QTableViewPrivate::drawAndClipSpans(const QRegion &area, QPainter *painter, for(int y = firstVisualRow; y <= lastVisualRow; y++) set.insert(spans.spanAt(x,y)); set.remove(0); - visibleSpans = set.toList(); + visibleSpans = set.values(); } for (QSpanCollection::Span *span : qAsConst(visibleSpans)) { diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index c1c4014c6b..ca48a9e145 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1721,7 +1721,7 @@ QWidgetList QApplication::topLevelWidgets() QWidgetList QApplication::allWidgets() { if (QWidgetPrivate::allWidgets) - return QWidgetPrivate::allWidgets->toList(); + return QWidgetPrivate::allWidgets->values(); return QWidgetList(); } diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp index cd27c9c5be..390602205c 100644 --- a/src/widgets/kernel/qgesturemanager.cpp +++ b/src/widgets/kernel/qgesturemanager.cpp @@ -171,7 +171,7 @@ void QGestureManager::cleanupCachedGestures(QObject *target, Qt::GestureType typ while (iter != m_objectGestures.end()) { ObjectGesture objectGesture = iter.key(); if (objectGesture.gesture == type && target == objectGesture.object) { - QSet gestures = iter.value().toSet(); + QSet gestures = QSet(iter.value().constBegin(), iter.value().constEnd()); for (QHash >::iterator it = m_obsoleteGestures.begin(), e = m_obsoleteGestures.end(); it != e; ++it) { it.value() -= gestures; diff --git a/tests/auto/corelib/tools/collections/tst_collections.cpp b/tests/auto/corelib/tools/collections/tst_collections.cpp index 9bd90d21cd..734b018b39 100644 --- a/tests/auto/corelib/tools/collections/tst_collections.cpp +++ b/tests/auto/corelib/tools/collections/tst_collections.cpp @@ -2531,14 +2531,18 @@ void tst_Collections::conversions() QCOMPARE(list2.size(), 4); QVERIFY(list2 == (QList() << STUFF)); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) QSet set1 = list1.toSet(); +#else + QSet set1(list1.begin(), list1.end()); +#endif QCOMPARE(set1.size(), 3); QVERIFY(set1.contains("A")); QVERIFY(set1.contains("B")); QVERIFY(set1.contains("C")); QVERIFY(!set1.contains("D")); - QList list3 = set1.toList(); + QList list3 = set1.values(); QCOMPARE(list3.size(), 3); QVERIFY(list3.contains("A")); QVERIFY(list3.contains("B")); @@ -2546,9 +2550,11 @@ void tst_Collections::conversions() QVERIFY(!list3.contains("D")); QVERIFY(QList().toVector().isEmpty()); - QVERIFY(QList().toSet().isEmpty()); QVERIFY(QVector().toList().isEmpty()); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) + QVERIFY(QList().toSet().isEmpty()); QVERIFY(QSet().toList().isEmpty()); +#endif } { @@ -2563,14 +2569,22 @@ void tst_Collections::conversions() QCOMPARE(list2.size(), 4); QVERIFY(list2 == (QList() << STUFF)); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) QSet set1 = QSet::fromList(list1); +#else + QSet set1(list1.begin(), list1.end()); +#endif QCOMPARE(set1.size(), 3); QVERIFY(set1.contains("A")); QVERIFY(set1.contains("B")); QVERIFY(set1.contains("C")); QVERIFY(!set1.contains("D")); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) QList list3 = QList::fromSet(set1); +#else + QList list3 = set1.values(); +#endif QCOMPARE(list3.size(), 3); QVERIFY(list3.contains("A")); QVERIFY(list3.contains("B")); @@ -2578,9 +2592,11 @@ void tst_Collections::conversions() QVERIFY(!list3.contains("D")); QVERIFY(QVector::fromList(QList()).isEmpty()); - QVERIFY(QSet::fromList(QList()).isEmpty()); QVERIFY(QList::fromVector(QVector()).isEmpty()); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) + QVERIFY(QSet::fromList(QList()).isEmpty()); QVERIFY(QList::fromSet(QSet()).isEmpty()); +#endif } #undef STUFF } @@ -2776,15 +2792,21 @@ void tst_Collections::vector_stl() for (int i = 0; i < elements.count(); ++i) vector << elements.at(i); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) std::vector stdVector = vector.toStdVector(); - +#else + std::vector stdVector(vector.begin(), vector.end()); +#endif QCOMPARE(int(stdVector.size()), elements.size()); std::vector::const_iterator it = stdVector.begin(); for (uint j = 0; j < stdVector.size() && it != stdVector.end(); ++j, ++it) QCOMPARE(*it, vector[j]); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) QCOMPARE(QVector::fromStdVector(stdVector), vector); +#endif + QCOMPARE(QVector(stdVector.begin(), stdVector.end()), vector); } void tst_Collections::linkedlist_stl_data() @@ -2830,7 +2852,11 @@ void tst_Collections::list_stl() for (int i = 0; i < elements.count(); ++i) list << elements.at(i); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) std::list stdList = list.toStdList(); +#else + std::list stdList(list.begin(), list.end()); +#endif QCOMPARE(int(stdList.size()), elements.size()); @@ -2838,7 +2864,10 @@ void tst_Collections::list_stl() for (uint j = 0; j < stdList.size() && it != stdList.end(); ++j, ++it) QCOMPARE(*it, list[j]); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) QCOMPARE(QList::fromStdList(stdList), list); +#endif + QCOMPARE(QList(stdList.begin(), stdList.end()), list); } template diff --git a/tests/auto/corelib/tools/qlist/tst_qlist.cpp b/tests/auto/corelib/tools/qlist/tst_qlist.cpp index 7fb3e67462..5a485e88d2 100644 --- a/tests/auto/corelib/tools/qlist/tst_qlist.cpp +++ b/tests/auto/corelib/tools/qlist/tst_qlist.cpp @@ -364,10 +364,10 @@ private slots: void takeLastOptimal() const; void takeLastMovable() const; void takeLastComplex() const; +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) void toSetOptimal() const; void toSetMovable() const; void toSetComplex() const; -#if QT_VERSION < QT_VERSION_CHECK(6,0,0) void toStdListOptimal() const; void toStdListMovable() const; void toStdListComplex() const; @@ -428,8 +428,8 @@ private: template void takeAt() const; template void takeFirst() const; template void takeLast() const; - template void toSet() const; #if QT_VERSION < QT_VERSION_CHECK(6,0,0) + template void toSet() const; template void toStdList() const; #endif template void toVector() const; @@ -1599,6 +1599,7 @@ void tst_QList::takeLastComplex() const QCOMPARE(liveCount, Complex::getLiveCount()); } +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) template void tst_QList::toSet() const { @@ -1637,7 +1638,6 @@ void tst_QList::toSetComplex() const QCOMPARE(liveCount, Complex::getLiveCount()); } -#if QT_VERSION < QT_VERSION_CHECK(6,0,0) template void tst_QList::toStdList() const { diff --git a/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp b/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp index f8dfdbd3b0..b82b277781 100644 --- a/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp +++ b/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp @@ -200,7 +200,7 @@ static void dumpGlConfiguration(QOpenGLContext &context, QTextStream &str) << "\nShading language : " << reinterpret_cast(functions.glGetString(GL_SHADING_LANGUAGE_VERSION)) << "\nFormat : " << context.format(); - QList extensionList = context.extensions().toList(); + QList extensionList = context.extensions().values(); std::sort(extensionList.begin(), extensionList.end()); const int extensionCount = extensionList.size(); str << "\n\nFound " << extensionCount << " extensions:\n"; @@ -233,9 +233,9 @@ void tst_QOpenGlConfig::testGlConfiguration() static inline QByteArray msgSetMismatch(const QSet &expected, const QSet &actual) { - const QString result = QStringList(expected.toList()).join(QLatin1Char(',')) + const QString result = QStringList(expected.values()).join(QLatin1Char(',')) + QLatin1String(" != ") - + QStringList(actual.toList()).join(QLatin1Char(',')); + + QStringList(actual.values()).join(QLatin1Char(',')); return result.toLatin1(); } diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index e57ac77c39..af70b653ee 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -908,7 +908,9 @@ void tst_QApplication::libraryPaths() QStringList actual = QApplication::libraryPaths(); actual.sort(); - QStringList expected = QSet::fromList((QStringList() << testDir << appDirPath)).toList(); + QStringList expected; + expected << testDir << appDirPath; + expected = QSet(expected.constBegin(), expected.constEnd()).values(); expected.sort(); QVERIFY2(isPathListIncluded(actual, expected), @@ -925,7 +927,9 @@ void tst_QApplication::libraryPaths() QStringList actual = QApplication::libraryPaths(); actual.sort(); - QStringList expected = QSet::fromList((QStringList() << installPathPlugins << appDirPath)).toList(); + QStringList expected; + expected << installPathPlugins << appDirPath; + expected = QSet(expected.constBegin(), expected.constEnd()).values(); expected.sort(); #ifdef Q_OS_WINRT diff --git a/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp b/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp index 007825d39c..a17a9f6c33 100644 --- a/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp +++ b/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp @@ -124,13 +124,19 @@ void tst_QAbstractScrollArea::scrollBarWidgets() QCOMPARE(area.scrollBarWidgets(Qt::AlignTop), QWidgetList()); QCOMPARE(area.scrollBarWidgets(Qt::AlignBottom), w2List); + auto sort = [](const QWidgetList l) { + QWidgetList list = l; + std::sort(list.begin(), list.end()); + return list; + }; + // two widgets at Bottom. area.addScrollBarWidget(w3, Qt::AlignBottom); - QCOMPARE(area.scrollBarWidgets(all).toSet(), allList.toSet()); + QCOMPARE(sort(area.scrollBarWidgets(all)), sort(allList)); QCOMPARE(area.scrollBarWidgets(Qt::AlignLeft), w1List); QCOMPARE(area.scrollBarWidgets(Qt::AlignRight), QWidgetList()); QCOMPARE(area.scrollBarWidgets(Qt::AlignTop), QWidgetList()); - QCOMPARE(area.scrollBarWidgets(Qt::AlignBottom).toSet(), (w2List + w3List).toSet()); + QCOMPARE(sort(area.scrollBarWidgets(Qt::AlignBottom)), sort(w2List + w3List)); //delete delete w1; From 06b8644953fc526707b5fe24c8ef08f4829ba1c6 Mon Sep 17 00:00:00 2001 From: Dmitry Kazakov Date: Thu, 6 Dec 2018 16:16:27 +0300 Subject: [PATCH 269/292] Fix notification of QDockWidget when it gets undocked Before the patch the notification was emitted only when the docker was attached to the panel or changed a position on it. It looks like the old behavior was documented in a unittest, so this patch might actually be a "behavior change". Change-Id: Id3ffbd2018a8e68844d174328dd1c4ceb7fa01d3 Reviewed-by: Richard Moe Gustavsen --- src/widgets/widgets/qdockwidget.cpp | 2 ++ tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index 4041c730b8..f98e0e44db 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -1182,6 +1182,8 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect QMainWindowLayout *mwlayout = qt_mainwindow_layout_from_dock(q); if (mwlayout) emit q->dockLocationChanged(mwlayout->dockWidgetArea(q)); + } else { + emit q->dockLocationChanged(Qt::NoDockWidgetArea); } } diff --git a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp index f8ce6a2c0a..625116654d 100644 --- a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp +++ b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp @@ -670,7 +670,11 @@ void tst_QDockWidget::dockLocationChanged() spy.clear(); dw.setFloating(true); - QTest::qWait(100); + QTRY_COMPARE(spy.count(), 1); + QCOMPARE(qvariant_cast(spy.at(0).at(0)), + Qt::NoDockWidgetArea); + spy.clear(); + dw.setFloating(false); QTRY_COMPARE(spy.count(), 1); QCOMPARE(qvariant_cast(spy.at(0).at(0)), From 2841d5bf64d6228cdb5e42cdd1d4e2e8035217fa Mon Sep 17 00:00:00 2001 From: Dmitry Kazakov Date: Tue, 4 Dec 2018 20:11:34 +0300 Subject: [PATCH 270/292] Return QScreen's HMONITOR handle via QPlatformNativeInterface It is needed to be able to fetch extra information about the display via DXGI interface. Change-Id: Id83982eb07ade157719e430d0abcc2613409a343 Reviewed-by: Friedemann Kleint --- .../windows/qwindowsnativeinterface.cpp | 16 ++++++++++++++++ .../platforms/windows/qwindowsnativeinterface.h | 1 + src/plugins/platforms/windows/qwindowsscreen.cpp | 5 +++++ src/plugins/platforms/windows/qwindowsscreen.h | 2 ++ 4 files changed, 24 insertions(+) diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp index b8ab7f8779..e581b30ced 100644 --- a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp +++ b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp @@ -40,6 +40,7 @@ #include "qwindowsnativeinterface.h" #include "qwindowsclipboard.h" #include "qwindowswindow.h" +#include "qwindowsscreen.h" #include "qwindowscontext.h" #include "qwindowscursor.h" #include "qwindowsopenglcontext.h" @@ -124,6 +125,21 @@ void *QWindowsNativeInterface::nativeResourceForWindow(const QByteArray &resourc return nullptr; } +void *QWindowsNativeInterface::nativeResourceForScreen(const QByteArray &resource, QScreen *screen) +{ + if (!screen || !screen->handle()) { + qWarning("%s: '%s' requested for null screen or screen without handle.", __FUNCTION__, resource.constData()); + return nullptr; + } + QWindowsScreen *bs = static_cast(screen->handle()); + int type = resourceType(resource); + if (type == HandleType) + return bs->handle(); + + qWarning("%s: Invalid key '%s' requested.", __FUNCTION__, resource.constData()); + return nullptr; +} + #ifndef QT_NO_CURSOR void *QWindowsNativeInterface::nativeResourceForCursor(const QByteArray &resource, const QCursor &cursor) { diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.h b/src/plugins/platforms/windows/qwindowsnativeinterface.h index e6f8aae8fb..ce395dc5a4 100644 --- a/src/plugins/platforms/windows/qwindowsnativeinterface.h +++ b/src/plugins/platforms/windows/qwindowsnativeinterface.h @@ -74,6 +74,7 @@ public: void *nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) override; #endif void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) override; + void *nativeResourceForScreen(const QByteArray &resource, QScreen *screen) override; #ifndef QT_NO_CURSOR void *nativeResourceForCursor(const QByteArray &resource, const QCursor &cursor) override; #endif diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index 0520f88935..b70b0bbe31 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -321,6 +321,11 @@ void QWindowsScreen::handleChanges(const QWindowsScreenData &newData) } } +HMONITOR QWindowsScreen::handle() const +{ + return m_data.hMonitor; +} + QRect QWindowsScreen::virtualGeometry(const QPlatformScreen *screen) // cf QScreen::virtualGeometry() { QRect result; diff --git a/src/plugins/platforms/windows/qwindowsscreen.h b/src/plugins/platforms/windows/qwindowsscreen.h index 824bcb1ad6..33c9effa2a 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.h +++ b/src/plugins/platforms/windows/qwindowsscreen.h @@ -104,6 +104,8 @@ public: inline void handleChanges(const QWindowsScreenData &newData); + HMONITOR handle() const; + #ifndef QT_NO_CURSOR QPlatformCursor *cursor() const override { return m_cursor.data(); } const CursorPtr &cursorPtr() const { return m_cursor; } From add4b56b21bae5cef222ee23e00707664ca50e7f Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 7 May 2019 14:57:56 +0200 Subject: [PATCH 271/292] Add warning suppression for icc when comparing floating-point values The new implementations of qIsNull use naked floating point comparisons to 0 and suppress the warnings for clang and gcc; so add suppression also for icc. Fixes: QTBUG-75644 Change-Id: I59aa1443666a542f38197f2b124503cc562708cb Reviewed-by: Qt CI Bot Reviewed-by: Giuseppe D'Angelo --- src/corelib/global/qglobal.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index a1f191516a..0a0c434a07 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -905,6 +905,7 @@ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qFuzzyIsNul QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wfloat-equal") QT_WARNING_DISABLE_GCC("-Wfloat-equal") +QT_WARNING_DISABLE_INTEL(1572) Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qIsNull(double d) noexcept { From ce1830fd21751e90060d77ba529bcd8904555587 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 24 Apr 2019 11:26:58 +0200 Subject: [PATCH 272/292] Migrate Windows system libs to external dependencies Started-by: Oswald Buddenhagen Change-Id: I211ce3252b836894aeeac1c85eb316d9596bca57 Reviewed-by: Oliver Wolff --- .../network/bearermonitor/bearermonitor.pro | 2 +- src/corelib/configure.json | 64 +++++++++++++++++++ src/corelib/corelib.pro | 6 +- src/corelib/io/io.pri | 3 +- src/dbus/dbus.pro | 10 +-- src/network/socket/socket.pri | 2 +- .../fontdatabases/windows/windows.pri | 4 +- .../fontdatabases/winrt/winrt.pri | 4 +- src/plugins/bearer/nla/nla.pro | 2 +- src/plugins/platforms/direct2d/direct2d.pro | 4 +- .../windows/uiautomation/uiautomation.pri | 3 +- src/plugins/platforms/windows/windows.pri | 14 ++-- src/plugins/platforms/windows/windows.pro | 3 +- src/plugins/platforms/winrt/winrt.pro | 3 +- src/plugins/printsupport/windows/windows.pro | 3 +- .../styles/windowsvista/windowsvista.pro | 2 +- src/printsupport/kernel/kernel.pri | 5 +- src/widgets/kernel/win.pri | 5 +- src/winmain/winmain.pro | 2 +- tests/auto/corelib/io/qfile/test.pro | 2 +- tests/auto/corelib/io/qfileinfo/qfileinfo.pro | 2 +- .../corelib/io/qlockfile/tst_qlockfile.pro | 2 +- .../testProcessEchoGui/testProcessEchoGui.pro | 2 +- .../io/qprocess/testSoftExit/testSoftExit.pro | 2 +- tests/auto/corelib/io/qsettings/qsettings.pro | 2 +- .../corelib/kernel/qeventloop/qeventloop.pro | 2 +- tests/auto/gui/image/qimage/qimage.pro | 2 +- tests/auto/gui/image/qpixmap/qpixmap.pro | 2 +- .../kernel/noqteventloop/noqteventloop.pro | 2 +- tests/auto/gui/kernel/qwindow/qwindow.pro | 2 +- .../kernel/qhostaddress/qhostaddress.pro | 2 +- .../network/kernel/qhostinfo/qhostinfo.pro | 2 +- .../platformsocketengine.pri | 2 +- .../network/socket/qtcpserver/test/test.pro | 2 +- .../network/socket/qtcpsocket/test/test.pro | 2 +- .../other/qaccessibility/qaccessibility.pro | 3 +- tests/auto/tools/qmakelib/qmakelib.pro | 2 +- .../qgraphicsitem/qgraphicsitem.pro | 2 +- .../qgraphicsscene/qgraphicsscene.pro | 2 +- .../itemviews/qitemdelegate/qitemdelegate.pro | 2 +- .../widgets/itemviews/qlistview/qlistview.pro | 2 +- tests/auto/widgets/kernel/qwidget/qwidget.pro | 2 +- .../widgets/widgets/qtabwidget/qtabwidget.pro | 2 +- tests/manual/diaglib/diaglib.pri | 2 +- 44 files changed, 133 insertions(+), 59 deletions(-) diff --git a/examples/network/bearermonitor/bearermonitor.pro b/examples/network/bearermonitor/bearermonitor.pro index 7d90b408e0..16ac41298a 100644 --- a/examples/network/bearermonitor/bearermonitor.pro +++ b/examples/network/bearermonitor/bearermonitor.pro @@ -13,7 +13,7 @@ FORMS = bearermonitor_240_320.ui \ bearermonitor_640_480.ui \ sessionwidget.ui -win32:LIBS += -lws2_32 +win32: QMAKE_USE += ws2_32 CONFIG += console diff --git a/src/corelib/configure.json b/src/corelib/configure.json index a6091d4825..d24867ffa0 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -235,6 +235,66 @@ "sources": [ "-lslog2" ] + }, + "advapi32": { + "label": "advapi32", + "sources": [ + "-ladvapi32" + ] + }, + "gdi32": { + "label": "gdi32", + "sources": [ + "-lgdi32" + ] + }, + "kernel32": { + "label": "kernel32", + "sources": [ + "-lkernel32" + ] + }, + "netapi32": { + "label": "netapi32", + "sources": [ + "-lnetapi32" + ] + }, + "ole32": { + "label": "ole32", + "sources": [ + "-lole32" + ] + }, + "shell32": { + "label": "shell32", + "sources": [ + "-lshell32" + ] + }, + "uuid": { + "label": "uuid", + "sources": [ + "-luuid" + ] + }, + "user32": { + "label": "user32", + "sources": [ + "-luser32" + ] + }, + "winmm": { + "label": "winmm", + "sources": [ + "-lwinmm" + ] + }, + "ws2_32": { + "label": "ws2_32", + "sources": [ + "-lws2_32" + ] } }, @@ -1017,6 +1077,10 @@ If enabled, a binary dump of the Public Suffix List (http://www.publicsuffix.org Mozilla License) is included. The data is then also used in QNetworkCookieJar::validateCookie.", "section": "Utilities", "output": [ "publicFeature" ] + }, + "win32_system_libs": { + "label": "Windows System Libraries", + "condition": "config.win32 && libs.advapi32 && libs.gdi32 && libs.kernel32 && libs.netapi32 && libs.ole32 && libs.shell32 && libs.uuid && libs.user32 && libs.winmm && libs.ws2_32" } }, diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro index dc43e56836..6babbac8f5 100644 --- a/src/corelib/corelib.pro +++ b/src/corelib/corelib.pro @@ -47,10 +47,8 @@ include(mimetypes/mimetypes.pri) include(platform/platform.pri) win32 { - LIBS_PRIVATE += -lws2_32 - !winrt { - LIBS_PRIVATE += -lkernel32 -luser32 -lshell32 -luuid -lole32 -ladvapi32 -lwinmm - } + QMAKE_USE_PRIVATE += ws2_32 + !winrt: QMAKE_USE_PRIVATE += advapi32 kernel32 ole32 shell32 uuid user32 winmm } darwin { diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index 9b6044752f..13b43ad8f7 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -158,7 +158,8 @@ win32 { io/qwindowspipereader.cpp \ io/qwindowspipewriter.cpp - LIBS += -lmpr -lnetapi32 -luserenv + LIBS += -lmpr -luserenv + QMAKE_USE_PRIVATE += netapi32 } else { SOURCES += \ io/qstandardpaths_winrt.cpp \ diff --git a/src/dbus/dbus.pro b/src/dbus/dbus.pro index 920a04315d..2cfd7e086c 100644 --- a/src/dbus/dbus.pro +++ b/src/dbus/dbus.pro @@ -9,11 +9,11 @@ qtConfig(dbus-linked) { } win32 { - LIBS_PRIVATE += \ - -lws2_32 \ - -ladvapi32 \ - -lnetapi32 \ - -luser32 + QMAKE_USE_PRIVATE += \ + advapi32 \ + netapi32 \ + user32 \ + ws2_32 } DEFINES += QT_NO_FOREACH diff --git a/src/network/socket/socket.pri b/src/network/socket/socket.pri index 44ff5b7b39..c3a98ea31a 100644 --- a/src/network/socket/socket.pri +++ b/src/network/socket/socket.pri @@ -58,7 +58,7 @@ unix { msvc: QMAKE_MOC_OPTIONS += -D_WINSOCK_DEPRECATED_NO_WARNINGS win32:!winrt:SOURCES += socket/qnativesocketengine_win.cpp -win32:!winrt:LIBS_PRIVATE += -ladvapi32 +win32:!winrt: QMAKE_USE_PRIVATE += advapi32 winrt { SOURCES += socket/qnativesocketengine_winrt.cpp diff --git a/src/platformsupport/fontdatabases/windows/windows.pri b/src/platformsupport/fontdatabases/windows/windows.pri index 9c529f55ea..7ddfb2c281 100644 --- a/src/platformsupport/fontdatabases/windows/windows.pri +++ b/src/platformsupport/fontdatabases/windows/windows.pri @@ -30,5 +30,5 @@ qtConfig(directwrite):qtConfig(direct2d) { DEFINES *= QT_NO_DIRECTWRITE } -LIBS += -lole32 -lgdi32 -luser32 -ladvapi32 -mingw: LIBS += -luuid +QMAKE_USE_PRIVATE += advapi32 ole32 user32 gdi32 +mingw: QMAKE_USE_PRIVATE += uuid diff --git a/src/platformsupport/fontdatabases/winrt/winrt.pri b/src/platformsupport/fontdatabases/winrt/winrt.pri index 7617df2e7a..1cd417c1fd 100644 --- a/src/platformsupport/fontdatabases/winrt/winrt.pri +++ b/src/platformsupport/fontdatabases/winrt/winrt.pri @@ -8,6 +8,4 @@ HEADERS += \ DEFINES += __WRL_NO_DEFAULT_LIB__ -LIBS += -lws2_32 - -QMAKE_USE_PRIVATE += dwrite_1 +QMAKE_USE_PRIVATE += dwrite_1 ws2_32 diff --git a/src/plugins/bearer/nla/nla.pro b/src/plugins/bearer/nla/nla.pro index 113d0667d2..76f3279d25 100644 --- a/src/plugins/bearer/nla/nla.pro +++ b/src/plugins/bearer/nla/nla.pro @@ -2,7 +2,7 @@ TARGET = qnlabearer QT = core core-private network network-private -LIBS += -lws2_32 +QMAKE_USE_PRIVATE += ws2_32 HEADERS += qnlaengine.h \ ../platformdefs_win.h \ diff --git a/src/plugins/platforms/direct2d/direct2d.pro b/src/plugins/platforms/direct2d/direct2d.pro index 9764272632..6e73bd14f9 100644 --- a/src/plugins/platforms/direct2d/direct2d.pro +++ b/src/plugins/platforms/direct2d/direct2d.pro @@ -8,8 +8,8 @@ QT += \ qtConfig(accessibility): QT += accessibility_support-private qtConfig(vulkan): QT += vulkan_support-private -LIBS += -ldwmapi -lversion -lgdi32 -QMAKE_USE_PRIVATE += dwrite_1 d2d1_1 d3d11_1 dxgi1_2 +LIBS += -ldwmapi -lversion +QMAKE_USE_PRIVATE += gdi32 dwrite_1 d2d1_1 d3d11_1 dxgi1_2 include(../windows/windows.pri) diff --git a/src/plugins/platforms/windows/uiautomation/uiautomation.pri b/src/plugins/platforms/windows/uiautomation/uiautomation.pri index e3071766d9..b79e42cdec 100644 --- a/src/plugins/platforms/windows/uiautomation/uiautomation.pri +++ b/src/plugins/platforms/windows/uiautomation/uiautomation.pri @@ -39,5 +39,4 @@ HEADERS += \ $$PWD/qwindowsuiagriditemprovider.h \ $$PWD/qwindowsuiautils.h -mingw: LIBS *= -luuid - +mingw: QMAKE_USE *= uuid diff --git a/src/plugins/platforms/windows/windows.pri b/src/plugins/platforms/windows/windows.pri index 7004d7e854..95ba961df1 100644 --- a/src/plugins/platforms/windows/windows.pri +++ b/src/plugins/platforms/windows/windows.pri @@ -1,15 +1,21 @@ # Note: OpenGL32 must precede Gdi32 as it overwrites some functions. -LIBS += -lole32 -luser32 -lwinspool -limm32 -lwinmm -loleaut32 +LIBS += -lwinspool -limm32 -loleaut32 QT_FOR_CONFIG += gui qtConfig(opengl):!qtConfig(opengles2):!qtConfig(dynamicgl): LIBS *= -lopengl32 -mingw: LIBS *= -luuid +mingw: QMAKE_USE *= uuid # For the dialog helpers: -LIBS += -lshlwapi -lshell32 -ladvapi32 -lwtsapi32 +LIBS += -lshlwapi -lwtsapi32 -QMAKE_USE_PRIVATE += d3d9/nolink +QMAKE_USE_PRIVATE += \ + advapi32 \ + d3d9/nolink \ + ole32 \ + shell32 \ + user32 \ + winmm DEFINES *= QT_NO_CAST_FROM_ASCII QT_NO_FOREACH diff --git a/src/plugins/platforms/windows/windows.pro b/src/plugins/platforms/windows/windows.pro index 174bc7b609..50a3bb41a9 100644 --- a/src/plugins/platforms/windows/windows.pro +++ b/src/plugins/platforms/windows/windows.pro @@ -8,7 +8,8 @@ QT += \ qtConfig(accessibility): QT += accessibility_support-private qtConfig(vulkan): QT += vulkan_support-private -LIBS += -lgdi32 -ldwmapi +LIBS += -ldwmapi +QMAKE_USE_PRIVATE += gdi32 include(windows.pri) diff --git a/src/plugins/platforms/winrt/winrt.pro b/src/plugins/platforms/winrt/winrt.pro index 43132a1a76..43dc8f074c 100644 --- a/src/plugins/platforms/winrt/winrt.pro +++ b/src/plugins/platforms/winrt/winrt.pro @@ -8,8 +8,7 @@ QT += \ DEFINES *= QT_NO_CAST_FROM_ASCII __WRL_NO_DEFAULT_LIB__ -LIBS += -lws2_32 -QMAKE_USE_PRIVATE += d3d11 +QMAKE_USE_PRIVATE += d3d11 ws2_32 SOURCES = \ main.cpp \ diff --git a/src/plugins/printsupport/windows/windows.pro b/src/plugins/printsupport/windows/windows.pro index 06694fb7fe..6ca601b2a4 100644 --- a/src/plugins/printsupport/windows/windows.pro +++ b/src/plugins/printsupport/windows/windows.pro @@ -18,7 +18,8 @@ HEADERS += \ OTHER_FILES += windows.json -LIBS += -lwinspool -lcomdlg32 -lgdi32 -luser32 +LIBS += -lwinspool -lcomdlg32 +QMAKE_USE_PRIVATE += user32 gdi32 PLUGIN_TYPE = printsupport PLUGIN_CLASS_NAME = QWindowsPrinterSupportPlugin diff --git a/src/plugins/styles/windowsvista/windowsvista.pro b/src/plugins/styles/windowsvista/windowsvista.pro index f82bcfc91b..c08db7f533 100644 --- a/src/plugins/styles/windowsvista/windowsvista.pro +++ b/src/plugins/styles/windowsvista/windowsvista.pro @@ -10,7 +10,7 @@ SOURCES += qwindowsvistastyle.cpp HEADERS += qwindowsxpstyle_p.h qwindowsxpstyle_p_p.h SOURCES += qwindowsxpstyle.cpp -LIBS_PRIVATE += -lgdi32 -luser32 +QMAKE_USE_PRIVATE += user32 gdi32 # DEFINES/LIBS needed for qwizard_win.cpp and the styles include(../../../widgets/kernel/win.pri) diff --git a/src/printsupport/kernel/kernel.pri b/src/printsupport/kernel/kernel.pri index ea7b4b9780..2ceaf152eb 100644 --- a/src/printsupport/kernel/kernel.pri +++ b/src/printsupport/kernel/kernel.pri @@ -33,7 +33,10 @@ win32 { $$PWD/qprintengine_win_p.h SOURCES += \ $$PWD/qprintengine_win.cpp - !winrt: LIBS_PRIVATE += -lwinspool -lcomdlg32 -lgdi32 -luser32 + !winrt { + LIBS_PRIVATE += -lwinspool -lcomdlg32 + QMAKE_USE_PRIVATE += user32 gdi32 + } } unix:!darwin:qtConfig(cups) { diff --git a/src/widgets/kernel/win.pri b/src/widgets/kernel/win.pri index f6877b02db..3b3170beb1 100644 --- a/src/widgets/kernel/win.pri +++ b/src/widgets/kernel/win.pri @@ -2,4 +2,7 @@ # -------------------------------------------------------------------- INCLUDEPATH += ../3rdparty/wintab -!winrt: LIBS_PRIVATE *= -lshell32 -luxtheme -ldwmapi +!winrt { + LIBS_PRIVATE *= -luxtheme -ldwmapi + QMAKE_USE_PRIVATE += shell32 +} diff --git a/src/winmain/winmain.pro b/src/winmain/winmain.pro index 9cb6ab0c59..1f54c846ec 100644 --- a/src/winmain/winmain.pro +++ b/src/winmain/winmain.pro @@ -23,7 +23,7 @@ winrt { } else { CONFIG -= qt SOURCES = qtmain_win.cpp - LIBS += -lshell32 + QMAKE_USE_PRIVATE += shell32 } load(qt_installs) diff --git a/tests/auto/corelib/io/qfile/test.pro b/tests/auto/corelib/io/qfile/test.pro index 95389ab3e2..7a2767bf3c 100644 --- a/tests/auto/corelib/io/qfile/test.pro +++ b/tests/auto/corelib/io/qfile/test.pro @@ -23,4 +23,4 @@ TESTDATA += \ Makefile forCopying.txt forRenaming.txt \ resources/file1.ext1 -win32:!winrt: LIBS += -lole32 -luuid +win32:!winrt: QMAKE_USE += ole32 uuid diff --git a/tests/auto/corelib/io/qfileinfo/qfileinfo.pro b/tests/auto/corelib/io/qfileinfo/qfileinfo.pro index 496729f9f1..d181d16a3e 100644 --- a/tests/auto/corelib/io/qfileinfo/qfileinfo.pro +++ b/tests/auto/corelib/io/qfileinfo/qfileinfo.pro @@ -5,4 +5,4 @@ SOURCES = tst_qfileinfo.cpp RESOURCES += qfileinfo.qrc \ testdata.qrc -win32:!winrt: LIBS += -ladvapi32 -lnetapi32 +win32:!winrt: QMAKE_USE += advapi32 netapi32 diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro b/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro index da2660fd02..e33e22b36f 100644 --- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro +++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro @@ -3,4 +3,4 @@ TARGET = tst_qlockfile SOURCES += tst_qlockfile.cpp QT = core-private testlib concurrent -win32:!winrt:LIBS += -ladvapi32 +win32:!winrt: QMAKE_USE += advapi32 diff --git a/tests/auto/corelib/io/qprocess/testProcessEchoGui/testProcessEchoGui.pro b/tests/auto/corelib/io/qprocess/testProcessEchoGui/testProcessEchoGui.pro index 935f43630c..e41ed0a425 100644 --- a/tests/auto/corelib/io/qprocess/testProcessEchoGui/testProcessEchoGui.pro +++ b/tests/auto/corelib/io/qprocess/testProcessEchoGui/testProcessEchoGui.pro @@ -1,6 +1,6 @@ win32 { SOURCES = main_win.cpp - LIBS += -luser32 + QMAKE_USE += user32 } CONFIG -= qt app_bundle diff --git a/tests/auto/corelib/io/qprocess/testSoftExit/testSoftExit.pro b/tests/auto/corelib/io/qprocess/testSoftExit/testSoftExit.pro index 2cfcb4794e..964c47f6ae 100644 --- a/tests/auto/corelib/io/qprocess/testSoftExit/testSoftExit.pro +++ b/tests/auto/corelib/io/qprocess/testSoftExit/testSoftExit.pro @@ -1,6 +1,6 @@ win32 { SOURCES = main_win.cpp - LIBS += -luser32 + QMAKE_USE += user32 } unix { SOURCES = main_unix.cpp diff --git a/tests/auto/corelib/io/qsettings/qsettings.pro b/tests/auto/corelib/io/qsettings/qsettings.pro index 79552b62df..98ea337e7f 100644 --- a/tests/auto/corelib/io/qsettings/qsettings.pro +++ b/tests/auto/corelib/io/qsettings/qsettings.pro @@ -5,7 +5,7 @@ SOURCES = tst_qsettings.cpp RESOURCES += qsettings.qrc INCLUDEPATH += $$PWD/../../kernel/qmetatype -msvc: LIBS += advapi32.lib +msvc: QMAKE_USE += advapi32 darwin: LIBS += -framework CoreFoundation DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/corelib/kernel/qeventloop/qeventloop.pro b/tests/auto/corelib/kernel/qeventloop/qeventloop.pro index 295a42aa9c..159761c0c6 100644 --- a/tests/auto/corelib/kernel/qeventloop/qeventloop.pro +++ b/tests/auto/corelib/kernel/qeventloop/qeventloop.pro @@ -3,6 +3,6 @@ TARGET = tst_qeventloop QT = core network testlib core-private SOURCES = $$PWD/tst_qeventloop.cpp -win32:!winrt: LIBS += -luser32 +win32:!winrt: QMAKE_USE += user32 qtConfig(glib): DEFINES += HAVE_GLIB diff --git a/tests/auto/gui/image/qimage/qimage.pro b/tests/auto/gui/image/qimage/qimage.pro index b40866892e..0593cfbc23 100644 --- a/tests/auto/gui/image/qimage/qimage.pro +++ b/tests/auto/gui/image/qimage/qimage.pro @@ -7,7 +7,7 @@ qtConfig(c++11): CONFIG += c++11 android:!android-embedded: RESOURCES += qimage.qrc -win32:!winrt: LIBS += -lgdi32 -luser32 +win32:!winrt: QMAKE_USE += user32 gdi32 darwin: LIBS += -framework CoreGraphics TESTDATA += images/* diff --git a/tests/auto/gui/image/qpixmap/qpixmap.pro b/tests/auto/gui/image/qpixmap/qpixmap.pro index e6a020af1a..c9219dad1d 100644 --- a/tests/auto/gui/image/qpixmap/qpixmap.pro +++ b/tests/auto/gui/image/qpixmap/qpixmap.pro @@ -5,7 +5,7 @@ QT += core-private gui-private testlib qtHaveModule(widgets): QT += widgets widgets-private SOURCES += tst_qpixmap.cpp -win32:!winrt:LIBS += -lgdi32 -luser32 +win32:!winrt: QMAKE_USE += user32 gdi32 RESOURCES += qpixmap.qrc TESTDATA += convertFromImage/* convertFromToHICON/* loadFromData/* images/* diff --git a/tests/auto/gui/kernel/noqteventloop/noqteventloop.pro b/tests/auto/gui/kernel/noqteventloop/noqteventloop.pro index 7e98704aea..293a6a8581 100644 --- a/tests/auto/gui/kernel/noqteventloop/noqteventloop.pro +++ b/tests/auto/gui/kernel/noqteventloop/noqteventloop.pro @@ -5,4 +5,4 @@ QT += core-private network gui-private testlib SOURCES += tst_noqteventloop.cpp -qtConfig(dynamicgl):win32:!winrt: LIBS += -luser32 +qtConfig(dynamicgl):win32:!winrt: QMAKE_USE += user32 diff --git a/tests/auto/gui/kernel/qwindow/qwindow.pro b/tests/auto/gui/kernel/qwindow/qwindow.pro index 844b3e8507..e7931ca773 100644 --- a/tests/auto/gui/kernel/qwindow/qwindow.pro +++ b/tests/auto/gui/kernel/qwindow/qwindow.pro @@ -5,4 +5,4 @@ QT += core-private gui-private testlib SOURCES += tst_qwindow.cpp -qtConfig(dynamicgl):win32:!winrt: LIBS += -luser32 +qtConfig(dynamicgl):win32:!winrt: QMAKE_USE += user32 diff --git a/tests/auto/network/kernel/qhostaddress/qhostaddress.pro b/tests/auto/network/kernel/qhostaddress/qhostaddress.pro index b5d6ea6459..d170d879e6 100644 --- a/tests/auto/network/kernel/qhostaddress/qhostaddress.pro +++ b/tests/auto/network/kernel/qhostaddress/qhostaddress.pro @@ -4,4 +4,4 @@ SOURCES += tst_qhostaddress.cpp QT = core network-private testlib -win32:LIBS += -lws2_32 +win32: QMAKE_USE += ws2_32 diff --git a/tests/auto/network/kernel/qhostinfo/qhostinfo.pro b/tests/auto/network/kernel/qhostinfo/qhostinfo.pro index 3d8457dd46..d358cdf52c 100644 --- a/tests/auto/network/kernel/qhostinfo/qhostinfo.pro +++ b/tests/auto/network/kernel/qhostinfo/qhostinfo.pro @@ -6,6 +6,6 @@ SOURCES += tst_qhostinfo.cpp requires(qtConfig(private_tests)) QT = core-private network-private testlib -win32:LIBS += -lws2_32 +win32: QMAKE_USE += ws2_32 winrt: WINRT_MANIFEST.capabilities += internetClientServer diff --git a/tests/auto/network/socket/platformsocketengine/platformsocketengine.pri b/tests/auto/network/socket/platformsocketengine/platformsocketengine.pri index 46c722deba..868439de6a 100644 --- a/tests/auto/network/socket/platformsocketengine/platformsocketengine.pri +++ b/tests/auto/network/socket/platformsocketengine/platformsocketengine.pri @@ -4,7 +4,7 @@ QNETWORK_SRC = $$QT_SOURCE_TREE/src/network INCLUDEPATH += $$QNETWORK_SRC -win32:LIBS += -lws2_32 +win32: QMAKE_USE += ws2_32 unix:qtConfig(reduce_exports) { SOURCES += $$QNETWORK_SRC/socket/qnativesocketengine_unix.cpp diff --git a/tests/auto/network/socket/qtcpserver/test/test.pro b/tests/auto/network/socket/qtcpserver/test/test.pro index de02fb032d..7e2e60a1e3 100644 --- a/tests/auto/network/socket/qtcpserver/test/test.pro +++ b/tests/auto/network/socket/qtcpserver/test/test.pro @@ -1,7 +1,7 @@ CONFIG += testcase SOURCES += ../tst_qtcpserver.cpp -win32:LIBS += -lws2_32 +win32: QMAKE_USE += ws2_32 TARGET = ../tst_qtcpserver diff --git a/tests/auto/network/socket/qtcpsocket/test/test.pro b/tests/auto/network/socket/qtcpsocket/test/test.pro index 05699bbe4e..4c07b1ec66 100644 --- a/tests/auto/network/socket/qtcpsocket/test/test.pro +++ b/tests/auto/network/socket/qtcpsocket/test/test.pro @@ -2,8 +2,8 @@ CONFIG += testcase QT = core-private network-private testlib SOURCES += ../tst_qtcpsocket.cpp -win32:LIBS += -lws2_32 +win32: QMAKE_USE += ws2_32 TARGET = tst_qtcpsocket win32 { diff --git a/tests/auto/other/qaccessibility/qaccessibility.pro b/tests/auto/other/qaccessibility/qaccessibility.pro index 3587c38e76..6f3740a24f 100644 --- a/tests/auto/other/qaccessibility/qaccessibility.pro +++ b/tests/auto/other/qaccessibility/qaccessibility.pro @@ -11,5 +11,6 @@ win32 { !winrt { QT += windowsuiautomation_support-private } - LIBS += -luuid -loleacc -loleaut32 -lole32 + LIBS += -loleacc -loleaut32 + QMAKE_USE += ole32 uuid } diff --git a/tests/auto/tools/qmakelib/qmakelib.pro b/tests/auto/tools/qmakelib/qmakelib.pro index 29f17f6a14..5e9e9fe637 100644 --- a/tests/auto/tools/qmakelib/qmakelib.pro +++ b/tests/auto/tools/qmakelib/qmakelib.pro @@ -1,7 +1,7 @@ CONFIG += testcase TARGET = tst_qmakelib QT = core testlib -win32: LIBS += -ladvapi32 +win32: QMAKE_USE += advapi32 INCLUDEPATH += ../../../../qmake/library VPATH += ../../../../qmake/library diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/qgraphicsitem.pro b/tests/auto/widgets/graphicsview/qgraphicsitem/qgraphicsitem.pro index ae6de48195..16818a98f9 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/qgraphicsitem.pro +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/qgraphicsitem.pro @@ -5,4 +5,4 @@ QT += core-private gui-private SOURCES += tst_qgraphicsitem.cpp DEFINES += QT_NO_CAST_TO_ASCII -win32:!winrt: LIBS += -luser32 +win32:!winrt: QMAKE_USE += user32 diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/qgraphicsscene.pro b/tests/auto/widgets/graphicsview/qgraphicsscene/qgraphicsscene.pro index 351cecd92e..2f648a2212 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/qgraphicsscene.pro +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/qgraphicsscene.pro @@ -4,7 +4,7 @@ QT += widgets widgets-private testlib QT += core-private gui-private SOURCES += tst_qgraphicsscene.cpp RESOURCES += images.qrc -win32:!winrt: LIBS += -luser32 +win32:!winrt: QMAKE_USE += user32 DEFINES += SRCDIR=\\\"$$PWD\\\" DEFINES += QT_NO_CAST_TO_ASCII diff --git a/tests/auto/widgets/itemviews/qitemdelegate/qitemdelegate.pro b/tests/auto/widgets/itemviews/qitemdelegate/qitemdelegate.pro index 10cd1dcc54..916694fd0f 100644 --- a/tests/auto/widgets/itemviews/qitemdelegate/qitemdelegate.pro +++ b/tests/auto/widgets/itemviews/qitemdelegate/qitemdelegate.pro @@ -3,4 +3,4 @@ TARGET = tst_qitemdelegate QT += widgets widgets-private testlib SOURCES += tst_qitemdelegate.cpp -win32:!winrt: LIBS += -luser32 +win32:!winrt: QMAKE_USE += user32 diff --git a/tests/auto/widgets/itemviews/qlistview/qlistview.pro b/tests/auto/widgets/itemviews/qlistview/qlistview.pro index 75f45ab432..c3e19adc81 100644 --- a/tests/auto/widgets/itemviews/qlistview/qlistview.pro +++ b/tests/auto/widgets/itemviews/qlistview/qlistview.pro @@ -2,4 +2,4 @@ CONFIG += testcase TARGET = tst_qlistview QT += widgets gui-private widgets-private core-private testlib testlib-private SOURCES += tst_qlistview.cpp -win32:!winrt: LIBS += -luser32 +win32:!winrt: QMAKE_USE += user32 diff --git a/tests/auto/widgets/kernel/qwidget/qwidget.pro b/tests/auto/widgets/kernel/qwidget/qwidget.pro index c1908af2a2..d3fbd6d0d9 100644 --- a/tests/auto/widgets/kernel/qwidget/qwidget.pro +++ b/tests/auto/widgets/kernel/qwidget/qwidget.pro @@ -16,4 +16,4 @@ mac { OBJECTIVE_SOURCES += tst_qwidget_mac_helpers.mm } -win32:!winrt: LIBS += -luser32 -lgdi32 +win32:!winrt: QMAKE_USE += user32 gdi32 diff --git a/tests/auto/widgets/widgets/qtabwidget/qtabwidget.pro b/tests/auto/widgets/widgets/qtabwidget/qtabwidget.pro index 6523209c32..b61cc8fa13 100644 --- a/tests/auto/widgets/widgets/qtabwidget/qtabwidget.pro +++ b/tests/auto/widgets/widgets/qtabwidget/qtabwidget.pro @@ -8,4 +8,4 @@ INCLUDEPATH += ../ HEADERS += SOURCES += tst_qtabwidget.cpp -win32:!winrt: LIBS += -luser32 +win32:!winrt: QMAKE_USE += user32 diff --git a/tests/manual/diaglib/diaglib.pri b/tests/manual/diaglib/diaglib.pri index 9f10167136..b57ee75841 100644 --- a/tests/manual/diaglib/diaglib.pri +++ b/tests/manual/diaglib/diaglib.pri @@ -12,7 +12,7 @@ HEADERS += \ win32:!winrt: { SOURCES += $$PWD/nativewindowdump_win.cpp - LIBS *= -luser32 + QMAKE_USE += user32 } else { SOURCES += $$PWD/nativewindowdump.cpp } From c1721cc859cc58cf04b73ba3e8db51f628684b26 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 8 May 2019 08:52:56 +0200 Subject: [PATCH 273/292] uic/Python: Generate empty strings as "" instead of QString() Task-number: PYSIDE-797 Change-Id: I4ce12ba01318e5ed7e88178dfd2450d9fe78c708 Reviewed-by: Cristian Maureira-Fredes --- src/tools/uic/cpp/cppwriteinitialization.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 2510fd0edc..55541db98a 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -2465,8 +2465,10 @@ void WriteInitialization::initializeTableWidget(DomWidget *w) QString WriteInitialization::trCall(const QString &str, const QString &commentHint, const QString &id) const { - if (str.isEmpty()) - return QLatin1String("QString()"); + if (str.isEmpty()) { + return language::language() == Language::Cpp + ? QLatin1String("QString()") : QLatin1String("\"\""); + } QString result; QTextStream ts(&result); From 6a58a68ae3feb27dca48ebb3274b748f784b3d12 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 7 May 2019 17:25:59 +0200 Subject: [PATCH 274/292] Remove 3rdparty include from QTextMarkdownImporter header file It's a private header; but to be able to use it in a test, it has to be as clean as a public header. Change-Id: I868372406e62acc24051a6523fee89bb911a61f9 Reviewed-by: Gatis Paeglis --- src/gui/text/qtextmarkdownimporter.cpp | 49 +++++++++++++------------- src/gui/text/qtextmarkdownimporter_p.h | 45 ++++++++++++----------- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp index bcb0b777d4..2c520a71c9 100644 --- a/src/gui/text/qtextmarkdownimporter.cpp +++ b/src/gui/text/qtextmarkdownimporter.cpp @@ -46,6 +46,7 @@ #include #include #include +#include "../../3rdparty/md4c/md4c.h" QT_BEGIN_NAMESPACE @@ -57,31 +58,31 @@ Q_LOGGING_CATEGORY(lcMD, "qt.text.markdown") static int CbEnterBlock(MD_BLOCKTYPE type, void *detail, void *userdata) { QTextMarkdownImporter *mdi = static_cast(userdata); - return mdi->cbEnterBlock(type, detail); + return mdi->cbEnterBlock(int(type), detail); } static int CbLeaveBlock(MD_BLOCKTYPE type, void *detail, void *userdata) { QTextMarkdownImporter *mdi = static_cast(userdata); - return mdi->cbLeaveBlock(type, detail); + return mdi->cbLeaveBlock(int(type), detail); } static int CbEnterSpan(MD_SPANTYPE type, void *detail, void *userdata) { QTextMarkdownImporter *mdi = static_cast(userdata); - return mdi->cbEnterSpan(type, detail); + return mdi->cbEnterSpan(int(type), detail); } static int CbLeaveSpan(MD_SPANTYPE type, void *detail, void *userdata) { QTextMarkdownImporter *mdi = static_cast(userdata); - return mdi->cbLeaveSpan(type, detail); + return mdi->cbLeaveSpan(int(type), detail); } static int CbText(MD_TEXTTYPE type, const MD_CHAR *text, MD_SIZE size, void *userdata) { QTextMarkdownImporter *mdi = static_cast(userdata); - return mdi->cbText(type, text, size); + return mdi->cbText(int(type), text, size); } static void CbDebugLog(const char *msg, void *userdata) @@ -131,15 +132,15 @@ void QTextMarkdownImporter::import(QTextDocument *doc, const QString &markdown) doc->clear(); qCDebug(lcMD) << "default font" << doc->defaultFont() << "mono font" << m_monoFont; QByteArray md = markdown.toUtf8(); - md_parse(md.constData(), md.size(), &callbacks, this); + md_parse(md.constData(), MD_SIZE(md.size()), &callbacks, this); delete m_cursor; m_cursor = nullptr; } -int QTextMarkdownImporter::cbEnterBlock(MD_BLOCKTYPE type, void *det) +int QTextMarkdownImporter::cbEnterBlock(int blockType, void *det) { - m_blockType = type; - switch (type) { + m_blockType = blockType; + switch (blockType) { case MD_BLOCK_P: { QTextBlockFormat blockFmt; int margin = m_doc->defaultFont().pointSize() / 2; @@ -157,10 +158,10 @@ int QTextMarkdownImporter::cbEnterBlock(MD_BLOCKTYPE type, void *det) MD_BLOCK_H_DETAIL *detail = static_cast(det); QTextBlockFormat blockFmt; QTextCharFormat charFmt; - int sizeAdjustment = 4 - detail->level; // H1 to H6: +3 to -2 + int sizeAdjustment = 4 - int(detail->level); // H1 to H6: +3 to -2 charFmt.setProperty(QTextFormat::FontSizeAdjustment, sizeAdjustment); charFmt.setFontWeight(QFont::Bold); - blockFmt.setHeadingLevel(detail->level); + blockFmt.setHeadingLevel(int(detail->level)); m_cursor->insertBlock(blockFmt, charFmt); } break; case MD_BLOCK_LI: { @@ -258,10 +259,10 @@ int QTextMarkdownImporter::cbEnterBlock(MD_BLOCKTYPE type, void *det) return 0; // no error } -int QTextMarkdownImporter::cbLeaveBlock(MD_BLOCKTYPE type, void *detail) +int QTextMarkdownImporter::cbLeaveBlock(int blockType, void *detail) { Q_UNUSED(detail) - switch (type) { + switch (blockType) { case MD_BLOCK_UL: case MD_BLOCK_OL: m_listStack.pop(); @@ -304,10 +305,10 @@ int QTextMarkdownImporter::cbLeaveBlock(MD_BLOCKTYPE type, void *detail) return 0; // no error } -int QTextMarkdownImporter::cbEnterSpan(MD_SPANTYPE type, void *det) +int QTextMarkdownImporter::cbEnterSpan(int spanType, void *det) { QTextCharFormat charFmt; - switch (type) { + switch (spanType) { case MD_SPAN_EM: charFmt.setFontItalic(true); break; @@ -316,8 +317,8 @@ int QTextMarkdownImporter::cbEnterSpan(MD_SPANTYPE type, void *det) break; case MD_SPAN_A: { MD_SPAN_A_DETAIL *detail = static_cast(det); - QString url = QString::fromLatin1(detail->href.text, detail->href.size); - QString title = QString::fromLatin1(detail->title.text, detail->title.size); + QString url = QString::fromLatin1(detail->href.text, int(detail->href.size)); + QString title = QString::fromLatin1(detail->title.text, int(detail->title.size)); charFmt.setAnchorHref(url); charFmt.setAnchorNames(QStringList(title)); charFmt.setForeground(m_palette.link()); @@ -326,8 +327,8 @@ int QTextMarkdownImporter::cbEnterSpan(MD_SPANTYPE type, void *det) case MD_SPAN_IMG: { m_imageSpan = true; MD_SPAN_IMG_DETAIL *detail = static_cast(det); - QString src = QString::fromUtf8(detail->src.text, detail->src.size); - QString title = QString::fromUtf8(detail->title.text, detail->title.size); + QString src = QString::fromUtf8(detail->src.text, int(detail->src.size)); + QString title = QString::fromUtf8(detail->title.text, int(detail->title.size)); QTextImageFormat img; img.setName(src); qCDebug(lcMD) << "image" << src << "title" << title << "relative to" << m_doc->baseUrl(); @@ -346,7 +347,7 @@ int QTextMarkdownImporter::cbEnterSpan(MD_SPANTYPE type, void *det) return 0; // no error } -int QTextMarkdownImporter::cbLeaveSpan(MD_SPANTYPE type, void *detail) +int QTextMarkdownImporter::cbLeaveSpan(int spanType, void *detail) { Q_UNUSED(detail) QTextCharFormat charFmt; @@ -356,20 +357,20 @@ int QTextMarkdownImporter::cbLeaveSpan(MD_SPANTYPE type, void *detail) charFmt = m_spanFormatStack.top(); } m_cursor->setCharFormat(charFmt); - if (type == MD_SPAN_IMG) + if (spanType == int(MD_SPAN_IMG)) m_imageSpan = false; return 0; // no error } -int QTextMarkdownImporter::cbText(MD_TEXTTYPE type, const MD_CHAR *text, MD_SIZE size) +int QTextMarkdownImporter::cbText(int textType, const char *text, unsigned size) { if (m_imageSpan) return 0; // it's the alt-text static const QRegularExpression openingBracket(QStringLiteral("<[a-zA-Z]")); static const QRegularExpression closingBracket(QStringLiteral("(/>| #include -#include "../../3rdparty/md4c/md4c.h" - QT_BEGIN_NAMESPACE class QTextCursor; @@ -69,22 +67,23 @@ class Q_GUI_EXPORT QTextMarkdownImporter { public: enum Feature { - FeatureCollapseWhitespace = MD_FLAG_COLLAPSEWHITESPACE, - FeaturePermissiveATXHeaders = MD_FLAG_PERMISSIVEATXHEADERS, - FeaturePermissiveURLAutoLinks = MD_FLAG_PERMISSIVEURLAUTOLINKS, - FeaturePermissiveMailAutoLinks = MD_FLAG_PERMISSIVEEMAILAUTOLINKS, - FeatureNoIndentedCodeBlocks = MD_FLAG_NOINDENTEDCODEBLOCKS, - FeatureNoHTMLBlocks = MD_FLAG_NOHTMLBLOCKS, - FeatureNoHTMLSpans = MD_FLAG_NOHTMLSPANS, - FeatureTables = MD_FLAG_TABLES, - FeatureStrikeThrough = MD_FLAG_STRIKETHROUGH, - FeaturePermissiveWWWAutoLinks = MD_FLAG_PERMISSIVEWWWAUTOLINKS, - FeatureTasklists = MD_FLAG_TASKLISTS, + // Must be kept in sync with MD_FLAG_* in md4c.h + FeatureCollapseWhitespace = 0x0001, // MD_FLAG_COLLAPSEWHITESPACE + FeaturePermissiveATXHeaders = 0x0002, // MD_FLAG_PERMISSIVEATXHEADERS + FeaturePermissiveURLAutoLinks = 0x0004, // MD_FLAG_PERMISSIVEURLAUTOLINKS + FeaturePermissiveMailAutoLinks = 0x0008, // MD_FLAG_PERMISSIVEEMAILAUTOLINKS + FeatureNoIndentedCodeBlocks = 0x0010, // MD_FLAG_NOINDENTEDCODEBLOCKS + FeatureNoHTMLBlocks = 0x0020, // MD_FLAG_NOHTMLBLOCKS + FeatureNoHTMLSpans = 0x0040, // MD_FLAG_NOHTMLSPANS + FeatureTables = 0x0100, // MD_FLAG_TABLES + FeatureStrikeThrough = 0x0200, // MD_FLAG_STRIKETHROUGH + FeaturePermissiveWWWAutoLinks = 0x0400, // MD_FLAG_PERMISSIVEWWWAUTOLINKS + FeatureTasklists = 0x0800, // MD_FLAG_TASKLISTS // composite flags - FeaturePermissiveAutoLinks = MD_FLAG_PERMISSIVEAUTOLINKS, - FeatureNoHTML = MD_FLAG_NOHTML, - DialectCommonMark = MD_DIALECT_COMMONMARK, - DialectGitHub = MD_DIALECT_GITHUB + FeaturePermissiveAutoLinks = FeaturePermissiveMailAutoLinks | FeaturePermissiveURLAutoLinks | FeaturePermissiveWWWAutoLinks, // MD_FLAG_PERMISSIVEAUTOLINKS + FeatureNoHTML = FeatureNoHTMLBlocks | FeatureNoHTMLSpans, // MD_FLAG_NOHTML + DialectCommonMark = 0, // MD_DIALECT_COMMONMARK + DialectGitHub = FeaturePermissiveAutoLinks | FeatureTables | FeatureStrikeThrough | FeatureTasklists // MD_DIALECT_GITHUB }; Q_DECLARE_FLAGS(Features, Feature) @@ -94,11 +93,11 @@ public: public: // MD4C callbacks - int cbEnterBlock(MD_BLOCKTYPE type, void* detail); - int cbLeaveBlock(MD_BLOCKTYPE type, void* detail); - int cbEnterSpan(MD_SPANTYPE type, void* detail); - int cbLeaveSpan(MD_SPANTYPE type, void* detail); - int cbText(MD_TEXTTYPE type, const MD_CHAR* text, MD_SIZE size); + int cbEnterBlock(int blockType, void* detail); + int cbLeaveBlock(int blockType, void* detail); + int cbEnterSpan(int spanType, void* detail); + int cbLeaveSpan(int spanType, void* detail); + int cbText(int textType, const char* text, unsigned size); private: QTextDocument *m_doc = nullptr; @@ -115,7 +114,7 @@ private: int m_tableRowCount = 0; int m_tableCol = -1; // because relative cell movements (e.g. m_cursor->movePosition(QTextCursor::NextCell)) don't work Features m_features; - MD_BLOCKTYPE m_blockType = MD_BLOCK_DOC; + int m_blockType = 0; bool m_emptyList = false; // true when the last thing we did was insertList bool m_imageSpan = false; }; From 040dd7fe26bfa34aae19e2db698ff0d69346ed56 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 26 Apr 2019 07:40:34 +0200 Subject: [PATCH 275/292] Markdown: fix several issues with lists and continuations Importer fixes: - the first list item after a heading doesn't keep the heading font - the first text fragment after a bullet is the bullet text, not a separate paragraph - detect continuation lines and append to the list item text - detect continuation paragraphs and indent them properly - indent nested list items properly - add a test for QTextMarkdownImporter Writer fixes: - after bullet items, continuation lines and paragraphs are indented - indentation of continuations isn't affected by checkboxes - add extra newlines between list items in "loose" lists - avoid writing triple newlines - enhance the test for QTextMarkdownWriter Change-Id: Ib1dda514832f6dc0cdad177aa9a423a7038ac8c6 Reviewed-by: Gatis Paeglis --- src/gui/text/qtextmarkdownimporter.cpp | 59 +++++++-- src/gui/text/qtextmarkdownimporter_p.h | 2 + src/gui/text/qtextmarkdownwriter.cpp | 107 +++++++++++++--- src/gui/text/qtextmarkdownwriter_p.h | 11 ++ .../data/headingBulletsContinuations.md | 28 ++++ .../qtextmarkdownimporter.pro | 7 + .../tst_qtextmarkdownimporter.cpp | 121 ++++++++++++++++++ .../text/qtextmarkdownwriter/data/example.md | 18 +-- .../tst_qtextmarkdownwriter.cpp | 104 +++++++++++++-- tests/auto/gui/text/text.pro | 1 + 10 files changed, 410 insertions(+), 48 deletions(-) create mode 100644 tests/auto/gui/text/qtextmarkdownimporter/data/headingBulletsContinuations.md create mode 100644 tests/auto/gui/text/qtextmarkdownimporter/qtextmarkdownimporter.pro create mode 100644 tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp index 2c520a71c9..a65d8f270e 100644 --- a/src/gui/text/qtextmarkdownimporter.cpp +++ b/src/gui/text/qtextmarkdownimporter.cpp @@ -52,6 +52,9 @@ QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY(lcMD, "qt.text.markdown") +static const QChar Newline = QLatin1Char('\n'); +static const QChar Space = QLatin1Char(' '); + // -------------------------------------------------------- // MD4C callback function wrappers @@ -141,18 +144,33 @@ int QTextMarkdownImporter::cbEnterBlock(int blockType, void *det) { m_blockType = blockType; switch (blockType) { - case MD_BLOCK_P: { - QTextBlockFormat blockFmt; - int margin = m_doc->defaultFont().pointSize() / 2; - blockFmt.setTopMargin(margin); - blockFmt.setBottomMargin(margin); - m_cursor->insertBlock(blockFmt, QTextCharFormat()); - } break; + case MD_BLOCK_P: + if (m_listStack.isEmpty()) { + QTextBlockFormat blockFmt; + int margin = m_doc->defaultFont().pointSize() / 2; + blockFmt.setTopMargin(margin); + blockFmt.setBottomMargin(margin); + m_cursor->insertBlock(blockFmt, QTextCharFormat()); + qCDebug(lcMD, "P"); + } else { + if (m_emptyListItem) { + qCDebug(lcMD, "LI text block at level %d -> BlockIndent %d", + m_listStack.count(), m_cursor->blockFormat().indent()); + m_emptyListItem = false; + } else { + qCDebug(lcMD, "P inside LI at level %d", m_listStack.count()); + QTextBlockFormat blockFmt; + blockFmt.setIndent(m_listStack.count()); + m_cursor->insertBlock(blockFmt, QTextCharFormat()); + } + } + break; case MD_BLOCK_CODE: { QTextBlockFormat blockFmt; QTextCharFormat charFmt; charFmt.setFont(m_monoFont); m_cursor->insertBlock(blockFmt, charFmt); + qCDebug(lcMD, "CODE"); } break; case MD_BLOCK_H: { MD_BLOCK_H_DETAIL *detail = static_cast(det); @@ -163,6 +181,7 @@ int QTextMarkdownImporter::cbEnterBlock(int blockType, void *det) charFmt.setFontWeight(QFont::Bold); blockFmt.setHeadingLevel(int(detail->level)); m_cursor->insertBlock(blockFmt, charFmt); + qCDebug(lcMD, "H%d", detail->level); } break; case MD_BLOCK_LI: { MD_BLOCK_LI_DETAIL *detail = static_cast(det); @@ -176,7 +195,10 @@ int QTextMarkdownImporter::cbEnterBlock(int blockType, void *det) list->add(m_cursor->block()); } m_cursor->setBlockFormat(bfmt); + qCDebug(lcMD) << (m_emptyList ? "LI (first in list)" : "LI"); m_emptyList = false; // Avoid insertBlock for the first item (because insertList already did that) + m_listItem = true; + m_emptyListItem = true; } break; case MD_BLOCK_UL: { MD_BLOCK_UL_DETAIL *detail = static_cast(det); @@ -193,6 +215,7 @@ int QTextMarkdownImporter::cbEnterBlock(int blockType, void *det) fmt.setStyle(QTextListFormat::ListDisc); break; } + qCDebug(lcMD, "UL %c level %d", detail->mark, m_listStack.count()); m_listStack.push(m_cursor->insertList(fmt)); m_emptyList = true; } break; @@ -202,6 +225,7 @@ int QTextMarkdownImporter::cbEnterBlock(int blockType, void *det) fmt.setIndent(m_listStack.count() + 1); fmt.setNumberSuffix(QChar::fromLatin1(detail->mark_delimiter)); fmt.setStyle(QTextListFormat::ListDecimal); + qCDebug(lcMD, "OL xx%d level %d", detail->mark_delimiter, m_listStack.count()); m_listStack.push(m_cursor->insertList(fmt)); m_emptyList = true; } break; @@ -265,6 +289,7 @@ int QTextMarkdownImporter::cbLeaveBlock(int blockType, void *detail) switch (blockType) { case MD_BLOCK_UL: case MD_BLOCK_OL: + qCDebug(lcMD, "list at level %d ended", m_listStack.count()); m_listStack.pop(); break; case MD_BLOCK_TR: { @@ -299,6 +324,14 @@ int QTextMarkdownImporter::cbLeaveBlock(int blockType, void *detail) m_currentTable = nullptr; m_cursor->movePosition(QTextCursor::End); break; + case MD_BLOCK_LI: + qCDebug(lcMD, "LI at level %d ended", m_listStack.count()); + m_listItem = false; + break; + case MD_BLOCK_CODE: + case MD_BLOCK_H: + m_cursor->setCharFormat(QTextCharFormat()); + break; default: break; } @@ -381,10 +414,10 @@ int QTextMarkdownImporter::cbText(int textType, const char *text, unsigned size) s = QString(QChar(0xFFFD)); // CommonMark-required replacement for null break; case MD_TEXT_BR: - s = QLatin1String("\n"); + s = QString(Newline); break; case MD_TEXT_SOFTBR: - s = QLatin1String(" "); + s = QString(Space); break; case MD_TEXT_CODE: // We'll see MD_SPAN_CODE too, which will set the char format, and that's enough. @@ -431,6 +464,14 @@ int QTextMarkdownImporter::cbText(int textType, const char *text, unsigned size) if (!s.isEmpty()) m_cursor->insertText(s); + if (m_cursor->currentList()) { + // The list item will indent the list item's text, so we don't need indentation on the block. + QTextBlockFormat blockFmt = m_cursor->blockFormat(); + blockFmt.setIndent(0); + m_cursor->setBlockFormat(blockFmt); + } + qCDebug(lcMD) << textType << "in block" << m_blockType << s << "in list?" << m_cursor->currentList() + << "indent" << m_cursor->blockFormat().indent(); return 0; // no error } diff --git a/src/gui/text/qtextmarkdownimporter_p.h b/src/gui/text/qtextmarkdownimporter_p.h index dee24a8e22..8ab119d051 100644 --- a/src/gui/text/qtextmarkdownimporter_p.h +++ b/src/gui/text/qtextmarkdownimporter_p.h @@ -116,6 +116,8 @@ private: Features m_features; int m_blockType = 0; bool m_emptyList = false; // true when the last thing we did was insertList + bool m_listItem = false; + bool m_emptyListItem = false; bool m_imageSpan = false; }; diff --git a/src/gui/text/qtextmarkdownwriter.cpp b/src/gui/text/qtextmarkdownwriter.cpp index 313d62bb8a..2f4c8587ad 100644 --- a/src/gui/text/qtextmarkdownwriter.cpp +++ b/src/gui/text/qtextmarkdownwriter.cpp @@ -46,12 +46,17 @@ #include "qtexttable.h" #include "qtextcursor.h" #include "qtextimagehandler_p.h" +#include "qloggingcategory.h" QT_BEGIN_NAMESPACE +Q_LOGGING_CATEGORY(lcMDW, "qt.text.markdown.writer") + static const QChar Space = QLatin1Char(' '); static const QChar Newline = QLatin1Char('\n'); +static const QChar LineBreak = QChar(0x2028); static const QChar Backtick = QLatin1Char('`'); +static const QChar Period = QLatin1Char('.'); QTextMarkdownWriter::QTextMarkdownWriter(QTextStream &stream, QTextDocument::MarkdownFeatures features) : m_stream(stream), m_features(features) @@ -93,6 +98,7 @@ void QTextMarkdownWriter::writeTable(const QAbstractTableModel &table) } m_stream << '|'<< Qt::endl; } + m_listInfo.clear(); } void QTextMarkdownWriter::writeFrame(const QTextFrame *frame) @@ -144,6 +150,7 @@ void QTextMarkdownWriter::writeFrame(const QTextFrame *frame) m_stream << Newline; } int endingCol = writeBlock(block, !table, table && tableRow == 0); + m_doubleNewlineWritten = false; if (table) { QTextTableCell cell = table->cellAt(block.position()); int paddingLen = -endingCol; @@ -158,14 +165,48 @@ void QTextMarkdownWriter::writeFrame(const QTextFrame *frame) m_stream << Newline; } else if (endingCol > 0) { m_stream << Newline << Newline; + m_doubleNewlineWritten = true; } lastWasList = block.textList(); } child = iterator.currentFrame(); ++iterator; } - if (table) + if (table) { m_stream << Newline << Newline; + m_doubleNewlineWritten = true; + } + m_listInfo.clear(); +} + +QTextMarkdownWriter::ListInfo QTextMarkdownWriter::listInfo(QTextList *list) +{ + if (!m_listInfo.contains(list)) { + // decide whether this list is loose or tight + ListInfo info; + info.loose = false; + if (list->count() > 1) { + QTextBlock first = list->item(0); + QTextBlock last = list->item(list->count() - 1); + QTextBlock next = first.next(); + while (next.isValid()) { + if (next == last) + break; + qCDebug(lcMDW) << "next block in list" << list << next.text() << "part of list?" << next.textList(); + if (!next.textList()) { + // If we find a continuation paragraph, this list is "loose" + // because it will need a blank line to separate that paragraph. + qCDebug(lcMDW) << "decided list beginning with" << first.text() << "is loose after" << next.text(); + info.loose = true; + break; + } + next = next.next(); + } + } + m_listInfo.insert(list, info); + return info; + } + return m_listInfo.value(list); } static int nearestWordWrapIndex(const QString &s, int before) @@ -211,7 +252,6 @@ static void maybeEscapeFirstChar(QString &s) int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ignoreFormat) { int ColumnLimit = 80; - int wrapIndent = 0; if (block.textList()) { // it's a list-item auto fmt = block.textList()->format(); const int listLevel = fmt.indent(); @@ -219,9 +259,18 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign QByteArray bullet = " "; bool numeric = false; switch (fmt.style()) { - case QTextListFormat::ListDisc: bullet = "-"; break; - case QTextListFormat::ListCircle: bullet = "*"; break; - case QTextListFormat::ListSquare: bullet = "+"; break; + case QTextListFormat::ListDisc: + bullet = "-"; + m_wrappedLineIndent = 2; + break; + case QTextListFormat::ListCircle: + bullet = "*"; + m_wrappedLineIndent = 2; + break; + case QTextListFormat::ListSquare: + bullet = "+"; + m_wrappedLineIndent = 2; + break; case QTextListFormat::ListStyleUndefined: break; case QTextListFormat::ListDecimal: case QTextListFormat::ListLowerAlpha: @@ -229,6 +278,7 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign case QTextListFormat::ListLowerRoman: case QTextListFormat::ListUpperRoman: numeric = true; + m_wrappedLineIndent = 4; break; } switch (block.blockFormat().marker()) { @@ -241,23 +291,36 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign default: break; } - QString prefix((listLevel - 1) * (numeric ? 4 : 2), Space); - if (numeric) - prefix += QString::number(number) + fmt.numberSuffix() + Space; - else + int indentFirstLine = (listLevel - 1) * (numeric ? 4 : 2); + m_wrappedLineIndent += indentFirstLine; + if (m_lastListIndent != listLevel && !m_doubleNewlineWritten && listInfo(block.textList()).loose) + m_stream << Newline; + m_lastListIndent = listLevel; + QString prefix(indentFirstLine, Space); + if (numeric) { + QString suffix = fmt.numberSuffix(); + if (suffix.isEmpty()) + suffix = QString(Period); + QString numberStr = QString::number(number) + suffix + Space; + if (numberStr.length() == 3) + numberStr += Space; + prefix += numberStr; + } else { prefix += QLatin1String(bullet) + Space; + } m_stream << prefix; - wrapIndent = prefix.length(); + } else if (!block.blockFormat().indent()) { + m_wrappedLineIndent = 0; } if (block.blockFormat().headingLevel()) m_stream << QByteArray(block.blockFormat().headingLevel(), '#') << ' '; - QString wrapIndentString(wrapIndent, Space); + QString wrapIndentString(m_wrappedLineIndent, Space); // It would be convenient if QTextStream had a lineCharPos() accessor, // to keep track of how many characters (not bytes) have been written on the current line, // but it doesn't. So we have to keep track with this col variable. - int col = wrapIndent; + int col = m_wrappedLineIndent; bool mono = false; bool startsOrEndsWithBacktick = false; bool bold = false; @@ -267,8 +330,16 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign QString backticks(Backtick); for (QTextBlock::Iterator frag = block.begin(); !frag.atEnd(); ++frag) { QString fragmentText = frag.fragment().text(); - while (fragmentText.endsWith(QLatin1Char('\n'))) + while (fragmentText.endsWith(Newline)) fragmentText.chop(1); + if (block.textList()) { //
  3. first line
    continuation
  4. + QString newlineIndent = QString(Newline) + QString(m_wrappedLineIndent, Space); + fragmentText.replace(QString(LineBreak), newlineIndent); + } else if (block.blockFormat().indent() > 0) { //
  5. first line

    continuation

  6. + m_stream << QString(m_wrappedLineIndent, Space); + } else { + fragmentText.replace(LineBreak, Newline); + } startsOrEndsWithBacktick |= fragmentText.startsWith(Backtick) || fragmentText.endsWith(Backtick); QTextCharFormat fmt = frag.fragment().charFormat(); if (fmt.isImageFormat()) { @@ -276,7 +347,7 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign QString s = QLatin1String("![image](") + ifmt.name() + QLatin1Char(')'); if (wrap && col + s.length() > ColumnLimit) { m_stream << Newline << wrapIndentString; - col = wrapIndent; + col = m_wrappedLineIndent; } m_stream << s; col += s.length(); @@ -285,7 +356,7 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign fmt.property(QTextFormat::AnchorHref).toString() + QLatin1Char(')'); if (wrap && col + s.length() > ColumnLimit) { m_stream << Newline << wrapIndentString; - col = wrapIndent; + col = m_wrappedLineIndent; } m_stream << s; col += s.length(); @@ -296,7 +367,7 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign if (!ignoreFormat) { if (monoFrag != mono) { if (monoFrag) - backticks = QString::fromLatin1(QByteArray(adjacentBackticksCount(fragmentText) + 1, '`')); + backticks = QString(adjacentBackticksCount(fragmentText) + 1, Backtick); markers += backticks; if (startsOrEndsWithBacktick) markers += Space; @@ -347,12 +418,12 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign m_stream << markers; col += markers.length(); } - if (col == wrapIndent) + if (col == m_wrappedLineIndent) maybeEscapeFirstChar(subfrag); m_stream << subfrag; if (breakingLine) { m_stream << Newline << wrapIndentString; - col = wrapIndent; + col = m_wrappedLineIndent; } else { col += subfrag.length(); } diff --git a/src/gui/text/qtextmarkdownwriter_p.h b/src/gui/text/qtextmarkdownwriter_p.h index 2a9388ca2d..250288bcff 100644 --- a/src/gui/text/qtextmarkdownwriter_p.h +++ b/src/gui/text/qtextmarkdownwriter_p.h @@ -70,9 +70,20 @@ public: int writeBlock(const QTextBlock &block, bool table, bool ignoreFormat); void writeFrame(const QTextFrame *frame); +private: + struct ListInfo { + bool loose; + }; + + ListInfo listInfo(QTextList *list); + private: QTextStream &m_stream; QTextDocument::MarkdownFeatures m_features; + QMap m_listInfo; + int m_wrappedLineIndent = 0; + int m_lastListIndent = 1; + bool m_doubleNewlineWritten = false; }; QT_END_NAMESPACE diff --git a/tests/auto/gui/text/qtextmarkdownimporter/data/headingBulletsContinuations.md b/tests/auto/gui/text/qtextmarkdownimporter/data/headingBulletsContinuations.md new file mode 100644 index 0000000000..99eb633d17 --- /dev/null +++ b/tests/auto/gui/text/qtextmarkdownimporter/data/headingBulletsContinuations.md @@ -0,0 +1,28 @@ +# heading +- bullet 1 + continuation line 1, indented via tab +- bullet 2 + continuation line 2, indented via 4 spaces +- bullet 3 + + continuation paragraph 3, indented via tab + + - bullet 3.1 + + continuation paragraph 3.1, indented via 4 spaces + + - bullet 3.2 + continuation line, indented via 2 tabs +- bullet 4 + + continuation paragraph 4, indented via 4 spaces + and continuing onto another line too + +- bullet 5 + + continuation paragraph 5, indented via 2 spaces and continuing onto another + line too + +- bullet 6 + +plain old paragraph at the end diff --git a/tests/auto/gui/text/qtextmarkdownimporter/qtextmarkdownimporter.pro b/tests/auto/gui/text/qtextmarkdownimporter/qtextmarkdownimporter.pro new file mode 100644 index 0000000000..3b63a67228 --- /dev/null +++ b/tests/auto/gui/text/qtextmarkdownimporter/qtextmarkdownimporter.pro @@ -0,0 +1,7 @@ +CONFIG += testcase +TARGET = tst_qtextmarkdownimporter +QT += core-private gui-private testlib +SOURCES += tst_qtextmarkdownimporter.cpp +TESTDATA += data/headingBulletsContinuations.md + +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp b/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp new file mode 100644 index 0000000000..2ede2e73ad --- /dev/null +++ b/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** 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 +#include +#include +#include +#include +#include +#include +#include + +#include + +// #define DEBUG_WRITE_HTML + +Q_LOGGING_CATEGORY(lcTests, "qt.text.tests") + +static const QChar LineBreak = QChar(0x2028); +static const QChar Tab = QLatin1Char('\t'); +static const QChar Space = QLatin1Char(' '); +static const QChar Period = QLatin1Char('.'); + +class tst_QTextMarkdownImporter : public QObject +{ + Q_OBJECT + +private slots: + void headingBulletsContinuations(); +}; + +void tst_QTextMarkdownImporter::headingBulletsContinuations() +{ + const QStringList expectedBlocks = QStringList() << + "" << // we could do without this blank line before the heading, but currently it happens + "heading" << + "bullet 1 continuation line 1, indented via tab" << + "bullet 2 continuation line 2, indented via 4 spaces" << + "bullet 3" << + "continuation paragraph 3, indented via tab" << + "bullet 3.1" << + "continuation paragraph 3.1, indented via 4 spaces" << + "bullet 3.2 continuation line, indented via 2 tabs" << + "bullet 4" << + "continuation paragraph 4, indented via 4 spaces and continuing onto another line too" << + "bullet 5" << + // indenting by only 2 spaces is perhaps non-standard but currently is OK + "continuation paragraph 5, indented via 2 spaces and continuing onto another line too" << + "bullet 6" << + "plain old paragraph at the end"; + + QFile f(QFINDTESTDATA("data/headingBulletsContinuations.md")); + QVERIFY(f.open(QFile::ReadOnly | QIODevice::Text)); + QString md = QString::fromUtf8(f.readAll()); + f.close(); + + QTextDocument doc; + QTextMarkdownImporter(QTextMarkdownImporter::DialectGitHub).import(&doc, md); + QTextFrame::iterator iterator = doc.rootFrame()->begin(); + QTextFrame *currentFrame = iterator.currentFrame(); + QStringList::const_iterator expectedIt = expectedBlocks.constBegin(); + int i = 0; + while (!iterator.atEnd()) { + // There are no child frames + QCOMPARE(iterator.currentFrame(), currentFrame); + // Check whether we got the right child block + QTextBlock block = iterator.currentBlock(); + QCOMPARE(block.text().contains(LineBreak), false); + QCOMPARE(block.text().contains(Tab), false); + QVERIFY(!block.text().startsWith(Space)); + int expectedIndentation = 0; + if (block.text().contains(QLatin1String("continuation paragraph"))) + expectedIndentation = (block.text().contains(Period) ? 2 : 1); + qCDebug(lcTests) << i << "child block" << block.text() << "indentation" << block.blockFormat().indent(); + QVERIFY(expectedIt != expectedBlocks.constEnd()); + QCOMPARE(block.text(), *expectedIt); + if (i > 2) + QCOMPARE(block.blockFormat().indent(), expectedIndentation); + ++iterator; + ++expectedIt; + ++i; + } + QCOMPARE(expectedIt, expectedBlocks.constEnd()); + +#ifdef DEBUG_WRITE_HTML + { + QFile out("/tmp/headingBulletsContinuations.html"); + out.open(QFile::WriteOnly); + out.write(doc.toHtml().toLatin1()); + out.close(); + } +#endif +} + +QTEST_MAIN(tst_QTextMarkdownImporter) +#include "tst_qtextmarkdownimporter.moc" diff --git a/tests/auto/gui/text/qtextmarkdownwriter/data/example.md b/tests/auto/gui/text/qtextmarkdownwriter/data/example.md index 3c63f209a2..0c3f34e09d 100644 --- a/tests/auto/gui/text/qtextmarkdownwriter/data/example.md +++ b/tests/auto/gui/text/qtextmarkdownwriter/data/example.md @@ -27,8 +27,8 @@ text layout changes.* Different kinds of lists can be included in rich text documents. Standard bullet lists can be nested, using different symbols for each level of the list: -* Disc symbols are typically used for top-level list items. - - Circle symbols can be used to distinguish between items in lower-level +- Disc symbols are typically used for top-level list items. + * Circle symbols can be used to distinguish between items in lower-level lists. + Square symbols provide a reasonable alternative to discs and circles. @@ -36,13 +36,13 @@ Ordered lists can be created that can be used for tables of contents. Different characters can be used to enumerate items, and we can use both Roman and Arabic numerals in the same list structure: -1. Introduction -2. Qt Tools - 1) Qt Assistant - 2) Qt Designer - 1. Form Editor - 2. Component Architecture - 3) Qt Linguist +1. Introduction +2. Qt Tools + 1) Qt Assistant + 2) Qt Designer + 1. Form Editor + 2. Component Architecture + 3) Qt Linguist The list will automatically be renumbered if you add or remove items. *Try adding new sections to the above list or removing existing item to see the diff --git a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp index bf7c9708de..dca6d90a48 100644 --- a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp +++ b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp @@ -50,6 +50,7 @@ private slots: void testWriteParagraph_data(); void testWriteParagraph(); void testWriteList(); + void testWriteNestedBulletLists_data(); void testWriteNestedBulletLists(); void testWriteNestedNumericLists(); void testWriteTable(); @@ -122,9 +123,44 @@ void tst_QTextMarkdownWriter::testWriteList() "- ListItem 1\n- ListItem 2\n")); } +void tst_QTextMarkdownWriter::testWriteNestedBulletLists_data() +{ + QTest::addColumn("checkbox"); + QTest::addColumn("checked"); + QTest::addColumn("continuationLine"); + QTest::addColumn("continuationParagraph"); + QTest::addColumn("expectedOutput"); + + QTest::newRow("plain bullets") << false << false << false << false << + "- ListItem 1\n * ListItem 2\n + ListItem 3\n- ListItem 4\n * ListItem 5\n"; + QTest::newRow("bullets with continuation lines") << false << false << true << false << + "- ListItem 1\n * ListItem 2\n + ListItem 3 with text that won't fit on one line and thus needs a\n continuation\n- ListItem 4\n * ListItem 5 with text that won't fit on one line and thus needs a\n continuation\n"; + QTest::newRow("bullets with continuation paragraphs") << false << false << false << true << + "- ListItem 1\n\n * ListItem 2\n + ListItem 3\n\n continuation\n\n- ListItem 4\n\n * ListItem 5\n\n continuation\n\n"; + QTest::newRow("unchecked") << true << false << false << false << + "- [ ] ListItem 1\n * [ ] ListItem 2\n + [ ] ListItem 3\n- [ ] ListItem 4\n * [ ] ListItem 5\n"; + QTest::newRow("checked") << true << true << false << false << + "- [x] ListItem 1\n * [x] ListItem 2\n + [x] ListItem 3\n- [x] ListItem 4\n * [x] ListItem 5\n"; + QTest::newRow("checked with continuation lines") << true << true << true << false << + "- [x] ListItem 1\n * [x] ListItem 2\n + [x] ListItem 3 with text that won't fit on one line and thus needs a\n continuation\n- [x] ListItem 4\n * [x] ListItem 5 with text that won't fit on one line and thus needs a\n continuation\n"; + QTest::newRow("checked with continuation paragraphs") << true << true << false << true << + "- [x] ListItem 1\n\n * [x] ListItem 2\n + [x] ListItem 3\n\n continuation\n\n- [x] ListItem 4\n\n * [x] ListItem 5\n\n continuation\n\n"; +} + void tst_QTextMarkdownWriter::testWriteNestedBulletLists() { + QFETCH(bool, checkbox); + QFETCH(bool, checked); + QFETCH(bool, continuationParagraph); + QFETCH(bool, continuationLine); + QFETCH(QString, expectedOutput); + QTextCursor cursor(document); + QTextBlockFormat blockFmt = cursor.blockFormat(); + if (checkbox) { + blockFmt.setMarker(checked ? QTextBlockFormat::Checked : QTextBlockFormat::Unchecked); + cursor.setBlockFormat(blockFmt); + } QTextList *list1 = cursor.createList(QTextListFormat::ListDisc); cursor.insertText("ListItem 1"); @@ -140,18 +176,42 @@ void tst_QTextMarkdownWriter::testWriteNestedBulletLists() fmt3.setStyle(QTextListFormat::ListSquare); fmt3.setIndent(3); cursor.insertList(fmt3); - cursor.insertText("ListItem 3"); + cursor.insertText(continuationLine ? + "ListItem 3 with text that won't fit on one line and thus needs a continuation" : + "ListItem 3"); + if (continuationParagraph) { + QTextBlockFormat blockFmt; + blockFmt.setIndent(2); + cursor.insertBlock(blockFmt); + cursor.insertText("continuation"); + } - cursor.insertBlock(); + cursor.insertBlock(blockFmt); cursor.insertText("ListItem 4"); list1->add(cursor.block()); cursor.insertBlock(); - cursor.insertText("ListItem 5"); + cursor.insertText(continuationLine ? + "ListItem 5 with text that won't fit on one line and thus needs a continuation" : + "ListItem 5"); list2->add(cursor.block()); + if (continuationParagraph) { + QTextBlockFormat blockFmt; + blockFmt.setIndent(2); + cursor.insertBlock(blockFmt); + cursor.insertText("continuation"); + } - QCOMPARE(documentToUnixMarkdown(), QString::fromLatin1( - "- ListItem 1\n * ListItem 2\n + ListItem 3\n- ListItem 4\n * ListItem 5\n")); + QString output = documentToUnixMarkdown(); +#ifdef DEBUG_WRITE_OUTPUT + { + QFile out("/tmp/" + QLatin1String(QTest::currentDataTag()) + ".md"); + out.open(QFile::WriteOnly); + out.write(output.toUtf8()); + out.close(); + } +#endif + QCOMPARE(documentToUnixMarkdown(), expectedOutput); } void tst_QTextMarkdownWriter::testWriteNestedNumericLists() @@ -185,7 +245,7 @@ void tst_QTextMarkdownWriter::testWriteNestedNumericLists() // There's no QTextList API to set the starting number so we hard-coded all lists to start at 1 (QTBUG-65384) QCOMPARE(documentToUnixMarkdown(), QString::fromLatin1( - "1 ListItem 1\n 1) ListItem 2\n 1 ListItem 3\n2 ListItem 4\n 2) ListItem 5\n")); + "1. ListItem 1\n 1) ListItem 2\n 1. ListItem 3\n2. ListItem 4\n 2) ListItem 5\n")); } void tst_QTextMarkdownWriter::testWriteTable() @@ -312,8 +372,8 @@ void tst_QTextMarkdownWriter::rewriteDocument() void tst_QTextMarkdownWriter::fromHtml_data() { - QTest::addColumn("input"); - QTest::addColumn("output"); + QTest::addColumn("expectedInput"); + QTest::addColumn("expectedOutput"); QTest::newRow("long URL") << "https://www.example.com/dir/subdir/subsubdir/subsubsubdir/subsubsubsubdir/subsubsubsubsubdir/" << @@ -329,6 +389,15 @@ void tst_QTextMarkdownWriter::fromHtml_data() QTest::newRow("escaped hyphen after newline") << "The first sentence of this paragraph holds 80 characters, then there's a minus. - This is wrapped, but is not a bullet point." << "The first sentence of this paragraph holds 80 characters, then there's a minus.\n\\- This is wrapped, but is *not* a bullet point.\n\n"; + QTest::newRow("list items with indented continuations") << + "
    • bullet

      continuation paragraph

    • another bullet
      continuation line
    " << + "- bullet\n\n continuation paragraph\n\n- another bullet\n continuation line\n"; + QTest::newRow("nested list items with continuations") << + "
    • bullet

      continuation paragraph

    • another bullet
      continuation line
      • bullet

        continuation paragraph

      • another bullet
        continuation line
    " << + "- bullet\n\n continuation paragraph\n\n- another bullet\n continuation line\n\n - bullet\n\n continuation paragraph\n\n - another bullet\n continuation line\n"; + QTest::newRow("nested ordered list items with continuations") << + "
    1. item

      continuation paragraph

    2. another item
      continuation line
      1. item

        continuation paragraph

      2. another item
        continuation line
    3. another
    4. another
    " << + "1. item\n\n continuation paragraph\n\n2. another item\n continuation line\n\n 1. item\n\n continuation paragraph\n\n 2. another item\n continuation line\n\n3. another\n4. another\n"; // TODO // QTest::newRow("escaped number and paren after double newline") << // "

    (The first sentence of this paragraph is a line, the next paragraph has a number

    13) but that's not part of an ordered list" << @@ -340,11 +409,22 @@ void tst_QTextMarkdownWriter::fromHtml_data() void tst_QTextMarkdownWriter::fromHtml() { - QFETCH(QString, input); - QFETCH(QString, output); + QFETCH(QString, expectedInput); + QFETCH(QString, expectedOutput); - document->setHtml(input); - QCOMPARE(documentToUnixMarkdown(), output); + document->setHtml(expectedInput); + QString output = documentToUnixMarkdown(); + +#ifdef DEBUG_WRITE_OUTPUT + { + QFile out("/tmp/" + QLatin1String(QTest::currentDataTag()) + ".md"); + out.open(QFile::WriteOnly); + out.write(output.toUtf8()); + out.close(); + } +#endif + + QCOMPARE(output, expectedOutput); } QString tst_QTextMarkdownWriter::documentToUnixMarkdown() diff --git a/tests/auto/gui/text/text.pro b/tests/auto/gui/text/text.pro index a98debe35c..794d9ea8d3 100644 --- a/tests/auto/gui/text/text.pro +++ b/tests/auto/gui/text/text.pro @@ -28,6 +28,7 @@ SUBDIRS=\ win32:SUBDIRS -= qtextpiecetable +qtConfig(textmarkdownreader): SUBDIRS += qtextmarkdownimporter qtConfig(textmarkdownwriter): SUBDIRS += qtextmarkdownwriter !qtConfig(private_tests): SUBDIRS -= \ From 76716c4a9adc3f9aeb251d3ebe4d1d0be38b97ee Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 26 Apr 2019 08:29:07 +0200 Subject: [PATCH 276/292] Markdown: deal with horizontal rules (thematic breaks) Change-Id: I14d4bcfe1a6c3bd87d1328f0abb81b2138545e4e Reviewed-by: Gatis Paeglis --- src/gui/text/qtextmarkdownimporter.cpp | 3 +- src/gui/text/qtextmarkdownwriter.cpp | 3 ++ .../data/thematicBreaks.md | 17 ++++++++ .../qtextmarkdownimporter.pro | 3 +- .../tst_qtextmarkdownimporter.cpp | 42 +++++++++++++++++++ .../tst_qtextmarkdownwriter.cpp | 3 ++ 6 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 tests/auto/gui/text/qtextmarkdownimporter/data/thematicBreaks.md diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp index a65d8f270e..5cee01d932 100644 --- a/src/gui/text/qtextmarkdownimporter.cpp +++ b/src/gui/text/qtextmarkdownimporter.cpp @@ -273,7 +273,8 @@ int QTextMarkdownImporter::cbEnterBlock(int blockType, void *det) m_currentTable = m_cursor->insertTable(1, 1); // we don't know the dimensions yet break; case MD_BLOCK_HR: { - QTextBlockFormat blockFmt = m_cursor->blockFormat(); + qCDebug(lcMD, "HR"); + QTextBlockFormat blockFmt; blockFmt.setProperty(QTextFormat::BlockTrailingHorizontalRulerWidth, 1); m_cursor->insertBlock(blockFmt, QTextCharFormat()); } break; diff --git a/src/gui/text/qtextmarkdownwriter.cpp b/src/gui/text/qtextmarkdownwriter.cpp index 2f4c8587ad..0634d324b1 100644 --- a/src/gui/text/qtextmarkdownwriter.cpp +++ b/src/gui/text/qtextmarkdownwriter.cpp @@ -309,6 +309,9 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign prefix += QLatin1String(bullet) + Space; } m_stream << prefix; + } else if (block.blockFormat().hasProperty(QTextFormat::BlockTrailingHorizontalRulerWidth)) { + m_stream << "- - -\n"; // unambiguous horizontal rule, not an underline under a heading + return 0; } else if (!block.blockFormat().indent()) { m_wrappedLineIndent = 0; } diff --git a/tests/auto/gui/text/qtextmarkdownimporter/data/thematicBreaks.md b/tests/auto/gui/text/qtextmarkdownimporter/data/thematicBreaks.md new file mode 100644 index 0000000000..7a0d5388ad --- /dev/null +++ b/tests/auto/gui/text/qtextmarkdownimporter/data/thematicBreaks.md @@ -0,0 +1,17 @@ +Heading +------- +*** +stars +- bullet + ** not a bullet or a rule, just two stars +- [ ] unchecked + + --- indented too far, so not a rule +* * * +stars with tabs between +*** +stars with whitespace after +--- +hyphens with whitespace after +_____ +underscores with whitespace after diff --git a/tests/auto/gui/text/qtextmarkdownimporter/qtextmarkdownimporter.pro b/tests/auto/gui/text/qtextmarkdownimporter/qtextmarkdownimporter.pro index 3b63a67228..7afc807c9b 100644 --- a/tests/auto/gui/text/qtextmarkdownimporter/qtextmarkdownimporter.pro +++ b/tests/auto/gui/text/qtextmarkdownimporter/qtextmarkdownimporter.pro @@ -2,6 +2,7 @@ CONFIG += testcase TARGET = tst_qtextmarkdownimporter QT += core-private gui-private testlib SOURCES += tst_qtextmarkdownimporter.cpp -TESTDATA += data/headingBulletsContinuations.md +TESTDATA += \ + data/thematicBreaks.md \ DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp b/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp index 2ede2e73ad..8f51a7a474 100644 --- a/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp +++ b/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp @@ -52,6 +52,7 @@ class tst_QTextMarkdownImporter : public QObject private slots: void headingBulletsContinuations(); + void thematicBreaks(); }; void tst_QTextMarkdownImporter::headingBulletsContinuations() @@ -117,5 +118,46 @@ void tst_QTextMarkdownImporter::headingBulletsContinuations() #endif } +void tst_QTextMarkdownImporter::thematicBreaks() +{ + int horizontalRuleCount = 0; + int textLinesCount = 0; + + QFile f(QFINDTESTDATA("data/thematicBreaks.md")); + QVERIFY(f.open(QFile::ReadOnly | QIODevice::Text)); + QString md = QString::fromUtf8(f.readAll()); + f.close(); + + QTextDocument doc; + QTextMarkdownImporter(QTextMarkdownImporter::DialectGitHub).import(&doc, md); + QTextFrame::iterator iterator = doc.rootFrame()->begin(); + QTextFrame *currentFrame = iterator.currentFrame(); + int i = 0; + while (!iterator.atEnd()) { + // There are no child frames + QCOMPARE(iterator.currentFrame(), currentFrame); + // Check whether the block is text or a horizontal rule + QTextBlock block = iterator.currentBlock(); + if (block.blockFormat().hasProperty(QTextFormat::BlockTrailingHorizontalRulerWidth)) + ++horizontalRuleCount; + else if (!block.text().isEmpty()) + ++textLinesCount; + qCDebug(lcTests) << i << (block.blockFormat().hasProperty(QTextFormat::BlockTrailingHorizontalRulerWidth) ? QLatin1String("- - -") : block.text()); + ++iterator; + ++i; + } + QCOMPARE(horizontalRuleCount, 5); + QCOMPARE(textLinesCount, 9); + +#ifdef DEBUG_WRITE_HTML + { + QFile out("/tmp/thematicBreaks.html"); + out.open(QFile::WriteOnly); + out.write(doc.toHtml().toLatin1()); + out.close(); + } +#endif +} + QTEST_MAIN(tst_QTextMarkdownImporter) #include "tst_qtextmarkdownimporter.moc" diff --git a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp index dca6d90a48..4fbc64e408 100644 --- a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp +++ b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp @@ -398,6 +398,9 @@ void tst_QTextMarkdownWriter::fromHtml_data() QTest::newRow("nested ordered list items with continuations") << "
    1. item

      continuation paragraph

    2. another item
      continuation line
      1. item

        continuation paragraph

      2. another item
        continuation line
    3. another
    4. another
    " << "1. item\n\n continuation paragraph\n\n2. another item\n continuation line\n\n 1. item\n\n continuation paragraph\n\n 2. another item\n continuation line\n\n3. another\n4. another\n"; + QTest::newRow("thematic break") << + "something
    something else" << + "something\n\n- - -\nsomething else\n\n"; // TODO // QTest::newRow("escaped number and paren after double newline") << // "

    (The first sentence of this paragraph is a line, the next paragraph has a number

    13) but that's not part of an ordered list" << From 82b26444a456d4d5ddf5f483b7766977659bee35 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 7 May 2019 17:49:32 +0200 Subject: [PATCH 277/292] Change QTextMarkdownWriter to pass by const pointer and QAIM - QObjects are always passed by pointer not by reference, by convention - writeTable() takes QAIM rather than QATM to make testing via QStandardItemModel possible in the future Change-Id: I5bc6b8cd9709da4fb5d57d98fa22e0cb34360944 Reviewed-by: Gatis Paeglis --- src/gui/text/qtextdocument.cpp | 2 +- src/gui/text/qtextdocumentwriter.cpp | 2 +- src/gui/text/qtextmarkdownwriter.cpp | 26 +++++++++---------- src/gui/text/qtextmarkdownwriter_p.h | 4 +-- .../tst_qtextmarkdownwriter.cpp | 2 +- .../itemviews/qtableview/tst_qtableview.cpp | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 0a59bfb838..b5ff72e706 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -3301,7 +3301,7 @@ QString QTextDocument::toMarkdown(QTextDocument::MarkdownFeatures features) cons QString ret; QTextStream s(&ret); QTextMarkdownWriter w(s, features); - if (w.writeAll(*this)) + if (w.writeAll(this)) return ret; return QString(); } diff --git a/src/gui/text/qtextdocumentwriter.cpp b/src/gui/text/qtextdocumentwriter.cpp index c82ff873cd..193d2c0dd3 100644 --- a/src/gui/text/qtextdocumentwriter.cpp +++ b/src/gui/text/qtextdocumentwriter.cpp @@ -278,7 +278,7 @@ bool QTextDocumentWriter::write(const QTextDocument *document) } QTextStream s(d->device); QTextMarkdownWriter writer(s, QTextDocument::MarkdownDialectGitHub); - return writer.writeAll(*document); + return writer.writeAll(document); } #endif // textmarkdownwriter diff --git a/src/gui/text/qtextmarkdownwriter.cpp b/src/gui/text/qtextmarkdownwriter.cpp index 0634d324b1..a445ee7e83 100644 --- a/src/gui/text/qtextmarkdownwriter.cpp +++ b/src/gui/text/qtextmarkdownwriter.cpp @@ -63,26 +63,26 @@ QTextMarkdownWriter::QTextMarkdownWriter(QTextStream &stream, QTextDocument::Mar { } -bool QTextMarkdownWriter::writeAll(const QTextDocument &document) +bool QTextMarkdownWriter::writeAll(const QTextDocument *document) { - writeFrame(document.rootFrame()); + writeFrame(document->rootFrame()); return true; } -void QTextMarkdownWriter::writeTable(const QAbstractTableModel &table) +void QTextMarkdownWriter::writeTable(const QAbstractItemModel *table) { - QVector tableColumnWidths(table.columnCount()); - for (int col = 0; col < table.columnCount(); ++col) { - tableColumnWidths[col] = table.headerData(col, Qt::Horizontal).toString().length(); - for (int row = 0; row < table.rowCount(); ++row) { + QVector tableColumnWidths(table->columnCount()); + for (int col = 0; col < table->columnCount(); ++col) { + tableColumnWidths[col] = table->headerData(col, Qt::Horizontal).toString().length(); + for (int row = 0; row < table->rowCount(); ++row) { tableColumnWidths[col] = qMax(tableColumnWidths[col], - table.data(table.index(row, col)).toString().length()); + table->data(table->index(row, col)).toString().length()); } } // write the header and separator - for (int col = 0; col < table.columnCount(); ++col) { - QString s = table.headerData(col, Qt::Horizontal).toString(); + for (int col = 0; col < table->columnCount(); ++col) { + QString s = table->headerData(col, Qt::Horizontal).toString(); m_stream << "|" << s << QString(tableColumnWidths[col] - s.length(), Space); } m_stream << "|" << Qt::endl; @@ -91,9 +91,9 @@ void QTextMarkdownWriter::writeTable(const QAbstractTableModel &table) m_stream << '|'<< Qt::endl; // write the body - for (int row = 0; row < table.rowCount(); ++row) { - for (int col = 0; col < table.columnCount(); ++col) { - QString s = table.data(table.index(row, col)).toString(); + for (int row = 0; row < table->rowCount(); ++row) { + for (int col = 0; col < table->columnCount(); ++col) { + QString s = table->data(table->index(row, col)).toString(); m_stream << "|" << s << QString(tableColumnWidths[col] - s.length(), Space); } m_stream << '|'<< Qt::endl; diff --git a/src/gui/text/qtextmarkdownwriter_p.h b/src/gui/text/qtextmarkdownwriter_p.h index 250288bcff..4c07bad2e7 100644 --- a/src/gui/text/qtextmarkdownwriter_p.h +++ b/src/gui/text/qtextmarkdownwriter_p.h @@ -64,8 +64,8 @@ class Q_GUI_EXPORT QTextMarkdownWriter { public: QTextMarkdownWriter(QTextStream &stream, QTextDocument::MarkdownFeatures features); - bool writeAll(const QTextDocument &document); - void writeTable(const QAbstractTableModel &table); + bool writeAll(const QTextDocument *document); + void writeTable(const QAbstractItemModel *table); int writeBlock(const QTextBlock &block, bool table, bool ignoreFormat); void writeFrame(const QTextFrame *frame); diff --git a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp index 4fbc64e408..3d77ccd9d8 100644 --- a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp +++ b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp @@ -435,7 +435,7 @@ QString tst_QTextMarkdownWriter::documentToUnixMarkdown() QString ret; QTextStream ts(&ret, QIODevice::WriteOnly); QTextMarkdownWriter writer(ts, QTextDocument::MarkdownDialectGitHub); - writer.writeAll(*document); + writer.writeAll(document); return ret; } diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp index e7822ef7de..bf87408056 100644 --- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp +++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp @@ -4579,7 +4579,7 @@ void tst_QTableView::markdownWriter() { QTextStream stream(&md); QTextMarkdownWriter writer(stream, QTextDocument::MarkdownDialectGitHub); - writer.writeTable(model); + writer.writeTable(&model); } #ifdef DEBUG_WRITE_OUTPUT From 7dd71e812542c561a00dd792d314843a81c5687c Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 26 Apr 2019 08:12:18 +0200 Subject: [PATCH 278/292] Markdown: blockquotes, code blocks, and generalized nesting Can now detect nested quotes and code blocks inside quotes, and can rewrite the markdown too. QTextHtmlParser sets hard-coded left and right margins, so we need to do the same to be able to read HTML and write markdown, or vice-versa, and to ensure that all views (QTextEdit, QTextBrowser, QML Text etc.) will render it with margins. But now we add a semantic memory too: BlockQuoteLevel is similar to HeadingLevel, which was added in 310daae53926628f80c08e4415b94b90ad525c8f to preserve H1..H6 heading levels, because detecting it via font size didn't make sense in QTextMarkdownWriter. Likewise detecting quote level by its margins didn't make sense; markdown supports nesting quotes; and indenting nested quotes via 40 pixels may be a bit too much, so we should consider it subject to change (and perhaps be able to change it via CSS later on). Since we're adding BlockQuoteLevel and depending on it in QTextMarkdownWriter, it's necessary to set it in QTextHtmlParser to enable HTML->markdown conversion. (But so far, nested blockquotes in HTML are not supported.) Quotes (and nested quotes) can contain indented code blocks, but it seems the reverse is not true (according to https://spec.commonmark.org/0.29/#example-201 ) Quotes can contain fenced code blocks. Quotes can contain lists. Nested lists can be interrupted with nested code blocks and nested quotes. So far the writer assumes all code blocks are the indented type. It will be necessary to add another attribute to remember whether the code block is indented or fenced (assuming that's necessary). Fenced code blocks would work better for writing inside block quotes and list items because the fence is less ambiguous than the indent. Postponing cursor->insertBlock() as long as possible helps with nesting. cursor->insertBlock() needs to be done "just in time" before inserting text that will go in the block. The block and char formats aren't necessarily known until that time. When a nested block (such as a nested quote) ends, the context reverts to the previous block format, which then needs to be re-determined and set before we insert text into the outer block; but if no text will be inserted, no new block is necessary. But we can't use QTextBlockFormat itself as storage, because for some reason bullets become very "sticky" and it becomes impossible to have plain continuation paragraphs inside list items: they all get bullets. Somehow QTextBlockFormat remembers, if we copy it. But we can create a new one each time and it's OK. Change-Id: Icd0529eb90d2b6a3cb57f0104bf78a7be81ede52 Reviewed-by: Gatis Paeglis --- src/gui/text/qtextformat.h | 4 +- src/gui/text/qtexthtmlparser.cpp | 1 + src/gui/text/qtextmarkdownimporter.cpp | 103 ++++++++++++++---- src/gui/text/qtextmarkdownimporter_p.h | 8 ++ src/gui/text/qtextmarkdownwriter.cpp | 58 ++++++---- src/gui/text/qtextmarkdownwriter_p.h | 1 + .../qtextmarkdownimporter.pro | 1 + .../qtextmarkdownwriter/data/blockquotes.md | 39 +++++++ .../qtextmarkdownwriter.pro | 4 +- .../tst_qtextmarkdownwriter.cpp | 17 ++- 10 files changed, 191 insertions(+), 45 deletions(-) create mode 100644 tests/auto/gui/text/qtextmarkdownwriter/data/blockquotes.md diff --git a/src/gui/text/qtextformat.h b/src/gui/text/qtextformat.h index 1eb52a379c..a631309ae0 100644 --- a/src/gui/text/qtextformat.h +++ b/src/gui/text/qtextformat.h @@ -176,7 +176,9 @@ public: BlockNonBreakableLines = 0x1050, BlockTrailingHorizontalRulerWidth = 0x1060, HeadingLevel = 0x1070, - BlockMarker = 0x1080, + BlockQuoteLevel = 0x1080, + BlockCodeLanguage = 0x1090, + BlockMarker = 0x10A0, // character properties FirstFontProperty = 0x1FE0, diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp index 895232e4c7..37051502fa 100644 --- a/src/gui/text/qtexthtmlparser.cpp +++ b/src/gui/text/qtexthtmlparser.cpp @@ -1125,6 +1125,7 @@ void QTextHtmlParserNode::initializeProperties(const QTextHtmlParserNode *parent margin[QTextHtmlParser::MarginBottom] = 12; margin[QTextHtmlParser::MarginLeft] = 40; margin[QTextHtmlParser::MarginRight] = 40; + blockFormat.setProperty(QTextFormat::BlockQuoteLevel, 1); break; case Html_dl: margin[QTextHtmlParser::MarginTop] = 8; diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp index 5cee01d932..d8ffec2496 100644 --- a/src/gui/text/qtextmarkdownimporter.cpp +++ b/src/gui/text/qtextmarkdownimporter.cpp @@ -55,6 +55,9 @@ Q_LOGGING_CATEGORY(lcMD, "qt.text.markdown") static const QChar Newline = QLatin1Char('\n'); static const QChar Space = QLatin1Char(' '); +// TODO maybe eliminate the margins after all views recognize BlockQuoteLevel, CSS can format it, etc. +static const int BlockQuoteIndent = 40; // pixels, same as in QTextHtmlParserNode::initializeProperties + // -------------------------------------------------------- // MD4C callback function wrappers @@ -131,6 +134,7 @@ void QTextMarkdownImporter::import(QTextDocument *doc, const QString &markdown) nullptr // syntax }; m_doc = doc; + m_paragraphMargin = m_doc->defaultFont().pointSize() * 2 / 3; m_cursor = new QTextCursor(doc); doc->clear(); qCDebug(lcMD) << "default font" << doc->defaultFont() << "mono font" << m_monoFont; @@ -146,11 +150,7 @@ int QTextMarkdownImporter::cbEnterBlock(int blockType, void *det) switch (blockType) { case MD_BLOCK_P: if (m_listStack.isEmpty()) { - QTextBlockFormat blockFmt; - int margin = m_doc->defaultFont().pointSize() / 2; - blockFmt.setTopMargin(margin); - blockFmt.setBottomMargin(margin); - m_cursor->insertBlock(blockFmt, QTextCharFormat()); + m_needsInsertBlock = true; qCDebug(lcMD, "P"); } else { if (m_emptyListItem) { @@ -159,18 +159,25 @@ int QTextMarkdownImporter::cbEnterBlock(int blockType, void *det) m_emptyListItem = false; } else { qCDebug(lcMD, "P inside LI at level %d", m_listStack.count()); - QTextBlockFormat blockFmt; - blockFmt.setIndent(m_listStack.count()); - m_cursor->insertBlock(blockFmt, QTextCharFormat()); + m_needsInsertBlock = true; } } break; + case MD_BLOCK_QUOTE: { + ++m_blockQuoteDepth; + qCDebug(lcMD, "QUOTE level %d", m_blockQuoteDepth); + break; + } case MD_BLOCK_CODE: { - QTextBlockFormat blockFmt; - QTextCharFormat charFmt; - charFmt.setFont(m_monoFont); - m_cursor->insertBlock(blockFmt, charFmt); - qCDebug(lcMD, "CODE"); + MD_BLOCK_CODE_DETAIL *detail = static_cast(det); + m_codeBlock = true; + m_blockCodeLanguage = QLatin1String(detail->lang.text, int(detail->lang.size)); + QString info = QLatin1String(detail->info.text, int(detail->info.size)); + m_needsInsertBlock = true; + if (m_blockQuoteDepth) + qCDebug(lcMD, "CODE lang '%s' info '%s' inside QUOTE %d", qPrintable(m_blockCodeLanguage), qPrintable(info), m_blockQuoteDepth); + else + qCDebug(lcMD, "CODE lang '%s' info '%s'", qPrintable(m_blockCodeLanguage), qPrintable(info)); } break; case MD_BLOCK_H: { MD_BLOCK_H_DETAIL *detail = static_cast(det); @@ -180,10 +187,12 @@ int QTextMarkdownImporter::cbEnterBlock(int blockType, void *det) charFmt.setProperty(QTextFormat::FontSizeAdjustment, sizeAdjustment); charFmt.setFontWeight(QFont::Bold); blockFmt.setHeadingLevel(int(detail->level)); + m_needsInsertBlock = false; m_cursor->insertBlock(blockFmt, charFmt); qCDebug(lcMD, "H%d", detail->level); } break; case MD_BLOCK_LI: { + m_needsInsertBlock = false; MD_BLOCK_LI_DETAIL *detail = static_cast(det); QTextList *list = m_listStack.top(); QTextBlockFormat bfmt = list->item(list->count() - 1).blockFormat(); @@ -316,9 +325,9 @@ int QTextMarkdownImporter::cbLeaveBlock(int blockType, void *detail) } } break; case MD_BLOCK_QUOTE: { - QTextBlockFormat blockFmt = m_cursor->blockFormat(); - blockFmt.setIndent(1); - m_cursor->setBlockFormat(blockFmt); + qCDebug(lcMD, "QUOTE level %d ended", m_blockQuoteDepth); + --m_blockQuoteDepth; + m_needsInsertBlock = true; } break; case MD_BLOCK_TABLE: qCDebug(lcMD) << "table ended with" << m_currentTable->columns() << "cols and" << m_currentTable->rows() << "rows"; @@ -329,7 +338,15 @@ int QTextMarkdownImporter::cbLeaveBlock(int blockType, void *detail) qCDebug(lcMD, "LI at level %d ended", m_listStack.count()); m_listItem = false; break; - case MD_BLOCK_CODE: + case MD_BLOCK_CODE: { + m_codeBlock = false; + m_blockCodeLanguage.clear(); + if (m_blockQuoteDepth) + qCDebug(lcMD, "CODE ended inside QUOTE %d", m_blockQuoteDepth); + else + qCDebug(lcMD, "CODE ended"); + m_needsInsertBlock = true; + } break; case MD_BLOCK_H: m_cursor->setCharFormat(QTextCharFormat()); break; @@ -365,6 +382,8 @@ int QTextMarkdownImporter::cbEnterSpan(int spanType, void *det) QString title = QString::fromUtf8(detail->title.text, int(detail->title.size)); QTextImageFormat img; img.setName(src); + if (m_needsInsertBlock) + insertBlock(); qCDebug(lcMD) << "image" << src << "title" << title << "relative to" << m_doc->baseUrl(); m_cursor->insertImage(img); break; @@ -377,6 +396,8 @@ int QTextMarkdownImporter::cbEnterSpan(int spanType, void *det) break; } m_spanFormatStack.push(charFmt); + qCDebug(lcMD) << spanType << "setCharFormat" << charFmt.font().family() << charFmt.fontWeight() + << (charFmt.fontItalic() ? "italic" : "") << charFmt.foreground().color().name(); m_cursor->setCharFormat(charFmt); return 0; // no error } @@ -391,6 +412,8 @@ int QTextMarkdownImporter::cbLeaveSpan(int spanType, void *detail) charFmt = m_spanFormatStack.top(); } m_cursor->setCharFormat(charFmt); + qCDebug(lcMD) << spanType << "setCharFormat" << charFmt.font().family() << charFmt.fontWeight() + << (charFmt.fontItalic() ? "italic" : "") << charFmt.foreground().color().name(); if (spanType == int(MD_SPAN_IMG)) m_imageSpan = false; return 0; // no error @@ -400,6 +423,8 @@ int QTextMarkdownImporter::cbText(int textType, const char *text, unsigned size) { if (m_imageSpan) return 0; // it's the alt-text + if (m_needsInsertBlock) + insertBlock(); static const QRegularExpression openingBracket(QStringLiteral("<[a-zA-Z]")); static const QRegularExpression closingBracket(QStringLiteral("(/>|insertText(s); if (m_cursor->currentList()) { // The list item will indent the list item's text, so we don't need indentation on the block. - QTextBlockFormat blockFmt = m_cursor->blockFormat(); - blockFmt.setIndent(0); - m_cursor->setBlockFormat(blockFmt); + QTextBlockFormat bfmt = m_cursor->blockFormat(); + bfmt.setIndent(0); + m_cursor->setBlockFormat(bfmt); + } + if (lcMD().isEnabled(QtDebugMsg)) { + QTextBlockFormat bfmt = m_cursor->blockFormat(); + QString debugInfo; + if (m_cursor->currentList()) + debugInfo = QLatin1String("in list at depth ") + QString::number(m_cursor->currentList()->format().indent()); + if (bfmt.hasProperty(QTextFormat::BlockQuoteLevel)) + debugInfo += QLatin1String("in blockquote at depth ") + + QString::number(bfmt.intProperty(QTextFormat::BlockQuoteLevel)); + if (bfmt.hasProperty(QTextFormat::BlockCodeLanguage)) + debugInfo += QLatin1String("in a code block"); + qCDebug(lcMD) << textType << "in block" << m_blockType << s << qPrintable(debugInfo) + << "bindent" << bfmt.indent() << "tindent" << bfmt.textIndent() + << "margins" << bfmt.leftMargin() << bfmt.topMargin() << bfmt.bottomMargin() << bfmt.rightMargin(); } qCDebug(lcMD) << textType << "in block" << m_blockType << s << "in list?" << m_cursor->currentList() << "indent" << m_cursor->blockFormat().indent(); return 0; // no error } +void QTextMarkdownImporter::insertBlock() +{ + QTextCharFormat charFormat; + if (!m_spanFormatStack.isEmpty()) + charFormat = m_spanFormatStack.top(); + QTextBlockFormat blockFormat; + if (m_blockQuoteDepth) { + blockFormat.setProperty(QTextFormat::BlockQuoteLevel, m_blockQuoteDepth); + blockFormat.setLeftMargin(BlockQuoteIndent * m_blockQuoteDepth); + blockFormat.setRightMargin(BlockQuoteIndent); + } + if (m_listStack.count()) + blockFormat.setIndent(m_listStack.count()); + if (m_codeBlock) { + blockFormat.setProperty(QTextFormat::BlockCodeLanguage, m_blockCodeLanguage); + charFormat.setFont(m_monoFont); + } else { + blockFormat.setTopMargin(m_paragraphMargin); + blockFormat.setBottomMargin(m_paragraphMargin); + } + m_cursor->insertBlock(blockFormat, charFormat); + m_needsInsertBlock = false; +} + QT_END_NAMESPACE diff --git a/src/gui/text/qtextmarkdownimporter_p.h b/src/gui/text/qtextmarkdownimporter_p.h index 8ab119d051..1716530b1d 100644 --- a/src/gui/text/qtextmarkdownimporter_p.h +++ b/src/gui/text/qtextmarkdownimporter_p.h @@ -99,26 +99,34 @@ public: int cbLeaveSpan(int spanType, void* detail); int cbText(int textType, const char* text, unsigned size); +private: + void insertBlock(); + private: QTextDocument *m_doc = nullptr; QTextCursor *m_cursor = nullptr; QTextTable *m_currentTable = nullptr; // because m_cursor->currentTable() doesn't work QString m_htmlAccumulator; + QString m_blockCodeLanguage; QVector m_nonEmptyTableCells; // in the current row QStack m_listStack; QStack m_spanFormatStack; QFont m_monoFont; QPalette m_palette; int m_htmlTagDepth = 0; + int m_blockQuoteDepth = 0; int m_tableColumnCount = 0; int m_tableRowCount = 0; int m_tableCol = -1; // because relative cell movements (e.g. m_cursor->movePosition(QTextCursor::NextCell)) don't work + int m_paragraphMargin = 0; Features m_features; int m_blockType = 0; bool m_emptyList = false; // true when the last thing we did was insertList bool m_listItem = false; bool m_emptyListItem = false; + bool m_codeBlock = false; bool m_imageSpan = false; + bool m_needsInsertBlock = false; }; Q_DECLARE_OPERATORS_FOR_FLAGS(QTextMarkdownImporter::Features) diff --git a/src/gui/text/qtextmarkdownwriter.cpp b/src/gui/text/qtextmarkdownwriter.cpp index a445ee7e83..f180098db2 100644 --- a/src/gui/text/qtextmarkdownwriter.cpp +++ b/src/gui/text/qtextmarkdownwriter.cpp @@ -106,7 +106,7 @@ void QTextMarkdownWriter::writeFrame(const QTextFrame *frame) Q_ASSERT(frame); const QTextTable *table = qobject_cast (frame); QTextFrame::iterator iterator = frame->begin(); - QTextFrame *child = 0; + QTextFrame *child = nullptr; int tableRow = -1; bool lastWasList = false; QVector tableColumnWidths; @@ -161,7 +161,7 @@ void QTextMarkdownWriter::writeFrame(const QTextFrame *frame) m_stream << QString(paddingLen, Space); for (int col = cell.column(); col < spanEndCol; ++col) m_stream << "|"; - } else if (block.textList()) { + } else if (block.textList() || block.blockFormat().hasProperty(QTextFormat::BlockCodeLanguage)) { m_stream << Newline; } else if (endingCol > 0) { m_stream << Newline << Newline; @@ -252,6 +252,8 @@ static void maybeEscapeFirstChar(QString &s) int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ignoreFormat) { int ColumnLimit = 80; + QTextBlockFormat blockFmt = block.blockFormat(); + bool indentedCodeBlock = false; if (block.textList()) { // it's a list-item auto fmt = block.textList()->format(); const int listLevel = fmt.indent(); @@ -281,7 +283,7 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign m_wrappedLineIndent = 4; break; } - switch (block.blockFormat().marker()) { + switch (blockFmt.marker()) { case QTextBlockFormat::Checked: bullet += " [x]"; break; @@ -309,21 +311,35 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign prefix += QLatin1String(bullet) + Space; } m_stream << prefix; - } else if (block.blockFormat().hasProperty(QTextFormat::BlockTrailingHorizontalRulerWidth)) { + } else if (blockFmt.hasProperty(QTextFormat::BlockTrailingHorizontalRulerWidth)) { m_stream << "- - -\n"; // unambiguous horizontal rule, not an underline under a heading return 0; - } else if (!block.blockFormat().indent()) { + } else if (!blockFmt.indent()) { m_wrappedLineIndent = 0; + m_linePrefix.clear(); + if (blockFmt.hasProperty(QTextFormat::BlockQuoteLevel)) { + int level = blockFmt.intProperty(QTextFormat::BlockQuoteLevel); + QString quoteMarker = QStringLiteral("> "); + m_linePrefix.reserve(level * 2); + for (int i = 0; i < level; ++i) + m_linePrefix += quoteMarker; + } + if (blockFmt.hasProperty(QTextFormat::BlockCodeLanguage)) { + // A block quote can contain an indented code block, but not vice-versa. + m_linePrefix += QString(4, Space); + indentedCodeBlock = true; + } } + if (blockFmt.headingLevel()) + m_stream << QByteArray(blockFmt.headingLevel(), '#') << ' '; + else + m_stream << m_linePrefix; - if (block.blockFormat().headingLevel()) - m_stream << QByteArray(block.blockFormat().headingLevel(), '#') << ' '; - - QString wrapIndentString(m_wrappedLineIndent, Space); + QString wrapIndentString = m_linePrefix + QString(m_wrappedLineIndent, Space); // It would be convenient if QTextStream had a lineCharPos() accessor, // to keep track of how many characters (not bytes) have been written on the current line, // but it doesn't. So we have to keep track with this col variable. - int col = m_wrappedLineIndent; + int col = wrapIndentString.length(); bool mono = false; bool startsOrEndsWithBacktick = false; bool bold = false; @@ -338,7 +354,7 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign if (block.textList()) { //
  7. first line
    continuation
  8. QString newlineIndent = QString(Newline) + QString(m_wrappedLineIndent, Space); fragmentText.replace(QString(LineBreak), newlineIndent); - } else if (block.blockFormat().indent() > 0) { //
  9. first line

    continuation

  10. + } else if (blockFmt.indent() > 0) { //
  11. first line

    continuation

  12. m_stream << QString(m_wrappedLineIndent, Space); } else { fragmentText.replace(LineBreak, Newline); @@ -368,7 +384,7 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign bool monoFrag = fontInfo.fixedPitch(); QString markers; if (!ignoreFormat) { - if (monoFrag != mono) { + if (monoFrag != mono && !indentedCodeBlock) { if (monoFrag) backticks = QString(adjacentBackticksCount(fragmentText) + 1, Backtick); markers += backticks; @@ -376,25 +392,25 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign markers += Space; mono = monoFrag; } - if (!block.blockFormat().headingLevel() && !mono) { - if (fmt.font().bold() != bold) { + if (!blockFmt.headingLevel() && !mono) { + if (fontInfo.bold() != bold) { markers += QLatin1String("**"); - bold = fmt.font().bold(); + bold = fontInfo.bold(); } - if (fmt.font().italic() != italic) { + if (fontInfo.italic() != italic) { markers += QLatin1Char('*'); - italic = fmt.font().italic(); + italic = fontInfo.italic(); } - if (fmt.font().strikeOut() != strikeOut) { + if (fontInfo.strikeOut() != strikeOut) { markers += QLatin1String("~~"); - strikeOut = fmt.font().strikeOut(); + strikeOut = fontInfo.strikeOut(); } - if (fmt.font().underline() != underline) { + if (fontInfo.underline() != underline) { // Markdown doesn't support underline, but the parser will treat a single underline // the same as a single asterisk, and the marked fragment will be rendered in italics. // That will have to do. markers += QLatin1Char('_'); - underline = fmt.font().underline(); + underline = fontInfo.underline(); } } } diff --git a/src/gui/text/qtextmarkdownwriter_p.h b/src/gui/text/qtextmarkdownwriter_p.h index 4c07bad2e7..96ceb445cd 100644 --- a/src/gui/text/qtextmarkdownwriter_p.h +++ b/src/gui/text/qtextmarkdownwriter_p.h @@ -81,6 +81,7 @@ private: QTextStream &m_stream; QTextDocument::MarkdownFeatures m_features; QMap m_listInfo; + QString m_linePrefix; int m_wrappedLineIndent = 0; int m_lastListIndent = 1; bool m_doubleNewlineWritten = false; diff --git a/tests/auto/gui/text/qtextmarkdownimporter/qtextmarkdownimporter.pro b/tests/auto/gui/text/qtextmarkdownimporter/qtextmarkdownimporter.pro index 7afc807c9b..7b7fb61244 100644 --- a/tests/auto/gui/text/qtextmarkdownimporter/qtextmarkdownimporter.pro +++ b/tests/auto/gui/text/qtextmarkdownimporter/qtextmarkdownimporter.pro @@ -4,5 +4,6 @@ QT += core-private gui-private testlib SOURCES += tst_qtextmarkdownimporter.cpp TESTDATA += \ data/thematicBreaks.md \ + data/headingBulletsContinuations.md \ DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/gui/text/qtextmarkdownwriter/data/blockquotes.md b/tests/auto/gui/text/qtextmarkdownwriter/data/blockquotes.md new file mode 100644 index 0000000000..f429fcc21b --- /dev/null +++ b/tests/auto/gui/text/qtextmarkdownwriter/data/blockquotes.md @@ -0,0 +1,39 @@ +In 1958, Mahatma Gandhi was quoted as follows: + +> The Earth provides enough to satisfy every man's need but not for every man's +> greed. + +In [The CommonMark Specification](https://spec.commonmark.org/0.29/) John +MacFarlane writes: + +> What distinguishes Markdown from many other lightweight markup syntaxes, +> which are often easier to write, is its readability. As Gruber writes: + +> > The overriding design goal for Markdown's formatting syntax is to make it +> > as readable as possible. The idea is that a Markdown-formatted document should +> > be publishable as-is, as plain text, without looking like it's been marked up +> > with tags or formatting instructions. ( +> > [http://daringfireball.net/projects/markdown/](http://daringfireball.net/projects/markdown/)) + +> The point can be illustrated by comparing a sample of AsciiDoc with an +> equivalent sample of Markdown. Here is a sample of AsciiDoc from the AsciiDoc +> manual: + +> 1. List item one. +> + +> List item one continued with a second paragraph followed by an +> Indented block. +> + +> ................. +> $ ls *.sh +> $ mv *.sh ~/tmp +> ................. +> + +> List item continued with a third paragraph. +> +> 2. List item two continued with an open block. +> ... +> +The quotation includes an embedded quotation and a code quotation and ends with +an ellipsis due to being incomplete. + diff --git a/tests/auto/gui/text/qtextmarkdownwriter/qtextmarkdownwriter.pro b/tests/auto/gui/text/qtextmarkdownwriter/qtextmarkdownwriter.pro index 04cf7ef5dd..6144710b99 100644 --- a/tests/auto/gui/text/qtextmarkdownwriter/qtextmarkdownwriter.pro +++ b/tests/auto/gui/text/qtextmarkdownwriter/qtextmarkdownwriter.pro @@ -2,6 +2,8 @@ CONFIG += testcase TARGET = tst_qtextmarkdownwriter QT += core-private gui-private testlib SOURCES += tst_qtextmarkdownwriter.cpp -TESTDATA += data/example.md +TESTDATA += \ + data/example.md \ + data/blockquotes.md \ DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp index 3d77ccd9d8..9998794762 100644 --- a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp +++ b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp @@ -54,6 +54,7 @@ private slots: void testWriteNestedBulletLists(); void testWriteNestedNumericLists(); void testWriteTable(); + void rewriteDocument_data(); void rewriteDocument(); void fromHtml_data(); void fromHtml(); @@ -350,10 +351,19 @@ void tst_QTextMarkdownWriter::testWriteTable() QCOMPARE(md, QString::fromLatin1("\n|a ||b|\n|-|-|-|\n|c|d ||\n|e|f| |\n\n")); } +void tst_QTextMarkdownWriter::rewriteDocument_data() +{ + QTest::addColumn("inputFile"); + + QTest::newRow("block quotes") << "blockquotes.md"; + QTest::newRow("example") << "example.md"; +} + void tst_QTextMarkdownWriter::rewriteDocument() { + QFETCH(QString, inputFile); QTextDocument doc; - QFile f(QFINDTESTDATA("data/example.md")); + QFile f(QFINDTESTDATA("data/" + inputFile)); QVERIFY(f.open(QFile::ReadOnly | QIODevice::Text)); QString orig = QString::fromUtf8(f.readAll()); f.close(); @@ -361,7 +371,7 @@ void tst_QTextMarkdownWriter::rewriteDocument() QString md = doc.toMarkdown(); #ifdef DEBUG_WRITE_OUTPUT - QFile out("/tmp/rewrite.md"); + QFile out("/tmp/rewrite-" + inputFile); out.open(QFile::WriteOnly); out.write(md.toUtf8()); out.close(); @@ -401,6 +411,9 @@ void tst_QTextMarkdownWriter::fromHtml_data() QTest::newRow("thematic break") << "something
    something else" << "something\n\n- - -\nsomething else\n\n"; + QTest::newRow("block quote") << + "

    In 1958, Mahatma Gandhi was quoted as follows:

    The Earth provides enough to satisfy every man's need but not for every man's greed.
    " << + "In 1958, Mahatma Gandhi was quoted as follows:\n\n> The Earth provides enough to satisfy every man's need but not for every man's\n> greed.\n\n"; // TODO // QTest::newRow("escaped number and paren after double newline") << // "

    (The first sentence of this paragraph is a line, the next paragraph has a number

    13) but that's not part of an ordered list" << From 5652d33f973a03b93c9b5ce9e49db8cf0430b675 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 30 Apr 2019 11:54:31 +0200 Subject: [PATCH 279/292] Bump version to Qt 6 Needed to disable QT_NO_UNSHARABLE_CONTAINERS, as this triggers asserts. QMetaType also has some Qt 6 specific code disabled to get things to compile. Fix various details in autotests to accommodate for the changes with Qt 6. Add a workaround for black lists on macos, where QSysInfo::productType() now returns 'macos' and not 'osx' anymore. Change-Id: Ie26afb12a2aac36521472715934a7e34639ea4d0 Reviewed-by: Simon Hausmann --- .qmake.conf | 2 +- src/corelib/global/qglobal.h | 3 +- src/corelib/global/qlogging.cpp | 2 +- src/corelib/io/qfileselector.cpp | 7 -- src/corelib/io/qfilesystemwatcher_win.cpp | 2 +- src/corelib/itemmodels/qabstractitemmodel.cpp | 4 + src/corelib/itemmodels/qabstractproxymodel.h | 6 +- src/corelib/kernel/qcoreapplication.cpp | 6 +- src/corelib/kernel/qmetatype.h | 2 +- src/corelib/mimetypes/qmimedatabase_p.h | 1 + src/corelib/plugin/qlibrary.cpp | 4 +- src/gui/image/qimage_p.h | 2 +- src/gui/itemmodels/qstandarditemmodel.h | 7 +- src/network/ssl/qsslsocket_winrt.cpp | 6 +- .../platforms/cocoa/qcocoaintegration.mm | 2 +- src/testlib/qtestblacklist.cpp | 10 ++ .../corelib/io/qfileinfo/tst_qfileinfo.cpp | 2 +- .../io/qfileselector/platforms/+mac/test5 | 0 .../io/qfileselector/platforms/+osx/test4 | 0 .../{+mac => +unix/+darwin/+ios}/test | 0 .../platforms/+unix/+darwin/+mac/+ios/test | 0 .../platforms/+unix/+darwin/+mac/+macos/test | 0 .../+unix/+darwin/+mac/+osx/+macos/test | 0 .../platforms/+unix/+darwin/+mac/+osx/test | 0 .../platforms/+unix/+darwin/+mac/test | 0 .../{+osx => +unix/+darwin/+macos}/test | 0 .../io/qfileselector/qfileselector.qrc | 114 ++++++++---------- .../io/qfileselector/tst_qfileselector.cpp | 8 -- .../corelib/tools/qvector/outofline.cpp | 2 +- .../qfile_vs_qnetworkaccessmanager/main.cpp | 6 +- 30 files changed, 96 insertions(+), 102 deletions(-) delete mode 100644 tests/auto/corelib/io/qfileselector/platforms/+mac/test5 delete mode 100644 tests/auto/corelib/io/qfileselector/platforms/+osx/test4 rename tests/auto/corelib/io/qfileselector/platforms/{+mac => +unix/+darwin/+ios}/test (100%) delete mode 100644 tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/+ios/test delete mode 100644 tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/+macos/test delete mode 100644 tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/+osx/+macos/test delete mode 100644 tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/+osx/test delete mode 100644 tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/test rename tests/auto/corelib/io/qfileselector/platforms/{+osx => +unix/+darwin/+macos}/test (100%) diff --git a/.qmake.conf b/.qmake.conf index 08e1a4723c..1d049940d8 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -4,4 +4,4 @@ CONFIG += warning_clean QT_SOURCE_TREE = $$PWD QT_BUILD_TREE = $$shadowed($$PWD) -MODULE_VERSION = 5.14.0 +MODULE_VERSION = 6.0.0 diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 0a0c434a07..499558d7e6 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -87,7 +87,8 @@ #define QT_REQUIRE_CONFIG(feature) Q_STATIC_ASSERT_X(QT_FEATURE_##feature == 1, "Required feature " #feature " for file " __FILE__ " not available.") #if QT_VERSION >= QT_VERSION_CHECK(6,0,0) -# define QT_NO_UNSHARABLE_CONTAINERS +// ### Qt6: FIXME and get rid of unsharable containers +//# define QT_NO_UNSHARABLE_CONTAINERS # define QT6_VIRTUAL virtual # define QT6_NOT_VIRTUAL #else diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 4941ca45aa..23cb5ba61e 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -1318,7 +1318,7 @@ static QStringList backtraceFramesForLogMessage(int frameCount) QString function = m.captured(2); // skip the trace from QtCore that are because of the qDebug itself - if (!numberPrinted && library.contains(QLatin1String("Qt5Core")) + if (!numberPrinted && library.contains(QLatin1String("Qt6Core")) && (function.isEmpty() || function.contains(QLatin1String("Message"), Qt::CaseInsensitive) || function.contains(QLatin1String("QDebug")))) { continue; diff --git a/src/corelib/io/qfileselector.cpp b/src/corelib/io/qfileselector.cpp index ce06c8e00b..7f65b0f8f7 100644 --- a/src/corelib/io/qfileselector.cpp +++ b/src/corelib/io/qfileselector.cpp @@ -331,7 +331,6 @@ void QFileSelectorPrivate::updateSelectors() QStringList QFileSelectorPrivate::platformSelectors() { // similar, but not identical to QSysInfo::osType - // ### Qt6: remove macOS fallbacks to "mac" and the future compatibility QStringList ret; #if defined(Q_OS_WIN) ret << QStringLiteral("windows"); @@ -344,16 +343,10 @@ QStringList QFileSelectorPrivate::platformSelectors() # if !defined(Q_OS_ANDROID) && !defined(Q_OS_QNX) // we don't want "linux" for Android or two instances of "qnx" for QNX ret << QSysInfo::kernelType(); -# ifdef Q_OS_MAC - ret << QStringLiteral("mac"); // compatibility, since kernelType() is "darwin" -# endif # endif QString productName = QSysInfo::productType(); if (productName != QLatin1String("unknown")) ret << productName; // "opensuse", "fedora", "osx", "ios", "android" -# if defined(Q_OS_MACOS) - ret << QStringLiteral("macos"); // future compatibility -# endif #endif return ret; } diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp index eb626fd541..e1949e9697 100644 --- a/src/corelib/io/qfilesystemwatcher_win.cpp +++ b/src/corelib/io/qfilesystemwatcher_win.cpp @@ -79,7 +79,7 @@ static Qt::HANDLE createChangeNotification(const QString &path, uint flags) nativePath.append(QLatin1Char('\\')); const HANDLE result = FindFirstChangeNotification(reinterpret_cast(nativePath.utf16()), FALSE, flags); - DEBUG() << __FUNCTION__ << nativePath << Qt::hex <invalidatePersistentIndexes(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + resetInternalData(); +#else QMetaObject::invokeMethod(this, "resetInternalData"); +#endif emit modelReset(QPrivateSignal()); } diff --git a/src/corelib/itemmodels/qabstractproxymodel.h b/src/corelib/itemmodels/qabstractproxymodel.h index c9a73b6a31..f6f6e45c1a 100644 --- a/src/corelib/itemmodels/qabstractproxymodel.h +++ b/src/corelib/itemmodels/qabstractproxymodel.h @@ -103,7 +103,11 @@ Q_SIGNALS: void sourceModelChanged(QPrivateSignal); protected Q_SLOTS: - void resetInternalData(); + void resetInternalData() +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + override +#endif + ; protected: QAbstractProxyModel(QAbstractProxyModelPrivate &, QObject *parent); diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 7a6faf2e2b..fc8b9227d4 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -152,10 +152,10 @@ private: extern QString qAppFileName(); #endif -#if QT_VERSION >= 0x060000 -# error "Bump QCoreApplicatoinPrivate::app_compile_version to 0x060000" +#if QT_VERSION >= 0x070000 +# error "Bump QCoreApplicatoinPrivate::app_compile_version to 0x070000" #endif -int QCoreApplicationPrivate::app_compile_version = 0x050000; //we don't know exactly, but it's at least 5.0.0 +int QCoreApplicationPrivate::app_compile_version = 0x060000; //we don't know exactly, but it's at least 6.0.0 bool QCoreApplicationPrivate::setuidAllowed = false; diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 79ee5eec11..7f512b6cb1 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -493,7 +493,7 @@ public: typedef void (*Deleter)(void *); typedef void *(*Creator)(const void *); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if 1 || QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt6: fix this typedef void (*Destructor)(void *); typedef void *(*Constructor)(void *, const void *); // TODO Qt6: remove me #endif diff --git a/src/corelib/mimetypes/qmimedatabase_p.h b/src/corelib/mimetypes/qmimedatabase_p.h index d9cf446d44..831390de1f 100644 --- a/src/corelib/mimetypes/qmimedatabase_p.h +++ b/src/corelib/mimetypes/qmimedatabase_p.h @@ -63,6 +63,7 @@ QT_REQUIRE_CONFIG(mimetype); #include #include +#include #include QT_BEGIN_NAMESPACE diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp index 0e32776c71..c059851fce 100644 --- a/src/corelib/plugin/qlibrary.cpp +++ b/src/corelib/plugin/qlibrary.cpp @@ -692,7 +692,7 @@ static bool qt_get_metadata(QLibraryPrivate *priv, QString *errMsg) }; #else auto getMetaData = [](QFunctionPointer fptr) { - auto f = reinterpret_cast (*)()>(fptr); + auto f = reinterpret_cast(fptr); return f(); }; #endif @@ -702,7 +702,7 @@ static bool qt_get_metadata(QLibraryPrivate *priv, QString *errMsg) return false; auto metaData = getMetaData(pfn); - QJsonDocument doc = qJsonFromRawLibraryMetaData(metaData.first, metaData.second, errMsg); + QJsonDocument doc = qJsonFromRawLibraryMetaData(reinterpret_cast(metaData.data), metaData.size, errMsg); if (doc.isNull()) return false; priv->metaData = doc.object(); diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h index 9da6acd0a7..1cd0e8e0aa 100644 --- a/src/gui/image/qimage_p.h +++ b/src/gui/image/qimage_p.h @@ -140,7 +140,7 @@ QImageData::calculateImageParameters(qsizetype width, qsizetype height, qsizetyp qsizetype dummy; if (mul_overflow(height, qsizetype(sizeof(uchar *)), &dummy)) return invalid; // why is this here? -#if QT_VERSION < QT_VERSION_CHECK(6,0,0) +#if 1 || QT_VERSION < QT_VERSION_CHECK(6,0,0) // ### can only fix this if QImage dimensions are not int anymore // Disallow images where width * depth calculations might overflow if (width > (INT_MAX - 31) / depth) return invalid; diff --git a/src/gui/itemmodels/qstandarditemmodel.h b/src/gui/itemmodels/qstandarditemmodel.h index a9ee25da75..435b66591c 100644 --- a/src/gui/itemmodels/qstandarditemmodel.h +++ b/src/gui/itemmodels/qstandarditemmodel.h @@ -344,8 +344,11 @@ public: QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; - // Qt 6: add override keyword - bool clearItemData(const QModelIndex &index); + bool clearItemData(const QModelIndex &index) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + override +#endif + ; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; diff --git a/src/network/ssl/qsslsocket_winrt.cpp b/src/network/ssl/qsslsocket_winrt.cpp index d54ac2ad73..0bbe6fe57d 100644 --- a/src/network/ssl/qsslsocket_winrt.cpp +++ b/src/network/ssl/qsslsocket_winrt.cpp @@ -274,7 +274,7 @@ void QSslSocketBackendPrivate::startClientEncryption() } // Sync custom certificates - const QSet caCertificates = configuration.caCertificates.toSet(); + const QSet caCertificates(configuration.caCertificates.constBegin(), configuration.caCertificates.constEnd()); const QSet newCertificates = caCertificates - previousCaCertificates; const QSet oldCertificates = previousCaCertificates - caCertificates; g->syncCaCertificates(newCertificates, oldCertificates); @@ -397,7 +397,7 @@ void QSslSocketBackendPrivate::continueHandshake() hr = control2->get_IgnorableServerCertificateErrors(&ignoreList); Q_ASSERT_SUCCEEDED(hr); - QSet ignoreErrors = ignoreErrorsList.toSet(); + QSet ignoreErrors(ignoreErrorsList.constBegin(), ignoreErrorsList.constEnd()); for (int i = ChainValidationResult_Untrusted; i < ChainValidationResult_OtherErrors + 1; ++i) { // Populate the native ignore list - break to add, continue to skip switch (i) { @@ -600,7 +600,7 @@ HRESULT QSslSocketBackendPrivate::onSslUpgrade(IAsyncAction *action, AsyncStatus } } - sslErrors = errors.toList(); + sslErrors = QList(errors.constBegin(), errors.constEnd()); // Peer validation if (!configuration.peerCertificate.isNull()) { diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index fb3d05d3e4..eb18e573ea 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -272,7 +272,7 @@ void QCocoaIntegration::updateScreens() [screens addObject:[NSScreen mainScreen]]; if ([screens count] == 0) return; - QSet remainingScreens = QSet::fromList(mScreens); + QSet remainingScreens = QSet(mScreens.constBegin(), mScreens.constEnd()); QList siblings; uint screenCount = [screens count]; for (uint i = 0; i < screenCount; i++) { diff --git a/src/testlib/qtestblacklist.cpp b/src/testlib/qtestblacklist.cpp index 886f1f75b9..72bb5688ef 100644 --- a/src/testlib/qtestblacklist.cpp +++ b/src/testlib/qtestblacklist.cpp @@ -186,10 +186,20 @@ static QSet activeConditions() if (!distributionName.isEmpty()) { if (result.find(distributionName) == result.end()) result.insert(distributionName); + // backwards compatibility with Qt 5 + if (distributionName == "macos") { + if (result.find(distributionName) == result.end()) + result.insert("osx"); + } if (!distributionRelease.isEmpty()) { QByteArray versioned = distributionName + "-" + distributionRelease; if (result.find(versioned) == result.end()) result.insert(versioned); + if (distributionName == "macos") { + QByteArray versioned = "osx-" + distributionRelease; + if (result.find(versioned) == result.end()) + result.insert(versioned); + } } } diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index 64075a94f0..98830bbc9b 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -115,7 +115,7 @@ static DWORD createSymbolicLink(const QString &symLinkName, const QString &targe reinterpret_cast(nativeTarget.utf16()), flags) == FALSE) { result = GetLastError(); QTextStream(errorMessage) << "CreateSymbolicLink(" << nativeSymLinkName << ", " - << nativeTarget << ", 0x" << hex << flags << dec << ") failed with error " << result + << nativeTarget << ", 0x" << Qt::hex << flags << Qt::dec << ") failed with error " << result << ": " << qt_error_string(int(result)); } return result; diff --git a/tests/auto/corelib/io/qfileselector/platforms/+mac/test5 b/tests/auto/corelib/io/qfileselector/platforms/+mac/test5 deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+osx/test4 b/tests/auto/corelib/io/qfileselector/platforms/+osx/test4 deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+mac/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+ios/test similarity index 100% rename from tests/auto/corelib/io/qfileselector/platforms/+mac/test rename to tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+ios/test diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/+ios/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/+ios/test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/+macos/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/+macos/test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/+osx/+macos/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/+osx/+macos/test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/+osx/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/+osx/test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+mac/test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+osx/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+macos/test similarity index 100% rename from tests/auto/corelib/io/qfileselector/platforms/+osx/test rename to tests/auto/corelib/io/qfileselector/platforms/+unix/+darwin/+macos/test diff --git a/tests/auto/corelib/io/qfileselector/qfileselector.qrc b/tests/auto/corelib/io/qfileselector/qfileselector.qrc index 54b2e0a0e2..f3b3ede575 100644 --- a/tests/auto/corelib/io/qfileselector/qfileselector.qrc +++ b/tests/auto/corelib/io/qfileselector/qfileselector.qrc @@ -1,65 +1,51 @@ - - - extras/test - extras/test2 - extras/+custom1/test - extras/+custom1/test3 - extras/+custom2/test - extras/+custom3/test - extras/+custom3/+custom2/test - extras/+custom3/+custom4/test - extras/+custom3/+custom5/test - extras/+custom5/+custom3/test - - - platforms/test - platforms/+unix/+android/test - platforms/+unix/+darwin/+mac/+ios/test - platforms/+unix/+darwin/+mac/+osx/+macos/test - platforms/+unix/+darwin/+mac/+osx/test - platforms/+unix/+darwin/+mac/test - platforms/+unix/+darwin/test - platforms/+unix/+haiku/test - platforms/+unix/+linux/test - platforms/+unix/+qnx/test - platforms/+unix/test - platforms/+windows/+wince/test - platforms/+windows/+winnt/test - platforms/+windows/+winrt/test - platforms/+windows/test - platforms/+android/test - platforms/+ios/test - platforms/+macos/test - platforms/+osx/test - platforms/+darwin/test - platforms/+mac/test - platforms/+haiku/test - platforms/+linux/test - platforms/+qnx/test - platforms/+wince/test - platforms/+winrt/test - - - platforms/test2 - platforms/+android/test2 - platforms/+ios/test2 - platforms/+macos/test2 - platforms/+haiku/test2 - platforms/+linux/test2 - platforms/+qnx/test2 - platforms/+wince/test2 - platforms/+winnt/test2 - platforms/+winrt/test2 - - - platforms/test3 - platforms/+windows/test3 - platforms/+unix/test3 - - - platforms/test4 - platforms/+osx/test4 - platforms/test5 - platforms/+mac/test5 - + + + extras/test + extras/test2 + extras/+custom1/test + extras/+custom1/test3 + extras/+custom2/test + extras/+custom3/test + extras/+custom3/+custom2/test + extras/+custom3/+custom4/test + extras/+custom3/+custom5/test + extras/+custom5/+custom3/test + platforms/test + platforms/+unix/+android/test + platforms/+unix/+darwin/test + platforms/+unix/+haiku/test + platforms/+unix/+linux/test + platforms/+unix/+qnx/test + platforms/+unix/test + platforms/+windows/+wince/test + platforms/+windows/+winnt/test + platforms/+windows/+winrt/test + platforms/+windows/test + platforms/+android/test + platforms/+ios/test + platforms/+macos/test + platforms/+darwin/test + platforms/+haiku/test + platforms/+linux/test + platforms/+qnx/test + platforms/+wince/test + platforms/+winrt/test + platforms/test2 + platforms/+android/test2 + platforms/+ios/test2 + platforms/+macos/test2 + platforms/+haiku/test2 + platforms/+linux/test2 + platforms/+qnx/test2 + platforms/+wince/test2 + platforms/+winnt/test2 + platforms/+winrt/test2 + platforms/test3 + platforms/+windows/test3 + platforms/+unix/test3 + platforms/test4 + platforms/test5 + platforms/+unix/+darwin/+macos/test + platforms/+unix/+darwin/+ios/test + diff --git a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp index c9f1e3d9f6..b98a98df9c 100644 --- a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp +++ b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp @@ -126,14 +126,6 @@ void tst_QFileSelector::basicTest_data() QTest::newRow("platform3") << QString(":/platforms/test3") << QStringList() << expectedPlatform3File; -#ifdef Q_OS_MACOS - // special case for compatibility code - QTest::newRow("osx-compat") << QString(":/platforms/test4") << QStringList() - << ":/platforms/+osx/test4"; - QTest::newRow("mac-compat") << QString(":/platforms/test5") << QStringList() - << ":/platforms/+mac/test5"; -#endif - QString resourceTestPath(":/extras/test"); QString custom1("custom1"); QTest::newRow("custom1-noselector") << resourceTestPath << QStringList() diff --git a/tests/benchmarks/corelib/tools/qvector/outofline.cpp b/tests/benchmarks/corelib/tools/qvector/outofline.cpp index 76a4edaa10..7182a43008 100644 --- a/tests/benchmarks/corelib/tools/qvector/outofline.cpp +++ b/tests/benchmarks/corelib/tools/qvector/outofline.cpp @@ -54,7 +54,7 @@ QVector mixedvector_fill_and_return_helper() std::vector v(N); for (int i = 0; i != N; ++i) v[i] = i; - return QVector::fromStdVector(v); + return QVector(v.begin(), v.end()); } diff --git a/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/main.cpp b/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/main.cpp index 46bb1791b4..1f3f38eaaf 100644 --- a/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/main.cpp +++ b/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/main.cpp @@ -105,7 +105,7 @@ void qfile_vs_qnetworkaccessmanager::qnamFileRead() } qint64 elapsed = t.elapsed(); - qDebug() << endl << "Finished!"; + qDebug() << Qt::endl << "Finished!"; qDebug() << "Bytes:" << size; qDebug() << "Speed:" << (qreal(size*iterations) / 1024.0) / (qreal(elapsed) / 1000.0) << "KB/sec"; } @@ -138,7 +138,7 @@ void qfile_vs_qnetworkaccessmanager::qnamImmediateFileRead() } qint64 elapsed = t.elapsed(); - qDebug() << endl << "Finished!"; + qDebug() << Qt::endl << "Finished!"; qDebug() << "Bytes:" << size; qDebug() << "Speed:" << (qreal(size*iterations) / 1024.0) / (qreal(elapsed) / 1000.0) << "KB/sec"; } @@ -167,7 +167,7 @@ void qfile_vs_qnetworkaccessmanager::qfileFileRead() } qint64 elapsed = t.elapsed(); - qDebug() << endl << "Finished!"; + qDebug() << Qt::endl << "Finished!"; qDebug() << "Bytes:" << size; qDebug() << "Speed:" << (qreal(size*iterations) / 1024.0) / (qreal(elapsed) / 1000.0) << "KB/sec"; } From 1dde5a7b9523ab7f62a6965edfd7b87ed40eecb8 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 13 Mar 2019 09:46:20 +0100 Subject: [PATCH 280/292] Remove deprecated QEasingCurve::cubicBezierSpline() function It has been deprecated since Qt 5.0 so hopefully nobody is using it anymore. Change-Id: If3466f8a2d25ea87cd51ca71606d2a27a428efcf Reviewed-by: Christian Ehrlicher --- src/corelib/tools/qeasingcurve.cpp | 5 ----- src/corelib/tools/qeasingcurve.h | 7 ------- 2 files changed, 12 deletions(-) diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp index 9169b5c7f1..c807bbd2e1 100644 --- a/src/corelib/tools/qeasingcurve.cpp +++ b/src/corelib/tools/qeasingcurve.cpp @@ -1365,11 +1365,6 @@ void QEasingCurve::addTCBSegment(const QPointF &nextPoint, qreal t, qreal c, qre } -/*! - \fn QList QEasingCurve::cubicBezierSpline() const - \obsolete Use toCubicSpline() instead. - */ - /*! \since 5.0 diff --git a/src/corelib/tools/qeasingcurve.h b/src/corelib/tools/qeasingcurve.h index 725ddd5dcc..f7a1d6bdc0 100644 --- a/src/corelib/tools/qeasingcurve.h +++ b/src/corelib/tools/qeasingcurve.h @@ -43,10 +43,6 @@ #include #include #include -#if QT_DEPRECATED_SINCE(5, 0) -# include -# include -#endif QT_BEGIN_NAMESPACE @@ -102,9 +98,6 @@ public: void addCubicBezierSegment(const QPointF & c1, const QPointF & c2, const QPointF & endPoint); void addTCBSegment(const QPointF &nextPoint, qreal t, qreal c, qreal b); QVector toCubicSpline() const; -#if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED QList cubicBezierSpline() const { return toCubicSpline().toList(); } -#endif Type type() const; void setType(Type type); From 5505d25be972948db1621e1511b89b4144aa8bfc Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 17 May 2019 14:30:10 +0200 Subject: [PATCH 281/292] uic: Remove deprecated options The --no-stringliteral option got introduced by commit d12d2949d1e4ac0 for 5.10.0, but already deprecated in commit ff18b02f21a04f7 for 5.12.0. [ChangeLog][uic] uic does not accept the --no-stringliteral/-s option anymore. Change-Id: I7a0f647ad91b3760bc826884702bf8581f5565f2 Reviewed-by: Jarek Kobus --- src/tools/uic/main.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/tools/uic/main.cpp b/src/tools/uic/main.cpp index 166fe78ff7..e689d477bd 100644 --- a/src/tools/uic/main.cpp +++ b/src/tools/uic/main.cpp @@ -76,10 +76,6 @@ int runUic(int argc, char *argv[]) noImplicitIncludesOption.setDescription(QStringLiteral("Disable generation of #include-directives.")); parser.addOption(noImplicitIncludesOption); - QCommandLineOption noStringLiteralOption(QStringList() << QStringLiteral("s") << QStringLiteral("no-stringliteral")); - noStringLiteralOption.setDescription(QStringLiteral("Deprecated. The use of this option won't take any effect.")); - parser.addOption(noStringLiteralOption); - QCommandLineOption postfixOption(QStringLiteral("postfix")); postfixOption.setDescription(QStringLiteral("Postfix to add to all generated classnames.")); postfixOption.setValueName(QStringLiteral("postfix")); @@ -124,9 +120,6 @@ int runUic(int argc, char *argv[]) } language::setLanguage(language); - if (parser.isSet(noStringLiteralOption)) - fprintf(stderr, "The -s, --no-stringliteral option is deprecated and it won't take any effect.\n"); - QString inputFile; if (!parser.positionalArguments().isEmpty()) inputFile = parser.positionalArguments().at(0); From 6f2eabb54e3f827ebd2b90f68144b86342933869 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 19 Jun 2019 12:48:04 +0200 Subject: [PATCH 282/292] Remove binary compat qimage methods Change-Id: Ic8f1bd6c13468e9a19ff11a23d4b0c29afbcded4 Reviewed-by: Alexandru Croitor --- src/gui/image/image.pri | 3 -- src/gui/image/qimage.h | 9 ----- src/gui/image/qimage_compat.cpp | 66 --------------------------------- 3 files changed, 78 deletions(-) delete mode 100644 src/gui/image/qimage_compat.cpp diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri index 70fccbc378..b482a6e142 100644 --- a/src/gui/image/image.pri +++ b/src/gui/image/image.pri @@ -59,9 +59,6 @@ win32:!winrt: SOURCES += image/qpixmap_win.cpp darwin: OBJECTIVE_SOURCES += image/qimage_darwin.mm -NO_PCH_SOURCES += image/qimage_compat.cpp -false: SOURCES += $$NO_PCH_SOURCES # Hack for QtCreator - # Built-in image format support HEADERS += \ image/qbmphandler_p.h \ diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index 7c68168be8..3f0d900a70 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -178,7 +178,6 @@ public: Format format() const; -#if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QIMAGE_COMPAT_CPP) Q_REQUIRED_RESULT Q_ALWAYS_INLINE QImage convertToFormat(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) const & { return convertToFormat_helper(f, flags); } Q_REQUIRED_RESULT Q_ALWAYS_INLINE QImage convertToFormat(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) && @@ -188,9 +187,6 @@ public: else return convertToFormat_helper(f, flags); } -#else - Q_REQUIRED_RESULT QImage convertToFormat(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) const; -#endif Q_REQUIRED_RESULT QImage convertToFormat(Format f, const QVector &colorTable, Qt::ImageConversionFlags flags = Qt::AutoColor) const; bool reinterpretAsFormat(Format f); @@ -283,7 +279,6 @@ public: static QMatrix trueMatrix(const QMatrix &, int w, int h); QImage transformed(const QTransform &matrix, Qt::TransformationMode mode = Qt::FastTransformation) const; static QTransform trueMatrix(const QTransform &, int w, int h); -#if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QIMAGE_COMPAT_CPP) QImage mirrored(bool horizontally = false, bool vertically = true) const & { return mirrored_helper(horizontally, vertically); } QImage &&mirrored(bool horizontally = false, bool vertically = true) && @@ -292,10 +287,6 @@ public: { return rgbSwapped_helper(); } QImage &&rgbSwapped() && { rgbSwapped_inplace(); return std::move(*this); } -#else - QImage mirrored(bool horizontally = false, bool vertically = true) const; - QImage rgbSwapped() const; -#endif void invertPixels(InvertMode = InvertRgb); QColorSpace colorSpace() const; diff --git a/src/gui/image/qimage_compat.cpp b/src/gui/image/qimage_compat.cpp deleted file mode 100644 index ba31a9ac9b..0000000000 --- a/src/gui/image/qimage_compat.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifdef QIMAGE_H -# error "This file cannot be used with precompiled headers" -#endif -#define QT_COMPILING_QIMAGE_COMPAT_CPP - -#include "qimage.h" - -QT_BEGIN_NAMESPACE - -// These implementations must be the same as the inline versions in qimage.h - -QImage QImage::convertToFormat(Format f, Qt::ImageConversionFlags flags) const -{ - return convertToFormat_helper(f, flags); -} - -QImage QImage::mirrored(bool horizontally, bool vertically) const -{ - return mirrored_helper(horizontally, vertically); -} - -QImage QImage::rgbSwapped() const -{ - return rgbSwapped_helper(); -} - -QT_END_NAMESPACE From f955bd8ced8b93d142b7f755665946424c6d3644 Mon Sep 17 00:00:00 2001 From: Aapo Keskimolo Date: Mon, 1 Jul 2019 14:22:33 +0300 Subject: [PATCH 283/292] Add initial dependencies.yaml file Change-Id: Idcc30343c5ce9e4245952079a0e7c114c064632a Reviewed-by: Frederik Gladhorn --- dependencies.yaml | 1 + 1 file changed, 1 insertion(+) create mode 100644 dependencies.yaml diff --git a/dependencies.yaml b/dependencies.yaml new file mode 100644 index 0000000000..32cf5dda7e --- /dev/null +++ b/dependencies.yaml @@ -0,0 +1 @@ +dependencies: [] From 7301e44161d8bb25410219a31405584c9492b83e Mon Sep 17 00:00:00 2001 From: Aapo Keskimolo Date: Mon, 29 Jul 2019 11:17:10 +0300 Subject: [PATCH 284/292] Convert dependencies.yaml to dict from list Change-Id: I8a9df23c5cc66568d17f3c53af40ace97cfe7ab6 Reviewed-by: Toni Saario Reviewed-by: Aapo Keskimolo --- dependencies.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies.yaml b/dependencies.yaml index 32cf5dda7e..c093387ce0 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -1 +1 @@ -dependencies: [] +dependencies: {} From 6132260da394a9627947f0fe6a279c20863b6ad2 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 7 Aug 2019 14:37:21 +0200 Subject: [PATCH 285/292] Temporarily remove dependencies.yaml We'll re-add it after we get a working qt5.git wip/qt6 build. Change-Id: Ic6724070a03cd0b2e2535c3ad9d19215b1cdf891 Reviewed-by: Simon Hausmann --- dependencies.yaml | 1 - 1 file changed, 1 deletion(-) delete mode 100644 dependencies.yaml diff --git a/dependencies.yaml b/dependencies.yaml deleted file mode 100644 index c093387ce0..0000000000 --- a/dependencies.yaml +++ /dev/null @@ -1 +0,0 @@ -dependencies: {} From 3eedb2fbd08ab73bfe3e9a8456f2c5228637b52a Mon Sep 17 00:00:00 2001 From: Leander Beernaert Date: Tue, 23 Jul 2019 11:51:12 +0200 Subject: [PATCH 286/292] Fix crash when no plugins are specified MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the case that no plugins are specified, the above code would assert since we are not checking whether there is a value in the variable name. Change-Id: Ia5922a6936aff179ca19fdd10e335133cd30daf4 Reviewed-by: Friedemann Kleint Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qguiapplication.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 426f2aeece..a7fe2ec50a 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1177,14 +1177,18 @@ Q_LOGGING_CATEGORY(lcQpaPluginLoading, "qt.qpa.plugin"); static void init_platform(const QString &pluginNamesWithArguments, const QString &platformPluginPath, const QString &platformThemeName, int &argc, char **argv) { - QStringList plugins = pluginNamesWithArguments.split(QLatin1Char(';')); + QStringList plugins = pluginNamesWithArguments.split(QLatin1Char(';'), QString::SkipEmptyParts); QStringList platformArguments; QStringList availablePlugins = QPlatformIntegrationFactory::keys(platformPluginPath); for (const auto &pluginArgument : plugins) { // Split into platform name and arguments - QStringList arguments = pluginArgument.split(QLatin1Char(':')); + QStringList arguments = pluginArgument.split(QLatin1Char(':'), QString::SkipEmptyParts); + if (arguments.isEmpty()) + continue; const QString name = arguments.takeFirst().toLower(); QString argumentsKey = name; + if (name.isEmpty()) + continue; argumentsKey[0] = argumentsKey.at(0).toUpper(); arguments.append(QLibraryInfo::platformPluginArguments(argumentsKey)); From ae83398d82173e7d416e72952760180414ea3fb6 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 23 Jul 2019 13:26:54 +0200 Subject: [PATCH 287/292] Kill all QPictureIO Has been deprecated for a long time. Change-Id: I4579e3c2997c649f0fa66b9cdbcf8e7fc6d661a5 Reviewed-by: Lars Knoll --- src/gui/doc/snippets/picture/picture.cpp | 79 -- src/gui/image/image.pri | 2 - src/gui/image/qpicture.cpp | 832 +----------------- src/gui/image/qpicture.h | 78 +- src/gui/image/qpictureformatplugin.cpp | 135 --- src/gui/image/qpictureformatplugin.h | 76 -- src/tools/uic/qclass_lib_map.h | 3 - .../auto/gui/image/qpicture/tst_qpicture.cpp | 31 +- 8 files changed, 14 insertions(+), 1222 deletions(-) delete mode 100644 src/gui/image/qpictureformatplugin.cpp delete mode 100644 src/gui/image/qpictureformatplugin.h diff --git a/src/gui/doc/snippets/picture/picture.cpp b/src/gui/doc/snippets/picture/picture.cpp index 863476fdbf..807c263b19 100644 --- a/src/gui/doc/snippets/picture/picture.cpp +++ b/src/gui/doc/snippets/picture/picture.cpp @@ -80,82 +80,3 @@ int main() painter.end(); // painting done //! [1] } - - QPicture myPicture; - { - // FORMATS -//! [2] - const QStringList list = QPicture::inputFormatList(); - for (const QString &string : list) - myProcessing(string); -//! [2] - } - - { - // OUTPUT -//! [3] - const QStringList list = QPicture::outputFormatList(); - for (const QString &string : list) - myProcessing(string); -//! [3] - } - - { - // PIC READ -//! [4] - QPictureIO iio; - QPixmap pixmap; - iio.setFileName("vegeburger.pic"); - if (iio.read()) { // OK - QPicture picture = iio.picture(); - QPainter painter(&pixmap); - painter.drawPicture(0, 0, picture); - } -//! [4] - } - - { - QPixmap pixmap; - // PIC WRITE -//! [5] - QPictureIO iio; - QPicture picture; - QPainter painter(&picture); - painter.drawPixmap(0, 0, pixmap); - iio.setPicture(picture); - iio.setFileName("vegeburger.pic"); - iio.setFormat("PIC"); - if (iio.write()) - return true; // returned true if written successfully -//! [5] - } - -} - -// SVG READ -//! [6] -void readSVG(QPictureIO *picture) -{ - // read the picture using the picture->ioDevice() -} -//! [6] - -// SVG WRITE -//! [7] -void writeSVG(QPictureIO *picture) -{ - // write the picture using the picture->ioDevice() -} -//! [7] - -// USE SVG -void foo() { - -//! [8] - // add the SVG picture handler - // ... -//! [8] - QPictureIO::defineIOHandler("SVG", 0, 0, readSVG, writeSVG); - // ... - -} diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri index b482a6e142..76a4662b36 100644 --- a/src/gui/image/image.pri +++ b/src/gui/image/image.pri @@ -14,7 +14,6 @@ HEADERS += \ image/qpaintengine_pic_p.h \ image/qpicture.h \ image/qpicture_p.h \ - image/qpictureformatplugin.h \ image/qpixmap.h \ image/qpixmap_raster_p.h \ image/qpixmap_blitter_p.h \ @@ -38,7 +37,6 @@ SOURCES += \ image/qimagewriter.cpp \ image/qpaintengine_pic.cpp \ image/qpicture.cpp \ - image/qpictureformatplugin.cpp \ image/qpixmap.cpp \ image/qpixmapcache.cpp \ image/qplatformpixmap.cpp \ diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp index 8548f1857e..84de91353a 100644 --- a/src/gui/image/qpicture.cpp +++ b/src/gui/image/qpicture.cpp @@ -263,14 +263,14 @@ void QPicture::setData(const char* data, uint size) \sa save() */ -bool QPicture::load(const QString &fileName, const char *format) +bool QPicture::load(const QString &fileName) { QFile f(fileName); if (!f.open(QIODevice::ReadOnly)) { operator=(QPicture()); return false; } - return load(&f, format); + return load(&f); } /*! @@ -279,21 +279,8 @@ bool QPicture::load(const QString &fileName, const char *format) \a dev is the device to use for loading. */ -bool QPicture::load(QIODevice *dev, const char *format) +bool QPicture::load(QIODevice *dev) { - if(format) { -#ifndef QT_NO_PICTUREIO - QPictureIO io(dev, format); - if (io.read()) { - operator=(io.picture()); - return true; - } -#endif - qWarning("QPicture::load: No such picture format: %s", format); - operator=(QPicture()); - return false; - } - detach(); QByteArray a = dev->readAll(); @@ -311,7 +298,7 @@ bool QPicture::load(QIODevice *dev, const char *format) \sa load() */ -bool QPicture::save(const QString &fileName, const char *format) +bool QPicture::save(const QString &fileName) { if (paintingActive()) { qWarning("QPicture::save: still being painted on. " @@ -319,27 +306,10 @@ bool QPicture::save(const QString &fileName, const char *format) return false; } - - if(format) { -#ifndef QT_NO_PICTUREIO - QPictureIO io(fileName, format); - bool result = io.write(); - if (result) { - operator=(io.picture()); - } else if (format) -#else - bool result = false; -#endif - { - qWarning("QPicture::save: No such picture format: %s", format); - } - return result; - } - QFile f(fileName); if (!f.open(QIODevice::WriteOnly)) return false; - return save(&f, format); + return save(&f); } /*! @@ -348,7 +318,7 @@ bool QPicture::save(const QString &fileName, const char *format) \a dev is the device to use for saving. */ -bool QPicture::save(QIODevice *dev, const char *format) +bool QPicture::save(QIODevice *dev) { if (paintingActive()) { qWarning("QPicture::save: still being painted on. " @@ -356,22 +326,6 @@ bool QPicture::save(QIODevice *dev, const char *format) return false; } - if(format) { -#ifndef QT_NO_PICTUREIO - QPictureIO io(dev, format); - bool result = io.write(); - if (result) { - operator=(io.picture()); - } else if (format) -#else - bool result = false; -#endif - { - qWarning("QPicture::save: No such picture format: %s", format); - } - return result; - } - dev->write(d_func()->pictb.buffer(), d_func()->pictb.buffer().size()); return true; } @@ -1188,780 +1142,6 @@ QDataStream &operator>>(QDataStream &s, QPicture &r) } #endif // QT_NO_DATASTREAM - -#ifndef QT_NO_PICTUREIO - -QT_BEGIN_INCLUDE_NAMESPACE -#include "qregexp.h" -#include "qpictureformatplugin.h" -QT_END_INCLUDE_NAMESPACE - -#if QT_DEPRECATED_SINCE(5, 10) -/*! - \obsolete - - Returns a string that specifies the picture format of the file \a - fileName, or \nullptr if the file cannot be read or if the format - is not recognized. - - \sa load(), save() -*/ - -const char* QPicture::pictureFormat(const QString &fileName) -{ - const QByteArray format = QPictureIO::pictureFormat(fileName); - // This function returns a const char * from a QByteArray. - // Double check that the QByteArray is not detached, otherwise - // we would return a dangling pointer. - Q_ASSERT(!format.isDetached()); - return format; -} - -/*! - \obsolete - - Returns a list of picture formats that are supported for picture - input. - - \sa outputFormats(), inputFormatList(), QPictureIO -*/ -QList QPicture::inputFormats() -{ - return QPictureIO::inputFormats(); -} - -static QStringList qToStringList(const QList &arr) -{ - QStringList list; - const int count = arr.count(); - list.reserve(count); - for (int i = 0; i < count; ++i) - list.append(QString::fromLatin1(arr.at(i))); - return list; -} - -/*! - \obsolete - - Returns a list of picture formats that are supported for picture - input. - - Note that if you want to iterate over the list, you should iterate - over a copy, e.g. - \snippet picture/picture.cpp 2 - - \sa outputFormatList(), inputFormats(), QPictureIO -*/ -QStringList QPicture::inputFormatList() -{ - return qToStringList(QPictureIO::inputFormats()); -} - - -/*! - \obsolete - - Returns a list of picture formats that are supported for picture - output. - - Note that if you want to iterate over the list, you should iterate - over a copy, e.g. - \snippet picture/picture.cpp 3 - - \sa inputFormatList(), outputFormats(), QPictureIO -*/ -QStringList QPicture::outputFormatList() -{ - return qToStringList(QPictureIO::outputFormats()); -} - -/*! - \obsolete - - Returns a list of picture formats that are supported for picture - output. - - \sa inputFormats(), outputFormatList(), QPictureIO -*/ -QList QPicture::outputFormats() -{ - return QPictureIO::outputFormats(); -} -#endif // QT_DEPRECATED_SINCE(5, 10) - -/***************************************************************************** - QPictureIO member functions - *****************************************************************************/ - -/*! - \obsolete - - \class QPictureIO - - \brief The QPictureIO class contains parameters for loading and - saving pictures. - - \ingroup painting - \ingroup io - \inmodule QtGui - - QPictureIO contains a QIODevice object that is used for picture data - I/O. The programmer can install new picture file formats in addition - to those that Qt provides. - - You don't normally need to use this class; QPicture::load(), - QPicture::save(). - - \sa QPicture, QPixmap, QFile -*/ - -struct QPictureIOData -{ - QPicture pi; // picture - int iostat; // IO status - QByteArray frmt; // picture format - QIODevice *iodev; // IO device - QString fname; // file name - QString descr; // picture description - const char *parameters; - int quality; - float gamma; -}; - -/*! - Constructs a QPictureIO object with all parameters set to zero. -*/ - -QPictureIO::QPictureIO() -{ - init(); -} - -/*! - Constructs a QPictureIO object with the I/O device \a ioDevice and a - \a format tag. -*/ - -QPictureIO::QPictureIO(QIODevice *ioDevice, const char *format) -{ - init(); - d->iodev = ioDevice; - d->frmt = format; -} - -/*! - Constructs a QPictureIO object with the file name \a fileName and a - \a format tag. -*/ - -QPictureIO::QPictureIO(const QString &fileName, const char* format) -{ - init(); - d->frmt = format; - d->fname = fileName; -} - -/*! - Contains initialization common to all QPictureIO constructors. -*/ - -void QPictureIO::init() -{ - d = new QPictureIOData(); - d->parameters = 0; - d->quality = -1; // default quality of the current format - d->gamma=0.0f; - d->iostat = 0; - d->iodev = 0; -} - -/*! - Destroys the object and all related data. -*/ - -QPictureIO::~QPictureIO() -{ - if (d->parameters) - delete [] d->parameters; - delete d; -} - - -/***************************************************************************** - QPictureIO picture handler functions - *****************************************************************************/ - -class QPictureHandler -{ -public: - QPictureHandler(const char *f, const char *h, const QByteArray& fl, - picture_io_handler r, picture_io_handler w); - QByteArray format; // picture format - QRegExp header; // picture header pattern - enum TMode { Untranslated=0, TranslateIn, TranslateInOut } text_mode; - picture_io_handler read_picture; // picture read function - picture_io_handler write_picture; // picture write function - bool obsolete; // support not "published" -}; - -QPictureHandler::QPictureHandler(const char *f, const char *h, const QByteArray& fl, - picture_io_handler r, picture_io_handler w) - : format(f), header(QString::fromLatin1(h)) -{ - text_mode = Untranslated; - if (fl.contains('t')) - text_mode = TranslateIn; - else if (fl.contains('T')) - text_mode = TranslateInOut; - obsolete = fl.contains('O'); - read_picture = r; - write_picture = w; -} - -typedef QList QPHList; -Q_GLOBAL_STATIC(QPHList, pictureHandlers) - -void qt_init_picture_plugins() -{ - typedef QMultiMap PluginKeyMap; - typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator; - - static QBasicMutex mutex; - QMutexLocker locker(&mutex); - static QFactoryLoader loader(QPictureFormatInterface_iid, - QStringLiteral("/pictureformats")); - - const PluginKeyMap keyMap = loader.keyMap(); - const PluginKeyMapConstIterator cend = keyMap.constEnd(); - for (PluginKeyMapConstIterator it = keyMap.constBegin(); it != cend; ++it) { - if (QPictureFormatPlugin *format = qobject_cast(loader.instance(it.key()))) - format->installIOHandler(it.value()); - } -} - -static void cleanup() -{ - // make sure that picture handlers are delete before plugin manager - if (QPHList *list = pictureHandlers()) { - qDeleteAll(*list); - list->clear(); - } -} - -void qt_init_picture_handlers() // initialize picture handlers -{ - static QBasicAtomicInt done = Q_BASIC_ATOMIC_INITIALIZER(0); - if (done.testAndSetRelaxed(0, 1)) { - qAddPostRoutine(cleanup); - } -} - -static QPictureHandler *get_picture_handler(const char *format) -{ // get pointer to handler - qt_init_picture_handlers(); - qt_init_picture_plugins(); - if (QPHList *list = pictureHandlers()) { - for (int i = 0; i < list->size(); ++i) { - if (list->at(i)->format == format) - return list->at(i); - } - } - return 0; // no such handler -} - - -/*! - Defines a picture I/O handler for the picture format called \a - format, which is recognized using the regular - expression defined in \a header, read using \a readPicture and - written using \a writePicture. - - \a flags is a string of single-character flags for this format. - The only flag defined currently is T (upper case), so the only - legal value for \a flags are "T" and the empty string. The "T" - flag means that the picture file is a text file, and Qt should treat - all newline conventions as equivalent. (XPM files and some PPM - files are text files for example.) - - \a format is used to select a handler to write a QPicture; \a header - is used to select a handler to read an picture file. - - If \a readPicture is \nullptr, the QPictureIO will not be able - to read pictures in \a format. If \a writePicture is \nullptr, - the QPictureIO will not be able to write pictures in \a format. If - both are null, the QPictureIO object is valid but useless. - - Example: - \snippet picture/picture.cpp 6 - \codeline - \snippet picture/picture.cpp 7 - \codeline - \snippet picture/picture.cpp 8 - - Before the regular expression test, all the 0 bytes in the file header are - converted to 1 bytes. This is done because when Qt was ASCII-based, QRegExp - could not handle 0 bytes in strings. - - The regexp is only applied on the first 14 bytes of the file. - - (Note that if one handlerIO supports writing a format and another - supports reading it, Qt supports both reading and writing. If two - handlers support the same operation, Qt chooses one arbitrarily.) -*/ - -void QPictureIO::defineIOHandler(const char *format, - const char *header, - const char *flags, - picture_io_handler readPicture, - picture_io_handler writePicture) -{ - qt_init_picture_handlers(); - if (QPHList *list = pictureHandlers()) { - QPictureHandler *p; - p = new QPictureHandler(format, header, QByteArray(flags), readPicture, writePicture); - list->prepend(p); - } -} - - -/***************************************************************************** - QPictureIO normal member functions - *****************************************************************************/ - -/*! - Returns the picture currently set. - - \sa setPicture() -*/ -const QPicture &QPictureIO::picture() const { return d->pi; } - -/*! - Returns the picture's IO status. A non-zero value indicates an - error, whereas 0 means that the IO operation was successful. - - \sa setStatus() -*/ -int QPictureIO::status() const { return d->iostat; } - -/*! - Returns the picture format string or \nullptr if no format has been - explicitly set. -*/ -const char *QPictureIO::format() const { return d->frmt; } - -/*! - Returns the IO device currently set. - - \sa setIODevice() -*/ -QIODevice *QPictureIO::ioDevice() const { return d->iodev; } - -/*! - Returns the file name currently set. - - \sa setFileName() -*/ -QString QPictureIO::fileName() const { return d->fname; } - - -/*! - Returns the picture description string. - - \sa setDescription() -*/ -QString QPictureIO::description() const { return d->descr; } - -/*! - Sets the picture to \a picture. - - \sa picture() -*/ -void QPictureIO::setPicture(const QPicture &picture) -{ - d->pi = picture; -} - -/*! - Sets the picture IO status to \a status. A non-zero value indicates - an error, whereas 0 means that the IO operation was successful. - - \sa status() -*/ -void QPictureIO::setStatus(int status) -{ - d->iostat = status; -} - -/*! - Sets the picture format to \a format for the picture to be read or - written. - - It is necessary to specify a format before writing an picture, but - it is not necessary to specify a format before reading an picture. - - If no format has been set, Qt guesses the picture format before - reading it. If a format is set the picture will only be read if it - has that format. - - \sa read(), write(), format() -*/ -void QPictureIO::setFormat(const char *format) -{ - d->frmt = format; -} - -/*! - Sets the IO device to be used for reading or writing an picture. - - Setting the IO device allows pictures to be read/written to any - block-oriented QIODevice. - - If \a ioDevice is not null, this IO device will override file name - settings. - - \sa setFileName() -*/ -void QPictureIO::setIODevice(QIODevice *ioDevice) -{ - d->iodev = ioDevice; -} - -/*! - Sets the name of the file to read or write an picture from to \a - fileName. - - \sa setIODevice() -*/ -void QPictureIO::setFileName(const QString &fileName) -{ - d->fname = fileName; -} - -/*! - Returns the quality of the written picture, related to the - compression ratio. - - \sa setQuality(), QPicture::save() -*/ -int QPictureIO::quality() const -{ - return d->quality; -} - -/*! - Sets the quality of the written picture to \a q, related to the - compression ratio. - - \a q must be in the range -1..100. Specify 0 to obtain small - compressed files, 100 for large uncompressed files. (-1 signifies - the default compression.) - - \sa quality(), QPicture::save() -*/ - -void QPictureIO::setQuality(int q) -{ - d->quality = q; -} - -/*! - Returns the picture's parameters string. - - \sa setParameters() -*/ - -const char *QPictureIO::parameters() const -{ - return d->parameters; -} - -/*! - Sets the picture's parameter string to \a parameters. This is for - picture handlers that require special parameters. - - Although the current picture formats supported by Qt ignore the - parameters string, it may be used in future extensions or by - contributions (for example, JPEG). - - \sa parameters() -*/ - -void QPictureIO::setParameters(const char *parameters) -{ - if (d->parameters) - delete [] d->parameters; - d->parameters = qstrdup(parameters); -} - -/*! - Sets the gamma value at which the picture will be viewed to \a - gamma. If the picture format stores a gamma value for which the - picture is intended to be used, then this setting will be used to - modify the picture. Setting to 0.0 will disable gamma correction - (i.e. any specification in the file will be ignored). - - The default value is 0.0. - - \sa gamma() -*/ -void QPictureIO::setGamma(float gamma) -{ - d->gamma=gamma; -} - -/*! - Returns the gamma value at which the picture will be viewed. - - \sa setGamma() -*/ -float QPictureIO::gamma() const -{ - return d->gamma; -} - -/*! - Sets the picture description string for picture handlers that support - picture descriptions to \a description. - - Currently, no picture format supported by Qt uses the description - string. -*/ - -void QPictureIO::setDescription(const QString &description) -{ - d->descr = description; -} - - -/*! - Returns a string that specifies the picture format of the file \a - fileName, or null if the file cannot be read or if the format is - not recognized. -*/ - -QByteArray QPictureIO::pictureFormat(const QString &fileName) -{ - QFile file(fileName); - QByteArray format; - if (!file.open(QIODevice::ReadOnly)) - return format; - format = pictureFormat(&file); - file.close(); - return format; -} - -/*! - \overload - - Returns a string that specifies the picture format of the picture read - from IO device \a d, or 0 if the device cannot be read or if the - format is not recognized. - - Make sure that \a d is at the right position in the device (for - example, at the beginning of the file). - - \sa QIODevice::pos() -*/ - -QByteArray QPictureIO::pictureFormat(QIODevice *d) -{ - // if you change this change the documentation for defineIOHandler() - const int buflen = 14; - - char buf[buflen]; - char buf2[buflen]; - qt_init_picture_handlers(); - qt_init_picture_plugins(); - int pos = d->pos(); // save position - int rdlen = d->read(buf, buflen); // read a few bytes - - QByteArray format; - if (rdlen != buflen) - return format; - - memcpy(buf2, buf, buflen); - - for (int n = 0; n < rdlen; n++) - if (buf[n] == '\0') - buf[n] = '\001'; - if (rdlen > 0) { - buf[rdlen - 1] = '\0'; - QString bufStr = QString::fromLatin1(buf); - if (QPHList *list = pictureHandlers()) { - for (int i = 0; i < list->size(); ++i) { - if (list->at(i)->header.indexIn(bufStr) != -1) { // try match with headers - format = list->at(i)->format; - break; - } - } - } - } - d->seek(pos); // restore position - return format; -} - -/*! - Returns a sorted list of picture formats that are supported for - picture input. -*/ -QList QPictureIO::inputFormats() -{ - QList result; - - qt_init_picture_handlers(); - qt_init_picture_plugins(); - - if (QPHList *list = pictureHandlers()) { - for (int i = 0; i < list->size(); ++i) { - QPictureHandler *p = list->at(i); - if (p->read_picture && !p->obsolete && !result.contains(p->format)) - result.append(p->format); - } - } - std::sort(result.begin(), result.end()); - - return result; -} - -/*! - Returns a sorted list of picture formats that are supported for - picture output. -*/ -QList QPictureIO::outputFormats() -{ - qt_init_picture_handlers(); - qt_init_picture_plugins(); - - QList result; - if (QPHList *list = pictureHandlers()) { - for (int i = 0; i < list->size(); ++i) { - QPictureHandler *p = list->at(i); - if (p->write_picture && !p->obsolete && !result.contains(p->format)) - result.append(p->format); - } - } - return result; -} - - - -/*! - Reads an picture into memory and returns \c true if the picture was - successfully read; otherwise returns \c false. - - Before reading an picture you must set an IO device or a file name. - If both an IO device and a file name have been set, the IO device - will be used. - - Setting the picture file format string is optional. - - Note that this function does \e not set the \l{format()}{format} used to read the picture. If you need that - information, use the pictureFormat() static functions. - - Example: - - \snippet picture/picture.cpp 4 - - \sa setIODevice(), setFileName(), setFormat(), write(), QPixmap::load() -*/ -bool QPictureIO::read() -{ - QFile file; - QByteArray picture_format; - QPictureHandler *h; - - if (d->iodev) { // read from io device - // ok, already open - } else if (!d->fname.isEmpty()) { // read from file - file.setFileName(d->fname); - if (!file.open(QIODevice::ReadOnly)) - return false; // cannot open file - d->iodev = &file; - } else { // no file name or io device - return false; - } - if (d->frmt.isEmpty()) { - // Try to guess format - picture_format = pictureFormat(d->iodev); // get picture format - if (picture_format.isEmpty()) { - if (file.isOpen()) { // unknown format - file.close(); - d->iodev = 0; - } - return false; - } - } else { - picture_format = d->frmt; - } - - h = get_picture_handler(picture_format); - if (file.isOpen()) { -#if !defined(Q_OS_UNIX) - if (h && h->text_mode) { // reopen in translated mode - file.close(); - file.open(QIODevice::ReadOnly | QIODevice::Text); - } - else -#endif - file.seek(0); // position to start - } - d->iostat = 1; // assume error - - if (h && h->read_picture) - (*h->read_picture)(this); - - if (file.isOpen()) { // picture was read using file - file.close(); - d->iodev = 0; - } - return d->iostat == 0; // picture successfully read? -} - - -/*! - Writes an picture to an IO device and returns \c true if the picture was - successfully written; otherwise returns \c false. - - Before writing an picture you must set an IO device or a file name. - If both an IO device and a file name have been set, the IO device - will be used. - - The picture will be written using the specified picture format. - - Example: - \snippet picture/picture.cpp 5 - - \sa setIODevice(), setFileName(), setFormat(), read(), QPixmap::save() -*/ -bool QPictureIO::write() -{ - if (d->frmt.isEmpty()) - return false; - QPictureHandler *h = get_picture_handler(d->frmt); - if (!h || !h->write_picture) { - qWarning("QPictureIO::write: No such picture format handler: %s", - format()); - return false; - } - QFile file; - if (!d->iodev && !d->fname.isEmpty()) { - file.setFileName(d->fname); - bool translate = h->text_mode==QPictureHandler::TranslateInOut; - QIODevice::OpenMode fmode = translate ? QIODevice::WriteOnly | QIODevice::Text : QIODevice::OpenMode(QIODevice::WriteOnly); - if (!file.open(fmode)) // couldn't create file - return false; - d->iodev = &file; - } - d->iostat = 1; - (*h->write_picture)(this); - if (file.isOpen()) { // picture was written using file - file.close(); - d->iodev = 0; - } - return d->iostat == 0; // picture successfully written? -} -#endif //QT_NO_PICTUREIO - QT_END_NAMESPACE #endif // QT_NO_PICTURE diff --git a/src/gui/image/qpicture.h b/src/gui/image/qpicture.h index 189e57b9a3..34860985ed 100644 --- a/src/gui/image/qpicture.h +++ b/src/gui/image/qpicture.h @@ -48,7 +48,6 @@ QT_BEGIN_NAMESPACE - #ifndef QT_NO_PICTURE class QPicturePrivate; @@ -69,10 +68,10 @@ public: bool play(QPainter *p); - bool load(QIODevice *dev, const char *format = nullptr); - bool load(const QString &fileName, const char *format = nullptr); - bool save(QIODevice *dev, const char *format = nullptr); - bool save(const QString &fileName, const char *format = nullptr); + bool load(QIODevice *dev); + bool load(const QString &fileName); + bool save(QIODevice *dev); + bool save(const QString &fileName); QRect boundingRect() const; void setBoundingRect(const QRect &r); @@ -88,14 +87,6 @@ public: friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QPicture &p); friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QPicture &p); -#if QT_DEPRECATED_SINCE(5, 10) - static QT_DEPRECATED const char* pictureFormat(const QString &fileName); - static QT_DEPRECATED QList inputFormats(); - static QT_DEPRECATED QList outputFormats(); - static QT_DEPRECATED QStringList inputFormatList(); - static QT_DEPRECATED QStringList outputFormatList(); -#endif // QT_DEPRECATED_SINCE(5, 10) - QPaintEngine *paintEngine() const override; protected: @@ -118,67 +109,6 @@ public: Q_DECLARE_SHARED(QPicture) - -#ifndef QT_NO_PICTUREIO -class QIODevice; -class QPictureIO; -typedef void (*picture_io_handler)(QPictureIO *); // picture IO handler - -struct QPictureIOData; - -class Q_GUI_EXPORT QPictureIO -{ -public: - QPictureIO(); - QPictureIO(QIODevice *ioDevice, const char *format); - QPictureIO(const QString &fileName, const char *format); - ~QPictureIO(); - - const QPicture &picture() const; - int status() const; - const char *format() const; - QIODevice *ioDevice() const; - QString fileName() const; - int quality() const; - QString description() const; - const char *parameters() const; - float gamma() const; - - void setPicture(const QPicture &); - void setStatus(int); - void setFormat(const char *); - void setIODevice(QIODevice *); - void setFileName(const QString &); - void setQuality(int); - void setDescription(const QString &); - void setParameters(const char *); - void setGamma(float); - - bool read(); - bool write(); - - static QByteArray pictureFormat(const QString &fileName); - static QByteArray pictureFormat(QIODevice *); - static QList inputFormats(); - static QList outputFormats(); - - static void defineIOHandler(const char *format, - const char *header, - const char *flags, - picture_io_handler read_picture, - picture_io_handler write_picture); - -private: - Q_DISABLE_COPY(QPictureIO) - - void init(); - - QPictureIOData *d; -}; - -#endif //QT_NO_PICTUREIO - - /***************************************************************************** QPicture stream functions *****************************************************************************/ diff --git a/src/gui/image/qpictureformatplugin.cpp b/src/gui/image/qpictureformatplugin.cpp deleted file mode 100644 index ef57ad720f..0000000000 --- a/src/gui/image/qpictureformatplugin.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qpictureformatplugin.h" -#if !defined(QT_NO_PICTURE) -#include "qpicture.h" - -QT_BEGIN_NAMESPACE - -/*! - \obsolete - - \class QPictureFormatPlugin - \brief The QPictureFormatPlugin class provides an abstract base - for custom picture format plugins. - - \ingroup plugins - \inmodule QtGui - - The picture format plugin is a simple plugin interface that makes - it easy to create custom picture formats that can be used - transparently by applications. - - Writing an picture format plugin is achieved by subclassing this - base class, reimplementing the pure virtual functions - loadPicture(), savePicture(), and installIOHandler(), and - exporting the class with the Q_PLUGIN_METADATA() macro. - - The json file containing the metadata should contain one entry - with the list of picture formats supported by the plugin: - - \code - { "Keys": [ "mypictureformat" ] } - \endcode - - \sa {How to Create Qt Plugins} -*/ - -/*! - \fn bool QPictureFormatPlugin::installIOHandler(const QString &format) - - Installs a QPictureIO picture I/O handler for the picture format \a - format. Returns \c true on success. -*/ - - -/*! - Constructs an picture format plugin with the given \a parent. - This is invoked automatically by the moc generated code that exports the plugin. -*/ -QPictureFormatPlugin::QPictureFormatPlugin(QObject *parent) - : QObject(parent) -{ -} - -/*! - Destroys the picture format plugin. - - You never have to call this explicitly. Qt destroys a plugin - automatically when it is no longer used. -*/ -QPictureFormatPlugin::~QPictureFormatPlugin() -{ -} - - -/*! - Loads the picture stored in the file called \a fileName, with the - given \a format, into *\a picture. Returns \c true on success; - otherwise returns \c false. - - \sa savePicture() -*/ -bool QPictureFormatPlugin::loadPicture(const QString &format, const QString &fileName, QPicture *picture) -{ - Q_UNUSED(format) - Q_UNUSED(fileName) - Q_UNUSED(picture) - return false; -} - -/*! - Saves the given \a picture into the file called \a fileName, - using the specified \a format. Returns \c true on success; otherwise - returns \c false. - - \sa loadPicture() -*/ -bool QPictureFormatPlugin::savePicture(const QString &format, const QString &fileName, const QPicture &picture) -{ - Q_UNUSED(format) - Q_UNUSED(fileName) - Q_UNUSED(picture) - return false; -} - -#endif // QT_NO_PICTURE - -QT_END_NAMESPACE diff --git a/src/gui/image/qpictureformatplugin.h b/src/gui/image/qpictureformatplugin.h deleted file mode 100644 index 3f59c04d79..0000000000 --- a/src/gui/image/qpictureformatplugin.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QPICTUREFORMATPLUGIN_H -#define QPICTUREFORMATPLUGIN_H - -#include -#include -#include - -QT_BEGIN_NAMESPACE - - -#if !defined(QT_NO_PICTURE) - -class QPicture; -class QImage; -class QString; -class QStringList; - -#define QPictureFormatInterface_iid "org.qt-project.Qt.QPictureFormatInterface" - -class Q_GUI_EXPORT QPictureFormatPlugin : public QObject -{ - Q_OBJECT -public: - explicit QPictureFormatPlugin(QObject *parent = nullptr); - ~QPictureFormatPlugin(); - - virtual bool loadPicture(const QString &format, const QString &filename, QPicture *pic); - virtual bool savePicture(const QString &format, const QString &filename, const QPicture &pic); - virtual bool installIOHandler(const QString &format) = 0; - -}; - -#endif // QT_NO_PICTURE - -QT_END_NAMESPACE - -#endif // QPICTUREFORMATPLUGIN_H diff --git a/src/tools/uic/qclass_lib_map.h b/src/tools/uic/qclass_lib_map.h index 8cebe65a00..bf3882edd1 100644 --- a/src/tools/uic/qclass_lib_map.h +++ b/src/tools/uic/qclass_lib_map.h @@ -644,9 +644,6 @@ QT_CLASS_LIB(QImageReader, QtGui, qimagereader.h) QT_CLASS_LIB(QImageWriter, QtGui, qimagewriter.h) QT_CLASS_LIB(QMovie, QtGui, qmovie.h) QT_CLASS_LIB(QPicture, QtGui, qpicture.h) -QT_CLASS_LIB(QPictureIO, QtGui, qpicture.h) -QT_CLASS_LIB(QPictureFormatInterface, QtGui, qpictureformatplugin.h) -QT_CLASS_LIB(QPictureFormatPlugin, QtGui, qpictureformatplugin.h) QT_CLASS_LIB(QPixmap, QtGui, qpixmap.h) QT_CLASS_LIB(QPixmapCache, QtGui, qpixmapcache.h) QT_CLASS_LIB(QAbstractItemDelegate, QtWidgets, qabstractitemdelegate.h) diff --git a/tests/auto/gui/image/qpicture/tst_qpicture.cpp b/tests/auto/gui/image/qpicture/tst_qpicture.cpp index ec6bb8dcee..6287960457 100644 --- a/tests/auto/gui/image/qpicture/tst_qpicture.cpp +++ b/tests/auto/gui/image/qpicture/tst_qpicture.cpp @@ -37,6 +37,8 @@ #include #include +#ifndef QT_NO_PICTURE + class tst_QPicture : public QObject { Q_OBJECT @@ -45,7 +47,6 @@ public: tst_QPicture(); private slots: - void getSetCheck(); void devType(); void paintingActive(); void boundingRect(); @@ -56,31 +57,6 @@ private slots: void boundaryValues(); }; -// Testing get/set functions -void tst_QPicture::getSetCheck() -{ - QPictureIO obj1; - // const QPicture & QPictureIO::picture() - // void QPictureIO::setPicture(const QPicture &) - // const char * QPictureIO::format() - // void QPictureIO::setFormat(const char *) - const char var2[] = "PNG"; - obj1.setFormat(var2); - QCOMPARE(var2, obj1.format()); - obj1.setFormat((char *)0); - // The format is stored internally in a QString, so return is always a valid char * - QVERIFY(QString(obj1.format()).isEmpty()); - - // const char * QPictureIO::parameters() - // void QPictureIO::setParameters(const char *) - const char var3[] = "Bogus data"; - obj1.setParameters(var3); - QCOMPARE(var3, obj1.parameters()); - obj1.setParameters((char *)0); - // The format is stored internally in a QString, so return is always a valid char * - QVERIFY(QString(obj1.parameters()).isEmpty()); -} - tst_QPicture::tst_QPicture() { } @@ -316,6 +292,7 @@ void tst_QPicture::boundaryValues() painter.end(); } - QTEST_MAIN(tst_QPicture) #include "tst_qpicture.moc" + +#endif // QT_NO_PICTURE From 49400214e0562e519f918bd88496eda91816c0e0 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 8 Oct 2018 14:58:56 +0200 Subject: [PATCH 288/292] Get rid of the deprecated QSet::to/fromList methods This is the first step towards removing/deprecating QList in Qt 6. Change-Id: I043151d25a1dc17fc748fb1b4686c4b6c9c5e90b Reviewed-by: Marc Mutz --- src/corelib/tools/qset.h | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h index 19d6982133..f6db47ed59 100644 --- a/src/corelib/tools/qset.h +++ b/src/corelib/tools/qset.h @@ -246,12 +246,6 @@ public: { QSet result = *this; result -= other; return result; } QList values() const; -#if QT_VERSION < QT_VERSION_CHECK(6,0,0) - Q_DECL_DEPRECATED_X("Use values() instead.") - QList toList() const { return values(); } - Q_DECL_DEPRECATED_X("Use QSet(list.begin(), list.end()) instead.") - static QSet fromList(const QList &list); -#endif private: Hash q_hash; @@ -376,30 +370,6 @@ Q_OUTOFLINE_TEMPLATE QList QSet::values() const return result; } -#if QT_VERSION < QT_VERSION_CHECK(6,0,0) -template -Q_OUTOFLINE_TEMPLATE QSet QList::toSet() const -{ - QSet result; - result.reserve(size()); - for (int i = 0; i < size(); ++i) - result.insert(at(i)); - return result; -} - -template -QSet QSet::fromList(const QList &list) -{ - return list.toSet(); -} - -template -QList QList::fromSet(const QSet &set) -{ - return set.toList(); -} -#endif - Q_DECLARE_SEQUENTIAL_ITERATOR(Set) #if !defined(QT_NO_JAVA_STYLE_ITERATORS) From e125e6837cf9a85506206fbef6a7aa716ebcb559 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 26 Jun 2019 17:41:59 +0200 Subject: [PATCH 289/292] QObject: remove the undocumented userData() feature Change-Id: I74445b964eb32bf60f389fcb50bd4929de01230e Reviewed-by: Lars Knoll --- src/corelib/kernel/qobject.cpp | 56 ------------------- src/corelib/kernel/qobject.h | 24 -------- src/corelib/kernel/qobject_p.h | 3 - .../corelib/kernel/qobject/tst_qobject.cpp | 48 ---------------- 4 files changed, 131 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index d364ae1087..d6e8ced665 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -233,10 +233,6 @@ QObjectPrivate::~QObjectPrivate() if (metaObject) metaObject->objectDestroyed(q_ptr); -#ifndef QT_NO_USERDATA - if (extraData) - qDeleteAll(extraData->userData); -#endif delete extraData; } @@ -4188,58 +4184,6 @@ void QObject::dumpObjectInfo() const } } -#ifndef QT_NO_USERDATA -static QBasicAtomicInteger user_data_registration = Q_BASIC_ATOMIC_INITIALIZER(0); - -/*! - \internal - */ -uint QObject::registerUserData() -{ - return user_data_registration.fetchAndAddRelaxed(1); -} - -/*! - \fn QObjectUserData::QObjectUserData() - \internal - */ - -/*! - \internal - */ -QObjectUserData::~QObjectUserData() -{ -} - -/*! - \internal - */ -void QObject::setUserData(uint id, QObjectUserData* data) -{ - Q_D(QObject); - if (!d->extraData) - d->extraData = new QObjectPrivate::ExtraData; - - if (d->extraData->userData.size() <= (int) id) - d->extraData->userData.resize((int) id + 1); - d->extraData->userData[id] = data; -} - -/*! - \internal - */ -QObjectUserData* QObject::userData(uint id) const -{ - Q_D(const QObject); - if (!d->extraData) - return 0; - if ((int)id < d->extraData->userData.size()) - return d->extraData->userData.at(id); - return 0; -} - -#endif // QT_NO_USERDATA - #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QObject *o) diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 540b8b32c1..296552c2f2 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -78,12 +78,6 @@ class QRegExp; #if QT_CONFIG(regularexpression) class QRegularExpression; #endif -#if !QT_DEPRECATED_SINCE(5, 14) || QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) -# define QT_NO_USERDATA -#endif -#ifndef QT_NO_USERDATA -class QObjectUserData; -#endif struct QDynamicMetaObjectData; typedef QList QObjectList; @@ -408,15 +402,6 @@ public: QList dynamicPropertyNames() const; #endif // QT_NO_PROPERTIES -#ifndef QT_NO_USERDATA - QT_DEPRECATED_VERSION_5_14 - static uint registerUserData(); - QT_DEPRECATED_VERSION_X_5_14("Use setProperty()") - void setUserData(uint id, QObjectUserData* data); - QT_DEPRECATED_VERSION_X_5_14("Use property()") - QObjectUserData* userData(uint id) const; -#endif // QT_NO_USERDATA - Q_SIGNALS: void destroyed(QObject * = nullptr); void objectNameChanged(const QString &objectName, QPrivateSignal); @@ -485,15 +470,6 @@ inline QMetaObject::Connection QObject::connect(const QObject *asender, const ch inline const QMetaObject *qt_getQtMetaObject() noexcept { return &QObject::staticQtMetaObject; } -#ifndef QT_NO_USERDATA -class Q_CORE_EXPORT QObjectUserData { - Q_DISABLE_COPY(QObjectUserData) -public: - QObjectUserData() = default; - virtual ~QObjectUserData(); -}; -#endif - #if QT_DEPRECATED_SINCE(5, 0) template inline QT_DEPRECATED T qFindChild(const QObject *o, const QString &name = QString()) diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 95ffc1b2e8..393d57b20a 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -113,9 +113,6 @@ public: struct ExtraData { ExtraData() {} - #ifndef QT_NO_USERDATA - QVector userData; - #endif QList propertyNames; QVector propertyValues; QVector runningTimers; diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index a805bfb747..676999a08c 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -81,9 +81,6 @@ private slots: void senderTest(); void declareInterface(); void qpointerResetBeforeDestroyedSignal(); -#ifndef QT_NO_USERDATA - void testUserData(); -#endif void childDeletesItsSibling(); void dynamicProperties(); void floatProperty(); @@ -2341,51 +2338,6 @@ void tst_QObject::declareInterface() } -#ifndef QT_NO_USERDATA -class CustomData : public QObjectUserData -{ -public: - int id; -}; - -void tst_QObject::testUserData() -{ - const int USER_DATA_COUNT = 100; - int user_data_ids[USER_DATA_COUNT]; - - // Register a few - for (int i=0; ibounded(USER_DATA_COUNT); - int p2 = QRandomGenerator::global()->bounded(USER_DATA_COUNT); - - int tmp = user_data_ids[p1]; - user_data_ids[p1] = user_data_ids[p2]; - user_data_ids[p2] = tmp; - } - - // insert the user data into an object - QObject my_test_object; - for (int i=0; iid = user_data_ids[i]; - my_test_object.setUserData(data->id, data); - } - - // verify that all ids and positions are matching - for (int i=0; i(my_test_object.userData(id)); - QVERIFY(data != nullptr); - QCOMPARE(data->id, id); - } -} -#endif // QT_NO_USERDATA - class DestroyedListener : public QObject { Q_OBJECT From 8811e96aac7537bae049860b90adf425042afb31 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Tue, 20 Aug 2019 11:04:52 +0200 Subject: [PATCH 290/292] Re-add dependencies.yaml now that qt5.git wip/qt6 builds fine Change-Id: I732f4f7520e49ec0cca8a497638fa389fc7bc032 Reviewed-by: Aapo Keskimolo --- dependencies.yaml | 1 + 1 file changed, 1 insertion(+) create mode 100644 dependencies.yaml diff --git a/dependencies.yaml b/dependencies.yaml new file mode 100644 index 0000000000..c093387ce0 --- /dev/null +++ b/dependencies.yaml @@ -0,0 +1 @@ +dependencies: {} From 92a9778026e2cfb26281df9ac020eb6799ea2f7e Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 22 Aug 2019 10:38:50 +0200 Subject: [PATCH 291/292] QNativeGestureEvent: clean up for Qt 6 Make the touch device a member instead of holding it in a static QHash, indexed by event address. Change-Id: I21588ede2ebdde70eea2844ded2fb880700b92fb Reviewed-by: Friedemann Kleint --- src/gui/kernel/qevent.cpp | 17 +++-------------- src/gui/kernel/qevent.h | 3 ++- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index ec52791010..96f61e7ae9 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -2686,10 +2686,6 @@ QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QPoin { } #endif -typedef QHash NativeGestureEventDataHash; -// ### Qt6: move this to a member in QNativeGestureEvent -Q_GLOBAL_STATIC(NativeGestureEventDataHash, g_nativeGestureEventDataHash) - /*! Constructs a native gesture event of type \a type originating from \a device. @@ -2704,27 +2700,20 @@ QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QTouc const QPointF &screenPos, qreal realValue, ulong sequenceId, quint64 intValue) : QInputEvent(QEvent::NativeGesture), mGestureType(type), mLocalPos(localPos), mWindowPos(windowPos), mScreenPos(screenPos), mRealValue(realValue), - mSequenceId(sequenceId), mIntValue(intValue) + mSequenceId(sequenceId), mIntValue(intValue), mDevice(device) { - g_nativeGestureEventDataHash->insert(this, device); } QNativeGestureEvent::~QNativeGestureEvent() -{ - g_nativeGestureEventDataHash->remove(this); -} + = default; /*! + \fn const QTouchDevice *QNativeGestureEvent::device() const \since 5.10 Returns the device. */ -const QTouchDevice *QNativeGestureEvent::device() const -{ - return g_nativeGestureEventDataHash->value(this); -} - /*! \fn QNativeGestureEvent::gestureType() const \since 5.2 diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index b73d90529a..10ef01fa1d 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -350,7 +350,7 @@ public: const QPointF &windowPos() const { return mWindowPos; } const QPointF &screenPos() const { return mScreenPos; } - const QTouchDevice *device() const; + const QTouchDevice *device() const { return mDevice; } protected: Qt::NativeGestureType mGestureType; @@ -360,6 +360,7 @@ protected: qreal mRealValue; ulong mSequenceId; quint64 mIntValue; + const QTouchDevice *mDevice; }; #endif // QT_NO_GESTURES From 7e8705f6632428a8d9a937ab5fe087999347b3dd Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 28 Aug 2019 09:53:48 +0200 Subject: [PATCH 292/292] Revert "Re-add dependencies.yaml now that qt5.git wip/qt6 builds fine" This reverts commit 8811e96aac7537bae049860b90adf425042afb31. As discussed we shouldn't use the files until we have an easier mechanism for updating in place. Change-Id: I34bbed8ac2f11005db3a9c20621d797a110d8b31 Reviewed-by: Simon Hausmann --- dependencies.yaml | 1 - 1 file changed, 1 deletion(-) delete mode 100644 dependencies.yaml diff --git a/dependencies.yaml b/dependencies.yaml deleted file mode 100644 index c093387ce0..0000000000 --- a/dependencies.yaml +++ /dev/null @@ -1 +0,0 @@ -dependencies: {}