Merge pull request #1770 from PatrickvL/fix_memleak_pointsprite_textures

Avoid memory leak in point-sprite texture swaps
This commit is contained in:
Luke Usher 2019-11-07 15:41:30 +00:00 committed by GitHub
commit 97b13c35fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -260,6 +260,10 @@ void XboxTextureStateConverter::Apply()
g_pD3DDevice->GetTexture(3, &pTexture);
g_pD3DDevice->SetTexture(0, pTexture);
// Avoid a dangling reference that would lead to a memory leak
if (pTexture != nullptr)
pTexture->Release();
// disable all other stages
g_pD3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
g_pD3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);