From b6876733ba4d49d99269a290c170b1c3716e35d4 Mon Sep 17 00:00:00 2001 From: Alexandr Akulich Date: Tue, 29 Sep 2015 16:47:45 +0500 Subject: QXmppTransferManager: Fixed device ownership. - sendFile() without a device argument now set Job as a parent for the constructed (own) device. - sendFile() with a device argument does not reparent the device anymore. --- src/client/QXmppTransferManager.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/client/QXmppTransferManager.cpp') diff --git a/src/client/QXmppTransferManager.cpp b/src/client/QXmppTransferManager.cpp index 6fb2da75..0784279e 100644 --- a/src/client/QXmppTransferManager.cpp +++ b/src/client/QXmppTransferManager.cpp @@ -1307,7 +1307,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)); @@ -1342,6 +1342,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 +1362,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()) -- cgit v1.2.3