PianoRoll: fixed crash with detune tool
When clicking at an invalid position with the detune tool, LMMS could
crash as an invalid iterator was referenced (closes #2808589).
Furthermore renamed PianoRoll::ModeOpen to PianoRoll::ModeEditDetuning.
Signed-off-by: Tobias Doerffel <tobias.doerffel@gmail.com>
(cherry picked from commit 9ca93040de)
This commit is contained in:
@@ -150,7 +150,7 @@ private:
|
||||
ModeDraw,
|
||||
ModeErase,
|
||||
ModeSelect,
|
||||
ModeOpen,
|
||||
ModeEditDetuning,
|
||||
};
|
||||
|
||||
enum actions
|
||||
@@ -311,8 +311,7 @@ private:
|
||||
void drawDetuningInfo( QPainter & _p, note * _n, int _x, int _y );
|
||||
bool mouseOverNote( void );
|
||||
note * noteUnderMouse( void );
|
||||
NoteVector::const_iterator noteIteratorUnderMouse( void );
|
||||
|
||||
|
||||
// turn a selection rectangle into selected notes
|
||||
void computeSelectedNotes( bool shift );
|
||||
void clearSelectedNotes( void );
|
||||
|
||||
@@ -1295,7 +1295,7 @@ void pianoRoll::mousePressEvent( QMouseEvent * _me )
|
||||
return;
|
||||
}
|
||||
|
||||
if( m_editMode == ModeOpen && noteUnderMouse() )
|
||||
if( m_editMode == ModeEditDetuning && noteUnderMouse() )
|
||||
{
|
||||
noteUnderMouse()->editDetuningPattern();
|
||||
return;
|
||||
@@ -2883,7 +2883,7 @@ void pianoRoll::paintEvent( QPaintEvent * _pe )
|
||||
break;
|
||||
case ModeErase: cursor = s_toolErase; break;
|
||||
case ModeSelect: cursor = s_toolSelect; break;
|
||||
case ModeOpen: cursor = s_toolOpen; break;
|
||||
case ModeEditDetuning: cursor = s_toolOpen; break;
|
||||
}
|
||||
if( cursor != NULL )
|
||||
{
|
||||
@@ -3206,7 +3206,7 @@ void pianoRoll::selectButtonToggled( void )
|
||||
|
||||
void pianoRoll::detuneButtonToggled( void )
|
||||
{
|
||||
m_editMode = ModeOpen;
|
||||
m_editMode = ModeEditDetuning;
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -3570,22 +3570,13 @@ midiTime pianoRoll::newNoteLen( void ) const
|
||||
|
||||
bool pianoRoll::mouseOverNote( void )
|
||||
{
|
||||
return validPattern() &&
|
||||
noteIteratorUnderMouse() != m_pattern->notes().end();
|
||||
return validPattern() && noteUnderMouse() != NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
note * pianoRoll::noteUnderMouse( void )
|
||||
{
|
||||
return *noteIteratorUnderMouse();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
NoteVector::ConstIterator pianoRoll::noteIteratorUnderMouse( void )
|
||||
{
|
||||
QPoint pos = mapFromGlobal( QCursor::pos() );
|
||||
|
||||
@@ -3596,7 +3587,7 @@ NoteVector::ConstIterator pianoRoll::noteIteratorUnderMouse( void )
|
||||
|| pos.y() < PR_TOP_MARGIN
|
||||
|| pos.y() > keyAreaBottom() )
|
||||
{
|
||||
return notes.end();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int key_num = getKey( pos.y() );
|
||||
@@ -3620,11 +3611,12 @@ NoteVector::ConstIterator pianoRoll::noteIteratorUnderMouse( void )
|
||||
++it;
|
||||
}
|
||||
|
||||
return it;
|
||||
return *it;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#include "moc_piano_roll.cxx"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user