Fix crash in wxMSW wxFileSystemWatcher when removing the same path twice.

Starting to watch a path, stopping to watch it, starting to watch it again and
stopping again resulted in a crash in wxMSW wxFileSystemWatcher implementation
because the watcher object wasn't kept artificially kept alive when it was
stopped for the second time. This happened because our way of keeping it alive
was to store it in a hash map indexed by path, but if a watcher for the same
path (added there when this path was first unwatched) was already present in
the map, the watcher wasn't added to it and not kept alive.

Fix this by using a vector instead of a map. We obviously sacrifice quick
access to it by path but at least this doesn't crash any more. And we could
actually still use a map, just indexed by the (unique) pointer to the object
stored inside wxSharedPtr itself, and not its path. But a vector might be a
more efficient data structure in practice, if we keep it from becoming too big
as we should try to do by triggering artificial port completions when a watch
is removed.

At any rate, at least the crash is fixed for now.

Closes #15995.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@75915 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-02-17 23:55:22 +00:00
parent e354c7a59a
commit 79542a7196
2 changed files with 17 additions and 10 deletions

View File

@@ -629,6 +629,7 @@ wxMSW:
- Fix bug with multiple default buttons in a dialog (Artur Wieczorek).
- Improve tooltips wrapping after updating their text (Artur Wieczorek).
- Fix checking menu items before appending them to the menu.
- Fix crash when adding/removing the same path to/from wxFileSystemWatcher.
wxOSX: