Skip to content

Commit

Permalink
Guard against nullptr cmdAllocators Release call
Browse files Browse the repository at this point in the history
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.

Change-Id: I395d247a952f9584122be083ac5ca6a3caddf300
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
(cherry picked from commit 63c8c1e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 7ad4db5)
  • Loading branch information
ollie-dawes authored and Qt Cherry-pick Bot committed Feb 18, 2024
1 parent 45efad7 commit 016bc69
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/gui/rhi/qrhid3d12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,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) {
Expand Down

0 comments on commit 016bc69

Please sign in to comment.