Fixed a memory leak related to the gamelist placeholders.

This commit is contained in:
Leon Styhre 2021-03-19 18:47:49 +01:00
parent 924b3ac033
commit 90e3fe0fac
4 changed files with 23 additions and 17 deletions

View file

@ -47,7 +47,8 @@ SystemData::SystemData(
mIsCustomCollectionSystem(CustomCollectionSystem),
mIsGroupedCustomCollectionSystem(false),
mIsGameSystem(true),
mScrapeFlag(false)
mScrapeFlag(false),
mPlaceholder(nullptr)
{
mFilterIndex = new FileFilterIndex();
@ -79,6 +80,10 @@ SystemData::SystemData(
mRootFolder = new FileData(FOLDER, "" + name, mEnvData, this);
setupSystemSortType(mRootFolder);
}
// This placeholder can be used later in the gamelist view.
mPlaceholder = new FileData(PLACEHOLDER, "<No Entries Found>", getSystemEnvData(), this);
setIsGameSystemStatus();
loadTheme();
}
@ -93,6 +98,7 @@ SystemData::~SystemData()
if (!mEnvData->mStartPath.empty())
delete mEnvData;
delete mRootFolder;
delete mPlaceholder;
delete mFilterIndex;
}

View file

@ -96,6 +96,7 @@ public:
SystemData* getPrev() const;
static SystemData* getRandomSystem(const SystemData* currentSystem);
FileData* getRandomGame(const FileData* currentGame = nullptr);
FileData* getPlaceholder() { return mPlaceholder; };
void sortSystem(bool reloadGamelist = true, bool jumpToFirstRow = false);
@ -127,6 +128,7 @@ private:
FileFilterIndex* mFilterIndex;
FileData* mRootFolder;
FileData* mPlaceholder;
};
#endif // ES_APP_SYSTEM_DATA_H

View file

@ -162,15 +162,14 @@ FileData* BasicGameListView::getFirstGameEntry()
void BasicGameListView::addPlaceholder(FileData* firstEntry)
{
// Empty list - add a placeholder.
SystemData* system;
if (firstEntry && firstEntry->getSystem()->isGroupedCustomCollection())
system = firstEntry->getSystem();
else
system = this->mRoot->getSystem();
// Empty list, add a placeholder.
FileData* placeholder;
if (firstEntry && firstEntry->getSystem()->isGroupedCustomCollection())
placeholder = firstEntry->getSystem()->getPlaceholder();
else
placeholder = this->mRoot->getSystem()->getPlaceholder();
FileData* placeholder = new FileData(PLACEHOLDER, "<No Entries Found>",
this->mRoot->getSystem()->getSystemEnvData(), system);
mList.add(placeholder->getName(), placeholder, (placeholder->getType() == PLACEHOLDER));
}

View file

@ -535,15 +535,14 @@ void GridGameListView::updateInfoPanel()
void GridGameListView::addPlaceholder(FileData* firstEntry)
{
// Empty list - add a placeholder.
SystemData* system;
if (firstEntry && firstEntry->getSystem()->isGroupedCustomCollection())
system = firstEntry->getSystem();
else
system = this->mRoot->getSystem();
// Empty list, add a placeholder.
FileData* placeholder;
if (firstEntry && firstEntry->getSystem()->isGroupedCustomCollection())
placeholder = firstEntry->getSystem()->getPlaceholder();
else
placeholder = this->mRoot->getSystem()->getPlaceholder();
FileData* placeholder = new FileData(PLACEHOLDER, "<No Entries Found>",
this->mRoot->getSystem()->getSystemEnvData(), system);
mGrid.add(placeholder->getName(), "", placeholder);
}