On Thu, 2004-05-06 at 18:47, Paolo Casarini wrote: > The problem you have found was already found in the past and fixed in > the gdome_xml_doc_mkref (gdome_xml_document.c, line 127) with a > workaround. I see, unfortunately the workaround didn't quite cover every case ;-) > For this reason I think that its better to fix the bug using the > gdome_xml_doc_mkref inside the gdome_xml_n_mkref also when > n->_private != NULL. Agreed, it's cleaner. I thereby attach a new patch based on this version of the fix. I've just moved down the check n->_private != NULL but the patch covers much more lines because indentation has changed a little all over the body of the function. If the patch seems reasonable to you I'll commit it right away. Thanks, --luca
Index: gdome-xml-node.c =================================================================== RCS file: /cvs/gnome/gdome2/libgdome/gdomecore/gdome-xml-node.c,v retrieving revision 1.76 diff -c -r1.76 gdome-xml-node.c *** gdome-xml-node.c 3 Oct 2003 15:53:33 -0000 1.76 --- gdome-xml-node.c 6 May 2004 17:20:58 -0000 *************** *** 162,184 **** return NULL; type = n->type; ! if (n->_private && type != XML_NAMESPACE_DECL) { ! result = (Gdome_xml_Node *)n->_private; ! result->refcnt++; ! } else { ! switch (type) { ! case XML_ELEMENT_NODE: ! case XML_TEXT_NODE: ! case XML_CDATA_SECTION_NODE: ! case XML_ENTITY_REF_NODE: ! case XML_PI_NODE: ! case XML_COMMENT_NODE: ! case XML_NOTATION_NODE: ! case XML_DOCUMENT_FRAG_NODE: ! case XML_ATTRIBUTE_NODE: ! case XML_ENTITY_DECL: /*libxml use this instead of XML_ENTITY_NODE*/ result = g_new (Gdome_xml_Node, 1); ! result->refcnt = 1; result->vtab = (GdomeNodeVtab *)gdome_xml_vtabs[n->type]; result->super.user_data = NULL; --- 162,184 ---- return NULL; type = n->type; ! switch (type) { ! case XML_ELEMENT_NODE: ! case XML_TEXT_NODE: ! case XML_CDATA_SECTION_NODE: ! case XML_ENTITY_REF_NODE: ! case XML_PI_NODE: ! case XML_COMMENT_NODE: ! case XML_NOTATION_NODE: ! case XML_DOCUMENT_FRAG_NODE: ! case XML_ATTRIBUTE_NODE: ! case XML_ENTITY_DECL: /*libxml use this instead of XML_ENTITY_NODE*/ ! if (n->_private) { ! result = (Gdome_xml_Node *)n->_private; ! result->refcnt++; ! } else { result = g_new (Gdome_xml_Node, 1); ! result->refcnt = 1; result->vtab = (GdomeNodeVtab *)gdome_xml_vtabs[n->type]; result->super.user_data = NULL; *************** *** 195,215 **** gdome_refdbg_addRef ((void *)result, GDOME_REFDBG_NODE); #endif gdome_treegc_addNode ((GdomeNode *)result); - - break; - case XML_DOCUMENT_TYPE_NODE: - case XML_DTD_NODE: - return (GdomeNode *)gdome_xml_dt_mkref ((xmlDtd *)n); - case XML_HTML_DOCUMENT_NODE: - case XML_DOCUMENT_NODE: - return (GdomeNode *)gdome_xml_doc_mkref ((xmlDoc *)n); - case XML_NAMESPACE_DECL: - return (GdomeNode *)gdome_xml_xpns_mkref ((xmlNs *)n); - default: - g_warning ("gdome_xml_n_mkref: invalid node type"); - break; } } return (GdomeNode *)result; } --- 195,215 ---- gdome_refdbg_addRef ((void *)result, GDOME_REFDBG_NODE); #endif gdome_treegc_addNode ((GdomeNode *)result); } + break; + case XML_DOCUMENT_TYPE_NODE: + case XML_DTD_NODE: + return (GdomeNode *)gdome_xml_dt_mkref ((xmlDtd *)n); + case XML_HTML_DOCUMENT_NODE: + case XML_DOCUMENT_NODE: + return (GdomeNode *)gdome_xml_doc_mkref ((xmlDoc *)n); + case XML_NAMESPACE_DECL: + return (GdomeNode *)gdome_xml_xpns_mkref ((xmlNs *)n); + default: + g_warning ("gdome_xml_n_mkref: invalid node type"); + break; } + return (GdomeNode *)result; }
Attachment:
signature.asc
Description: This is a digitally signed message part