Skip to content

Commit

Permalink
Use WITH_LOCK in Warnings::Set
Browse files Browse the repository at this point in the history
The scope of the lock should be limited to just guarding m_warnings as
anything listening on `NotifyAlertChanged` may execute code that
requires the lock as well.
  • Loading branch information
achow101 committed Jul 6, 2024
1 parent bd5d168 commit 6af51e8
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/node/warnings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ Warnings::Warnings()
}
bool Warnings::Set(warning_type id, bilingual_str message)
{
LOCK(m_mutex);
const auto& [_, inserted]{m_warnings.insert({id, std::move(message)})};
const auto& [_, inserted]{WITH_LOCK(m_mutex, return m_warnings.insert({id, std::move(message)}))};
if (inserted) uiInterface.NotifyAlertChanged();
return inserted;
}
Expand Down

0 comments on commit 6af51e8

Please sign in to comment.