Ensure owner param of ShowHawkDialog overloads are never null

This commit is contained in:
YoshiRulz 2020-12-01 04:04:10 +10:00 committed by James Groom
parent aad612593b
commit dd44ff7f6c
3 changed files with 5 additions and 9 deletions

View File

@ -148,7 +148,7 @@ namespace BizHawk.Client.EmuHawk
/// <summary> /// <summary>
/// Handles EmuHawk specific issues before showing a modal dialog /// Handles EmuHawk specific issues before showing a modal dialog
/// </summary> /// </summary>
public static DialogResult ShowHawkDialog(this Form form, IWin32Window owner = null, Point position = default) public static DialogResult ShowHawkDialog(this Form form, IWin32Window owner, Point position = default)
{ {
Sound.Instance.StopSound(); Sound.Instance.StopSound();
if (position != default) if (position != default)
@ -156,7 +156,7 @@ namespace BizHawk.Client.EmuHawk
form.StartPosition = FormStartPosition.Manual; form.StartPosition = FormStartPosition.Manual;
form.Location = position; form.Location = position;
} }
var result = (owner == null ? form.ShowDialog(new Form { TopMost = true }) : form.ShowDialog(owner)); var result = form.ShowDialog(owner);
Sound.Instance.StartSound(); Sound.Instance.StartSound();
return result; return result;
} }
@ -167,11 +167,7 @@ namespace BizHawk.Client.EmuHawk
public static DialogResult ShowHawkDialog(this CommonDialog form, IWin32Window owner) public static DialogResult ShowHawkDialog(this CommonDialog form, IWin32Window owner)
{ {
Sound.Instance.StopSound(); Sound.Instance.StopSound();
DialogResult result; var result = form.ShowDialog(owner);
if(owner != null)
result = form.ShowDialog(owner);
else
result = form.ShowDialog();
Sound.Instance.StartSound(); Sound.Instance.StartSound();
return result; return result;
} }

View File

@ -150,7 +150,7 @@ namespace BizHawk.Client.EmuHawk
Config.PathEntries.CheatsAbsolutePath(Game.System), Config.PathEntries.CheatsAbsolutePath(Game.System),
"Cheat Files", "Cheat Files",
"cht", "cht",
Owner); Owner ?? this);
return file != null && MainForm.CheatList.SaveFile(file.FullName); return file != null && MainForm.CheatList.SaveFile(file.FullName);
} }

View File

@ -426,7 +426,7 @@ namespace BizHawk.Client.EmuHawk
TextInputType = InputPrompt.InputType.Text TextInputType = InputPrompt.InputType.Text
}; };
var result = MainForm.DoWithTempMute(() => inputPrompt.ShowHawkDialog()); var result = MainForm.DoWithTempMute(() => inputPrompt.ShowHawkDialog(this));
if (result == DialogResult.OK) if (result == DialogResult.OK)
{ {