#ScriptEngine: The method setVariable() does not only change the value of the variable but also adds a new one if the variable does not exists

This commit is contained in:
Arin Alex 2017-09-11 21:31:54 +03:00
parent 77cc93e766
commit c9b6078fa8

View File

@ -1491,7 +1491,11 @@ QVariant ScriptFunctionsManager::currencyUSBasedFormat(QVariant value, const QSt
void ScriptFunctionsManager::setVariable(const QString &name, QVariant value) void ScriptFunctionsManager::setVariable(const QString &name, QVariant value)
{ {
DataSourceManager* dm = scriptEngineManager()->dataManager(); DataSourceManager* dm = scriptEngineManager()->dataManager();
dm->changeVariable(name,value); if (dm->containsVariable(name)){
dm->changeVariable(name,value);
} else {
dm->addVariable(name, value, VarDesc::User);
}
} }
QVariant ScriptFunctionsManager::getVariable(const QString &name) QVariant ScriptFunctionsManager::getVariable(const QString &name)