diff --git a/Source/ImGui/Private/TextureManager.cpp b/Source/ImGui/Private/TextureManager.cpp index 7a96433..c165ed0 100644 --- a/Source/ImGui/Private/TextureManager.cpp +++ b/Source/ImGui/Private/TextureManager.cpp @@ -53,7 +53,7 @@ FTextureManager::FTextureEntry::FTextureEntry(const FName& InName, UTexture2D* I Texture->AddToRoot(); // Create brush and resource handle for input texture. - Brush.SetResourceObject(Texture); + Brush.SetResourceObject(InTexture); ResourceHandle = FSlateApplication::Get().GetRenderer()->GetResourceHandle(Brush); } @@ -67,7 +67,7 @@ FTextureManager::FTextureEntry::~FTextureEntry() // Remove texture from root to allow for garbage collection (it might be already invalid if this is application // shutdown). - if (Texture && Texture->IsValidLowLevel()) + if (Texture.IsValid()) { Texture->RemoveFromRoot(); } diff --git a/Source/ImGui/Private/TextureManager.h b/Source/ImGui/Private/TextureManager.h index c8df7a5..2c06896 100644 --- a/Source/ImGui/Private/TextureManager.h +++ b/Source/ImGui/Private/TextureManager.h @@ -86,7 +86,7 @@ private: FTextureEntry& operator=(FTextureEntry&&) = delete; FName Name = NAME_None; - UTexture2D* Texture = nullptr; + TWeakObjectPtr Texture; FSlateBrush Brush; FSlateResourceHandle ResourceHandle; };