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:
@@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user