diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2019-05-14 20:42:01 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-05-15 11:03:52 +0200 |
commit | 1a872e5ff2ce538960c54986e09dcb5eb8d4bd63 (patch) | |
tree | b6ffcc88f46dbff49b5ef439f5430bfd1d802f03 /examples/network/http/httpwindow.h | |
parent | 6e121d81cb4ae4663d656c29a7ac590b6069e22a (diff) |
HTTP example: use std::unique_ptr instead of QScopedPointer
This allows the QFile factory there to actually return the payload in
a unique_ptr instead of falling back to a raw pointer.
The use of a unique_ptr member requires that the destructor be
out-of-line, since QFile is only forward-declared in the header
file. This is good hygiene, so do it for ProgressDialog, too.
Change-Id: Idb6ed327f9592526bb7d0d5b2cfbffe9f08f3eea
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'examples/network/http/httpwindow.h')
-rw-r--r-- | examples/network/http/httpwindow.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/examples/network/http/httpwindow.h b/examples/network/http/httpwindow.h index 20ad2bb4da..f7bd0047de 100644 --- a/examples/network/http/httpwindow.h +++ b/examples/network/http/httpwindow.h @@ -55,6 +55,8 @@ #include <QNetworkAccessManager> #include <QUrl> +#include <memory> + QT_BEGIN_NAMESPACE class QFile; class QLabel; @@ -72,6 +74,7 @@ class ProgressDialog : public QProgressDialog { public: explicit ProgressDialog(const QUrl &url, QWidget *parent = nullptr); + ~ProgressDialog(); public slots: void networkReplyProgress(qint64 bytesRead, qint64 totalBytes); @@ -83,6 +86,7 @@ class HttpWindow : public QDialog public: explicit HttpWindow(QWidget *parent = nullptr); + ~HttpWindow(); void startRequest(const QUrl &requestedUrl); @@ -98,7 +102,7 @@ private slots: #endif private: - QFile *openFileForWrite(const QString &fileName); + std::unique_ptr<QFile> openFileForWrite(const QString &fileName); QLabel *statusLabel; QLineEdit *urlLineEdit; @@ -110,7 +114,7 @@ private: QUrl url; QNetworkAccessManager qnam; QNetworkReply *reply; - QFile *file; + std::unique_ptr<QFile> file; bool httpRequestAborted; }; |