From b008426ed7c6f24a8033111b24147b6822a7bd08 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 8 Jan 2018 10:41:31 +0200 Subject: [PATCH] Added propagation of unsafe execution context to waiting command Thanks Edward-san for pointing this out --- src/c_dispatch.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/c_dispatch.cpp b/src/c_dispatch.cpp index 73d0d5d3e6..fa786b271b 100644 --- a/src/c_dispatch.cpp +++ b/src/c_dispatch.cpp @@ -65,7 +65,7 @@ class DWaitingCommand : public DThinker { DECLARE_CLASS (DWaitingCommand, DThinker) public: - DWaitingCommand (const char *cmd, int tics); + DWaitingCommand (const char *cmd, int tics, bool unsafe); ~DWaitingCommand (); void Serialize(FSerializer &arc); void Tick (); @@ -75,6 +75,7 @@ private: char *Command; int TicsLeft; + bool IsUnsafe; }; class DStoredCommand : public DThinker @@ -203,12 +204,14 @@ DWaitingCommand::DWaitingCommand () { Command = NULL; TicsLeft = 1; + IsUnsafe = false; } -DWaitingCommand::DWaitingCommand (const char *cmd, int tics) +DWaitingCommand::DWaitingCommand (const char *cmd, int tics, bool unsafe) { Command = copystring (cmd); TicsLeft = tics+1; + IsUnsafe = unsafe; } DWaitingCommand::~DWaitingCommand () @@ -223,7 +226,10 @@ void DWaitingCommand::Tick () { if (--TicsLeft == 0) { + const bool wasUnsafe = UnsafeExecutionContext; + UnsafeExecutionContext = IsUnsafe; AddCommandString (Command); + UnsafeExecutionContext = wasUnsafe; Destroy (); } } @@ -739,7 +745,7 @@ void AddCommandString (char *cmd, int keynum) // Note that deferred commands lose track of which key // (if any) they were pressed from. *brkpt = ';'; - Create (brkpt, tics); + Create (brkpt, tics, UnsafeExecutionContext); } return; }