mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-04-26 00:01:13 -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::string Variable::Value(bool updateLastUsed) const
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(_mutex);
|
||||||
if (updateLastUsed) {
|
if (updateLastUsed) {
|
||||||
UpdateLastUsed();
|
UpdateLastUsed();
|
||||||
}
|
}
|
||||||
|
|
@ -73,6 +74,7 @@ std::optional<int> Variable::IntValue() const
|
||||||
|
|
||||||
void Variable::SetValue(const std::string &value)
|
void Variable::SetValue(const std::string &value)
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(_mutex);
|
||||||
_previousValue = _value;
|
_previousValue = _value;
|
||||||
_value = value;
|
_value = value;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,11 @@
|
||||||
#include "item-selection-helpers.hpp"
|
#include "item-selection-helpers.hpp"
|
||||||
#include "resizing-text-edit.hpp"
|
#include "resizing-text-edit.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <mutex>
|
||||||
#include <optional>
|
|
||||||
#include <QStringList>
|
|
||||||
#include <obs-data.h>
|
#include <obs-data.h>
|
||||||
|
#include <optional>
|
||||||
|
#include <string>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
|
|
@ -52,6 +53,7 @@ private:
|
||||||
int _valueChangeCount = 0;
|
int _valueChangeCount = 0;
|
||||||
mutable std::chrono::high_resolution_clock::time_point _lastUsed;
|
mutable std::chrono::high_resolution_clock::time_point _lastUsed;
|
||||||
mutable std::chrono::high_resolution_clock::time_point _lastChanged;
|
mutable std::chrono::high_resolution_clock::time_point _lastChanged;
|
||||||
|
mutable std::mutex _mutex;
|
||||||
|
|
||||||
friend VariableSelection;
|
friend VariableSelection;
|
||||||
friend VariableSettingsDialog;
|
friend VariableSettingsDialog;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user