Skip to content

Commit

Permalink
Merge pull request #4236 from daschuer/assert_debug
Browse files Browse the repository at this point in the history
ControlDoublePrivate: log warning before assert fails.
  • Loading branch information
uklotzde committed Aug 21, 2021
2 parents 7bb2f29 + e124d1a commit c9df5af
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/control/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,12 @@ QSharedPointer<ControlDoublePrivate> 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(!"pCreatorCO != nullptr, ControlObject already created");
return nullptr;
}
return pControl;
Expand Down Expand Up @@ -311,26 +312,29 @@ double ControlDoublePrivate::getParameterForValue(double value) const {

double ControlDoublePrivate::getParameterForMidi(double midiParam) const {
QSharedPointer<ControlNumericBehavior> pBehavior = m_pBehavior;
VERIFY_OR_DEBUG_ASSERT(pBehavior) {
qWarning() << "Cannot set" << m_key << "by Midi";
if (!pBehavior) {
qWarning() << "Cannot get" << m_key << "for Midi";
DEBUG_ASSERT(!"pBehavior == nullptr, getParameterForMidi is returning 0");
return 0;
}
return pBehavior->midiToParameter(midiParam);
}

void ControlDoublePrivate::setValueFromMidi(MidiOpCode opcode, double midiParam) {
QSharedPointer<ControlNumericBehavior> pBehavior = m_pBehavior;
VERIFY_OR_DEBUG_ASSERT(pBehavior) {
qWarning() << "Cannot set" << m_key << "by Midi";
if (!pBehavior) {
qWarning() << "Cannot set" << m_key << "from Midi";
DEBUG_ASSERT(!"pBehavior == nullptr, abort setValueFromMidi()");
return;
}
pBehavior->setValueFromMidi(opcode, midiParam, this);
}

double ControlDoublePrivate::getMidiParameter() const {
QSharedPointer<ControlNumericBehavior> pBehavior = m_pBehavior;
VERIFY_OR_DEBUG_ASSERT(pBehavior) {
qWarning() << "Cannot get" << m_key << "by Midi";
if (!pBehavior) {
qWarning() << "Cannot get" << m_key << "as Midi";
DEBUG_ASSERT(!"pBehavior == nullptr, getMidiParameter() is returning 0");
return 0;
}
return pBehavior->valueToMidiParameter(get());
Expand Down

0 comments on commit c9df5af

Please sign in to comment.