Skip to content

Commit

Permalink
[MP2K] Fix program crash caused by batch export during song playing
Browse files Browse the repository at this point in the history
1. Auto stop playing before batch export
2. Reload current song after batch export
  • Loading branch information
laqieer committed Apr 27, 2022
1 parent b10514e commit 7fbb126
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions VG Music Studio/UI/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ private void ExportMIDIBatch(object sender, EventArgs e)
if (d.ShowDialog() == CommonFileDialogResult.Ok)
{
var p = (Core.GBA.MP2K.Player)Engine.Instance.Player;
Stop();
var args = new Core.GBA.MP2K.Player.MIDISaveArgs
{
SaveCommandsBeforeTranspose = true,
Expand Down Expand Up @@ -555,6 +556,15 @@ private void ExportMIDIBatch(object sender, EventArgs e)
}
}
FlexibleMessageBox.Show(Strings.SuccessSaveMIDIBatch, Text);
long oldIndex = (long)_songNumerical.Value;
try
{
Engine.Instance.Player.LoadSong(oldIndex);
}
catch (Exception ex)
{
FlexibleMessageBox.Show(ex, string.Format(Strings.ErrorLoadSong, Engine.Instance.Config.GetSongName(oldIndex)));
}
}
}
private void ExportSF2(object sender, EventArgs e)
Expand Down

0 comments on commit 7fbb126

Please sign in to comment.