Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ControlDoublePrivate: log warning before assert fails. #4236

Merged
merged 2 commits into from
Aug 21, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 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(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition is out of sight here. Please use something like

Suggested change
DEBUG_ASSERT(false);
DEBUG_ASSERT(!"Tried to create Control Object that already exists.");

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) {
if (!pBehavior) {
qWarning() << "Cannot set" << m_key << "by Midi";
DEBUG_ASSERT(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

return 0;
}
return pBehavior->midiToParameter(midiParam);
}

void ControlDoublePrivate::setValueFromMidi(MidiOpCode opcode, double midiParam) {
QSharedPointer<ControlNumericBehavior> pBehavior = m_pBehavior;
VERIFY_OR_DEBUG_ASSERT(pBehavior) {
if (!pBehavior) {
qWarning() << "Cannot set" << m_key << "by Midi";
DEBUG_ASSERT(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here

return;
}
pBehavior->setValueFromMidi(opcode, midiParam, this);
}

double ControlDoublePrivate::getMidiParameter() const {
QSharedPointer<ControlNumericBehavior> pBehavior = m_pBehavior;
VERIFY_OR_DEBUG_ASSERT(pBehavior) {
if (!pBehavior) {
qWarning() << "Cannot get" << m_key << "by Midi";
DEBUG_ASSERT(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here

return 0;
}
return pBehavior->valueToMidiParameter(get());
Expand Down