The code seems correct, except that usually you put a space either before or after the ampersand when you declare the argument MidiMessage&, but that is just a readability issue.
It would help, if you post the line, where the debugger points to when crashing, together with the stack trace…
I got it to work. In the original code the problem was from setting a label’s text from handleIncomingMidiMessage. I should have posted the code exactly as it was.
Also, the ampersand thing was just a typo when I made the post.