1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-23 17:30:17 +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

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