diff --git a/src/libinputactions/scripting/modules/core/VariableRegistryWrapper.cpp b/src/libinputactions/scripting/modules/core/VariableRegistryWrapper.cpp index f928f4d..740c6bd 100644 --- a/src/libinputactions/scripting/modules/core/VariableRegistryWrapper.cpp +++ b/src/libinputactions/scripting/modules/core/VariableRegistryWrapper.cpp @@ -57,6 +57,12 @@ VariableWrapper *VariableRegistryWrapper::get(const QString &name) const return new VariableWrapper(*variable, m_engine); } +VariableWrapper *VariableRegistryWrapper::variable(const QString &name) const +{ + auto *variable = m_variableRegistry.variable(name); + return variable ? new VariableWrapper(*variable, m_engine) : nullptr; +} + VariableWrapper *VariableRegistryWrapper::registerComputedVariable(const QString &name, VariableType type, QJSValue getter) const { if (!m_registrationAllowed) { diff --git a/src/libinputactions/scripting/modules/core/VariableRegistryWrapper.h b/src/libinputactions/scripting/modules/core/VariableRegistryWrapper.h index 0c505fa..88466b8 100644 --- a/src/libinputactions/scripting/modules/core/VariableRegistryWrapper.h +++ b/src/libinputactions/scripting/modules/core/VariableRegistryWrapper.h @@ -39,6 +39,10 @@ class VariableRegistryWrapper : public QObject Q_INVOKABLE bool contains(const QString &name) const; Q_INVOKABLE VariableWrapper *get(const QString &name) const; + /** + * Deprecated, kept for backwards compatibility. Returns null instead of throwing when variable doesn't exist. + */ + Q_INVOKABLE VariableWrapper *variable(const QString &name) const; Q_INVOKABLE VariableWrapper *registerComputedVariable(const QString &name, VariableType type, QJSValue getter) const; Q_INVOKABLE StoredVariableWrapper *registerStoredVariable(const QString &name, VariableType type) const;