diff options
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/llfloater.cpp | 8 | ||||
-rw-r--r-- | indra/llui/llfloater.h | 2 | ||||
-rw-r--r-- | indra/llui/llmenubutton.cpp | 2 | ||||
-rw-r--r-- | indra/llui/llpanel.cpp | 4 | ||||
-rw-r--r-- | indra/llui/llpanel.h | 3 | ||||
-rw-r--r-- | indra/llui/lluictrlfactory.cpp | 4 | ||||
-rw-r--r-- | indra/llui/lluictrlfactory.h | 6 | ||||
-rw-r--r-- | indra/llui/llxuiparser.cpp | 27 |
8 files changed, 34 insertions, 22 deletions
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 25006abf2c..48693c6267 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -3522,16 +3522,12 @@ bool LLFloater::isVisible(const LLFloater* floater) return floater && floater->getVisible(); } -bool LLFloater::buildFromFile(const std::string& filename, bool cacheable) +bool LLFloater::buildFromFile(const std::string& filename) { LL_PROFILE_ZONE_SCOPED; - - llassert_msg(!cacheable || !mSingleInstance || !mReuseInstance, - "No needs to cache XML for floater with mSingleInstance AND mReuseInstance flags set"); - LLXMLNodePtr root; - if (!LLUICtrlFactory::getLayeredXMLNode(filename, root, LLDir::CURRENT_SKIN, cacheable)) + if (!LLUICtrlFactory::getLayeredXMLNode(filename, root)) { LL_WARNS() << "Couldn't find (or parse) floater from: " << filename << LL_ENDL; return false; diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index 13d9bf5adc..f7e121ed7e 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -208,7 +208,7 @@ public: // Don't export top/left for rect, only height/width static void setupParamsForExport(Params& p, LLView* parent); - bool buildFromFile(const std::string &filename, bool cacheable = false); + bool buildFromFile(const std::string &filename); boost::signals2::connection setMinimizeCallback( const commit_signal_t::slot_type& cb ); boost::signals2::connection setOpenCallback( const commit_signal_t::slot_type& cb ); diff --git a/indra/llui/llmenubutton.cpp b/indra/llui/llmenubutton.cpp index 85aa766918..5374b7ea73 100644 --- a/indra/llui/llmenubutton.cpp +++ b/indra/llui/llmenubutton.cpp @@ -95,7 +95,7 @@ void LLMenuButton::setMenu(const std::string& menu_filename, EMenuPosition posit } llassert(LLMenuGL::sMenuContainer != NULL); - LLToggleableMenu* menu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>(menu_filename, LLMenuGL::sMenuContainer, LLMenuHolderGL::child_registry_t::instance(), true); + LLToggleableMenu* menu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>(menu_filename, LLMenuGL::sMenuContainer, LLMenuHolderGL::child_registry_t::instance()); if (!menu) { LL_WARNS() << "Error loading menu_button menu" << LL_ENDL; diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp index bba10bd792..ba6a31eb9e 100644 --- a/indra/llui/llpanel.cpp +++ b/indra/llui/llpanel.cpp @@ -803,13 +803,13 @@ boost::signals2::connection LLPanel::setVisibleCallback( const commit_signal_t:: //----------------------------------------------------------------------------- // buildPanel() //----------------------------------------------------------------------------- -bool LLPanel::buildFromFile(const std::string& filename, const LLPanel::Params& default_params, bool cacheable) +bool LLPanel::buildFromFile(const std::string& filename, const LLPanel::Params& default_params) { LL_PROFILE_ZONE_SCOPED; bool didPost = false; LLXMLNodePtr root; - if (!LLUICtrlFactory::getLayeredXMLNode(filename, root, LLDir::CURRENT_SKIN, cacheable)) + if (!LLUICtrlFactory::getLayeredXMLNode(filename, root)) { LL_WARNS() << "Couldn't parse panel from: " << filename << LL_ENDL; return didPost; diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h index dd73a41132..33883bf6a4 100644 --- a/indra/llui/llpanel.h +++ b/indra/llui/llpanel.h @@ -107,8 +107,7 @@ protected: public: typedef std::vector<class LLUICtrl *> ctrl_list_t; - bool buildFromFile(const std::string &filename, const LLPanel::Params& default_params, bool cacheable = false); - bool buildFromFile(const std::string &filename, bool cacheable = false) { return buildFromFile(filename, getDefaultParams(), cacheable); } + bool buildFromFile(const std::string &filename, const LLPanel::Params& default_params = getDefaultParams()); static LLPanel* createFactoryPanel(const std::string& name); diff --git a/indra/llui/lluictrlfactory.cpp b/indra/llui/lluictrlfactory.cpp index 706140fd49..dca777cc1f 100644 --- a/indra/llui/lluictrlfactory.cpp +++ b/indra/llui/lluictrlfactory.cpp @@ -157,7 +157,7 @@ void LLUICtrlFactory::createChildren(LLView* viewp, LLXMLNodePtr node, const wid // getLayeredXMLNode() //----------------------------------------------------------------------------- bool LLUICtrlFactory::getLayeredXMLNode(const std::string &xui_filename, LLXMLNodePtr& root, - LLDir::ESkinConstraint constraint, bool cacheable) + LLDir::ESkinConstraint constraint) { LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; std::vector<std::string> paths = @@ -169,7 +169,7 @@ bool LLUICtrlFactory::getLayeredXMLNode(const std::string &xui_filename, LLXMLNo paths.push_back(xui_filename); } - return LLXMLNode::getLayeredXMLNode(root, paths, cacheable); + return LLXMLNode::getLayeredXMLNode(root, paths); } diff --git a/indra/llui/lluictrlfactory.h b/indra/llui/lluictrlfactory.h index 2e1cc75508..6e585abfc0 100644 --- a/indra/llui/lluictrlfactory.h +++ b/indra/llui/lluictrlfactory.h @@ -148,7 +148,7 @@ public: LLView* createFromXML(LLXMLNodePtr node, LLView* parent, const std::string& filename, const widget_registry_t&, LLXMLNodePtr output_node ); template<typename T> - static T* createFromFile(const std::string &filename, LLView *parent, const widget_registry_t& registry, bool cacheable = false) + static T* createFromFile(const std::string &filename, LLView *parent, const widget_registry_t& registry) { T* widget = NULL; @@ -156,7 +156,7 @@ public: { LLXMLNodePtr root_node; - if (!LLUICtrlFactory::getLayeredXMLNode(filename, root_node, LLDir::CURRENT_SKIN, cacheable)) + if (!LLUICtrlFactory::getLayeredXMLNode(filename, root_node)) { LL_WARNS() << "Couldn't parse XUI from path: " << instance().getCurFileName() << ", from filename: " << filename << LL_ENDL; goto fail; @@ -192,7 +192,7 @@ fail: static void createChildren(LLView* viewp, LLXMLNodePtr node, const widget_registry_t&, LLXMLNodePtr output_node = NULL); static bool getLayeredXMLNode(const std::string &filename, LLXMLNodePtr& root, - LLDir::ESkinConstraint constraint = LLDir::CURRENT_SKIN, bool cacheable = false); + LLDir::ESkinConstraint constraint=LLDir::CURRENT_SKIN); private: //NOTE: both friend declarations are necessary to keep both gcc and msvc happy diff --git a/indra/llui/llxuiparser.cpp b/indra/llui/llxuiparser.cpp index 6209058875..f8d4a61721 100644 --- a/indra/llui/llxuiparser.cpp +++ b/indra/llui/llxuiparser.cpp @@ -28,7 +28,6 @@ #include "llxuiparser.h" -#include "lldir.h" #include "llxmlnode.h" #include "llfasttimer.h" #ifdef LL_USESYSTEMLIBS @@ -45,7 +44,6 @@ #include "lluicolor.h" #include "v3math.h" - using namespace BOOST_SPIRIT_CLASSIC_NS; const S32 MAX_STRING_ATTRIBUTE_SIZE = 40; @@ -1399,17 +1397,36 @@ bool LLSimpleXUIParser::readXUI(const std::string& filename, LLInitParam::BaseBl mCurReadDepth = 0; setParseSilently(silent); - std::string xml = gDirUtilp->getFileContents(filename); - if (xml.empty()) + ScopedFile file(filename, "rb"); + if( !file.isOpen() ) { LL_WARNS("ReadXUI") << "Unable to open file " << filename << LL_ENDL; XML_ParserFree( mParser ); return false; } + S32 bytes_read = 0; + + S32 buffer_size = file.getRemainingBytes(); + void* buffer = XML_GetBuffer(mParser, buffer_size); + if( !buffer ) + { + LL_WARNS("ReadXUI") << "Unable to allocate XML buffer while reading file " << filename << LL_ENDL; + XML_ParserFree( mParser ); + return false; + } + + bytes_read = (S32)fread(buffer, 1, buffer_size, file.mFile); + if( bytes_read <= 0 ) + { + LL_WARNS("ReadXUI") << "Error while reading file " << filename << LL_ENDL; + XML_ParserFree( mParser ); + return false; + } + mEmptyLeafNode.push_back(false); - if (!XML_Parse(mParser, xml.data(), (int)xml.size(), true)) + if( !XML_ParseBuffer(mParser, bytes_read, true ) ) { LL_WARNS("ReadXUI") << "Error while parsing file " << filename << LL_ENDL; XML_ParserFree( mParser ); |