From 7cab490cc54133e2e164a5e8766ba9f6afc69ee8 Mon Sep 17 00:00:00 2001 From: Matthijs Tijink Date: Thu, 4 Oct 2018 19:05:15 +0200 Subject: [PATCH] Fix receiving payloads using a bluetooth connection Summary: This fixes receiving payloads using the bluetooth backend. This looks like some bug in Qt, but I couldn't figure out what happens exactly (will report a bug though). Test Plan: Receiving files now works! Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: kdeconnect, nicolasfella, apol, #kde_connect Tags: #kde_connect Differential Revision: https://phabricator.kde.org/D12153 --- core/backends/bluetooth/bluetoothdownloadjob.cpp | 3 ++- core/filetransferjob.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/core/backends/bluetooth/bluetoothdownloadjob.cpp b/core/backends/bluetooth/bluetoothdownloadjob.cpp index 1557e13d9..74e5c6a71 100644 --- a/core/backends/bluetooth/bluetoothdownloadjob.cpp +++ b/core/backends/bluetooth/bluetoothdownloadjob.cpp @@ -35,6 +35,7 @@ QSharedPointer BluetoothDownloadJob::payload() const void BluetoothDownloadJob::start() { - connect(mSocket.data(), SIGNAL(disconnected()), this, SLOT(deleteLater())); + connect(mSocket.data(), &QBluetoothSocket::disconnected, mSocket.data(), &QBluetoothSocket::readyRead); + connect(mSocket.data(), &QBluetoothSocket::disconnected, mSocket.data(), &QBluetoothSocket::readChannelFinished); mSocket->connectToService(mRemoteAddress, mTransferUuid, QIODevice::ReadOnly); } diff --git a/core/filetransferjob.cpp b/core/filetransferjob.cpp index 583cb0af9..c16a15e3d 100644 --- a/core/filetransferjob.cpp +++ b/core/filetransferjob.cpp @@ -40,7 +40,8 @@ FileTransferJob::FileTransferJob(const QSharedPointer& origin, qint64 , m_size(size) { Q_ASSERT(m_origin); - Q_ASSERT(m_origin->isReadable()); + //Disabled this assert: QBluetoothSocket doesn't report "->isReadable() == true" until it's connected + //Q_ASSERT(m_origin->isReadable()); if (m_destination.scheme().isEmpty()) { qCWarning(KDECONNECT_CORE) << "Destination QUrl" << m_destination << "lacks a scheme. Setting its scheme to 'file'."; m_destination.setScheme(QStringLiteral("file"));