BUG+FIX: backwards compatibility for void removeMidiInputCallback forgotton?

Pass in an empty string to deselect all devices.

I think this is not possible anymore.

Even if the method is deprecated, this is a big problem because it cause crash on existing code, midi-callback isn’t deleted.

backwards compatibility for addMidiInputCallback was reintroduced here:


okay, i have to use removeMidiInputDeviceCallback now, but it seems to have the same problem.
If i want to remove a callback from all devices, there is no check if the identifier is empty, i guess this is a bug.

I created this pull request to fix the bug

connect means disconnect :wink:

Nobody interested in fixing this crashing bug?

audioDeviceManager.removeMidiInputDeviceCallback ({}, this); is used multiple times in the juce sourcecode tree, it will result in a crash, because midi-callbacks will arrive after calling it. Also removeMidiInputCallback needs the same fix, because the behaviour was removed and only partially restored.

These are all required changes:

1 Like

Thanks for reporting, backwards compatibility for passing an empty string to the deprecated AudioDeviceManager::removeMidiInputCallback() has been fixed in 240089b.

removeMidiInputDeviceCallback() doesn’t require an explicit check for an empty identifier. If you’ve indicated that you want to receive all events from all devices by passing an empty string to addMidiInputDeviceCallback() then the MidiCallbackInfo::deviceIdentifier will be empty and the following check in removeMidiInputDeviceCallback() will correctly remove the callback that was registered:

for (int i = midiCallbacks.size(); --i >= 0;)
    auto& mc = midiCallbacks.getReference (i);

    if (mc.callback == callbackToRemove && mc.deviceIdentifier == identifier)
        const ScopedLock sl (midiCallbackLock);
        midiCallbacks.remove (i);
1 Like