diff options
Diffstat (limited to 'src')
33 files changed, 201 insertions, 109 deletions
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index ebacd8a0c6..aa83cf2bcc 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -569,6 +569,23 @@ static QString getRelocatablePrefix() #error "The chosen platform / config does not support querying for a dynamic prefix." #endif +#if defined(Q_OS_LINUX) && !defined(QT_STATIC) && defined(__GLIBC__) + // QTBUG-78948: libQt5Core.so may be located in subdirectories below libdir. + // See "Hardware capabilities" in the ld.so documentation and the Qt 5.3.0 + // changelog regarding SSE2 support. + const QString libdir = QString::fromLatin1( + qt_configure_strs + qt_configure_str_offsets[QLibraryInfo::LibrariesPath - 1]); + QDir prefixDir(prefixPath); + while (!prefixDir.exists(libdir)) { + prefixDir.cdUp(); + prefixPath = prefixDir.absolutePath(); + if (prefixDir.isRoot()) { + prefixPath.clear(); + break; + } + } +#endif + Q_ASSERT_X(!prefixPath.isEmpty(), "getRelocatablePrefix", "Failed to find the Qt prefix path."); return prefixPath; diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp index f56fef7f8e..3b5f2f97da 100644 --- a/src/corelib/io/qstandardpaths.cpp +++ b/src/corelib/io/qstandardpaths.cpp @@ -232,7 +232,7 @@ QT_BEGIN_NAMESPACE \row \li DocumentsLocation \li "~/Documents" \row \li FontsLocation - \li "~/.fonts" + \li "~/.fonts", "~/.local/share/fonts", "/usr/local/share/fonts", "/usr/share/fonts" \row \li ApplicationsLocation \li "~/.local/share/applications", "/usr/local/share/applications", "/usr/share/applications" \row \li MusicLocation diff --git a/src/corelib/io/qstandardpaths_unix.cpp b/src/corelib/io/qstandardpaths_unix.cpp index 6425890e3f..c35d7adc9f 100644 --- a/src/corelib/io/qstandardpaths_unix.cpp +++ b/src/corelib/io/qstandardpaths_unix.cpp @@ -339,6 +339,9 @@ QStringList QStandardPaths::standardLocations(StandardLocation type) break; case FontsLocation: dirs += QDir::homePath() + QLatin1String("/.fonts"); + dirs += xdgDataDirs(); + for (int i = 1; i < dirs.count(); ++i) + dirs[i].append(QLatin1String("/fonts")); break; default: break; diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 6ed0efe77d..95a7255a04 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -3861,6 +3861,9 @@ int QDateTime::offsetFromUtc() const QString QDateTime::timeZoneAbbreviation() const { + if (!isValid()) + return QString(); + switch (getSpec(d)) { case Qt::UTC: return QLatin1String("UTC"); @@ -3895,6 +3898,9 @@ QString QDateTime::timeZoneAbbreviation() const bool QDateTime::isDaylightTime() const { + if (!isValid()) + return false; + switch (getSpec(d)) { case Qt::UTC: case Qt::OffsetFromUTC: @@ -4761,17 +4767,24 @@ QDateTime QDateTime::toTimeZone(const QTimeZone &timeZone) const Returns \c true if this datetime is equal to the \a other datetime; otherwise returns \c false. + Since 5.14, all invalid datetimes are equal to one another and differ from + all other datetimes. + \sa operator!=() */ bool QDateTime::operator==(const QDateTime &other) const { - if (getSpec(d) == Qt::LocalTime - && getStatus(d) == getStatus(other.d)) { + if (!isValid()) + return !other.isValid(); + if (!other.isValid()) + return false; + + if (getSpec(d) == Qt::LocalTime && getStatus(d) == getStatus(other.d)) return getMSecs(d) == getMSecs(other.d); - } + // Convert to UTC and compare - return (toMSecsSinceEpoch() == other.toMSecsSinceEpoch()); + return toMSecsSinceEpoch() == other.toMSecsSinceEpoch(); } /*! @@ -4780,8 +4793,9 @@ bool QDateTime::operator==(const QDateTime &other) const Returns \c true if this datetime is different from the \a other datetime; otherwise returns \c false. - Two datetimes are different if either the date, the time, or the - time zone components are different. + Two datetimes are different if either the date, the time, or the time zone + components are different. Since 5.14, any invalid datetime is less than all + valid datetimes. \sa operator==() */ @@ -4793,12 +4807,16 @@ bool QDateTime::operator==(const QDateTime &other) const bool QDateTime::operator<(const QDateTime &other) const { - if (getSpec(d) == Qt::LocalTime - && getStatus(d) == getStatus(other.d)) { + if (!isValid()) + return other.isValid(); + if (!other.isValid()) + return false; + + if (getSpec(d) == Qt::LocalTime && getStatus(d) == getStatus(other.d)) return getMSecs(d) < getMSecs(other.d); - } + // Convert to UTC and compare - return (toMSecsSinceEpoch() < other.toMSecsSinceEpoch()); + return toMSecsSinceEpoch() < other.toMSecsSinceEpoch(); } /*! @@ -5849,7 +5867,7 @@ uint qHash(const QDateTime &key, uint seed) // QDate/QTime/spec/offset because QDateTime::operator== converts both arguments // to the same timezone. If we don't, qHash would return different hashes for // two QDateTimes that are equivalent once converted to the same timezone. - return qHash(key.toMSecsSinceEpoch(), seed); + return key.isValid() ? qHash(key.toMSecsSinceEpoch(), seed) : seed; } /*! \fn uint qHash(const QDate &key, uint seed = 0) diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp index 2ae63fe135..52c8d13fe3 100644 --- a/src/corelib/tools/qeasingcurve.cpp +++ b/src/corelib/tools/qeasingcurve.cpp @@ -583,6 +583,13 @@ struct BezierEase : public QEasingCurveFunction qWarning("QEasingCurve: Invalid bezier curve"); return x; } + + // The bezier computation is not always precise on the endpoints, so handle explicitly + if (!(x > 0)) + return 0; + if (!(x < 1)) + return 1; + SingleCubicBezier *singleCubicBezier = 0; getBezierSegment(singleCubicBezier, x); @@ -998,6 +1005,11 @@ struct BackEase : public QEasingCurveFunction qreal value(qreal t) override { + // The *Back() functions are not always precise on the endpoints, so handle explicitly + if (!(t > 0)) + return 0; + if (!(t < 1)) + return 1; qreal o = (_o < 0) ? qreal(1.70158) : _o; switch(_t) { case QEasingCurve::InBack: diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index 58b5af3615..d6f3230fd2 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -871,8 +871,12 @@ bool QDBusConnection::disconnect(const QString &service, const QString &path, co This function does not replace existing objects: if there is already an object registered at path \a path, this function will return false. Use unregisterObject() to unregister it first. + The ExportChildObjects flag exports child objects on D-Bus based on the + path of the registered objects and the QObject::objectName of the child. + Therefore, it is important for the child object to have an object name. + You cannot register an object as a child object of an object that - was registered with QDBusConnection::ExportChildObjects. + was registered with ExportChildObjects. */ bool QDBusConnection::registerObject(const QString &path, QObject *object, RegisterOptions options) { @@ -891,8 +895,12 @@ bool QDBusConnection::registerObject(const QString &path, QObject *object, Regis This function does not replace existing objects: if there is already an object registered at path \a path, this function will return false. Use unregisterObject() to unregister it first. + The ExportChildObjects flag exports child objects on D-Bus based on the + path of the registered objects and the QObject::objectName of the child. + Therefore, it is important for the child object to have an object name. + You cannot register an object as a child object of an object that - was registered with QDBusConnection::ExportChildObjects. + was registered with ExportChildObjects. */ bool QDBusConnection::registerObject(const QString &path, const QString &interface, QObject *object, RegisterOptions options) { diff --git a/src/gui/image/qmovie.cpp b/src/gui/image/qmovie.cpp index 3e975115ab..25fce050a1 100644 --- a/src/gui/image/qmovie.cpp +++ b/src/gui/image/qmovie.cpp @@ -414,7 +414,7 @@ QFrameInfo QMoviePrivate::infoForFrame(int frameNumber) } else { // We've read all frames now. Return an end marker haveReadAll = true; - return QFrameInfo::endMarker(); + return frameNumber == greatestFrameNumber + 1 ? QFrameInfo::endMarker() : QFrameInfo(); } } } diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 03be72ca30..5f61853a6d 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -617,6 +617,7 @@ bool QWindowSystemInterface::isTouchDeviceRegistered(const QTouchDevice *device) static int g_nextPointId = 1; // map from device-independent point id (arbitrary) to "Qt point" ids +QMutex QWindowSystemInterfacePrivate::pointIdMapMutex; typedef QMap<quint64, int> PointIdMap; Q_GLOBAL_STATIC(PointIdMap, g_pointIdMap) @@ -634,6 +635,8 @@ Q_GLOBAL_STATIC(PointIdMap, g_pointIdMap) */ static int acquireCombinedPointId(quint8 deviceId, int pointId) { + QMutexLocker locker(&QWindowSystemInterfacePrivate::pointIdMapMutex); + quint64 combinedId64 = (quint64(deviceId) << 32) + pointId; auto it = g_pointIdMap->constFind(combinedId64); int uid; @@ -693,6 +696,8 @@ QList<QTouchEvent::TouchPoint> } if (states == Qt::TouchPointReleased) { + QMutexLocker locker(&QWindowSystemInterfacePrivate::pointIdMapMutex); + // All points on deviceId have been released. // Remove all points associated with that device from g_pointIdMap. // (On other devices, some touchpoints might still be pressed. @@ -712,6 +717,7 @@ QList<QTouchEvent::TouchPoint> void QWindowSystemInterfacePrivate::clearPointIdMap() { + QMutexLocker locker(&QWindowSystemInterfacePrivate::pointIdMapMutex); g_pointIdMap->clear(); g_nextPointId = 1; } diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h index 540170f733..55fd181ef0 100644 --- a/src/gui/kernel/qwindowsysteminterface_p.h +++ b/src/gui/kernel/qwindowsysteminterface_p.h @@ -528,6 +528,7 @@ public: static QWaitCondition eventsFlushed; static QMutex flushEventMutex; + static QMutex pointIdMapMutex; static QAtomicInt eventAccepted; static QList<QTouchEvent::TouchPoint> diff --git a/src/gui/text/qabstracttextdocumentlayout.cpp b/src/gui/text/qabstracttextdocumentlayout.cpp index 5263ece87c..8b8f3e28ac 100644 --- a/src/gui/text/qabstracttextdocumentlayout.cpp +++ b/src/gui/text/qabstracttextdocumentlayout.cpp @@ -660,7 +660,7 @@ QTextBlock QAbstractTextDocumentLayout::blockWithMarkerAt(const QPointF &pos) co { QTextBlock block = document()->firstBlock(); while (block.isValid()) { - if (block.blockFormat().marker() != QTextBlockFormat::NoMarker) { + if (block.blockFormat().marker() != QTextBlockFormat::MarkerType::NoMarker) { QRectF blockBr = blockBoundingRect(block); QTextBlockFormat blockFmt = block.blockFormat(); QFontMetrics fm(block.charFormat().font()); diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index 1d5afee16b..7be114adf9 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -2194,11 +2194,11 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p QBrush brush = context.palette.brush(QPalette::Text); - bool marker = bl.blockFormat().marker() != QTextBlockFormat::NoMarker; + bool marker = bl.blockFormat().marker() != QTextBlockFormat::MarkerType::NoMarker; if (marker) { int adj = fontMetrics.lineSpacing() / 6; r.adjust(-adj, 0, -adj, 0); - if (bl.blockFormat().marker() == QTextBlockFormat::Checked) { + if (bl.blockFormat().marker() == QTextBlockFormat::MarkerType::Checked) { // ### Qt6: render with QStyle / PE_IndicatorCheckBox. We don't currently // have access to that here, because it would be a widget dependency. painter->setPen(QPen(painter->pen().color(), 2)); diff --git a/src/gui/text/qtextformat.h b/src/gui/text/qtextformat.h index 12f14a1555..28da0fe344 100644 --- a/src/gui/text/qtextformat.h +++ b/src/gui/text/qtextformat.h @@ -627,7 +627,7 @@ public: LineDistanceHeight = 4 }; - enum MarkerType { + enum class MarkerType { NoMarker = 0, Unchecked = 1, Checked = 2 diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp index b96263f5fc..fe7e422923 100644 --- a/src/gui/text/qtextmarkdownimporter.cpp +++ b/src/gui/text/qtextmarkdownimporter.cpp @@ -190,8 +190,8 @@ int QTextMarkdownImporter::cbEnterBlock(int blockType, void *det) m_listItem = true; MD_BLOCK_LI_DETAIL *detail = static_cast<MD_BLOCK_LI_DETAIL *>(det); m_markerType = detail->is_task ? - (detail->task_mark == ' ' ? QTextBlockFormat::Unchecked : QTextBlockFormat::Checked) : - QTextBlockFormat::NoMarker; + (detail->task_mark == ' ' ? QTextBlockFormat::MarkerType::Unchecked : QTextBlockFormat::MarkerType::Checked) : + QTextBlockFormat::MarkerType::NoMarker; qCDebug(lcMD) << "LI"; } break; case MD_BLOCK_UL: { @@ -549,7 +549,7 @@ void QTextMarkdownImporter::insertBlock() blockFormat.setTopMargin(m_paragraphMargin); blockFormat.setBottomMargin(m_paragraphMargin); } - if (m_markerType == QTextBlockFormat::NoMarker) + if (m_markerType == QTextBlockFormat::MarkerType::NoMarker) blockFormat.clearProperty(QTextFormat::BlockMarker); else blockFormat.setMarker(m_markerType); diff --git a/src/gui/text/qtextmarkdownimporter_p.h b/src/gui/text/qtextmarkdownimporter_p.h index 1b8c2ca354..35655aff8a 100644 --- a/src/gui/text/qtextmarkdownimporter_p.h +++ b/src/gui/text/qtextmarkdownimporter_p.h @@ -128,7 +128,7 @@ private: Features m_features; QTextImageFormat m_imageFormat; QTextListFormat m_listFormat; - QTextBlockFormat::MarkerType m_markerType = QTextBlockFormat::NoMarker; + QTextBlockFormat::MarkerType m_markerType = QTextBlockFormat::MarkerType::NoMarker; bool m_needsInsertBlock = false; bool m_needsInsertList = false; bool m_listItem = false; // true from the beginning of LI to the end of the first P diff --git a/src/gui/text/qtextmarkdownwriter.cpp b/src/gui/text/qtextmarkdownwriter.cpp index cbfb092485..764c64aead 100644 --- a/src/gui/text/qtextmarkdownwriter.cpp +++ b/src/gui/text/qtextmarkdownwriter.cpp @@ -327,10 +327,10 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign break; } switch (blockFmt.marker()) { - case QTextBlockFormat::Checked: + case QTextBlockFormat::MarkerType::Checked: bullet += " [x]"; break; - case QTextBlockFormat::Unchecked: + case QTextBlockFormat::MarkerType::Unchecked: bullet += " [ ]"; break; default: diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp index 3561c185a6..0e8666565f 100644 --- a/src/gui/text/qtextodfwriter.cpp +++ b/src/gui/text/qtextodfwriter.cpp @@ -358,7 +358,7 @@ void QTextOdfWriter::writeBlock(QXmlStreamWriter &writer, const QTextBlock &bloc int precedingSpaces = 0; int exportedIndex = 0; for (int i=0; i <= fragmentText.count(); ++i) { - QChar character = fragmentText[i]; + QChar character = (i == fragmentText.count() ? QChar() : fragmentText.at(i)); bool isSpace = character.unicode() == ' '; // find more than one space. -> <text:s text:c="2" /> diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp index b280f27fac..bf2df93d11 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp +++ b/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp @@ -98,8 +98,8 @@ void QEvdevTouchManager::addDevice(const QString &deviceNode) qCDebug(qLcEvdevTouch, "evdevtouch: Adding device at %ls", qUtf16Printable(deviceNode)); auto handler = qt_make_unique<QEvdevTouchScreenHandlerThread>(deviceNode, m_spec); if (handler) { - m_activeDevices.add(deviceNode, std::move(handler)); connect(handler.get(), &QEvdevTouchScreenHandlerThread::touchDeviceRegistered, this, &QEvdevTouchManager::updateInputDeviceCount); + m_activeDevices.add(deviceNode, std::move(handler)); } else { qWarning("evdevtouch: Failed to open touch device %ls", qUtf16Printable(deviceNode)); } diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm index 2cf6672da9..2df85c791b 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm @@ -171,12 +171,8 @@ QT_USE_NAMESPACE // This function will only be called when NSApp is actually running. - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { - // The reflection delegate gets precedence - if (reflectionDelegate) { - if ([reflectionDelegate respondsToSelector:@selector(applicationShouldTerminate:)]) - return [reflectionDelegate applicationShouldTerminate:sender]; - return NSTerminateNow; - } + if ([reflectionDelegate respondsToSelector:_cmd]) + return [reflectionDelegate applicationShouldTerminate:sender]; if ([self canQuit]) { if (!startedQuit) { @@ -228,10 +224,6 @@ QT_USE_NAMESPACE */ NSAppleEventManager *eventManager = [NSAppleEventManager sharedAppleEventManager]; [eventManager setEventHandler:self - andSelector:@selector(appleEventQuit:withReplyEvent:) - forEventClass:kCoreEventClass - andEventID:kAEQuitApplication]; - [eventManager setEventHandler:self andSelector:@selector(getUrl:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL]; @@ -241,7 +233,6 @@ QT_USE_NAMESPACE - (void)removeAppleEventHandlers { NSAppleEventManager *eventManager = [NSAppleEventManager sharedAppleEventManager]; - [eventManager removeEventHandlerForEventClass:kCoreEventClass andEventID:kAEQuitApplication]; [eventManager removeEventHandlerForEventClass:kInternetEventClass andEventID:kAEGetURL]; } @@ -282,26 +273,22 @@ QT_USE_NAMESPACE QWindowSystemInterface::handleFileOpenEvent(qtFileName); } - if (reflectionDelegate && - [reflectionDelegate respondsToSelector:@selector(application:openFiles:)]) + if ([reflectionDelegate respondsToSelector:_cmd]) [reflectionDelegate application:sender openFiles:filenames]; } - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender { - // If we have a reflection delegate, that will get to call the shots. - if (reflectionDelegate - && [reflectionDelegate respondsToSelector: - @selector(applicationShouldTerminateAfterLastWindowClosed:)]) + if ([reflectionDelegate respondsToSelector:_cmd]) return [reflectionDelegate applicationShouldTerminateAfterLastWindowClosed:sender]; + return NO; // Someday qApp->quitOnLastWindowClosed(); when QApp and NSApp work closer together. } - (void)applicationDidBecomeActive:(NSNotification *)notification { - if (reflectionDelegate - && [reflectionDelegate respondsToSelector:@selector(applicationDidBecomeActive:)]) + if ([reflectionDelegate respondsToSelector:_cmd]) [reflectionDelegate applicationDidBecomeActive:notification]; QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationActive); @@ -309,8 +296,7 @@ QT_USE_NAMESPACE - (void)applicationDidResignActive:(NSNotification *)notification { - if (reflectionDelegate - && [reflectionDelegate respondsToSelector:@selector(applicationDidResignActive:)]) + if ([reflectionDelegate respondsToSelector:_cmd]) [reflectionDelegate applicationDidResignActive:notification]; QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationInactive); @@ -318,10 +304,7 @@ QT_USE_NAMESPACE - (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag { - Q_UNUSED(theApplication); - Q_UNUSED(flag); - if (reflectionDelegate - && [reflectionDelegate respondsToSelector:@selector(applicationShouldHandleReopen:hasVisibleWindows:)]) + if ([reflectionDelegate respondsToSelector:_cmd]) return [reflectionDelegate applicationShouldHandleReopen:theApplication hasVisibleWindows:flag]; /* @@ -354,16 +337,13 @@ QT_USE_NAMESPACE - (BOOL)respondsToSelector:(SEL)aSelector { - BOOL result = [super respondsToSelector:aSelector]; - if (!result && reflectionDelegate) - result = [reflectionDelegate respondsToSelector:aSelector]; - return result; + return [super respondsToSelector:aSelector] || [reflectionDelegate respondsToSelector:aSelector]; } - (void)forwardInvocation:(NSInvocation *)invocation { SEL invocationSelector = [invocation selector]; - if (reflectionDelegate && [reflectionDelegate respondsToSelector:invocationSelector]) + if ([reflectionDelegate respondsToSelector:invocationSelector]) [invocation invokeWithTarget:reflectionDelegate]; else [self doesNotRecognizeSelector:invocationSelector]; @@ -375,14 +355,6 @@ QT_USE_NAMESPACE NSString *urlString = [[event paramDescriptorForKeyword:keyDirectObject] stringValue]; QWindowSystemInterface::handleFileOpenEvent(QUrl(QString::fromNSString(urlString))); } - -- (void)appleEventQuit:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent -{ - Q_UNUSED(event); - Q_UNUSED(replyEvent); - [NSApp terminate:self]; -} - @end @implementation QCocoaApplicationDelegate (Menus) diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index eb316c53a8..b17302a640 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -560,17 +560,26 @@ void QCALayerBackingStore::flush(QWindow *flushedWindow, const QRegion ®ion, flushedView.layer.contents = nil; } - qCInfo(lcQpaBackingStore) << "Flushing" << backBufferSurface - << "to" << flushedView.layer << "of" << flushedView; - - flushedView.layer.contents = backBufferSurface; + if (flushedView == backingStoreView) { + qCInfo(lcQpaBackingStore) << "Flushing" << backBufferSurface + << "to" << flushedView.layer << "of" << flushedView; + flushedView.layer.contents = backBufferSurface; + } else { + auto subviewRect = [flushedView convertRect:flushedView.bounds toView:backingStoreView]; + auto scale = flushedView.layer.contentsScale; + subviewRect = CGRectApplyAffineTransform(subviewRect, CGAffineTransformMakeScale(scale, scale)); + + // We make a copy of the image data up front, which means we don't + // need to mark the IOSurface as being in use. FIXME: Investigate + // if there's a cheaper way to get sub-image data to a layer. + m_buffers.back()->lock(QPlatformGraphicsBuffer::SWReadAccess); + QImage subImage = m_buffers.back()->asImage()->copy(QRectF::fromCGRect(subviewRect).toRect()); + m_buffers.back()->unlock(); - if (flushedView != backingStoreView) { - const CGSize backingStoreSize = backingStoreView.bounds.size; - flushedView.layer.contentsRect = CGRectApplyAffineTransform( - [flushedView convertRect:flushedView.bounds toView:backingStoreView], - // The contentsRect is in unit coordinate system - CGAffineTransformMakeScale(1.0 / backingStoreSize.width, 1.0 / backingStoreSize.height)); + qCInfo(lcQpaBackingStore) << "Flushing" << subImage + << "to" << flushedView.layer << "of subview" << flushedView; + QCFType<CGImageRef> cgImage = subImage.toCGImage(); + flushedView.layer.contents = (__bridge id)static_cast<CGImageRef>(cgImage); } // Since we may receive multiple flushes before a new frame is started, we do not diff --git a/src/plugins/platforms/windows/openglblacklists/default.json b/src/plugins/platforms/windows/openglblacklists/default.json index 3cfa7e3856..e37351f9e0 100644 --- a/src/plugins/platforms/windows/openglblacklists/default.json +++ b/src/plugins/platforms/windows/openglblacklists/default.json @@ -152,6 +152,18 @@ "features": [ "disable_program_cache" ] - } + }, + { + "id": 13, + "description": "Disable DesktopGL on Windows with Mobile Intel(R) 4 Series Express Chipset Family graphics card (QTBUG-58772)", + "vendor_id": "0x8086", + "device_id": [ "0x2A42" ], + "os": { + "type": "win" + }, + "features": [ + "disable_desktopgl" + ] + } ] } diff --git a/src/plugins/platforms/windows/qwindowsclipboard.cpp b/src/plugins/platforms/windows/qwindowsclipboard.cpp index b87e43f3f7..4e6d3306e1 100644 --- a/src/plugins/platforms/windows/qwindowsclipboard.cpp +++ b/src/plugins/platforms/windows/qwindowsclipboard.cpp @@ -115,12 +115,21 @@ static QDebug operator<<(QDebug d, const QMimeData *mimeData) IDataObject *QWindowsClipboardRetrievalMimeData::retrieveDataObject() const { + enum : int { attempts = 3 }; IDataObject * pDataObj = nullptr; - if (OleGetClipboard(&pDataObj) == S_OK) { - if (QWindowsContext::verbose > 1) - qCDebug(lcQpaMime) << __FUNCTION__ << pDataObj; - return pDataObj; + // QTBUG-53979, retry in case the other application has clipboard locked + for (int i = 1; i <= attempts; ++i) { + if (SUCCEEDED(OleGetClipboard(&pDataObj))) { + if (QWindowsContext::verbose > 1) + qCDebug(lcQpaMime) << __FUNCTION__ << pDataObj; + return pDataObj; + } + qCWarning(lcQpaMime, i == attempts + ? "Unable to obtain clipboard." + : "Retrying to obtain clipboard."); + QThread::msleep(50); } + return nullptr; } diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 0fe22bd318..8da299d491 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -773,7 +773,7 @@ void QXcbScreen::updateRefreshRate(xcb_randr_mode_t mode) xcb_randr_mode_info_t *modeInfo = modesIter.data; if (modeInfo->id == mode) { const uint32_t dotCount = modeInfo->htotal * modeInfo->vtotal; - m_refreshRate = (dotCount != 0) ? modeInfo->dot_clock / dotCount : 0; + m_refreshRate = (dotCount != 0) ? modeInfo->dot_clock / qreal(dotCount) : 0; m_mode = mode; break; } diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h index 62931d2500..79698b4ef3 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.h +++ b/src/plugins/platforms/xcb/qxcbscreen.h @@ -226,7 +226,7 @@ private: QRect m_availableGeometry; Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation; QXcbCursor *m_cursor; - int m_refreshRate = 60; + qreal m_refreshRate = 60.0; QEdidParser m_edid; }; diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 0a216e540d..63dc49fd18 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -328,6 +328,20 @@ static const int closeButtonSize = 14; static const qreal closeButtonCornerRadius = 2.0; #endif // QT_CONFIG(tabbar) +#ifndef QT_NO_ACCESSIBILITY // This ifdef to avoid "unused function" warning. +QBrush brushForToolButton(bool isOnKeyWindow) +{ + // When a toolbutton in a toolbar is in the 'ON' state, we draw a + // partially transparent background. The colors must be different + // for 'Aqua' and 'DarkAqua' appearances though. + if (isDarkMode()) + return isOnKeyWindow ? QColor(73, 73, 73, 100) : QColor(56, 56, 56, 100); + + return isOnKeyWindow ? QColor(0, 0, 0, 28) : QColor(0, 0, 0, 21); +} +#endif // QT_NO_ACCESSIBILITY + + static const int headerSectionArrowHeight = 6; static const int headerSectionSeparatorInset = 2; @@ -5603,8 +5617,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex if (view) isKey = [view.window isKeyWindow]; - QBrush brush(isKey ? QColor(0, 0, 0, 28) - : QColor(0, 0, 0, 21)); + QBrush brush(brushForToolButton(isKey)); QPainterPath path; path.addRoundedRect(QRectF(tb->rect.x(), tb->rect.y(), tb->rect.width(), tb->rect.height() + 4), 4, 4); p->setRenderHint(QPainter::Antialiasing); diff --git a/src/src.pro b/src/src.pro index 832a3b6d82..8ff3ec4c1f 100644 --- a/src/src.pro +++ b/src/src.pro @@ -70,7 +70,7 @@ src_winmain.depends = sub-corelib # just for the module .pri file src_corelib.subdir = $$PWD/corelib src_corelib.target = sub-corelib -src_corelib.depends = src_tools_moc src_tools_rcc +src_corelib.depends = src_tools_moc src_tools_rcc src_tools_tracegen src_xml.subdir = $$PWD/xml src_xml.target = sub-xml @@ -157,17 +157,12 @@ src_android.subdir = $$PWD/android src_3rdparty_freetype.depends += src_corelib } } -SUBDIRS += src_tools_bootstrap src_tools_moc src_tools_rcc +SUBDIRS += src_tools_bootstrap src_tools_moc src_tools_rcc src_tools_tracegen qtConfig(regularexpression):pcre2 { SUBDIRS += src_3rdparty_pcre2 src_corelib.depends += src_3rdparty_pcre2 } -TOOLS = src_tools_moc src_tools_rcc src_tools_qlalr -!force_bootstrap:if(qtConfig(lttng)|qtConfig(etw)) { - SUBDIRS += src_tools_tracegen - src_corelib.depends += src_tools_tracegen - TOOLS += src_tools_tracegen -} +TOOLS = src_tools_moc src_tools_rcc src_tools_tracegen src_tools_qlalr SUBDIRS += src_corelib src_tools_qlalr win32:SUBDIRS += src_winmain qtConfig(network) { diff --git a/src/tools/tracegen/provider.h b/src/tools/tracegen/provider.h index 9be0c33d89..a4baf56815 100644 --- a/src/tools/tracegen/provider.h +++ b/src/tools/tracegen/provider.h @@ -42,6 +42,7 @@ #include <qvector.h> #include <qstring.h> +#include <qstringlist.h> #include <qtypeinfo.h> struct Tracepoint diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index 451b18d8d3..bc5ca21b97 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -788,10 +788,12 @@ void QOpenGLWidgetPrivate::initialize() if (initialized) return; - // Get our toplevel's context with which we will share in order to make the - // texture usable by the underlying window's backingstore. + // If no global shared context get our toplevel's context with which we + // will share in order to make the texture usable by the underlying window's backingstore. QWidget *tlw = q->window(); - QOpenGLContext *shareContext = get(tlw)->shareContext(); + QOpenGLContext *shareContext = qt_gl_global_share_context(); + if (!shareContext) + shareContext = get(tlw)->shareContext(); // If shareContext is null, showing content on-screen will not work. // However, offscreen rendering and grabFramebuffer() will stay fully functional. diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index b70a03b311..588bed0366 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -7669,7 +7669,7 @@ void QWidget::show() else if (defaultState == Qt::WindowMaximized) showMaximized(); else - setVisible(true); // FIXME: Why not showNormal(), like QWindow::show()? + setVisible(true); // Don't call showNormal() as not to clobber Qt::Window(Max/Min)imized } /*! \internal diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index ba2b6b0ed9..b58dc1660a 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -88,6 +88,7 @@ #include <private/qstylehelper_p.h> #include <private/qdrawhelper_p.h> #include <private/qapplication_p.h> +#include <private/qwidget_p.h> QT_BEGIN_NAMESPACE @@ -364,6 +365,11 @@ static void qt_fusion_draw_mdibutton(QPainter *painter, const QStyleOptionTitleB painter->drawPoint(tmp.right() , tmp.bottom() - 1); } +static QWindow *qt_getWindow(const QWidget *widget) +{ + return widget ? QWidgetPrivate::get(widget)->windowHandle(QWidgetPrivate::WindowHandleMode::Closest) : nullptr; +} + /* \internal */ @@ -995,7 +1001,7 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem, d->tabBarcloseButtonIcon = proxy()->standardIcon(SP_DialogCloseButton, option, widget); if ((option->state & State_Enabled) && (option->state & State_MouseOver)) proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget); - QPixmap pixmap = d->tabBarcloseButtonIcon.pixmap(QSize(16, 16), QIcon::Normal, QIcon::On); + QPixmap pixmap = d->tabBarcloseButtonIcon.pixmap(qt_getWindow(widget), QSize(16, 16), QIcon::Normal, QIcon::On); proxy()->drawItemPixmap(painter, option->rect, Qt::AlignCenter, pixmap); } break; @@ -1035,7 +1041,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio if (!cb->currentIcon.isNull()) { QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal : QIcon::Disabled; - QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode); + QPixmap pixmap = cb->currentIcon.pixmap(qt_getWindow(widget), cb->iconSize, mode); QRect iconRect(editRect); iconRect.setWidth(cb->iconSize.width() + 4); iconRect = alignedRect(cb->direction, @@ -1647,9 +1653,9 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio iconSize = combo->iconSize(); #endif if (checked) - pixmap = menuItem->icon.pixmap(iconSize, mode, QIcon::On); + pixmap = menuItem->icon.pixmap(qt_getWindow(widget), iconSize, mode, QIcon::On); else - pixmap = menuItem->icon.pixmap(iconSize, mode); + pixmap = menuItem->icon.pixmap(qt_getWindow(widget), iconSize, mode); const int pixw = pixmap.width() / pixmap.devicePixelRatio(); const int pixh = pixmap.height() / pixmap.devicePixelRatio(); @@ -1783,7 +1789,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio if (button->state & State_On) state = QIcon::On; - QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state); + QPixmap pixmap = button->icon.pixmap(qt_getWindow(widget), button->iconSize, mode, state); int w = pixmap.width() / pixmap.devicePixelRatio(); int h = pixmap.height() / pixmap.devicePixelRatio(); diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp index b295e66574..d2372a7be9 100644 --- a/src/widgets/widgets/qabstractscrollarea.cpp +++ b/src/widgets/widgets/qabstractscrollarea.cpp @@ -1144,11 +1144,14 @@ void QAbstractScrollArea::paintEvent(QPaintEvent*) mouse press events for the viewport() widget. The event is passed in \a e. + The default implementation calls QWidget::mousePressEvent() for + default popup handling. + \sa QWidget::mousePressEvent() */ void QAbstractScrollArea::mousePressEvent(QMouseEvent *e) { - e->ignore(); + QWidget::mousePressEvent(e); } /*! diff --git a/src/widgets/widgets/qgroupbox.cpp b/src/widgets/widgets/qgroupbox.cpp index 69eac1ebf7..eec794562a 100644 --- a/src/widgets/widgets/qgroupbox.cpp +++ b/src/widgets/widgets/qgroupbox.cpp @@ -389,9 +389,13 @@ bool QGroupBox::event(QEvent *e) void QGroupBox::childEvent(QChildEvent *c) { Q_D(QGroupBox); - if (c->type() != QEvent::ChildAdded || !c->child()->isWidgetType()) + /* + Children might have been enabled after being added to the group box, in which case + the childEvent handler ran too early, and we need to disabled children again. + */ + if (!(c->added() || c->polished()) || !c->child()->isWidgetType()) return; - QWidget *w = (QWidget*)c->child(); + QWidget *w = static_cast<QWidget*>(c->child()); if (w->isWindow()) return; if (d->checkable) { diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index 0ccbad7eaa..dd2ea3f18f 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -237,7 +237,7 @@ void QTextEditPrivate::_q_hoveredBlockWithMarkerChanged(const QTextBlock &block) Qt::CursorShape cursor = cursorToRestoreAfterHover; if (block.isValid() && !q->isReadOnly()) { QTextBlockFormat::MarkerType marker = block.blockFormat().marker(); - if (marker != QTextBlockFormat::NoMarker) { + if (marker != QTextBlockFormat::MarkerType::NoMarker) { if (viewport->cursor().shape() != Qt::PointingHandCursor) cursorToRestoreAfterHover = viewport->cursor().shape(); cursor = Qt::PointingHandCursor; @@ -772,6 +772,7 @@ void QTextEdit::setAlignment(Qt::Alignment a) QTextCursor cursor = d->control->textCursor(); cursor.mergeBlockFormat(fmt); d->control->setTextCursor(cursor); + d->relayoutDocument(); } /*! diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index fdbaf29dd8..094c59a0c9 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -1810,11 +1810,11 @@ void QWidgetTextControlPrivate::mouseReleaseEvent(QEvent *e, Qt::MouseButton but if (markerBlock == blockWithMarkerUnderMouse) { auto fmt = blockWithMarkerUnderMouse.blockFormat(); switch (fmt.marker()) { - case QTextBlockFormat::Unchecked : - fmt.setMarker(QTextBlockFormat::Checked); + case QTextBlockFormat::MarkerType::Unchecked : + fmt.setMarker(QTextBlockFormat::MarkerType::Checked); break; - case QTextBlockFormat::Checked: - fmt.setMarker(QTextBlockFormat::Unchecked); + case QTextBlockFormat::MarkerType::Checked: + fmt.setMarker(QTextBlockFormat::MarkerType::Unchecked); break; default: break; |