-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[cpp-qt5] Fix memory leaks in Pet Store client sample #270
[cpp-qt5] Fix memory leaks in Pet Store client sample #270
Conversation
@MartinDelille However the setter are still not user friendly in that for pointer types the user has to care about de-allocating. |
I quickly review your PR but I don’t understand why you’re not using local variables instead of pointer: you wouldn’t have to deallocate the memory at the end of the block and would reduce the code size. I will point an example in your code and make a proposal. |
@MartinDelille |
@MartinDelille @stkrwork |
@ethereajoy ok do as you wish! |
|
||
QList<QString*>* status = new QList<QString*>(); | ||
status->append(new QString("available")); | ||
status->append(new QString("sold")); | ||
auto available = new QString("available"); |
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.
What about:
const QString available = “available “
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.
We will do it in the next update.
I plan to switch to QVariant for all members and lets see. It will be a breaking change but I will make it with the server first.
OK, I will create a different issue to track these for both Qt5 Client and Server since they share common code. |
@wing328 |
The CircleCI (1.0) error can be ignored as latest master has migrated to use CircleCI 2.0 with better and more stable build. |
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
and./bin/security/{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\
.master
.Description of the PR
Allow generated code to do cleanup of allocated memory by preventing premature loop exit.
The generated code has the possibility to delete all memory allocations from itself but the sample client is terminating the loop before allowing the callback to return and memory de-allocation to take place.
With this change the callback from the timer and response schedule an event to the eventloop and then perform the clean up after which the exit is done.
Tests
@stkrwork @MartinDelille @ravinikam @fvarose