From 9827dff971807471a2c20c2342bd77c43a931e6f Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Sun, 18 Aug 2024 15:40:57 -0400 Subject: Fix frequent deep findChild calls for LLFloaterSidePanelContainer main during various ui callbacks --- indra/newview/llfloatersidepanelcontainer.cpp | 28 ++++++++++++++++++++++----- indra/newview/llfloatersidepanelcontainer.h | 9 +++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/indra/newview/llfloatersidepanelcontainer.cpp b/indra/newview/llfloatersidepanelcontainer.cpp index 6c5d2570f2..9e577c83a8 100644 --- a/indra/newview/llfloatersidepanelcontainer.cpp +++ b/indra/newview/llfloatersidepanelcontainer.cpp @@ -53,9 +53,15 @@ LLFloaterSidePanelContainer::~LLFloaterSidePanelContainer() LLTransientFloaterMgr::getInstance()->removeControlView(LLTransientFloaterMgr::GLOBAL, this); } +bool LLFloaterSidePanelContainer::postBuild() +{ + mMainPanel = getChild(sMainPanelName); + return TRUE; +} + void LLFloaterSidePanelContainer::onOpen(const LLSD& key) { - getChild(sMainPanelName)->onOpen(key); + mMainPanel->onOpen(key); } void LLFloaterSidePanelContainer::closeFloater(bool app_quitting) @@ -206,10 +212,16 @@ void LLFloaterSidePanelContainer::showPanel(std::string_view floater_name, std:: LLPanel* LLFloaterSidePanelContainer::getPanel(std::string_view floater_name, std::string_view panel_name) { LLFloaterSidePanelContainer* floaterp = LLFloaterReg::getTypedInstance(floater_name); - if (floaterp) { - return floaterp->findChild(panel_name, true); + if (panel_name == sMainPanelName) + { + return floaterp->mMainPanel; + } + else + { + return floaterp->findChild(panel_name, true); + } } return NULL; @@ -218,10 +230,16 @@ LLPanel* LLFloaterSidePanelContainer::getPanel(std::string_view floater_name, st LLPanel* LLFloaterSidePanelContainer::findPanel(std::string_view floater_name, std::string_view panel_name) { LLFloaterSidePanelContainer* floaterp = LLFloaterReg::findTypedInstance(floater_name); - if (floaterp) { - return floaterp->findChild(panel_name, true); + if (panel_name == sMainPanelName) + { + return floaterp->mMainPanel; + } + else + { + return floaterp->findChild(panel_name, true); + } } return NULL; diff --git a/indra/newview/llfloatersidepanelcontainer.h b/indra/newview/llfloatersidepanelcontainer.h index d7f6c309c4..a57a2da4d9 100644 --- a/indra/newview/llfloatersidepanelcontainer.h +++ b/indra/newview/llfloatersidepanelcontainer.h @@ -49,6 +49,8 @@ public: LLFloaterSidePanelContainer(const LLSD& key, const Params& params = getDefaultParams()); ~LLFloaterSidePanelContainer(); + bool postBuild() override; + void onOpen(const LLSD& key) override; void closeFloater(bool app_quitting = false) override; @@ -77,6 +79,11 @@ public: * @returns a pointer to the panel of given type T. */ template + static T* findPanel(std::string_view floater_name, std::string_view panel_name = sMainPanelName) + { + return dynamic_cast(findPanel(floater_name, panel_name)); + } + template static T* getPanel(std::string_view floater_name, std::string_view panel_name = sMainPanelName) { T* panel = dynamic_cast(getPanel(floater_name, panel_name)); @@ -89,6 +96,8 @@ public: protected: void onCloseMsgCallback(const LLSD& notification, const LLSD& response); + + LLPanel* mMainPanel = nullptr; }; #endif // LL_LLFLOATERSIDEPANELCONTAINER_H -- cgit v1.2.3