Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-19422

QDomDocument::setContent later result in an access violation crash in some cases

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 4.7.3
    • XML: DOM
    • None
    • Windows 7
      Visual C++ 2010 Express

    Description

      The QDomDocument::setContent implementation reuses an existing QDomDocumentPrivate. This is a problem for nodes of the "old" document.
      Example code:

      QDomNode node; QDomNode::NodeType type; QString string;
      {
      QDomDocument doc;
      node = doc.appendChild(doc.createElement("element"));
      type = node.parentNode().nodeType(); // == DocumentNode
      string = node.ownerDocument().toString(); // == "<element/>"
      doc.setContent(QString("<other/>"));
      type = node.parentNode().nodeType(); // == DocumentNode
      string = node.ownerDocument().toString(); // == "<other/>" (but node has not been changed)
      }
      type = node.parentNode().nodeType(); // throws access violation

      Our current workaround to have no crash is:

      QDomNode node; QDomNode::NodeType type; QString string;
      {
      QDomDocument doc;
      node = doc.appendChild(doc.createElement("element"));
      type = node.parentNode().nodeType(); // == DocumentNode
      string = node.ownerDocument().toString(); // == "<element/>"
      doc = QDomDocument(); // currently needed to get no access violation
      doc.setContent(QString("<other/>"));
      type = node.parentNode().nodeType(); // == BaseNode
      string = node.ownerDocument().toString(); // == ""
      }
      type = node.parentNode().nodeType(); // == BaseNode (throws no exception)

      So with our workaround we get no access violation but can not access the ownerDocument after calling setContent.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            andiby Andreas Brzesowsky
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes