OSDN Git Service

revert back to QScopedPointer for the network component
authorIvailo Monev <xakepa10@laimg.moc>
Thu, 3 Nov 2016 01:05:41 +0000 (01:05 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Thu, 3 Nov 2016 01:05:45 +0000 (01:05 +0000)
the problem with the component is that it's mostly async and most
applications expect the pointer to remain valid longer than they
should and some just crash (konqueror, kuassel, etc.).

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
13 files changed:
src/network/access/qhttp.cpp
src/network/access/qhttp.h
src/network/kernel/qhostaddress.cpp
src/network/kernel/qhostaddress.h
src/network/kernel/qhostinfo.cpp
src/network/kernel/qhostinfo.h
src/network/kernel/qnetworkinterface.cpp
src/network/kernel/qnetworkinterface.h
src/network/socket/qsocks5socketengine.cpp
src/network/ssl/qsslcipher.cpp
src/network/ssl/qsslcipher.h
src/network/ssl/qsslerror.cpp
src/network/ssl/qsslerror.h

index f445908..8b7de1e 100644 (file)
@@ -619,7 +619,6 @@ QHttpHeader::QHttpHeader(QHttpHeaderPrivate &dd, const QHttpHeader &header)
 */
 QHttpHeader::~QHttpHeader()
 {
-    delete d_ptr;
 }
 
 /*!
index f883632..694e982 100644 (file)
@@ -46,6 +46,7 @@
 #include <QtCore/qstringlist.h>
 #include <QtCore/qmap.h>
 #include <QtCore/qpair.h>
+#include <QtCore/qscopedpointer.h>
 
 QT_BEGIN_HEADER
 
@@ -107,7 +108,7 @@ protected:
 
     QHttpHeader(QHttpHeaderPrivate &dd, const QString &str = QString());
     QHttpHeader(QHttpHeaderPrivate &dd, const QHttpHeader &header);
-    QHttpHeaderPrivate* d_ptr;
+    QScopedPointer<QHttpHeaderPrivate> d_ptr;
 
 private:
     Q_DECLARE_PRIVATE(QHttpHeader)
index d15959b..0f8f950 100644 (file)
@@ -486,7 +486,7 @@ QHostAddress::QHostAddress(const struct sockaddr *sockaddr)
     Constructs a copy of the given \a address.
 */
 QHostAddress::QHostAddress(const QHostAddress &address)
-    : d(new QHostAddressPrivate(*address.d))
+    : d(new QHostAddressPrivate(*address.d.data()))
 {
 }
 
@@ -532,7 +532,7 @@ QHostAddress::~QHostAddress()
 */
 QHostAddress &QHostAddress::operator=(const QHostAddress &address)
 {
-    d = address.d;
+    *d.data() = *address.d.data();
     return *this;
 }
 
index e929933..a3303c0 100644 (file)
@@ -44,6 +44,7 @@
 
 #include <QtCore/qpair.h>
 #include <QtCore/qstring.h>
+#include <QtCore/qscopedpointer.h>
 #include <QtNetwork/qabstractsocket.h>
 
 struct sockaddr;
@@ -121,7 +122,7 @@ public:
     static QPair<QHostAddress, int> parseSubnet(const QString &subnet);
 
 protected:
-    QHostAddressPrivate* d;
+    QScopedPointer<QHostAddressPrivate> d;
 };
 
 inline bool operator ==(QHostAddress::SpecialAddress address1, const QHostAddress &address2)
index 4cda599..420c83b 100644 (file)
@@ -293,7 +293,7 @@ QHostInfo::QHostInfo(int id)
     Constructs a copy of \a other.
 */
 QHostInfo::QHostInfo(const QHostInfo &other)
-    : d(new QHostInfoPrivate(*other.d))
+    : d(new QHostInfoPrivate(*other.d.data()))
 {
 }
 
@@ -303,7 +303,7 @@ QHostInfo::QHostInfo(const QHostInfo &other)
 */
 QHostInfo &QHostInfo::operator=(const QHostInfo &other)
 {
-    d = other.d;
+    *d.data() = *other.d.data();
     return *this;
 }
 
@@ -312,7 +312,6 @@ QHostInfo &QHostInfo::operator=(const QHostInfo &other)
 */
 QHostInfo::~QHostInfo()
 {
-    delete d;
 }
 
 /*!
index a72b167..f3d80ab 100644 (file)
@@ -43,6 +43,7 @@
 #define QHOSTINFO_H
 
 #include <QtCore/qlist.h>
+#include <QtCore/qscopedpointer.h>
 #include <QtNetwork/qhostaddress.h>
 
 QT_BEGIN_HEADER
@@ -90,7 +91,7 @@ public:
     static QString localDomainName();
 
 private:
-    QHostInfoPrivate* d;
+    QScopedPointer<QHostInfoPrivate> d;
 };
 
 QT_END_NAMESPACE
index a0241d1..8efdbfc 100644 (file)
@@ -165,7 +165,7 @@ QNetworkAddressEntry::QNetworkAddressEntry()
     object \a other.
 */
 QNetworkAddressEntry::QNetworkAddressEntry(const QNetworkAddressEntry &other)
-    : d(new QNetworkAddressEntryPrivate(*other.d))
+    : d(new QNetworkAddressEntryPrivate(*other.d.data()))
 {
 }
 
@@ -174,7 +174,7 @@ QNetworkAddressEntry::QNetworkAddressEntry(const QNetworkAddressEntry &other)
 */
 QNetworkAddressEntry &QNetworkAddressEntry::operator=(const QNetworkAddressEntry &other)
 {
-    d = other.d;
+    *d.data() = *other.d.data();
     return *this;
 }
 
