Store truncated representation of doubles when used as variables

This commit is contained in:
Przemek Pawlas
2024-02-22 19:47:00 +01:00
committed by WarmUpTill
parent c3f207f93c
commit b2fc560701
3 changed files with 11 additions and 1 deletions

View File

@@ -7,6 +7,7 @@
#include <QDateTime>
#include <QFile>
#include <QStandardPaths>
#include <sstream>
namespace advss {
@@ -77,6 +78,13 @@ bool CompareIgnoringLineEnding(QString &s1, QString &s2)
return true;
}
std::string ToString(double value)
{
std::stringstream stream;
stream << value;
return stream.str();
}
std::string GetDataFilePath(const std::string &file)
{
std::string root_path = obs_get_module_data_path(obs_current_module());

View File

@@ -21,6 +21,7 @@ bool ReplaceAll(std::string &str, const std::string &from,
EXPORT std::optional<std::string> GetJsonField(const std::string &json,
const std::string &id);
EXPORT bool CompareIgnoringLineEnding(QString &s1, QString &s2);
std::string ToString(double value);
EXPORT std::string GetDataFilePath(const std::string &file);
QString GetDefaultSettingsSaveLocation();

View File

@@ -1,6 +1,7 @@
#include "variable.hpp"
#include "math-helpers.hpp"
#include "obs-module-helper.hpp"
#include "utility.hpp"
#include <QGridLayout>
@@ -78,7 +79,7 @@ void Variable::SetValue(const std::string &val)
void Variable::SetValue(double value)
{
_value = std::to_string(value);
_value = ToString(value);
_lastUsed = std::chrono::high_resolution_clock::now();
lastVariableChange = std::chrono::high_resolution_clock::now();
}