From f529533fdb9023a5421a1b2d3b3e524ac8437f8c Mon Sep 17 00:00:00 2001 From: assiduous Date: Mon, 7 Dec 2020 16:26:32 -0800 Subject: Fixed issue with the last reference to TextureAtlasSuballocation and BufferSuballocation --- Graphics/GraphicsTools/src/BufferSuballocator.cpp | 12 ++++++++++++ Graphics/GraphicsTools/src/DynamicTextureAtlas.cpp | 12 ++++++++++++ 2 files changed, 24 insertions(+) (limited to 'Graphics/GraphicsTools') diff --git a/Graphics/GraphicsTools/src/BufferSuballocator.cpp b/Graphics/GraphicsTools/src/BufferSuballocator.cpp index 5f1f5cfd..7f59edcd 100644 --- a/Graphics/GraphicsTools/src/BufferSuballocator.cpp +++ b/Graphics/GraphicsTools/src/BufferSuballocator.cpp @@ -68,6 +68,18 @@ public: IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_BufferSuballocation, TBase) + virtual Atomics::Long DILIGENT_CALL_TYPE Release() override final + { + RefCntAutoPtr pParent; + return TBase::Release( + [&]() // + { + // We must keep parent alive while the object is being destroyed because + // it keeps the object allocator. + pParent = m_pParentAllocator; + }); + } + virtual Uint32 GetOffset() const override final { return m_Offset; diff --git a/Graphics/GraphicsTools/src/DynamicTextureAtlas.cpp b/Graphics/GraphicsTools/src/DynamicTextureAtlas.cpp index 2c5fcc2a..6881decf 100644 --- a/Graphics/GraphicsTools/src/DynamicTextureAtlas.cpp +++ b/Graphics/GraphicsTools/src/DynamicTextureAtlas.cpp @@ -69,6 +69,18 @@ public: IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_TextureAtlasSuballocation, TBase) + virtual Atomics::Long DILIGENT_CALL_TYPE Release() override final + { + RefCntAutoPtr pAtlas; + return TBase::Release( + [&]() // + { + // We must keep the atlas alive while the object is being destroyed because + // the atlas keeps the object allocator. + pAtlas = m_pParentAtlas; + }); + } + virtual uint2 GetOrigin() const override final; virtual Uint32 GetSlice() const override final -- cgit v1.2.3