HttpRequest: fix potential memleak
The logic of cleaning up QFile instances relies on the fact that
they are added to the addedFiles list, and later their parent is
set to a non-null QObject.
However, if the file could not be opened, it was not added to the
list. We were leaking memory in such case. Use std::unique_ptr to
manage the lifetime of the file, and release() it when adding the
file to the list.
As a drive-by: use std::as_const() when iterating over the list of
files to prevent detaches.
Change-Id: I1399c69a2bac19f82334525de606702180e98771
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Rym Bouabid <rym.bouabid@qt.io>
| commit | d15db2c56ce31c6eb2ad3745a777b268d346ec9d |
| parent | fa4205a09329a1974263f475790b0f3efc0da93f |
| author | Ivan Solovev <ivan.solovev@qt.io> |
| committer | Ivan Solovev <ivan.solovev@qt.io> |
| commit time | Wed, 10 Sep 2025 11:53:11 +0200 |
- M src/main/resources/cpp-qt6-client/HttpRequest.cpp.mustache
- M tests/auto/colorpalette/client/client/QtOAIHttpRequest.cpp
- M tests/auto/colorpalette/qmlclient/client/OAIHttpRequest.cpp
- M tests/auto/mediatype/client/client/QtOAIHttpRequest.cpp
- M tests/auto/openapi2.0/client/client/QtOAIHttpRequest.cpp
- M tests/auto/operation-parameters/client/client/QtOAIHttpRequest.cpp
- M tests/auto/petstore/client/client/QtOAIHttpRequest.cpp
- M tests/auto/petstore/qmlclient/client/OAIHttpRequest.cpp