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>
This commit is contained in:
Tobias Doerffel
2009-06-18 23:26:15 +02:00
parent e12476f79c
commit 9ca93040de
2 changed files with 9 additions and 18 deletions

View File

@@ -152,7 +152,7 @@ private:
ModeDraw,
ModeErase,
ModeSelect,
ModeOpen,
ModeEditDetuning,
};
enum Actions
@@ -313,8 +313,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 );

View File

@@ -1303,7 +1303,7 @@ void pianoRoll::mousePressEvent( QMouseEvent * _me )
return;
}
if( m_editMode == ModeOpen && noteUnderMouse() )
if( m_editMode == ModeEditDetuning && noteUnderMouse() )
{
noteUnderMouse()->editDetuningPattern();
return;
@@ -2887,7 +2887,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 )
{
@@ -3216,7 +3216,7 @@ void pianoRoll::selectButtonToggled( void )
void pianoRoll::detuneButtonToggled( void )
{
m_editMode = ModeOpen;
m_editMode = ModeEditDetuning;
update();
}
@@ -3580,22 +3580,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() );
@@ -3606,7 +3597,7 @@ NoteVector::ConstIterator pianoRoll::noteIteratorUnderMouse( void )
|| pos.y() < TopMargin
|| pos.y() > keyAreaBottom() )
{
return notes.end();
return NULL;
}
int key_num = getKey( pos.y() );
@@ -3630,11 +3621,12 @@ NoteVector::ConstIterator pianoRoll::noteIteratorUnderMouse( void )
++it;
}
return it;
return *it;
}
#include "moc_piano_roll.cxx"