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
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions src/gui/editors/PianoRoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.

NoteVector notes = getSelectedNotes();

if (notes.empty())
{
for (Note* n : m_pattern->notes())
if( notes.empty() )
{
notes.push_back(n);
for( Note* n : m_pattern->notes() )
{
notes.push_back(n);
}
}
}

for (Note* n : notes)
{
if (n->length() == MidiTime(0))
for( Note* n : notes )
{
continue;
if (n->length() == MidiTime(0))
{
continue;
}

Note copy(*n);
m_pattern->removeNote(n);
copy.quantizePos(quantization());
m_pattern->addNote(copy);
}

Note copy(*n);
m_pattern->removeNote(n);
copy.quantizePos(quantization());
m_pattern->addNote(copy);
update();
gui->songEditor()->update();
}

update();
gui->songEditor()->update();
}


Expand Down