-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 all Qt 5.15 deprecation warnings #7783
base: develop
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #7783 +/- ##
===========================================
+ Coverage 63.65% 64.85% +1.20%
===========================================
Files 360 342 -18
Lines 44254 44416 +162
===========================================
+ Hits 28169 28804 +635
+ Misses 16085 15612 -473 ☔ View full report in Codecov by Sentry. |
FYI, with 2.7.0 (+ c33995e) it is still possible to build with Qt 5.5 (but not below) |
Hmm, so what is the minimum Qt version the maintainers want to support? Currently, 5.9.5 is what's documented (in INSTALL.md). |
e40c912
to
7e867bf
Compare
Ok, I think this is in a reasonable state now. Regarding the test failures: Ubuntu failureFrom the logs, this is:
That line is: QCOMPARE(*clonedEntry->customData(), *entry->customData()); Now, Windows failureNot much detail in the logs, just:
Since I don't have a Windows build setup ready to go, I'd appreciate any hints or details. |
You can ignore the gui failures, they are transient |
Cool. My latest update just rebased against The CustomData failure is as I suspected, I'll open a separate PR for that. |
Otherwise, assertions in TestKdbx4::testCustomData() may fail on rare occasions, because the customData in a cloned entry won't be identical to its original, because of its potentially-updated LastModified property. Originally noticed in keepassxreboot#7783 (comment).
Otherwise, assertions in TestKdbx4::testCustomData() may fail on rare occasions, because the customData in a cloned entry won't be identical to its original, because of its potentially-updated LastModified property. Originally noticed in #7783 (comment).
Otherwise, assertions in TestKdbx4::testCustomData() may fail on rare occasions, because the customData in a cloned entry won't be identical to its original, because of its potentially-updated LastModified property. Originally noticed in keepassxreboot#7783 (comment).
f7b22f2
to
a653d7c
Compare
Okay, great. I have resolved all merge conflicts and rebased this PR against I have re-run the tests as stated in the original PR descriptions. Everything still works, except that when using an Ubuntu 18.04 container, there's now a few more CLI and GUI related test failures, but not sure how relevant those are [1]. Hopefully the GitHub checks that get run as part of this PR will show more relevant results. [1] Edit: I've compared these failures against the
Again, this is in an Ubuntu 18.04 container; they don't occur on my Arch Linux machine. They look like artefacts of running the tests in a container, where some stuff doesn't work correctly. |
I'll merge this after 2.7.9 is bottled up, don't need any merge conflicts between branches. |
It does not need to be a recursive mutex, as per keepassxreboot#7783 (comment).
This is in agreement with our stated requirements in INSTALL.md.
qSort() is deprecated.
QDateTime::toString(Qt::DefaultLocaleShortDate) will go away in Qt 6; replace it as recommended in the docs, introducing a Clock::toString() helper function. The replacement functionality we use already exists in Qt 5.9.5, our minimum supported Qt version.
Replace it with QLocale::system().toString(..., QLocale::ShortFormat) as recommended in the official docs. The replacement already exists in Qt 5.9.5, our earliest supported Qt version.
...instead of QDate(QDateTime) constructor, which is deprecated as of Qt 5.15. Since QDateTime::startOfDay() is only available in Qt 5.14, we need to use an #if.
QString::SplitBehavior (of which SkipEmptyParts is an element) was deprecated in Qt 5.15. Its designated replacement, Qt::SplitBehavior, was only added in Qt 5.14. Hence we need to use some preprocessor magic to keep supporting older Qt versions (we require at minimum Qt 5.9.5).
It is deprecated as of Qt 5.15.
QSet::toList() is deprecated as of Qt 5.14. Use the recommended replacement QSet::values() instead. It already exists as of Qt 5.9.5, our minimum supported Qt version.
Both methods are deprecated since Qt 5.14. The recommended replacement QSet(list.begin(), list.end()) is only available from Qt 5.14. Since we support Qt 5.9.5 or better, provide our own 'Tools::asSet()' helper function for this purpose.
QHash::insertMulti is deprecated as of Qt 5.15. QMultiHash already exists in Qt 5.9.5, our earliest supported Qt version.
The overload we were using before has been deprecated in Qt 5.15. To get the same behaviour as before, we need to use QProcess::splitCommand(), which was only introduced in Qt 5.15, hence we need to use an #if for the Qt version.
QProcess::pid() has been deprecated since Qt 5.15. Recommended replacement QProcess::processId() exists since Qt 5.3.
The "HighQuality" version is deprecated as of Qt 5.14. Since it's not immediately clear at which point in Qt version history it becomes preferable to use the non-"HighQuality" one, we only do so in Qt 5.14 onwards.
QPalette::background() is deprecated as of Qt 5.13. Its replacement, QtPalette::window(), is already available in Qt 5.9.5, our minimum supported Qt version.
Instead of their deprecated aliases.
Qt 5.15 deprecates usage of non-'Qt::'-prefixed 'endl' and 'flush' I/O manipulators. Since the 'Qt::' versions are only introduced in Qt 5.14, we backport them for older Qt versions (since we support down to Qt 5.9.5).
Instead of deprecated constructor QMutex(QMutex::RecursionMode), use recommended replacement class QRecursiveMutex. This deprecation was done only in the KDE branch of Qt, specifically in https://invent.kde.org/qt/qt/qtbase/-/commit/6d5988831862f081404270bd7fa2f25bc836fdc9. Since that commit is included in the Qt packaged for some Linux distributions (e.g. Arch Linux: https://archlinux.org/packages/extra/x86_64/qt5-base/), it seems worth respecting this deprecation. Since QRecursiveMutex was only introduced in Qt 5.14, whereas we need to support Qt 5.9.5 or better, this involves some #ifdef magic.
Use non-deprecated QComboBox::sizeAdjustPolicy setting
It does not need to be a recursive mutex, as per keepassxreboot#7783 (comment).
I've just rebased this again so there shouldn't be any merge conflicts (but don't mind if you want to defer merge after 2.7.9 anyway). |
Fix all deprecation warnings when building against Qt 5.15. This is a first step towards being able to eventually upgrade to Qt 6 (see #7774 for discussion).
This now builds cleanly with
-DWITH_XC_ALL=ON -DWITH_GUI_TESTS=ON -DWITH_DEV_BUILD=ON
.Since this is a sizeable change, I've done my best to structure this sensibly into a set of commits.
I've assumed here that the earliest Qt version we support is 5.9.5, as stated in INSTALL.md. I have adjusted the check in CMakeLists.txt accordingly (0a1e776). In some cases I've resorted to compile-time checks for the Qt version.
One particular annoyance is that
QUrl::topLevelDomain()
has been deprecated without direct replacement. I worked around that by accessing its functionality indirectly (9ed6095).Testing strategy
Built with
-DWITH_XC_ALL=ON -DWITH_GUI_TESTS=ON -DWITH_DEV_BUILD=ON -DCMAKE_BUILD_TYPE=Debug
and ran all tests.Did the same thing in an Ubuntu 18.04 container that has
libbotan-kpxc-2-dev
fromppa:phoerious/keepassxc
installed in it. This one did cause some test failures (inTestCli::testClip()
andTestCli::testInvalidDbFiles()
), but those also failed against the2.7.4
tag, so I feel okay about them.Suggestion
In order to keep the code base deprecation-clean, it would be excellent if the automated tests (i.e. TeamCity) could be enhanced to build with
-DWITH_XC_ALL=ON -DWITH_GUI_TESTS=ON -DWITH_DEV_BUILD=ON -DCMAKE_BUILD_TYPE=Debug
and ideally against different Qt versions, including Qt 5.9.5 (assuming that we want to keep supporting it) and Qt 5.15 (the last Qt 5 version).Type of change