Skip to content

Commit

Permalink
Fixed|FS|libcore: Minor memory leak when shutting down the file system
Browse files Browse the repository at this point in the history
Indices were being recreated during root folder destruction (deindexing)
and not deleted afterwards.
  • Loading branch information
skyjake committed Jan 23, 2017
1 parent d5cf9bc commit 0577eef
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions doomsday/sdk/libcore/src/filesys/filesystem.cpp
Expand Up @@ -51,10 +51,16 @@ DENG2_PIMPL_NOREF(FileSystem)
QSet<FileIndex *> userIndices; // not owned

/// The root folder of the entire file system.
Folder root;
std::unique_ptr<Folder> root;

Impl()
{
root.reset(new Folder);
}

~Impl()
{
root.reset();
qDeleteAll(typeIndex.values());
typeIndex.clear();
}
Expand Down Expand Up @@ -91,7 +97,7 @@ void FileSystem::refresh()
LOG_AS("FS::refresh");

//Time startedAt;
d->root.populate(Folder::PopulateAsyncFullTree);
d->root->populate(Folder::PopulateAsyncFullTree);

/*LOGDEV_RES_VERBOSE("Completed in %.2f seconds") << startedAt.since();
printIndex();*/
Expand All @@ -101,7 +107,7 @@ Folder &FileSystem::makeFolder(String const &path, FolderCreationBehaviors behav
{
LOG_AS("FS::makeFolder");

Folder *subFolder = d->root.tryLocate<Folder>(path);
Folder *subFolder = d->root->tryLocate<Folder>(path);
if (!subFolder)
{
// This folder does not exist yet. Let's create it.
Expand Down Expand Up @@ -366,12 +372,12 @@ String FileSystem::accessNativeLocation(NativePath const &nativePath, File::Flag

Folder &FileSystem::root()
{
return d->root;
return *d->root;
}

Folder const &FileSystem::root() const
{
return d->root;
return *d->root;
}

FileSystem &FileSystem::get() // static
Expand Down

0 comments on commit 0577eef

Please sign in to comment.