Hopefully block edge cases where global `GameInfo` is uninitialised
`Game == null` conditions in `MainForm` ctor looked unreachable, so I changed them to `Game.IsNullInstance()` which is what I assume was intended, and added an assert to `RomLoader` in case a bug is introduced later
This commit is contained in:
parent
d84da4ec4b
commit
bd58bde07c
|
@ -703,6 +703,8 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_ = game!; // shouldn't be null if `nextEmulator` isn't? just in case
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -198,19 +198,12 @@ namespace BizHawk.Client.Common
|
||||||
movie.SyncSettingsJson = ConfigService.SaveWithType(settable.GetSyncSettings());
|
movie.SyncSettingsJson = ConfigService.SaveWithType(settable.GetSyncSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (game.IsNullInstance())
|
|
||||||
{
|
|
||||||
movie.GameName = "NULL";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
movie.GameName = game.FilesystemSafeName();
|
movie.GameName = game.FilesystemSafeName();
|
||||||
movie.Hash = game.Hash;
|
movie.Hash = game.Hash;
|
||||||
if (game.FirmwareHash != null)
|
if (game.FirmwareHash != null)
|
||||||
{
|
{
|
||||||
movie.FirmwareHash = game.FirmwareHash;
|
movie.FirmwareHash = game.FirmwareHash;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (emulator.HasBoardInfo())
|
if (emulator.HasBoardInfo())
|
||||||
{
|
{
|
||||||
|
|
|
@ -427,6 +427,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void RecordMovieMenuItem_Click(object sender, EventArgs e)
|
private void RecordMovieMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if (Game.IsNullInstance()) return;
|
||||||
if (!Emulator.Attributes().Released)
|
if (!Emulator.Attributes().Released)
|
||||||
{
|
{
|
||||||
var result = this.ModalMessageBox2(
|
var result = this.ModalMessageBox2(
|
||||||
|
|
|
@ -548,7 +548,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
var ioa = OpenAdvancedSerializer.ParseWithLegacy(_argParser.cmdRom);
|
var ioa = OpenAdvancedSerializer.ParseWithLegacy(_argParser.cmdRom);
|
||||||
if (ioa is OpenAdvanced_OpenRom oaor) ioa = new OpenAdvanced_OpenRom { Path = oaor.Path.MakeAbsolute() }; // fixes #3224; should this be done for all the IOpenAdvanced types? --yoshi
|
if (ioa is OpenAdvanced_OpenRom oaor) ioa = new OpenAdvanced_OpenRom { Path = oaor.Path.MakeAbsolute() }; // fixes #3224; should this be done for all the IOpenAdvanced types? --yoshi
|
||||||
LoadRom(ioa.SimplePath, new LoadRomArgs { OpenAdvanced = ioa });
|
LoadRom(ioa.SimplePath, new LoadRomArgs { OpenAdvanced = ioa });
|
||||||
if (Game == null)
|
if (Game.IsNullInstance())
|
||||||
{
|
{
|
||||||
ShowMessageBox(owner: null, $"Failed to load {_argParser.cmdRom} specified on commandline");
|
ShowMessageBox(owner: null, $"Failed to load {_argParser.cmdRom} specified on commandline");
|
||||||
}
|
}
|
||||||
|
@ -567,7 +567,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
if (_argParser.cmdMovie != null)
|
if (_argParser.cmdMovie != null)
|
||||||
{
|
{
|
||||||
_suppressSyncSettingsWarning = true; // We don't want to be nagged if we are attempting to automate
|
_suppressSyncSettingsWarning = true; // We don't want to be nagged if we are attempting to automate
|
||||||
if (Game == null)
|
if (Game.IsNullInstance())
|
||||||
{
|
{
|
||||||
OpenRom();
|
OpenRom();
|
||||||
}
|
}
|
||||||
|
@ -3318,6 +3318,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
if (_currAviWriter != null) return;
|
if (_currAviWriter != null) return;
|
||||||
|
|
||||||
|
if (Game.IsNullInstance()) throw new InvalidOperationException("how is an A/V recording starting with no game loaded? please report this including as much detail as possible");
|
||||||
|
|
||||||
// select IVideoWriter to use
|
// select IVideoWriter to use
|
||||||
IVideoWriter aw;
|
IVideoWriter aw;
|
||||||
|
|
||||||
|
@ -3431,19 +3433,12 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
using var sfd = new SaveFileDialog();
|
using SaveFileDialog sfd = new()
|
||||||
if (Game != null)
|
|
||||||
{
|
{
|
||||||
sfd.FileName = $"{Game.FilesystemSafeName()}.{ext}"; // don't use Path.ChangeExtension, it might wreck game names with dots in them
|
FileName = $"{Game.FilesystemSafeName()}.{ext}",
|
||||||
sfd.InitialDirectory = Config.PathEntries.AvAbsolutePath();
|
Filter = new FilesystemFilterSet(new FilesystemFilter(ext, new[] { ext })).ToString(),
|
||||||
}
|
InitialDirectory = Config.PathEntries.AvAbsolutePath(),
|
||||||
else
|
};
|
||||||
{
|
|
||||||
sfd.FileName = "NULL";
|
|
||||||
sfd.InitialDirectory = Config.PathEntries.AvAbsolutePath();
|
|
||||||
}
|
|
||||||
|
|
||||||
sfd.Filter = new FilesystemFilterSet(new FilesystemFilter(ext, new[] { ext })).ToString();
|
|
||||||
|
|
||||||
if (this.ShowDialogWithTempMute(sfd) == DialogResult.Cancel)
|
if (this.ShowDialogWithTempMute(sfd) == DialogResult.Cancel)
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,6 +30,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
IMovieSession movieSession,
|
IMovieSession movieSession,
|
||||||
FirmwareManager firmwareManager)
|
FirmwareManager firmwareManager)
|
||||||
{
|
{
|
||||||
|
if (game.IsNullInstance()) throw new InvalidOperationException("how is the traditional Record dialog open with no game loaded? please report this including as much detail as possible");
|
||||||
|
|
||||||
_mainForm = mainForm;
|
_mainForm = mainForm;
|
||||||
_config = config;
|
_config = config;
|
||||||
_game = game;
|
_game = game;
|
||||||
|
|
|
@ -583,6 +583,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Game.IsNullInstance()) throw new InvalidOperationException("how is TAStudio open with no game loaded? please report this including as much detail as possible");
|
||||||
|
|
||||||
var filename = DefaultTasProjName(); // TODO don't do this, take over any mainform actions that can crash without a filename
|
var filename = DefaultTasProjName(); // TODO don't do this, take over any mainform actions that can crash without a filename
|
||||||
var tasMovie = (ITasMovie)MovieSession.Get(filename);
|
var tasMovie = (ITasMovie)MovieSession.Get(filename);
|
||||||
tasMovie.BindMarkersToInput = Settings.BindMarkersToInput;
|
tasMovie.BindMarkersToInput = Settings.BindMarkersToInput;
|
||||||
|
|
Loading…
Reference in New Issue