aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2015-11-01 10:18:41 +0100
committerJeremy Lainé <jeremy.laine@m4x.org>2015-11-01 10:18:41 +0100
commit9fe0fe5a1d4e90b268d3d2febfea8e79cf62096b (patch)
treea62e72b3c56214851c292b249c24714ed18c5761
parent2f942c6b75305ec6b3fa471d2381a5f04cd44ee3 (diff)
parent032c2c0a886a5b66d0460e6c4ddad1fd6c99f72b (diff)
downloadqxmpp-9fe0fe5a1d4e90b268d3d2febfea8e79cf62096b.tar.gz
Merge pull request #79 from Kaffeine/master
QXmppTransferManager: Fixed device management
-rw-r--r--src/client/QXmppTransferManager.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/client/QXmppTransferManager.cpp b/src/client/QXmppTransferManager.cpp
index 6fb2da75..d0741511 100644
--- a/src/client/QXmppTransferManager.cpp
+++ b/src/client/QXmppTransferManager.cpp
@@ -204,6 +204,7 @@ public:
QString requestId;
QXmppTransferJob::State state;
QTime transferStart;
+ bool deviceIsOwn;
// file meta-data
QXmppTransferFileInfo fileInfo;
@@ -225,6 +226,7 @@ QXmppTransferJobPrivate::QXmppTransferJobPrivate()
iodevice(0),
method(QXmppTransferJob::NoMethod),
state(QXmppTransferJob::OfferState),
+ deviceIsOwn(false),
ibbSequence(0),
socksSocket(0)
{
@@ -426,7 +428,7 @@ void QXmppTransferJob::terminate(QXmppTransferJob::Error cause)
d->state = FinishedState;
// close IO device
- if (d->iodevice)
+ if (d->iodevice && d->deviceIsOwn)
d->iodevice->close();
// close socket
@@ -1307,7 +1309,7 @@ QXmppTransferJob *QXmppTransferManager::sendFile(const QString &jid, const QStri
fileInfo.setDescription(description);
// open file
- QIODevice *device = new QFile(filePath);
+ QIODevice *device = new QFile(filePath, this);
if (!device->open(QIODevice::ReadOnly))
{
warning(QString("Could not read from %1").arg(filePath));
@@ -1332,6 +1334,7 @@ QXmppTransferJob *QXmppTransferManager::sendFile(const QString &jid, const QStri
// create job
QXmppTransferJob *job = sendFile(jid, device, fileInfo);
job->setLocalFileUrl(QUrl::fromLocalFile(filePath));
+ job->d->deviceIsOwn = true;
return job;
}
@@ -1342,6 +1345,7 @@ QXmppTransferJob *QXmppTransferManager::sendFile(const QString &jid, const QStri
/// Returns 0 if the \a jid is not valid.
///
/// \note The recipient's \a jid must be a full JID with a resource, for instance "user@host/resource".
+/// \note The ownership of the \a device should be managed by the caller.
///
QXmppTransferJob *QXmppTransferManager::sendFile(const QString &jid, QIODevice *device, const QXmppTransferFileInfo &fileInfo, const QString &sid)
@@ -1361,8 +1365,6 @@ QXmppTransferJob *QXmppTransferManager::sendFile(const QString &jid, QIODevice *
job->d->sid = sid;
job->d->fileInfo = fileInfo;
job->d->iodevice = device;
- if (device)
- device->setParent(job);
// check file is open
if (!device || !device->isReadable())