QtNetwork: replace clashing statics with lambdas I: downloadBufferDeleter
Detected with -unity-build-batch-size 103. Pick-to: 6.6 6.5 Task-number: QTBUG-115031 Change-Id: Ia67082efbdb3f403a8c8010ec15f9f796f97feb6 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
f0ae4b07eb
commit
5b7c8eb984
@ -567,11 +567,6 @@ void QHttpThreadDelegate::synchronousFinishedWithErrorSlot(QNetworkReply::Networ
|
|||||||
httpReply = nullptr;
|
httpReply = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void downloadBufferDeleter(char *ptr)
|
|
||||||
{
|
|
||||||
delete[] ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QHttpThreadDelegate::headerChangedSlot()
|
void QHttpThreadDelegate::headerChangedSlot()
|
||||||
{
|
{
|
||||||
if (!httpReply)
|
if (!httpReply)
|
||||||
@ -592,7 +587,7 @@ void QHttpThreadDelegate::headerChangedSlot()
|
|||||||
QT_TRY {
|
QT_TRY {
|
||||||
char *buf = new char[httpReply->contentLength()]; // throws if allocation fails
|
char *buf = new char[httpReply->contentLength()]; // throws if allocation fails
|
||||||
if (buf) {
|
if (buf) {
|
||||||
downloadBuffer = QSharedPointer<char>(buf, downloadBufferDeleter);
|
downloadBuffer = QSharedPointer<char>(buf, [](auto p) { delete[] p; });
|
||||||
httpReply->setUserProvidedDownloadBuffer(buf);
|
httpReply->setUserProvidedDownloadBuffer(buf);
|
||||||
}
|
}
|
||||||
} QT_CATCH(const std::bad_alloc &) {
|
} QT_CATCH(const std::bad_alloc &) {
|
||||||
|
@ -519,11 +519,6 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)
|
|||||||
_q_copyReadyRead();
|
_q_copyReadyRead();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void downloadBufferDeleter(char *ptr)
|
|
||||||
{
|
|
||||||
delete[] ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
char* QNetworkReplyImplPrivate::getDownloadBuffer(qint64 size)
|
char* QNetworkReplyImplPrivate::getDownloadBuffer(qint64 size)
|
||||||
{
|
{
|
||||||
Q_Q(QNetworkReplyImpl);
|
Q_Q(QNetworkReplyImpl);
|
||||||
@ -536,7 +531,7 @@ char* QNetworkReplyImplPrivate::getDownloadBuffer(qint64 size)
|
|||||||
downloadBufferCurrentSize = 0;
|
downloadBufferCurrentSize = 0;
|
||||||
downloadBufferMaximumSize = size;
|
downloadBufferMaximumSize = size;
|
||||||
downloadBuffer = new char[downloadBufferMaximumSize]; // throws if allocation fails
|
downloadBuffer = new char[downloadBufferMaximumSize]; // throws if allocation fails
|
||||||
downloadBufferPointer = QSharedPointer<char>(downloadBuffer, downloadBufferDeleter);
|
downloadBufferPointer = QSharedPointer<char>(downloadBuffer, [](auto p) { delete[] p; });
|
||||||
|
|
||||||
q->setAttribute(QNetworkRequest::DownloadBufferAttribute, QVariant::fromValue<QSharedPointer<char> > (downloadBufferPointer));
|
q->setAttribute(QNetworkRequest::DownloadBufferAttribute, QVariant::fromValue<QSharedPointer<char> > (downloadBufferPointer));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user