diff options
Diffstat (limited to 'unoxml/source/dom/node.cxx')
-rw-r--r-- | unoxml/source/dom/node.cxx | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/unoxml/source/dom/node.cxx b/unoxml/source/dom/node.cxx index 2a03896502a9..fb4a6bf508b3 100644 --- a/unoxml/source/dom/node.cxx +++ b/unoxml/source/dom/node.cxx @@ -43,13 +43,19 @@ #include "attr.hxx" #include <com/sun/star/xml/sax/FastToken.hpp> - +#include "rtl/instance.hxx" +#include "osl/mutex.hxx" #include "../events/eventdispatcher.hxx" #include "../events/mutationevent.hxx" #include <boost/bind.hpp> #include <algorithm> +namespace { +//see CNode::remove + struct NodeMutex: public ::rtl::Static<osl::Mutex, NodeMutex> {}; +} + namespace DOM { void pushContext(Context& io_rContext) @@ -131,6 +137,18 @@ 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()) { @@ -145,7 +163,8 @@ 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); if (i != CNode::theNodeMap.end()) |