From 30555282fea98e334606f61ef0f28ef355580d63 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 9 Aug 2022 12:43:50 +0300 Subject: [PATCH] Use weak pointer for ElemBase last to avoid memory leak --- code/AssetLib/Blender/BlenderScene.cpp | 4 +++- code/AssetLib/Blender/BlenderScene.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/code/AssetLib/Blender/BlenderScene.cpp b/code/AssetLib/Blender/BlenderScene.cpp index d458ede2e..76582db76 100644 --- a/code/AssetLib/Blender/BlenderScene.cpp +++ b/code/AssetLib/Blender/BlenderScene.cpp @@ -624,7 +624,9 @@ void Structure ::Convert( const FileDatabase &db) const { ReadFieldPtr(dest.first, "*first", db); - ReadFieldPtr(dest.last, "*last", db); + std::shared_ptr last; + ReadFieldPtr(last, "*last", db); + dest.last = last; db.reader->IncPtr(size); } diff --git a/code/AssetLib/Blender/BlenderScene.h b/code/AssetLib/Blender/BlenderScene.h index 479eae018..c592db57f 100644 --- a/code/AssetLib/Blender/BlenderScene.h +++ b/code/AssetLib/Blender/BlenderScene.h @@ -124,7 +124,7 @@ struct ID : ElemBase { // ------------------------------------------------------------------------------- struct ListBase : ElemBase { std::shared_ptr first; - std::shared_ptr last; + std::weak_ptr last; }; // -------------------------------------------------------------------------------