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.
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.
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);
}
}