QMetalRhi: Reset proxyData when swapChain is destroyed

When the swap chain is destroyed, we reset the swapchain’s layer
(set it to nullptr). However we were not resetting the proxyData which
would still point to the window’s (NSView) layer. This starts to become
a problem in  the cases where the swapchain’s associated QWindow is
closed (NSView gets destroyed) and reopened (a new NSView will be
created) because when the swap chain is recreated again, since the
proxyData already exists and points to the invalid old layer,
QRhi::updateSwapChainProxyData is never called. This led to an invalid
value being assigned to the swap chain’s layer.
To fix the issue, make sure to reset the swapchain’s proxy data when
destroy() is called.

Task-number: QTBUG-113498
Pick-to: 6.6 6.5
Change-Id: I02996ecf69ad9d183cac31c9188717ec36742531
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 948b93a847e1d6b78b5eee039281b3cd078fbabe)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Doris Verria 2024-01-16 16:12:32 +01:00 committed by Qt Cherry-pick Bot
parent 4a1ba399ea
commit b2eb82a42f

View File

@ -6101,6 +6101,7 @@ void QMetalSwapChain::destroy()
#endif #endif
d->layer = nullptr; d->layer = nullptr;
m_proxyData = {};
[d->curDrawable release]; [d->curDrawable release];
d->curDrawable = nil; d->curDrawable = nil;