Jelajahi Sumber

Use weak pointer for ModifierData prev to avoid memory leak

Turo Lamminen 3 tahun lalu
induk
melakukan
d2dc0401c3

+ 3 - 1
code/AssetLib/Blender/BlenderScene.cpp

@@ -650,7 +650,9 @@ void Structure ::Convert<ModifierData>(
         const FileDatabase &db) const {
 
     ReadFieldPtr<ErrorPolicy_Warn>(dest.next, "*next", db);
-    ReadFieldPtr<ErrorPolicy_Warn>(dest.prev, "*prev", db);
+    std::shared_ptr<ElemBase> prev;
+    ReadFieldPtr<ErrorPolicy_Warn>(prev, "*prev", db);
+    dest.prev = prev;
     ReadField<ErrorPolicy_Igno>(dest.type, "type", db);
     ReadField<ErrorPolicy_Igno>(dest.mode, "mode", db);
     ReadFieldArray<ErrorPolicy_Igno>(dest.name, "name", db);

+ 1 - 1
code/AssetLib/Blender/BlenderScene.h

@@ -642,7 +642,7 @@ struct ModifierData : ElemBase {
     };
 
     std::shared_ptr<ElemBase> next WARN;
-    std::shared_ptr<ElemBase> prev WARN;
+    std::weak_ptr<ElemBase> prev WARN;
 
     int type, mode;
     char name[32];