summaryrefslogtreecommitdiff
path: root/indra/llxml
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2024-05-07 20:44:53 +0300
committerAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2024-05-08 00:56:41 +0300
commitad6425173900855852b8c8437cc88120ea46cc53 (patch)
treeccee27dd7c9846cf7fdfd4f7695bb7c23968394b /indra/llxml
parentf9473e8afcb624cc1b101195bf15943ec372b56f (diff)
viewer#1420 Fixed names not showing in Chat
Save node prior to calling updateDefault
Diffstat (limited to 'indra/llxml')
-rw-r--r--indra/llxml/llxmlnode.cpp46
-rw-r--r--indra/llxml/llxmlnode.h16
2 files changed, 43 insertions, 19 deletions
diff --git a/indra/llxml/llxmlnode.cpp b/indra/llxml/llxmlnode.cpp
index 627e99a1e6..dc60b1aa66 100644
--- a/indra/llxml/llxmlnode.cpp
+++ b/indra/llxml/llxmlnode.cpp
@@ -137,19 +137,19 @@ LLXMLNode::LLXMLNode(const LLXMLNode& rhs) :
}
// returns a new copy of this node and all its children
-LLXMLNodePtr LLXMLNode::deepCopy()
+LLXMLNodePtr LLXMLNode::deepCopy() const
{
LLXMLNodePtr newnode = LLXMLNodePtr(new LLXMLNode(*this));
if (mChildren.notNull())
{
- for (LLXMLChildList::iterator iter = mChildren->map.begin();
+ for (LLXMLChildList::const_iterator iter = mChildren->map.begin();
iter != mChildren->map.end(); ++iter)
{
LLXMLNodePtr temp_ptr_for_gcc(iter->second->deepCopy());
newnode->addChild(temp_ptr_for_gcc);
}
}
- for (LLXMLAttribList::iterator iter = mAttributes.begin();
+ for (LLXMLAttribList::const_iterator iter = mAttributes.begin();
iter != mAttributes.end(); ++iter)
{
LLXMLNodePtr temp_ptr_for_gcc(iter->second->deepCopy());
@@ -653,10 +653,12 @@ bool LLXMLNode::updateNode(
static std::map<std::string, LLXMLNodePtr> sXMLCache;
static LLSharedMutex sXMLCacheMutex;
-static void saveToCache(const std::string& filename, LLXMLNodePtr& node)
+static void saveToCache(const std::string& filename, const LLXMLNodePtr& node)
{
+ LLXMLNodePtr node_copy = node->deepCopy();
+
LLExclusiveMutexLock lock(&sXMLCacheMutex);
- sXMLCache.emplace(filename, node.notNull() ? node->deepCopy() : nullptr);
+ sXMLCache.emplace(filename, node_copy);
}
static bool loadFromCache(const std::string& filename, LLXMLNodePtr& node)
@@ -665,8 +667,8 @@ static bool loadFromCache(const std::string& filename, LLXMLNodePtr& node)
auto it = sXMLCache.find(filename);
if (it == sXMLCache.end())
return false;
- node = it->second.notNull() ? it->second->deepCopy() : nullptr;
- return node.notNull();
+ node = it->second->deepCopy();
+ return true;
}
// static
@@ -676,7 +678,11 @@ bool LLXMLNode::parseFile(const std::string& filename, LLXMLNodePtr& node, LLXML
if (cacheable)
{
if (loadFromCache(filename, node))
+ {
+ node->setDefault(defaults_tree);
+ node->updateDefault();
return true;
+ }
}
std::string xml = gDirUtilp->getFileContents(filename);
@@ -684,12 +690,14 @@ bool LLXMLNode::parseFile(const std::string& filename, LLXMLNodePtr& node, LLXML
{
LL_WARNS("XMLNode") << "no XML file: " << filename << LL_ENDL;
}
- else if (parseBuffer(xml.data(), xml.size(), node, defaults_tree))
+ else if (parseBuffer(xml.data(), xml.size(), node))
{
if (cacheable)
{
saveToCache(filename, node);
}
+ node->setDefault(defaults_tree);
+ node->updateDefault();
return true;
}
@@ -699,10 +707,25 @@ bool LLXMLNode::parseFile(const std::string& filename, LLXMLNodePtr& node, LLXML
// static
bool LLXMLNode::parseBuffer(
+ const char* buffer,
+ U32 length,
+ LLXMLNodePtr& node,
+ LLXMLNode* defaults)
+{
+ if (parseBuffer(buffer, length, node))
+ {
+ node->setDefault(defaults);
+ node->updateDefault();
+ return true;
+ }
+ return false;
+}
+
+// static
+bool LLXMLNode::parseBuffer(
const char* buffer,
U32 length,
- LLXMLNodePtr& node,
- LLXMLNode* defaults)
+ LLXMLNodePtr& node)
{
// Init
XML_Parser my_parser = XML_ParserCreate(NULL);
@@ -739,9 +762,6 @@ bool LLXMLNode::parseBuffer(
LLXMLNode *return_node = file_node->mChildren->map.begin()->second;
- return_node->setDefault(defaults);
- return_node->updateDefault();
-
node = return_node;
return true;
}
diff --git a/indra/llxml/llxmlnode.h b/indra/llxml/llxmlnode.h
index 32aee057ed..e09c89c543 100644
--- a/indra/llxml/llxmlnode.h
+++ b/indra/llxml/llxmlnode.h
@@ -121,7 +121,7 @@ public:
LLXMLNode(const char* name, bool is_attribute);
LLXMLNode(LLStringTableEntry* name, bool is_attribute);
LLXMLNode(const LLXMLNode& rhs);
- LLXMLNodePtr deepCopy();
+ LLXMLNodePtr deepCopy() const;
bool isNull();
@@ -135,11 +135,11 @@ public:
LLXMLNodePtr& node,
LLXMLNode* defaults_tree,
bool cacheable = false);
- static bool parseBuffer(
- const char* buffer,
- U32 length,
- LLXMLNodePtr& node,
- LLXMLNode* defaults);
+ static bool parseBuffer(
+ const char* buffer,
+ U32 length,
+ LLXMLNodePtr& node,
+ LLXMLNode* defaults);
static bool parseStream(
std::istream& str,
LLXMLNodePtr& node,
@@ -290,6 +290,10 @@ public:
protected:
bool removeChild(LLXMLNode* child);
+ static bool parseBuffer(
+ const char* buffer,
+ U32 length,
+ LLXMLNodePtr& node);
public:
std::string mID; // The ID attribute of this node