toolmanager: when electing to close and not restart a tool because of lack of services on the new core, clear out all services attached to the core first. this will turn some existing silent failures into NullReferenceExceptions, likely. fix one such bug in GBAGPUView
This commit is contained in:
parent
eacadc8e09
commit
d1caf79a56
|
@ -794,7 +794,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void GBAGPUView_FormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
gba.SetScanlineCallback(null, 0);
|
||||
if (gba != null)
|
||||
{
|
||||
gba.SetScanlineCallback(null, 0);
|
||||
}
|
||||
}
|
||||
|
||||
#region copy to clipboard
|
||||
|
|
|
@ -358,6 +358,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
else
|
||||
{
|
||||
unavailable.Add(tool);
|
||||
ServiceInjector.ClearServices(tool); // the services of the old emulator core are no longer valid on the tool
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,23 @@ namespace BizHawk.Emulation.Common
|
|||
/// </summary>
|
||||
public static class ServiceInjector
|
||||
{
|
||||
/// <summary>
|
||||
/// clears all services from a target
|
||||
/// </summary>
|
||||
/// <param name="target"></param>
|
||||
public static void ClearServices(object target)
|
||||
{
|
||||
Type targetType = target.GetType();
|
||||
object[] tmp = new object[1];
|
||||
|
||||
foreach (var propinfo in
|
||||
targetType.GetPropertiesWithAttrib(typeof(RequiredService))
|
||||
.Concat(targetType.GetPropertiesWithAttrib(typeof(OptionalService))))
|
||||
{
|
||||
propinfo.GetSetMethod(true).Invoke(target, tmp);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Feeds the target its required services.
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in New Issue