Fixed LMMS crash when pressing Q in not existing piano roll. (#3609)
This commit is contained in:
committed by
Oskar Wallgren
parent
d3359f5a70
commit
567898143b
@@ -805,7 +805,7 @@ void PianoRoll::setBackgroundShade( const QColor & c )
|
||||
|
||||
|
||||
|
||||
void PianoRoll::drawNoteRect( QPainter & p, int x, int y,
|
||||
void PianoRoll::drawNoteRect( QPainter & p, int x, int y,
|
||||
int width, const Note * n, const QColor & noteCol,
|
||||
const QColor & selCol, const int noteOpc, const bool borders )
|
||||
{
|
||||
@@ -1918,7 +1918,7 @@ void PianoRoll::mouseReleaseEvent( QMouseEvent * me )
|
||||
{
|
||||
// select the notes within the selection rectangle and
|
||||
// then destroy the selection rectangle
|
||||
computeSelectedNotes(
|
||||
computeSelectedNotes(
|
||||
me->modifiers() & Qt::ShiftModifier );
|
||||
}
|
||||
else if( m_action == ActionMoveNote )
|
||||
@@ -2463,7 +2463,7 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift, bool ctrl )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m_action == ActionResizeNote)
|
||||
{
|
||||
// When resizing notes:
|
||||
@@ -2471,7 +2471,7 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift, bool ctrl )
|
||||
// If shift is pressed we resize and rearrange only the selected notes
|
||||
// If shift + ctrl then we also rearrange all posterior notes (sticky)
|
||||
// If shift is pressed but only one note is selected, apply sticky
|
||||
|
||||
|
||||
if (shift)
|
||||
{
|
||||
// Algorithm:
|
||||
@@ -2491,8 +2491,8 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift, bool ctrl )
|
||||
const Note *posteriorNote = nullptr;
|
||||
for (const Note *note : notes)
|
||||
{
|
||||
if (note->selected() && (posteriorNote == nullptr ||
|
||||
note->oldPos().getTicks() + note->oldLength().getTicks() >
|
||||
if (note->selected() && (posteriorNote == nullptr ||
|
||||
note->oldPos().getTicks() + note->oldLength().getTicks() >
|
||||
posteriorNote->oldPos().getTicks() + posteriorNote->oldLength().getTicks()))
|
||||
{
|
||||
posteriorNote = note;
|
||||
@@ -2512,9 +2512,9 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift, bool ctrl )
|
||||
if(note->selected())
|
||||
{
|
||||
// scale relative start and end positions by scaleFactor
|
||||
int newStart = stretchStartTick + scaleFactor *
|
||||
int newStart = stretchStartTick + scaleFactor *
|
||||
(note->oldPos().getTicks() - stretchStartTick);
|
||||
int newEnd = stretchStartTick + scaleFactor *
|
||||
int newEnd = stretchStartTick + scaleFactor *
|
||||
(note->oldPos().getTicks()+note->oldLength().getTicks() - stretchStartTick);
|
||||
// if not holding alt, quantize the offsets
|
||||
if(!alt)
|
||||
@@ -2533,7 +2533,7 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift, bool ctrl )
|
||||
int newLength = qMax(1, newEnd-newStart);
|
||||
if (note == posteriorNote)
|
||||
{
|
||||
posteriorDeltaThisFrame = (newStart+newLength) -
|
||||
posteriorDeltaThisFrame = (newStart+newLength) -
|
||||
(note->pos().getTicks() + note->length().getTicks());
|
||||
}
|
||||
note->setLength( MidiTime(newLength) );
|
||||
@@ -3918,27 +3918,32 @@ int PianoRoll::quantization() const
|
||||
|
||||
void PianoRoll::quantizeNotes()
|
||||
{
|
||||
if( ! hasValidPattern() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
NoteVector notes = getSelectedNotes();
|
||||
|
||||
if (notes.empty())
|
||||
if( notes.empty() )
|
||||
{
|
||||
for (Note* n : m_pattern->notes())
|
||||
for( Note* n : m_pattern->notes() )
|
||||
{
|
||||
notes.push_back(n);
|
||||
notes.push_back( n );
|
||||
}
|
||||
}
|
||||
|
||||
for (Note* n : notes)
|
||||
for( Note* n : notes )
|
||||
{
|
||||
if (n->length() == MidiTime(0))
|
||||
if( n->length() == MidiTime( 0 ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Note copy(*n);
|
||||
m_pattern->removeNote(n);
|
||||
copy.quantizePos(quantization());
|
||||
m_pattern->addNote(copy);
|
||||
m_pattern->removeNote( n );
|
||||
copy.quantizePos( quantization() );
|
||||
m_pattern->addNote( copy );
|
||||
}
|
||||
|
||||
update();
|
||||
|
||||
Reference in New Issue
Block a user