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

QFileSystemWatcher cannot removePath() on files from watched directory

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Duplicate
    • Affects Version/s: 4.7.0
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      Win7

      Description

      If one adds both a directory and a file from this directory, the file cannot be removed from watch:

      #include <QtCore/QCoreApplication>
      #include <QFileSystemWatcher>
      #include <QDebug>
      #include <QStringList>
      
      int main(int argc, char *argv[])
      {
          QCoreApplication a(argc, argv);
      
          QFileSystemWatcher* w = new QFileSystemWatcher;
      
      
          w->addPath("D:\\Pictures\\16225777_500.jpg");
          w->addPath("D:\\Pictures");    // comment to "fix"
      
          qDebug()<<w->files();   // expected: ("D:\\Pictures\\16225777_500.jpg")
      
          w->removePath("D:\\Pictures");     // does not help!
          w->removePath("D:\\Pictures\\16225777_500.jpg");    //*** should remove the path
      
      
      
          qDebug()<<w->files();// ***unexpected: ("D:\\Pictures\\16225777_500.jpg")
      
          return a.exec();
      }
      
      

      If later the file is added again the unhelpful: "failed to add path" message appears, which by no means implies the path is already(still) included, making the bug even more annoying.

        Attachments

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

          Activity

            People

            Assignee:
            w00t Robin Burchell
            Reporter:
            mnaydenov Mihail Naydenov
            Votes:
            4 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes