From 65636ed06069fe7cc83ad159a0f48e4d3d7aba48 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 2 Apr 2020 10:17:43 +0200 Subject: [PATCH 1/5] Documentation: Add examples for Q_NAMESPACE(_EXPORT) It is not obvious how to use them. Change-Id: I60fdfb95f4c29cbc310d149495ebb38964e5a9ac Reviewed-by: Paul Wicking --- src/corelib/kernel/qobject.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 23e4e1163c..3765e19184 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -4614,6 +4614,14 @@ QDebug operator<<(QDebug dbg, const QObject *o) \c{staticMetaObject} is of type QMetaObject and provides access to the enums declared with Q_ENUM_NS/Q_FLAG_NS. + For example: + + \code + namespace test { + Q_NAMESPACE + ... + \endcode + \sa Q_NAMESPACE_EXPORT */ @@ -4630,6 +4638,14 @@ QDebug operator<<(QDebug dbg, const QObject *o) is declared with the supplied \a EXPORT_MACRO qualifier. This is useful if the object needs to be exported from a dynamic library. + For example: + + \code + namespace test { + Q_NAMESPACE_EXPORT(EXPORT_MACRO) + ... + \endcode + \sa Q_NAMESPACE, {Creating Shared Libraries} */ From 0c6b4dd4ad66d86d5a8dba998679ea53a563b685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 20 Apr 2020 16:11:29 +0200 Subject: [PATCH 2/5] macOS: Don't optimize out aggressive backingstore flushes when single-buffered Comparing the layer contents to the backingstore surface doesn't make sense when we're single buffered since we're always using the same surface. And once Core Animation has picked up on the surface it's not enough to just keep drawing to it, we also need to tell Core Animation that the contents has changed. Change-Id: I517a0b7a3ba7e9d96033465c9bd5a192985643ac Fixes: QTBUG-81071 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoabackingstore.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index 3b9df8da3a..ba5d42e706 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -537,8 +537,10 @@ void QCALayerBackingStore::flush(QWindow *flushedWindow, const QRegion ®ion, flushedView.layer.contentsScale = m_buffers.back()->devicePixelRatio(); } + const bool isSingleBuffered = window()->format().swapBehavior() == QSurfaceFormat::SingleBuffer; + id backBufferSurface = (__bridge id)m_buffers.back()->surface(); - if (flushedView.layer.contents == backBufferSurface) { + if (!isSingleBuffered && flushedView.layer.contents == backBufferSurface) { // We've managed to paint to the back buffer again before Core Animation had time // to flush the transaction and persist the layer changes to the window server, or // we've been asked to flush without painting anything. The layer already knows about @@ -555,7 +557,7 @@ void QCALayerBackingStore::flush(QWindow *flushedWindow, const QRegion ®ion, // with other pending view and layer updates. flushedView.window.viewsNeedDisplay = YES; - if (window()->format().swapBehavior() == QSurfaceFormat::SingleBuffer) { + if (isSingleBuffered) { // The private API [CALayer reloadValueForKeyPath:@"contents"] would be preferable, // but barring any side effects or performance issues we opt for the hammer for now. flushedView.layer.contents = nil; From 871e2981dde9836311bbc560f58805c4b0d61839 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Mon, 20 Apr 2020 14:42:02 +0200 Subject: [PATCH 3/5] QStringLiteral: Remove const temporary that may prevent optimization clang-tidy 10 was complaining about http://clang.llvm.org/extra/clang-tidy/checks/performance-no-automatic-move.html Change-Id: Iea5276e401a10f3ead8599e135dec1f0fa63a0dc Reviewed-by: Thiago Macieira --- src/corelib/text/qstringliteral.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/corelib/text/qstringliteral.h b/src/corelib/text/qstringliteral.h index 2a7e607c63..ab2a5f83f7 100644 --- a/src/corelib/text/qstringliteral.h +++ b/src/corelib/text/qstringliteral.h @@ -69,8 +69,7 @@ Q_STATIC_ASSERT_X(sizeof(qunicodechar) == 2, Q_STATIC_STRING_DATA_HEADER_INITIALIZER(Size), \ QT_UNICODE_LITERAL(str) }; \ QStringDataPtr holder = { qstring_literal.data_ptr() }; \ - const QString qstring_literal_temp(holder); \ - return qstring_literal_temp; \ + return QString(holder); \ }()) \ /**/ From 5c1446e3faf7684dfa559edc49611b92ea825776 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 26 Mar 2020 10:53:44 +0100 Subject: [PATCH 4/5] QImage: optimize convertWithPalette() The old code got a QMap serialized as a QString and parsed it to re-create the same map. Just copy the map. Change-Id: Ic71b9fa9d822eab53fe37dfb4d76223cd69ac057 Reviewed-by: Allan Sandfeld Jensen --- src/gui/image/qimage.cpp | 7 +------ src/gui/image/qimage.h | 1 + src/gui/image/qimage_p.h | 3 +++ 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 2646d298e9..499c527cfc 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -2149,12 +2149,7 @@ static QImage convertWithPalette(const QImage &src, QImage::Format format, QImage dest(src.size(), format); dest.setColorTable(clut); - QString textsKeys = src.text(); - const auto textKeyList = textsKeys.splitRef(QLatin1Char('\n'), Qt::SkipEmptyParts); - for (const auto &textKey : textKeyList) { - const auto textKeySplitted = textKey.split(QLatin1String(": ")); - dest.setText(textKeySplitted[0].toString(), textKeySplitted[1].toString()); - } + QImageData::get(dest)->text = QImageData::get(src)->text; int h = src.height(); int w = src.width(); diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index 56824e5ee7..b11aa9d9d0 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -385,6 +385,7 @@ private: friend class QRasterPlatformPixmap; friend class QBlittablePlatformPixmap; friend class QPixmapCacheEntry; + friend struct QImageData; public: typedef QImageData * DataPtr; diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h index 0930955f5a..03ec43eaf7 100644 --- a/src/gui/image/qimage_p.h +++ b/src/gui/image/qimage_p.h @@ -69,6 +69,9 @@ struct Q_GUI_EXPORT QImageData { // internal image data static QImageData *create(const QSize &size, QImage::Format format); static QImageData *create(uchar *data, int w, int h, int bpl, QImage::Format format, bool readOnly, QImageCleanupFunction cleanupFunction = nullptr, void *cleanupInfo = nullptr); + static QImageData *get(QImage &img) noexcept { return img.d; } + static const QImageData *get(const QImage &img) noexcept { return img.d; } + QAtomicInt ref; int width; From 89dc1a1865dd8ed277b88a53262b79a93c2ba8dc Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 25 Mar 2020 15:46:32 +0100 Subject: [PATCH 5/5] Make t specifier for time-zone only apply to date-time It previously applied to dates and date-times, but was documented as applying to times (and date-times then included it by reference). It's only meaningful for a date-time. Change-Id: Id9e8e8cb987b03e5ddc77b05c581b9b6944065fc Reviewed-by: Thiago Macieira --- src/corelib/time/qdatetime.cpp | 12 +++++++++--- src/corelib/time/qdatetimeparser.cpp | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 8553f79d90..c2b741f7ca 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -2533,7 +2533,6 @@ QT_WARNING_POP \row \li ap or a \li Interpret as an am/pm time. \e a/ap will match a lower-case version of either QLocale::amText() or QLocale::pmText(). - \row \li t \li the timezone (for example "CEST") \endtable All other input characters will be treated as text. Any non-empty sequence @@ -5478,8 +5477,15 @@ QT_WARNING_POP Uses the calendar \a cal if supplied, else Gregorian. - See QDate::fromString() and QTime::fromString() for the expressions - recognized in the format string to represent parts of the date and time. + In addition to the expressions, recognized in the format string to represent + parts of the date and time, by QDate::fromString() and QTime::fromString(), + this method supports: + + \table + \header \li Expression \li Output + \row \li t \li the timezone (for example "CEST") + \endtable + All other input characters will be treated as text. Any non-empty sequence of characters enclosed in single quotes will also be treated (stripped of the quotes) as text and not be interpreted as expressions. diff --git a/src/corelib/time/qdatetimeparser.cpp b/src/corelib/time/qdatetimeparser.cpp index 3374b28b69..bc3d9b992e 100644 --- a/src/corelib/time/qdatetimeparser.cpp +++ b/src/corelib/time/qdatetimeparser.cpp @@ -525,7 +525,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat) } break; case 't': - if (parserType != QMetaType::QTime) { + if (parserType == QMetaType::QDateTime) { const SectionNode sn = { TimeZoneSection, i - add, countRepeat(newFormat, i, 4), 0 }; newSectionNodes.append(sn); appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);