1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-02-06 03:32:09 +01:00

Manage Commands and CommandOutputTarget objects with smart pointers

This commit is contained in:
Paul Licameli
2016-03-31 07:40:05 -04:00
parent f4441d7476
commit e8ad90b3c9
42 changed files with 164 additions and 172 deletions

View File

@@ -28,13 +28,14 @@ DEFINE_EVENT_TYPE(wxEVT_APP_COMMAND_RECEIVED)
IMPLEMENT_DYNAMIC_CLASS(AppCommandEvent, wxEvent)
AppCommandEvent::AppCommandEvent(wxEventType commandType, int id)
: wxCommandEvent(commandType, id), mCommand(NULL)
: wxCommandEvent(commandType, id)
{ }
// Copy constructor
AppCommandEvent::AppCommandEvent(const AppCommandEvent &event) : wxCommandEvent(event)
AppCommandEvent::AppCommandEvent(const AppCommandEvent &event)
: wxCommandEvent(event)
, mCommand(event.mCommand)
{
this->mCommand = event.mCommand;
}
AppCommandEvent::~AppCommandEvent()
@@ -48,17 +49,13 @@ wxEvent *AppCommandEvent::Clone() const
}
/// Store a pointer to a command object
void AppCommandEvent::SetCommand(Command *cmd)
void AppCommandEvent::SetCommand(const CommandHolder &cmd)
{
wxASSERT(NULL == mCommand);
wxASSERT(!mCommand);
mCommand = cmd;
}
// When the command pointer is retrieved, the caller is responsible for
// deletion.
Command *AppCommandEvent::GetCommand()
CommandHolder AppCommandEvent::GetCommand()
{
Command *tmp = mCommand;
mCommand = NULL;
return tmp;
return mCommand;
}