summaryrefslogtreecommitdiff
path: root/unoxml
diff options
context:
space:
mode:
authorJoachim Lingner <jl@openoffice.org>2010-08-05 16:09:11 +0200
committerJoachim Lingner <jl@openoffice.org>2010-08-05 16:09:11 +0200
commite3aa7efeb72001b0264947d962d0bf29077c5f0c (patch)
tree239d3fbef69e1e9e28586aa6ede034568dc6a60a /unoxml
parent1c5011a89faf5cc8990e6e7b0cff3922a7fd9888 (diff)
jl157 #161910# inserting comments
Diffstat (limited to 'unoxml')
-rw-r--r--unoxml/source/dom/node.cxx13
1 files changed, 13 insertions, 0 deletions
diff --git a/unoxml/source/dom/node.cxx b/unoxml/source/dom/node.cxx
index 41d7c253d534..fb4a6bf508b3 100644
--- a/unoxml/source/dom/node.cxx
+++ b/unoxml/source/dom/node.cxx
@@ -52,6 +52,7 @@
#include <algorithm>
namespace {
+//see CNode::remove
struct NodeMutex: public ::rtl::Static<osl::Mutex, NodeMutex> {};
}
@@ -136,6 +137,17 @@ namespace DOM
void CNode::remove(const xmlNodePtr aNode)
{
+ //Using the guard here protects against races when at the same time
+ //CNode::get() is called. This fix helps in many cases but is still
+ //incorrect. remove is called from ~CNode. That is, while the object
+ //is being destructed it can still be obtained by calling CNode::get().
+ //Another bug currently prevents the correct destruction of CNodes. So
+ //the destructor is rarely called.
+ //
+ //Doing this right would probably mean to store WeakReferences in the
+ //map and also guard oder functions. To keep the risk at a minimum
+ //we keep this imperfect fix for the upcoming release and fix it later
+ //properly (http://qa.openoffice.org/issues/show_bug.cgi?id=113682)
::osl::MutexGuard guard(NodeMutex::get());
nodemap_t::iterator i = CNode::theNodeMap.find(aNode);
if (i != CNode::theNodeMap.end())
@@ -151,6 +163,7 @@ namespace DOM
CNode* pNode = 0;
if (aNode == NULL)
return 0;
+ //see CNode::remove
::osl::MutexGuard guard(NodeMutex::get());
//check whether there is already an instance for this node
nodemap_t::const_iterator i = CNode::theNodeMap.find(aNode);