1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-21 22:12:58 +02:00

Singleton CommandDirectory used to leak!

This commit is contained in:
Paul Licameli
2016-03-31 13:20:25 -04:00
parent 29349fedbb
commit fd8fa69c62
2 changed files with 8 additions and 21 deletions

View File

@@ -32,13 +32,10 @@
#include "ImportExportCommands.h"
#include "OpenSaveCommands.h"
CommandDirectory *CommandDirectory::mInstance = NULL;
std::unique_ptr<CommandDirectory> CommandDirectory::mInstance;
CommandDirectory::CommandDirectory()
{
wxASSERT(mInstance == NULL);
mInstance = this;
// Create the command map.
// Adding an entry here is the easiest way to register a Command class.
AddCommand(new ScreenshotCommandType());
@@ -96,17 +93,7 @@ void CommandDirectory::AddCommand(CommandType *type)
CommandDirectory *CommandDirectory::Get()
{
if (mInstance == NULL)
{
return new CommandDirectory();
}
return mInstance;
}
void CommandDirectory::Destroy()
{
if (mInstance != NULL)
{
delete mInstance;
}
if (!mInstance)
mInstance.reset(safenew CommandDirectory());
return mInstance.get();
}