diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 15ddd5c0a..5886e8424 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -1456,11 +1456,6 @@ namespace bgfx , m_declRef.m_vertexDeclMap.getNumElements() ); - for (uint16_t ii = 0, num = m_vertexDeclHandle.getNumHandles(); ii < num; ++ii) - { - VertexDeclHandle handle = { m_vertexDeclHandle.getHandleAt(ii) }; - m_declRef.release(handle); - } m_declRef.shutdown(m_vertexDeclHandle); #if BGFX_CONFIG_MULTITHREADED diff --git a/src/bgfx_p.h b/src/bgfx_p.h index 841ca6f72..5818ca3f0 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -1961,9 +1961,12 @@ namespace bgfx template void shutdown(bx::HandleAllocT& _handleAlloc) { - for (VertexDeclMap::Iterator it = m_vertexDeclMap.first(); m_vertexDeclMap.next(it); ) + for (uint16_t ii = 0, num = _handleAlloc.getNumHandles(); ii < num; ++ii) { - _handleAlloc.free(it.handle); + VertexDeclHandle handle = { _handleAlloc.getHandleAt(ii) }; + handle = release(handle); + BX_CHECK(isValid(handle), "Failed to release vertex decl handle %d!", handle.idx); + _handleAlloc.free(handle.idx); } m_vertexDeclMap.reset();