diff --git a/src/control/controlobjectscript.cpp b/src/control/controlobjectscript.cpp index 3c6a6495732..dd69e3fb13a 100644 --- a/src/control/controlobjectscript.cpp +++ b/src/control/controlobjectscript.cpp @@ -19,7 +19,7 @@ bool ControlObjectScript::addScriptConnection(const ScriptConnection& conn) { &ControlObjectScript::slotValueChanged, Qt::QueuedConnection); connect(this, - &ControlObjectScript::trigger, + &ControlObjectScript::triggered, this, &ControlObjectScript::slotValueChanged, Qt::QueuedConnection); @@ -60,7 +60,7 @@ bool ControlObjectScript::removeScriptConnection(const ScriptConnection& conn) { this, &ControlObjectScript::slotValueChanged); disconnect(this, - &ControlObjectScript::trigger, + &ControlObjectScript::triggered, this, &ControlObjectScript::slotValueChanged); } diff --git a/src/control/controlobjectscript.h b/src/control/controlobjectscript.h index 219a4b0a991..ede0be26b41 100644 --- a/src/control/controlobjectscript.h +++ b/src/control/controlobjectscript.h @@ -22,14 +22,14 @@ class ControlObjectScript : public ControlProxy { return m_scriptConnections.first(); }; void disconnectAllConnectionsToFunction(const QJSValue& function); - // Called from update(); - void emitValueChanged() override { - emit trigger(get(), this); + /// Called from `ControlEngineScriptLegacy::trigger` + void trigger() { + emit triggered(get(), this); } signals: // It will connect to the slotValueChanged as well - void trigger(double, QObject*); + void triggered(double, QObject*); protected slots: // Receives the value from the master control by a unique queued connection diff --git a/src/control/controlproxy.h b/src/control/controlproxy.h index be6adc1b124..cd139a99ce9 100644 --- a/src/control/controlproxy.h +++ b/src/control/controlproxy.h @@ -86,33 +86,14 @@ class ControlProxy : public QObject { Qt::ConnectionType copConnection = static_cast( requestedConnectionType | Qt::UniqueConnection); - // clazy requires us to to pass a member function to connect() directly - // (i.e. w/o and intermediate variable) when used with - // Qt::UniqueConnection. Otherwise it detects a false positive and - // throws a [-Wclazy-lambda-unique-connection] warning. - switch (requestedConnectionType) { - case Qt::AutoConnection: - connect(m_pControl.data(), &ControlDoublePrivate::valueChanged, this, &ControlProxy::slotValueChangedAuto, copConnection); - break; - case Qt::DirectConnection: - connect(m_pControl.data(), &ControlDoublePrivate::valueChanged, this, &ControlProxy::slotValueChangedDirect, copConnection); - break; - case Qt::QueuedConnection: - connect(m_pControl.data(), &ControlDoublePrivate::valueChanged, this, &ControlProxy::slotValueChangedQueued, copConnection); - break; - default: - // Should be unreachable, but just to make sure ;-) - DEBUG_ASSERT(false); - return false; - } + connect(m_pControl.data(), + &ControlDoublePrivate::valueChanged, + this, + &ControlProxy::slotValueChanged, + copConnection); return true; } - /// Called from update(); - virtual void emitValueChanged() { - emit valueChanged(get()); - } - inline bool valid() const { return m_pControl != nullptr; } @@ -173,24 +154,9 @@ class ControlProxy : public QObject { void valueChanged(double); protected slots: - /// Receives the value from the master control by a unique direct connection - void slotValueChangedDirect(double v, QObject* pSetter) { - if (pSetter != this) { - // This is base implementation of this function without scaling - emit valueChanged(v); - } - } - - /// Receives the value from the master control by a unique auto connection - void slotValueChangedAuto(double v, QObject* pSetter) { - if (pSetter != this) { - // This is base implementation of this function without scaling - emit valueChanged(v); - } - } - - /// Receives the value from the master control by a unique Queued connection - void slotValueChangedQueued(double v, QObject* pSetter) { + /// Receives the value from the underlying control and emits the + /// `valueChanged` signal + void slotValueChanged(double v, QObject* pSetter) { if (pSetter != this) { // This is base implementation of this function without scaling emit valueChanged(v); diff --git a/src/controllers/scripting/legacy/controllerscriptinterfacelegacy.cpp b/src/controllers/scripting/legacy/controllerscriptinterfacelegacy.cpp index 40a46f544f9..0dba026038d 100644 --- a/src/controllers/scripting/legacy/controllerscriptinterfacelegacy.cpp +++ b/src/controllers/scripting/legacy/controllerscriptinterfacelegacy.cpp @@ -410,7 +410,7 @@ QJSValue ControllerScriptInterfaceLegacy::connectControl(const QString& group, void ControllerScriptInterfaceLegacy::trigger(const QString& group, const QString& name) { ControlObjectScript* coScript = getControlObjectScript(group, name); if (coScript != nullptr) { - coScript->emitValueChanged(); + coScript->trigger(); } }