Fix deadlock when changing condition / action type

The video preview dialogs could not exit as the destructor was holding
the main mutex while joining the preview thread, which in turn was
waiting to get the access to the mutex to exit its main loop
This commit is contained in:
WarmUpTill 2022-03-28 20:34:39 +02:00 committed by WarmUpTill
parent eeceb7cbd9
commit 102b93d3b5
2 changed files with 14 additions and 12 deletions

View File

@ -106,11 +106,12 @@ void MacroActionEdit::ActionSelectionChanged(const QString &text)
auto macro = _entryData->get()->GetMacro();
std::string id = MacroActionFactory::GetIdByName(text);
HeaderInfoChanged("");
std::lock_guard<std::mutex> lock(switcher->m);
_entryData->reset();
*_entryData = MacroActionFactory::Create(id, macro);
(*_entryData)->SetIndex(idx);
{
std::lock_guard<std::mutex> lock(switcher->m);
_entryData->reset();
*_entryData = MacroActionFactory::Create(id, macro);
(*_entryData)->SetIndex(idx);
}
auto widget = MacroActionFactory::CreateWidget(id, this, *_entryData);
QWidget::connect(widget, SIGNAL(HeaderInfoChanged(const QString &)),
this, SLOT(HeaderInfoChanged(const QString &)));

View File

@ -218,13 +218,14 @@ void MacroConditionEdit::ConditionSelectionChanged(const QString &text)
auto temp = DurationConstraint();
_dur->SetValue(temp);
HeaderInfoChanged("");
std::lock_guard<std::mutex> lock(switcher->m);
auto logic = (*_entryData)->GetLogicType();
_entryData->reset();
*_entryData = MacroConditionFactory::Create(id, macro);
(*_entryData)->SetIndex(idx);
(*_entryData)->SetLogicType(logic);
{
std::lock_guard<std::mutex> lock(switcher->m);
auto logic = (*_entryData)->GetLogicType();
_entryData->reset();
*_entryData = MacroConditionFactory::Create(id, macro);
(*_entryData)->SetIndex(idx);
(*_entryData)->SetLogicType(logic);
}
auto widget =
MacroConditionFactory::CreateWidget(id, this, *_entryData);
QWidget::connect(widget, SIGNAL(HeaderInfoChanged(const QString &)),