浏览代码

diagnosing Watcher exception in Action test runs

Charlie Kindel 2 年之前
父节点
当前提交
291df47b04
共有 1 个文件被更改,包括 9 次插入0 次删除
  1. 9 0
      Terminal.Gui/Windows/FileDialog.cs

+ 9 - 0
Terminal.Gui/Windows/FileDialog.cs

@@ -83,6 +83,7 @@ namespace Terminal.Gui {
 				case DirectoryNotFoundException _:
 				case ArgumentException _:
 					dirInfo = null;
+					watcher?.Dispose ();
 					watcher = null;
 					infos.Clear ();
 					valid = true;
@@ -104,7 +105,15 @@ namespace Terminal.Gui {
 		{
 			if (!_disposedValue) {
 				if (disposing) {
+					if (watcher != null) {
+						watcher.Changed -= Watcher_Changed;
+						watcher.Created -= Watcher_Changed;
+						watcher.Deleted -= Watcher_Changed;
+						watcher.Renamed -= Watcher_Changed;
+						watcher.Error -= Watcher_Error;
+					}
 					watcher?.Dispose ();
+					watcher = null;
 				}
 
 				_disposedValue = true;