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

QDirListing::const_iterator copy semantics

XMLWordPrintable

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

      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.

        1. qtbug125512.zip
          0.8 kB
          Friedemann Kleint
        For Gerrit Dashboard: QTBUG-125512
        # Subject Branch Project Status CR V

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

              Created:
              Updated:

                There are no open Gerrit changes