pedrolcl / dmidiplayer

Drumstick MIDI File Player Multiplatform (mirror)
https://dmidiplayer.sourceforge.io
GNU General Public License v3.0
24 stars 7 forks source link

Crash when loading a MIDI file while another song is playing #8

Closed pedrolcl closed 1 year ago

pedrolcl commented 1 year ago

Opened from https://sourceforge.net/p/dmidiplayer/tickets/19/

  1. Load a File into the Midi Player.
  2. While it is playing, go to the File menu, Open Recent Files, and pick another one. If the player doesn't crash, repeat the process. It should crash either the first time you load a recent file, or the second time. NOTE: You have to load the Recent File while the player is playing. If you stop or pause the song, it does not crash while loading a new one. So I think you just need to introduce a "stop" command to the Midi player, before the new song loads, and it should fix this.
pedrolcl commented 1 year ago

you just need to introduce a "stop" command to the Midi player, before the new song loads, and it should fix this.

Indeed, that should be done. And almost all code paths for loading a new song do that except when opening recent files. There are a few ways to open a song in this program:

  1. Providing the file name(s) on the command line. This is the same function used to open a song from the file manager's (open with..), when a file type is associated with dmidiplayer. It always starts a new instance of the program, so it doesn't need to execute stop() before loading a new song.
  2. Drag and drop one or more files from the file manager into dmidiplayer. Executes stop().
  3. File->Open dialog. Executes stop().
  4. File->PlayList dialog->select song, and press Ok. Executes stop().
  5. Tool Button "next file", or File menu->Next. Executes stop().
  6. Button "previous file", or File menu->Prev. Executes stop().
  7. When a song has finished playing and the option "Advance automatically to the next playlist item" is enabled. It doesn't need to execute stop().
  8. File->Open Recent Files. This is the one that doesn't execute stop() before loading a new song, and it makes the program crash.
pedrolcl commented 1 year ago

Fixed in commit 3177507e66bb30b9b89f0946364d2ea9709a2454