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

[Qt5][C++] Removed deprecated functions to support Qt6 #8234

Merged
merged 13 commits into from
Jan 25, 2021
Merged

[Qt5][C++] Removed deprecated functions to support Qt6 #8234

merged 13 commits into from
Jan 25, 2021

Conversation

basyskom-dege
Copy link
Contributor

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • If contributing template-only or documentation-only changes which will change sample output, build the project beforehand.
  • Run the shell script ./bin/generate-samples.shto update all Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*. For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

I created an Announcement #8232 regarding Qt6. This PR will remove all deprecated functions in the Qt5 generator.

These are the changes i did to support Qt6:

  • qsrand() is now a QRandomGenerator with a seed.
  • qrand() is now a call of generate() from the QRandomGenerator Object
  • toTime_t() -> toSecsSinceEpoch()
  • QString::SkipEmptyParts -> Qt::SkipEmptyParts
  • append(someQstring) -> append(someQstring.toUtf8())`
  • QJsonDocument::fromBinaryData() -> QJsonDocument::fromJson()
  • QJsonDocument::toBinaryData() -> QJsonDocument::toJson()

Everything works aswell in Qt5. The SkipEmptyParts will not work but I made a preprocessor variable for this:

#if QT_VERSION >= 0x060000
    #define SKIP_EMPTY_PARTS Qt::SkipEmptyParts
#else
    #define SKIP_EMPTY_PARTS QString::SkipEmptyParts
#endif

I did not change the CMakeLists.txt to Qt6, since it is still a generator for Qt5.

PING @wing328 @ravinikam (2017/07) @stkrwork (2017/07) @etherealjoy (2018/02) @MartinDelille (2018/03) @muttleyxd (2019/08)

Copy link
Contributor

@etherealjoy etherealjoy 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 a current LTS debian distribution should build off the shelf.

@basyskom-dege
Copy link
Contributor Author

basyskom-dege commented Dec 18, 2020

Okay I have to check for the compatibility of those functions. Will do a new commit on Monday to address the compatibility issues here. Is there a min. required version for Qt? Otherwise i would take the oldest LTS version ( 5.9 LTS )

@basyskom-dege
Copy link
Contributor Author

basyskom-dege commented Dec 21, 2020

I added version checks for the random functions. I kept the changes to the toTime_t() function even if its not available in Qt 5.8 but since the oldest LTS is 5.9, I think thats okay. Do you think I should consider supporting older versions? If yes, whats your oldes version you want to support?
EDIT: since the build failed, I added checks for the version for all functions that I changed, except for toUft8().

@etherealjoy etherealjoy changed the title [Qt5][C++] Removed depricated functions to support Qt6 [Qt5][C++] Removed deprecated functions to support Qt6 Dec 22, 2020
@etherealjoy
Copy link
Contributor

The current build failure, seems unrelated to the changes.

@MartinDelille
Copy link
Contributor

Since these changes solve annoying deprecated warning with Qt 5.15, I would rather check versus 5.15 instead of 6.0. What do you think?

@basyskom-dege
Copy link
Contributor Author

Since these changes solve annoying deprecated warning with Qt 5.15, I would rather check versus 5.15 instead of 6.0. What do you think?

I wouldnt mind that. Those warnings are numerous thats true.

basyskom-dege and others added 7 commits January 7, 2021 09:36
…tpFileElement.cpp.mustache

Co-authored-by: Martin Delille <[email protected]>
…tpFileElement.cpp.mustache

Co-authored-by: Martin Delille <[email protected]>
Changed version check to Qt 5.15 to remove the warning of the deprecated functions when compiling with Qt 5.15

Co-authored-by: Martin Delille <[email protected]>
@wing328 wing328 added Client: C++ Enhancement: Code Cleanup General refactoring, removal of deprecated things, commenting, etc. labels Jan 25, 2021
@wing328 wing328 added this to the 5.0.1 milestone Jan 25, 2021
@wing328
Copy link
Member

wing328 commented Jan 25, 2021

@wing328 wing328 merged commit 58f4866 into OpenAPITools:master Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client: C++ Enhancement: Code Cleanup General refactoring, removal of deprecated things, commenting, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants