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

QFileSystemModel hasChildren and rowCount are not consistent

    XMLWordPrintable

Details

    Description

      void check(const QModelIndex &idx, QAbstractItemModel *model)
      {
        const bool hasChildren = model->hasChildren(idx);
        const int rowCount = model->rowCount(idx);
      
        if (hasChildren) {
            Q_ASSERT(rowCount > 0);
            QModelIndex ni = model->index(0, 0, idx);
            Q_ASSERT(ni.isValid());
            check(ni, model);
        } else {
            Q_ASSERT(rowCount == 0);
        }
      }
      
      int main(int argc, char **argv)
      {
        QApplication app(argc, argv);
      
        QFileSystemModel model;
        model.setRootPath(QDir::currentPath());
      
        check(QModelIndex(), &model);
      
        app.exec();
      }
      
      

      Attachments

        Issue Links

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

          Activity

            People

              Unassigned Unassigned
              stephen.kelly Stephen Kelly (Unused account) (Inactive)
              Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes