-
-
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
Replace every use of the foreach macro with a C++11 range-based for loop #2669
Conversation
@@ -56,7 +56,7 @@ class EXPORT InstrumentPlayHandle : public PlayHandle | |||
do | |||
{ | |||
nphsLeft = false; | |||
foreach( const NotePlayHandle * cnph, nphv ) | |||
for( const NotePlayHandle * cnph : nphv ) |
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 would rename cnph
to something like notePlayHandle
to make things more readable in the loop.
@Fastigium I have left some remarks. Looks good to me otherwise. Thanks for your efforts! |
@michaelgregorius Thanks, I adapted And I also noticed that the Windows builds didn't work anymore in Travis. Apparently switching to |
@Fastigium are you sure it's needed? We already do that here: https://github.com/LMMS/lmms/blob/master/src/CMakeLists.txt#L11 |
@tresf It won't compile otherwise, as I replaced some foreach loops in |
When I compile my own projects under Windows with MinGW I have to add the following snippet to my
Otherwise the compiler has problems with constants from the I now wonder whether the |
Then add it to the affected plugins. 👍 |
Or optionally... leave the plugin fixing to the plugin authors 😆 |
That could take a while :P. I'll try adding it to the affected plugins. |
This is how I did it for FLP import: |
I'm guessing cmake helps out per http://stackoverflow.com/a/16144116/3196753 |
I think the builds break because you simply replaced
with
In the new version the |
@michaelgregorius Yeah, I just rebased the const_cast back in minutes ago. I think I'll leave it there for now. That part of |
Ok, rebased to only @tresf Should I include that |
Well, this was recently changed to |
M_PI is no longer defined by default in C++11, but lb302.cpp needs it. Therefore, before switching to C++11, we add an include.
This prevents a race condition with Qt5. A foreach loop makes a copy of its Qt container, increasing the reference count to the container's internal data. Qt5 often asserts isDetached(), which requires the reference count to be <= 1. This assertion fails when the foreach loop increases the reference count at exactly the wrong moment. Using a range-based for loop prevents an unnecessary copy from being made and ensures this race condition isn't triggered.
Right, after playing ping pong with Travis for a few hours, this PR is finally all green! I also performed the move-channels-while-playing-RandomProjectNumber14253-test again with no crashes, and #2659 is still absent as well. Can anyone look over the rebased code once more? Only the first two commits were changed. |
@@ -1,3 +1,6 @@ | |||
INCLUDE(BuildPlugin) | |||
|
|||
# Enable C++11 | |||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") |
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 assume ADD_DEFINITIONS
didn't work here?
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.
Correct, it triggers a warning that it's an invalid option for C files
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'm going to go ahead and merge this. I have a PR ready to fix FX channel removal crashes, and it would benefit the testing of that one a lot if no random race conditions got in the way. Thanks for all the feedback, and if I'm too brash merging this on my own, please let me know. |
Replace every use of the foreach macro with a C++11 range-based for loop
And, all of a sudden, everything just works... |
Feedback on the
CMakeLists.txt
changes, please! I don't know how to do that right. Plus things aren't const correct everywhere. Otherwise, this PR should be as good as #2658, and even doesn't exhibit #2659 😊Main commit message: