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

    • Type: Bug
    • Status: Closed
    • Priority: P1: Critical
    • Resolution: Done
    • Affects Version/s: 5.9.1
    • Fix Version/s: 5.9.4
    • Component/s: Widgets: Itemviews
    • Labels:
      None
    • Commits:
      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_diag.diff
          3 kB
        3. qtbug64147_stack.txt
          8 kB
        4. qtbug64147.diff
          0.9 kB

          Issue Links

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

            Activity

              People

              • Assignee:
                kleint Friedemann Kleint
                Reporter:
                philippe Philippe Goutier
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes