revert back to QScopedPointer for the network component

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>
This commit is contained in:
Ivailo Monev 2016-11-03 01:05:41 +00:00
parent 2d30f237b1
commit 50681e64f7
13 changed files with 56 additions and 26 deletions

View file

@ -619,7 +619,6 @@ QHttpHeader::QHttpHeader(QHttpHeaderPrivate &dd, const QHttpHeader &header)
*/ */
QHttpHeader::~QHttpHeader() QHttpHeader::~QHttpHeader()
{ {
delete d_ptr;
} }
/*! /*!

View file

@ -46,6 +46,7 @@
#include <QtCore/qstringlist.h> #include <QtCore/qstringlist.h>
#include <QtCore/qmap.h> #include <QtCore/qmap.h>
#include <QtCore/qpair.h> #include <QtCore/qpair.h>
#include <QtCore/qscopedpointer.h>
QT_BEGIN_HEADER QT_BEGIN_HEADER
@ -107,7 +108,7 @@ protected:
QHttpHeader(QHttpHeaderPrivate &dd, const QString &str = QString()); QHttpHeader(QHttpHeaderPrivate &dd, const QString &str = QString());
QHttpHeader(QHttpHeaderPrivate &dd, const QHttpHeader &header); QHttpHeader(QHttpHeaderPrivate &dd, const QHttpHeader &header);
QHttpHeaderPrivate* d_ptr; QScopedPointer<QHttpHeaderPrivate> d_ptr;
private: private:
Q_DECLARE_PRIVATE(QHttpHeader) Q_DECLARE_PRIVATE(QHttpHeader)

View file

@ -486,7 +486,7 @@ QHostAddress::QHostAddress(const struct sockaddr *sockaddr)
Constructs a copy of the given \a address. Constructs a copy of the given \a address.
*/ */
QHostAddress::QHostAddress(const QHostAddress &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) QHostAddress &QHostAddress::operator=(const QHostAddress &address)
{ {
d = address.d; *d.data() = *address.d.data();
return *this; return *this;
} }

View file

@ -44,6 +44,7 @@
#include <QtCore/qpair.h> #include <QtCore/qpair.h>
#include <QtCore/qstring.h> #include <QtCore/qstring.h>
#include <QtCore/qscopedpointer.h>
#include <QtNetwork/qabstractsocket.h> #include <QtNetwork/qabstractsocket.h>
struct sockaddr; struct sockaddr;
@ -121,7 +122,7 @@ public:
static QPair<QHostAddress, int> parseSubnet(const QString &subnet); static QPair<QHostAddress, int> parseSubnet(const QString &subnet);
protected: protected:
QHostAddressPrivate* d; QScopedPointer<QHostAddressPrivate> d;
}; };
inline bool operator ==(QHostAddress::SpecialAddress address1, const QHostAddress &address2) inline bool operator ==(QHostAddress::SpecialAddress address1, const QHostAddress &address2)

View file

