summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-06-12 16:59:05 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-06-12 16:59:05 -0400
commit2ad31a8316c56edfcd78ce494edfcd98209a2cfa (patch)
tree74dadb391f0a31aee384705c0557ff26f81019eb /indra/newview
parent128514da9e1b24e8d817ec90b53dea9506f31101 (diff)
Defend LLFloaterLUADebug against recursive calls to handlers.
The special case of a Lua snippet that indirectly invokes the "LLNotifications" listener can result in a recursive call to LLFloaterLUADebug's handler methods. Defend against that case.
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llfloaterluadebug.cpp24
-rw-r--r--indra/newview/llfloaterluadebug.h1
2 files changed, 25 insertions, 0 deletions
diff --git a/indra/newview/llfloaterluadebug.cpp b/indra/newview/llfloaterluadebug.cpp
index 60571d6247..6da28aef5e 100644
--- a/indra/newview/llfloaterluadebug.cpp
+++ b/indra/newview/llfloaterluadebug.cpp
@@ -41,6 +41,7 @@
#include "llsdutil.h"
#include "lua_function.h"
#include "stringize.h"
+#include "tempset.h"
LLFloaterLUADebug::LLFloaterLUADebug(const LLSD &key)
@@ -77,6 +78,17 @@ LLFloaterLUADebug::~LLFloaterLUADebug()
void LLFloaterLUADebug::onExecuteClicked()
{
+ // Empirically, running Lua code that indirectly invokes the
+ // "LLNotifications" listener can result (via mysterious labyrinthine
+ // viewer UI byways) in a recursive call to this handler. We've seen Bad
+ // Things happen to the viewer with a second call to runScriptLine() with
+ // the same cmd on the same LuaState.
+ if (mExecuting)
+ {
+ LL_DEBUGS("Lua") << "recursive call to onExecuteClicked()" << LL_ENDL;
+ return;
+ }
+ TempSet executing(mExecuting, true);
mResultOutput->setValue("");
std::string cmd = mLineInput->getText();
@@ -94,6 +106,12 @@ void LLFloaterLUADebug::onBtnBrowse()
void LLFloaterLUADebug::onBtnRun()
{
+ if (mExecuting)
+ {
+ LL_DEBUGS("Lua") << "recursive call to onBtnRun()" << LL_ENDL;
+ return;
+ }
+ TempSet executing(mExecuting, true);
std::vector<std::string> filenames;
std::string filepath = mScriptPath->getText();
if (!filepath.empty())
@@ -105,6 +123,12 @@ void LLFloaterLUADebug::onBtnRun()
void LLFloaterLUADebug::runSelectedScript(const std::vector<std::string> &filenames)
{
+ if (mExecuting)
+ {
+ LL_DEBUGS("Lua") << "recursive call to runSelectedScript()" << LL_ENDL;
+ return;
+ }
+ TempSet executing(mExecuting, true);
mResultOutput->setValue("");
std::string filepath = filenames[0];
diff --git a/indra/newview/llfloaterluadebug.h b/indra/newview/llfloaterluadebug.h
index 7418174570..4d9e2fabca 100644
--- a/indra/newview/llfloaterluadebug.h
+++ b/indra/newview/llfloaterluadebug.h
@@ -66,6 +66,7 @@ private:
LLLineEditor* mLineInput;
LLLineEditor* mScriptPath;
LuaState mState;
+ bool mExecuting{ false };
};
#endif // LL_LLFLOATERLUADEBUG_H