mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-09-30 05:18:04 -05:00
Resolve variables even when calling const functions
This is done to ensure that logs printed before actions are executed contain the correct parameter values instead of potentially outdated ones.
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
void StringVariable::Resolve()
|
void StringVariable::Resolve() const
|
||||||
{
|
{
|
||||||
if (switcher->variables.empty()) {
|
if (switcher->variables.empty()) {
|
||||||
_resolvedValue = _value;
|
_resolvedValue = _value;
|
||||||
@@ -17,7 +17,7 @@ void StringVariable::Resolve()
|
|||||||
_lastResolve = GetLastVariableChangeTime();
|
_lastResolve = GetLastVariableChangeTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
StringVariable::operator std::string()
|
StringVariable::operator std::string() const
|
||||||
{
|
{
|
||||||
Resolve();
|
Resolve();
|
||||||
return _resolvedValue;
|
return _resolvedValue;
|
||||||
@@ -59,7 +59,7 @@ const char *StringVariable::c_str()
|
|||||||
|
|
||||||
const char *StringVariable::c_str() const
|
const char *StringVariable::c_str() const
|
||||||
{
|
{
|
||||||
// Just assume that the value was previously resolved already
|
Resolve();
|
||||||
return _resolvedValue.c_str();
|
return _resolvedValue.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public:
|
|||||||
StringVariable() : _value(""){};
|
StringVariable() : _value(""){};
|
||||||
StringVariable(std::string str) : _value(std::move(str)){};
|
StringVariable(std::string str) : _value(std::move(str)){};
|
||||||
StringVariable(const char *str) : _value(str){};
|
StringVariable(const char *str) : _value(str){};
|
||||||
operator std::string();
|
operator std::string() const;
|
||||||
operator QVariant() const;
|
operator QVariant() const;
|
||||||
void operator=(std::string);
|
void operator=(std::string);
|
||||||
void operator=(const char *value);
|
void operator=(const char *value);
|
||||||
@@ -27,11 +27,11 @@ public:
|
|||||||
void Save(obs_data_t *obj, const char *name) const;
|
void Save(obs_data_t *obj, const char *name) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Resolve();
|
void Resolve() const;
|
||||||
|
|
||||||
std::string _value = "";
|
std::string _value = "";
|
||||||
std::string _resolvedValue = "";
|
mutable std::string _resolvedValue = "";
|
||||||
std::chrono::high_resolution_clock::time_point _lastResolve{};
|
mutable std::chrono::high_resolution_clock::time_point _lastResolve{};
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string SubstitueVariables(std::string str);
|
std::string SubstitueVariables(std::string str);
|
||||||
|
|||||||
Reference in New Issue
Block a user