Results 1 to 5 of 5

Thread: Broken QFileSystemWatcher in Qt 4.2.3 under Windows?

  1. #1
    Join Date
    Nov 2006
    Posts
    35
    Thanks
    25
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Broken QFileSystemWatcher in Qt 4.2.3 under Windows?

    I am using QFileSystemWatcher in my application to react on file changes of files in use that occur outside of my application.

    With Qt 4.2.3 I do not get the fileChanged signal anymore from the QFileSystemWatcher.

    Is this a bug? I searched http://www.trolltech.com/developer/task-tracker for QFileSystemWatcher but did not find anything on this issue.

    Thanks in advance,
    -Jens

    [EDIT]Note: Under Linux it works as expected so I assume it must be a bug with Qt for Windows.[/EDIT]
    Last edited by No-Nonsense; 21st March 2007 at 14:32. Reason: updated contents

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Broken QFileSystemWatcher in Qt 4.2.3 under Windows?

    Quote Originally Posted by No-Nonsense View Post
    With Qt 4.2.3 I do not get the fileChanged signal anymore from the QFileSystemWatcher.

    Is this a bug? I searched http://www.trolltech.com/developer/task-tracker for QFileSystemWatcher but did not find anything on this issue.
    Well, I gave it a shot and it works for me. Do you explicitly add the files to be monitored, not just directories?
    J-P Nurmi

  3. #3
    Join Date
    Nov 2006
    Posts
    35
    Thanks
    25
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Broken QFileSystemWatcher in Qt 4.2.3 under Windows?

    Quote Originally Posted by jpn View Post
    Well, I gave it a shot and it works for me. Do you explicitly add the files to be monitored, not just directories?
    Yes, I am adding files. I have a debug console to which I can dump the QFileSystemWacher::files() at any time. It contains the full path with filename and extension to the monitored files. When doing changes to these files ouside of my app (e.g. using notepad) the ::fileCanged(const QString & file) is not emitted (I have a qDebug to my debugging console that should show the filename).

    It worked before Qt 4.2.3, but I can not say for sure that the problem cam with this version. But it is working under correctly under Linux and another of my apps does have the same issue.

    I diffed QFileSystemWatcher 4.2.2 agains 4.2.3 and there were no changes for Windows so it must be some other thing... Funny is that it works in QDevelop (the IDE notices changes of files beeing edited).

    -Jens

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Broken QFileSystemWatcher in Qt 4.2.3 under Windows?

    Here's my test case. Once up and running, I modified main.cpp twice. It works with no problems for me with Notepad. On the other hand, Visual Studio seems to have it's own way for "editing" files (the file system watcher notices the file being removed).

    Qt Code:
    1. // main.cpp
    2. #include <QtCore>
    3. #include <QtDebug>
    4.  
    5. class Watcher : public QFileSystemWatcher
    6. {
    7. Q_OBJECT
    8.  
    9. public:
    10. Watcher()
    11. {
    12. addPath(QDir::current().filePath("main.cpp"));
    13. connect(this, SIGNAL(fileChanged(const QString&)), this, SLOT(fileChanged(const QString&)));
    14. qDebug() << "monitoring" << files();
    15. }
    16.  
    17. private slots:
    18. void fileChanged(const QString& path)
    19. {
    20. qDebug() << "fileChanged" << path;
    21. qDebug() << "-->" << files();
    22. }
    23. };
    24.  
    25. int main(int argc, char *argv[])
    26. {
    27. QCoreApplication a(argc, argv);
    28. Watcher w;
    29. return a.exec();
    30. }
    31.  
    32. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 


    Quote Originally Posted by Windows (notepad)
    monitoring ("D:/Temp/Watcher/main.cpp")
    fileChanged "D:/Temp/Watcher/main.cpp"
    --> ("D:/Temp/Watcher/main.cpp")
    fileChanged "D:/Temp/Watcher/main.cpp"
    --> ("D:/Temp/Watcher/main.cpp")
    Quote Originally Posted by Windows (vs)
    monitoring ("D:/Temp/Watcher/main.cpp")
    fileChanged "D:/Temp/Watcher/main.cpp"
    --> ()
    Quote Originally Posted by Linux
    monitoring ("/home/jpn/temp/watcher/main.cpp")
    fileChanged "/home/jpn/temp/watcher/main.cpp"
    --> ("/home/jpn/temp/watcher/main.cpp")
    fileChanged "/home/jpn/temp/watcher/main.cpp"
    --> ("/home/jpn/temp/watcher/main.cpp")
    J-P Nurmi

  5. The following user says thank you to jpn for this useful post:

    No-Nonsense (28th March 2007)

  6. #5
    Join Date
    Nov 2006
    Posts
    35
    Thanks
    25
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Broken QFileSystemWatcher in Qt 4.2.3 under Windows?

    Quote Originally Posted by jpn View Post
    Here's my test case. Once up and running, I modified main.cpp twice. It works with no problems for me with Notepad. On the other hand, Visual Studio seems to have it's own way for "editing" files (the file system watcher notices the file being removed).
    Thanks! Your demonstration works without any problems on my Windows with Qt 4.2.3. I have to take a look if the filename added to the QFileSystemWatcher is really ok in my app. But I assue it is, as my app gets correctly notified under Linux...

    -Jens

Similar Threads

  1. converting unix exe to windows binary
    By deekayt in forum General Programming
    Replies: 2
    Last Post: 17th September 2006, 01:00
  2. Qt and windows vista
    By munna in forum General Discussion
    Replies: 8
    Last Post: 11th January 2006, 22:33

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.