@ -293,7 +293,7 @@ QHostInfo::QHostInfo(int id)
Constructs a copy of \a other. Constructs a copy of \a other.
*/ */
QHostInfo::QHostInfo(const QHostInfo &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) QHostInfo &QHostInfo::operator=(const QHostInfo &other)
{ {
d = other.d; *d.data() = *other.d.data();
return *this; return *this;
} }
@ -312,7 +312,6 @@ QHostInfo &QHostInfo::operator=(const QHostInfo &other)
*/ */
QHostInfo::~QHostInfo() QHostInfo::~QHostInfo()
{ {
delete d;
} }
/*! /*!

View file

@ -43,6 +43,7 @@
#define QHOSTINFO_H #define QHOSTINFO_H
#include <QtCore/qlist.h> #include <QtCore/qlist.h>
#include <QtCore/qscopedpointer.h>
#include <QtNetwork/qhostaddress.h> #include <QtNetwork/qhostaddress.h>
QT_BEGIN_HEADER QT_BEGIN_HEADER
@ -90,7 +91,7 @@ public:
static QString localDomainName(); static QString localDomainName();
private: private:
QHostInfoPrivate* d; QScopedPointer<QHostInfoPrivate> d;
}; };
QT_END_NAMESPACE QT_END_NAMESPACE

View file

@ -165,7 +165,7 @@ QNetworkAddressEntry::QNetworkAddressEntry()
object \a other. object \a other.
*/ */
QNetworkAddressEntry::QNetworkAddressEntry(const QNetworkAddressEntry &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) QNetworkAddressEntry &QNetworkAddressEntry::operator=(const QNetworkAddressEntry &other)
{ {
d = other.d; *d.data() = *other.d.data();
return *this; return *this;
} }
@ -183,7 +183,6 @@ QNetworkAddressEntry &QNetworkAddressEntry::operator=(const QNetworkAddressEntry
*/ */
QNetworkAddressEntry::~QNetworkAddressEntry() QNetworkAddressEntry::~QNetworkAddressEntry()
{ {
delete d;
} }
/*! /*!

View file

@ -43,6 +43,7 @@
#define QNETWORKINTERFACE_H #define QNETWORKINTERFACE_H
#include <QtCore/qshareddata.h> #include <QtCore/qshareddata.h>
#include <QtCore/qscopedpointer.h>
#include <QtNetwork/qhostaddress.h> #include <QtNetwork/qhostaddress.h>
#ifndef QT_NO_NETWORKINTERFACE #ifndef QT_NO_NETWORKINTERFACE
@ -78,7 +79,7 @@ public:
void setBroadcast(const QHostAddress &newBroadcast); void setBroadcast(const QHostAddress &newBroadcast);
private: private:
QNetworkAddressEntryPrivate* d; QScopedPointer<QNetworkAddressEntryPrivate> d;
}; };
class QNetworkInterfacePrivate; class QNetworkInterfacePrivate;

View file

@ -58,7 +58,6 @@
#include "qendian.h" #include "qendian.h"
#include "qnetworkinterface.h" #include "qnetworkinterface.h"
#include "qnetworkcommon_p.h" #include "qnetworkcommon_p.h"
#include "qscopedpointer.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE

View file

@ -103,7 +103,7 @@ QSslCipher::QSslCipher(const QString &name, QSsl::SslProtocol protocol)
QSslCipher::QSslCipher(const QSslCipher &other) QSslCipher::QSslCipher(const QSslCipher &other)
: d(new QSslCipherPrivate) : d(new QSslCipherPrivate)
{ {
d = other.d; *d.data() = *other.d.data();
} }
/*! /*!
@ -111,7 +111,6 @@ QSslCipher::QSslCipher(const QSslCipher &other)
*/ */
QSslCipher::~QSslCipher() QSslCipher::~QSslCipher()
{ {
delete d;
} }
/*! /*!
@ -120,7 +119,7 @@ QSslCipher::~QSslCipher()
*/ */
QSslCipher &QSslCipher::operator=(const QSslCipher &other) QSslCipher &QSslCipher::operator=(const QSslCipher &other)
{ {
d = other.d; *d.data() = *other.d.data();
return *this; return *this;
} }

View file

@ -44,6 +44,7 @@
#define QSSLCIPHER_H #define QSSLCIPHER_H
#include <QtCore/qstring.h> #include <QtCore/qstring.h>
#include <QtCore/qscopedpointer.h>
#include <QtNetwork/qssl.h> #include <QtNetwork/qssl.h>
QT_BEGIN_HEADER QT_BEGIN_HEADER
@ -74,7 +75,7 @@ public:
QSsl::SslProtocol protocol() const; QSsl::SslProtocol protocol() const;
private: private:
QSslCipherPrivate* d; QScopedPointer<QSslCipherPrivate> d;
friend class QSslSocketBackendPrivate; friend class QSslSocketBackendPrivate;
}; };

View file

@ -107,8 +107,34 @@ public:
}; };
/*! /*!
Constructs a QSslError object. The two arguments specify the Constructs a QSslError object with no error and default certificate.
\a error that occurred, and which \a certificate the error relates to.
*/
// 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 \sa QSslCertificate
*/ */
@ -125,7 +151,7 @@ QSslError::QSslError(SslError error, const QSslCertificate &certificate)
QSslError::QSslError(const QSslError &other) QSslError::QSslError(const QSslError &other)
: d(new QSslErrorPrivate) : d(new QSslErrorPrivate)
{ {
d = other.d; *d.data() = *other.d.data();
} }
/*! /*!
@ -133,7 +159,6 @@ QSslError::QSslError(const QSslError &other)
*/ */
QSslError::~QSslError() QSslError::~QSslError()
{ {
delete d;
} }
/*! /*!
@ -143,7 +168,7 @@ QSslError::~QSslError()
*/ */
QSslError &QSslError::operator=(const QSslError &other) QSslError &QSslError::operator=(const QSslError &other)
{ {
d = other.d; *d.data() = *other.d.data();
return *this; return *this;
} }

View file

@ -44,6 +44,7 @@
#define QSSLERROR_H #define QSSLERROR_H
#include <QtCore/qvariant.h> #include <QtCore/qvariant.h>
#include <QtCore/qscopedpointer.h>
#include <QtNetwork/qsslcertificate.h> #include <QtNetwork/qsslcertificate.h>
QT_BEGIN_HEADER QT_BEGIN_HEADER
@ -83,7 +84,11 @@ public:
UnspecifiedError = -1 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); QSslError(const QSslError &other);
@ -96,9 +101,9 @@ public:
SslError error() const; SslError error() const;
QString errorString() const; QString errorString() const;
QSslCertificate certificate() const; QSslCertificate certificate() const;
private: private:
QSslErrorPrivate* d; QScopedPointer<QSslErrorPrivate> d;
}; };
#ifndef QT_NO_DEBUG_STREAM #ifndef QT_NO_DEBUG_STREAM