1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-20 22:30:05 +02: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

@ -4632,13 +4632,13 @@ void AudacityProject::TP_DisplayStatusMessage(const wxString &msg)
// (more overhead, but can be used from a non-GUI thread) // (more overhead, but can be used from a non-GUI thread)
void AudacityProject::SafeDisplayStatusMessage(const wxChar *msg) void AudacityProject::SafeDisplayStatusMessage(const wxChar *msg)
{ {
CommandOutputTarget *target auto target
= new CommandOutputTarget(TargetFactory::ProgressDefault(), = std::make_unique<CommandOutputTarget>(TargetFactory::ProgressDefault(),
new StatusBarTarget(*mStatusBar), new StatusBarTarget(*mStatusBar),
TargetFactory::MessageDefault()); TargetFactory::MessageDefault());
CommandType *type = CommandDirectory::Get()->LookUp(wxT("Message")); CommandType *type = CommandDirectory::Get()->LookUp(wxT("Message"));
wxASSERT_MSG(type != NULL, wxT("Message command not found!")); wxASSERT_MSG(type != NULL, wxT("Message command not found!"));
Command *statusCmd = type->Create(target); CommandHolder statusCmd = type->Create(std::move(target));
statusCmd->SetParameter(wxT("MessageString"), msg); statusCmd->SetParameter(wxT("MessageString"), msg);
ScriptCommandRelay::PostCommand(this, statusCmd); ScriptCommandRelay::PostCommand(this, statusCmd);

View File

@ -97,7 +97,7 @@ class ScreenFrame final : public wxFrame
void OnCaptureFirstTrack(wxCommandEvent & event); void OnCaptureFirstTrack(wxCommandEvent & event);
void OnCaptureSecondTrack(wxCommandEvent & event); void OnCaptureSecondTrack(wxCommandEvent & event);
ScreenshotCommand *CreateCommand(); std::unique_ptr<ScreenshotCommand> CreateCommand();
wxCheckBox *mDelayCheckBox; wxCheckBox *mDelayCheckBox;
wxTextCtrl *mDirectoryTextBox; wxTextCtrl *mDirectoryTextBox;
@ -105,7 +105,7 @@ class ScreenFrame final : public wxFrame
wxToggleButton *mWhite; wxToggleButton *mWhite;
wxStatusBar *mStatus; wxStatusBar *mStatus;
ScreenshotCommand *mCommand; std::unique_ptr<ScreenshotCommand> mCommand;
CommandExecutionContext mContext; CommandExecutionContext mContext;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
@ -253,16 +253,16 @@ BEGIN_EVENT_TABLE(ScreenFrame, wxFrame)
END_EVENT_TABLE(); END_EVENT_TABLE();
// Must not be called before CreateStatusBar! // Must not be called before CreateStatusBar!
ScreenshotCommand *ScreenFrame::CreateCommand() std::unique_ptr<ScreenshotCommand> ScreenFrame::CreateCommand()
{ {
wxASSERT(mStatus != NULL); wxASSERT(mStatus != NULL);
CommandOutputTarget *output = auto output =
new CommandOutputTarget(new NullProgressTarget(), std::make_unique<CommandOutputTarget>(new NullProgressTarget(),
new StatusBarTarget(*mStatus), new StatusBarTarget(*mStatus),
new MessageBoxTarget()); new MessageBoxTarget());
CommandType *type = CommandDirectory::Get()->LookUp(wxT("Screenshot")); CommandType *type = CommandDirectory::Get()->LookUp(wxT("Screenshot"));
wxASSERT_MSG(type != NULL, wxT("Screenshot command doesn't exist!")); wxASSERT_MSG(type != NULL, wxT("Screenshot command doesn't exist!"));
return new ScreenshotCommand(*type, output, this); return std::make_unique<ScreenshotCommand>(*type, std::move(output), this);
} }
ScreenFrame::ScreenFrame(wxWindow * parent, wxWindowID id) ScreenFrame::ScreenFrame(wxWindow * parent, wxWindowID id)
@ -293,7 +293,6 @@ ScreenFrame::ScreenFrame(wxWindow * parent, wxWindowID id)
ScreenFrame::~ScreenFrame() ScreenFrame::~ScreenFrame()
{ {
delete mCommand;
} }
void ScreenFrame::Populate() void ScreenFrame::Populate()

View File

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

View File

@ -18,15 +18,17 @@
#include <wx/event.h> #include <wx/event.h>
#include "../Audacity.h" #include "../Audacity.h"
#include "../MemoryX.h"
DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, wxEVT_APP_COMMAND_RECEIVED, -1); DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, wxEVT_APP_COMMAND_RECEIVED, -1);
class Command; class Command;
using CommandHolder = std::shared_ptr<Command>;
class AppCommandEvent final : public wxCommandEvent class AppCommandEvent final : public wxCommandEvent
{ {
private: private:
Command *mCommand; CommandHolder mCommand;
public: public:
AppCommandEvent(wxEventType commandType = wxEVT_APP_COMMAND_RECEIVED, int id = 0); AppCommandEvent(wxEventType commandType = wxEVT_APP_COMMAND_RECEIVED, int id = 0);
@ -35,8 +37,8 @@ public:
~AppCommandEvent(); ~AppCommandEvent();
wxEvent *Clone() const override; wxEvent *Clone() const override;
void SetCommand(Command *cmd); void SetCommand(const CommandHolder &cmd);
Command *GetCommand(); CommandHolder GetCommand();
private: private:
DECLARE_DYNAMIC_CLASS(AppCommandEvent) DECLARE_DYNAMIC_CLASS(AppCommandEvent)

View File

@ -30,9 +30,9 @@ void BatchEvalCommandType::BuildSignature(CommandSignature &signature)
signature.AddParameter(wxT("ChainName"), wxT(""), chainValidator); signature.AddParameter(wxT("ChainName"), wxT(""), chainValidator);
} }
Command *BatchEvalCommandType::Create(CommandOutputTarget *target) CommandHolder BatchEvalCommandType::Create(std::unique_ptr<CommandOutputTarget> &&target)
{ {
return new BatchEvalCommand(*this, target); return std::make_shared<BatchEvalCommand>(*this, std::move(target));
} }
bool BatchEvalCommand::Apply(CommandExecutionContext WXUNUSED(context)) bool BatchEvalCommand::Apply(CommandExecutionContext WXUNUSED(context))

