From 0f3f143f6deee3b31a7dfaba07dfd517f0aee442 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Sun, 23 Jun 2019 23:26:28 +0200 Subject: Fix window shortcuts when a completer popup has focus The completer popup has focus, making QShortcut direct to it's window rather than to the window the completer belongs to. As QShortcut handles the case for Tool windows that have a parent, but doens't do the same for popups. And they shouldn't be treated the same way, as a context menu popup for a e.g. text edit should in fact block the text edit's shortcuts while open. However, the completer popup is special, in that it explicitly makes the widget completes for its focusProxy, which is what we can use to fix this issue. Change-Id: Ie7177d39668b3af14a1d9e0ee5d93eca9c67c8af Fixes: QTBUG-4485 Reviewed-by: Richard Moe Gustavsen --- src/widgets/kernel/qshortcut.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp index a680ff7913..b7857e2b74 100644 --- a/src/widgets/kernel/qshortcut.cpp +++ b/src/widgets/kernel/qshortcut.cpp @@ -189,10 +189,15 @@ static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidge } #endif - /* if a floating tool window is active, keep shortcuts on the - * parent working */ - if (active_window != tlw && active_window && active_window->windowType() == Qt::Tool && active_window->parentWidget()) { - active_window = active_window->parentWidget()->window(); + if (active_window && active_window != tlw) { + /* if a floating tool window is active, keep shortcuts on the parent working. + * and if a popup window is active (f.ex a completer), keep shortcuts on the + * focus proxy working */ + if (active_window->windowType() == Qt::Tool && active_window->parentWidget()) { + active_window = active_window->parentWidget()->window(); + } else if (active_window->windowType() == Qt::Popup && active_window->focusProxy()) { + active_window = active_window->focusProxy()->window(); + } } if (active_window != tlw) { -- cgit v1.2.3 From 9be66cb282dee1ce4380602a2f3caf5abfd144cf Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 24 Apr 2019 15:40:29 +0200 Subject: Android: Use Android button layout for the DialogButtonBoxLayout hint Fixes: QTBUG-70045 Change-Id: I9c51e9a769f510a6f14f6e9d78583caf3df15031 Reviewed-by: BogDan Vatra --- src/plugins/platforms/android/qandroidplatformtheme.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/android/qandroidplatformtheme.cpp b/src/plugins/platforms/android/qandroidplatformtheme.cpp index b891407c44..94405738f3 100644 --- a/src/plugins/platforms/android/qandroidplatformtheme.cpp +++ b/src/plugins/platforms/android/qandroidplatformtheme.cpp @@ -488,6 +488,8 @@ QVariant QAndroidPlatformTheme::themeHint(ThemeHint hint) const Q_FALLTHROUGH(); } + case DialogButtonBoxLayout: + return QVariant(QPlatformDialogHelper::AndroidLayout); default: return QPlatformTheme::themeHint(hint); } -- cgit v1.2.3 From b6ded193ee64ffe67df6d22e7a23aa1ea9e02ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 5 Mar 2019 11:14:21 +0100 Subject: QHighDpi::fromNativePixels: use correct screen Calls like QHighDpi::fromNativePixels(point, window) would return device independent coordinates outside any screen in cases where the window is spanning multiple screens and the native point was not on the main screen. Correct this by looking up the correct screen and use its scale factor and origin when scaling coordinates. Task-number: QTBUG-73231 Change-Id: I01a3a42f42121b8d9f4ced2bb0fb023d6ae6bfe7 Reviewed-by: Friedemann Kleint --- src/gui/kernel/qhighdpiscaling.cpp | 50 +++++++++++--------------------------- src/gui/kernel/qhighdpiscaling_p.h | 37 +++++++++++++++++++++------- 2 files changed, 42 insertions(+), 45 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp index 93fcb1a216..0fea416404 100644 --- a/src/gui/kernel/qhighdpiscaling.cpp +++ b/src/gui/kernel/qhighdpiscaling.cpp @@ -452,52 +452,30 @@ QDpi QHighDpiScaling::logicalDpi() return m_logicalDpi; } -qreal QHighDpiScaling::factor(const QScreen *screen) +QHighDpiScaling::ScaleAndOrigin QHighDpiScaling::scaleAndOrigin(const QPlatformScreen *platformScreen, QPoint *nativePosition) { - // Fast path for when scaling in Qt is not used at all. if (!m_active) - return qreal(1.0); - - // The effective factor for a given screen is the product of the - // screen and global sub-factors - qreal factor = m_factor; - if (screen) - factor *= screenSubfactor(screen->handle()); - return factor; + return { qreal(1), QPoint() }; + const QPlatformScreen *actualScreen = nativePosition ? + platformScreen->screenForPosition(*nativePosition) : platformScreen; + return { m_factor * screenSubfactor(actualScreen), actualScreen->geometry().topLeft() }; } -qreal QHighDpiScaling::factor(const QPlatformScreen *platformScreen) +QHighDpiScaling::ScaleAndOrigin QHighDpiScaling::scaleAndOrigin(const QScreen *screen, QPoint *nativePosition) { if (!m_active) - return qreal(1.0); - - return m_factor * screenSubfactor(platformScreen); + return { qreal(1), QPoint() }; + if (!screen) + return { m_factor, QPoint() }; // the global factor + return scaleAndOrigin(screen->handle(), nativePosition); } -qreal QHighDpiScaling::factor(const QWindow *window) +QHighDpiScaling::ScaleAndOrigin QHighDpiScaling::scaleAndOrigin(const QWindow *window, QPoint *nativePosition) { if (!m_active) - return qreal(1.0); - - return factor(window ? window->screen() : QGuiApplication::primaryScreen()); -} - -QPoint QHighDpiScaling::origin(const QScreen *screen) -{ - return screen->geometry().topLeft(); -} - -QPoint QHighDpiScaling::origin(const QPlatformScreen *platformScreen) -{ - return platformScreen->geometry().topLeft(); -} - -QPoint QHighDpiScaling::origin(const QWindow *window) -{ - if (window && window->isTopLevel() && window->screen()) - return window->screen()->geometry().topLeft(); - - return QPoint(0, 0); + return { qreal(1), QPoint() }; + QScreen *screen = window ? window->screen() : QGuiApplication::primaryScreen(); + return scaleAndOrigin(screen, nativePosition); } #endif //QT_NO_HIGHDPISCALING diff --git a/src/gui/kernel/qhighdpiscaling_p.h b/src/gui/kernel/qhighdpiscaling_p.h index 525e3fe78e..3410c1d345 100644 --- a/src/gui/kernel/qhighdpiscaling_p.h +++ b/src/gui/kernel/qhighdpiscaling_p.h @@ -78,14 +78,23 @@ public: static void setScreenFactor(QScreen *window, qreal factor); static bool isActive() { return m_active; } - static qreal factor(const QWindow *window); - static qreal factor(const QScreen *screen); - static qreal factor(const QPlatformScreen *platformScreen); - static QPoint origin(const QScreen *screen); - static QPoint origin(const QPlatformScreen *platformScreen); - static QPoint origin(const QWindow *window); - static QPoint mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen); + + struct ScaleAndOrigin + { + qreal factor; + QPoint origin; + }; + static ScaleAndOrigin scaleAndOrigin(const QPlatformScreen *platformScreen, QPoint *nativePosition = nullptr); + static ScaleAndOrigin scaleAndOrigin(const QScreen *screen, QPoint *nativePosition = nullptr); + static ScaleAndOrigin scaleAndOrigin(const QWindow *platformScreen, QPoint *nativePosition = nullptr); + + template + static qreal factor(C *context, QPoint *nativePosition = nullptr) { + return scaleAndOrigin(context, nativePosition).factor; + } + static QPoint mapPositionFromNative(const QPoint &pos, const QPlatformScreen *platformScreen); + static QPoint mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen); static QPoint mapPositionToGlobal(const QPoint &pos, const QPoint &windowGlobalPosition, const QWindow *window); static QPoint mapPositionFromGlobal(const QPoint &pos, const QPoint &windowGlobalPosition, const QWindow *window); static QDpi logicalDpi(); @@ -166,16 +175,26 @@ inline QRegion scale(const QRegion ®ion, qreal scaleFactor, QPoint origin = Q return scaled; } +template +inline QPoint position(T) { return QPoint(); } +inline QPoint position(QPoint point) { return point; } +inline QPoint position(QPointF point) { return point.toPoint(); } +inline QPoint position(QRect rect) { return rect.center(); } +inline QPoint position(QRectF rect) { return rect.center().toPoint(); } + template T fromNativePixels(const T &value, const C *context) { - return scale(value, qreal(1) / QHighDpiScaling::factor(context), QHighDpiScaling::origin(context)); + QPoint nativePosition = position(value); + QHighDpiScaling::ScaleAndOrigin so = QHighDpiScaling::scaleAndOrigin(context, &nativePosition); + return scale(value, qreal(1) / so.factor, so.origin); } template T toNativePixels(const T &value, const C *context) { - return scale(value, QHighDpiScaling::factor(context), QHighDpiScaling::origin(context)); + QHighDpiScaling::ScaleAndOrigin so = QHighDpiScaling::scaleAndOrigin(context); + return scale(value, so.factor, so.origin); } template -- cgit v1.2.3 From 084e17c4e113f72dc43180bae2cb4e8c68b2a0f6 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 19 Jun 2019 13:42:01 +0200 Subject: Avoid undefined behavior in qjsonwriter.cpp See comment in qnumeric_p.h:convertDoubleTo for details. Change-Id: Ifcd13f7f67995af6a60e50ccabe843a855be04ae Reviewed-by: Thiago Macieira --- src/corelib/serialization/qjsonwriter.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/serialization/qjsonwriter.cpp b/src/corelib/serialization/qjsonwriter.cpp index 12ce20ef09..32feb41183 100644 --- a/src/corelib/serialization/qjsonwriter.cpp +++ b/src/corelib/serialization/qjsonwriter.cpp @@ -43,6 +43,7 @@ #include "qjsonwriter_p.h" #include "qjson_p.h" #include "private/qutfcodec_p.h" +#include QT_BEGIN_NAMESPACE @@ -131,8 +132,9 @@ static void valueToJson(const QJsonPrivate::Base *b, const QJsonPrivate::Value & case QJsonValue::Double: { const double d = v.toDouble(b); if (qIsFinite(d)) { // +2 to format to ensure the expected precision - const double abs = std::abs(d); - json += QByteArray::number(d, abs == static_cast(abs) ? 'f' : 'g', QLocale::FloatingPointShortest); + quint64 absInt; + json += QByteArray::number(d, convertDoubleTo(std::abs(d), &absInt) ? 'f' : 'g', + QLocale::FloatingPointShortest); } else { json += "null"; // +INF || -INF || NaN (see RFC4627#section2.4) } -- cgit v1.2.3 From 53da86fe8c2a39bebe665231480cad3cc08b6cb3 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Tue, 16 Apr 2019 09:58:23 +0200 Subject: 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 (cherry picked from commit b21b07877a96c175ee51e83e1b41425c2e67beb3) Reviewed-by: Lars Knoll Reviewed-by: Johan Helsing --- .../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 (limited to 'src') 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) -- cgit v1.2.3 From f6ed6037596783ef1562f586eff69186610ba620 Mon Sep 17 00:00:00 2001 From: Val Doroshchuk Date: Fri, 21 Jun 2019 11:24:06 +0200 Subject: ANGLE: Invalidate client window area when resizing swap chain Inspired by: https://codereview.appspot.com/6812076/ Resizing a window larger results in the newly exposed region being invalidated but the old region is treated as valid. This can result in the old region no longer updating. Was added to D3D9. Improving a fix from Filippo Cucchetto: https://codereview.qt-project.org/c/qt/qtbase/+/195336 and pushing to D3D11. ifndef protects against compilation error for WinRT. Invalidate() should be used only for desktop apps. Task-number: QTBUG-46074 Change-Id: Ie24b8dffe130b970f2362337ac4f9bee666f82b2 Reviewed-by: Oliver Wolff --- .../libANGLE/renderer/d3d/d3d11/SwapChain11.cpp | 4 +++ ...idate-client-window-area-when-resizing-sw.patch | 37 ++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 src/angle/patches/0015-ANGLE-Invalidate-client-window-area-when-resizing-sw.patch (limited to 'src') diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp index dcfd06484d..e8f13b388f 100644 --- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp +++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp @@ -504,6 +504,10 @@ EGLint SwapChain11::resize(const gl::Context *context, ASSERT(SUCCEEDED(result)); if (SUCCEEDED(result)) { +#ifndef ANGLE_ENABLE_WINDOWS_STORE + if (mNativeWindow->getNativeWindow()) + InvalidateRect(mNativeWindow->getNativeWindow(), nullptr, FALSE); +#endif const auto &format = d3d11::Format::Get(mOffscreenRenderTargetFormat, mRenderer->getRenderer11DeviceCaps()); mBackBufferTexture.set(backbufferTexture, format); diff --git a/src/angle/patches/0015-ANGLE-Invalidate-client-window-area-when-resizing-sw.patch b/src/angle/patches/0015-ANGLE-Invalidate-client-window-area-when-resizing-sw.patch new file mode 100644 index 0000000000..9380437761 --- /dev/null +++ b/src/angle/patches/0015-ANGLE-Invalidate-client-window-area-when-resizing-sw.patch @@ -0,0 +1,37 @@ +From 7d300c6e7d05f4e31c966f1298d11da3eae9d679 Mon Sep 17 00:00:00 2001 +From: Val Doroshchuk +Date: Fri, 21 Jun 2019 11:24:06 +0200 +Subject: [PATCH] ANGLE: Invalidate client window area when resizing swap chain + +Inspired by: +https://codereview.appspot.com/6812076/ +Resizing a window larger results in the newly exposed region being invalidated +but the old region is treated as valid. +This can result in the old region no longer updating. +Was added to D3D9. + +Improving a fix from Filippo Cucchetto: +https://codereview.qt-project.org/c/qt/qtbase/+/195336 +and pushing to D3D11. + +ifndef protects against compilation error for WinRT. +Invalidate() should be used only for desktop apps. + +diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp +index dcfd06484d..e8f13b388f 100644 +--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp ++++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp +@@ -504,6 +504,10 @@ EGLint SwapChain11::resize(const gl::Context *context, + ASSERT(SUCCEEDED(result)); + if (SUCCEEDED(result)) + { ++#ifndef ANGLE_ENABLE_WINDOWS_STORE ++ if (mNativeWindow->getNativeWindow()) ++ InvalidateRect(mNativeWindow->getNativeWindow(), nullptr, FALSE); ++#endif + const auto &format = + d3d11::Format::Get(mOffscreenRenderTargetFormat, mRenderer->getRenderer11DeviceCaps()); + mBackBufferTexture.set(backbufferTexture, format); +-- +2.14.2.windows.1 + -- cgit v1.2.3 From 44d9e9b096738a79b6bceffcdad20da42f2e3713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 25 Jun 2019 18:31:58 +0200 Subject: Fix crash when setting QGuiApplication palette before app is available Change-Id: Ia154f66a27cba970d179f100e66aa2daab01c9fa Reviewed-by: Timur Pocheptsov --- src/gui/kernel/qguiapplication.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index a67214bd9a..5014878bd2 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -3233,9 +3233,12 @@ void QGuiApplication::setPalette(const QPalette &pal) QGuiApplicationPrivate::app_pal = new QPalette(pal); else *QGuiApplicationPrivate::app_pal = pal; + applicationResourceFlags |= ApplicationPaletteExplicitlySet; QCoreApplication::setAttribute(Qt::AA_SetPalette); - emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal); + + if (qGuiApp) + emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal); } void QGuiApplicationPrivate::applyWindowGeometrySpecificationTo(QWindow *window) -- cgit v1.2.3 From e21169796297f752a62db25c722ff8e2ff66d8dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Fri, 21 Jun 2019 09:29:22 +0200 Subject: QHttpNetworkConnectionChannel: don't close if we're already closing In some scenarios with QNAM we call socket->close, leading to a flush, leading to an error, leading to another error emission... To work around this scenario we stop trying to close the socket if the network channel is already closing. Change-Id: Id15504f476484ce61f11ba83a5755ceb5f581f9b Fixes: QTBUG-76567 Reviewed-by: Timur Pocheptsov --- src/network/access/qhttpnetworkconnectionchannel.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index d5f63af745..074c389689 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -207,6 +207,9 @@ void QHttpNetworkConnectionChannel::init() void QHttpNetworkConnectionChannel::close() { + if (state == QHttpNetworkConnectionChannel::ClosingState) + return; + if (!socket) state = QHttpNetworkConnectionChannel::IdleState; else if (socket->state() == QAbstractSocket::UnconnectedState) -- cgit v1.2.3 From 89655525ae56dd9662f1873efdce72cbff7bb932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Fri, 21 Jun 2019 09:20:39 +0200 Subject: QHttpNetworkConnection: Change assert to early return and handle Http2 When using a http proxy (and presumably other proxies) we might have failed/aborted (aka "finished") the request and _then_ receive a "proxy authentication required" message from the proxy. In this case there is no spdy/http2 reply in the queue, so asserting is wrong. Change-Id: Id9b76b580299f6a6cd6efad62d6aaf63183816fb Fixes: QTBUG-76426 Reviewed-by: Timur Pocheptsov --- src/network/access/qhttpnetworkconnection.cpp | 12 +++++++----- src/network/access/qhttpnetworkconnectionchannel.cpp | 4 +++- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index c58fd24a44..10c8541c5f 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -1528,19 +1528,21 @@ void QHttpNetworkConnectionPrivate::emitProxyAuthenticationRequired(const QHttpN // dialog is displaying pauseConnection(); QHttpNetworkReply *reply; -#ifndef QT_NO_SSL - if (connectionType == QHttpNetworkConnection::ConnectionTypeSPDY) { + if (connectionType == QHttpNetworkConnection::ConnectionTypeHTTP2 + || connectionType == QHttpNetworkConnection::ConnectionTypeHTTP2Direct +#if QT_CONFIG(ssl) + || connectionType == QHttpNetworkConnection::ConnectionTypeSPDY +#endif + ) { + // we choose the reply to emit the proxyAuth signal from somewhat arbitrarily, // but that does not matter because the signal will ultimately be emitted // by the QNetworkAccessManager. Q_ASSERT(chan->spdyRequestsToSend.count() > 0); reply = chan->spdyRequestsToSend.cbegin().value().second; } else { // HTTP -#endif // QT_NO_SSL reply = chan->reply; -#ifndef QT_NO_SSL } -#endif // QT_NO_SSL Q_ASSERT(reply); emit reply->proxyAuthenticationRequired(proxy, auth); diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 074c389689..38adca2633 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -1115,11 +1115,13 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket void QHttpNetworkConnectionChannel::_q_proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator* auth) { if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2 + || connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2Direct #ifndef QT_NO_SSL || connection->connectionType() == QHttpNetworkConnection::ConnectionTypeSPDY #endif ) { - connection->d_func()->emitProxyAuthenticationRequired(this, proxy, auth); + if (spdyRequestsToSend.count() > 0) + connection->d_func()->emitProxyAuthenticationRequired(this, proxy, auth); } else { // HTTP // Need to dequeue the request before we can emit the error. if (!reply) -- cgit v1.2.3 From cc13b99781b0bbf5f9d09b2c5b081a085762cd0c Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Mon, 24 Jun 2019 17:43:16 +0200 Subject: Do not downscale png when the size is exactly right Don't go through the doScaledRead path (i.e. calling read_image_scaled) when reading an image that the target size is the image of the file we are opening. This makes the loading of the file much faster while keeping the output correct. [ChangeLog][QtGui][QImage] Improve loading time when loading png files that have the same size as the target. Change-Id: I2a33c49fe1ce52ec296c2175ee542b5bcdec2c4b Reviewed-by: Eirik Aavitsland --- src/gui/image/qpnghandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index 801b30881d..e7e998efd1 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -394,7 +394,7 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, QSize scal } QSize outSize(width,height); if (!scaledSize.isEmpty() && quint32(scaledSize.width()) <= width && - quint32(scaledSize.height()) <= height && interlace_method == PNG_INTERLACE_NONE) { + quint32(scaledSize.height()) <= height && scaledSize != outSize && interlace_method == PNG_INTERLACE_NONE) { // Do inline downscaling outSize = scaledSize; if (doScaledRead) -- cgit v1.2.3 From 2a756e294e2efa4bcb2b51afd1c20822df251f29 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Mon, 24 Jun 2019 22:42:28 +0200 Subject: macOS: lower the splash screen when a modal dialog blocks it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes the usability issue of a modal dialog showing up behind a splash screen, not visible to the user, but blocking user input and the application startup sequence until discarded. [ChangeLog][QtWidgets][QSlashScreen] On macOS, lower the splash screen when a modal dialog is shown to make sure the user sees the dialog. Change-Id: Ibae768f76909d930cb25dcf5cee31edc5f15c29a Fixes: QTBUG-49576 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoaintegration.mm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 232c74b1e9..b5d63f8331 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -217,6 +217,25 @@ QCocoaIntegration::QCocoaIntegration(const QStringList ¶mList) connect(qGuiApp, &QGuiApplication::focusWindowChanged, this, &QCocoaIntegration::focusWindowChanged); + + static auto splashScreenHider = QMacKeyValueObserver(NSApp, @"modalWindow", []{ + const QWindowList allWindows = QGuiApplication::topLevelWindows(); + for (QWindow *window : allWindows) { + if ((window->flags() & Qt::SplashScreen) == Qt::SplashScreen) { + QCocoaWindow *platformWindow = static_cast(window->handle()); + NSWindow *splashWindow = platformWindow->view().window; + if (!splashWindow) + continue; + if (NSApp.modalWindow) { + NSInteger originalLevel = splashWindow.level; + splashWindow.level = NSNormalWindowLevel; + window->setProperty("_q_levelBeforeModalSession", (qlonglong)originalLevel); + } else if (NSInteger originalLevel = window->property("_q_levelBeforeModalSession").toLongLong()) { + splashWindow.level = originalLevel; + } + } + } + }); } QCocoaIntegration::~QCocoaIntegration() -- cgit v1.2.3 From df7c97f8eed00a1dcd24a815d89d2842f7d6d116 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Thu, 27 Jun 2019 16:14:30 +0200 Subject: qsslsocket_openssl.cpp - restructure the code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit not to resolve merge conflicts on every 5.13->dev merge. Change-Id: Id41a7efff52148fe46bedcde828646694fd1764d Reviewed-by: Mårten Nordheim --- src/network/ssl/qsslsocket_openssl.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index 4bd2f4c99a..c0035d23a8 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -1572,12 +1572,10 @@ bool QSslSocketBackendPrivate::checkOcspStatus() // verify the responder's chain (see their commit 4ba9a4265bd). // Working this around - is too much fuss for ancient versions we // are dropping quite soon anyway. - { - const unsigned long verificationFlags = 0; - const int success = q_OCSP_basic_verify(basicResponse, peerChain, store, verificationFlags); - if (success <= 0) - ocspErrors.push_back(QSslError::OcspResponseCannotBeTrusted); - } + const unsigned long verificationFlags = 0; + const int success = q_OCSP_basic_verify(basicResponse, peerChain, store, verificationFlags); + if (success <= 0) + ocspErrors.push_back(QSslError::OcspResponseCannotBeTrusted); if (q_OCSP_resp_count(basicResponse) != 1) { ocspErrors.push_back(QSslError::OcspMalformedResponse); -- cgit v1.2.3 From 1e4dec12d5c0152d5c3eee3b612a0af4bf389a37 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Thu, 27 Jun 2019 11:51:26 +0300 Subject: Android: Stick with buildToolsVersion 28.0.3 On Windows buildToolsVersion 29.0.0 have problems, therefore, it's better to use a version that we know it works on all platofrms. Change-Id: I25cdea4b8101bfe5f022025fcd7cc4cbf358fa03 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/android/templates/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/android/templates/build.gradle b/src/android/templates/build.gradle index 989d0792cf..ed704c4957 100644 --- a/src/android/templates/build.gradle +++ b/src/android/templates/build.gradle @@ -36,7 +36,7 @@ android { compileSdkVersion androidCompileSdkVersion.toInteger() - buildToolsVersion androidBuildToolsVersion + buildToolsVersion '28.0.3' sourceSets { main { -- cgit v1.2.3 From d1141b6c90e53554f69fd6a7a272988211f5bd34 Mon Sep 17 00:00:00 2001 From: Joni Poikelin Date: Thu, 28 Feb 2019 09:54:20 +0200 Subject: Fix crash with drag cursor handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 7a7c722782a435f7c01b94f48df7a5f4ff4d599e caused a regresssion in some cases. Change-Id: I1089a79534d811b195de663ff664d9ba5a6ac6c5 Fixes: QTBUG-74110 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qsimpledrag.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp index 9aab332ef5..bd409c124f 100644 --- a/src/gui/kernel/qsimpledrag.cpp +++ b/src/gui/kernel/qsimpledrag.cpp @@ -310,11 +310,15 @@ void QBasicDrag::updateCursor(Qt::DropAction action) m_dndHasSetOverrideCursor = true; } else { QCursor *cursor = QGuiApplication::overrideCursor(); - if (!pixmap.isNull()) { - if (cursor->pixmap().cacheKey() != pixmap.cacheKey()) - QGuiApplication::changeOverrideCursor(QCursor(pixmap)); - } else if (cursorShape != cursor->shape()) { - QGuiApplication::changeOverrideCursor(QCursor(cursorShape)); + if (!cursor) { + QGuiApplication::changeOverrideCursor(pixmap.isNull() ? QCursor(cursorShape) : QCursor(pixmap)); + } else { + if (!pixmap.isNull()) { + if (cursor->pixmap().cacheKey() != pixmap.cacheKey()) + QGuiApplication::changeOverrideCursor(QCursor(pixmap)); + } else if (cursorShape != cursor->shape()) { + QGuiApplication::changeOverrideCursor(QCursor(cursorShape)); + } } } #endif -- cgit v1.2.3 From e19d93b212d71521b7edd3a7e45e4b9319cd5c72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Thu, 27 Jun 2019 11:38:43 +0200 Subject: QSocks5SocketEngine: avoid dereferencing null-pointer The header argument is optional Change-Id: I035e11db5ee70183274afb48ba67c4d3ed2f615d Reviewed-by: Timur Pocheptsov --- src/network/socket/qsocks5socketengine.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index dd2bc90855..6791b85273 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -1611,8 +1611,10 @@ qint64 QSocks5SocketEngine::readDatagram(char *data, qint64 maxlen, QIpPacketHea QSocks5RevivedDatagram datagram = d->udpData->pendingDatagrams.dequeue(); int copyLen = qMin(maxlen, datagram.data.size()); memcpy(data, datagram.data.constData(), copyLen); - header->senderAddress = datagram.address; - header->senderPort = datagram.port; + if (header) { + header->senderAddress = datagram.address; + header->senderPort = datagram.port; + } return copyLen; #else Q_UNUSED(data) -- cgit v1.2.3 From 399bf445771936648691c48bebca500b36ae69dd Mon Sep 17 00:00:00 2001 From: Vova Mshanetskiy Date: Fri, 31 May 2019 18:51:43 +0300 Subject: QAndroidInputContext: Consider preedit text in getCursorCapsMode() Fixes auto-capitalization in AnySoftKeyboard. It was typing the whole first word in a sentence in upper case. Change-Id: I605a1aee39d432a3474c0bf706445d354562285f Reviewed-by: BogDan Vatra --- src/plugins/platforms/android/qandroidinputcontext.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index fa07af8c46..bab71751f8 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -1200,13 +1200,18 @@ jint QAndroidInputContext::getCursorCapsMode(jint /*reqModes*/) const uint qtInputMethodHints = query->value(Qt::ImHints).toUInt(); const int localPos = query->value(Qt::ImCursorPosition).toInt(); - bool atWordBoundary = (localPos == 0); + bool atWordBoundary = + localPos == 0 + && (!focusObjectIsComposing() || m_composingCursor == m_composingTextStart); + if (!atWordBoundary) { QString surroundingText = query->value(Qt::ImSurroundingText).toString(); surroundingText.truncate(localPos); + if (focusObjectIsComposing()) + surroundingText += m_composingText.leftRef(m_composingCursor - m_composingTextStart); // Add a character to see if it is at the end of the sentence or not QTextBoundaryFinder finder(QTextBoundaryFinder::Sentence, surroundingText + QLatin1Char('A')); - finder.setPosition(localPos); + finder.setPosition(surroundingText.length()); if (finder.isAtBoundary()) atWordBoundary = finder.isAtBoundary(); } -- cgit v1.2.3 From 2c61b4e0f08e55d5478e710fe66eb12594ae17cb Mon Sep 17 00:00:00 2001 From: Vova Mshanetskiy Date: Fri, 31 May 2019 19:42:57 +0300 Subject: QAndroidInputContext: Do not stop composing when user taps the cursor There is no need to tell the editor to stop composing if user taps so close to the cursor position that the cursor will not move anyway. If we do stop composing in such case, then since there will be no cursor position change notification, we will never start composing again (before the cursor is actually moved), and the current composing region will remain being displayed as normal text instead of being displayed as composing text. Change-Id: I4ebe6442e1ba8c365d6754c1a8487235d177c732 Reviewed-by: BogDan Vatra --- .../platforms/android/qandroidinputcontext.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index bab71751f8..69b100fa4e 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -792,7 +792,25 @@ void QAndroidInputContext::touchDown(int x, int y) m_handleMode = ShowCursor; // The VK will appear in a moment, stop the timer m_hideCursorHandleTimer.stop(); - focusObjectStopComposing(); + + if (focusObjectIsComposing()) { + const double pixelDensity = + QGuiApplication::focusWindow() + ? QHighDpiScaling::factor(QGuiApplication::focusWindow()) + : QHighDpiScaling::factor(QtAndroid::androidPlatformIntegration()->screen()); + + const QPointF touchPointLocal = + QGuiApplication::inputMethod()->inputItemTransform().inverted().map( + QPointF(x / pixelDensity, y / pixelDensity)); + + const int curBlockPos = getBlockPosition( + focusObjectInputMethodQuery(Qt::ImCursorPosition | Qt::ImAbsolutePosition)); + const int touchPosition = curBlockPos + + QInputMethod::queryFocusObject(Qt::ImCursorPosition, touchPointLocal).toInt(); + if (touchPosition != m_composingCursor) + focusObjectStopComposing(); + } + updateSelectionHandles(); } } -- cgit v1.2.3 From 346f1999f579c76c98eaa53c5bec2510ae596c22 Mon Sep 17 00:00:00 2001 From: Vova Mshanetskiy Date: Wed, 5 Jun 2019 14:59:18 +0300 Subject: QAndroidInputContext: Generate a QInputMethodEvent in reset() Although QPlatformInputContext::reset() documentation says that reset() should not send any QInputMethodEvents, implementations on Windows, macOS and iOS do send a QInputMethodEvent which clears preedit text in their reimplementations of reset(). Text editing controls depend on that and may not clear preedit text if such event is not sent. Change-Id: I75ab73946cb06e93e5fc5e98e0cc503a7de5c2e0 Reviewed-by: BogDan Vatra --- src/plugins/platforms/android/qandroidinputcontext.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index 69b100fa4e..5614d3b04f 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -558,6 +558,7 @@ static inline int getBlockPosition(const QSharedPointer void QAndroidInputContext::reset() { + focusObjectStopComposing(); clear(); m_batchEditNestingLevel = 0; m_handleMode = Hidden; -- cgit v1.2.3 From 7ffb5b2c8c1d374d8181ebcd288b869c43fe5b3a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 22 May 2019 12:25:51 -0700 Subject: Fix Clang warning about applying operator|| to non-boolean qmetatype_p.h:111:412: error: use of logical '||' with constant operand [-Werror,-Wconstant-logical-operand] Change-Id: Iac6ae11e29bd4169bae9fffd15a117d576a95adb Reviewed-by: Ville Voutilainen --- src/corelib/kernel/qmetatype_p.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qmetatype_p.h b/src/corelib/kernel/qmetatype_p.h index 94e9228778..eba0207ea7 100644 --- a/src/corelib/kernel/qmetatype_p.h +++ b/src/corelib/kernel/qmetatype_p.h @@ -74,7 +74,7 @@ template class QTypeModuleInfo { public: - enum Module { + enum Module : bool { IsCore = false, IsWidget = false, IsGui = false, @@ -87,7 +87,7 @@ template<> \ class QTypeModuleInfo \ { \ public: \ - enum Module { \ + enum Module : bool { \ IsCore = (((MODULE) == (QModulesPrivate::Core))), \ IsWidget = (((MODULE) == (QModulesPrivate::Widgets))), \ IsGui = (((MODULE) == (QModulesPrivate::Gui))), \ -- cgit v1.2.3 From 89d28ebe86e3e3912b4811f344c728e053bab122 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 27 Jun 2019 19:20:04 -0700 Subject: QTransposeProxyModel: include the moc in the .cpp All the other QtCore files do. Change-Id: Ie7ae7616eadf4035bec6fffd15ac3b5479716ff3 Reviewed-by: Marc Mutz --- src/corelib/itemmodels/qtransposeproxymodel.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/corelib/itemmodels/qtransposeproxymodel.cpp b/src/corelib/itemmodels/qtransposeproxymodel.cpp index d4f379bc64..4853f90632 100644 --- a/src/corelib/itemmodels/qtransposeproxymodel.cpp +++ b/src/corelib/itemmodels/qtransposeproxymodel.cpp @@ -445,3 +445,5 @@ void QTransposeProxyModel::sort(int column, Qt::SortOrder order) } QT_END_NAMESPACE + +#include "moc_qtransposeproxymodel.cpp" -- cgit v1.2.3 From d62ee142839ff78134d6d4a48acfdd11040ceeae Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 15 May 2019 07:48:49 -0700 Subject: Work around Apple Clang's -Wshadow warning Well, yeah, it technically does... qcborstream.h:245:15: warning: declaration shadows a typedef in the global namespace [-Wshadow] /usr/include/libkern/OSTypes.h:36:26: note: previous declaration is here Fixes: QTBUG-75825 Change-Id: Idce141629dd34287808bfffd159ee2a75428bf12 Reviewed-by: Marc Mutz --- src/corelib/serialization/qcborstream.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/serialization/qcborstream.h b/src/corelib/serialization/qcborstream.h index 3b13a309ab..7a451e63ac 100644 --- a/src/corelib/serialization/qcborstream.h +++ b/src/corelib/serialization/qcborstream.h @@ -242,8 +242,8 @@ private: template FP _toFloatingPoint() const noexcept { - using UInt = typename QIntegerForSizeof::Unsigned; - UInt u = UInt(value64); + using UIntFP = typename QIntegerForSizeof::Unsigned; + UIntFP u = UIntFP(value64); FP f; memcpy(static_cast(&f), &u, sizeof(f)); return f; -- cgit v1.2.3 From b321559a22a3ee6490695ecb9d95d3c9fbf7ee1c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 29 Apr 2019 11:13:04 -0700 Subject: Document OOM conditions in the QArrayData-based containers The other containers probably don't handle as well, so I just documented the ones that I know how they work. Fixes: QTBUG-75470 Change-Id: I95ecabe2f50e450c991afffd159a0483aac35a79 Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Albert Astals Cid Reviewed-by: Thiago Macieira --- src/corelib/tools/qbytearray.cpp | 17 +++++++++++++++++ src/corelib/tools/qstring.cpp | 18 ++++++++++++++++++ src/corelib/tools/qvector.qdoc | 18 ++++++++++++++++++ 3 files changed, 53 insertions(+) (limited to 'src') diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index 6cc41a8956..c2c2b9de28 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -1043,6 +1043,23 @@ QByteArray qUncompress(const uchar* data, int nbytes) and QByteArray() compares equal to QByteArray(""). We recommend that you always use isEmpty() and avoid isNull(). + \section1 Maximum size and out-of-memory conditions + + The current version of QByteArray is limited to just under 2 GB (2^31 + bytes) in size. The exact value is architecture-dependent, since it depends + on the overhead required for managing the data block, but is no more than + 32 bytes. Raw data blocks are also limited by the use of \c int type in the + current version to 2 GB minus 1 byte. + + In case memory allocation fails, QByteArray will throw a \c std::bad_alloc + exception. Out of memory conditions in the Qt containers are the only case + where Qt will throw exceptions. + + Note that the operating system may impose further limits on applications + holding a lot of allocated memory, especially large, contiguous blocks. + Such considerations, the configuration of such behavior or any mitigation + are outside the scope of the QByteArray API. + \section1 Notes on Locale \section2 Number-String Conversions diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index ee9d486eb8..a0e33d4e45 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -1777,6 +1777,24 @@ const QString::Null QString::null = { }; and the \c{'+'} will automatically be performed as the \c{QStringBuilder} \c{'%'} everywhere. + \section1 Maximum size and out-of-memory conditions + + The current version of QString is limited to just under 2 GB (2^31 bytes) + in size. The exact value is architecture-dependent, since it depends on the + overhead required for managing the data block, but is no more than 32 + bytes. Raw data blocks are also limited by the use of \c int type in the + current version to 2 GB minus 1 byte. Since QString uses two bytes per + character, that translates to just under 2^30 characters in one QString. + + In case memory allocation fails, QString will throw a \c std::bad_alloc + exception. Out of memory conditions in the Qt containers are the only case + where Qt will throw exceptions. + + Note that the operating system may impose further limits on applications + holding a lot of allocated memory, especially large, contiguous blocks. + Such considerations, the configuration of such behavior or any mitigation + are outside the scope of the Qt API. + \sa fromRawData(), QChar, QLatin1String, QByteArray, QStringRef */ diff --git a/src/corelib/tools/qvector.qdoc b/src/corelib/tools/qvector.qdoc index 75b17a4207..ad5821e73b 100644 --- a/src/corelib/tools/qvector.qdoc +++ b/src/corelib/tools/qvector.qdoc @@ -173,6 +173,24 @@ For a detailed discussion comparing Qt containers with each other and with STL containers, see \l {Understand the Qt Containers}. + \section1 Maximum size and out-of-memory conditions + + The current version of QVector is limited to just under 2 GB (2^31 bytes) + in size. The exact value is architecture-dependent, since it depends on the + overhead required for managing the data block, but is no more than 32 + bytes. The number of elements that can be stored in a QVector is that size + divided by the size of each element. + + In case memory allocation fails, QVector will use the \l Q_CHECK_PTR macro, + which will throw a \c std::bad_alloc exception if the application is being + compiled with exception support. If exceptions are disabled, then running + out of memory is undefined behavior. + + Note that the operating system may impose further limits on applications + holding a lot of allocated memory, especially large, contiguous blocks. + Such considerations, the configuration of such behavior or any mitigation + are outside the scope of the Qt API. + \sa QVectorIterator, QMutableVectorIterator, QList, QLinkedList */ -- cgit v1.2.3 From 227c1a56ecb8b99cbd64bd6b8335b3cc3c8a21f1 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 14 Apr 2019 08:20:31 -0700 Subject: Move the Item typedef to public in the associative Java iterators The documentation talks about them. They're just iterators. Fixes: QTBUG-75123 Change-Id: I194d3f37471a49788a7bfffd15956064b42383b7 Reviewed-by: Lars Knoll --- src/corelib/tools/qiterator.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qiterator.h b/src/corelib/tools/qiterator.h index 586d26cbad..177a4f1a4c 100644 --- a/src/corelib/tools/qiterator.h +++ b/src/corelib/tools/qiterator.h @@ -115,11 +115,11 @@ template \ class Q##C##Iterator \ { \ typedef typename Q##C::const_iterator const_iterator; \ - typedef const_iterator Item; \ Q##C c; \ const_iterator i, n; \ inline bool item_exists() const { return n != c.constEnd(); } \ public: \ + typedef const_iterator Item; \ inline Q##C##Iterator(const Q##C &container) \ : c(container), i(c.constBegin()), n(c.constEnd()) {} \ inline Q##C##Iterator &operator=(const Q##C &container) \ @@ -148,11 +148,11 @@ class QMutable##C##Iterator \ { \ typedef typename Q##C::iterator iterator; \ typedef typename Q##C::const_iterator const_iterator; \ - typedef iterator Item; \ Q##C *c; \ iterator i, n; \ inline bool item_exists() const { return const_iterator(n) != c->constEnd(); } \ public: \ + typedef iterator Item; \ inline QMutable##C##Iterator(Q##C &container) \ : c(&container) \ { i = c->begin(); n = c->end(); } \ -- cgit v1.2.3 From a39b19b0c7419021b3c22dc4d4bced0995f3a29f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 27 Mar 2019 11:18:37 -0700 Subject: QTranslator: simplify QString byte-swapping code No need to check QSysInfo, just use qFromBigEndian. On big-endian systems, it does the memcpy for us. Change-Id: I1004b4b819774c4c9296fffd158fe3aa5ff0a287 Reviewed-by: Oswald Buddenhagen Reviewed-by: Thiago Macieira --- src/corelib/kernel/qtranslator.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp index dc0ab9f08a..637ef84d21 100644 --- a/src/corelib/kernel/qtranslator.cpp +++ b/src/corelib/kernel/qtranslator.cpp @@ -948,11 +948,8 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context, end: if (!tn) return QString(); - QString str = QString((const QChar *)tn, tn_length/2); - if (QSysInfo::ByteOrder == QSysInfo::LittleEndian) { - QChar *data = str.data(); - qbswap(data, str.length(), data); - } + QString str(tn_length / 2, Qt::Uninitialized); + qFromBigEndian(tn, str.length(), str.data()); return str; } -- cgit v1.2.3