mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-19 09:30:52 +02:00
Prevent excessive macro reentry.
User could have made a macro call itself. Or could have an 'exploding' macro chain with 'too much' in it. So limit it to a macro can call a macro, but not deeper.
This commit is contained in:
parent
153da3a94d
commit
585a4c6170
@ -751,16 +751,27 @@ bool MacroCommands::ApplyCommandInBatchMode(const wxString & command, const wxSt
|
|||||||
return ApplyCommand( command, params );
|
return ApplyCommand( command, params );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int MacroReentryCount = 0;
|
||||||
// ApplyMacro returns true on success, false otherwise.
|
// ApplyMacro returns true on success, false otherwise.
|
||||||
// Any error reporting to the user in setting up the chain
|
// Any error reporting to the user in setting up the chain
|
||||||
// has already been done.
|
// has already been done.
|
||||||
bool MacroCommands::ApplyMacro(const wxString & filename)
|
bool MacroCommands::ApplyMacro(const wxString & filename)
|
||||||
{
|
{
|
||||||
|
// Check for reentrant ApplyMacro commands.
|
||||||
|
// We'll allow 1 level of reentry, but not more.
|
||||||
|
// And we treat ignoring deeper levels as a success.
|
||||||
|
if( MacroReentryCount > 1 )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Restore the reentry counter (to zero) when we exit.
|
||||||
|
auto cleanup1 = valueRestorer( MacroReentryCount);
|
||||||
|
MacroReentryCount++;
|
||||||
|
|
||||||
mFileName = filename;
|
mFileName = filename;
|
||||||
|
|
||||||
AudacityProject *proj = GetActiveProject();
|
AudacityProject *proj = GetActiveProject();
|
||||||
bool res = false;
|
bool res = false;
|
||||||
auto cleanup = finally( [&] {
|
auto cleanup2 = finally( [&] {
|
||||||
if (!res) {
|
if (!res) {
|
||||||
if(proj) {
|
if(proj) {
|
||||||
// Macro failed or was cancelled; revert to the previous state
|
// Macro failed or was cancelled; revert to the previous state
|
||||||
@ -801,7 +812,8 @@ bool MacroCommands::ApplyMacro(const wxString & filename)
|
|||||||
|
|
||||||
if (!proj)
|
if (!proj)
|
||||||
return false;
|
return false;
|
||||||
proj->PushState(longDesc, shortDesc);
|
if( MacroReentryCount <= 1 )
|
||||||
|
proj->PushState(longDesc, shortDesc);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user