Ticket #14544 (closed defect: fixed)
wxFileSystemWatcher: More fixes
|Reported by:||dghart||Owned by:|
|Blocked By:||14488, 14488, 14488, 14488, 14488, 14488, 14490, 14490, 14490, 14542, 14542, 14542, 14542, 14542, 14542, 14542, 14542, 14542, 14543, 14543, 14543||Patch:||yes|
This is (I hope) the last of a series of wxFileSystemWatcher patches. The patches should be applied in this order, and on top of those from #14488, #14490, #14542 and #14543. (If you prefer I could instead create a Grand Unified Patch...)
First a reversion. In an earlier patch I tried to fix wxFileSystemWatcher:AddTree by having it watch files as well as dirs; this was partly because RemoveTree() was trying to remove those watches.
This was a mistake. Doing so is 1) unnecessary: the watch on the parent dir can manage its contents perfectly well by itself; and 2) Add() doesn't do this, and the difference in behaviour caused problems in dealing with creation/deletion in a watched tree. RevertAddTreeFiles.diff reverts this, and also removes from RemoveTree() the attempt to remove the unwatched files.
Next a correction to the #14480/ fix. If a watched file is deleted, the first event to arrive is likely to be IN_IGNORED. At that stage the wd won't be in m_staleDescriptors, so trying to remove it causes an assert. StaleDescriptors.diff fixes this.
#14488 tried to make passing a file-mask happen at AddTree() level. This no longer works now that files themselves aren't watched. Instead Filespec.diff devolves it down to wxFSWatcherImpl::ProcessNativeEvent, which is much more flexible. This also avoids the issue raised in #14488 about whether to watch non-matching dirs. Filespecs now work well in wxGTK, and afaict also in wxMSW.
The current code lets the user add and remove watches, but ignores the possibility that a watched dir may be added/removed by the filesystem itself. CreateDelete.diff fixes this.
Finally, SampleAndTest.diff makes the sample notice if the directory it's watching is deleted or renamed, notifies the user, and removes it from the wxListView. This prevents the sample asserting (at least in wxGTK) when it tries to remove it later. It also updates FileSystemWatcherTestCase to work with the new code. I don't know if this will now fail on wxMac; if so, #if defined(UNIX) will need to be changed.
This patch series make wxFileSystemWatcher work well in wxGTK, without adversely affecting wxMSW.