-
-
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
Conversation
src/gui/editors/PianoRoll.cpp
Outdated
@@ -3918,31 +3918,33 @@ int PianoRoll::quantization() const | |||
|
|||
void PianoRoll::quantizeNotes() | |||
{ | |||
NoteVector notes = getSelectedNotes(); | |||
if( m_pattern != NULL ) { |
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.
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.
@@ -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, |
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 :)
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.
Tested, works!
This PR has now been updated to conform with @michaelgregorius suggested changes. I suggest merge if there are no other concerns.
src/gui/editors/PianoRoll.cpp
Outdated
@@ -3918,31 +3918,33 @@ int PianoRoll::quantization() const | |||
|
|||
void PianoRoll::quantizeNotes() | |||
{ | |||
NoteVector notes = getSelectedNotes(); | |||
if( hasValidPattern() ) { |
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.
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 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.
src/gui/editors/PianoRoll.cpp
Outdated
@@ -3918,33 +3918,36 @@ int PianoRoll::quantization() const | |||
|
|||
void PianoRoll::quantizeNotes() | |||
{ | |||
if( hasValidPattern() ) { | |||
NoteVector notes = getSelectedNotes(); | |||
if( ! hasValidPattern() ) |
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.
That's what I meant. Thanks!
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.
Clean and simple. Retested, merging!
FYI, this commit is all ready to merge to master in |
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.
This is merely a cosmetic thing
NoteVector notes = getSelectedNotes(); | ||
|
||
if (notes.empty()) | ||
if( notes.empty() ) |
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.
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.