View File

@ -31,15 +31,15 @@ class BatchEvalCommandType final : public CommandType
public: public:
wxString BuildName() override; wxString BuildName() override;
void BuildSignature(CommandSignature &signature) override; void BuildSignature(CommandSignature &signature) override;
Command *Create(CommandOutputTarget *target) override; CommandHolder Create(std::unique_ptr<CommandOutputTarget> &&target) override;
}; };
class BatchEvalCommand final : public CommandImplementation class BatchEvalCommand final : public CommandImplementation
{ {
public: public:
BatchEvalCommand(CommandType &type, BatchEvalCommand(CommandType &type,
CommandOutputTarget *target) std::unique_ptr<CommandOutputTarget> &&target)
: CommandImplementation(type, target) : CommandImplementation(type, std::move(target))
{ } { }
virtual ~BatchEvalCommand(); virtual ~BatchEvalCommand();

View File

@ -51,7 +51,6 @@ void DecoratedCommand::Error(const wxString &message)
DecoratedCommand::~DecoratedCommand() DecoratedCommand::~DecoratedCommand()
{ {
delete mCommand;
} }
wxString DecoratedCommand::GetName() wxString DecoratedCommand::GetName()
@ -80,7 +79,8 @@ bool ApplyAndSendResponse::Apply(CommandExecutionContext context)
if (result) if (result)
{ {
response += wxT("OK"); response += wxT("OK");
} else }
else
{ {
response += wxT("Failed!"); response += wxT("Failed!");
} }
@ -89,17 +89,16 @@ bool ApplyAndSendResponse::Apply(CommandExecutionContext context)
} }
CommandImplementation::CommandImplementation(CommandType &type, CommandImplementation::CommandImplementation(CommandType &type,
CommandOutputTarget *output) std::unique_ptr<CommandOutputTarget> &&output)
: mType(type), : mType(type),
mParams(type.GetSignature().GetDefaults()), mParams(type.GetSignature().GetDefaults()),
mOutput(output) mOutput(std::move(output))
{ {
wxASSERT(output != NULL); wxASSERT(mOutput);
} }
CommandImplementation::~CommandImplementation() CommandImplementation::~CommandImplementation()
{ {
delete mOutput;
} }
void CommandImplementation::TypeCheck(const wxString &typeName, void CommandImplementation::TypeCheck(const wxString &typeName,

View File

@ -70,17 +70,19 @@ public:
virtual bool Apply(CommandExecutionContext context) = 0; virtual bool Apply(CommandExecutionContext context) = 0;
}; };
using CommandHolder = std::shared_ptr<Command>;
// Command which wraps another command // Command which wraps another command
class DecoratedCommand /* not final */ : public Command class DecoratedCommand /* not final */ : public Command
{ {
protected: protected:
Command *mCommand; CommandHolder mCommand;
public: public:
void Progress(double completed) override; void Progress(double completed) override;
void Status(const wxString &message) override; void Status(const wxString &message) override;
void Error(const wxString &message) override; void Error(const wxString &message) override;
DecoratedCommand(Command *cmd) DecoratedCommand(const CommandHolder &cmd)
: mCommand(cmd) : mCommand(cmd)
{ {
wxASSERT(cmd != NULL); wxASSERT(cmd != NULL);
@ -96,7 +98,7 @@ public:
class ApplyAndSendResponse final : public DecoratedCommand class ApplyAndSendResponse final : public DecoratedCommand
{ {
public: public:
ApplyAndSendResponse(Command *cmd) ApplyAndSendResponse(const CommandHolder &cmd)
: DecoratedCommand(cmd) : DecoratedCommand(cmd)
{ } { }
@ -114,7 +116,7 @@ private:
bool Valid(const wxString &paramName, const wxVariant &paramValue); bool Valid(const wxString &paramName, const wxVariant &paramValue);
protected: protected:
CommandOutputTarget *mOutput; std::unique_ptr<CommandOutputTarget> mOutput;
// Convenience methods for allowing subclasses to access parameters // Convenience methods for allowing subclasses to access parameters
void TypeCheck(const wxString &typeName, void TypeCheck(const wxString &typeName,
@ -135,7 +137,7 @@ public:
/// Constructor should not be called directly; only by a factory which /// Constructor should not be called directly; only by a factory which
/// ensures name and params are set appropriately for the command. /// ensures name and params are set appropriately for the command.
CommandImplementation(CommandType &type, CommandImplementation(CommandType &type,
CommandOutputTarget *output); std::unique_ptr<CommandOutputTarget> &&output);
virtual ~CommandImplementation(); virtual ~CommandImplementation();

View File

@ -30,20 +30,19 @@ system by constructing BatchCommandEval objects.
#include "ScriptCommandRelay.h" #include "ScriptCommandRelay.h"
CommandBuilder::CommandBuilder(const wxString &cmdString) CommandBuilder::CommandBuilder(const wxString &cmdString)
: mValid(false), mCommand(NULL) : mValid(false)
{ {
BuildCommand(cmdString); BuildCommand(cmdString);
} }
CommandBuilder::CommandBuilder(const wxString &cmdName, const wxString &params) CommandBuilder::CommandBuilder(const wxString &cmdName, const wxString &params)
: mValid(false), mCommand(NULL) : mValid(false)
{ {
BuildCommand(cmdName, params); BuildCommand(cmdName, params);
} }
CommandBuilder::~CommandBuilder() CommandBuilder::~CommandBuilder()
{ {
Cleanup();
} }
bool CommandBuilder::WasValid() bool CommandBuilder::WasValid()
@ -56,22 +55,13 @@ const wxString &CommandBuilder::GetErrorMessage()
return mError; return mError;
} }
Command *CommandBuilder::GetCommand() CommandHolder CommandBuilder::GetCommand()
{ {
wxASSERT(mValid); wxASSERT(mValid);
wxASSERT(NULL != mCommand); wxASSERT(mCommand);
Command *tmp = mCommand; auto result = mCommand;
mCommand = NULL; mCommand.reset();
return tmp; return result;
}
void CommandBuilder::Cleanup()
{
if (mCommand != NULL)
{
delete mCommand;
mCommand = NULL;
}
} }
void CommandBuilder::Failure(const wxString &msg) void CommandBuilder::Failure(const wxString &msg)
@ -80,7 +70,7 @@ void CommandBuilder::Failure(const wxString &msg)
mValid = false; mValid = false;
} }
void CommandBuilder::Success(Command *cmd) void CommandBuilder::Success(const CommandHolder &cmd)
{ {
mCommand = cmd; mCommand = cmd;
mValid = true; mValid = true;
@ -92,8 +82,8 @@ void CommandBuilder::BuildCommand(const wxString &cmdName,
// Stage 1: create a Command object of the right type // Stage 1: create a Command object of the right type
CommandMessageTarget *scriptOutput = ScriptCommandRelay::GetResponseTarget(); CommandMessageTarget *scriptOutput = ScriptCommandRelay::GetResponseTarget();
CommandOutputTarget *output auto output
= new CommandOutputTarget(new NullProgressTarget(), = std::make_unique<CommandOutputTarget>(new NullProgressTarget(),
scriptOutput, scriptOutput,
scriptOutput); scriptOutput);
@ -104,15 +94,15 @@ void CommandBuilder::BuildCommand(const wxString &cmdName,
// Fall back to hoping the Batch Command system can handle it // Fall back to hoping the Batch Command system can handle it
CommandType *type = CommandDirectory::Get()->LookUp(wxT("BatchCommand")); CommandType *type = CommandDirectory::Get()->LookUp(wxT("BatchCommand"));
wxASSERT(type != NULL); wxASSERT(type != NULL);
mCommand = type->Create(output); mCommand = type->Create(std::move(output));
mCommand->SetParameter(wxT("CommandName"), cmdName); mCommand->SetParameter(wxT("CommandName"), cmdName);
mCommand->SetParameter(wxT("ParamString"), cmdParamsArg); mCommand->SetParameter(wxT("ParamString"), cmdParamsArg);
Success(new ApplyAndSendResponse(mCommand)); Success(std::make_shared<ApplyAndSendResponse>(mCommand));
return; return;
} }
CommandSignature &signature = factory->GetSignature(); CommandSignature &signature = factory->GetSignature();
mCommand = factory->Create(output); mCommand = factory->Create(std::move(output));
// Stage 2: set the parameters // Stage 2: set the parameters
@ -165,7 +155,7 @@ void CommandBuilder::BuildCommand(const wxString &cmdName,
cmdParams = cmdParams.Mid(splitAt); cmdParams = cmdParams.Mid(splitAt);
} }
Success(new ApplyAndSendResponse(mCommand)); Success(std::make_shared<ApplyAndSendResponse>(mCommand));
} }
void CommandBuilder::BuildCommand(const wxString &cmdStringArg) void CommandBuilder::BuildCommand(const wxString &cmdStringArg)

View File

@ -17,6 +17,7 @@
#define __COMMANDBUILDER__ #define __COMMANDBUILDER__
class Command; class Command;
using CommandHolder = std::shared_ptr<Command>;
class wxString; class wxString;
// CommandBuilder has the task of validating and interpreting a command string. // CommandBuilder has the task of validating and interpreting a command string.
@ -26,11 +27,11 @@ class CommandBuilder
{ {
private: private:
bool mValid; bool mValid;
Command *mCommand; CommandHolder mCommand;
wxString mError; wxString mError;
void Failure(const wxString &msg = wxEmptyString); void Failure(const wxString &msg = wxEmptyString);
void Success(Command *cmd); void Success(const CommandHolder &cmd);
void BuildCommand(const wxString &cmdName, const wxString &cmdParams); void BuildCommand(const wxString &cmdName, const wxString &cmdParams);
void BuildCommand(const wxString &cmdString); void BuildCommand(const wxString &cmdString);
public: public:
@ -39,8 +40,7 @@ class CommandBuilder
const wxString &cmdParams); const wxString &cmdParams);
~CommandBuilder(); ~CommandBuilder();
bool WasValid(); bool WasValid();
Command *GetCommand(); CommandHolder GetCommand();
void Cleanup();
const wxString &GetErrorMessage(); const wxString &GetErrorMessage();
}; };
#endif /* End of include guard: __COMMANDBUILDER__ */ #endif /* End of include guard: __COMMANDBUILDER__ */

View File

@ -41,7 +41,7 @@ void CommandHandler::SetProject(AudacityProject *)
void CommandHandler::OnReceiveCommand(AppCommandEvent &event) void CommandHandler::OnReceiveCommand(AppCommandEvent &event)
{ {
// First retrieve the actual command from the event 'envelope'. // First retrieve the actual command from the event 'envelope'.
Command *cmd = event.GetCommand(); CommandHolder cmd = event.GetCommand();
// JKC: In case the user changed the project, let us track that. // JKC: In case the user changed the project, let us track that.
// This saves us the embarrassment (crash) of a NEW project // This saves us the embarrassment (crash) of a NEW project
@ -53,9 +53,6 @@ void CommandHandler::OnReceiveCommand(AppCommandEvent &event)
// different project. // different project.
cmd->Apply(*mCurrentContext); cmd->Apply(*mCurrentContext);
// Done with the command so DELETE it.
delete cmd;
// Redraw the project // Redraw the project
mCurrentContext->GetProject()->RedrawProject(); mCurrentContext->GetProject()->RedrawProject();
} }

View File

@ -17,8 +17,10 @@
#define __COMMANDTYPE__ #define __COMMANDTYPE__
#include "CommandMisc.h" #include "CommandMisc.h"
#include "../MemoryX.h"
class Command; class Command;
using CommandHolder = std::shared_ptr<Command>;
class CommandOutputTarget; class CommandOutputTarget;
class CommandSignature; class CommandSignature;
class wxString; class wxString;
@ -47,7 +49,7 @@ public:
virtual void BuildSignature(CommandSignature &signature) = 0; virtual void BuildSignature(CommandSignature &signature) = 0;
// Create a command instance with the specified output target // Create a command instance with the specified output target
virtual Command *Create(CommandOutputTarget *target) = 0; virtual CommandHolder Create(std::unique_ptr<CommandOutputTarget> &&target) = 0;
}; };
#endif /* End of include guard: __COMMANDTYPE__ */ #endif /* End of include guard: __COMMANDTYPE__ */

View File

@ -33,9 +33,9 @@ void CompareAudioCommandType::BuildSignature(CommandSignature &signature)
signature.AddParameter(wxT("Threshold"), 0.0, thresholdValidator); signature.AddParameter(wxT("Threshold"), 0.0, thresholdValidator);
} }
Command *CompareAudioCommandType::Create(CommandOutputTarget *target) CommandHolder CompareAudioCommandType::Create(std::unique_ptr<CommandOutputTarget> &&target)
{ {
return new CompareAudioCommand(*this, target); return std::make_shared<CompareAudioCommand>(*this, std::move(target));
} }
// Update member variables with project selection data (and validate) // Update member variables with project selection data (and validate)

View File

@ -27,7 +27,7 @@ class CompareAudioCommandType final : public CommandType
public: public:
wxString BuildName() override; wxString BuildName() override;
void BuildSignature(CommandSignature &signature) override; void BuildSignature(CommandSignature &signature) override;
Command *Create(CommandOutputTarget *target) override; CommandHolder Create(std::unique_ptr<CommandOutputTarget> &&target) override;
}; };
class CompareAudioCommand final : public CommandImplementation class CompareAudioCommand final : public CommandImplementation
@ -44,8 +44,8 @@ protected:
double CompareSample(double value1, double value2) /* not override */; double CompareSample(double value1, double value2) /* not override */;
public: public:
CompareAudioCommand(CommandType &type, CommandOutputTarget *target) CompareAudioCommand(CommandType &type, std::unique_ptr<CommandOutputTarget> &&target)
: CommandImplementation(type, target) : CommandImplementation(type, std::move(target))
{ } { }
bool Apply(CommandExecutionContext context) override; bool Apply(CommandExecutionContext context) override;
}; };

