telepathy-qt: IncomingFileTransferChannel: Fixed device management.
Alexandr Akulich
kaffeine at kemper.freedesktop.org
Sat Apr 23 08:33:21 UTC 2016
Module: telepathy-qt
Branch: master
Commit: 3422faaca86e79ce8acc42296e407f8f2548186c
URL: http://cgit.freedesktop.org/telepathy/telepathy-qt/commit/?id=3422faaca86e79ce8acc42296e407f8f2548186c
Author: Alexandr Akulich <akulichalexander at gmail.com>
Date: Tue Feb 16 14:11:16 2016 +0500
IncomingFileTransferChannel: Fixed device management.
Now we close the device only if we opened it.
---
TelepathyQt/incoming-file-transfer-channel.cpp | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/TelepathyQt/incoming-file-transfer-channel.cpp b/TelepathyQt/incoming-file-transfer-channel.cpp
index 096ede0..4653bf5 100644
--- a/TelepathyQt/incoming-file-transfer-channel.cpp
+++ b/TelepathyQt/incoming-file-transfer-channel.cpp
@@ -54,6 +54,7 @@ struct TP_QT_NO_EXPORT IncomingFileTransferChannel::Private
qulonglong requestedOffset;
qint64 pos;
+ bool weOpenedDevice;
};
IncomingFileTransferChannel::Private::Private(IncomingFileTransferChannel *parent)
@@ -62,7 +63,8 @@ IncomingFileTransferChannel::Private::Private(IncomingFileTransferChannel *paren
output(0),
socket(0),
requestedOffset(0),
- pos(0)
+ pos(0),
+ weOpenedDevice(false)
{
parent->connect(fileTransferInterface,
SIGNAL(URIDefined(QString)),
@@ -232,12 +234,18 @@ PendingOperation *IncomingFileTransferChannel::acceptFile(qulonglong offset,
IncomingFileTransferChannelPtr(this));
}
- if ((!output->isOpen() && !output->open(QIODevice::WriteOnly)) &&
- (!output->isWritable())) {
+ if (!output->isOpen()) {
+ if (output->open(QIODevice::WriteOnly)) {
+ mPriv->weOpenedDevice = true;
+ }
+ }
+
+ if (!output->isWritable()) {
+ mPriv->weOpenedDevice = false;
warning() << "Unable to open IO device for writing";
return new PendingFailure(TP_QT_ERROR_PERMISSION_DENIED,
- QLatin1String("Unable to open IO device for writing"),
- IncomingFileTransferChannelPtr(this));
+ QLatin1String("Unable to open IO device for writing"),
+ IncomingFileTransferChannelPtr(this));
}
mPriv->output = output;
@@ -371,7 +379,7 @@ void IncomingFileTransferChannel::setFinished()
mPriv->socket->close();
}
- if (mPriv->output) {
+ if (mPriv->output && mPriv->weOpenedDevice) {
mPriv->output->close();
}
More information about the telepathy-commits
mailing list