From 779ff8f333af01f2db889853a3aeaf32bd7d3462 Mon Sep 17 00:00:00 2001 From: Mate Barany Date: Fri, 5 Jul 2024 14:41:02 +0200 Subject: [PATCH] Initialize all data members in QNetworkAccessCache::CacheableObject MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address the "A constructor must initialize all data members of the class" warning. The class should accept initial values as argument of a (possibly protected) constructor if it expects them to be set by a derived class. Add an enum Option and a protected constructor that can be called by the derived classes with the enum values. This makes setExpires and setShareable redundant so remove them. Found by an Axivion scan. Pick-to: 6.7 6.5 Task-number: QTBUG-125026 Change-Id: Ia8a2a19469a2c0185b5d2e6b2a0895e897f33f28 Reviewed-by: MÃ¥rten Nordheim (cherry picked from commit 36aa5fc3fa361ecb6f7bb035c3cace3dd14735e0) Reviewed-by: Qt Cherry-pick Bot --- src/network/access/qhttpthreaddelegate.cpp | 4 ++-- .../qnetworkaccessauthenticationmanager.cpp | 3 +-- src/network/access/qnetworkaccesscache.cpp | 17 ++++------------- src/network/access/qnetworkaccesscache_p.h | 15 ++++++++++----- 4 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/network/access/qhttpthreaddelegate.cpp b/src/network/access/qhttpthreaddelegate.cpp index 1e11c9cd96a..bd44e570378 100644 --- a/src/network/access/qhttpthreaddelegate.cpp +++ b/src/network/access/qhttpthreaddelegate.cpp @@ -151,9 +151,9 @@ public: QNetworkAccessCachedHttpConnection(quint16 connectionCount, const QString &hostName, quint16 port, bool encrypt, bool isLocalSocket, QHttpNetworkConnection::ConnectionType connectionType) : QHttpNetworkConnection(connectionCount, hostName, port, encrypt, isLocalSocket, /*parent=*/nullptr, connectionType) + ,CacheableObject(Option::Expires | Option::Shareable) { - setExpires(true); - setShareable(true); + } virtual void dispose() override diff --git a/src/network/access/qnetworkaccessauthenticationmanager.cpp b/src/network/access/qnetworkaccessauthenticationmanager.cpp index ab7c27b885e..6e86d6387c2 100644 --- a/src/network/access/qnetworkaccessauthenticationmanager.cpp +++ b/src/network/access/qnetworkaccessauthenticationmanager.cpp @@ -22,9 +22,8 @@ class QNetworkAuthenticationCache : private QList #include "QtCore/qhash.h" #include "QtCore/qmetatype.h" @@ -36,7 +37,6 @@ class QNetworkAccessCache: public QObject public: struct Node; typedef QHash NodeHash; - class CacheableObject { friend class QNetworkAccessCache; @@ -45,14 +45,17 @@ public: bool shareable; qint64 expiryTimeoutSeconds = -1; public: - CacheableObject(); + enum class Option { + Expires = 0x01, + Shareable = 0x02, + }; + typedef QFlags