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

File changes not detected by QFileSystemModel

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • P2: Important
    • None
    • 4.8.x, 5.5.0
    • Widgets: Itemviews
    • None
    • Windows 7 and Linux

    Description

      Using PyQt and Python I came across the following issue:

      1. Set up a QFileSystemModel, call setRootPath() and hook up to the dataChanged signal.

      2. Open a new file from Python and write some text into it. Then close it.
      Reopen the file in append mode and write some more text into it. Then close it.

      3. Open a file in an external editor. Write some stuff. Save. Write more stuff.

      4. Save.

      If you do (3), the dataChanged signal is NOT emitted. However, if you do (4), the dataChanged signal IS emitted.

      Here are some more general observations:

      The basic problem is that QFileSystemModel apparently does not monitor file changes in a proper way:

      Case 1 (Ubuntu):

      1) Run the script in the background as 'python fsm.py &'
      2) Launch a Python prompt in the same directory where the script was started in
      3) Type:

      f = open('foo.txt', 'w')
      f.write('eyeyehydhdhdhdhdhdhhdhdshshs')
      f.close()

      The new file IS detected by the QFileSystemModel when open() is called. However, the file modifications caused by f.write() and f.close() are NOT detected.

      Case 2 (Ubuntu):

      1) While the script 'fsm.py' is still running, open a new file using some external editor (gedit, emacs, etc.)

      2) Write some stuff and save

      In this case, both the new file and the modification are detected. This is the first thing I don't understand. How come Python IO is not detected but IO from an editor is?

      Case 3 (Ubuntu):

      Using Ubuntu: I launch the Nautilus file browser and repeat step 1-3 from Case 1-2. Then both the new file and the modification are detected by nautilus. So there Python generated IO is monitored, but apparently using GNOME file monitoring system.

      Case 1 (Windows 7):

      Same behavior.

      Case 2 (Windows 7):

      If Notepad or Wordpad is used, file modifications are NOT detected. If GVim 7.3 is used, file modifications ARE detected.

      Case 3 (Windows 7):

      Launching the native Windows 7 file browser, all mods from Case 1-2 are detected.

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            repoman Mads Ipsen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes