From 566692b109a1ba9be516d5b29ece711a64c1aa46 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Wed, 18 Aug 2021 12:23:02 +0200 Subject: [PATCH 1/3] ControlProxy: Remove unnecessary methods for different connection types --- src/control/controlproxy.h | 45 +++++++------------------------------- 1 file changed, 8 insertions(+), 37 deletions(-) diff --git a/src/control/controlproxy.h b/src/control/controlproxy.h index be6adc1b124..d86f008b5e6 100644 --- a/src/control/controlproxy.h +++ b/src/control/controlproxy.h @@ -86,25 +86,11 @@ 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; } @@ -173,24 +159,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); From ae10c583721410e9c05967d6eff198d90b2e7b21 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Wed, 18 Aug 2021 14:16:30 +0200 Subject: [PATCH 2/3] ControlProxy: Remove unused `emitValueChanged()` method --- src/control/controlobjectscript.h | 4 ++-- src/control/controlproxy.h | 5 ----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/control/controlobjectscript.h b/src/control/controlobjectscript.h index 219a4b0a991..5340c906290 100644 --- a/src/control/controlobjectscript.h +++ b/src/control/controlobjectscript.h @@ -22,8 +22,8 @@ class ControlObjectScript : public ControlProxy { return m_scriptConnections.first(); }; void disconnectAllConnectionsToFunction(const QJSValue& function); - // Called from update(); - void emitValueChanged() override { + /// Called from `ControlEngineScriptLegacy::trigger` + void emitValueChanged() { emit trigger(get(), this); } diff --git a/src/control/controlproxy.h b/src/control/controlproxy.h index d86f008b5e6..cd139a99ce9 100644 --- a/src/control/controlproxy.h +++ b/src/control/controlproxy.h @@ -94,11 +94,6 @@ class ControlProxy : public QObject { return true; } - /// Called from update(); - virtual void emitValueChanged() { - emit valueChanged(get()); - } - inline bool valid() const { return m_pControl != nullptr; } From 22e54c4deb3798a374e5306f288dcc2badce582d Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Wed, 18 Aug 2021 21:31:42 +0200 Subject: [PATCH 3/3] ControlObjectScript: Improve naming of trigger signal/method --- src/control/controlobjectscript.cpp | 4 ++-- src/control/controlobjectscript.h | 6 +++--- .../scripting/legacy/controllerscriptinterfacelegacy.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) 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 5340c906290..ede0be26b41 100644 --- a/src/control/controlobjectscript.h +++ b/src/control/controlobjectscript.h @@ -23,13 +23,13 @@ class ControlObjectScript : public ControlProxy { void disconnectAllConnectionsToFunction(const QJSValue& function); /// Called from `ControlEngineScriptLegacy::trigger` - void emitValueChanged() { - emit trigger(get(), this); + 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/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(); } }