File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -174,9 +174,17 @@ abstract class _FileSystemWatcher {
174174 assert (watcherPath.count > 0 );
175175 watcherPath.count-- ;
176176 if (watcherPath.count == 0 ) {
177- _unwatchPath (_id! , watcherPath.pathId);
178- _pathWatchedEnd ();
179- _idMap.remove (watcherPath.pathId);
177+ var pathId = watcherPath.pathId;
178+ // DirectoryWatchHandle(aka pathId) might be closed already initiated
179+ // by issueReadEvent for example. When that happens, appropriate closeEvent
180+ // will arrive to us and we will remove this pathId from _idMap. If that
181+ // happens we should not try to close it again as pathId is no
182+ // longer usable(the memory it points to might be released)
183+ if (_idMap.containsKey (pathId)) {
184+ _unwatchPath (_id! , pathId);
185+ _pathWatchedEnd ();
186+ _idMap.remove (pathId);
187+ }
180188 }
181189 _watcherPath = null ;
182190 }
Original file line number Diff line number Diff line change @@ -27,5 +27,5 @@ CHANNEL dev
2727MAJOR 2
2828MINOR 12
2929PATCH 0
30- PRERELEASE 7
30+ PRERELEASE 8
3131PRERELEASE_PATCH 0
You can’t perform that action at this time.
0 commit comments