summaryrefslogtreecommitdiff
path: root/indra/newview/lluilistener.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lluilistener.cpp')
-rw-r--r--indra/newview/lluilistener.cpp46
1 files changed, 22 insertions, 24 deletions
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"));
}
}