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 <laszlo.agocs@qt.io>
This commit is contained in:
Laszlo Agocs 2023-06-01 16:04:54 +02:00
parent ec27b99c2a
commit bee7d2c610

View File

@ -6335,7 +6335,8 @@ QRhiSwapChainHdrInfo QMetalSwapChain::hdrInfo()
#ifdef Q_OS_MACOS
info.isHardCodedDefaults = false;
NSView *view = reinterpret_cast<NSView *>(window->winId());
// Must use m_window, not window, given this may be called before createOrResize().
NSView *view = reinterpret_cast<NSView *>(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.