View File

@ -28,9 +28,9 @@ void ExecMenuCommandType::BuildSignature(CommandSignature &signature)
signature.AddParameter(wxT("CommandName"), wxT(""), menuCommandValidator); signature.AddParameter(wxT("CommandName"), wxT(""), menuCommandValidator);
} }
Command *ExecMenuCommandType::Create(CommandOutputTarget *target) CommandHolder ExecMenuCommandType::Create(std::unique_ptr<CommandOutputTarget> &&target)
{ {
return new ExecMenuCommand(*this, target); return std::make_shared<ExecMenuCommand>(*this, std::move(target));
} }
bool ExecMenuCommand::Apply(CommandExecutionContext context) bool ExecMenuCommand::Apply(CommandExecutionContext context)

View File

@ -28,15 +28,15 @@ class ExecMenuCommandType final : public CommandType
public: public:
wxString BuildName() override; wxString BuildName() override;
void BuildSignature(CommandSignature &signature) override; void BuildSignature(CommandSignature &signature) override;
Command *Create(CommandOutputTarget *target) override; CommandHolder Create(std::unique_ptr<CommandOutputTarget> &&target) override;
}; };
class ExecMenuCommand final : public CommandImplementation class ExecMenuCommand final : public CommandImplementation
{ {
public: public:
ExecMenuCommand(CommandType &type, ExecMenuCommand(CommandType &type,
CommandOutputTarget *target) std::unique_ptr<CommandOutputTarget> &&target)
: CommandImplementation(type, target) : CommandImplementation(type, std::move(target))
{ } { }
virtual ~ExecMenuCommand() { } virtual ~ExecMenuCommand() { }
bool Apply(CommandExecutionContext context) override; bool Apply(CommandExecutionContext context) override;

View File

@ -28,9 +28,9 @@ void GetAllMenuCommandsType::BuildSignature(CommandSignature &signature)
signature.AddParameter(wxT("ShowStatus"), 0, showStatusValidator); signature.AddParameter(wxT("ShowStatus"), 0, showStatusValidator);
} }
Command *GetAllMenuCommandsType::Create(CommandOutputTarget *target) CommandHolder GetAllMenuCommandsType::Create(std::unique_ptr<CommandOutputTarget> &&target)
{ {
return new GetAllMenuCommands(*this, target); return std::make_shared<GetAllMenuCommands>(*this, std::move(target));
} }
bool GetAllMenuCommands::Apply(CommandExecutionContext context) bool GetAllMenuCommands::Apply(CommandExecutionContext context)

View File

@ -28,15 +28,15 @@ class GetAllMenuCommandsType final : public CommandType
public: public:
wxString BuildName() override; wxString BuildName() override;
void BuildSignature(CommandSignature &signature) override; void BuildSignature(CommandSignature &signature) override;
Command *Create(CommandOutputTarget *target) override; CommandHolder Create(std::unique_ptr<CommandOutputTarget> &&target) override;
}; };
class GetAllMenuCommands final : public CommandImplementation class GetAllMenuCommands final : public CommandImplementation
{ {
public: public:
GetAllMenuCommands(CommandType &type, GetAllMenuCommands(CommandType &type,
CommandOutputTarget *target) std::unique_ptr<CommandOutputTarget> &&target)
: CommandImplementation(type, target) : CommandImplementation(type, std::move(target))
{ } { }
virtual ~GetAllMenuCommands() virtual ~GetAllMenuCommands()

View File

@ -39,9 +39,9 @@ void GetProjectInfoCommandType::BuildSignature(CommandSignature &signature)
signature.AddParameter(wxT("Type"), wxT("Name"), infoTypeValidator); signature.AddParameter(wxT("Type"), wxT("Name"), infoTypeValidator);
} }
Command *GetProjectInfoCommandType::Create(CommandOutputTarget *target) CommandHolder GetProjectInfoCommandType::Create(std::unique_ptr<CommandOutputTarget> &&target)
{ {
return new GetProjectInfoCommand(*this, target); return std::make_shared<GetProjectInfoCommand>(*this, std::move(target));
} }

View File

