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

QDirListing::const_iterator copy semantics

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.8
    • Core: I/O
    • None
    • All
    • 29dfcc240 (dev), 46ec49894 (6.8)

    Description

      QDirListing::const_iterator seems to point to a common instance, hence changing an iterator changes other instances:

         QDirListing l(QDir::homePath());
         auto it1 = l.begin();
          qDebug() << "it1=" << it1->absoluteFilePath();
          auto it2 = it1++;
          qDebug("it2 = it1++");
          qDebug() << "it1=" << it1->absoluteFilePath();
          qDebug() << "it2=" << it2->absoluteFilePath();
      

      produces

      Qt 6.8.0 (x86_64-little_endian-lp64 shared (dynamic) debug build; by GCC 13.2.0)
      it1= "/home/user/Public"
      it2 = it1++
      it1= "/home/user/tmp"
      it2= "/home/user/tmp"
      

      it2 should still point to "/home/user/Public".

      This was noticed during creating the Python bindings, here I need to emulate Java-Style iterators with next()/value() for the Python iterable protocol.

      Attachments

        1. qtbug125512.zip
          0.8 kB
          Friedemann Kleint

        Issue Links

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

          Activity

            People

              ahmad.samir Ahmad Samir
              kleint Friedemann Kleint
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes