mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 15:21:51 +00:00
Restore unsafe execution context to its previous value
This commit is contained in:
parent
f4191f27cf
commit
c8b6e5719e
1 changed files with 20 additions and 7 deletions
|
@ -129,6 +129,23 @@ FButtonStatus Button_Mlook, Button_Klook, Button_Use, Button_AltAttack,
|
||||||
|
|
||||||
bool ParsingKeyConf, UnsafeExecutionContext;
|
bool ParsingKeyConf, UnsafeExecutionContext;
|
||||||
|
|
||||||
|
class UnsafeExecutionScope
|
||||||
|
{
|
||||||
|
const bool wasEnabled;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit UnsafeExecutionScope(const bool enable = true)
|
||||||
|
: wasEnabled(UnsafeExecutionContext)
|
||||||
|
{
|
||||||
|
UnsafeExecutionContext = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
~UnsafeExecutionScope()
|
||||||
|
{
|
||||||
|
UnsafeExecutionContext = wasEnabled;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// To add new actions, go to the console and type "key <action name>".
|
// To add new actions, go to the console and type "key <action name>".
|
||||||
// This will give you the key value to use in the first column. Then
|
// This will give you the key value to use in the first column. Then
|
||||||
// insert your new action into this list so that the keys remain sorted
|
// insert your new action into this list so that the keys remain sorted
|
||||||
|
@ -226,10 +243,8 @@ void DWaitingCommand::Tick ()
|
||||||
{
|
{
|
||||||
if (--TicsLeft == 0)
|
if (--TicsLeft == 0)
|
||||||
{
|
{
|
||||||
const bool wasUnsafe = UnsafeExecutionContext;
|
UnsafeExecutionScope scope;
|
||||||
UnsafeExecutionContext = IsUnsafe;
|
|
||||||
AddCommandString (Command);
|
AddCommandString (Command);
|
||||||
UnsafeExecutionContext = wasUnsafe;
|
|
||||||
Destroy ();
|
Destroy ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -677,9 +692,8 @@ DEFINE_ACTION_FUNCTION(DOptionMenuItemCommand, DoCommand)
|
||||||
if (CurrentMenu == nullptr) return 0;
|
if (CurrentMenu == nullptr) return 0;
|
||||||
PARAM_PROLOGUE;
|
PARAM_PROLOGUE;
|
||||||
PARAM_STRING(cmd);
|
PARAM_STRING(cmd);
|
||||||
UnsafeExecutionContext = true;
|
UnsafeExecutionScope scope;
|
||||||
C_DoCommand(cmd);
|
C_DoCommand(cmd);
|
||||||
UnsafeExecutionContext = false;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1508,9 +1522,8 @@ void FConsoleAlias::SafeDelete ()
|
||||||
|
|
||||||
void FUnsafeConsoleAlias::Run (FCommandLine &args, APlayerPawn *instigator, int key)
|
void FUnsafeConsoleAlias::Run (FCommandLine &args, APlayerPawn *instigator, int key)
|
||||||
{
|
{
|
||||||
UnsafeExecutionContext = true;
|
UnsafeExecutionScope scope;
|
||||||
FConsoleAlias::Run(args, instigator, key);
|
FConsoleAlias::Run(args, instigator, key);
|
||||||
UnsafeExecutionContext = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FExecList::AddCommand(const char *cmd, const char *file)
|
void FExecList::AddCommand(const char *cmd, const char *file)
|
||||||
|
|
Loading…
Reference in a new issue