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()
{
delete d_ptr;
}
/*!

View 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)

View 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;
}

View 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)

View 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;
}
/*!

View 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

View 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;
}
/*!

View 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;

View file

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

View 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;
}

View 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;
};

View 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;
}

View 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