From 234642ed0ddefcbf4890e5f7e80671c4d93a9e27 Mon Sep 17 00:00:00 2001 From: zeromus Date: Fri, 28 Aug 2020 19:09:07 -0400 Subject: [PATCH] fix some crashes in CDL. things were rough enough for CDL due to tool open/close and core life cycle being wrecked, but it totally melted down when CDL got sent through the service injection stuff, so this has been pretty broken for years now --- src/BizHawk.Client.EmuHawk/tools/CDL.cs | 17 +++++++++++++++-- .../Consoles/Nintendo/SNES/LibsnesApi_QUERY.cs | 3 +++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/BizHawk.Client.EmuHawk/tools/CDL.cs b/src/BizHawk.Client.EmuHawk/tools/CDL.cs index 001bee85ff..09dd28d2f0 100644 --- a/src/BizHawk.Client.EmuHawk/tools/CDL.cs +++ b/src/BizHawk.Client.EmuHawk/tools/CDL.cs @@ -48,8 +48,21 @@ namespace BizHawk.Client.EmuHawk [RequiredService] private IMemoryDomains MemoryDomains { get; set; } + ICodeDataLogger _icdlogger; + [RequiredService] - private ICodeDataLogger CodeDataLogger { get; set; } + private ICodeDataLogger CodeDataLogger + { + get + { + return _icdlogger; + } + set + { + _icdlogger?.SetCDL(null); + _icdlogger = value; + } + } private string _currentFilename; private CodeDataLog _cdl; @@ -450,7 +463,7 @@ namespace BizHawk.Client.EmuHawk void ShutdownCDL() { _cdl = null; - CodeDataLogger.SetCDL(null); + CodeDataLogger?.SetCDL(null); } protected override void OnClosing(System.ComponentModel.CancelEventArgs e) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_QUERY.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_QUERY.cs index 111dd8f0d3..81b39a5b1a 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_QUERY.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_QUERY.cs @@ -153,6 +153,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES public void QUERY_set_cdl(ICodeDataLog cdl) { + if (_exe == null) + return; + using (_exe.EnterExit()) { for (int i = 0; i < 8; i++)