-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed LMMS crash when pressing Q in not existing piano roll. #3609
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,15 +2463,15 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift, bool ctrl ) | |
} | ||
} | ||
} | ||
} | ||
} | ||
else if (m_action == ActionResizeNote) | ||
{ | ||
// When resizing notes: | ||
// If shift is not pressed, resize the selected notes but do not rearrange them | ||
// 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,28 +3918,28 @@ int PianoRoll::quantization() const | |
|
||
void PianoRoll::quantizeNotes() | ||
{ | ||
if( m_pattern != NULL ) { | ||
if( hasValidPattern() ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is already better than before but I was also asking to use the following coding pattern: if ( !hasValidPattern() )
{
return;
}
NoteVector notes = getSelectedNotes();
// ...
// Everything that's inside the `if` statement follows here This is an often used pattern when the scope of an |
||
NoteVector notes = getSelectedNotes(); | ||
|
||
if( notes.empty() ) | ||
{ | ||
for( Note* n : m_pattern->notes() ) | ||
{ | ||
notes.push_back(n); | ||
notes.push_back( n ); | ||
} | ||
} | ||
|
||
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(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have one requested fix in here together with 14 lines that are formatting changes like whitespace at the end etc. This makes it a bit hard to review. I suggest for the next time to commit changes like this separately and name the commit 'fixup' or 'whitespace' or something similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zonkmachine agreed. Harder to cherry-pick too as the more lines that get modified increases the chances of a merge conflict.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to switch off editor's automatic cleanups :)