@ -24,15 +24,15 @@ class GetProjectInfoCommandType final : public CommandType
public: public:
wxString BuildName() override; wxString BuildName() override;
void BuildSignature(CommandSignature &signature) override; void BuildSignature(CommandSignature &signature) override;
Command *Create(CommandOutputTarget *target) override; CommandHolder Create(std::unique_ptr<CommandOutputTarget> &&target) override;
}; };
class GetProjectInfoCommand final : public CommandImplementation class GetProjectInfoCommand final : public CommandImplementation
{ {
public: public:
GetProjectInfoCommand(CommandType &type, CommandOutputTarget *target) GetProjectInfoCommand(CommandType &type, std::unique_ptr<CommandOutputTarget> &&target)
: CommandImplementation(type, target) : CommandImplementation(type, std::move(target))
{ } { }
virtual ~GetProjectInfoCommand() virtual ~GetProjectInfoCommand()
{ } { }

View File

@ -46,9 +46,9 @@ void GetTrackInfoCommandType::BuildSignature(CommandSignature &signature)
signature.AddParameter(wxT("Type"), wxT("Name"), infoTypeValidator); signature.AddParameter(wxT("Type"), wxT("Name"), infoTypeValidator);
} }
Command *GetTrackInfoCommandType::Create(CommandOutputTarget *target) CommandHolder GetTrackInfoCommandType::Create(std::unique_ptr<CommandOutputTarget> &&target)
{ {
return new GetTrackInfoCommand(*this, target); return std::make_shared<GetTrackInfoCommand>(*this, std::move(target));
} }

View File

@ -24,14 +24,14 @@ class GetTrackInfoCommandType final : public CommandType
public: public:
wxString BuildName() override; wxString BuildName() override;
void BuildSignature(CommandSignature &signature) override; void BuildSignature(CommandSignature &signature) override;
Command *Create(CommandOutputTarget *target) override; CommandHolder Create(std::unique_ptr<CommandOutputTarget> &&target) override;
}; };
class GetTrackInfoCommand final : public CommandImplementation class GetTrackInfoCommand final : public CommandImplementation
{ {
public: public:
GetTrackInfoCommand(CommandType &type, CommandOutputTarget *target) GetTrackInfoCommand(CommandType &type, std::unique_ptr<CommandOutputTarget> &&target)
: CommandImplementation(type, target) : CommandImplementation(type, std::move(target))
{ } { }
virtual ~GetTrackInfoCommand() virtual ~GetTrackInfoCommand()
{ } { }

View File

@ -28,9 +28,9 @@ void HelpCommandType::BuildSignature(CommandSignature &signature)
signature.AddParameter(wxT("CommandName"), wxT(""), commandNameValidator); signature.AddParameter(wxT("CommandName"), wxT(""), commandNameValidator);
} }
Command *HelpCommandType::Create(CommandOutputTarget *target) CommandHolder HelpCommandType::Create(std::unique_ptr<CommandOutputTarget> &&target)
{ {
return new HelpCommand(*this, target); return std::make_shared<HelpCommand>(*this, std::move(target));
} }
bool HelpCommand::Apply(CommandExecutionContext WXUNUSED(context)) bool HelpCommand::Apply(CommandExecutionContext WXUNUSED(context))

View File

@ -27,14 +27,14 @@ class HelpCommandType final : public CommandType
public: public:
wxString BuildName() override; wxString BuildName() override;
void BuildSignature(CommandSignature &signature) override; void BuildSignature(CommandSignature &signature) override;
Command *Create(CommandOutputTarget *target) override; CommandHolder Create(std::unique_ptr<CommandOutputTarget> &&target) override;
}; };
class HelpCommand final : public CommandImplementation class HelpCommand final : public CommandImplementation
{ {
public: public:
HelpCommand(HelpCommandType &type, CommandOutputTarget *target) HelpCommand(HelpCommandType &type, std::unique_ptr<CommandOutputTarget> &&target)
: CommandImplementation(type, target) { } : CommandImplementation(type, std::move(target)) { }
bool Apply(CommandExecutionContext context) override; bool Apply(CommandExecutionContext context) override;
}; };

View File

@ -31,9 +31,9 @@ void ImportCommandType::BuildSignature(CommandSignature &signature)
signature.AddParameter(wxT("Filename"), wxT(""), filenameValidator); signature.AddParameter(wxT("Filename"), wxT(""), filenameValidator);
} }
Command *ImportCommandType::Create(CommandOutputTarget *target) CommandHolder ImportCommandType::Create(std::unique_ptr<CommandOutputTarget> &&target)
{ {
return new ImportCommand(*this, target); return std::make_shared<ImportCommand>(*this, std::move(target));
} }
bool ImportCommand::Apply(CommandExecutionContext context) bool ImportCommand::Apply(CommandExecutionContext context)
@ -66,9 +66,9 @@ void ExportCommandType::BuildSignature(CommandSignature &signature)
signature.AddParameter(wxT("Channels"), 1, channelsValidator); signature.AddParameter(wxT("Channels"), 1, channelsValidator);
} }
Command *ExportCommandType::Create(CommandOutputTarget *target) CommandHolder ExportCommandType::Create(std::unique_ptr<CommandOutputTarget> &&target)
{ {
return new ExportCommand(*this, target); return std::make_shared<ExportCommand>(*this, std::move(target));
} }
bool ExportCommand::Apply(CommandExecutionContext context) bool ExportCommand::Apply(CommandExecutionContext context)

View File

@ -27,15 +27,15 @@ class ImportCommandType final : public CommandType
public: public:
wxString BuildName() override; wxString BuildName() override;
void BuildSignature(CommandSignature &signature) override; void BuildSignature(CommandSignature &signature) override;
Command *Create(CommandOutputTarget *target) override; CommandHolder Create(std::unique_ptr<CommandOutputTarget> &&target) override;
}; };
class ImportCommand final : public CommandImplementation class ImportCommand final : public CommandImplementation
{ {
public: public:
ImportCommand(CommandType &type, ImportCommand(CommandType &type,
CommandOutputTarget *target) std::unique_ptr<CommandOutputTarget> &&target)
: CommandImplementation(type, target) : CommandImplementation(type, std::move(target))
{ } { }
virtual ~ImportCommand(); virtual ~ImportCommand();
@ -49,15 +49,15 @@ class ExportCommandType final : public CommandType
public: public:
wxString BuildName() override; wxString BuildName() override;
void BuildSignature(CommandSignature &signature) override; void BuildSignature(CommandSignature &signature) override;
Command *Create(CommandOutputTarget *target) override; CommandHolder Create(std::unique_ptr<CommandOutputTarget> &&target) override;
}; };
class ExportCommand final : public CommandImplementation class ExportCommand final : public CommandImplementation
{ {
public: public:
ExportCommand(CommandType &type, ExportCommand(CommandType &type,
CommandOutputTarget *target) std::unique_ptr<CommandOutputTarget> &&target)
: CommandImplementation(type, target) : CommandImplementation(type, std::move(target))
{ } { }
virtual ~ExportCommand(); virtual ~ExportCommand();

View File

@ -27,9 +27,9 @@ void MessageCommandType::BuildSignature(CommandSignature &signature)
signature.AddParameter(wxT("MessageString"), wxT(""), stringValidator); signature.AddParameter(wxT("MessageString"), wxT(""), stringValidator);
} }
Command *MessageCommandType::Create(CommandOutputTarget *target) CommandHolder MessageCommandType::Create(std::unique_ptr<CommandOutputTarget> &&target)
{ {
return new MessageCommand(*this, target); return std::make_shared<MessageCommand>(*this, std::move(target));
} }
bool MessageCommand::Apply(CommandExecutionContext WXUNUSED(context)) bool MessageCommand::Apply(CommandExecutionContext WXUNUSED(context))

