Fixed LMMS crash when pressing Q in not existing piano roll. - #3609
Conversation
| void PianoRoll::quantizeNotes() | ||
| { | ||
| NoteVector notes = getSelectedNotes(); | ||
| if( m_pattern != NULL ) { |
There was a problem hiding this comment.
While this definitively works I'd propose to use the same style like in PianoRoll::cutSelectedNotes():
if( ! hasValidPattern() )
{
return;
}This make it more obvious what's tested and also keeps the indentation level of the method down.
|
|
||
| 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, |
There was a problem hiding this comment.
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.
@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.
I need to switch off editor's automatic cleanups :)
zonkmachine
left a comment
There was a problem hiding this comment.
Tested, works!
This PR has now been updated to conform with @michaelgregorius suggested changes. I suggest merge if there are no other concerns.
| void PianoRoll::quantizeNotes() | ||
| { | ||
| NoteVector notes = getSelectedNotes(); | ||
| if( hasValidPattern() ) { |
There was a problem hiding this comment.
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 hereThis is an often used pattern when the scope of an if statement encompasses a whole method. By doing it like this you also get rid of one indentation level for the code that's inside the if clause which makes the code more readable.
| { | ||
| if( hasValidPattern() ) { | ||
| NoteVector notes = getSelectedNotes(); | ||
| if( ! hasValidPattern() ) |
There was a problem hiding this comment.
That's what I meant. Thanks!
There was a problem hiding this comment.
Clean and simple. Retested, merging!
|
FYI, this commit is all ready to merge to master in |
grejppi
left a comment
There was a problem hiding this comment.
This is merely a cosmetic thing
| NoteVector notes = getSelectedNotes(); | ||
|
|
||
| if (notes.empty()) | ||
| if( notes.empty() ) |
There was a problem hiding this comment.
This is a new function, and therefore the old coding style (wrt spaces inside parentheses) should not apply. I realize this is late, but still 😅
Steps to reproduce:
This change fixes it.
Link to issue: #3608.