]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix bug in Unix wxFileSystemWatcher implementation when watch is deleted.
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 15 Oct 2012 01:09:49 +0000 (01:09 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 15 Oct 2012 01:09:49 +0000 (01:09 +0000)
Don't assert when removing a watch descriptor from the stale descriptors list.

See #14544.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72682 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/unix/fswatcher_inotify.cpp

index 481455ad6b9199e04cc48b6a5ccab427815dfae0..2349d4b9fc5ad4840924eed4d25fabc76cc7de79 100644 (file)
@@ -222,9 +222,15 @@ protected:
         {
             // It is now safe to remove it from the stale descriptors too, we
             // won't get any more events for it.
-            m_staleDescriptors.Remove(inevt.wd);
-            wxLogTrace(wxTRACE_FSWATCHER,
+            // However if we're here because a dir that we're still watching
+            // has just been deleted, its wd won't be on this list
+            const int pos = m_staleDescriptors.Index(inevt.wd);
+            if ( pos != wxNOT_FOUND )
+            {
+                m_staleDescriptors.RemoveAt(static_cast<size_t>(pos));
+                wxLogTrace(wxTRACE_FSWATCHER,
                        "Removed wd %i from the stale-wd cache", inevt.wd);
+            }
             return;
         }