fix crash on deleting scene sequences

This crash could occur when a scene sequence was currently in progress and the entries were changed while in the 'wait for ...' state.
This commit is contained in:
WarmUpTill
2020-11-02 19:05:19 +01:00
parent 0c6a7b140e
commit bf30a058ee

View File

@@ -30,10 +30,19 @@ void AdvSceneSwitcher::on_sceneSequenceRemove_clicked()
return;
{
// might be in waiting state of sequence
// causing invalid access to after wakeup
// thus we need to stop the main thread before delete
bool wasRunning = !switcher->stop;
switcher->Stop();
std::lock_guard<std::mutex> lock(switcher->m);
int idx = ui->sceneSequenceSwitches->currentRow();
auto &switches = switcher->sceneSequenceSwitches;
switches.erase(switches.begin() + idx);
if (wasRunning)
switcher->Start();
}
delete item;
@@ -119,6 +128,10 @@ void AdvSceneSwitcher::on_sceneSequenceLoad_clicked()
Msgbox.exec();
return;
}
// might be in waiting state of sequence
// causing invalid access to after wakeup
// thus we need to stop the main thread before delete
bool wasRunning = !switcher->stop;
switcher->Stop();