Clean up ext. tools dir monitoring (resolves #2787)

This commit is contained in:
YoshiRulz 2021-06-09 01:58:26 +10:00
parent 14fef0f2b5
commit 77bbd6b24e
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
2 changed files with 6 additions and 4 deletions

View File

@ -4067,6 +4067,7 @@ namespace BizHawk.Client.EmuHawk
DisplayManager.UpdateGlobals(Config, Emulator);
InputManager.SyncControls(Emulator, MovieSession, Config);
Tools.UpdateCheatRelatedTools(null, null);
ExtToolManager.BuildToolStrip();
PauseOnFrame = null;
CurrentlyOpenRom = null;
CurrentlyOpenRomArgs = null;

View File

@ -15,6 +15,8 @@ namespace BizHawk.Client.EmuHawk
{
private readonly Func<(CoreSystem System, string Hash)> _getLoadedRomInfoCallback;
private PathEntryCollection _paths;
private FileSystemWatcher DirectoryMonitor;
private readonly List<ToolStripMenuItem> MenuItems = new List<ToolStripMenuItem>();
@ -27,14 +29,13 @@ namespace BizHawk.Client.EmuHawk
public void Restart(PathEntryCollection paths)
{
_paths = paths;
if (DirectoryMonitor != null)
{
DirectoryMonitor.Created -= DirectoryMonitor_Created;
DirectoryMonitor.Dispose();
}
var extToolsDir = paths["Global", "External Tools"].Path;
if (!Directory.Exists(extToolsDir)) Directory.CreateDirectory(extToolsDir);
DirectoryMonitor = new FileSystemWatcher(extToolsDir, "*.dll")
DirectoryMonitor = new FileSystemWatcher(_paths["Global", "External Tools"].Path, "*.dll")
{
IncludeSubdirectories = false,
NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName,
@ -83,7 +84,7 @@ namespace BizHawk.Client.EmuHawk
var toolAttribute = allAttrs.OfType<ExternalToolAttribute>().First();
if (toolAttribute.LoadAssemblyFiles != null)
{
foreach (var depFilename in toolAttribute.LoadAssemblyFiles) Assembly.LoadFrom($"ExternalTools/{depFilename}");
foreach (var depFilename in toolAttribute.LoadAssemblyFiles) Assembly.LoadFrom($"{_paths["Global", "External Tools"].Path}/{depFilename}");
}
var embeddedIconAttr = allAttrs.OfType<ExternalToolEmbeddedIconAttribute>().FirstOrDefault();
if (embeddedIconAttr != null)