diff options
author | Kurt Zenker <kz@openoffice.org> | 2010-08-18 12:47:07 +0200 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2010-08-18 12:47:07 +0200 |
commit | 59cbec669aca271287b31bc891713613af443b67 (patch) | |
tree | f97bb8bab1345204214108e397dd35898724fe61 | |
parent | 584fdc1a31a0a04e02ec8806c334fd0b0bfd4a58 (diff) | |
parent | e3aa7efeb72001b0264947d962d0bf29077c5f0c (diff) |
CWS-TOOLING: integrate CWS jl157
Notes
split repo tag: filters_ooo/OOO330_m5
-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()) |