Skip to content
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

Merged
merged 3 commits into from
Jun 7, 2017

Conversation

karmux
Copy link
Contributor

@karmux karmux commented Jun 4, 2017

Steps to reproduce:

  1. Open LMMS
  2. Open Piano-Roll
  3. Click on Q
  4. LMMS crashes.

This change fixes it.
Link to issue: #3608.

@@ -3918,31 +3918,33 @@ int PianoRoll::quantization() const

void PianoRoll::quantizeNotes()
{
NoteVector notes = getSelectedNotes();
if( m_pattern != NULL ) {
Copy link
Contributor

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.

@Umcaruje Umcaruje added this to the 1.2.0 milestone Jun 6, 2017
@@ -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,
Copy link
Member

@zonkmachine zonkmachine Jun 7, 2017

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.

Copy link
Member

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.

Copy link
Contributor Author

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 :)

Copy link
Member

@zonkmachine zonkmachine left a 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.

@@ -3918,31 +3918,33 @@ int PianoRoll::quantization() const

void PianoRoll::quantizeNotes()
{
NoteVector notes = getSelectedNotes();
if( hasValidPattern() ) {
Copy link
Contributor

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.

@@ -3918,33 +3918,36 @@ int PianoRoll::quantization() const

void PianoRoll::quantizeNotes()
{
if( hasValidPattern() ) {
NoteVector notes = getSelectedNotes();
if( ! hasValidPattern() )
Copy link
Contributor

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!

Copy link
Member

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!

@tresf
Copy link
Member

tresf commented Jun 8, 2017

FYI, this commit is all ready to merge to master in liushuyu/merge.

Copy link
Contributor

@grejppi grejppi left a 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() )
Copy link
Contributor

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 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants