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

Only set sample clips for valid files #7224

Conversation

michaelgregorius
Copy link
Contributor

Check if a non-empty buffer was loaded and only set the sample clip if that's the case.

Fix code formatting.

Fixes #6287.

Check if a non-empty buffer was loaded and only set the sample clip if that's the case.

Fix code formatting.
Move setting the song to modified towards the core in the context of `SampleClip`. Previously the `SampleClipView` did this but it's none of it's business.

Introduce `SampleClip::changeLengthToSampleLength` which changes the length of the clip to the length of the sample. This was also previously done by the view which is again the wrong place to do the necessary calculations.
Remove the `QMessageBox` include which is a left over of another fix attempt.
Copy link
Contributor

@sakertooth sakertooth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comments are a bit much. I feel like the code is simple enough that it can be understood very well without them. Also, we might want to change SampleLoader::createBufferFromFile to return nullptr later. It returned an empty buffer just in case callers did not handle it properly, but it may make checking for validity more simplistic.

src/gui/clips/SampleClipView.cpp Show resolved Hide resolved
src/gui/clips/SampleClipView.cpp Show resolved Hide resolved
src/core/SampleClip.cpp Show resolved Hide resolved
src/core/SampleClip.cpp Show resolved Hide resolved
src/core/SampleClip.cpp Outdated Show resolved Hide resolved
Remove an unnecessary `static_cast`.
@sakertooth
Copy link
Contributor

Do we really need all of these comments? The code is very simple to understand without them.

Add the method `SampleClip::hasSampleFileLoaded` and remove some comments.
@michaelgregorius
Copy link
Contributor Author

Do we really need all of these comments? The code is very simple to understand without them.

Most of the comments have been kept and slightly adjusted from the previous code. With commit 4d5bf7c I have removed them. I have also introduced SampleClip::hasSampleFileLoaded to make the check more readable so that the comment can also be removed there. Before it was not directly obvious that the string comparison checks if the filename corresponds to the file that's loaded in the clip.

@michaelgregorius michaelgregorius merged commit bb6a77a into LMMS:master Apr 29, 2024
9 checks passed
@michaelgregorius michaelgregorius deleted the 6287-OnlySetValidSampleFilesInClips branch April 29, 2024 17:23
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.

SampleClip: valid file disappears when replaced with invalid one
3 participants