Use weak pointer for ElemBase last to avoid memory leak

This commit is contained in:
Turo Lamminen
2022-08-17 11:42:32 +03:00
parent 219dbbd4af
commit 30555282fe
2 changed files with 4 additions and 2 deletions
+3 -1
View File
@@ -624,7 +624,9 @@ void Structure ::Convert<ListBase>(
const FileDatabase &db) const {
ReadFieldPtr<ErrorPolicy_Igno>(dest.first, "*first", db);
ReadFieldPtr<ErrorPolicy_Igno>(dest.last, "*last", db);
std::shared_ptr<ElemBase> last;
ReadFieldPtr<ErrorPolicy_Igno>(last, "*last", db);
dest.last = last;
db.reader->IncPtr(size);
}
+1 -1
View File
@@ -124,7 +124,7 @@ struct ID : ElemBase {
// -------------------------------------------------------------------------------
struct ListBase : ElemBase {
std::shared_ptr<ElemBase> first;
std::shared_ptr<ElemBase> last;
std::weak_ptr<ElemBase> last;
};
// -------------------------------------------------------------------------------