- // on success, add path to our 'watch-list'
- wxFSWatchInfoMap::value_type val(canonical, watch);
- return m_watches.insert(val).second;
+ // on success, either add path to our 'watch-list'
+ // or, if already watched, inc the refcount. This may happen if
+ // a dir is Add()ed, then later AddTree() is called on a parent dir
+ wxFSWatchInfoMap::iterator it = m_watches.find(canonical);
+ if ( it == m_watches.end() )
+ {
+ wxFSWatchInfoMap::value_type val(canonical, watch);
+ m_watches.insert(val).second;
+ }
+ else
+ {
+ wxFSWatchInfo& watch = it->second;
+ int count = watch.IncRef();
+ wxLogTrace(wxTRACE_FSWATCHER,
+ "'%s' is now watched %d times", canonical, count);
+ }
+ return true;