comparison main/MainWindow.cpp @ 793:568c6da853e6

Fix incoherent logic for what happens if MIDI arrives while no suitable layer is current (from coverity scan)
author Chris Cannam
date Wed, 03 Sep 2014 09:19:55 +0100
parents c8e378ad8a10
children c305961985c4
comparison
equal deleted inserted replaced
792:c8e378ad8a10 793:568c6da853e6
4052 { 4052 {
4053 Pane *currentPane = 0; 4053 Pane *currentPane = 0;
4054 NoteLayer *currentNoteLayer = 0; 4054 NoteLayer *currentNoteLayer = 0;
4055 TimeValueLayer *currentTimeValueLayer = 0; 4055 TimeValueLayer *currentTimeValueLayer = 0;
4056 4056
4057 if (m_paneStack) currentPane = m_paneStack->getCurrentPane(); 4057 if (m_paneStack) {
4058 currentPane = m_paneStack->getCurrentPane();
4059 }
4060
4058 if (currentPane) { 4061 if (currentPane) {
4059 currentNoteLayer = dynamic_cast<NoteLayer *> 4062 currentNoteLayer = dynamic_cast<NoteLayer *>
4060 (currentPane->getSelectedLayer()); 4063 (currentPane->getSelectedLayer());
4061 currentTimeValueLayer = dynamic_cast<TimeValueLayer *> 4064 currentTimeValueLayer = dynamic_cast<TimeValueLayer *>
4062 (currentPane->getSelectedLayer()); 4065 (currentPane->getSelectedLayer());
4066 }
4067
4068 if (!currentNoteLayer && !currentTimeValueLayer) {
4069 // discard these events
4070 while (m_midiInput->getEventsAvailable() > 0) {
4071 (void)m_midiInput->readEvent();
4072 }
4073 return;
4063 } 4074 }
4064 4075
4065 // This is called through a serialised signal/slot invocation 4076 // This is called through a serialised signal/slot invocation
4066 // (across threads). It could happen quite some time after the 4077 // (across threads). It could happen quite some time after the
4067 // event was actually received, which is why event timestamping 4078 // event was actually received, which is why event timestamping