diff options
-rw-r--r-- | indra/llui/lltoolbarview.cpp | 48 | ||||
-rw-r--r-- | indra/llui/lltoolbarview.h | 1 |
2 files changed, 19 insertions, 30 deletions
diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp index 641c3eb0ab..73c8c99418 100644 --- a/indra/llui/lltoolbarview.cpp +++ b/indra/llui/lltoolbarview.cpp @@ -80,52 +80,25 @@ bool LLToolBarView::load() } // Add commands to each toolbar - // *TODO: factorize that code : tricky with Blocks though, simple lexical approach fails - LLCommandManager& mgr = LLCommandManager::instance(); - if (toolbar_set.left_toolbar.isProvided() && mToolbarLeft) { BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.left_toolbar.commands) { - LLCommandId* commandId = new LLCommandId(command); - if (mgr.getCommand(*commandId)) - { - mToolbarLeft->addCommand(*commandId); - } - else - { - llwarns << "Toolbars creation : the command " << commandId->name() << " cannot be found in the command manager" << llendl; - } + addCommand(LLCommandId(command),mToolbarLeft); } } if (toolbar_set.right_toolbar.isProvided() && mToolbarRight) { BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.right_toolbar.commands) { - LLCommandId* commandId = new LLCommandId(command); - if (mgr.getCommand(*commandId)) - { - mToolbarRight->addCommand(*commandId); - } - else - { - llwarns << "Toolbars creation : the command " << commandId->name() << " cannot be found in the command manager" << llendl; - } + addCommand(LLCommandId(command),mToolbarRight); } } if (toolbar_set.bottom_toolbar.isProvided() && mToolbarBottom) { BOOST_FOREACH(LLCommandId::Params& command, toolbar_set.bottom_toolbar.commands) { - LLCommandId* commandId = new LLCommandId(command); - if (mgr.getCommand(*commandId)) - { - mToolbarBottom->addCommand(*commandId); - } - else - { - llwarns << "Toolbars creation : the command " << commandId->name() << " cannot be found in the command manager" << llendl; - } + addCommand(LLCommandId(command),mToolbarBottom); } } return true; @@ -179,6 +152,21 @@ bool LLToolBarView::hasCommand(const LLCommandId& commandId) const return has_command; } +bool LLToolBarView::addCommand(const LLCommandId& command, LLToolBar* toolbar) +{ + LLCommandManager& mgr = LLCommandManager::instance(); + if (mgr.getCommand(command)) + { + toolbar->addCommand(command); + } + else + { + llwarns << "Toolbars creation : the command " << command.name() << " cannot be found in the command manager" << llendl; + return false; + } + return true; +} + void LLToolBarView::draw() { static bool debug_print = true; diff --git a/indra/llui/lltoolbarview.h b/indra/llui/lltoolbarview.h index 0f16b89ecc..208660da8e 100644 --- a/indra/llui/lltoolbarview.h +++ b/indra/llui/lltoolbarview.h @@ -78,6 +78,7 @@ protected: private: // Loads the toolbars from the existing user or default settings bool load(); // return false if load fails + bool addCommand(const LLCommandId& commandId, LLToolBar* toolbar); // Pointers to the toolbars handled by the toolbar view LLToolBar* mToolbarLeft; |