From 5b7c8eb9849855fac16d91c47803d0ef16a8e9a8 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 4 Jul 2023 14:40:10 +0200 Subject: [PATCH] QtNetwork: replace clashing statics with lambdas I: downloadBufferDeleter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/network/access/qhttpthreaddelegate.cpp | 7 +------ src/network/access/qnetworkreplyimpl.cpp | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/network/access/qhttpthreaddelegate.cpp b/src/network/access/qhttpthreaddelegate.cpp index c5c35d522a..261a1eccd6 100644 --- a/src/network/access/qhttpthreaddelegate.cpp +++ b/src/network/access/qhttpthreaddelegate.cpp @@ -567,11 +567,6 @@ void QHttpThreadDelegate::synchronousFinishedWithErrorSlot(QNetworkReply::Networ httpReply = nullptr; } -static void downloadBufferDeleter(char *ptr) -{ - delete[] ptr; -} - void QHttpThreadDelegate::headerChangedSlot() { if (!httpReply) @@ -592,7 +587,7 @@ void QHttpThreadDelegate::headerChangedSlot() QT_TRY { char *buf = new char[httpReply->contentLength()]; // throws if allocation fails if (buf) { - downloadBuffer = QSharedPointer(buf, downloadBufferDeleter); + downloadBuffer = QSharedPointer(buf, [](auto p) { delete[] p; }); httpReply->setUserProvidedDownloadBuffer(buf); } } QT_CATCH(const std::bad_alloc &) { diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index 2c713e69fd..8b2acfdb4e 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -519,11 +519,6 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data) _q_copyReadyRead(); } -static void downloadBufferDeleter(char *ptr) -{ - delete[] ptr; -} - char* QNetworkReplyImplPrivate::getDownloadBuffer(qint64 size) { Q_Q(QNetworkReplyImpl); @@ -536,7 +531,7 @@ char* QNetworkReplyImplPrivate::getDownloadBuffer(qint64 size) downloadBufferCurrentSize = 0; downloadBufferMaximumSize = size; downloadBuffer = new char[downloadBufferMaximumSize]; // throws if allocation fails - downloadBufferPointer = QSharedPointer(downloadBuffer, downloadBufferDeleter); + downloadBufferPointer = QSharedPointer(downloadBuffer, [](auto p) { delete[] p; }); q->setAttribute(QNetworkRequest::DownloadBufferAttribute, QVariant::fromValue > (downloadBufferPointer)); }