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

Fix Qt Deprecations #6386

Merged
merged 1 commit into from
Jun 23, 2022
Merged

Conversation

sakertooth
Copy link
Contributor

This PR fixes the following deprecations in src:

‘QMutex::QMutex(QMutex::RecursionMode)’ is deprecated: Use QRecursiveMutex instead of a recursive QMutex

‘QTextStream& QTextStreamFunctions::endl(QTextStream&)’ is deprecated: Use Qt::endl

‘Qt::MidButton’ is deprecated: MidButton is deprecated. Use MiddleButton instead

‘QPalette::Background’ is deprecated: Use QPalette::Window instead

‘QStringList QString::split(QChar, QString::SplitBehavior, Qt::CaseSensitivity) const’ is deprecated: Use 
Qt::SplitBehavior variant instead

@LmmsBot
Copy link

LmmsBot commented Apr 23, 2022

🤖 Hey, I'm @LmmsBot from github.com/lmms/bot and I made downloads for this pull request, click me to make them magically appear! 🎩

Linux

Windows

🤖
{"platform_name_to_artifacts": {"Linux": [{"artifact": {"title": {"title": "(AppImage)", "platform_name": "Linux"}, "link": {"link": "https://output.circle-artifacts.com/output/job/8c4b39a6-87d3-4665-825c-7e43350abe15/artifacts/0/lmms-1.3.0-alpha.1.196+gb3ccfeff2-linux-x86_64.AppImage"}}, "build_link": "https://circleci.com/gh/sakertooth/lmms/238?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}], "Windows": [{"artifact": {"title": {"title": "32-bit", "platform_name": "Windows"}, "link": {"link": "https://output.circle-artifacts.com/output/job/431110e6-f24d-4885-a7fb-455897ac07f6/artifacts/0/lmms-1.3.0-alpha.1.196+gb3ccfeff2-mingw-win32.exe"}}, "build_link": "https://circleci.com/gh/sakertooth/lmms/237?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}, {"artifact": {"title": {"title": "64-bit", "platform_name": "Windows"}, "link": {"link": "https://output.circle-artifacts.com/output/job/b862e0b4-4b01-4227-b3e0-ec5971a78f37/artifacts/0/lmms-1.3.0-alpha.1.196+gb3ccfeff2-mingw-win64.exe"}}, "build_link": "https://circleci.com/gh/sakertooth/lmms/239?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}, {"artifact": {"title": {"title": "32-bit", "platform_name": "Windows"}, "link": {"link": "https://ci.appveyor.com/api/buildjobs/v0pesmhd7rismgq9/artifacts/build/lmms-1.3.0-alpha-msvc2017-win32.exe"}}, "build_link": "https://ci.appveyor.com/project/Lukas-W/lmms/builds/43907999"}, {"artifact": {"title": {"title": "64-bit", "platform_name": "Windows"}, "link": {"link": "https://ci.appveyor.com/api/buildjobs/xbpjtwugjm34q7vd/artifacts/build/lmms-1.3.0-alpha-msvc2017-win64.exe"}}, "build_link": "https://ci.appveyor.com/project/Lukas-W/lmms/builds/43907999"}]}, "commit_sha": "b3ccfeff2de3542f82b54a88e55676e144901926"}

@Veratil
Copy link
Contributor

Veratil commented Apr 23, 2022

I don't see anything in the 5.15 Qt docs about QMutex::QMutex([QMutex::RecursionMode]) being deprecated. https://doc.qt.io/qt-5/qmutex.html#QMutex-1

Qt::endl is fine. I don't even see anything about QTextStreamFunctions anymore.

Qt::MiddleButton is fine.

QPalette::Background has been deprecated since 5.13, I don't think we should switch to QPalette::Window explicitly yet. I think we should use the normal #if (QT_VERSION >= QT_VERSION_CHECK(5,13,0)) guard instead for now.

It looks like Qt::SplitBehavior was copied from QString::SplitBehavior in 5.14. Another we'll probably want to use the version check live above for.

@sakertooth
Copy link
Contributor Author

sakertooth commented Apr 23, 2022

I don't see anything in the 5.15 Qt docs about QMutex::QMutex([QMutex::RecursionMode]) being deprecated. https://doc.qt.io/qt-5/qmutex.html#QMutex-1

Qt::endl is fine. I don't even see anything about QTextStreamFunctions anymore.

Qt::MiddleButton is fine.

QPalette::Background has been deprecated since 5.13, I don't think we should switch to QPalette::Window explicitly yet. I think we should use the normal #if (QT_VERSION >= QT_VERSION_CHECK(5,13,0)) guard instead for now.

It looks like Qt::SplitBehavior was copied from QString::SplitBehavior in 5.14. Another we'll probably want to use the version check live above for.

Seems like I had Qt 6 on my system, so it compiled fine on my end and gave a warning for QMutex::QMutex([QMutex::RecursionMode]). I'll be reverting some of the changes soon however.

@Veratil
Copy link
Contributor

Veratil commented Apr 23, 2022

Seems like I had Qt 6 on my system, so it compiled fine on my end and gave a warning for QMutex::QMutex([QMutex::RecursionMode]). I'll be reverting some of the changes soon however.

You don't need to revert, just check out #5619 for examples of how to handle deprecation stuff. :)

@sakertooth
Copy link
Contributor Author

Deprecation of QMutex::QMutex([QMutex::RecursionMode]) is not specified in the docs, but I found this in Qt's code:

#if QT_DEPRECATED_SINCE(5,15)
    enum RecursionMode { NonRecursive, Recursive };
    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
    explicit QMutex(RecursionMode mode);

    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
    bool isRecursive() const noexcept
    { return QBasicMutex::isRecursive(); }
#endif

@Veratil
Copy link
Contributor

Veratil commented Apr 23, 2022

Deprecation of QMutex::QMutex([QMutex::RecursionMode]) is not specified in the docs, but I found this in Qt's code:

#if QT_DEPRECATED_SINCE(5,15)
    enum RecursionMode { NonRecursive, Recursive };
    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
    explicit QMutex(RecursionMode mode);

    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
    bool isRecursive() const noexcept
    { return QBasicMutex::isRecursive(); }
#endif

Alright, I think this should be fine then. 👍

@sakertooth sakertooth requested a review from Veratil April 23, 2022 17:31
Copy link
Contributor

@Veratil Veratil left a comment

Choose a reason for hiding this comment

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

Mostly style changes to move the preprocessor directives to the beginning of the line.
One move request to put a doc comment back in place.
One question about removing a previously added deprecation section.

sakertooth added a commit to sakertooth/lmms that referenced this pull request Apr 24, 2022
Co-authored-by: Kevin Zander <[email protected]>
@JohannesLorenz
Copy link
Contributor

Just for information, clazy 1.11 also warns that you should replace QMutex by QRecursiveMutex, so I'm very positive about this PR.

@JohannesLorenz JohannesLorenz self-requested a review June 12, 2022 21:49
Copy link
Contributor

@JohannesLorenz JohannesLorenz left a comment

Choose a reason for hiding this comment

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

I left only 1 minor comment. Code looks mostly OK.

@JohannesLorenz
Copy link
Contributor

@Veratil are you OK with the last rework commit? If yes, then there is only testing review left.

@JohannesLorenz
Copy link
Contributor

Testing review failed!

I rebased this to master on my local machine and loaded a large demo song ("Greippi - Krem Kaakkuja (Second Flight Remix).mmpz"). In master, the song plays normal, and the CPU is low if nothing is being played. In this branch, the song plays only with interruptions, and the CPU is high both when playing and when not playing. I assume that it's from the QMutex change (you could try to find out what causes it by removing parts of your PR).

@Veratil
Copy link
Contributor

Veratil commented Jun 18, 2022

Testing review failed!

I rebased this to master on my local machine and loaded a large demo song ("Greippi - Krem Kaakkuja (Second Flight Remix).mmpz"). In master, the song plays normal, and the CPU is low if nothing is being played. In this branch, the song plays only with interruptions, and the CPU is high both when playing and when not playing. I assume that it's from the QMutex change (you could try to find out what causes it by removing parts of your PR).

Does it do the same if you didn't rebase?

@JohannesLorenz
Copy link
Contributor

JohannesLorenz commented Jun 18, 2022

Does it do the same if you didn't rebase?

Yes. I just did the rebase to exclude that a master commit would have caused the difference. Can you reproduce this issue?

@Veratil
Copy link
Contributor

Veratil commented Jun 18, 2022

Does it do the same if you didn't rebase?

Yes. I just did the rebase to exclude that a master commit would have caused the difference. Can you reproduce this issue?

Unfortunately I can't even play it on any branch in my VM because it takes up too much CPU. It's constantly in the red.

@sakertooth sakertooth marked this pull request as draft June 18, 2022 16:37
@sakertooth
Copy link
Contributor Author

sakertooth commented Jun 18, 2022

Testing review failed!

I rebased this to master on my local machine and loaded a large demo song ("Greippi - Krem Kaakkuja (Second Flight Remix).mmpz"). In master, the song plays normal, and the CPU is low if nothing is being played. In this branch, the song plays only with interruptions, and the CPU is high both when playing and when not playing. I assume that it's from the QMutex change (you could try to find out what causes it by removing parts of your PR).

For me, it just segfaults for the same demo. I have no idea what is going on 😆, and the different demos I have tried segfault for different reasons it seems. Was doing a partial build.

@JohannesLorenz
Copy link
Contributor

For me, it just segfaults for the same demo. I have no idea what is going on laughing, and the different demos I have tried segfault for different reasons it seems.

Can you please run it in gdb, and print us a backtrace (bt)?

@sakertooth
Copy link
Contributor Author

For me, it just segfaults for the same demo. I have no idea what is going on laughing, and the different demos I have tried segfault for different reasons it seems.

Can you please run it in gdb, and print us a backtrace (bt)?

Sorry, disregard that. It was because I was doing a partial build for lmms. I usually do this to speed up build times, especially when I don't think I need to build the full suite of plugins.

Pertaining to the issue you described above, my CPU usage is fairly high when playing the project and then stays on some middle ground constantly. Not sure what could be the issue. Going to do some testing.

@sakertooth
Copy link
Contributor Author

Tested this on master, and I am seeing the same issue. I do not think this issue originates from this PR.

@JohannesLorenz
Copy link
Contributor

Tested this on master, and I am seeing the same issue

Dumb question, did you recompile and reinstall? Do you have a good computer?

@sakertooth
Copy link
Contributor Author

Tested this on master, and I am seeing the same issue

Dumb question, did you recompile and reinstall? Do you have a good computer?

My computer is fine, truly (although having 8 GB of RAM can sometimes be a bottleneck under heavy load, it should be more than enough). I reconfigured my CMake configuration and rebuilt everything on the master branch, but the CPU usage issue remains. It stays high on idle.

I forgot to mention that the playback for me has no interruptions of any kind even with the CPU being fairly high.

@JohannesLorenz JohannesLorenz self-requested a review June 18, 2022 20:02
Copy link
Contributor

@JohannesLorenz JohannesLorenz left a comment

Choose a reason for hiding this comment

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

My bad. I tested with pulseaudio (which is not RT safe), and thus got very strange results.

With ALSA, I now get much better results. It plays well there. Testing passed.

Also, the last commit looks good. @Veratil shall we merge this?

sakertooth added a commit to sakertooth/lmms that referenced this pull request Jun 18, 2022
Co-authored-by: Kevin Zander <[email protected]>
@sakertooth sakertooth marked this pull request as ready for review June 18, 2022 20:09
sakertooth added a commit to sakertooth/lmms that referenced this pull request Jun 18, 2022
Co-authored-by: Kevin Zander <[email protected]>
@Veratil
Copy link
Contributor

Veratil commented Jun 18, 2022

I'm okay with it. 👍

@JohannesLorenz
Copy link
Contributor

@sakertooth The PR is good, but can you please fix this merge conflict so we can merge it?

@sakertooth
Copy link
Contributor Author

@sakertooth The PR is good, but can you please fix this merge conflict so we can merge it?

Ah, just saw that the namespace PR was merged. Resolving merge conflicts soon.

sakertooth added a commit to sakertooth/lmms that referenced this pull request Jun 19, 2022
Co-authored-by: Kevin Zander <[email protected]>
sakertooth added a commit to sakertooth/lmms that referenced this pull request Jun 19, 2022
Co-authored-by: Kevin Zander <[email protected]>
Co-authored-by: Dominic Clark <[email protected]>
sakertooth added a commit to sakertooth/lmms that referenced this pull request Jun 19, 2022
Co-authored-by: Kevin Zander <[email protected]>
Co-authored-by: Dominic Clark <[email protected]>
Copy link
Contributor

@JohannesLorenz JohannesLorenz left a comment

Choose a reason for hiding this comment

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

I think there are 1 or 2 merge errors, but only whitespace.

sakertooth added a commit to sakertooth/lmms that referenced this pull request Jun 19, 2022
Co-authored-by: Kevin Zander <[email protected]>
Co-authored-by: Dominic Clark <[email protected]>
sakertooth added a commit to sakertooth/lmms that referenced this pull request Jun 19, 2022
Co-authored-by: Kevin Zander <[email protected]>
Co-authored-by: Dominic Clark <[email protected]>
Co-authored-by: Kevin Zander <[email protected]>
Co-authored-by: Dominic Clark <[email protected]>
@sakertooth
Copy link
Contributor Author

Merge?

@JohannesLorenz JohannesLorenz merged commit 420769a into LMMS:master Jun 23, 2022
CLandel89 added a commit to CLandel89/lmms that referenced this pull request Jul 7, 2022
Typo in MicrotunerConfig.cpp.
@sakertooth sakertooth deleted the fix-deprecations branch December 8, 2022 05:25
sakertooth added a commit to sakertooth/lmms that referenced this pull request May 30, 2023
Co-authored-by: Kevin Zander <[email protected]>
Co-authored-by: Dominic Clark <[email protected]>
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.

5 participants