QNetworkRequest: make the default ctor implicit
As in QVarLengthArray (c34242c679aaea6ee1badf6c1e5f274f925f5f50), this will probably bite someone someday, so fix it before there's a bug report. Use ctor delegation to keep code size increase small. There's also the benefit that default-constructing a QNetworkRequest now no longer creates an expensive QUrl object just to destroy it unused again. Add an auto-test. Change-Id: I5ceb5402ca3946048d695244d1b1c36564a1e80a Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
parent
efa183309e
commit
a7383b4b6d
@ -467,6 +467,17 @@ public:
|
|||||||
QString peerVerifyName;
|
QString peerVerifyName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Constructs a QNetworkRequest object with no URL to be requested.
|
||||||
|
Use setUrl() to set one.
|
||||||
|
|
||||||
|
\sa url(), setUrl()
|
||||||
|
*/
|
||||||
|
QNetworkRequest::QNetworkRequest()
|
||||||
|
: d(new QNetworkRequestPrivate)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Constructs a QNetworkRequest object with \a url as the URL to be
|
Constructs a QNetworkRequest object with \a url as the URL to be
|
||||||
requested.
|
requested.
|
||||||
@ -474,7 +485,7 @@ public:
|
|||||||
\sa url(), setUrl()
|
\sa url(), setUrl()
|
||||||
*/
|
*/
|
||||||
QNetworkRequest::QNetworkRequest(const QUrl &url)
|
QNetworkRequest::QNetworkRequest(const QUrl &url)
|
||||||
: d(new QNetworkRequestPrivate)
|
: QNetworkRequest()
|
||||||
{
|
{
|
||||||
d->url = url;
|
d->url = url;
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
explicit QNetworkRequest(const QUrl &url = QUrl());
|
QNetworkRequest();
|
||||||
|
explicit QNetworkRequest(const QUrl &url);
|
||||||
QNetworkRequest(const QNetworkRequest &other);
|
QNetworkRequest(const QNetworkRequest &other);
|
||||||
~QNetworkRequest();
|
~QNetworkRequest();
|
||||||
QNetworkRequest &operator=(QNetworkRequest &&other) noexcept { swap(other); return *this; }
|
QNetworkRequest &operator=(QNetworkRequest &&other) noexcept { swap(other); return *this; }
|
||||||
|
@ -41,6 +41,7 @@ class tst_QNetworkRequest: public QObject
|
|||||||
private slots:
|
private slots:
|
||||||
void ctor_data();
|
void ctor_data();
|
||||||
void ctor();
|
void ctor();
|
||||||
|
void implicitDefaultCtor();
|
||||||
void setUrl_data();
|
void setUrl_data();
|
||||||
void setUrl();
|
void setUrl();
|
||||||
void setRawHeader_data();
|
void setRawHeader_data();
|
||||||
@ -78,6 +79,12 @@ void tst_QNetworkRequest::ctor()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QNetworkRequest::implicitDefaultCtor()
|
||||||
|
{
|
||||||
|
QNetworkRequest r = {};
|
||||||
|
Q_UNUSED(r);
|
||||||
|
}
|
||||||
|
|
||||||
void tst_QNetworkRequest::setUrl_data()
|
void tst_QNetworkRequest::setUrl_data()
|
||||||
{
|
{
|
||||||
ctor_data();
|
ctor_data();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user