View File

@ -29,15 +29,15 @@ class MessageCommandType final : public CommandType
public: public:
wxString BuildName() override; wxString BuildName() override;
void BuildSignature(CommandSignature &signature) override; void BuildSignature(CommandSignature &signature) override;
Command *Create(CommandOutputTarget *target) override; CommandHolder Create(std::unique_ptr<CommandOutputTarget> &&target) override;
}; };
class MessageCommand final : public CommandImplementation class MessageCommand final : public CommandImplementation
{ {
public: public:
MessageCommand(CommandType &type, MessageCommand(CommandType &type,
CommandOutputTarget *target) std::unique_ptr<CommandOutputTarget> &&target)
: CommandImplementation(type, target) {} : CommandImplementation(type, std::move(target)) {}
bool Apply(CommandExecutionContext context) override; bool Apply(CommandExecutionContext context) override;
}; };

View File

@ -32,9 +32,9 @@ void OpenProjectCommandType::BuildSignature(CommandSignature &signature)
signature.AddParameter(wxT("Filename"), wxT(""), filenameValidator); signature.AddParameter(wxT("Filename"), wxT(""), filenameValidator);
} }
Command *OpenProjectCommandType::Create(CommandOutputTarget *target) CommandHolder OpenProjectCommandType::Create(std::unique_ptr<CommandOutputTarget> &&target)
{ {
return new OpenProjectCommand(*this, target); return std::make_shared<OpenProjectCommand>(*this, std::move(target));
} }
bool OpenProjectCommand::Apply(CommandExecutionContext context) bool OpenProjectCommand::Apply(CommandExecutionContext context)
@ -80,9 +80,9 @@ void SaveProjectCommandType::BuildSignature(CommandSignature &signature)
signature.AddParameter(wxT("Filename"), wxT(""), filenameValidator); signature.AddParameter(wxT("Filename"), wxT(""), filenameValidator);
} }
Command *SaveProjectCommandType::Create(CommandOutputTarget *target) CommandHolder SaveProjectCommandType::Create(std::unique_ptr<CommandOutputTarget> &&target)
{ {
return new SaveProjectCommand(*this, target); return std::make_shared<SaveProjectCommand>(*this, std::move(target));
} }
bool SaveProjectCommand::Apply(CommandExecutionContext context) bool SaveProjectCommand::Apply(CommandExecutionContext context)

View File

@ -27,15 +27,15 @@ class OpenProjectCommandType final : public CommandType
public: public:
wxString BuildName() override; wxString BuildName() override;
void BuildSignature(CommandSignature &signature) override; void BuildSignature(CommandSignature &signature) override;
Command *Create(CommandOutputTarget *target) override; CommandHolder Create(std::unique_ptr<CommandOutputTarget> &&target) override;
}; };
class OpenProjectCommand final : public CommandImplementation class OpenProjectCommand final : public CommandImplementation
{ {
public: public:
OpenProjectCommand(CommandType &type, OpenProjectCommand(CommandType &type,
CommandOutputTarget *target) std::unique_ptr<CommandOutputTarget> &&target)
: CommandImplementation(type, target) : CommandImplementation(type, std::move(target))
{ } { }
virtual ~OpenProjectCommand(); virtual ~OpenProjectCommand();
@ -49,15 +49,15 @@ class SaveProjectCommandType final : public CommandType
public: public:
wxString BuildName() override; wxString BuildName() override;
void BuildSignature(CommandSignature &signature) override; void BuildSignature(CommandSignature &signature) override;
Command *Create(CommandOutputTarget *target) override; CommandHolder Create(std::unique_ptr<CommandOutputTarget> &&target) override;
}; };
class SaveProjectCommand final : public CommandImplementation class SaveProjectCommand final : public CommandImplementation
{ {
public: public:
SaveProjectCommand(CommandType &type, SaveProjectCommand(CommandType &type,
CommandOutputTarget *target) std::unique_ptr<CommandOutputTarget> &&target)
: CommandImplementation(type, target) : CommandImplementation(type, std::move(target))
{ } { }
virtual ~SaveProjectCommand(); virtual ~SaveProjectCommand();

View File

@ -30,9 +30,9 @@ void GetPreferenceCommandType::BuildSignature(CommandSignature &signature)
signature.AddParameter(wxT("PrefName"), wxT(""), prefNameValidator); signature.AddParameter(wxT("PrefName"), wxT(""), prefNameValidator);
} }
Command *GetPreferenceCommandType::Create(CommandOutputTarget *target) CommandHolder GetPreferenceCommandType::Create(std::unique_ptr<CommandOutputTarget> &&target)
{ {
return new GetPreferenceCommand(*this, target); return std::make_shared<GetPreferenceCommand>(*this, std::move(target));
} }
bool GetPreferenceCommand::Apply(CommandExecutionContext WXUNUSED(context)) bool GetPreferenceCommand::Apply(CommandExecutionContext WXUNUSED(context))
@ -65,9 +65,9 @@ void SetPreferenceCommandType::BuildSignature(CommandSignature &signature)
signature.AddParameter(wxT("PrefValue"), wxT(""), prefValueValidator); signature.AddParameter(wxT("PrefValue"), wxT(""), prefValueValidator);
} }
Command *SetPreferenceCommandType::Create(CommandOutputTarget *target) CommandHolder SetPreferenceCommandType::Create(std::unique_ptr<CommandOutputTarget> &&target)
{ {
return new SetPreferenceCommand(*this, target); return std::make_shared<SetPreferenceCommand>(*this, std::move(target));
} }
bool SetPreferenceCommand::Apply(CommandExecutionContext WXUNUSED(context)) bool SetPreferenceCommand::Apply(CommandExecutionContext WXUNUSED(context))

