summaryrefslogtreecommitdiffstats
path: root/src/network/ssl
diff options
context:
space:
mode:
authorRobert Griebl <rgriebl@trolltech.com>2009-06-10 11:46:23 (GMT)
committerRobert Griebl <rgriebl@trolltech.com>2009-06-10 11:46:23 (GMT)
commit7604f8087f88171ef933d8ae08f501467e647338 (patch)
tree51d071f462ed48d0b25884d9f62b8ba11c5dff13 /src/network/ssl
parent8c265860b41214daade7c8a28237c1e07ea71a3c (diff)
downloadQt-7604f8087f88171ef933d8ae08f501467e647338.zip
Qt-7604f8087f88171ef933d8ae08f501467e647338.tar.gz
Qt-7604f8087f88171ef933d8ae08f501467e647338.tar.bz2
Make Qt exception safer.
Squashed commit of the branch haralds-haralds-qt-s60-topics/topic/exceptions, which also contains the full history. Rev-By: Harald Fernengel Rev-By: Ralf Engels
Diffstat (limited to 'src/network/ssl')
-rw-r--r--src/network/ssl/qsslcertificate.cpp13
-rw-r--r--src/network/ssl/qsslcertificate.h2
-rw-r--r--src/network/ssl/qsslcipher.cpp5
-rw-r--r--src/network/ssl/qsslcipher.h3
-rw-r--r--src/network/ssl/qsslerror.cpp5
-rw-r--r--src/network/ssl/qsslerror.h2
-rw-r--r--src/network/ssl/qsslkey.cpp17
-rw-r--r--src/network/ssl/qsslkey.h3
8 files changed, 22 insertions, 28 deletions
diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp
index 7b554dc..c4aa43e 100644
--- a/src/network/ssl/qsslcertificate.cpp
+++ b/src/network/ssl/qsslcertificate.cpp
@@ -155,7 +155,7 @@ QSslCertificate::QSslCertificate(const QByteArray &data, QSsl::EncodingFormat fo
/*!
Constructs an identical copy of \a other.
*/
-QSslCertificate::QSslCertificate(const QSslCertificate &other) : d(other.d)
+QSslCertificate::QSslCertificate(const QSslCertificate &other) : d(other.d.data())
{
d->ref.ref();
}
@@ -165,8 +165,6 @@ QSslCertificate::QSslCertificate(const QSslCertificate &other) : d(other.d)
*/
QSslCertificate::~QSslCertificate()
{
- if (!d->ref.deref())
- delete d;
}
/*!
@@ -175,7 +173,7 @@ QSslCertificate::~QSslCertificate()
*/
QSslCertificate &QSslCertificate::operator=(const QSslCertificate &other)
{
- qAtomicAssign(d, other.d);
+ d.assign(other.d.data());
return *this;
}
@@ -241,12 +239,7 @@ void QSslCertificate::clear()
{
if (isNull())
return;
- if (d->ref == 1)
- delete d;
- else
- d->ref.deref();
-
- d = new QSslCertificatePrivate;
+ d.reset(new QSslCertificatePrivate);
}
/*!
diff --git a/src/network/ssl/qsslcertificate.h b/src/network/ssl/qsslcertificate.h
index d4597cd..19152fb 100644
--- a/src/network/ssl/qsslcertificate.h
+++ b/src/network/ssl/qsslcertificate.h
@@ -118,7 +118,7 @@ public:
Qt::HANDLE handle() const;
private:
- QSslCertificatePrivate *d;
+ QScopedSharedPointer<QSslCertificatePrivate> d;
friend class QSslCertificatePrivate;
friend class QSslSocketBackendPrivate;
};
diff --git a/src/network/ssl/qsslcipher.cpp b/src/network/ssl/qsslcipher.cpp
index 7fec2df..a72879d 100644
--- a/src/network/ssl/qsslcipher.cpp
+++ b/src/network/ssl/qsslcipher.cpp
@@ -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;
}
diff --git a/src/network/ssl/qsslcipher.h b/src/network/ssl/qsslcipher.h
index 404dc3d..d9ac7a9 100644
--- a/src/network/ssl/qsslcipher.h
+++ b/src/network/ssl/qsslcipher.h
@@ -44,6 +44,7 @@
#define QSSLCIPHER_H
#include <QtCore/qstring.h>
+#include <QtCore/qscopedpointer.h>
#include <QtNetwork/qssl.h>
QT_BEGIN_HEADER
@@ -78,7 +79,7 @@ public:
QSsl::SslProtocol protocol() const;
private:
- QSslCipherPrivate *d;
+ QScopedPointer<QSslCipherPrivate> d;
friend class QSslSocketBackendPrivate;
};
diff --git a/src/network/ssl/qsslerror.cpp b/src/network/ssl/qsslerror.cpp
index 3096fee..280c659 100644
--- a/src/network/ssl/qsslerror.cpp
+++ b/src/network/ssl/qsslerror.cpp
@@ -140,7 +140,7 @@ QSslError::QSslError(SslError error, const QSslCertificate &certificate)
QSslError::QSslError(const QSslError &other)
: d(new QSslErrorPrivate)
{
- *d = *other.d;
+ *d.data() = *other.d.data();
}
/*!
@@ -148,7 +148,6 @@ QSslError::QSslError(const QSslError &other)
*/
QSslError::~QSslError()
{
- delete d;
}
/*!
@@ -158,7 +157,7 @@ QSslError::~QSslError()
*/
QSslError &QSslError::operator=(const QSslError &other)
{
- *d = *other.d;
+ *d.data() = *other.d.data();
return *this;
}
diff --git a/src/network/ssl/qsslerror.h b/src/network/ssl/qsslerror.h
index 50cc142..8b8ebff 100644
--- a/src/network/ssl/qsslerror.h
+++ b/src/network/ssl/qsslerror.h
@@ -105,7 +105,7 @@ public:
QSslCertificate certificate() const;
private:
- QSslErrorPrivate *d;
+ QScopedPointer<QSslErrorPrivate> d;
};
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/network/ssl/qsslkey.cpp b/src/network/ssl/qsslkey.cpp
index 8d550c0..d076112 100644
--- a/src/network/ssl/qsslkey.cpp
+++ b/src/network/ssl/qsslkey.cpp
@@ -269,7 +269,7 @@ QSslKey::QSslKey(QIODevice *device, QSsl::KeyAlgorithm algorithm, QSsl::Encoding
/*!
Constructs an identical copy of \a other.
*/
-QSslKey::QSslKey(const QSslKey &other) : d(other.d)
+QSslKey::QSslKey(const QSslKey &other) : d(other.d.data())
{
d->ref.ref();
}
@@ -279,8 +279,6 @@ QSslKey::QSslKey(const QSslKey &other) : d(other.d)
*/
QSslKey::~QSslKey()
{
- if (!d->ref.deref())
- delete d;
}
/*!
@@ -291,7 +289,7 @@ QSslKey::~QSslKey()
*/
QSslKey &QSslKey::operator=(const QSslKey &other)
{
- qAtomicAssign(d, other.d);
+ d.assign(other.d.data());
return *this;
}
@@ -312,10 +310,13 @@ bool QSslKey::isNull() const
*/
void QSslKey::clear()
{
- if (!d->ref.deref()) {
- delete d;
- d = new QSslKeyPrivate;
- }
+ d.reset(new QSslKeyPrivate);
+
+ //### old code: is this really correct???
+ //if (!d->ref.deref()) {
+ // delete d;
+ // d = new QSslKeyPrivate;
+ //}
}
/*!
diff --git a/src/network/ssl/qsslkey.h b/src/network/ssl/qsslkey.h
index 45d03f7..d5d60a6 100644
--- a/src/network/ssl/qsslkey.h
+++ b/src/network/ssl/qsslkey.h
@@ -45,6 +45,7 @@
#include <QtCore/qnamespace.h>
#include <QtCore/qbytearray.h>
+#include <QtCore/qscopedpointer.h>
#include <QtNetwork/qssl.h>
QT_BEGIN_HEADER
@@ -92,7 +93,7 @@ public:
inline bool operator!=(const QSslKey &key) const { return !operator==(key); }
private:
- QSslKeyPrivate *d;
+ QScopedSharedPointer<QSslKeyPrivate> d;
friend class QSslCertificate;
};