Use weak pointer for ElemBase last to avoid memory leak

pull/4679/head
Turo Lamminen 2022-08-09 12:43:50 +03:00
parent 219dbbd4af
commit 30555282fe
2 changed files with 4 additions and 2 deletions

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);
}

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;
};
// -------------------------------------------------------------------------------