From 31e0d171d605159a83dbee3379a38e4dcd1f4b19 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 6 Aug 2019 09:52:34 +0200 Subject: Fix qinstall on Windows for directories containing read-only files Initial patch by: Vlad Lipskiy Fixes: QTBUG-77299 Change-Id: I803b809d1f23d844252b701cb070f6e4ba34eca1 Reviewed-by: Oliver Wolff --- qmake/main.cpp | 42 ++++++++++++++++++++++++++++++------ tests/auto/tools/qmake/tst_qmake.cpp | 3 --- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/qmake/main.cpp b/qmake/main.cpp index a598296898..dd1cca9633 100644 --- a/qmake/main.cpp +++ b/qmake/main.cpp @@ -242,6 +242,39 @@ static int doLink(int argc, char **argv) #endif +static bool setFilePermissions(QFile &file, QFileDevice::Permissions permissions) +{ + if (file.setPermissions(permissions)) + return true; + fprintf(stderr, "Error setting permissions on %s: %s\n", + qPrintable(file.fileName()), qPrintable(file.errorString())); + return false; +} + +static bool copyFileTimes(QFile &targetFile, const QString &sourceFilePath, + bool mustEnsureWritability, QString *errorString) +{ +#ifdef Q_OS_WIN + bool mustRestorePermissions = false; + QFileDevice::Permissions targetPermissions; + if (mustEnsureWritability) { + targetPermissions = targetFile.permissions(); + if (!targetPermissions.testFlag(QFileDevice::WriteUser)) { + mustRestorePermissions = true; + if (!setFilePermissions(targetFile, targetPermissions | QFileDevice::WriteUser)) + return false; + } + } +#endif + if (!IoUtils::touchFile(targetFile.fileName(), sourceFilePath, errorString)) + return false; +#ifdef Q_OS_WIN + if (mustRestorePermissions && !setFilePermissions(targetFile, targetPermissions)) + return false; +#endif + return true; +} + static int installFile(const QString &source, const QString &target, bool exe = false, bool preservePermissions = false) { @@ -270,18 +303,15 @@ static int installFile(const QString &source, const QString &target, bool exe = targetPermissions |= QFileDevice::ExeOwner | QFileDevice::ExeUser | QFileDevice::ExeGroup | QFileDevice::ExeOther; } - if (!targetFile.setPermissions(targetPermissions)) { - fprintf(stderr, "Error setting permissions on %s: %s\n", - qPrintable(target), qPrintable(targetFile.errorString())); + if (!setFilePermissions(targetFile, targetPermissions)) return 3; - } - // Copy file times QString error; - if (!IoUtils::touchFile(target, sourceFile.fileName(), &error)) { + if (!copyFileTimes(targetFile, sourceFile.fileName(), preservePermissions, &error)) { fprintf(stderr, "%s", qPrintable(error)); return 3; } + return 0; } diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp index 8ca367773d..09e725f98a 100644 --- a/tests/auto/tools/qmake/tst_qmake.cpp +++ b/tests/auto/tools/qmake/tst_qmake.cpp @@ -679,9 +679,6 @@ void tst_qmake::qinstall() QFile srcfile(src.filePath("main.cpp")); QVERIFY(srcfile.setPermissions(srcfile.permissions() & ~writeFlags)); QDir dst("zort"); -#ifdef Q_OS_WIN - QEXPECT_FAIL("", "QTBUG-77299", Abort); -#endif QVERIFY(qinstall(src.absolutePath(), dst.absolutePath())); QCOMPARE(src.entryList(QDir::Files, QDir::Name), dst.entryList(QDir::Files, QDir::Name)); } -- cgit v1.2.3 From a547404c12b50b8c9ab6a078fce5ce9a7300586f Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Mon, 18 Feb 2019 13:09:58 +0100 Subject: QTextureFileReader: backport ASTC support Add support for astc format files as an experimental feature. To enable, configure with "-feature-texture_format_astc_experimental" (Backported from commit 5a4db421bd94acd12a4ac1f77031996b95f85dbf) Change-Id: I9a2f7b1fa20ba344b79637bafb50ff2bd0596747 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/configure.json | 5 + src/gui/util/qastchandler.cpp | 168 +++++++++++++++++++++ src/gui/util/qastchandler_p.h | 73 +++++++++ src/gui/util/qtexturefilereader.cpp | 10 +- src/gui/util/util.pri | 5 + .../util/qtexturefilereader/qtexturefilereader.qrc | 2 + .../qtexturefilereader/texturefiles/newlogo.astc | Bin 0 -> 2512 bytes .../texturefiles/newlogo_srgb.astc | Bin 0 -> 2512 bytes .../qtexturefilereader/tst_qtexturefilereader.cpp | 73 ++++++--- 9 files changed, 311 insertions(+), 25 deletions(-) create mode 100644 src/gui/util/qastchandler.cpp create mode 100644 src/gui/util/qastchandler_p.h create mode 100644 tests/auto/gui/util/qtexturefilereader/texturefiles/newlogo.astc create mode 100644 tests/auto/gui/util/qtexturefilereader/texturefiles/newlogo_srgb.astc diff --git a/src/gui/configure.json b/src/gui/configure.json index c51e3ceee3..6dd6f5b16c 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -1748,6 +1748,11 @@ "section": "Images", "output": [ "publicFeature", "feature" ] }, + "texture_format_astc_experimental" : { + "label": "ASTC Texture format (experimental)", + "autoDetect": "false", + "output": [ "privateFeature" ] + }, "picture": { "label": "QPicture", "purpose": "Supports recording and replaying QPainter commands.", diff --git a/src/gui/util/qastchandler.cpp b/src/gui/util/qastchandler.cpp new file mode 100644 index 0000000000..6d163c6701 --- /dev/null +++ b/src/gui/util/qastchandler.cpp @@ -0,0 +1,168 @@ +/**************************************************************************** +** +** 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 "qastchandler_p.h" +#include "qtexturefiledata_p.h" + +#include + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +struct AstcHeader +{ + quint8 magic[4]; + quint8 blockDimX; + quint8 blockDimY; + quint8 blockDimZ; + quint8 xSize[3]; + quint8 ySize[3]; + quint8 zSize[3]; +}; + +bool QAstcHandler::canRead(const QByteArray &suffix, const QByteArray &block) +{ + Q_UNUSED(suffix) + + return block.startsWith("\x13\xAB\xA1\x5C"); +} + +quint32 QAstcHandler::astcGLFormat(quint8 xBlockDim, quint8 yBlockDim) const +{ + static const quint32 glFormatRGBABase = 0x93B0; // GL_COMPRESSED_RGBA_ASTC_4x4_KHR + static const quint32 glFormatSRGBBase = 0x93D0; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR + + static QSize dims[14] = { + { 4, 4 }, // GL_COMPRESSED_xxx_ASTC_4x4_KHR + { 5, 4 }, // GL_COMPRESSED_xxx_ASTC_5x4_KHR + { 5, 5 }, // GL_COMPRESSED_xxx_ASTC_5x5_KHR + { 6, 5 }, // GL_COMPRESSED_xxx_ASTC_6x5_KHR + { 6, 6 }, // GL_COMPRESSED_xxx_ASTC_6x6_KHR + { 8, 5 }, // GL_COMPRESSED_xxx_ASTC_8x5_KHR + { 8, 6 }, // GL_COMPRESSED_xxx_ASTC_8x6_KHR + { 8, 8 }, // GL_COMPRESSED_xxx_ASTC_8x8_KHR + { 10, 5 }, // GL_COMPRESSED_xxx_ASTC_10x5_KHR + { 10, 6 }, // GL_COMPRESSED_xxx_ASTC_10x6_KHR + { 10, 8 }, // GL_COMPRESSED_xxx_ASTC_10x8_KHR + { 10, 10 }, // GL_COMPRESSED_xxx_ASTC_10x10_KHR + { 12, 10 }, // GL_COMPRESSED_xxx_ASTC_12x10_KHR + { 12, 12 } // GL_COMPRESSED_xxx_ASTC_12x12_KHR + }; + + const QSize dim(xBlockDim, yBlockDim); + int index = -1; + for (int i = 0; i < 14; i++) { + if (dim == dims[i]) { + index = i; + break; + } + } + if (index < 0) + return 0; + + bool useSrgb = qEnvironmentVariableIsSet("QT_ASTCHANDLER_USE_SRGB") + || logName().toLower().contains("srgb"); + + return useSrgb ? (glFormatSRGBBase + index) : (glFormatRGBABase + index); +} + +QTextureFileData QAstcHandler::read() +{ + QTextureFileData nullData; + QTextureFileData res; + + if (!device()) + return nullData; + + QByteArray fileData = device()->readAll(); + if (fileData.size() < int(sizeof(AstcHeader)) || !canRead(QByteArray(), fileData)) { + qCDebug(lcQtGuiTextureIO, "Not an ASTC file: %s", logName().constData()); + return nullData; + } + res.setData(fileData); + + const AstcHeader *header = reinterpret_cast(fileData.constData()); + + int xSz = int(header->xSize[0]) | int(header->xSize[1]) << 8 | int(header->xSize[2]) << 16; + int ySz = int(header->ySize[0]) | int(header->ySize[1]) << 8 | int(header->ySize[2]) << 16; + int zSz = int(header->zSize[0]) | int(header->zSize[1]) << 8 | int(header->zSize[2]) << 16; + + quint32 glFmt = astcGLFormat(header->blockDimX, header->blockDimY); + + if (!xSz || !ySz || !zSz || !glFmt || header->blockDimZ != 1) { + qCDebug(lcQtGuiTextureIO, "Invalid ASTC header data in file %s", logName().constData()); + return nullData; + } + + res.setSize(QSize(xSz, ySz)); + res.setGLFormat(0); // 0 for compressed textures + res.setGLInternalFormat(glFmt); + //? BaseInternalFormat + + int xBlocks = (xSz + header->blockDimX - 1) / header->blockDimX; + int yBlocks = (ySz + header->blockDimY - 1) / header->blockDimY; + int zBlocks = (zSz + header->blockDimZ - 1) / header->blockDimZ; + + int byteCount = 0; + bool oob = mul_overflow(xBlocks, yBlocks, &byteCount) + || mul_overflow(byteCount, zBlocks, &byteCount) + || mul_overflow(byteCount, 16, &byteCount); + + + res.setDataOffset(sizeof(AstcHeader)); + res.setNumLevels(1); + res.setDataLength(byteCount); + + if (oob || !res.isValid()) { + qCDebug(lcQtGuiTextureIO, "Invalid ASTC file %s", logName().constData()); + return nullData; + } + + res.setLogName(logName()); + +#if 0 + qDebug() << "ASTC file handler read" << res << res.dataOffset() << res.dataLength(); +#endif + return res; +} + +QT_END_NAMESPACE diff --git a/src/gui/util/qastchandler_p.h b/src/gui/util/qastchandler_p.h new file mode 100644 index 0000000000..398f1833b6 --- /dev/null +++ b/src/gui/util/qastchandler_p.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** 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 QASTCHANDLER_H +#define QASTCHANDLER_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 "qtexturefilehandler_p.h" + +QT_BEGIN_NAMESPACE + +class QAstcHandler : public QTextureFileHandler +{ +public: + using QTextureFileHandler::QTextureFileHandler; + + static bool canRead(const QByteArray &suffix, const QByteArray &block); + + QTextureFileData read() override; + +private: + quint32 astcGLFormat(quint8 xBlockDim, quint8 yBlockDim) const; +}; + +QT_END_NAMESPACE + +#endif // QASTCHANDLER_H diff --git a/src/gui/util/qtexturefilereader.cpp b/src/gui/util/qtexturefilereader.cpp index 5d4bd600e0..73d6b6811a 100644 --- a/src/gui/util/qtexturefilereader.cpp +++ b/src/gui/util/qtexturefilereader.cpp @@ -37,10 +37,14 @@ ** ****************************************************************************/ +#include #include "qtexturefilereader_p.h" #include "qpkmhandler_p.h" #include "qktxhandler_p.h" +#if QT_CONFIG(texture_format_astc_experimental) +#include "qastchandler_p.h" +#endif #include @@ -80,6 +84,10 @@ bool QTextureFileReader::canRead() m_handler = new QPkmHandler(m_device, logName); } else if (QKtxHandler::canRead(suffix, headerBlock)) { m_handler = new QKtxHandler(m_device, logName); +#if QT_CONFIG(texture_format_astc_experimental) + } else if (QAstcHandler::canRead(suffix, headerBlock)) { + m_handler = new QAstcHandler(m_device, logName); +#endif } // else if OtherHandler::canRead() ...etc. } @@ -89,7 +97,7 @@ bool QTextureFileReader::canRead() QList QTextureFileReader::supportedFileFormats() { // Hardcoded for now - return {QByteArrayLiteral("pkm"), QByteArrayLiteral("ktx")}; + return {QByteArrayLiteral("pkm"), QByteArrayLiteral("ktx"), QByteArrayLiteral("astc")}; } bool QTextureFileReader::init() diff --git a/src/gui/util/util.pri b/src/gui/util/util.pri index 6324642505..b36ee60a97 100644 --- a/src/gui/util/util.pri +++ b/src/gui/util/util.pri @@ -39,3 +39,8 @@ SOURCES += \ util/qtexturefilereader.cpp \ util/qpkmhandler.cpp \ util/qktxhandler.cpp + +qtConfig(texture_format_astc_experimental) { + HEADERS += util/qastchandler_p.h + SOURCES += util/qastchandler.cpp +} diff --git a/tests/auto/gui/util/qtexturefilereader/qtexturefilereader.qrc b/tests/auto/gui/util/qtexturefilereader/qtexturefilereader.qrc index ab882b5db2..8aab86e1ff 100644 --- a/tests/auto/gui/util/qtexturefilereader/qtexturefilereader.qrc +++ b/tests/auto/gui/util/qtexturefilereader/qtexturefilereader.qrc @@ -3,5 +3,7 @@ texturefiles/car.ktx texturefiles/pattern.pkm texturefiles/car_mips.ktx + texturefiles/newlogo_srgb.astc + texturefiles/newlogo.astc diff --git a/tests/auto/gui/util/qtexturefilereader/texturefiles/newlogo.astc b/tests/auto/gui/util/qtexturefilereader/texturefiles/newlogo.astc new file mode 100644 index 0000000000..39bf3f1734 Binary files /dev/null and b/tests/auto/gui/util/qtexturefilereader/texturefiles/newlogo.astc differ diff --git a/tests/auto/gui/util/qtexturefilereader/texturefiles/newlogo_srgb.astc b/tests/auto/gui/util/qtexturefilereader/texturefiles/newlogo_srgb.astc new file mode 100644 index 0000000000..38e876829b Binary files /dev/null and b/tests/auto/gui/util/qtexturefilereader/texturefiles/newlogo_srgb.astc differ diff --git a/tests/auto/gui/util/qtexturefilereader/tst_qtexturefilereader.cpp b/tests/auto/gui/util/qtexturefilereader/tst_qtexturefilereader.cpp index 9ff4f0ccf2..7939b688af 100644 --- a/tests/auto/gui/util/qtexturefilereader/tst_qtexturefilereader.cpp +++ b/tests/auto/gui/util/qtexturefilereader/tst_qtexturefilereader.cpp @@ -27,6 +27,7 @@ ****************************************************************************/ #include +#include #include class tst_qtexturefilereader : public QObject @@ -49,33 +50,57 @@ void tst_qtexturefilereader::checkHandlers_data() QTest::addColumn>("dataOffsets"); QTest::addColumn>("dataLengths"); - QTest::addRow("pattern.pkm") << QStringLiteral(":/texturefiles/pattern.pkm") - << QSize(64, 64) - << quint32(0x0) - << quint32(0x8d64) - << quint32(0x0) - << 1 - << (QList() << 16) - << (QList() << 2048); + QTest::addRow("pattern.pkm") + << QStringLiteral(":/texturefiles/pattern.pkm") + << QSize(64, 64) + << quint32(0x0) + << quint32(0x8d64) + << quint32(0x0) + << 1 + << (QList() << 16) + << (QList() << 2048); - QTest::addRow("car.ktx") << QStringLiteral(":/texturefiles/car.ktx") - << QSize(146, 80) - << quint32(0x0) - << quint32(0x9278) - << quint32(0x1908) - << 1 - << (QList() << 68) - << (QList() << 11840); + QTest::addRow("car.ktx") + << QStringLiteral(":/texturefiles/car.ktx") + << QSize(146, 80) + << quint32(0x0) + << quint32(0x9278) + << quint32(0x1908) + << 1 + << (QList() << 68) + << (QList() << 11840); - QTest::addRow("car_mips.ktx") << QStringLiteral(":/texturefiles/car_mips.ktx") - << QSize(146, 80) - << quint32(0x0) - << quint32(0x9274) - << quint32(0x1907) - << 8 - << (QList() << 68 << 5992 << 7516 << 7880 << 8004 << 8056 << 8068 << 8080) - << (QList() << 5920 << 1520 << 360 << 120 << 48 << 8 << 8 << 8); + QTest::addRow("car_mips.ktx") + << QStringLiteral(":/texturefiles/car_mips.ktx") + << QSize(146, 80) + << quint32(0x0) + << quint32(0x9274) + << quint32(0x1907) + << 8 + << (QList() << 68 << 5992 << 7516 << 7880 << 8004 << 8056 << 8068 << 8080) + << (QList() << 5920 << 1520 << 360 << 120 << 48 << 8 << 8 << 8); +#if QT_CONFIG(texture_format_astc_experimental) + QTest::addRow("newlogo.astc") + << QStringLiteral(":/texturefiles/newlogo.astc") + << QSize(111, 78) + << quint32(0x0) + << quint32(0x93b9) + << quint32(0x0) + << 1 + << (QList() << 16) + << (QList() << 2496); + + QTest::addRow("newlogo_srgb.astc") + << QStringLiteral(":/texturefiles/newlogo_srgb.astc") + << QSize(111, 78) + << quint32(0x0) + << quint32(0x93d9) + << quint32(0x0) + << 1 + << (QList() << 16) + << (QList() << 2496); +#endif // QT_CONFIG(texture_format_astc_experimental) } void tst_qtexturefilereader::checkHandlers() -- cgit v1.2.3 From 80e7120feb5ddf9d5f0c9ed12bb8580898b18db8 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 1 Aug 2019 15:29:01 +0200 Subject: eglfs/kms: Re-enable drm/gbm format overrides in the config file Follow up to 091a386eaf91ad8932332a8aefc2df793de59f6c Defaulting to querying from the egl config is fine, but dropping support for the "format" key in the output list in the json config file is not ideal. Task-number: QTBUG-76748 Change-Id: I25dc99369d118c300cdef25b464426f6be85453b Reviewed-by: Johan Helsing --- src/platformsupport/kmsconvenience/qkmsdevice.cpp | 12 +++++-- src/platformsupport/kmsconvenience/qkmsdevice_p.h | 1 + .../eglfs_kms/qeglfskmsgbmscreen.cpp | 37 +++++++++++++++------- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/src/platformsupport/kmsconvenience/qkmsdevice.cpp index 7e3a870421..fec59cfc7b 100644 --- a/src/platformsupport/kmsconvenience/qkmsdevice.cpp +++ b/src/platformsupport/kmsconvenience/qkmsdevice.cpp @@ -342,10 +342,14 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, } qCDebug(qLcKmsDebug) << "Physical size is" << physSize << "mm" << "for output" << connectorName; - const QByteArray formatStr = userConnectorConfig.value(QStringLiteral("format"), QStringLiteral("xrgb8888")) + const QByteArray formatStr = userConnectorConfig.value(QStringLiteral("format"), QString()) .toByteArray().toLower(); uint32_t drmFormat; - if (formatStr == "xrgb8888") { + bool drmFormatExplicit = true; + if (formatStr.isEmpty()) { + drmFormat = DRM_FORMAT_XRGB8888; + drmFormatExplicit = false; + } else if (formatStr == "xrgb8888") { drmFormat = DRM_FORMAT_XRGB8888; } else if (formatStr == "xbgr8888") { drmFormat = DRM_FORMAT_XBGR8888; @@ -368,7 +372,10 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, } else { qWarning("Invalid pixel format \"%s\" for output %s", formatStr.constData(), connectorName.constData()); drmFormat = DRM_FORMAT_XRGB8888; + drmFormatExplicit = false; } + qCDebug(qLcKmsDebug) << "Format is" << hex << drmFormat << dec << "requested_by_user =" << drmFormatExplicit + << "for output" << connectorName; const QString cloneSource = userConnectorConfig.value(QStringLiteral("clones")).toString(); if (!cloneSource.isEmpty()) @@ -411,6 +418,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, output.forced_plane_id = 0; output.forced_plane_set = false; output.drm_format = drmFormat; + output.drm_format_requested_by_user = drmFormatExplicit; output.clone_source = cloneSource; output.size = framebufferSize; diff --git a/src/platformsupport/kmsconvenience/qkmsdevice_p.h b/src/platformsupport/kmsconvenience/qkmsdevice_p.h index 403972fbb8..14da6bb947 100644 --- a/src/platformsupport/kmsconvenience/qkmsdevice_p.h +++ b/src/platformsupport/kmsconvenience/qkmsdevice_p.h @@ -201,6 +201,7 @@ struct QKmsOutput uint32_t forced_plane_id = 0; bool forced_plane_set = false; uint32_t drm_format = DRM_FORMAT_XRGB8888; + bool drm_format_requested_by_user = false; QString clone_source; QVector available_planes; struct QKmsPlane *eglfs_plane = nullptr; diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp index 24f82e7843..3a2951efbd 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp @@ -155,20 +155,33 @@ gbm_surface *QEglFSKmsGbmScreen::createSurface(EGLConfig eglConfig) qCDebug(qLcEglfsKmsDebug, "Creating gbm_surface for screen %s", qPrintable(name())); 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); - - if (success) - m_gbm_surface = gbm_surface_create(gbmDevice, - rawGeometry().width(), - rawGeometry().height(), - native_format, - GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); + // If there was no format override given in the config file, + // query the native (here, gbm) format from the EGL config. + const bool queryFromEgl = !m_output.drm_format_requested_by_user; + if (queryFromEgl) { + 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); + + if (success) { + m_gbm_surface = gbm_surface_create(gbmDevice, + rawGeometry().width(), + rawGeometry().height(), + native_format, + GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); + if (m_gbm_surface) + m_output.drm_format = gbmFormatToDrmFormat(native_format); + } + } - if (!m_gbm_surface) { // fallback for older drivers + // Fallback for older drivers, and when "format" is explicitly specified + // in the output config. (not guaranteed that the requested format works + // of course, but do what we are told to) + if (!m_gbm_surface) { uint32_t gbmFormat = drmFormatToGbmFormat(m_output.drm_format); - qCDebug(qLcEglfsKmsDebug, "Could not create surface with EGL_NATIVE_VISUAL_ID, falling back to format %x", gbmFormat); + if (queryFromEgl) + qCDebug(qLcEglfsKmsDebug, "Could not create surface with EGL_NATIVE_VISUAL_ID, falling back to format %x", gbmFormat); m_gbm_surface = gbm_surface_create(gbmDevice, rawGeometry().width(), rawGeometry().height(), -- cgit v1.2.3 From 5dc318d5e80b5ec415e981f3e655cc6cdfdab3ba Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 15 Jul 2019 14:50:33 +0200 Subject: Fix typo in description of feature datestring Change-Id: I858512af94b5160a0008789ca972cd57307cc9e2 Reviewed-by: Tasuku Suzuki Reviewed-by: Paul Wicking --- src/corelib/configure.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/configure.json b/src/corelib/configure.json index 5f5a00a64f..de8d26a12b 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -814,7 +814,7 @@ }, "datestring": { "label": "QDate/QTime/QDateTime", - "purpose": "Provides convertion between dates and strings.", + "purpose": "Provides conversion between dates and strings.", "section": "Data structures", "condition": "features.textdate", "output": [ "publicFeature", "feature" ] -- cgit v1.2.3 From 12d37e70a71cf4c6b802cb95f2e85351b2648692 Mon Sep 17 00:00:00 2001 From: James McDonnell Date: Mon, 24 Jun 2019 14:59:20 -0400 Subject: Make the inputRejected test compatible with -no-feature-clipboard Qt for QNX is, by default, built without the clipboard feature. Change-Id: Ie8a36ceb0c0f0a695ae7d0fcf6f0bd70d2a43e0c Reviewed-by: Richard Moe Gustavsen Reviewed-by: Dan Cape Reviewed-by: Rafael Roquetto --- tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 95799905de..27cc385df4 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -4842,6 +4842,7 @@ void tst_QLineEdit::inputRejected() QCOMPARE(spyInputRejected.count(), 0); QTest::keyClicks(testWidget, "fgh"); QCOMPARE(spyInputRejected.count(), 3); +#if QT_CONFIG(clipboard) testWidget->clear(); spyInputRejected.clear(); QApplication::clipboard()->setText("ijklmno"); @@ -4849,6 +4850,7 @@ void tst_QLineEdit::inputRejected() // The first 5 characters are accepted, but // the last 2 are not. QCOMPARE(spyInputRejected.count(), 1); +#endif testWidget->setMaxLength(INT_MAX); testWidget->clear(); @@ -4859,11 +4861,13 @@ void tst_QLineEdit::inputRejected() QCOMPARE(spyInputRejected.count(), 0); QTest::keyClicks(testWidget, "a#"); QCOMPARE(spyInputRejected.count(), 2); +#if QT_CONFIG(clipboard) testWidget->clear(); spyInputRejected.clear(); QApplication::clipboard()->setText("a#"); testWidget->paste(); QCOMPARE(spyInputRejected.count(), 1); +#endif testWidget->clear(); testWidget->setValidator(0); -- cgit v1.2.3 From ec940f898b42f16bb0727f807b72488fad6d6d12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Wed, 14 Aug 2019 14:20:03 +0200 Subject: SSL: ALPN: Don't include empty, too long or truncated names As is said in RFC7301 in section 3.1 [1]: Protocols are named by IANA-registered, opaque, non-empty byte strings [...]. Empty strings MUST NOT be included and byte strings MUST NOT be truncated. [1]: https://tools.ietf.org/html/rfc7301#section-3.1 Change-Id: I2c41fa99984a53cc58803e5a264d06edac964cc6 Reviewed-by: Timur Pocheptsov --- src/network/ssl/qsslcontext_openssl.cpp | 44 ++++++++++++++++++--------------- src/network/ssl/qsslsocket_mac.cpp | 7 ++++++ 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/src/network/ssl/qsslcontext_openssl.cpp b/src/network/ssl/qsslcontext_openssl.cpp index 35cca9f01a..675d5f8e62 100644 --- a/src/network/ssl/qsslcontext_openssl.cpp +++ b/src/network/ssl/qsslcontext_openssl.cpp @@ -157,32 +157,36 @@ SSL* QSslContext::createSsl() for (int a = 0; a < protocols.count(); ++a) { if (protocols.at(a).size() > 255) { qCWarning(lcSsl) << "TLS NPN extension" << protocols.at(a) - << "is too long and will be truncated to 255 characters."; - protocols[a] = protocols.at(a).left(255); + << "is too long and will be ignored."; + continue; + } else if (protocols.at(a).isEmpty()) { + continue; } m_supportedNPNVersions.append(protocols.at(a).size()).append(protocols.at(a)); } - m_npnContext.data = reinterpret_cast(m_supportedNPNVersions.data()); - m_npnContext.len = m_supportedNPNVersions.count(); - m_npnContext.status = QSslConfiguration::NextProtocolNegotiationNone; + if (m_supportedNPNVersions.size()) { + m_npnContext.data = reinterpret_cast(m_supportedNPNVersions.data()); + m_npnContext.len = m_supportedNPNVersions.count(); + m_npnContext.status = QSslConfiguration::NextProtocolNegotiationNone; #if OPENSSL_VERSION_NUMBER >= 0x10002000L - if (QSslSocket::sslLibraryVersionNumber() >= 0x10002000L) { - // Callback's type has a parameter 'const unsigned char ** out' - // since it was introduced in 1.0.2. Internally, OpenSSL's own code - // (tests/examples) cast it to unsigned char * (since it's 'out'). - // We just re-use our NPN callback and cast here: - typedef int (*alpn_callback_t) (SSL *, const unsigned char **, unsigned char *, - const unsigned char *, unsigned int, void *); - // With ALPN callback is for a server side only, for a client m_npnContext.status - // will stay in NextProtocolNegotiationNone. - q_SSL_CTX_set_alpn_select_cb(ctx, alpn_callback_t(next_proto_cb), &m_npnContext); - // Client: - q_SSL_set_alpn_protos(ssl, m_npnContext.data, m_npnContext.len); - } + if (QSslSocket::sslLibraryVersionNumber() >= 0x10002000L) { + // Callback's type has a parameter 'const unsigned char ** out' + // since it was introduced in 1.0.2. Internally, OpenSSL's own code + // (tests/examples) cast it to unsigned char * (since it's 'out'). + // We just re-use our NPN callback and cast here: + typedef int (*alpn_callback_t) (SSL *, const unsigned char **, unsigned char *, + const unsigned char *, unsigned int, void *); + // With ALPN callback is for a server side only, for a client m_npnContext.status + // will stay in NextProtocolNegotiationNone. + q_SSL_CTX_set_alpn_select_cb(ctx, alpn_callback_t(next_proto_cb), &m_npnContext); + // Client: + q_SSL_set_alpn_protos(ssl, m_npnContext.data, m_npnContext.len); + } #endif // OPENSSL_VERSION_NUMBER >= 0x10002000L ... - // And in case our peer does not support ALPN, but supports NPN: - q_SSL_CTX_set_next_proto_select_cb(ctx, next_proto_cb, &m_npnContext); + // And in case our peer does not support ALPN, but supports NPN: + q_SSL_CTX_set_next_proto_select_cb(ctx, next_proto_cb, &m_npnContext); + } } #endif // OPENSSL_VERSION_NUMBER >= 0x1000100fL ... diff --git a/src/network/ssl/qsslsocket_mac.cpp b/src/network/ssl/qsslsocket_mac.cpp index 7c5f4310f8..e6b71b293e 100644 --- a/src/network/ssl/qsslsocket_mac.cpp +++ b/src/network/ssl/qsslsocket_mac.cpp @@ -928,6 +928,13 @@ bool QSslSocketBackendPrivate::initSslContext() QCFType cfNames(CFArrayCreateMutable(nullptr, 0, &kCFTypeArrayCallBacks)); if (cfNames) { for (const QByteArray &name : protocolNames) { + if (name.size() > 255) { + qCWarning(lcSsl) << "TLS ALPN extension" << name + << "is too long and will be ignored."; + continue; + } else if (name.isEmpty()) { + continue; + } QCFString cfName(QString::fromLatin1(name).toCFString()); CFArrayAppendValue(cfNames, cfName); } -- cgit v1.2.3 From 88d1909871ce1a3016ff61edd8bc2062a79f35fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Klitzing?= Date: Wed, 14 Aug 2019 15:40:26 +0200 Subject: Fix macOS build with -no-feature-accessibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Id16b102feb7b57efcf1a36385a009774cb023f41 Reviewed-by: Jörg Bornemann --- src/plugins/platforms/cocoa/cocoa.pro | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index 02e00039ae..f0dd013922 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -21,8 +21,6 @@ SOURCES += main.mm \ qcocoamenuloader.mm \ qcocoahelpers.mm \ qmultitouch_mac.mm \ - qcocoaaccessibilityelement.mm \ - qcocoaaccessibility.mm \ qcocoacursor.mm \ qcocoaclipboard.mm \ qcocoadrag.mm \ @@ -57,8 +55,6 @@ HEADERS += qcocoaintegration.h \ qcocoamenuloader.h \ qcocoahelpers.h \ qmultitouch_mac_p.h \ - qcocoaaccessibilityelement.h \ - qcocoaaccessibility.h \ qcocoacursor.h \ qcocoaclipboard.h \ qcocoadrag.h \ @@ -83,13 +79,21 @@ qtConfig(vulkan) { HEADERS += qcocoavulkaninstance.h } +qtConfig(accessibility) { + QT += accessibility_support-private + SOURCES += qcocoaaccessibilityelement.mm \ + qcocoaaccessibility.mm + HEADERS += qcocoaaccessibilityelement.h \ + qcocoaaccessibility.h +} + RESOURCES += qcocoaresources.qrc LIBS += -framework AppKit -framework CoreServices -framework Carbon -framework IOKit -framework QuartzCore -framework CoreVideo -framework Metal -framework IOSurface -lcups QT += \ core-private gui-private \ - accessibility_support-private clipboard_support-private theme_support-private \ + clipboard_support-private theme_support-private \ fontdatabase_support-private graphics_support-private qtConfig(vulkan): QT += vulkan_support-private -- cgit v1.2.3 From 0d81667f87e80f7d0a866df3b0ee4a164f47e26d Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 16 Aug 2019 14:26:32 +0200 Subject: Describe the -egl option in configure's help output Change-Id: Ibb47cfc2dd0b85c33a062d03aa4d43374f71ebb1 Fixes: QTBUG-54811 Reviewed-by: Laszlo Agocs --- config_help.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/config_help.txt b/config_help.txt index fb37cbaed9..63ba289941 100644 --- a/config_help.txt +++ b/config_help.txt @@ -277,6 +277,7 @@ Gui, printing, widget options: es2 (default on Windows), desktop (default on Unix), dynamic (Windows only) -opengles3 ........... Enable OpenGL ES 3.x support instead of ES 2.x [auto] + -egl ................. Enable EGL support [auto] -angle ............... Use bundled ANGLE to support OpenGL ES 2.0 [auto] (Windows only) -combined-angle-lib .. Merge LibEGL and LibGLESv2 into LibANGLE (Windows only) -- cgit v1.2.3 From 6d3a4546934827955f0eb2b07a9928f82790ba37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 13 Aug 2019 15:17:40 +0200 Subject: DBus: fix deadlock when destroying QDBusServer Observed infrequently in the QDBus tests, it would deadlock when destroying QDBusServer at the same time as qDBusNewConnection was being executed as they were locking the same locks, but in opposite order. QDBusServer locks d->lock, then QDBusConnectionManager::instance()->mutex. While qDBusNewConnection locks QDBusConnectionManager::instance()->mutex, then serverConnection->lock (and serverConnection here is QDBusServer's d-pointer). QOrderedMutexLocker cannot be used in this situation because it operates on QMutex*, which d->lock (QReadWriteLock) is not. Change the code to lock QDBusConnectionManager's mutex before d->lock and then unlock the QMutexLocker where it would previously destruct. If QDBusConnectionManager has already been destroyed then we pass a nullptr to the QMutexLocker which is fine and will not do anything. Fixes: QTBUG-74635 Change-Id: I7f02d7759da67377996ef042c81b0969ccb8aadb Reviewed-by: Marc Mutz Reviewed-by: Edward Welbourne --- src/dbus/qdbusserver.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/dbus/qdbusserver.cpp b/src/dbus/qdbusserver.cpp index a2dfb86164..3ac5c794e1 100644 --- a/src/dbus/qdbusserver.cpp +++ b/src/dbus/qdbusserver.cpp @@ -109,12 +109,16 @@ QDBusServer::QDBusServer(QObject *parent) */ QDBusServer::~QDBusServer() { - QWriteLocker locker(&d->lock); + QMutex *managerMutex = nullptr; + if (QDBusConnectionManager::instance()) + managerMutex = &QDBusConnectionManager::instance()->mutex; + QMutexLocker locker(managerMutex); + QWriteLocker writeLocker(&d->lock); if (QDBusConnectionManager::instance()) { - QMutexLocker locker(&QDBusConnectionManager::instance()->mutex); for (const QString &name : qAsConst(d->serverConnectionNames)) QDBusConnectionManager::instance()->removeConnection(name); d->serverConnectionNames.clear(); + locker.unlock(); } d->serverObject = nullptr; d->ref.store(0); -- cgit v1.2.3 From 257bd49c1f47ba5fca6930082fdcf108f9d24e3f Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 14 Aug 2019 19:45:17 +0200 Subject: Guard with a mutex in QOpenGLProgramBinaryCache where needed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While there is likely no example of it in Qt itself, applications can use QOpenGLShaderProgram instances on different threads. These instances have nothing to do with each other but they do share a global cache object. This becomes problematic without proper synchronization. Change-Id: I80faf73f34af7e67349eee916bb3f216e22c07fd Fixes: QTBUG-77469 Reviewed-by: Christian Strømme --- src/gui/opengl/qopenglprogrambinarycache.cpp | 2 ++ src/gui/opengl/qopenglprogrambinarycache_p.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/gui/opengl/qopenglprogrambinarycache.cpp b/src/gui/opengl/qopenglprogrambinarycache.cpp index af48cdacc7..40237b9935 100644 --- a/src/gui/opengl/qopenglprogrambinarycache.cpp +++ b/src/gui/opengl/qopenglprogrambinarycache.cpp @@ -263,6 +263,7 @@ public: bool QOpenGLProgramBinaryCache::load(const QByteArray &cacheKey, uint programId) { + QMutexLocker lock(&m_mutex); if (m_memCache.contains(cacheKey)) { const MemCacheEntry *e = m_memCache[cacheKey]; return setProgramBinary(programId, e->format, e->blob.constData(), e->blob.size()); @@ -401,6 +402,7 @@ void QOpenGLProgramBinaryCache::save(const QByteArray &cacheKey, uint programId) GLint outSize = 0; #if defined(QT_OPENGL_ES_2) if (context->isOpenGLES() && context->format().majorVersion() < 3) { + QMutexLocker lock(&m_mutex); initializeProgramBinaryOES(context); getProgramBinaryOES(programId, blobSize, &outSize, &blobFormat, p); } else diff --git a/src/gui/opengl/qopenglprogrambinarycache_p.h b/src/gui/opengl/qopenglprogrambinarycache_p.h index 9fade08e66..e181a6ab81 100644 --- a/src/gui/opengl/qopenglprogrambinarycache_p.h +++ b/src/gui/opengl/qopenglprogrambinarycache_p.h @@ -54,6 +54,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -99,6 +100,7 @@ private: void initializeProgramBinaryOES(QOpenGLContext *context); bool m_programBinaryOESInitialized = false; #endif + QMutex m_mutex; }; QT_END_NAMESPACE -- cgit v1.2.3 From 5d7e9c9667d60490ffbbf33ddb38736960eae1d9 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 19 Jun 2019 17:43:19 +0200 Subject: CMake: Fix prl and library names on macOS for debug configurations The paths to the libraries and prl files should have the "_debug" suffix for the debug configuration. This prefix is added to the TARGET when by qt_module.prf when doing a debug build, but not during a debug_and_release build. Make sure to strip the _debug suffix if it's there, and re-add it later always, to be consistent in both debug_and_release builds and in debug builds. Amends a12b6e7bf6688021c6af809d024958b59dfa3555. Task-number: QTBUG-38913 Task-number: QTBUG-75520 Task-number: QTBUG-77092 Change-Id: I29e88f2b991e2be06b23652d64edc768fa35a5ae (cherry picked from qt/78d67d17a6c108a419816b8bd47f78864ddbb07f) Reviewed-by: Alexandru Croitor --- mkspecs/features/create_cmake.prf | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf index c9910dda53..00da9bd33f 100644 --- a/mkspecs/features/create_cmake.prf +++ b/mkspecs/features/create_cmake.prf @@ -34,10 +34,20 @@ CMAKE_INCLUDE_NAME = $$eval(QT.$${MODULE}.name) # TARGET here is the one changed at the end of qt_module.prf, # which already contains the Qt5 prefix and QT_LIBINFIX suffix : -# Qt5Core_suffix, Qt5Network_suffix, Foo_suffix -# (or QtCore_suffix, Foo_suffix on macos with -framework) +# Qt5Core_{libinfix_suffix}, Qt5Network_{libinfix_suffix}, Foo_{libinfix_suffix} +# (or QtCore_{libinfix_suffix}, Foo_{libinfix_suffix} on macos with -framework). CMAKE_QT_STEM = $${TARGET} +# On macOS when building just a debug configuration which is not part of debug_and_release, +# $${TARGET} already contains a _debug suffix, as per the following call chain: +# qt_module.prf -> qt5LibraryTarget -> qtLibraryTarget -> qtPlatformTargetSuffix. +# Remove the _debug suffix in the stem, to keep all further uses of CMAKE_QT_STEM consistent. +# The _debug suffix is then re-added where needed regardless if it's a debug_and_release build +# or just debug. +darwin:!qt_framework:!debug_and_release:CONFIG(debug, debug|release) { + CMAKE_QT_STEM = $$replace(CMAKE_QT_STEM, _debug$, ) +} + !generated_privates { isEmpty(SYNCQT.INJECTED_PRIVATE_HEADER_FILES):isEmpty(SYNCQT.PRIVATE_HEADER_FILES): \ CMAKE_NO_PRIVATE_INCLUDES = true @@ -211,18 +221,18 @@ CMAKE_INTERFACE_QT5_MODULE_DEPS = $$join(aux_lib_deps, ";") mac { !isEmpty(CMAKE_STATIC_TYPE) { - CMAKE_LIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}.a + CMAKE_LIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}_debug.a CMAKE_LIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.a - CMAKE_PRL_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}.prl + CMAKE_PRL_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}_debug.prl CMAKE_PRL_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.prl } else { qt_framework { - CMAKE_LIB_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}.framework/$${CMAKE_QT_STEM} + CMAKE_LIB_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}.framework/$${CMAKE_QT_STEM}_debug CMAKE_LIB_FILE_LOCATION_RELEASE = $${CMAKE_QT_STEM}.framework/$${CMAKE_QT_STEM} CMAKE_BUILD_IS_FRAMEWORK = "true" } else { - CMAKE_LIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}.$$eval(QT.$${MODULE}.VERSION).dylib + CMAKE_LIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}_debug.$$eval(QT.$${MODULE}.VERSION).dylib CMAKE_LIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.$$eval(QT.$${MODULE}.VERSION).dylib } } -- cgit v1.2.3 From 70e7445dbeba9bd24de963e7e431c4698b6b4569 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Tue, 30 Jul 2019 10:27:41 +0200 Subject: Simplify QBezier::addPolygon() implementation Makes the code a little cleaner, avoiding an issue caused by UB and/or optimization bug in msvc2019. Fixes: QTBUG-77119 Fixes: QTBUG-77230 Change-Id: I9bc8f427a90e6fe32b3c26301bbb703a3c4ad846 Reviewed-by: Friedemann Kleint Reviewed-by: Ville Voutilainen --- src/gui/painting/qbezier.cpp | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/gui/painting/qbezier.cpp b/src/gui/painting/qbezier.cpp index 8cda4b4072..65e6063fe4 100644 --- a/src/gui/painting/qbezier.cpp +++ b/src/gui/painting/qbezier.cpp @@ -122,10 +122,10 @@ void QBezier::addToPolygon(QPolygonF *polygon, qreal bezier_flattening_threshold int levels[10]; beziers[0] = *this; levels[0] = 9; - QBezier *b = beziers; - int *lvl = levels; + int top = 0; - while (b >= beziers) { + while (top >= 0) { + QBezier *b = &beziers[top]; // check if we can pop the top bezier curve from the stack qreal y4y1 = b->y4 - b->y1; qreal x4x1 = b->x4 - b->x1; @@ -139,17 +139,15 @@ void QBezier::addToPolygon(QPolygonF *polygon, qreal bezier_flattening_threshold qAbs(b->x1 - b->x3) + qAbs(b->y1 - b->y3); l = 1.; } - if (d < bezier_flattening_threshold*l || *lvl == 0) { + if (d < bezier_flattening_threshold * l || levels[top] == 0) { // good enough, we pop it off and add the endpoint polygon->append(QPointF(b->x4, b->y4)); - --b; - --lvl; + --top; } else { // split, second half of the polygon goes lower into the stack b->split(b+1, b); - lvl[1] = --lvl[0]; - ++b; - ++lvl; + levels[top + 1] = --levels[top]; + ++top; } } } @@ -160,10 +158,10 @@ void QBezier::addToPolygon(QDataBuffer &polygon, qreal bezier_flattenin int levels[10]; beziers[0] = *this; levels[0] = 9; - QBezier *b = beziers; - int *lvl = levels; + int top = 0; - while (b >= beziers) { + while (top >= 0) { + QBezier *b = &beziers[top]; // check if we can pop the top bezier curve from the stack qreal y4y1 = b->y4 - b->y1; qreal x4x1 = b->x4 - b->x1; @@ -177,17 +175,15 @@ void QBezier::addToPolygon(QDataBuffer &polygon, qreal bezier_flattenin qAbs(b->x1 - b->x3) + qAbs(b->y1 - b->y3); l = 1.; } - if (d < bezier_flattening_threshold*l || *lvl == 0) { + if (d < bezier_flattening_threshold * l || levels[top] == 0) { // good enough, we pop it off and add the endpoint polygon.add(QPointF(b->x4, b->y4)); - --b; - --lvl; + --top; } else { // split, second half of the polygon goes lower into the stack b->split(b+1, b); - lvl[1] = --lvl[0]; - ++b; - ++lvl; + levels[top + 1] = --levels[top]; + ++top; } } } -- cgit v1.2.3