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
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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,27 +3918,32 @@ int PianoRoll::quantization() const | |
|
||
void PianoRoll::quantizeNotes() | ||
{ | ||
if( ! hasValidPattern() ) | ||
{ | ||
return; | ||
} | ||
|
||
NoteVector notes = getSelectedNotes(); | ||
|
||
if (notes.empty()) | ||
if( notes.empty() ) | ||
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 a new function, and therefore the old coding style (wrt spaces inside parentheses) should not apply. I realize this is late, but still 😅 |
||
{ | ||
for (Note* n : m_pattern->notes()) | ||
for( Note* n : m_pattern->notes() ) | ||
{ | ||
notes.push_back(n); | ||
notes.push_back( n ); | ||
} | ||
} | ||
|
||
for (Note* n : notes) | ||
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(); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 :)