From d7ec24725f93599728a055885f9febd05d7df653 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Fri, 14 Jul 2017 03:30:49 +0200 Subject: [PATCH] Make sure we keep track of changes when the device link changes Especially useful because it contains the announce name. CCBUG: 364150 --- core/backends/lan/lanlinkprovider.cpp | 3 +-- core/device.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/core/backends/lan/lanlinkprovider.cpp b/core/backends/lan/lanlinkprovider.cpp index 91963e0de..138981328 100644 --- a/core/backends/lan/lanlinkprovider.cpp +++ b/core/backends/lan/lanlinkprovider.cpp @@ -501,9 +501,8 @@ void LanLinkProvider::addLink(const QString& deviceId, QSslSocket* socket, Netwo Q_ASSERT(mPairingHandlers.contains(deviceId)); mPairingHandlers[deviceId]->setDeviceLink(deviceLink); } - Q_EMIT onConnectionReceived(*receivedPackage, deviceLink); } - + Q_EMIT onConnectionReceived(*receivedPackage, deviceLink); } LanPairingHandler* LanLinkProvider::createPairingHandler(DeviceLink* link) diff --git a/core/device.cpp b/core/device.cpp index 413d89587..28de1a7f2 100644 --- a/core/device.cpp +++ b/core/device.cpp @@ -209,7 +209,11 @@ void Device::addLink(const NetworkPackage& identityPackage, DeviceLink* link) { //qCDebug(KDECONNECT_CORE) << "Adding link to" << id() << "via" << link->provider(); - Q_ASSERT(!m_deviceLinks.contains(link)); + setName(identityPackage.get(QStringLiteral("deviceName"))); + m_deviceType = str2type(identityPackage.get(QStringLiteral("deviceType"))); + + if (m_deviceLinks.contains(link)) + return; m_protocolVersion = identityPackage.get(QStringLiteral("protocolVersion"), -1); if (m_protocolVersion != NetworkPackage::ProtocolVersion) { @@ -221,10 +225,6 @@ void Device::addLink(const NetworkPackage& identityPackage, DeviceLink* link) m_deviceLinks.append(link); - //re-read the device name from the identityPackage because it could have changed - setName(identityPackage.get(QStringLiteral("deviceName"))); - m_deviceType = str2type(identityPackage.get(QStringLiteral("deviceType"))); - //Theoretically we will never add two links from the same provider (the provider should destroy //the old one before this is called), so we do not have to worry about destroying old links. //-- Actually, we should not destroy them or the provider will store an invalid ref!