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

QFileSystemWatcher fails to remove directory if its child file has been added (Windows)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 4.8.4
    • None
    • Windows XP (32bit), NTFS

    Description

      removePath("C:/test") fails if its child file, e.g. "C:/test/file", has been added.
      And the directory no longer be watched again.

      Example:

      QFileSystemWatcher watcher;
      
      qDebug() << "==== add ====";
      watcher.addPath("C:/test");
      watcher.addPath("C:/test/file");
      qDebug() << "watching:" << watcher.files() << watcher.directories();
      
      qDebug() << "==== remove ====";
      watcher.removePath("C:/test");
      watcher.removePath("C:/test/file");
      qDebug() << "watching:" << watcher.files() << watcher.directories();
          // still "C:/test" is included in watcher.directories(), but it seems not
          // actually watched.
      
      qDebug() << "==== add again ====";
      watcher.addPath("C:/test");
          // fails
      watcher.addPath("C:/test/file");
      qDebug() << "watching:" << watcher.files() << watcher.directories();
      

      Output:

      Z:\work\qfswatchwinbug>debug\qfswatchwinbug.exe
      ==== add ====
      watching: ("C:/test/file") ("C:/test")
      ==== remove ====
      watching: () ("C:/test")
      ==== add again ====
      QFileSystemWatcher: failed to add paths: C:/test
      watching: ("C:/test/file") ("C:/test")
      

      I suspect that the existing thread->handleForDir[absolutePath] (where absolutePath = "C:/test") is overwritten by addPath("C:/test/file") because flags is different.

      http://qt.gitorious.org/qt/qt/blobs/4.8/src/corelib/io/qfilesystemwatcher_win.cpp#line179

      Hope this helps.

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            yuja Yuya Nishihara
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes