Fix: avoid using string pointer after scope end

This commit is contained in:
Milek7 2020-01-12 14:56:27 +01:00 committed by Niels Martin Hansen
parent 1225693b9c
commit a411ce18c9
1 changed files with 2 additions and 1 deletions

View File

@ -732,11 +732,12 @@ struct MusicWindow : public Window {
case WID_M_TRACK_NAME: {
GfxFillRect(r.left, r.top + 1, r.right - 1, r.bottom, PC_BLACK);
StringID str = STR_MUSIC_TITLE_NONE;
MusicSystem::PlaylistEntry entry(_music.GetCurrentSong());
if (BaseMusic::GetUsedSet()->num_available == 0) {
str = STR_MUSIC_TITLE_NOMUSIC;
} else if (_music.IsPlaying()) {
str = STR_MUSIC_TITLE_NAME;
SetDParamStr(0, _music.GetCurrentSong().songname);
SetDParamStr(0, entry.songname);
}
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, str, TC_FROMSTRING, SA_HOR_CENTER);
break;