# HG changeset patch # User Chris Cannam # Date 1409732395 -3600 # Node ID 568c6da853e6cdf7ac4c770ad5ba5056e67e8e94 # Parent c8e378ad8a10f512954adbbc824bd2d51c6cf710 Fix incoherent logic for what happens if MIDI arrives while no suitable layer is current (from coverity scan) diff -r c8e378ad8a10 -r 568c6da853e6 main/MainWindow.cpp --- a/main/MainWindow.cpp Wed Sep 03 09:17:01 2014 +0100 +++ b/main/MainWindow.cpp Wed Sep 03 09:19:55 2014 +0100 @@ -4054,7 +4054,10 @@ NoteLayer *currentNoteLayer = 0; TimeValueLayer *currentTimeValueLayer = 0; - if (m_paneStack) currentPane = m_paneStack->getCurrentPane(); + if (m_paneStack) { + currentPane = m_paneStack->getCurrentPane(); + } + if (currentPane) { currentNoteLayer = dynamic_cast (currentPane->getSelectedLayer()); @@ -4062,6 +4065,14 @@ (currentPane->getSelectedLayer()); } + if (!currentNoteLayer && !currentTimeValueLayer) { + // discard these events + while (m_midiInput->getEventsAvailable() > 0) { + (void)m_midiInput->readEvent(); + } + return; + } + // This is called through a serialised signal/slot invocation // (across threads). It could happen quite some time after the // event was actually received, which is why event timestamping