diff --git a/lib/variables/variable.cpp b/lib/variables/variable.cpp index 44cf5358..5ea0942a 100644 --- a/lib/variables/variable.cpp +++ b/lib/variables/variable.cpp @@ -54,6 +54,7 @@ void Variable::Save(obs_data_t *obj) const std::string Variable::Value(bool updateLastUsed) const { + std::lock_guard lock(_mutex); if (updateLastUsed) { UpdateLastUsed(); } @@ -73,6 +74,7 @@ std::optional Variable::IntValue() const void Variable::SetValue(const std::string &value) { + std::lock_guard lock(_mutex); _previousValue = _value; _value = value; diff --git a/lib/variables/variable.hpp b/lib/variables/variable.hpp index 4bdf1c91..1f45e71b 100644 --- a/lib/variables/variable.hpp +++ b/lib/variables/variable.hpp @@ -3,10 +3,11 @@ #include "item-selection-helpers.hpp" #include "resizing-text-edit.hpp" -#include -#include -#include +#include #include +#include +#include +#include namespace advss { @@ -52,6 +53,7 @@ private: int _valueChangeCount = 0; mutable std::chrono::high_resolution_clock::time_point _lastUsed; mutable std::chrono::high_resolution_clock::time_point _lastChanged; + mutable std::mutex _mutex; friend VariableSelection; friend VariableSettingsDialog;