From bee7d2c61026089371249ab03e1a788604abf99b Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 1 Jun 2023 16:04:54 +0200 Subject: [PATCH] rhi: metal: Fix a swapchain debug print crash When enabling the logs, printing hdrInfo() to qDebug in Qt Quick is something that is done before calling createOrResize() on the swapchain. (logically since this is still at the point of configuring the swapchain settings) Thus the correct thing to do is to only access m_window, not the backend data's window. Pick-to: 6.6 6.5 Change-Id: I3004b0c4a4fdb09cb07a9c0e3c503f79c699c562 Reviewed-by: Laszlo Agocs --- src/gui/rhi/qrhimetal.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index d0eb805c42..7ef200649f 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -6335,7 +6335,8 @@ QRhiSwapChainHdrInfo QMetalSwapChain::hdrInfo() #ifdef Q_OS_MACOS info.isHardCodedDefaults = false; - NSView *view = reinterpret_cast(window->winId()); + // Must use m_window, not window, given this may be called before createOrResize(). + NSView *view = reinterpret_cast(m_window->winId()); info.limits.colorComponentValue.maxColorComponentValue = view.window.screen.maximumExtendedDynamicRangeColorComponentValue; #else // ### Fixme: Maybe retrieve the brightness from the screen and if we're not at full brightness we might be able to do more.