diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2024-06-11 10:40:38 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2024-06-11 10:40:38 -0400 |
commit | b5546377b0aa2482756b1dad4258659edc630c3b (patch) | |
tree | 3d7b76e4f82fbb147e6c07f104fb85c55246fd99 /indra | |
parent | 30f4163b7b576d96533b61d9b31243960fb83f2e (diff) | |
parent | f3bfc13f7957a5f142871bddc57d63cd08595ad9 (diff) |
Merge branch 'release/luau-scripting' into lua-bradfix
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/lllocationinputctrl.cpp | 2 | ||||
-rw-r--r-- | indra/newview/lluilistener.cpp | 46 | ||||
-rw-r--r-- | indra/newview/lluilistener.h | 4 | ||||
-rw-r--r-- | indra/newview/llviewermenu.cpp | 2 |
4 files changed, 26 insertions, 28 deletions
diff --git a/indra/newview/lllocationinputctrl.cpp b/indra/newview/lllocationinputctrl.cpp index c75bbec1d7..21f13108e0 100644 --- a/indra/newview/lllocationinputctrl.cpp +++ b/indra/newview/lllocationinputctrl.cpp @@ -377,7 +377,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", LLUICtrl::CommitCallbackInfo(boost::bind(&LLLocationInputCtrl::onLocationContextMenuItemClicked, this, _2))); + LLUICtrl::CommitCallbackRegistry::currentRegistrar().add("Navbar.Action", { 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 3ec300ffba..4afd7f1766 100644 --- a/indra/newview/lluilistener.cpp +++ b/indra/newview/lluilistener.cpp @@ -64,45 +64,43 @@ void LLUIListener::call(const LLSD& event) { Response response(LLSD(), event); LLUICtrl::CommitCallbackInfo *info = LLUICtrl::CommitCallbackRegistry::getValue(event["function"]); - if (!info ) + if (!info || !info->callback_func) { return response.error(stringize("Function ", std::quoted(event["function"].asString()), " was not found")); } if (info->handle_untrusted == cb_info::UNTRUSTED_BLOCK) { - return response.error(stringize("Function ", std::quoted(event["function"].asString()), " is not allowed to be called from the script")); + return response.error(stringize("Function ", std::quoted(event["function"].asString()), " may not be called from the script")); } - F64 cur_time = LLTimer::getElapsedSeconds(); - bool is_untrusted_throttle = info->handle_untrusted == cb_info::UNTRUSTED_THROTTLE; //Separate UNTRUSTED_THROTTLE and UNTRUSTED_ALLOW functions to have different timeout - F64 time_delta = is_untrusted_throttle ? mLastUntrustedThrottle + THROTTLE_PERIOD : mLastMinThrottle + MIN_THROTTLE; - if (cur_time < time_delta) + F64 *throttlep, period; + if (info->handle_untrusted == cb_info::UNTRUSTED_THROTTLE) { - LL_WARNS("LLUIListener") << "Throttled function " << std::quoted(event["function"].asString()) << LL_ENDL; - return; - } - if (is_untrusted_throttle) - { - mLastUntrustedThrottle = cur_time; + throttlep = &mLastUntrustedThrottle; + period = THROTTLE_PERIOD; } else { - mLastMinThrottle = cur_time; + throttlep = &mLastMinThrottle; + period = MIN_THROTTLE; } - - LLUICtrl::commit_callback_t func = info->callback_func; - - if (info->callback_func) + F64 cur_time = LLTimer::getElapsedSeconds(); + F64 time_delta = *throttlep + period; + if (cur_time < time_delta) { - // Interestingly, view_listener_t::addMenu() (addCommit(), - // addEnable()) constructs a commit_callback_t callable that accepts - // two parameters but discards the first. Only the second is passed to - // handleEvent(). Therefore we feel completely safe passing NULL for - // the first parameter. - (func)(NULL, event["parameter"]); + LL_WARNS("LLUIListener") << "Throttled function " << std::quoted(event["function"].asString()) << LL_ENDL; + return; } + *throttlep = cur_time; + + // Interestingly, view_listener_t::addMenu() (addCommit(), + // addEnable()) constructs a commit_callback_t callable that accepts + // two parameters but discards the first. Only the second is passed to + // handleEvent(). Therefore we feel completely safe passing NULL for + // the first parameter. + (info->callback_func)(NULL, event["parameter"]); } void LLUIListener::getValue(const LLSD&event) const @@ -119,6 +117,6 @@ void LLUIListener::getValue(const LLSD&event) const } else { - response.error(STRINGIZE("UI control " << std::quoted(event["path"].asString()) << " was not found")); + response.error(stringize("UI control ", std::quoted(event["path"].asString()), " was not found")); } } diff --git a/indra/newview/lluilistener.h b/indra/newview/lluilistener.h index 790284a27a..0df2afb3fe 100644 --- a/indra/newview/lluilistener.h +++ b/indra/newview/lluilistener.h @@ -45,8 +45,8 @@ public: void getValue(const LLSD&event) const; private: - F64 mLastUntrustedThrottle {0.f}; - F64 mLastMinThrottle {0.f}; + F64 mLastUntrustedThrottle {0}; + F64 mLastMinThrottle {0}; }; #endif /* ! defined(LL_LLUILISTENER_H) */ diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 15d1e069a5..90b7c43047 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -9493,7 +9493,7 @@ void initialize_menus() bool mMult; }; - LLUICtrl::CommitRegistrarHelper registrar(LLUICtrl::CommitCallbackRegistry::defaultRegistrar()); + LLUICtrl::CommitRegistrarHelper registrar(LLUICtrl::CommitCallbackRegistry::currentRegistrar()); LLUICtrl::EnableCallbackRegistry::Registrar& enable = LLUICtrl::EnableCallbackRegistry::currentRegistrar(); // Generic enable and visible |