@@ -183,7 +183,6 @@ QNetworkAddressEntry &QNetworkAddressEntry::operator=(const QNetworkAddressEntry
 */
 QNetworkAddressEntry::~QNetworkAddressEntry()
 {
-    delete d;
 }
 
 /*!
index 71045b3..89ef350 100644 (file)
@@ -43,6 +43,7 @@
 #define QNETWORKINTERFACE_H
 
 #include <QtCore/qshareddata.h>
+#include <QtCore/qscopedpointer.h>
 #include <QtNetwork/qhostaddress.h>
 
 #ifndef QT_NO_NETWORKINTERFACE
@@ -78,7 +79,7 @@ public:
     void setBroadcast(const QHostAddress &newBroadcast);
 
 private:
-    QNetworkAddressEntryPrivate* d;
+    QScopedPointer<QNetworkAddressEntryPrivate> d;
 };
 
 class QNetworkInterfacePrivate;
index 15bbba3..9bad5b3 100644 (file)
@@ -58,7 +58,6 @@
 #include "qendian.h"
 #include "qnetworkinterface.h"
 #include "qnetworkcommon_p.h"
-#include "qscopedpointer.h"
 
 QT_BEGIN_NAMESPACE
 
index d53a403..34ada72 100644 (file)
@@ -103,7 +103,7 @@ QSslCipher::QSslCipher(const QString &name, QSsl::SslProtocol protocol)
 QSslCipher::QSslCipher(const QSslCipher &other)
     : d(new QSslCipherPrivate)
 {
-    d = other.d;
+    *d.data() = *other.d.data();
 }
 
 /*!
@@ -111,7 +111,6 @@ QSslCipher::QSslCipher(const QSslCipher &other)
 */
 QSslCipher::~QSslCipher()
 {
-    delete d;
 }
 
 /*!
@@ -120,7 +119,7 @@ QSslCipher::~QSslCipher()
 */
 QSslCipher &QSslCipher::operator=(const QSslCipher &other)
 {
-    d = other.d;
+    *d.data() = *other.d.data();
     return *this;
 }
 
index c28b75f..37e61cb 100644 (file)
@@ -44,6 +44,7 @@
 #define QSSLCIPHER_H
 
 #include <QtCore/qstring.h>
+#include <QtCore/qscopedpointer.h>
 #include <QtNetwork/qssl.h>
 
 QT_BEGIN_HEADER
@@ -74,7 +75,7 @@ public:
     QSsl::SslProtocol protocol() const;
 
 private:
-    QSslCipherPrivate* d;
+    QScopedPointer<QSslCipherPrivate> d;
     friend class QSslSocketBackendPrivate;
 };
 
index 6e21cd0..2349168 100644 (file)
@@ -107,8 +107,34 @@ public:
 };
 
 /*!
-    Constructs a QSslError object. The two arguments specify the
-    \a error that occurred, and which \a certificate the error relates to.
+    Constructs a QSslError object with no error and default certificate. 
+
+*/
+
+// RVCT compiler in debug build does not like about default values in const-
+// So as an workaround we define all constructor overloads here explicitly
+QSslError::QSslError()
+    : d(new QSslErrorPrivate)
+{
+    d->error = QSslError::NoError;
+    d->certificate = QSslCertificate();
+}
+
+/*!
+    Constructs a QSslError object. The argument specifies the \a
+    error that occurred.
+
+*/
+QSslError::QSslError(SslError error)
+    : d(new QSslErrorPrivate)
+{
+    d->error = error;
+    d->certificate = QSslCertificate();
+}
+
+/*!
+    Constructs a QSslError object. The two arguments specify the \a
+    error that occurred, and which \a certificate the error relates to.
 
     \sa QSslCertificate
 */
@@ -125,7 +151,7 @@ QSslError::QSslError(SslError error, const QSslCertificate &certificate)
 QSslError::QSslError(const QSslError &other)
     : d(new QSslErrorPrivate)
 {
-    d = other.d;
+    *d.data() = *other.d.data();
 }
 
 /*!
@@ -133,7 +159,6 @@ QSslError::QSslError(const QSslError &other)
 */
 QSslError::~QSslError()
 {
-    delete d;
 }
 
 /*!
@@ -143,7 +168,7 @@ QSslError::~QSslError()
 */
 QSslError &QSslError::operator=(const QSslError &other)
 {
-    d = other.d;
+    *d.data() = *other.d.data();
     return *this;
 }
 
index d92f698..0a75e59 100644 (file)
@@ -44,6 +44,7 @@
 #define QSSLERROR_H
 
 #include <QtCore/qvariant.h>
+#include <QtCore/qscopedpointer.h>
 #include <QtNetwork/qsslcertificate.h>
 
 QT_BEGIN_HEADER
@@ -83,7 +84,11 @@ public:
         UnspecifiedError = -1
     };
 
-    QSslError(SslError error = QSslError::NoError, const QSslCertificate &certificate = QSslCertificate());
+    // RVCT compiler in debug build does not like about default values in const-
+    // So as an workaround we define all constructor overloads here explicitly
+    QSslError();
+    QSslError(SslError error);
+    QSslError(SslError error, const QSslCertificate &certificate);
 
     QSslError(const QSslError &other);
 
@@ -96,9 +101,9 @@ public:
     SslError error() const;
     QString errorString() const;
     QSslCertificate certificate() const;
-
+    
 private:
-    QSslErrorPrivate* d;
+    QScopedPointer<QSslErrorPrivate> d;
 };
 
 #ifndef QT_NO_DEBUG_STREAM