From da37e2c11a01c8a3071ea1c10074ecfa077bbfaf Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sat, 17 Oct 2020 17:35:50 +0200 Subject: [PATCH] Implemented proper memory cleanup when deleting FileData objects. This fixes a memory leak which was most prominent during application shutdown. --- es-app/src/FileData.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/es-app/src/FileData.cpp b/es-app/src/FileData.cpp index 29ac644b7..aad8b0b35 100644 --- a/es-app/src/FileData.cpp +++ b/es-app/src/FileData.cpp @@ -68,13 +68,14 @@ FileData::FileData( FileData::~FileData() { - if (mParent) - mParent->removeChild(this); - if (mType == GAME) mSystem->getIndex()->removeFromIndex(this); - mChildren.clear(); + if (mParent) + mParent->removeChild(this); + + while (mChildren.size() > 0) + delete (mChildren.front()); } std::string FileData::getDisplayName() const