From a6ffdbe30c49fa1ede0d147531b89d121d00fa94 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 7 Oct 2019 05:30:54 +0200 Subject: QTextCodec: try to work around an ICC 19 bug ICC 19 barfs on the TextCodecsMutexLocker class because it doesn't have a user-provided default ctor: ../../corelib/codecs/qtextcodec.cpp(543): error #854: const variable locker requires an initializer -- class TextCodecsMutexLocker has no user-provided default constructor [...] But the class doesn't have members that would delete the implictly-declared default ctor, so no user-provided default ctor should be necessary: The only member is the result of qt_unique_lock(), which is std::unique_lock, which does have a default ctor. We conclude that this is a compiler bug, and work around it with the introduction of a user-provided default ctor. Fix brace placement as a drive-by. Fixes: QTBUG-78844 Change-Id: I1f5a326afd68138fbebad506ba9aa1926f1afb85 Reviewed-by: Thiago Macieira --- src/corelib/codecs/qtextcodec.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index 14f9abc28a..06fd88da90 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -103,10 +103,13 @@ typedef QList::ConstIterator ByteArrayListConstIt; Q_GLOBAL_STATIC(QRecursiveMutex, textCodecsMutex); -class TextCodecsMutexLocker { +class TextCodecsMutexLocker +{ using Lock = decltype(qt_unique_lock(std::declval())); // ### FIXME: this is used when textCodecsMutex already == nullptr const Lock lock = qt_unique_lock(textCodecsMutex()); +public: + TextCodecsMutexLocker() {} // required d/t an ICC 19 bug }; #if !QT_CONFIG(icu) -- cgit v1.2.3 From 38cf346bd70de6aaabfbf66ba159919591ce9098 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 7 Oct 2019 11:19:01 +0200 Subject: QMacStyle::drawControl - lift the pool declaration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit out of switch/case - can help in case some NSControl is using autorelease and an application is calling drawControl too often. Fixes: QTBUG-78761 Change-Id: I2b55d533f52db16703dcc965920f4316fdf76734 Reviewed-by: Tor Arne Vestbø --- src/plugins/styles/mac/qmacstyle_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index b2bcdb3e5b..0a216e540d 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -3462,6 +3462,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter { Q_D(const QMacStyle); const AppearanceSync sync; + const QMacAutoReleasePool pool; QMacCGContext cg(p); QWindow *window = w && w->window() ? w->window()->windowHandle() : nullptr; d->resolveCurrentNSView(window); @@ -4326,7 +4327,6 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter break; case CE_ProgressBarContents: if (const QStyleOptionProgressBar *pb = qstyleoption_cast(opt)) { - QMacAutoReleasePool pool; const bool isIndeterminate = (pb->minimum == 0 && pb->maximum == 0); const bool vertical = pb->orientation == Qt::Vertical; const bool inverted = pb->invertedAppearance; -- cgit v1.2.3 From 1ed9cc2a93a1b5215b5ad149d9698aa970d1756a Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 1 Oct 2019 07:05:15 +0200 Subject: Drop unused code These defines are never used; maybe a remnant from Qt 4? Change-Id: Ieb12e629493e5483ca5ab84577569610eceb9417 Reviewed-by: Edward Welbourne Reviewed-by: Ulf Hermann --- src/corelib/text/qlocale_tools_p.h | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/corelib/text/qlocale_tools_p.h b/src/corelib/text/qlocale_tools_p.h index 594331ae37..e2142bf545 100644 --- a/src/corelib/text/qlocale_tools_p.h +++ b/src/corelib/text/qlocale_tools_p.h @@ -54,22 +54,6 @@ #include "qlocale_p.h" #include "qstring.h" -#if !defined(QT_QLOCALE_NEEDS_VOLATILE) -# if defined(Q_CC_GNU) -# if __GNUC__ == 4 -# define QT_QLOCALE_NEEDS_VOLATILE -# elif defined(Q_OS_WIN) -# define QT_QLOCALE_NEEDS_VOLATILE -# endif -# endif -#endif - -#if defined(QT_QLOCALE_NEEDS_VOLATILE) -# define NEEDS_VOLATILE volatile -#else -# define NEEDS_VOLATILE -#endif - QT_BEGIN_NAMESPACE enum StrayCharacterMode { -- cgit v1.2.3 From af8f3c5da4b842973f7e2b279fe21c486fcee696 Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Tue, 1 Oct 2019 17:12:42 +0200 Subject: Add libfuzzer test for QTextLayout::beginLayout() Task-number: QTBUG-77819 Change-Id: I34e9cbaa615896222bcf947012cfed9f6c3186c7 Reviewed-by: Rainer Keller --- .../text/qtextlayout/beginLayout/beginLayout.pro | 3 ++ .../gui/text/qtextlayout/beginLayout/main.cpp | 36 ++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 tests/libfuzzer/gui/text/qtextlayout/beginLayout/beginLayout.pro create mode 100644 tests/libfuzzer/gui/text/qtextlayout/beginLayout/main.cpp diff --git a/tests/libfuzzer/gui/text/qtextlayout/beginLayout/beginLayout.pro b/tests/libfuzzer/gui/text/qtextlayout/beginLayout/beginLayout.pro new file mode 100644 index 0000000000..c9b14f6caf --- /dev/null +++ b/tests/libfuzzer/gui/text/qtextlayout/beginLayout/beginLayout.pro @@ -0,0 +1,3 @@ +QT += widgets +SOURCES += main.cpp +LIBS += -fsanitize=fuzzer diff --git a/tests/libfuzzer/gui/text/qtextlayout/beginLayout/main.cpp b/tests/libfuzzer/gui/text/qtextlayout/beginLayout/main.cpp new file mode 100644 index 0000000000..dfb9559241 --- /dev/null +++ b/tests/libfuzzer/gui/text/qtextlayout/beginLayout/main.cpp @@ -0,0 +1,36 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) { + QTextLayout tl(QByteArray::fromRawData(Data, Size)); + tl.beginLayout(); + tl.endLayout(); + return 0; +} -- cgit v1.2.3 From 7a3d647bab633caae270a74d8a398669bbfe8521 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Fri, 4 Oct 2019 14:49:30 +0200 Subject: Vulkan: Add platform hooks before presenting This allows the Wayland plugin to circumvent the frame callback handling of the driver (which blocks until the frame is presented, potentially forever, if the window is minimized). Task-number: QTBUG-78000 Change-Id: Ia7d347019dfeae3bfcfad3d0cca3f4fffdc8c7a9 Reviewed-by: Laszlo Agocs --- src/gui/rhi/qrhivulkan.cpp | 4 ++++ src/gui/vulkan/qplatformvulkaninstance.cpp | 5 +++++ src/gui/vulkan/qplatformvulkaninstance.h | 1 + src/gui/vulkan/qvulkaninstance.cpp | 14 ++++++++++++++ src/gui/vulkan/qvulkaninstance.h | 1 + src/gui/vulkan/qvulkanwindow.cpp | 4 ++++ 6 files changed, 29 insertions(+) diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index 36a6557e04..d07777d63a 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -1705,6 +1705,10 @@ QRhi::FrameOpResult QRhiVulkan::endFrame(QRhiSwapChain *swapChain, QRhi::EndFram presInfo.waitSemaphoreCount = 1; presInfo.pWaitSemaphores = &frame.drawSem; // gfxQueueFamilyIdx == presQueueFamilyIdx ? &frame.drawSem : &frame.presTransSem; + // Do platform-specific WM notification. F.ex. essential on Wayland in + // order to circumvent driver frame callbacks + inst->presentAboutToBeQueued(swapChainD->window); + VkResult err = vkQueuePresentKHR(gfxQueue, &presInfo); if (err != VK_SUCCESS) { if (err == VK_ERROR_OUT_OF_DATE_KHR) { diff --git a/src/gui/vulkan/qplatformvulkaninstance.cpp b/src/gui/vulkan/qplatformvulkaninstance.cpp index 9d044bfd58..1b5d3370f0 100644 --- a/src/gui/vulkan/qplatformvulkaninstance.cpp +++ b/src/gui/vulkan/qplatformvulkaninstance.cpp @@ -80,6 +80,11 @@ QPlatformVulkanInstance::~QPlatformVulkanInstance() { } +void QPlatformVulkanInstance::presentAboutToBeQueued(QWindow *window) +{ + Q_UNUSED(window); +} + void QPlatformVulkanInstance::presentQueued(QWindow *window) { Q_UNUSED(window); diff --git a/src/gui/vulkan/qplatformvulkaninstance.h b/src/gui/vulkan/qplatformvulkaninstance.h index d47c59b5db..f96f1720fb 100644 --- a/src/gui/vulkan/qplatformvulkaninstance.h +++ b/src/gui/vulkan/qplatformvulkaninstance.h @@ -77,6 +77,7 @@ public: virtual QByteArrayList enabledExtensions() const = 0; virtual PFN_vkVoidFunction getInstanceProcAddr(const char *name) = 0; virtual bool supportsPresent(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, QWindow *window) = 0; + virtual void presentAboutToBeQueued(QWindow *window); virtual void presentQueued(QWindow *window); virtual void setDebugFilters(const QVector &filters); diff --git a/src/gui/vulkan/qvulkaninstance.cpp b/src/gui/vulkan/qvulkaninstance.cpp index 0605d88cca..daf37e3dc8 100644 --- a/src/gui/vulkan/qvulkaninstance.cpp +++ b/src/gui/vulkan/qvulkaninstance.cpp @@ -774,6 +774,20 @@ bool QVulkanInstance::supportsPresent(VkPhysicalDevice physicalDevice, uint32_t return d_ptr->platformInst->supportsPresent(physicalDevice, queueFamilyIndex, window); } +/*! + This function should be called by the application's renderer before queuing + a present operation for \a window. + + While on some platforms this will be a no-op, some may perform windowing + system dependent synchronization. For example, on Wayland this will + add send a wl_surface.frame request in order to prevent the driver from + blocking for minimized windows. + */ +void QVulkanInstance::presentAboutToBeQueued(QWindow *window) +{ + d_ptr->platformInst->presentAboutToBeQueued(window); +} + /*! This function should be called by the application's renderer after queuing a present operation for \a window. diff --git a/src/gui/vulkan/qvulkaninstance.h b/src/gui/vulkan/qvulkaninstance.h index 70f2fd5102..5b3db9a4c8 100644 --- a/src/gui/vulkan/qvulkaninstance.h +++ b/src/gui/vulkan/qvulkaninstance.h @@ -186,6 +186,7 @@ public: bool supportsPresent(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, QWindow *window); + void presentAboutToBeQueued(QWindow *window); void presentQueued(QWindow *window); typedef bool (*DebugFilter)(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, diff --git a/src/gui/vulkan/qvulkanwindow.cpp b/src/gui/vulkan/qvulkanwindow.cpp index caf53eb586..790bef9e14 100644 --- a/src/gui/vulkan/qvulkanwindow.cpp +++ b/src/gui/vulkan/qvulkanwindow.cpp @@ -2018,6 +2018,10 @@ void QVulkanWindowPrivate::endFrame() presInfo.waitSemaphoreCount = 1; presInfo.pWaitSemaphores = gfxQueueFamilyIdx == presQueueFamilyIdx ? &frame.drawSem : &frame.presTransSem; + // Do platform-specific WM notification. F.ex. essential on Wayland in + // order to circumvent driver frame callbacks + inst->presentAboutToBeQueued(q); + err = vkQueuePresentKHR(gfxQueue, &presInfo); if (err != VK_SUCCESS) { if (err == VK_ERROR_OUT_OF_DATE_KHR) { -- cgit v1.2.3 From b8a17ee13559a38c4cb2f20f91c39ea39d5ded9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 7 Oct 2019 12:28:08 +0200 Subject: Fix double free when debug printing QFont with non-default verbosity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ieb7fa19e8bdd98f5283f7f6d8751e6532c8e0fc4 Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Tor Arne Vestbø --- src/gui/text/qfont.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index efc79a1783..76fde5388c 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -3176,8 +3176,7 @@ QDebug operator<<(QDebug stream, const QFont &font) QDebug debug(&fontDescription); debug.nospace(); - QFontPrivate priv; - const QFont defaultFont(&priv); + const QFont defaultFont(new QFontPrivate); for (int property = QFont::FamilyResolved; property < QFont::AllPropertiesResolved; property <<= 1) { const bool resolved = (font.resolve_mask & property) != 0; -- cgit v1.2.3 From 6906b0647a2e1389a9eeeef0dd0f6354c9dd4206 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Sat, 5 Oct 2019 13:28:55 +0200 Subject: macOS: Pass required parameters to NSOpenSavePanelDelegate callbacks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I0e0322734a077e4ee948128f3ba6c074514ccbb9 Reviewed-by: Volker Hilsheimer Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm index 5f32400af0..03677ef0bc 100644 --- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm @@ -214,7 +214,7 @@ static QString strippedText(QString s) NSString *filepath = info.filePath().toNSString(); NSURL *url = [NSURL fileURLWithPath:filepath isDirectory:info.isDir()]; bool selectable = (mOptions->acceptMode() == QFileDialogOptions::AcceptSave) - || [self panel:nil shouldEnableURL:url]; + || [self panel:mOpenPanel shouldEnableURL:url]; [self updateProperties]; [mSavePanel setNameFieldStringValue:selectable ? info.fileName().toNSString() : @""]; @@ -233,7 +233,7 @@ static QString strippedText(QString s) NSString *filepath = info.filePath().toNSString(); NSURL *url = [NSURL fileURLWithPath:filepath isDirectory:info.isDir()]; bool selectable = (mOptions->acceptMode() == QFileDialogOptions::AcceptSave) - || [self panel:nil shouldEnableURL:url]; + || [self panel:mSavePanel shouldEnableURL:url]; [mSavePanel setDirectoryURL: [NSURL fileURLWithPath:mCurrentDir]]; [mSavePanel setNameFieldStringValue:selectable ? info.fileName().toNSString() : @""]; @@ -263,7 +263,7 @@ static QString strippedText(QString s) NSString *filepath = info.filePath().toNSString(); NSURL *url = [NSURL fileURLWithPath:filepath isDirectory:info.isDir()]; bool selectable = (mOptions->acceptMode() == QFileDialogOptions::AcceptSave) - || [self panel:nil shouldEnableURL:url]; + || [self panel:mSavePanel shouldEnableURL:url]; [self updateProperties]; [mSavePanel setDirectoryURL: [NSURL fileURLWithPath:mCurrentDir]]; -- cgit v1.2.3 From c962c77044901a08d1ec15ffec81d48f87a35b4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 3 Oct 2019 16:07:37 +0200 Subject: CoreText: Warn the user when family alias lookup slows down the application If the user specifies a font family in their application that doesn't exist in the system, or one that uses the localized family name, we will end up resolving the family alias for all fonts in the system, which typically adds 600-800ms of startup time. Let the user know when this happens. Change-Id: Id8d6f55028e37f681ec4a686df25d33240b5a30f Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qfontdatabase.cpp | 2 +- src/gui/text/qplatformfontdatabase.h | 2 +- .../fontdatabases/mac/qcoretextfontdatabase.mm | 50 +++++++++++++++++++--- .../fontdatabases/mac/qcoretextfontdatabase_p.h | 2 +- 4 files changed, 48 insertions(+), 8 deletions(-) diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index ce6bb0c347..261e1d831b 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -2684,7 +2684,7 @@ QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script) QtFontDesc desc; QList blackListed; int index = match(multi ? QChar::Script_Common : script, request, family_name, foundry_name, &desc, blackListed); - if (index < 0 && QGuiApplicationPrivate::platformIntegration()->fontDatabase()->populateFamilyAliases()) { + if (index < 0 && QGuiApplicationPrivate::platformIntegration()->fontDatabase()->populateFamilyAliases(family_name)) { // We populated familiy aliases (e.g. localized families), so try again index = match(multi ? QChar::Script_Common : script, request, family_name, foundry_name, &desc, blackListed); } diff --git a/src/gui/text/qplatformfontdatabase.h b/src/gui/text/qplatformfontdatabase.h index 38ba7f10b2..f79c5db625 100644 --- a/src/gui/text/qplatformfontdatabase.h +++ b/src/gui/text/qplatformfontdatabase.h @@ -104,7 +104,7 @@ class Q_GUI_EXPORT QPlatformFontDatabase public: virtual ~QPlatformFontDatabase(); virtual void populateFontDatabase(); - virtual bool populateFamilyAliases() { return false; } + virtual bool populateFamilyAliases(const QString &missingFamily) { Q_UNUSED(missingFamily); return false; } virtual void populateFamily(const QString &familyName); virtual void invalidate(); diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index 201a82864f..4887a501ba 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -48,6 +48,8 @@ #import #endif +#include + #include "qcoretextfontdatabase_p.h" #include "qfontengine_coretext_p.h" #if QT_CONFIG(settings) @@ -113,39 +115,77 @@ QCoreTextFontDatabase::~QCoreTextFontDatabase() void QCoreTextFontDatabase::populateFontDatabase() { + qCDebug(lcQpaFonts) << "Populating font database..."; + QElapsedTimer elapsed; + if (lcQpaFonts().isDebugEnabled()) + elapsed.start(); + QCFType familyNames = CTFontManagerCopyAvailableFontFamilyNames(); for (NSString *familyName in familyNames.as()) QPlatformFontDatabase::registerFontFamily(QString::fromNSString(familyName)); + qCDebug(lcQpaFonts) << "Populating available families took" << elapsed.restart() << "ms"; + // Force creating the theme fonts to get the descriptors in m_systemFontDescriptors if (m_themeFonts.isEmpty()) (void)themeFonts(); + qCDebug(lcQpaFonts) << "Resolving theme fonts took" << elapsed.restart() << "ms"; + Q_FOREACH (CTFontDescriptorRef fontDesc, m_systemFontDescriptors) populateFromDescriptor(fontDesc); + qCDebug(lcQpaFonts) << "Populating system descriptors took" << elapsed.restart() << "ms"; + Q_ASSERT(!m_hasPopulatedAliases); } -bool QCoreTextFontDatabase::populateFamilyAliases() +bool QCoreTextFontDatabase::populateFamilyAliases(const QString &missingFamily) { #if defined(Q_OS_MACOS) if (m_hasPopulatedAliases) return false; + // There's no API to go from a localized family name to its non-localized + // name, so we have to resort to enumerating all the available fonts and + // doing a reverse lookup. + + qCDebug(lcQpaFonts) << "Populating family aliases..."; + QElapsedTimer elapsed; + elapsed.start(); + + QString nonLocalizedMatch; QCFType familyNames = CTFontManagerCopyAvailableFontFamilyNames(); + NSFontManager *fontManager = NSFontManager.sharedFontManager; for (NSString *familyName in familyNames.as()) { - NSFontManager *fontManager = [NSFontManager sharedFontManager]; NSString *localizedFamilyName = [fontManager localizedNameForFamily:familyName face:nil]; if (![localizedFamilyName isEqual:familyName]) { - QPlatformFontDatabase::registerAliasToFontFamily( - QString::fromNSString(familyName), - QString::fromNSString(localizedFamilyName)); + QString nonLocalizedFamily = QString::fromNSString(familyName); + QString localizedFamily = QString::fromNSString(localizedFamilyName); + QPlatformFontDatabase::registerAliasToFontFamily(nonLocalizedFamily, localizedFamily); + if (localizedFamily == missingFamily) + nonLocalizedMatch = nonLocalizedFamily; } } m_hasPopulatedAliases = true; + + if (lcQpaFonts().isWarningEnabled()) { + QString warningMessage; + QDebug msg(&warningMessage); + + msg << "Populating font family aliases took" << elapsed.restart() << "ms."; + if (!nonLocalizedMatch.isNull()) + msg << "Replace uses of" << missingFamily << "with its non-localized name" << nonLocalizedMatch; + else + msg << "Replace uses of missing font family" << missingFamily << "with one that exists"; + msg << "to avoid this cost."; + + qCWarning(lcQpaFonts) << qPrintable(warningMessage); + } + return true; #else + Q_UNUSED(missingFamily); return false; #endif } diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h index 45e74b99be..69ff454d1e 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h @@ -71,7 +71,7 @@ public: QCoreTextFontDatabase(); ~QCoreTextFontDatabase(); void populateFontDatabase() override; - bool populateFamilyAliases() override; + bool populateFamilyAliases(const QString &missingFamily) override; void populateFamily(const QString &familyName) override; void invalidate() override; -- cgit v1.2.3 From 3425c9c6d7f7915e6f7931da46105b36245e86ad Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Thu, 29 Aug 2019 09:36:53 +0100 Subject: Handle context loss in QPlatformBackingStore This powers a QQuickWidget and we also need to reset the context if we get a context loss event. Change-Id: Id8b7112606670985860069c2bb11cf141b3ac723 Reviewed-by: Laszlo Agocs --- src/gui/painting/qplatformbackingstore.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp index 601dc97be1..45e90bd99b 100644 --- a/src/gui/painting/qplatformbackingstore.cpp +++ b/src/gui/painting/qplatformbackingstore.cpp @@ -338,7 +338,16 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion ®i } } - if (!d_ptr->context->makeCurrent(window)) { + bool current = d_ptr->context->makeCurrent(window); + + if (!current && !d_ptr->context->isValid()) { + delete d_ptr->blitter; + d_ptr->blitter = nullptr; + d_ptr->textureId = 0; + current = d_ptr->context->create() && d_ptr->context->makeCurrent(window); + } + + if (!current) { qCWarning(lcQpaBackingStore, "composeAndFlush: makeCurrent() failed"); return; } -- cgit v1.2.3 From 780137d585344bf9de906a285a50498104c0c66e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 13 Aug 2019 21:59:26 -0700 Subject: QRandom: add support for RDSEED The Intel whitepaer[1] recommends using the RDSEED over RDRAND whenever present. libstdc++ from GCC 10 will also use it in std::random_device. [ChangeLog][QtCore][QRandomGenerator] The system() random generator will now use the RDSEED instruction on x86 processors whenever available as the first source of random data. It will fall back to RDRAND and then to the system functions, in that order. [1] https://software.intel.com/en-us/articles/intel-digital-random-number-generator-drng-software-implementation-guide Change-Id: I907a43cd9a714da288a2fffd15bab176e54e1975 Reviewed-by: Edward Welbourne --- config.tests/x86_simd/main.cpp | 17 +++++++++++++++++ configure.json | 12 ++++++++++++ mkspecs/common/gcc-base.conf | 1 + mkspecs/common/icc-base-unix.conf | 1 + mkspecs/common/msvc-version.conf | 1 + mkspecs/features/simd.prf | 1 + mkspecs/win32-clang-msvc/qmake.conf | 1 + src/corelib/tools/qsimd.cpp | 36 +++++++++++++++++++++++++++++++++++- 8 files changed, 69 insertions(+), 1 deletion(-) diff --git a/config.tests/x86_simd/main.cpp b/config.tests/x86_simd/main.cpp index 4fac13973a..0e7ebed8d9 100644 --- a/config.tests/x86_simd/main.cpp +++ b/config.tests/x86_simd/main.cpp @@ -132,6 +132,23 @@ attribute_target("rdrnd") int test_rdrnd() } #endif +#if T(RDSEED) +attribute_target("rdseed") int test_rdseed() +{ + unsigned short us; + unsigned int ui; + if (_rdseed16_step(&us)) + return 1; + if (_rdseed32_step(&ui)) + return 1; +# if defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64) + unsigned long long ull; + if (_rdseed64_step(&ull)) + return 1; +# endif +} +#endif + #if T(SHANI) attribute_target("sha") void test_shani() { diff --git a/configure.json b/configure.json index 8ebb3c841f..ce71e67993 100644 --- a/configure.json +++ b/configure.json @@ -527,6 +527,10 @@ "label": "RDRAND instruction", "type": "x86Simd" }, + "rdseed": { + "label": "RDSEED instruction", + "type": "x86Simd" + }, "shani": { "label": "SHA new instructions", "type": "x86Simd" @@ -1181,6 +1185,14 @@ { "type": "define", "name": "QT_COMPILER_SUPPORTS_RDRND", "value": 1 } ] }, + "rdseed": { + "label": "RDSEED", + "condition": "tests.rdseed", + "output": [ + "privateConfig", + { "type": "define", "name": "QT_COMPILER_SUPPORTS_RDSEED", "value": 1 } + ] + }, "shani": { "label": "SHA", "condition": "features.sse2 && tests.shani", diff --git a/mkspecs/common/gcc-base.conf b/mkspecs/common/gcc-base.conf index 4d82321cba..472333d2ea 100644 --- a/mkspecs/common/gcc-base.conf +++ b/mkspecs/common/gcc-base.conf @@ -93,6 +93,7 @@ QMAKE_CFLAGS_SSE4_1 += -msse4.1 QMAKE_CFLAGS_SSE4_2 += -msse4.2 QMAKE_CFLAGS_F16C += -mf16c QMAKE_CFLAGS_RDRND += -mrdrnd +QMAKE_CFLAGS_RDSEED += -mrdseed QMAKE_CFLAGS_AVX += -mavx QMAKE_CFLAGS_AVX2 += -mavx2 QMAKE_CFLAGS_AVX512F += -mavx512f diff --git a/mkspecs/common/icc-base-unix.conf b/mkspecs/common/icc-base-unix.conf index 54eda984b7..e0bb55577e 100644 --- a/mkspecs/common/icc-base-unix.conf +++ b/mkspecs/common/icc-base-unix.conf @@ -51,6 +51,7 @@ QMAKE_CFLAGS_AVX512VL += -march=skylake-avx512 QMAKE_CFLAGS_AESNI += -maes QMAKE_CFLAGS_F16C += $$QMAKE_CFLAGS_AVX2 QMAKE_CFLAGS_RDRND += -mrdrnd +QMAKE_CFLAGS_RDSEED += -mrdseed QMAKE_CFLAGS_SHANI += -msha QMAKE_CXX = icpc diff --git a/mkspecs/common/msvc-version.conf b/mkspecs/common/msvc-version.conf index af33132077..adb45582c7 100644 --- a/mkspecs/common/msvc-version.conf +++ b/mkspecs/common/msvc-version.conf @@ -50,6 +50,7 @@ greaterThan(QMAKE_MSC_VER, 1799) { QMAKE_CFLAGS_F16C = -arch:AVX QMAKE_CFLAGS_RDRND = + QMAKE_CFLAGS_RDSEED = equals(QMAKE_MSC_VER, 1800) { QMAKE_CFLAGS_RELEASE += -Zc:strictStrings diff --git a/mkspecs/features/simd.prf b/mkspecs/features/simd.prf index a0b40fcf11..3918c4fe73 100644 --- a/mkspecs/features/simd.prf +++ b/mkspecs/features/simd.prf @@ -137,6 +137,7 @@ addSimdCompiler(avx512ifma) addSimdCompiler(avx512vbmi) addSimdCompiler(f16c) addSimdCompiler(rdrnd) +addSimdCompiler(rdseed) addSimdCompiler(neon) addSimdCompiler(mips_dsp) addSimdCompiler(mips_dspr2) diff --git a/mkspecs/win32-clang-msvc/qmake.conf b/mkspecs/win32-clang-msvc/qmake.conf index 238e401b84..be7cdaa396 100644 --- a/mkspecs/win32-clang-msvc/qmake.conf +++ b/mkspecs/win32-clang-msvc/qmake.conf @@ -15,6 +15,7 @@ QMAKE_CFLAGS_AVX = -mavx QMAKE_CFLAGS_AVX2 = -mavx2 QMAKE_CFLAGS_F16C = -mf16c QMAKE_CFLAGS_RDRND = -mrdrnd +QMAKE_CFLAGS_RDSEED = -mrdseed QMAKE_CFLAGS_AVX512F = -mavx512f QMAKE_CFLAGS_AVX512ER = -mavx512er QMAKE_CFLAGS_AVX512CD = -mavx512cd diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp index fb9b5996f6..6e3b0f9faf 100644 --- a/src/corelib/tools/qsimd.cpp +++ b/src/corelib/tools/qsimd.cpp @@ -626,8 +626,40 @@ void qDumpCPUFeatures() # ifdef Q_PROCESSOR_X86_64 # define _rdrandXX_step _rdrand64_step +# define _rdseedXX_step _rdseed64_step # else # define _rdrandXX_step _rdrand32_step +# define _rdseedXX_step _rdseed32_step +# endif + +# if QT_COMPILER_SUPPORTS_HERE(RDSEED) +static QT_FUNCTION_TARGET(RDSEED) unsigned *qt_random_rdseed(unsigned *ptr, unsigned *end) noexcept +{ + // Unlike for the RDRAND code below, the Intel whitepaper describing the + // use of the RDSEED instruction indicates we should not retry in a loop. + // If the independent bit generator used by RDSEED is out of entropy, it + // may take time to replenish. + // https://software.intel.com/en-us/articles/intel-digital-random-number-generator-drng-software-implementation-guide + while (ptr + sizeof(qregisteruint)/sizeof(*ptr) <= end) { + if (_rdseedXX_step(reinterpret_cast(ptr)) == 0) + goto out; + ptr += sizeof(qregisteruint)/sizeof(*ptr); + } + + if (sizeof(*ptr) != sizeof(qregisteruint) && ptr != end) { + if (_rdseed32_step(ptr) == 0) + goto out; + ++ptr; + } + +out: + return ptr; +} +# else +static unsigned *qt_random_rdseed(unsigned *ptr, unsigned *) +{ + return ptr; +} # endif QT_FUNCTION_TARGET(RDRND) qsizetype qRandomCpu(void *buffer, qsizetype count) noexcept @@ -636,6 +668,9 @@ QT_FUNCTION_TARGET(RDRND) qsizetype qRandomCpu(void *buffer, qsizetype count) no unsigned *end = ptr + count; int retries = 10; + if (qCpuHasFeature(RDSEED)) + ptr = qt_random_rdseed(ptr, end); + while (ptr + sizeof(qregisteruint)/sizeof(*ptr) <= end) { if (_rdrandXX_step(reinterpret_cast(ptr))) ptr += sizeof(qregisteruint)/sizeof(*ptr); @@ -657,5 +692,4 @@ out: } #endif - QT_END_NAMESPACE -- cgit v1.2.3