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

Improve cpp qt5 client #3688

Closed

Conversation

MartinDelille
Copy link
Contributor

@MartinDelille MartinDelille commented Aug 19, 2019

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\. If contributing template-only or documentation-only changes which will change sample output, be sure to build the project first.
  • Filed the PR against the correct branch: master, 4.1.x, 5.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

This PR add two improvements to the qt5 client:

  • I removed the host parameter which since it's buggy: The base path add to be set using setHost which is not appropriate. Ideally we could compose the request path with the scheme/host/port and base path (without host). Unfortunately the scheme is not accessible from the mustache template (I managed to access it locally by modifying this function.
  • I simplified timeout management using QTimer::singleShot()
  • I used simpler #pragma once directive

@ravinikam @stkrwork @etherealjoy @muttleyxd

connect(timer, &QTimer::timeout, this, [=](){ on_manager_timeout(reply); });
timer->start();
if(_timeOut > 0){
QTimer::singleShot(_timeOut, [&](){ on_manager_timeout(reply); });
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if the timer elapsed at the same time response is received? Would there be a crash because the object is still referenced in the Qt event Loop? Won't this happen since the QNetworkReply is async?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In #4430, I replaced [&] by [=]

@etherealjoy
Copy link
Contributor

I need to check the host, because the cpp uses it and I wonder how it compiles
We are using the host, e.g. like http://someurl.com/

then set the basePath at runtime to
/api/v1.0
/api/v2.0
/api/v3.0

And using a single client to talk to different versions of a service depending on what service is available on the field.

@etherealjoy
Copy link
Contributor

I removed the host parameter which since it's buggy: The base path add to be set using setHost which is not appropriate. Ideally we could compose the request path with the scheme/host/port and base path (without host). Unfortunately the scheme is not accessible from the mustache template (I managed to access it locally by modifying this function.

The issue is in the ModelUtils not in the AbstractCppCodegen

@wing328
Copy link
Member

wing328 commented Sep 4, 2019

I removed the host parameter which since it's buggy:

Can you please elaborate on the issue with the host parameter?

@MartinDelille
Copy link
Contributor Author

Replaced by #4429 and #4430

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.

3 participants