[libxml++] Node::find(): Revert some of my previous change because it breaks some code.



commit de06ad4580fa70b661de2cd0f7c542813a8c63f4
Author: Murray Cumming <murrayc murrayc com>
Date:   Sun Jun 13 23:11:30 2010 +0200

    Node::find(): Revert some of my previous change because it breaks some code.
    
    * libxml++/nodes/node.cc: find_impl(): Restore the previous behaviour,
    because the strange use of _private only seems to happen sometimes.

 ChangeLog              |    7 +++++++
 libxml++/nodes/node.cc |   12 +++++++-----
 2 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f53feb2..b07a8d0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2010-06-13  Murray Cumming  <murrayc murrayc com>
 
+	Node::find(): Revert some of my previous change because it breaks some code.
+
+	* libxml++/nodes/node.cc: find_impl(): Restore the previous behaviour, 
+	because the strange use of _private only seems to happen sometimes.
+
+2010-06-13  Murray Cumming  <murrayc murrayc com>
+
 	Node::find(): Cope with weird use of _private in xmlNodeSet.
 
 	* libxml++/nodes/node.cc: The xmlNodeSet seems to contain extra xmlNodes that 
diff --git a/libxml++/nodes/node.cc b/libxml++/nodes/node.cc
index fe2cf38..bdbc2c2 100644
--- a/libxml++/nodes/node.cc
+++ b/libxml++/nodes/node.cc
@@ -284,13 +284,15 @@ static NodeSet find_impl(xmlXPathContext* ctxt, const Glib::ustring& xpath)
     {
       xmlNode* cnode = xmlXPathNodeSetItem(nodeset, i);
 
-      // TODO: It is _very_ strange and undocumented that _private contains a 
-      // pointer to the actual xmlNode (which has the C++ instance in _private, which we set),
-      // Maybe libxml abuses xmlNode::_private.
+      // Usually, this cnode is one that was provided to on_libxml_construct(),
+      // so we have already created a C++ Node and set it in _private.
+      // TODO: But sometimes the xmlNode::_private contains a 
+      // pointer to the actual xmlNode (which has the Node* in _private),
+      // Maybe libxml abuses xmlNode::_private, but only sometimes.
       // I only discovered this through experimentation. murrayc.
       // See bug https://bugzilla.gnome.org/show_bug.cgi?id=386013
-      xmlNode* cnodeReal = static_cast<xmlNode*>(cnode->_private); //libxml creates a C++ instance for us here.
-      Node* cppNode = static_cast<Node*>(cnodeReal->_private); //libxml creates a C++ instance for us here.
+      xmlNode* cnodeReal = cnode; //static_cast<xmlNode*>(cnode->_private);
+      Node* cppNode = static_cast<Node*>(cnodeReal->_private);
       nodes.push_back(cppNode);
     }
   }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]