X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6eef5763a81cf58ba9ca4f6adcaa996d263258a0..64ea838d8f4d1853b7d850db93ee565e901d099a:/src/common/fswatchercmn.cpp diff --git a/src/common/fswatchercmn.cpp b/src/common/fswatchercmn.cpp index 89cb09e4a8..14c16bb543 100644 --- a/src/common/fswatchercmn.cpp +++ b/src/common/fswatchercmn.cpp @@ -198,8 +198,14 @@ bool wxFileSystemWatcherBase::AddTree(const wxFileName& path, int events, }; wxDir dir(path.GetFullPath()); + // Prevent asserts or infinite loops in trees containing symlinks + int flags = wxDIR_DIRS; + if ( !path.ShouldFollowLink() ) + { + flags |= wxDIR_NO_FOLLOW; + } AddTraverser traverser(this, events, filespec); - dir.Traverse(traverser, filespec); + dir.Traverse(traverser, filespec, flags); // Add the path itself explicitly as Traverse() doesn't return it. AddAny(path.GetPathWithSep(), events, wxFSWPath_Tree, filespec); @@ -260,8 +266,17 @@ bool wxFileSystemWatcherBase::RemoveTree(const wxFileName& path) #endif // __WINDOWS__ wxDir dir(path.GetFullPath()); + // AddTree() might have used the wxDIR_NO_FOLLOW to prevent asserts or + // infinite loops in trees containing symlinks. We need to do the same + // or we'll try to remove unwatched items. Let's hope the caller used + // the same ShouldFollowLink() setting as in AddTree()... + int flags = wxDIR_DIRS; + if ( !path.ShouldFollowLink() ) + { + flags |= wxDIR_NO_FOLLOW; + } RemoveTraverser traverser(this, filespec); - dir.Traverse(traverser, filespec); + dir.Traverse(traverser, filespec, flags); // As in AddTree() above, handle the path itself explicitly. Remove(path);