View File

@ -30,15 +30,15 @@ class GetPreferenceCommandType final : public CommandType
public: public:
wxString BuildName() override; wxString BuildName() override;
void BuildSignature(CommandSignature &signature) override; void BuildSignature(CommandSignature &signature) override;
Command *Create(CommandOutputTarget *target) override; CommandHolder Create(std::unique_ptr<CommandOutputTarget> &&target) override;
}; };
class GetPreferenceCommand final : public CommandImplementation class GetPreferenceCommand final : public CommandImplementation
{ {
public: public:
GetPreferenceCommand(CommandType &type, GetPreferenceCommand(CommandType &type,
CommandOutputTarget *target) std::unique_ptr<CommandOutputTarget> &&target)
: CommandImplementation(type, target) : CommandImplementation(type, std::move(target))
{ } { }
virtual ~GetPreferenceCommand(); virtual ~GetPreferenceCommand();
@ -52,15 +52,15 @@ class SetPreferenceCommandType final : public CommandType
public: public:
wxString BuildName() override; wxString BuildName() override;
void BuildSignature(CommandSignature &signature) override; void BuildSignature(CommandSignature &signature) override;
Command *Create(CommandOutputTarget *target) override; CommandHolder Create(std::unique_ptr<CommandOutputTarget> &&target) override;
}; };
class SetPreferenceCommand final : public CommandImplementation class SetPreferenceCommand final : public CommandImplementation
{ {
public: public:
SetPreferenceCommand(CommandType &type, SetPreferenceCommand(CommandType &type,
CommandOutputTarget *target) std::unique_ptr<CommandOutputTarget> &&target)
: CommandImplementation(type, target) : CommandImplementation(type, std::move(target))
{ } { }
virtual ~SetPreferenceCommand(); virtual ~SetPreferenceCommand();

View File

@ -306,9 +306,9 @@ void ScreenshotCommandType::BuildSignature(CommandSignature &signature)
signature.AddParameter(wxT("FilePath"), wxT(""), filePathValidator); signature.AddParameter(wxT("FilePath"), wxT(""), filePathValidator);
} }
Command *ScreenshotCommandType::Create(CommandOutputTarget *target) CommandHolder ScreenshotCommandType::Create(std::unique_ptr<CommandOutputTarget> &&target)
{ {
return new ScreenshotCommand(*this, target); return std::make_shared<ScreenshotCommand>(*this, std::move(target));
} }
wxString ScreenshotCommand::MakeFileName(const wxString &path, const wxString &basename) wxString ScreenshotCommand::MakeFileName(const wxString &path, const wxString &basename)

View File

@ -28,7 +28,7 @@ class ScreenshotCommandType final : public CommandType
public: public:
wxString BuildName() override; wxString BuildName() override;
void BuildSignature(CommandSignature &signature) override; void BuildSignature(CommandSignature &signature) override;
Command *Create(CommandOutputTarget *target) override; CommandHolder Create(std::unique_ptr<CommandOutputTarget> &&target) override;
}; };
class ScreenshotCommand final : public CommandImplementation class ScreenshotCommand final : public CommandImplementation
@ -53,9 +53,9 @@ private:
public: public:
wxTopLevelWindow *GetFrontWindow(AudacityProject *project); wxTopLevelWindow *GetFrontWindow(AudacityProject *project);
ScreenshotCommand(CommandType &type, ScreenshotCommand(CommandType &type,
CommandOutputTarget *output, std::unique_ptr<CommandOutputTarget> &&output,
wxWindow *ignore = NULL) wxWindow *ignore = NULL)
: CommandImplementation(type, output), : CommandImplementation(type, std::move(output)),
mIgnore(ignore), mIgnore(ignore),
mBackground(false) mBackground(false)
{ } { }

View File

