From f71048a5314c93732a8a77460b465709b632ff5e Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 22 Aug 2018 13:02:04 +0200 Subject: Fix crash when combining QOpenGLWidget, QStaticText and Qt Quick Under certain circumstances, if you had a widget with a QOpenGLPaintEngine, and drew QStaticText into this, and then later had Qt Quick access the same cache and try to resize it, we would get a crash because the resize function would have a pointer to the paint engine and try to access its shader manager (which would now be null, since this is outside the begin()/end() phase of the paint engine. The solution is to reset the paint engine pointer to null on the cache once it has been populated and it is no longer needed. [ChangeLog][QtGui][Text] Fixed a possible crash when combining QStaticText, QOpenGLWidget and Qt Quick in the same application. Task-number: QTBUG-70096 Change-Id: I7383ad7456d1a72499cfcd2da09a5a808d4b3eff Reviewed-by: Simon Hausmann --- src/gui/opengl/qopenglpaintengine.cpp | 1 + src/gui/opengl/qopengltextureglyphcache_p.h | 5 +++++ 2 files changed, 6 insertions(+) (limited to 'src') diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp index 3d1c362275..6a89089f18 100644 --- a/src/gui/opengl/qopenglpaintengine.cpp +++ b/src/gui/opengl/qopenglpaintengine.cpp @@ -1741,6 +1741,7 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngine::GlyphFormat gly // we may have to re-bind brush textures after filling in the cache. brushTextureDirty = (QT_BRUSH_TEXTURE_UNIT == glypchCacheTextureUnit); } + cache->setPaintEnginePrivate(nullptr); } if (cache->width() == 0 || cache->height() == 0) diff --git a/src/gui/opengl/qopengltextureglyphcache_p.h b/src/gui/opengl/qopengltextureglyphcache_p.h index 0b7b5f6082..598cb00ee5 100644 --- a/src/gui/opengl/qopengltextureglyphcache_p.h +++ b/src/gui/opengl/qopengltextureglyphcache_p.h @@ -152,6 +152,11 @@ public: void clear(); + QOpenGL2PaintEngineExPrivate *paintEnginePrivate() const + { + return pex; + } + private: void setupVertexAttribs(); -- cgit v1.2.3 From 9652711a0781a652fbf2319b0c59121c381bf016 Mon Sep 17 00:00:00 2001 From: Paul Wicking Date: Mon, 27 Aug 2018 14:11:39 +0200 Subject: Doc: Remove non-reentrant from QDomDocument::setContent Following QTBUG-40015, QDomDocument::setContent is reentrant. This change updates the documentation accordingly. Fixes: QTBUG-69920 Change-Id: Id09e3541156f52d1a976afd02b410c263d3b3352 Reviewed-by: David Faure --- src/xml/dom/qdom.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index 17f87804e9..91796106a2 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -6666,8 +6666,6 @@ bool QDomDocument::setContent(const QString& text, bool namespaceProcessing, QSt } /*! - \nonreentrant - This function parses the XML document from the byte array \a data and sets it as the content of the document. It tries to detect the encoding of the document as required by the XML -- cgit v1.2.3 From ac5e617596625504f4bd5d8bdb8cabb51b575a87 Mon Sep 17 00:00:00 2001 From: Paul Wicking Date: Mon, 27 Aug 2018 13:03:26 +0200 Subject: Doc: Fix typos in QRectF documentation Add missing 's'. Fixes: QTWEBSITE-823 Change-Id: I1acd3b7ae18982248bf3402fa5943ee95c1efdbe Reviewed-by: Venugopal Shivashankar --- src/corelib/tools/qrect.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qrect.cpp b/src/corelib/tools/qrect.cpp index 40d6c8b7c3..ad1885e8ce 100644 --- a/src/corelib/tools/qrect.cpp +++ b/src/corelib/tools/qrect.cpp @@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE The QRect class provides a collection of functions that return the various rectangle coordinates, and enable manipulation of - these. QRect also provide functions to move the rectangle relative + these. QRect also provides functions to move the rectangle relative to the various coordinates. In addition there is a moveTo() function that moves the rectangle, leaving its top left corner at the given coordinates. Alternatively, the translate() function @@ -155,7 +155,7 @@ QT_BEGIN_NAMESPACE The QRect class provides a collection of functions that return the various rectangle coordinates, and enable manipulation of - these. QRect also provide functions to move the rectangle relative + these. QRect also provides functions to move the rectangle relative to the various coordinates. For example the left(), setLeft() and moveLeft() functions as an @@ -1335,7 +1335,7 @@ QDebug operator<<(QDebug dbg, const QRect &r) The QRectF class provides a collection of functions that return the various rectangle coordinates, and enable manipulation of - these. QRectF also provide functions to move the rectangle + these. QRectF also provides functions to move the rectangle relative to the various coordinates. In addition there is a moveTo() function that moves the rectangle, leaving its top left corner at the given coordinates. Alternatively, the translate() @@ -1418,7 +1418,7 @@ QDebug operator<<(QDebug dbg, const QRect &r) The QRectF class provides a collection of functions that return the various rectangle coordinates, and enable manipulation of - these. QRectF also provide functions to move the rectangle + these. QRectF also provides functions to move the rectangle relative to the various coordinates. For example: the bottom(), setBottom() and moveBottom() functions: -- cgit v1.2.3 From 2ef53620115037015d44d9629ee1e12da44be715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 18 Jul 2018 23:51:58 +0200 Subject: QMacStyle: Make helper-NSViews layer-backed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This prevents the view from triggering display of its superview when being temporarily added, which is both inefficient and causes issues when those dirty-rects are wrong due to the wrong frame position of the added view. The additional drawRect: calls and corresponding expose events resulting from the needsDisplay calls also caused repaint issues in Qt Widgets. QWidgetBackingStore doesn't seem to take the exposed region into account for an expose event, and will try to flush all dirty regions. Some of those may be outside the exposed region, and will be clipped away by the window system, never ending up on the screen, but with Widgets still thinking it has flushed all dirty regions. This is a separate issue, possibly solvable by setting the wantsDefaultClipping property on NSView to NO, but this needs further testing, so applying this commit as workaround makes sense, even if it's just hiding the real bug. Task-number: QTBUG-67998 Task-number: QTBUG-68023 Task-number: QTBUG-69990 Task-number: QTBUG-69740 Task-number: QTBUG-69292 Task-number: QTBUG-69332 Reviewed-by: Timur Pocheptsov (cherry picked from commit 38979332d0a66666ebd178bccd7e7a2b300a7e42) Change-Id: I4ef3fef29f749daa4f3a11fe9186ae77b359f966 Reviewed-by: Simon Hausmann Reviewed-by: Morten Johan Sørvig --- src/plugins/styles/mac/qmacstyle_mac.mm | 36 ++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 45da5fbd84..3405f01046 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -1880,20 +1880,46 @@ NSCell *QMacStylePrivate::cocoaCell(CocoaControl widget) const return cell; } -void QMacStylePrivate::drawNSViewInRect(NSView *view, const QRectF &qtRect, QPainter *p, +void QMacStylePrivate::drawNSViewInRect(NSView *view, const QRectF &rect, QPainter *p, __attribute__((noescape)) DrawRectBlock drawRectBlock) const { QMacCGContext ctx(p); setupNSGraphicsContext(ctx, YES); - const CGRect rect = qtRect.toCGRect(); + // FIXME: The rect that we get in is relative to the widget that we're drawing + // style on behalf of, and doesn't take into account the offset of that widget + // to the widget that owns the backingstore, which we are placing the native + // view into below. This means most of the views are placed in the upper left + // corner of backingStoreNSView, which does not map to where the actual widget + // is, and which may cause problems such as triggering a setNeedsDisplay of the + // backingStoreNSView for the wrong rect. We work around this by making the view + // layer-backed, which prevents triggering display of the backingStoreNSView, but + // but there may be other issues lurking here due to the wrong position. QTBUG-68023 + view.wantsLayer = YES; + + // FIXME: We are also setting the frame of the incoming view a lot at the call + // sites of this function, making it unclear who's actually responsible for + // maintaining the size and position of the view. In theory the call sites + // should ensure the _size_ of the view is correct, and then let this code + // take care of _positioning_ the view at the right place inside backingStoreNSView. + // For now we pass on the rect as is, to prevent any regressions until this + // can be investigated properly. + view.frame = rect.toCGRect(); [backingStoreNSView addSubview:view]; - view.frame = rect; + + // FIXME: Based on the code below, this method isn't drawing an NSView into + // a rect, it's drawing _part of the NSView_, defined by the incoming clip + // or dirty rect, into the current graphics context. We're doing some manual + // translations at the call sites that would indicate that this relationship + // is a bit fuzzy. + const CGRect dirtyRect = rect.toCGRect(); + if (drawRectBlock) - drawRectBlock(ctx, rect); + drawRectBlock(ctx, dirtyRect); else - [view drawRect:rect]; + [view drawRect:dirtyRect]; + [view removeFromSuperviewWithoutNeedingDisplay]; restoreNSGraphicsContext(ctx); -- cgit v1.2.3 From d615fb39d58d61d244a460ee13f11c73431a35e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 17 Aug 2018 09:47:59 +0200 Subject: Make QMacCocoaViewContainer work again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The widget visibility state was set to explicitly hidden, which was preventing it from working correctly when its parent widget was shown. This regression was introduced by commit d7a9e08, which made QWindow::setVisible() call QWidget::setVisible(). QWindow::destroy() calls QWindow::setVisible(false), which means that the destroy() call in setCocoaView() would set the CoocaViewContainer to be explicitly hidden. Clear WA_WState_Hidden to work around this behavior. Task-number: QTBUG-67504 Change-Id: I77438fcd01f165f058eea178c214838bd4f27084 Reviewed-by: Tor Arne Vestbø --- src/widgets/widgets/qmaccocoaviewcontainer_mac.mm | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm index 98ee90deb7..0b64b2a2bb 100644 --- a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm +++ b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm @@ -165,6 +165,11 @@ void QMacCocoaViewContainer::setCocoaView(NSView *view) Q_ASSERT(window->handle()); [oldView release]; + + // The QWindow::destroy()) call above will explicitly hide this widget. + // Clear the hidden state here so it can be implicitly shown again. + setAttribute(Qt::WA_WState_Hidden, false); + } QT_END_NAMESPACE -- cgit v1.2.3 From 9da5b6f7432dc1d87cec94040ede69cb2f7ff537 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 31 Aug 2018 14:02:51 +0200 Subject: Revert "macOS: Force light theme on macOS 10.14+" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This does not really work: as soon as you build with the 10.14 SDK you opt-in to having updated palette management, which the Qt 5.11 series does not have. This leaves app developers with two ways to opt-out of dark mode: - Build with the 10.13 (or earlier) SDK. - Set NSRequiresAquaSystemAppearance in Info.plist This reverts commit 04671a80db32bd7fce470c50934cf60f2e8ffa70. Change-Id: I5c01b9965da45de914f699526ba0723837f36e1d Reviewed-by: Tor Arne Vestbø Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qcocoaintegration.mm | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 79f7ebda54..55b3805df3 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -70,12 +70,6 @@ #include -#if !QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_14) -@interface NSApplication (MojaveForwardDeclarations) -@property (strong) NSAppearance *appearance NS_AVAILABLE_MAC(10_14); -@end -#endif - static void initResources() { Q_INIT_RESOURCE(qcocoaresources); @@ -137,21 +131,6 @@ QCocoaIntegration::QCocoaIntegration(const QStringList ¶mList) NSApplication *cocoaApplication = [QNSApplication sharedApplication]; qt_redirectNSApplicationSendEvent(); - if (__builtin_available(macOS 10.14, *)) { - // Disable dark appearance, unless the Info.plist or environment requests that it should be enabled - bool plistEnablesDarkAppearance = [[[NSBundle mainBundle] objectForInfoDictionaryKey: - @"NSRequiresAquaSystemAppearance"] boolValue]; - - bool hasEnvironmentRequiresAquaAppearance; - int environmentRequiresAquaAppearance = qEnvironmentVariableIntValue( - "QT_MAC_REQUIRES_AQUA_SYSTEM_APPEARANCE", &hasEnvironmentRequiresAquaAppearance); - bool environmentEnablesDarkAppearance = hasEnvironmentRequiresAquaAppearance - && environmentRequiresAquaAppearance == 0; - - if (!(plistEnablesDarkAppearance || environmentEnablesDarkAppearance)) - NSApp.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua]; - } - if (qEnvironmentVariableIsEmpty("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM")) { // Applications launched from plain executables (without an app // bundle) are "background" applications that does not take keybaord -- cgit v1.2.3