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

QXmlStreamReader::characterOffset sometimes returns incorrect values

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.10
    • None

    Description

      Example:

      QString test = "<speak>PLAIN <say-as></say-as></speak>";
      QXmlStreamReader reader(test);
      QVector<int> offsets = {0, 0, 7, 13, 21, 30, 38};
      for (int i = 0; i < offsets.length(); i++) {
          if (offsets.at(i) != reader.characterOffset())
              qWarning() << "Wrong character offset. Is:"
                         << reader.characterOffset()
                         << "should be" << offsets.at(i);
          reader.readNext();
      }

      I think it is self explanatory.

      1. If there is no explicit start document element like "<?xml version=\"1.0\"?>" then  reader positions itself on "<s". Probably is probing for start of element, not founding it and not reverting back buffer pointer.
      2. Similar situation in case of characters token. It positions characterOffset on first "<" after text.

      Am I right expecting that characterOffset should be positioned before "<" if one uses readNext etc?

       

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            tolszak Tomasz Olszak
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes