diff options
author | Oliver Dawes <olliedawes@gmail.com> | 2024-02-02 14:01:22 +0000 |
---|---|---|
committer | Oliver Dawes <olliedawes@gmail.com> | 2024-02-06 15:23:42 +0000 |
commit | 63c8c1e862ee7dcd98dfd0d786e65e1b4fa05267 (patch) | |
tree | 9aaaabcc79d85c4ac15439f2c27a11eac0bc5c5d /src/gui/rhi | |
parent | f4e83fccb4ecbf01ba9b72b02a1041e93e7c92b3 (diff) |
Guard against nullptr cmdAllocators Release call
It is possible for a QRhiD3D12 instance to be created and destroyed
before the cmdAllocators list is initialized. This change simply
guards the cmdAllocators so that Release is only called if the
element is not nullptr.
For an example of how this can happen see QRhi::create. The
QRhiD3D12 is created but may be released immediately if
QRhiD3D12::create fails. One way this may happen is if the
ID3D12Device is removed but in practice many different errors may
cause create to fail.
Pick-to: 6.7 6.6
Change-Id: I395d247a952f9584122be083ac5ca6a3caddf300
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/gui/rhi')
-rw-r--r-- | src/gui/rhi/qrhid3d12.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/gui/rhi/qrhid3d12.cpp b/src/gui/rhi/qrhid3d12.cpp index 2909152d4a..f06d64a2ff 100644 --- a/src/gui/rhi/qrhid3d12.cpp +++ b/src/gui/rhi/qrhid3d12.cpp @@ -503,8 +503,10 @@ void QRhiD3D12::destroy() cbvSrvUavPool.destroy(); for (int i = 0; i < QD3D12_FRAMES_IN_FLIGHT; ++i) { - cmdAllocators[i]->Release(); - cmdAllocators[i] = nullptr; + if (cmdAllocators[i]) { + cmdAllocators[i]->Release(); + cmdAllocators[i] = nullptr; + } } if (fullFenceEvent) { |