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.5 6.6 6.7
Change-Id: I02996ecf69ad9d183cac31c9188717ec36742531
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
bb10
Doris Verria 2024-01-16 16:12:32 +01:00
parent a99d313076
commit 948b93a847
1 changed files with 1 additions and 0 deletions

View File

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