summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorMnikolenko Productengine <mnikolenko@productengine.com>2024-05-16 02:29:52 +0300
committerMnikolenko Productengine <mnikolenko@productengine.com>2024-05-16 02:29:52 +0300
commitc808d849aa6aa17db95a7814e6eb6bc5162ba816 (patch)
tree28a220037e72f5b5b302afbdb22af672456e2f95 /indra/newview
parent9f540f10e687bb3889de191afbae3b52cc21f415 (diff)
adjust the flag to be untrusted block/allow/throttle
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/lllocationinputctrl.cpp2
-rw-r--r--indra/newview/lluilistener.cpp15
-rw-r--r--indra/newview/llviewermenu.cpp34
3 files changed, 33 insertions, 18 deletions
diff --git a/indra/newview/lllocationinputctrl.cpp b/indra/newview/lllocationinputctrl.cpp
index 9fa35e3bd9..629b21e264 100644
--- a/indra/newview/lllocationinputctrl.cpp
+++ b/indra/newview/lllocationinputctrl.cpp
@@ -378,7 +378,7 @@ LLLocationInputCtrl::LLLocationInputCtrl(const LLLocationInputCtrl::Params& p)
addChild(mParcelIcon[SEE_AVATARS_ICON]);
// Register callbacks and load the location field context menu (NB: the order matters).
- LLUICtrl::CommitCallbackRegistry::currentRegistrar().add("Navbar.Action", boost::bind(&LLLocationInputCtrl::onLocationContextMenuItemClicked, this, _2));
+ LLUICtrl::SharedCommitCallbackRegistry::currentRegistrar().add("Navbar.Action", LLUICtrl::LLCommitCallbackInfo(boost::bind(&LLLocationInputCtrl::onLocationContextMenuItemClicked, this, _2)));
LLUICtrl::EnableCallbackRegistry::currentRegistrar().add("Navbar.EnableMenuItem", boost::bind(&LLLocationInputCtrl::onLocationContextMenuItemEnabled, this, _2));
setPrearrangeCallback(boost::bind(&LLLocationInputCtrl::onLocationPrearrange, this, _2));
diff --git a/indra/newview/lluilistener.cpp b/indra/newview/lluilistener.cpp
index c9e5cf00d6..938ef95b5c 100644
--- a/indra/newview/lluilistener.cpp
+++ b/indra/newview/lluilistener.cpp
@@ -38,6 +38,7 @@
#include "lluictrl.h"
#include "llerror.h"
+#define THROTTLE_PERIOD 1 // required seconds between throttled functions
LLUIListener::LLUIListener():
LLEventAPI("UI",
@@ -59,6 +60,7 @@ LLUIListener::LLUIListener():
void LLUIListener::call(const LLSD& event) const
{
+ static F64 last_throttle_time = 0.0;
Response response(LLSD(), event);
LLUICtrl::LLCommitCallbackInfo *info = LLUICtrl::SharedCommitCallbackRegistry::getValue(event["function"]);
if (!info )
@@ -66,11 +68,22 @@ void LLUIListener::call(const LLSD& event) const
response.error(STRINGIZE("Function " << std::quoted(event["function"].asString()) << "was not found"));
return;
}
- if (!info->mAllowUntrusted)
+ if (info->mHandleUntrusted == LLUICtrl::LLCommitCallbackInfo::UNTRUSTED_BLOCK)
{
response.error(STRINGIZE("Function " << std::quoted(event["function"].asString()) << " is not allowed to be called from the script"));
return;
}
+ if (info->mHandleUntrusted == LLUICtrl::LLCommitCallbackInfo::UNTRUSTED_THROTTLE)
+ {
+ F64 cur_time = LLTimer::getElapsedSeconds();
+ if (cur_time < last_throttle_time + THROTTLE_PERIOD)
+ {
+ LL_WARNS("LLUIListener") << "Throttled function " << std::quoted(event["function"].asString()) << LL_ENDL;
+ return;
+ }
+ last_throttle_time = cur_time;
+ }
+
LLUICtrl::commit_callback_t func = info->callback_func;
if (info->callback_func)
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 756e002540..513a804d97 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -9361,8 +9361,10 @@ void initialize_edit_menu()
view_listener_t::addMenu(new LLEditEnableDeselect(), "Edit.EnableDeselect");
}
-#define COMMIT_ADD(func_name, func) LLUICtrl::SharedCommitCallbackRegistry::currentRegistrar().add(func_name, LLUICtrl::LLCommitCallbackInfo(func, true))
-#define COMMIT_ADD_TRUSTED(func_name, func) LLUICtrl::SharedCommitCallbackRegistry::currentRegistrar().add(func_name, LLUICtrl::LLCommitCallbackInfo(func))
+const LLUICtrl::LLCommitCallbackInfo::EUntrustedCall UNTRUSTED_BLOCK = LLUICtrl::LLCommitCallbackInfo::UNTRUSTED_BLOCK;
+#define COMMIT_ADD(func_name, func) LLUICtrl::SharedCommitCallbackRegistry::currentRegistrar().add(func_name, LLUICtrl::LLCommitCallbackInfo(func))
+#define COMMIT_ADD_TRUSTED(func_name, func) LLUICtrl::SharedCommitCallbackRegistry::currentRegistrar().add(func_name, LLUICtrl::LLCommitCallbackInfo(func, UNTRUSTED_BLOCK))
+
void initialize_spellcheck_menu()
{
LLUICtrl::EnableCallbackRegistry::Registrar& enable = LLUICtrl::EnableCallbackRegistry::currentRegistrar();
@@ -9676,7 +9678,7 @@ void initialize_menus()
view_listener_t::addMenu(new LLAdvancedDropPacket(), "Advanced.DropPacket");
// Advanced > Cache
- view_listener_t::addMenu(new LLAdvancedPurgeDiskCache(), "Advanced.PurgeDiskCache", false);
+ view_listener_t::addMenu(new LLAdvancedPurgeDiskCache(), "Advanced.PurgeDiskCache", UNTRUSTED_BLOCK);
// Advanced > Recorder
view_listener_t::addMenu(new LLAdvancedAgentPilot(), "Advanced.AgentPilot");
@@ -9685,19 +9687,19 @@ void initialize_menus()
view_listener_t::addMenu(new LLAdvancedViewerEventRecorder(), "Advanced.EventRecorder");
// Advanced > Debugging
- view_listener_t::addMenu(new LLAdvancedForceErrorBreakpoint(), "Advanced.ForceErrorBreakpoint", false);
- view_listener_t::addMenu(new LLAdvancedForceErrorLlerror(), "Advanced.ForceErrorLlerror", false);
- view_listener_t::addMenu(new LLAdvancedForceErrorLlerrorMsg(), "Advanced.ForceErrorLlerrorMsg", false);
- view_listener_t::addMenu(new LLAdvancedForceErrorBadMemoryAccess(), "Advanced.ForceErrorBadMemoryAccess", false);
- view_listener_t::addMenu(new LLAdvancedForceErrorBadMemoryAccessCoro(), "Advanced.ForceErrorBadMemoryAccessCoro", false);
- view_listener_t::addMenu(new LLAdvancedForceErrorInfiniteLoop(), "Advanced.ForceErrorInfiniteLoop", false);
- view_listener_t::addMenu(new LLAdvancedForceErrorSoftwareException(), "Advanced.ForceErrorSoftwareException", false);
- view_listener_t::addMenu(new LLAdvancedForceOSException(), "Advanced.ForceErrorOSException", false);
- view_listener_t::addMenu(new LLAdvancedForceErrorSoftwareExceptionCoro(), "Advanced.ForceErrorSoftwareExceptionCoro", false);
- view_listener_t::addMenu(new LLAdvancedForceErrorDriverCrash(), "Advanced.ForceErrorDriverCrash", false);
- view_listener_t::addMenu(new LLAdvancedForceErrorCoroutineCrash(), "Advanced.ForceErrorCoroutineCrash", false);
- view_listener_t::addMenu(new LLAdvancedForceErrorThreadCrash(), "Advanced.ForceErrorThreadCrash", false);
- view_listener_t::addMenu(new LLAdvancedForceErrorDisconnectViewer(), "Advanced.ForceErrorDisconnectViewer", false);
+ view_listener_t::addMenu(new LLAdvancedForceErrorBreakpoint(), "Advanced.ForceErrorBreakpoint", UNTRUSTED_BLOCK);
+ view_listener_t::addMenu(new LLAdvancedForceErrorLlerror(), "Advanced.ForceErrorLlerror", UNTRUSTED_BLOCK);
+ view_listener_t::addMenu(new LLAdvancedForceErrorLlerrorMsg(), "Advanced.ForceErrorLlerrorMsg", UNTRUSTED_BLOCK);
+ view_listener_t::addMenu(new LLAdvancedForceErrorBadMemoryAccess(), "Advanced.ForceErrorBadMemoryAccess", UNTRUSTED_BLOCK);
+ view_listener_t::addMenu(new LLAdvancedForceErrorBadMemoryAccessCoro(), "Advanced.ForceErrorBadMemoryAccessCoro", UNTRUSTED_BLOCK);
+ view_listener_t::addMenu(new LLAdvancedForceErrorInfiniteLoop(), "Advanced.ForceErrorInfiniteLoop", UNTRUSTED_BLOCK);
+ view_listener_t::addMenu(new LLAdvancedForceErrorSoftwareException(), "Advanced.ForceErrorSoftwareException", UNTRUSTED_BLOCK);
+ view_listener_t::addMenu(new LLAdvancedForceOSException(), "Advanced.ForceErrorOSException", UNTRUSTED_BLOCK);
+ view_listener_t::addMenu(new LLAdvancedForceErrorSoftwareExceptionCoro(), "Advanced.ForceErrorSoftwareExceptionCoro", UNTRUSTED_BLOCK);
+ view_listener_t::addMenu(new LLAdvancedForceErrorDriverCrash(), "Advanced.ForceErrorDriverCrash", UNTRUSTED_BLOCK);
+ view_listener_t::addMenu(new LLAdvancedForceErrorCoroutineCrash(), "Advanced.ForceErrorCoroutineCrash", UNTRUSTED_BLOCK);
+ view_listener_t::addMenu(new LLAdvancedForceErrorThreadCrash(), "Advanced.ForceErrorThreadCrash", UNTRUSTED_BLOCK);
+ view_listener_t::addMenu(new LLAdvancedForceErrorDisconnectViewer(), "Advanced.ForceErrorDisconnectViewer", UNTRUSTED_BLOCK);
// Advanced (toplevel)
view_listener_t::addMenu(new LLAdvancedToggleShowObjectUpdates(), "Advanced.ToggleShowObjectUpdates");