summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorMaxim Nikolenko <maximnproductengine@lindenlab.com>2024-06-11 17:37:33 +0300
committerGitHub <noreply@github.com>2024-06-11 17:37:33 +0300
commitf3bfc13f7957a5f142871bddc57d63cd08595ad9 (patch)
tree4c630f1d08316147b43cd63d3fb7776d8f4b55d6 /indra
parent3d1aac4f5c369e9d402c41f1c790d9015f7c7773 (diff)
clean up LLUIListener::call
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/lllocationinputctrl.cpp2
-rw-r--r--indra/newview/lluilistener.cpp46
-rw-r--r--indra/newview/lluilistener.h4
-rw-r--r--indra/newview/llviewermenu.cpp2
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 a9d400881c..e7ac8d9be2 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -9430,7 +9430,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