mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-21 17:34:57 -05:00
Make read and write functions of variables thread-safe
This commit is contained in:
parent
82d23dcf0e
commit
685e28d161
|
|
@ -54,6 +54,7 @@ void Variable::Save(obs_data_t *obj) const
|
|||
|
||||
std::string Variable::Value(bool updateLastUsed) const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_mutex);
|
||||
if (updateLastUsed) {
|
||||
UpdateLastUsed();
|
||||
}
|
||||
|
|
@ -73,6 +74,7 @@ std::optional<int> Variable::IntValue() const
|
|||
|
||||
void Variable::SetValue(const std::string &value)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_mutex);
|
||||
_previousValue = _value;
|
||||
_value = value;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,10 +3,11 @@
|
|||
#include "item-selection-helpers.hpp"
|
||||
#include "resizing-text-edit.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include <QStringList>
|
||||
#include <mutex>
|
||||
#include <obs-data.h>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <QStringList>
|
||||
|
||||
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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user