Race condition in juce_linux_Midi.cpp

My application is receiving a continuous stream of MIDI message. When I’m deleting a MidiInput (when exiting the application for example), I’m sometimes getting calls to

void handleIncomingMidiMessage (snd_seq_event* event, const MidiMessage& message)

while ~MidiInput is running. More precisely, handleIncomingMidiMessage crashes because ports[event->dest.port] is nullptr ( it is set to nullptr by ports.set (port->portId, nullptr); in deletePort .

the ~MidiInput is executed in the message thread, while the handleIncomingMidiMessage runs in the MidiInputThread.

Thanks for reporting, I’ve attempted to fix this issue here:

Please let me know if you run into any problems with this change.

It seems to work fine, thanks !