summaryrefslogtreecommitdiffstats
path: root/src/control
diff options
context:
space:
mode:
authorBe <be@mixxx.org>2020-09-01 17:53:05 -0500
committerBe <be@mixxx.org>2020-09-01 17:53:05 -0500
commit62fc40cd6e7c5c588c9911f558a3d4745a12d818 (patch)
treea118f288fd6a264994087c1df1c26c637aee5133 /src/control
parent197c0d0b80e6c4687b0e07d210505dc6a0e941d2 (diff)
parent445355d17184d8a98c90c293ab68931c7c3f9e35 (diff)
Merge remote-tracking branch 'upstream/master' into controllerengine_refactoring
Diffstat (limited to 'src/control')
-rw-r--r--src/control/control.cpp6
-rw-r--r--src/control/control.h8
-rw-r--r--src/control/controlobject.cpp4
-rw-r--r--src/control/controlobjectscript.cpp2
-rw-r--r--src/control/controlproxy.cpp6
5 files changed, 16 insertions, 10 deletions
diff --git a/src/control/control.cpp b/src/control/control.cpp
index 99f72ce37f..9b0ae2f9f9 100644
--- a/src/control/control.cpp
+++ b/src/control/control.cpp
@@ -101,9 +101,9 @@ QSharedPointer<ControlDoublePrivate> ControlDoublePrivate::getControl(
bool bTrack,
bool bPersist,
double defaultValue) {
- VERIFY_OR_DEBUG_ASSERT(!key.isEmpty()) {
- qWarning() << "ControlDoublePrivate::getControl returning NULL"
- << "for empty ConfigKey.";
+ VERIFY_OR_DEBUG_ASSERT(key.isValid()) {
+ qWarning() << "ControlDoublePrivate::getControl returning nullptr"
+ << "for invalid ConfigKey" << key;
return nullptr;
}
diff --git a/src/control/control.h b/src/control/control.h
index 5ff49bcd4b..da89fafb06 100644
--- a/src/control/control.h
+++ b/src/control/control.h
@@ -15,9 +15,15 @@ class ControlObject;
enum class ControlFlag {
None = 0,
- AllowEmptyKey = 1,
+ /// Do not throw an assertion if the key is invalid. Needed for controller
+ /// mappings and skins.
+ AllowInvalidKey = 1,
+ /// Don't throw an assertion when trying to access a non-existing CO.
+ /// Needed for controller mappings and skins.
NoAssertIfMissing = 1 << 1,
+ /// Don't log a warning when trying to access a non-existing CO.
NoWarnIfMissing = (1 << 2) | NoAssertIfMissing,
+ AllowMissingOrInvalid = AllowInvalidKey | NoAssertIfMissing,
};
Q_DECLARE_FLAGS(ControlFlags, ControlFlag)
diff --git a/src/control/controlobject.cpp b/src/control/controlobject.cpp
index 988681cc50..543046e576 100644
--- a/src/control/controlobject.cpp
+++ b/src/control/controlobject.cpp
@@ -31,8 +31,8 @@ ControlObject::ControlObject() {
ControlObject::ControlObject(ConfigKey key, bool bIgnoreNops, bool bTrack,
bool bPersist, double defaultValue)
: m_key(key) {
- // Don't bother looking up the control if key is NULL. Prevents log spew.
- if (!m_key.isNull()) {
+ // Don't bother looking up the control if key is invalid. Prevents log spew.
+ if (m_key.isValid()) {
m_pControl = ControlDoublePrivate::getControl(m_key,
ControlFlag::None,
this,
diff --git a/src/control/controlobjectscript.cpp b/src/control/controlobjectscript.cpp
index 8465336bf0..fb997ad17f 100644
--- a/src/control/controlobjectscript.cpp
+++ b/src/control/controlobjectscript.cpp
@@ -3,7 +3,7 @@
#include "control/controlobjectscript.h"
ControlObjectScript::ControlObjectScript(const ConfigKey& key, QObject* pParent)
- : ControlProxy(key, pParent, ControlFlag::NoAssertIfMissing) {
+ : ControlProxy(key, pParent, ControlFlag::AllowMissingOrInvalid) {
}
bool ControlObjectScript::addScriptConnection(const ScriptConnection& conn) {
diff --git a/src/control/controlproxy.cpp b/src/control/controlproxy.cpp
index f0b93961a5..5ca1f04630 100644
--- a/src/control/controlproxy.cpp
+++ b/src/control/controlproxy.cpp
@@ -14,10 +14,10 @@ ControlProxy::ControlProxy(const char* g, const char* i, QObject* pParent, Contr
ControlProxy::ControlProxy(const ConfigKey& key, QObject* pParent, ControlFlags flags)
: QObject(pParent),
m_pControl(nullptr) {
- DEBUG_ASSERT(!key.isNull() || flags.testFlag(ControlFlag::AllowEmptyKey));
+ DEBUG_ASSERT(key.isValid() || flags.testFlag(ControlFlag::AllowInvalidKey));
m_key = key;
- if (!m_key.isNull()) {
+ if (m_key.isValid()) {
initialize(flags);
}
}
@@ -27,7 +27,7 @@ void ControlProxy::initialize(ControlFlags flags) {
DEBUG_ASSERT(!m_pControl);
// Prevent empty keys
- VERIFY_OR_DEBUG_ASSERT(!m_key.isNull() || flags.testFlag(ControlFlag::AllowEmptyKey)) {
+ VERIFY_OR_DEBUG_ASSERT(m_key.isValid() || flags.testFlag(ControlFlag::AllowInvalidKey)) {
return;
}