mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-21 17:34:57 -05:00
Fix crash when stopping queue from within the queue
This commit is contained in:
parent
6b4bcc074a
commit
96db0ad507
|
|
@ -51,9 +51,13 @@ void ActionQueue::Load(obs_data_t *obj)
|
|||
|
||||
void ActionQueue::Start()
|
||||
{
|
||||
if (_thread.joinable()) {
|
||||
if (!_stop) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_thread.joinable()) {
|
||||
_thread.join();
|
||||
}
|
||||
_stop = false;
|
||||
_thread = std::thread(&ActionQueue::RunActions, this);
|
||||
}
|
||||
|
|
@ -62,6 +66,10 @@ void ActionQueue::Stop()
|
|||
{
|
||||
_stop = true;
|
||||
_cv.notify_all();
|
||||
if (std::this_thread::get_id() == _thread.get_id()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_thread.joinable()) {
|
||||
_thread.join();
|
||||
}
|
||||
|
|
@ -69,7 +77,7 @@ void ActionQueue::Stop()
|
|||
|
||||
bool ActionQueue::IsRunning() const
|
||||
{
|
||||
return _thread.joinable();
|
||||
return !_stop;
|
||||
}
|
||||
|
||||
bool ActionQueue::RunsOnStartup() const
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ private:
|
|||
|
||||
bool _runOnStartup = true;
|
||||
bool _resolveVariablesOnAdd = true;
|
||||
std::atomic_bool _stop = {false};
|
||||
std::atomic_bool _stop = {true};
|
||||
std::mutex _mutex;
|
||||
std::condition_variable _cv;
|
||||
std::thread _thread;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user