Fixes FileSystemWatcher exception on Linux. (#1600)

This commit is contained in:
BDisp
2022-02-18 15:36:59 +00:00
committed by GitHub
parent d403b8b723
commit 0be59c9bc5
2 changed files with 26 additions and 0 deletions

View File

@@ -94,6 +94,21 @@ namespace Terminal.Gui {
return valid;
}
private bool _disposedValue;
protected override void Dispose (bool disposing)
{
if (!_disposedValue) {
if (disposing) {
watcher?.Dispose ();
}
_disposedValue = true;
}
// Call base class implementation.
base.Dispose (disposing);
}
void Watcher_Error (object sender, ErrorEventArgs e)
{
Application.MainLoop.Invoke (() => Reload ());

View File

@@ -647,5 +647,16 @@ namespace Terminal.Gui.Core {
Assert.Equal (Key.PageUp | Key.CtrlMask, Application.AlternateBackwardKey);
Assert.Equal (Key.Q | Key.CtrlMask, Application.QuitKey);
}
[Fact]
[AutoInitShutdown]
public void FileDialog_FileSystemWatcher ()
{
for (int i = 0; i < 256; i++) {
var fd = new FileDialog ();
fd.Ready += () => Application.RequestStop ();
Application.Run (fd);
}
}
}
}