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

        Issue Links

          For Gerrit Dashboard: QTBUG-125512
          # Subject Branch Project Status CR V

          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