diff options
author | Robert Griebl <rgriebl@trolltech.com> | 2009-06-10 11:46:23 (GMT) |
---|---|---|
committer | Robert Griebl <rgriebl@trolltech.com> | 2009-06-10 11:46:23 (GMT) |
commit | 7604f8087f88171ef933d8ae08f501467e647338 (patch) | |
tree | 51d071f462ed48d0b25884d9f62b8ba11c5dff13 /src/network/kernel/qhostinfo.cpp | |
parent | 8c265860b41214daade7c8a28237c1e07ea71a3c (diff) | |
download | Qt-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/kernel/qhostinfo.cpp')
-rw-r--r-- | src/network/kernel/qhostinfo.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index ca4124d..1858e02 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -42,6 +42,7 @@ #include "qhostinfo.h" #include "qhostinfo_p.h" +#include "QtCore/qscopedpointer.h" #include <qabstracteventdispatcher.h> #include <private/qunicodetables_p.h> #include <qcoreapplication.h> @@ -165,24 +166,24 @@ int QHostInfo::lookupHost(const QString &name, QObject *receiver, // Support for IDNA QString lookup = QString::fromLatin1(QUrl::toAce(name)); - QHostInfoResult *result = new QHostInfoResult; - result->autoDelete = false; - QObject::connect(result, SIGNAL(resultsReady(QHostInfo)), + QScopedPointer<QHostInfoResult> result(new QHostInfoResult); + result.data()->autoDelete = false; + QObject::connect(result.data(), SIGNAL(resultsReady(QHostInfo)), receiver, member); - int id = result->lookupId = theIdCounter.fetchAndAddRelaxed(1); + int id = result.data()->lookupId = theIdCounter.fetchAndAddRelaxed(1); if (lookup.isEmpty()) { QHostInfo info(id); info.setError(QHostInfo::HostNotFound); info.setErrorString(QObject::tr("No host name given")); - QMetaObject::invokeMethod(result, "emitResultsReady", Qt::QueuedConnection, + QMetaObject::invokeMethod(result.data(), "emitResultsReady", Qt::QueuedConnection, Q_ARG(QHostInfo, info)); - result->autoDelete = true; + result.take()->autoDelete = true; return id; } QHostInfoAgent *agent = theAgent(); - agent->addHostName(lookup, result); + agent->addHostName(lookup, result.take()); #if !defined QT_NO_THREAD if (!agent->isRunning()) @@ -327,7 +328,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())) { } @@ -337,7 +338,7 @@ QHostInfo::QHostInfo(const QHostInfo &other) */ QHostInfo &QHostInfo::operator=(const QHostInfo &other) { - *d = *other.d; + *d.data() = *other.d.data(); return *this; } @@ -346,7 +347,6 @@ QHostInfo &QHostInfo::operator=(const QHostInfo &other) */ QHostInfo::~QHostInfo() { - delete d; } /*! |