From 5080d9fef0622f3080d7b5796674f5c3bd16bffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sat, 21 Aug 2021 00:54:58 +0200 Subject: [PATCH 1/2] ControlDoublePrivate: Make sure the warning is printed before the assertion kills mixxx --- src/control/control.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/control/control.cpp b/src/control/control.cpp index 1187200dd77..5d03c3c6123 100644 --- a/src/control/control.cpp +++ b/src/control/control.cpp @@ -148,11 +148,12 @@ QSharedPointer ControlDoublePrivate::getControl( auto pControl = it.value().lock(); if (pControl) { // Control object already exists - VERIFY_OR_DEBUG_ASSERT(!pCreatorCO) { + if (pCreatorCO) { qWarning() << "ControlObject" << key.group << key.item << "already created"; + DEBUG_ASSERT(false); return nullptr; } return pControl; @@ -311,8 +312,9 @@ double ControlDoublePrivate::getParameterForValue(double value) const { double ControlDoublePrivate::getParameterForMidi(double midiParam) const { QSharedPointer pBehavior = m_pBehavior; - VERIFY_OR_DEBUG_ASSERT(pBehavior) { + if (!pBehavior) { qWarning() << "Cannot set" << m_key << "by Midi"; + DEBUG_ASSERT(false); return 0; } return pBehavior->midiToParameter(midiParam); @@ -320,8 +322,9 @@ double ControlDoublePrivate::getParameterForMidi(double midiParam) const { void ControlDoublePrivate::setValueFromMidi(MidiOpCode opcode, double midiParam) { QSharedPointer pBehavior = m_pBehavior; - VERIFY_OR_DEBUG_ASSERT(pBehavior) { + if (!pBehavior) { qWarning() << "Cannot set" << m_key << "by Midi"; + DEBUG_ASSERT(false); return; } pBehavior->setValueFromMidi(opcode, midiParam, this); @@ -329,8 +332,9 @@ void ControlDoublePrivate::setValueFromMidi(MidiOpCode opcode, double midiParam) double ControlDoublePrivate::getMidiParameter() const { QSharedPointer pBehavior = m_pBehavior; - VERIFY_OR_DEBUG_ASSERT(pBehavior) { + if (!pBehavior) { qWarning() << "Cannot get" << m_key << "by Midi"; + DEBUG_ASSERT(false); return 0; } return pBehavior->valueToMidiParameter(get()); From e124d1a4d18dca7717126aef25f5e52214f605fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sat, 21 Aug 2021 12:59:39 +0200 Subject: [PATCH 2/2] Replace DEBUG_ASSERT(false) with an inverted string literal --- src/control/control.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/control/control.cpp b/src/control/control.cpp index 5d03c3c6123..d7d4db46d60 100644 --- a/src/control/control.cpp +++ b/src/control/control.cpp @@ -153,7 +153,7 @@ QSharedPointer ControlDoublePrivate::getControl( << "ControlObject" << key.group << key.item << "already created"; - DEBUG_ASSERT(false); + DEBUG_ASSERT(!"pCreatorCO != nullptr, ControlObject already created"); return nullptr; } return pControl; @@ -313,8 +313,8 @@ double ControlDoublePrivate::getParameterForValue(double value) const { double ControlDoublePrivate::getParameterForMidi(double midiParam) const { QSharedPointer pBehavior = m_pBehavior; if (!pBehavior) { - qWarning() << "Cannot set" << m_key << "by Midi"; - DEBUG_ASSERT(false); + qWarning() << "Cannot get" << m_key << "for Midi"; + DEBUG_ASSERT(!"pBehavior == nullptr, getParameterForMidi is returning 0"); return 0; } return pBehavior->midiToParameter(midiParam); @@ -323,8 +323,8 @@ double ControlDoublePrivate::getParameterForMidi(double midiParam) const { void ControlDoublePrivate::setValueFromMidi(MidiOpCode opcode, double midiParam) { QSharedPointer pBehavior = m_pBehavior; if (!pBehavior) { - qWarning() << "Cannot set" << m_key << "by Midi"; - DEBUG_ASSERT(false); + qWarning() << "Cannot set" << m_key << "from Midi"; + DEBUG_ASSERT(!"pBehavior == nullptr, abort setValueFromMidi()"); return; } pBehavior->setValueFromMidi(opcode, midiParam, this); @@ -333,8 +333,8 @@ void ControlDoublePrivate::setValueFromMidi(MidiOpCode opcode, double midiParam) double ControlDoublePrivate::getMidiParameter() const { QSharedPointer pBehavior = m_pBehavior; if (!pBehavior) { - qWarning() << "Cannot get" << m_key << "by Midi"; - DEBUG_ASSERT(false); + qWarning() << "Cannot get" << m_key << "as Midi"; + DEBUG_ASSERT(!"pBehavior == nullptr, getMidiParameter() is returning 0"); return 0; } return pBehavior->valueToMidiParameter(get());