Skip to content

Commit

Permalink
fix(controllers): allow midino 0 in MidiController::makeInputHandler
Browse files Browse the repository at this point in the history
Fixes #14265
  • Loading branch information
git-developer committed Jan 31, 2025
1 parent 7b6001c commit 408c359
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/controllers/midi/midicontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ QJSValue MidiController::makeInputHandler(int status, int midino, const QJSValue
return QJSValue();
}

if (status <= 0 || midino <= 0) {
if (status <= 0 || midino < 0) {
auto mStatusError = QStringLiteral(
"Invalid status or midino passed to midi.makeInputHandler. "
"Please pass a strictly positive integer. status=%1,midino=%2")
Expand Down
13 changes: 10 additions & 3 deletions src/test/midicontrollertest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,10 +635,17 @@ TEST_F(MidiControllerTest, JSInputHandler_ControllerShutdownSlot) {
m_pController->setMapping(m_pMapping->clone());
EXPECT_EQ(getControllerMapping()->getInputMappings().count(), 0);
evaluateAndAssert(
"midi.makeInputHandler(0x90, 0x43, (channel, control, value, status) => {"
"engine.setParameter('[Channel1]', 'test_pot', value);"
"})");
"midi.makeInputHandler(0x90, 0x00, (channel, control, value, status) => {})");
EXPECT_EQ(getControllerMapping()->getInputMappings().count(), 1);
shutdownController();
EXPECT_EQ(getControllerMapping()->getInputMappings().count(), 0);
}

TEST_F(MidiControllerTest, JSInputHandler_ErrorWhenMidinoIsNegative) {
m_pController->setMapping(m_pMapping->clone());
EXPECT_EQ(getControllerMapping()->getInputMappings().count(), 0);
bool isError = evaluateAndAssert(
"midi.makeInputHandler(0x90, -1, (channel, control, value, status) => {})");
ASSERT_TRUE(isError);
EXPECT_EQ(getControllerMapping()->getInputMappings().count(), 0);
}

0 comments on commit 408c359

Please sign in to comment.