Use weak pointer for ModifierData prev to avoid memory leak

pull/4679/head
Turo Lamminen 2022-08-09 12:47:11 +03:00
parent 30555282fe
commit d2dc0401c3
2 changed files with 4 additions and 2 deletions

View File

@ -650,7 +650,9 @@ void Structure ::Convert<ModifierData>(
const FileDatabase &db) const { const FileDatabase &db) const {
ReadFieldPtr<ErrorPolicy_Warn>(dest.next, "*next", db); 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.type, "type", db);
ReadField<ErrorPolicy_Igno>(dest.mode, "mode", db); ReadField<ErrorPolicy_Igno>(dest.mode, "mode", db);
ReadFieldArray<ErrorPolicy_Igno>(dest.name, "name", db); ReadFieldArray<ErrorPolicy_Igno>(dest.name, "name", db);

View File

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