From dd53b01ffde959e808e7974cdc302f12e0ba5820 Mon Sep 17 00:00:00 2001 From: Salanto <62221668+Salanto@users.noreply.github.com> Date: Fri, 18 Feb 2022 20:51:27 +0100 Subject: [PATCH] Address potential source of race confition inside the play function (#658) Current working theory is that setting the future opens a brief interval where it deconstructs the old future and returning an invalid QFuture,, causing a segmentation fault. --- src/courtroom.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 3fb691e..34a596d 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -3873,17 +3873,16 @@ void Courtroom::handle_song(QStringList *p_contents) } } - QFuture future = QtConcurrent::run(music_player, &AOMusicPlayer::play, f_song, channel, - looping, effect_flags); if (channel == 0) { // Current song UI only displays the song playing, not other channels. // Any other music playing is irrelevant. if (music_player->music_watcher.isRunning()) { music_player->music_watcher.cancel(); } - music_player->music_watcher.setFuture(future); ui_music_name->setText(tr("[LOADING] %1").arg(f_song_clear)); } + music_player->music_watcher.setFuture(QtConcurrent::run(music_player, &AOMusicPlayer::play, f_song, channel, + looping, effect_flags)); } void Courtroom::update_ui_music_name()