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

QFileSystemModel pauses, delays or slows down for some seconds when reading phantom floppy drive

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • Not Evaluated
    • None
    • 4.8.0
    • Core: Item Models
    • None

    Description

      The problem is QFileSystemModel can cause slow down when opening a dialog that uses the model or anywhere in the code whenever the event loop has just started.

      As seen using the code example, if you comment out the line that says fsModel->setRootPath( "" ) and run the application, it starts immediately. If you leave the line and run the app, it pauses for 5 to 10 seconds (on Q6600 or i7) before the main window renders as if the main event loop has been blocked during that time.

      The fsModel->setRootPath( "" ) is required so that the file system model can sort properly like the solution suggested in QTBUG-12934 - QFileSystemModel is not correctly sorted.

      The crux of the issue is on some systems even new ones where the BIOS has floppy enabled and Windows 7 and buddies are installed, the floppy drive A:/ exists in Windows Explorer even though the hardware does not exist on the PC and when the event loop starts, QFileSystemModel stalls when it tries to do anything using QFileInfo. This is because internally, the watcher calls QFileSystemModelPrivate::_q_fileSystemChanged when enumerating My Computer and eventually calls QFileInfo with A:/ .

      Calls in QFileInfo (e.g. isRoot(), exists(), etc.) eventually leads to QFileSystemEngine::fillMetaData in qfilesystemengine_win.cpp where the Win32 call ::GetFileAttributesEx() where it stalls on A:/ .

      It is sort of Windows' fault but perhaps the function could be coded more robust in that if it is a removable device and has no media then use fallback metadata?

      This problem may have the same relationship as QTBUG-1892 - QFileDialog still spins floppy drive.

      At the moment, only way to fix this problem without fixing Qt is either users goto their devices in Device Manager and disable the floppy drive, or coders use shared QFileSystemModel in which it is initialised during start up to avoid pauses. However, this limits the desirabilities in having a nice throw away model every time a dialog is spawned.

      Attachments

        1. qt-testcode.zip
          799 kB
          Jason Moey

        Issue Links

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

          Activity

            People

              vhilshei Volker Hilsheimer
              jmoey Jason Moey
              Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes