From 89bd4269018fa5a36a15eac8d2c3f99674d18b2d Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Wed, 10 Mar 2021 16:23:20 +0000 Subject: SL-14862 - use nested LLSD for widget info, condensed to the two leaf-most elements of the path. Simplified floater logging. --- indra/llui/llfloater.cpp | 2 ++ indra/llui/llfloaterreg.cpp | 8 -------- indra/llui/lluiusage.cpp | 33 ++++++++++++++++++++++++++++++++- indra/llui/lluiusage.h | 1 + indra/newview/llviewermessage.cpp | 1 - 5 files changed, 35 insertions(+), 10 deletions(-) (limited to 'indra') diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index e9c980ad9a..c03b024dd5 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -58,6 +58,7 @@ #include "llhelp.h" #include "llmultifloater.h" #include "llsdutil.h" +#include "lluiusage.h" #include @@ -1631,6 +1632,7 @@ void LLFloater::bringToFront( S32 x, S32 y ) // virtual void LLFloater::setVisibleAndFrontmost(BOOL take_focus,const LLSD& key) { + LLUIUsage::instance().logFloater(getInstanceName()); LLMultiFloater* hostp = getHost(); if (hostp) { diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp index 6307bf1028..7c0933f554 100644 --- a/indra/llui/llfloaterreg.cpp +++ b/indra/llui/llfloaterreg.cpp @@ -244,8 +244,6 @@ LLFloaterReg::const_instance_list_t& LLFloaterReg::getFloaterList(const std::str //static LLFloater* LLFloaterReg::showInstance(const std::string& name, const LLSD& key, BOOL focus) { - LL_DEBUGS("UIUsage") << "floater showInstance " << name << LL_ENDL; - LLUIUsage::instance().logFloater(name); if( sBlockShowFloaters // see EXT-7090 && sAlwaysShowableList.find(name) == sAlwaysShowableList.end()) @@ -276,9 +274,6 @@ bool LLFloaterReg::hideInstance(const std::string& name, const LLSD& key) // returns true if the instance is visible when completed bool LLFloaterReg::toggleInstance(const std::string& name, const LLSD& key) { - LL_DEBUGS("UIUsage") << "floater toggleInstance " << name << LL_ENDL; - LLUIUsage::instance().logFloater(name); - LLFloater* instance = findInstance(name, key); if (LLFloater::isShown(instance)) { @@ -478,9 +473,6 @@ void LLFloaterReg::toggleInstanceOrBringToFront(const LLSD& sdname, const LLSD& std::string name = sdname.asString(); LLFloater* instance = getInstance(name, key); - - LL_DEBUGS("UIUsage") << "floater toggleInstanceOrBringToFront " << name << LL_ENDL; - LLUIUsage::instance().logFloater(name); if (!instance) { LL_DEBUGS() << "Unable to get instance of floater '" << name << "'" << LL_ENDL; diff --git a/indra/llui/lluiusage.cpp b/indra/llui/lluiusage.cpp index 99de4ff78a..824c59730b 100644 --- a/indra/llui/lluiusage.cpp +++ b/indra/llui/lluiusage.cpp @@ -26,6 +26,7 @@ #include "linden_common.h" #include "lluiusage.h" +#include LLUIUsage::LLUIUsage() { @@ -41,9 +42,39 @@ std::string LLUIUsage::sanitized(const std::string& s) // ViewerStats db doesn't like "." in keys std::string result(s); std::replace(result.begin(), result.end(), '.', '_'); + std::replace(result.begin(), result.end(), ' ', '_'); return result; } +void LLUIUsage::setLLSDNested(LLSD& sd, const std::string& path, S32 max_elts, S32 val) const +{ + std::vector fields; + boost::split(fields, path, boost::is_any_of("/")); + auto first_pos = std::max(fields.begin(), fields.end() - max_elts); + auto end_pos = fields.end(); + std::vector last_fields(first_pos,end_pos); + + // Code below is just to accomplish the equivalent of + // sd[last_fields[0]][last_fields[1]] = LLSD::Integer(val); + // for an arbitrary number of fields. + LLSD* fsd = &sd; + for (auto it=last_fields.begin(); it!=last_fields.end(); ++it) + { + if (it == last_fields.end()-1) + { + (*fsd)[*it] = LLSD::Integer(val); + } + else + { + if (!(*fsd)[*it].isMap()) + { + (*fsd)[*it] = LLSD::emptyMap(); + } + fsd = &(*fsd)[*it]; + } + } +} + void LLUIUsage::logFloater(const std::string& floater) { mFloaterCounts[sanitized(floater)]++; @@ -75,7 +106,7 @@ LLSD LLUIUsage::asLLSD() const } for (auto const& it : mWidgetCounts) { - result["widgets"][it.first] = LLSD::Integer(it.second); + setLLSDNested(result["widgets"], it.first, 2, it.second); } return result; } diff --git a/indra/llui/lluiusage.h b/indra/llui/lluiusage.h index efc8bb4032..956e184edc 100644 --- a/indra/llui/lluiusage.h +++ b/indra/llui/lluiusage.h @@ -39,6 +39,7 @@ public: ~LLUIUsage(); public: static std::string sanitized(const std::string& s); + void setLLSDNested(LLSD& sd, const std::string& path, S32 max_elts, S32 val) const; void logFloater(const std::string& floater); void logCommand(const std::string& command); void logWidget(const std::string& w); diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 458fc3b13d..0d1b074743 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -116,7 +116,6 @@ #include "llviewerregion.h" #include "llfloaterregionrestarting.h" -#include // #include #include "llnotificationmanager.h" // -- cgit v1.2.3