@ -51,7 +51,7 @@ void ScriptCommandRelay::Run()
} }
/// Send a command to a project, to be applied in that context. /// Send a command to a project, to be applied in that context.
void ScriptCommandRelay::PostCommand(AudacityProject *project, Command *cmd) void ScriptCommandRelay::PostCommand(AudacityProject *project, const CommandHolder &cmd)
{ {
wxASSERT(project != NULL); wxASSERT(project != NULL);
wxASSERT(cmd != NULL); wxASSERT(cmd != NULL);
@ -66,20 +66,22 @@ void ScriptCommandRelay::PostCommand(AudacityProject *project, Command *cmd)
/// the GUI at a time causes problems with wxwidgets. /// the GUI at a time causes problems with wxwidgets.
int ExecCommand(wxString *pIn, wxString *pOut) int ExecCommand(wxString *pIn, wxString *pOut)
{ {
CommandBuilder builder(*pIn);
if (builder.WasValid())
{ {
AudacityProject *project = GetActiveProject(); CommandBuilder builder(*pIn);
project->SafeDisplayStatusMessage(wxT("Received script command")); if (builder.WasValid())
Command *cmd = builder.GetCommand(); {
ScriptCommandRelay::PostCommand(project, cmd); AudacityProject *project = GetActiveProject();
project->SafeDisplayStatusMessage(wxT("Received script command"));
CommandHolder cmd = builder.GetCommand();
ScriptCommandRelay::PostCommand(project, cmd);
*pOut = wxEmptyString; *pOut = wxEmptyString;
} else }
{ else
*pOut = wxT("Syntax error!\n"); {
*pOut += builder.GetErrorMessage() + wxT("\n"); *pOut = wxT("Syntax error!\n");
builder.Cleanup(); *pOut += builder.GetErrorMessage() + wxT("\n");
}
} }
// Wait until all responses from the command have been received. // Wait until all responses from the command have been received.

View File

@ -17,6 +17,7 @@
#define __SCRIPTCOMMANDRELAY__ #define __SCRIPTCOMMANDRELAY__
#include "../Audacity.h" #include "../Audacity.h"
#include "../MemoryX.h"
class CommandHandler; class CommandHandler;
class ResponseQueue; class ResponseQueue;
@ -24,6 +25,7 @@ class Response;
class ResponseQueueTarget; class ResponseQueueTarget;
class AudacityProject; class AudacityProject;
class Command; class Command;
using CommandHolder = std::shared_ptr<Command>;
class wxString; class wxString;
typedef int (*tpExecScriptServerFunc)( wxString * pIn, wxString * pOut); typedef int (*tpExecScriptServerFunc)( wxString * pIn, wxString * pOut);
@ -47,7 +49,7 @@ class ScriptCommandRelay
static void SetCommandHandler(CommandHandler &ch); static void SetCommandHandler(CommandHandler &ch);
static void Run(); static void Run();
static void PostCommand(AudacityProject *project, Command *cmd); static void PostCommand(AudacityProject *project, const CommandHolder &cmd);
static void SendResponse(const wxString &response); static void SendResponse(const wxString &response);
static Response ReceiveResponse(); static Response ReceiveResponse();
static ResponseQueueTarget *GetResponseTarget(); static ResponseQueueTarget *GetResponseTarget();

View File

@ -49,9 +49,9 @@ void SelectCommandType::BuildSignature(CommandSignature &signature)
signature.AddParameter(wxT("TrackName"), 0, trackNameValidator); signature.AddParameter(wxT("TrackName"), 0, trackNameValidator);
} }
Command *SelectCommandType::Create(CommandOutputTarget *target) CommandHolder SelectCommandType::Create(std::unique_ptr<CommandOutputTarget> &&target)
{ {
return new SelectCommand(*this, target); return std::make_shared<SelectCommand>(*this, std::move(target));
} }
bool SelectCommand::Apply(CommandExecutionContext context) bool SelectCommand::Apply(CommandExecutionContext context)

View File

@ -24,14 +24,14 @@ class SelectCommandType final : public CommandType
public: public:
wxString BuildName() override; wxString BuildName() override;
void BuildSignature(CommandSignature &signature) override; void BuildSignature(CommandSignature &signature) override;
Command *Create(CommandOutputTarget *target) override; CommandHolder Create(std::unique_ptr<CommandOutputTarget> &&target) override;
}; };
class SelectCommand final : public CommandImplementation class SelectCommand final : public CommandImplementation
{ {
public: public:
SelectCommand(SelectCommandType &type, CommandOutputTarget *target) SelectCommand(SelectCommandType &type, std::unique_ptr<CommandOutputTarget> &&target)
: CommandImplementation(type, target) { } : CommandImplementation(type, std::move(target)) { }
bool Apply(CommandExecutionContext context) override; bool Apply(CommandExecutionContext context) override;
}; };

View File

@ -41,9 +41,9 @@ void SetProjectInfoCommandType::BuildSignature(CommandSignature &signature)
signature.AddParameter(wxT(kSetOfTracksStr), wxT("x"), TracksSetValidator); signature.AddParameter(wxT(kSetOfTracksStr), wxT("x"), TracksSetValidator);
} }
Command *SetProjectInfoCommandType::Create(CommandOutputTarget *target) CommandHolder SetProjectInfoCommandType::Create(std::unique_ptr<CommandOutputTarget> &&target)
{ {
return new SetProjectInfoCommand(*this, target); return std::make_shared<SetProjectInfoCommand>(*this, std::move(target));
} }

View File

@ -28,15 +28,15 @@ class SetProjectInfoCommandType final : public CommandType
public: public:
wxString BuildName() override; wxString BuildName() override;
void BuildSignature(CommandSignature &signature) override; void BuildSignature(CommandSignature &signature) override;
Command *Create(CommandOutputTarget *target) override; CommandHolder Create(std::unique_ptr<CommandOutputTarget> &&target) override;
}; };
class SetProjectInfoCommand final : public CommandImplementation class SetProjectInfoCommand final : public CommandImplementation
{ {
public: public:
SetProjectInfoCommand(CommandType &type, CommandOutputTarget *target) SetProjectInfoCommand(CommandType &type, std::unique_ptr<CommandOutputTarget> &&target)
: CommandImplementation(type, target) : CommandImplementation(type, std::move(target))
{ } { }
virtual ~SetProjectInfoCommand() virtual ~SetProjectInfoCommand()
{ } { }

View File

@ -37,9 +37,9 @@ void SetTrackInfoCommandType::BuildSignature(CommandSignature &signature)
signature.AddParameter(wxT("Name"), wxT("Unnamed"), nameValidator); signature.AddParameter(wxT("Name"), wxT("Unnamed"), nameValidator);
} }
Command *SetTrackInfoCommandType::Create(CommandOutputTarget *target) CommandHolder SetTrackInfoCommandType::Create(std::unique_ptr<CommandOutputTarget> &&target)
{ {
return new SetTrackInfoCommand(*this, target); return std::make_shared<SetTrackInfoCommand>(*this, std::move(target));
} }
bool SetTrackInfoCommand::Apply(CommandExecutionContext context) bool SetTrackInfoCommand::Apply(CommandExecutionContext context)

View File

@ -24,14 +24,14 @@ class SetTrackInfoCommandType final : public CommandType
public: public:
wxString BuildName() override; wxString BuildName() override;
void BuildSignature(CommandSignature &signature) override; void BuildSignature(CommandSignature &signature) override;
Command *Create(CommandOutputTarget *target) override; CommandHolder Create(std::unique_ptr<CommandOutputTarget> &&target) override;
}; };
class SetTrackInfoCommand final : public CommandImplementation class SetTrackInfoCommand final : public CommandImplementation
{ {
public: public:
SetTrackInfoCommand(CommandType &type, CommandOutputTarget *target) SetTrackInfoCommand(CommandType &type, std::unique_ptr<CommandOutputTarget> &&target)
: CommandImplementation(type, target) : CommandImplementation(type, std::move(target))
{ } { }
virtual ~SetTrackInfoCommand() virtual ~SetTrackInfoCommand()
{ } { }