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

Windows: assert in QFileSystemModel when setting the same root path 2 times in a row

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.9.4
    • 5.9.1
    • Widgets: Itemviews
    • None
    • fcbaa8ec385e796c18cf317e8f364bd8e3c2538b (qtbase/5.9, 9.1.2018, 5.9.4)

    Description

      On windows, the following code causes an assert in QFileSystemModelPrivate::addNode. This is just an easy way to reproduce a problem that can have severe consequences.
      For instance, I use a QSortFilterProxyModel::filterAcceptsRow and in certain cases, my overriden function is called recursively, causing sometimes a crash.

      #include <QApplication>
      #include <qfilesystemmodel>
      int main(int argc, char* argv[])
      {
      QApplication app(argc, argv);
      QFileSystemModel model;
      model.setRootPath(QLatin1String("\\\\MACPRO\\Data"));
      model.setRootPath(QLatin1String("\\\\MACPRO\\Data"));
      }
      

      The root of the problem is in QFileSystemModelPrivate::node (and maybe elsewhere) where the case sensitivity of the file system is not taken in account,

      There is this line:

       if (!root.children.contains(host.toLower())) { 

      while in other parts of the file, the case sensitivity is taken into account, eg.

      if ((parent->children.count() == 0)
          || (parent->caseSensitive()
              && parent->children.value(element)->fileName != element)
          || (!parent->caseSensitive()
              && parent->children.value(element)->fileName.toLower() != element.toLower()))
      

      [EDIT] there are other reports that seem to be related. But here my little sample is very easy to test.
      QTBUG-21278, QTBUG-31103, QTBUG-61786, QTBUG-17750

      Attachments

        1. patch.txt
          0.8 kB
        2. qtbug64147_stack.txt
          8 kB
        3. qtbug64147.diff
          0.9 kB
        4. qtbug64147_diag.diff
          3 kB

        Issue Links

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

          Activity

            People

              kleint Friedemann Kleint
              jirauser26727 user-04d21 (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes