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

QFileSystemModel fails to locate a host from the root node's visible children

    XMLWordPrintable

    Details

    • Platform/s:
      Windows
    • Commits:
      e253a30238ed1a93877780428c035d3b7a53e22a (qt/qtbase/dev) b67bbed1965ce9931a6280daeb1d2a05a3c905a5 (qt/qtbase/6.0) 5369a28df650c8f09e30dbf5c23746e103a87e7f (qt/qtbase/6.1) 95694109e9ec8200239f9a9aae7a789fe565c5e9 (qt/tqtc-qtbase/5.15)

      Description

      When I was investigating QTBUG-71700, I discovered this issue.

      In QFileSystemModel, in some cases the hostname in a UNC path is converted to lower case and stored in the root node's visibleChildren.When QFileSystemModel sets the UNC path as the root path, it tries to get the index of the host, but it didn't convert the hostname to lower case before getting the row number, which resulted in the host not found in the root node's visible children. As a result, it returns an invalid index.
      Code to duplicate this issue:

      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          QFileSystemModel model;
          QModelIndex index = model.setRootPath(QLatin1String("//<server-in-lower-case>"));
          index = model.setRootPath(QLatin1String("//<server>"));
          if (index.isValid())
              qDebug() << model.rootPath() << model.filePath(index) << index.row();
          else
              qDebug() << "Invalid index";
          return 0;
      }
      

      output:

      "5.12.0 windows" host= "host"
      
      rp= "\\\\host"
      rootPath= "//host" file path= "//host" row= 0
      rp= "\\\\HOST"
      Invalid index
      

        Attachments

        1. qtbug71701.zip
          2 kB
        2. testapp.7z
          0.9 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            heimrich Karsten Heimrich
            Reporter:
            dongmei Dongmei Wang
            PM Owner:
            Vladimir Minenko Vladimir Minenko
            RnD Owner:
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: