Ticket #14488 (closed defect: fixed)
wxFileSystemWatcher::AddTree and RemoveTree fixes
| Reported by: | dghart | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 2.9.5 |
| Component: | base | Version: | 2.9-svn |
| Keywords: | wxFileSystemWatcher | Cc: | |
| Blocked By: | Patch: | yes | |
| Blocking: | 14544, 14544, 14544, 14544, 14544, 14544, 14544, 14544, 14544, 14544, 14544 |
Description
This is a continuation of #14480, which left FileSystemWatcherTestCase failing in wxMSW. The problem was that, unless there's a passed filespec, wxMSW adds just a single, recursively acting, watch on the 'trunk' folder. I've fixed the test to account for this.
That revealed a different problem with fswatcher in wxMSW: removing a watch used the generic RemoveTree(), which uses RemoveTraverser to remove those watches which were never created. That made the 'fswatcher' sample assert (well, unless it was built with g++/mingw). This is now 'fixed' as part of the solution to the next problem (but see below). After all this I noticed 12847#comment:19. I think I've inadvertently fixed item 2.
While doing this, I realised that there was a different problem with AddTree(): it takes an optional filespec parameter, watching (in theory) only matching files. This had two problems:
1) It still watched all subdirs. At least with inotify, that meant that all the contained files were watched, whatever their ext. I've fixed this by not watching dirs unless they too match the filespec (which would be possible though unusual). You may feel that it would be better never to watch dirs if there's a filespec; if so I'll change the patch.
2) RemoveTree() knew nothing of filespecs, so always removed too much and asserted. I've fixed this by storing any filespec in wxFSWatchInfo, so it's available on removal. This also made it easy to distinguish between the different wxMSW AddTree() methods.
With this patch wxGTK AddTree() and RemoveTree() now work correctly, whether or not there's a filespec (as ever, untested on wxMac). I've added a new section in FileSystemWatcherTestCase to test for this. I've also uploaded a temporary diff to the fswatcher sample if you wish to test that.
There's still a problem with wxMSW. If there's a passed filespec, wxMSW uses the generic AddTree() to add the matching files. However it doesn't currently _support_ watching files, so this will fail with a wxLogError from src/msw/fswatcher.cpp:144. I've therefore disabled that section of the FileSystemWatcherTestCase.
In summary: wxGTK now works (except for links). wxMSW is no worse than before, and one bug is partially fixed. FileSystemWatcherTestCase no longer fails on wxMSWin, but hits the "Unable to dequeue completion packet" issue mentioned in #13294.
I'll add a doc patch for wxFileSystemWatcher::AddTree once it's decided how it should deal with subdirs; I'll mention the wxMSW issues too.

