diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2019-05-26 10:50:10 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-06-12 17:59:58 +0000 |
commit | d6cd1a3c2b6d2d67ba58673b9c3dfc35784f0bc4 (patch) | |
tree | 384523f0880c55fa30fe631d32b816f7492a4c49 /src/corelib/io/qurl.cpp | |
parent | c4a94edbbc3a59d955bf2721e51b1448d00e0483 (diff) |
QUrl: replace manual memory management of QUrlPrivate::Error with unique_ptr
Change-Id: I837866dbeff4b3f4ba4eb5b564041fecbd59e70e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/corelib/io/qurl.cpp')
-rw-r--r-- | src/corelib/io/qurl.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 4d0306abde..9bebfff53f 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -421,6 +421,7 @@ #include "private/qipaddress_p.h" #include "qurlquery.h" #include "private/qdir_p.h" +#include <private/qmemory_p.h> QT_BEGIN_NAMESPACE @@ -520,7 +521,7 @@ public: bool isEmpty() const { return sectionIsPresent == 0 && port == -1 && path.isEmpty(); } - Error *cloneError() const; + std::unique_ptr<Error> cloneError() const; void clearError(); void setError(ErrorCode errorCode, const QString &source, int supplement = -1); ErrorCode validityError(QString *source = nullptr, int *position = nullptr) const; @@ -576,7 +577,7 @@ public: QString query; QString fragment; - Error *error; + std::unique_ptr<Error> error; // not used for: // - Port (port == -1 means absence) @@ -591,7 +592,6 @@ public: inline QUrlPrivate::QUrlPrivate() : ref(1), port(-1), - error(nullptr), sectionIsPresent(0), flags(0) { @@ -613,19 +613,16 @@ inline QUrlPrivate::QUrlPrivate(const QUrlPrivate ©) } inline QUrlPrivate::~QUrlPrivate() -{ - delete error; -} + = default; -inline QUrlPrivate::Error *QUrlPrivate::cloneError() const +std::unique_ptr<QUrlPrivate::Error> QUrlPrivate::cloneError() const { - return error ? new Error(*error) : nullptr; + return error ? qt_make_unique<Error>(*error) : nullptr; } inline void QUrlPrivate::clearError() { - delete error; - error = nullptr; + error.reset(); } inline void QUrlPrivate::setError(ErrorCode errorCode, const QString &source, int supplement) @@ -634,7 +631,7 @@ inline void QUrlPrivate::setError(ErrorCode errorCode, const QString &source, in // don't overwrite an error set in a previous section during parsing return; } - error = new Error; + error = qt_make_unique<Error>(); error->code = errorCode; error->source = source; error->position = supplement; |