ToolManager Load<T> - check IsAvailable() before attempting to load

This commit is contained in:
adelikat 2014-12-14 01:25:28 +00:00
parent 3768e393c7
commit 30e6aeb0bf
1 changed files with 22 additions and 17 deletions

View File

@ -20,28 +20,33 @@ namespace BizHawk.Client.EmuHawk
/// </summary>
public IToolForm Load<T>() where T : IToolForm
{
var existingTool = _tools.FirstOrDefault(x => x is T);
if (existingTool != null)
if (IsAvailable(typeof(T)))
{
if (existingTool.IsDisposed)
var existingTool = _tools.FirstOrDefault(x => x is T);
if (existingTool != null)
{
_tools.Remove(existingTool);
}
else
{
existingTool.Show();
existingTool.Focus();
return existingTool;
if (existingTool.IsDisposed)
{
_tools.Remove(existingTool);
}
else
{
existingTool.Show();
existingTool.Focus();
return existingTool;
}
}
var result = Get<T>();
UpdateServices(result);
result.Restart();
result.Show();
return result;
}
var result = Get<T>();
UpdateServices(result);
result.Restart();
result.Show();
return result;
return null;
}
/// <summary>