diff options
author | Nedim Hadzic <nhadzic@blackberry.com> | 2014-03-31 10:27:25 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-04-04 10:57:00 +0200 |
commit | 2e0f7adbe4257cc3914db0b4a9e6f42cb12f948d (patch) | |
tree | a32c12c518c7a55cf332e79a6e6fe9245d2544da | |
parent | a5c733405e70945049f131f86e5c0b50c3249a08 (diff) |
Temporary file copy fix Bluez
If size is -1 it will go in endless while loop.
Added error handling in case QIODevice cannot be read.
Change-Id: I2026e45ac48592f32ce275871bf992413d7815b6
Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
-rw-r--r-- | src/bluetooth/qbluetoothtransferreply_bluez.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/bluetooth/qbluetoothtransferreply_bluez.cpp b/src/bluetooth/qbluetoothtransferreply_bluez.cpp index 8b271789..f0b4b5c2 100644 --- a/src/bluetooth/qbluetoothtransferreply_bluez.cpp +++ b/src/bluetooth/qbluetoothtransferreply_bluez.cpp @@ -104,6 +104,15 @@ bool QBluetoothTransferReplyBluez::start() tempfile = new QTemporaryFile(this ); tempfile->open(); qCDebug(QT_BT_BLUEZ) << "Not a QFile, making a copy" << tempfile->fileName(); + if (!source->isReadable()) { + m_errorStr = QBluetoothTransferReply::tr("QIODevice cannot be read." + "Make sure it is open for reading."); + m_error = QBluetoothTransferReply::IODeviceNotReadableError; + m_finished = true; + m_running = false; + QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection, Q_ARG(QBluetoothTransferReply*, this)); + return false; + } QFutureWatcher<bool> *watcher = new QFutureWatcher<bool>(); QObject::connect(watcher, SIGNAL(finished()), this, SLOT(copyDone())); @@ -139,7 +148,7 @@ bool QBluetoothTransferReplyBluez::copyToTempFile(QIODevice *to, QIODevice *from char *block = new char[4096]; int size; - while((size = from->read(block, 4096))) { + while ((size = from->read(block, 4096)) > 0) { if(size != to->write(block, size)){ return false; } |