[network/kdeconnect-kde/release/26.08] core/backends/lan: Do not create devicelink if we are going to discard it

Albert Vaca Cintora <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 7ad9ed7ec7319e61357737ce1ee8403d1c560354 by Albert Vaca Cintora.
Committed on 15/08/2026 at 11:10.
Pushed by albertvaka into branch 'release/26.08'.

Do not create devicelink if we are going to discard it

(cherry picked from commit 64c9118704634629f4bb11d972747abf53097189)

M  +3    -3    core/backends/lan/lanlinkprovider.cpp

https://invent.kde.org/network/kdeconnect-kde/-/commit/7ad9ed7ec7319e61357737ce1ee8403d1c560354

diff --git a/core/backends/lan/lanlinkprovider.cpp b/core/backends/lan/lanlinkprovider.cpp
index 5b5ba75a7..832867196 100644
--- a/core/backends/lan/lanlinkprovider.cpp
+++ b/core/backends/lan/lanlinkprovider.cpp
@@ -659,9 +659,6 @@ void LanLinkProvider::addLink(QSslSocket *socket, const DeviceInfo &deviceInfo)
         // qCDebug(KDECONNECT_CORE) << "Reusing link to" << deviceId;
         deviceLink->reset(socket);
     } else {
-        deviceLink = new LanDeviceLink(deviceInfo, this, socket);
-        // Socket disconnection will now be handled by LanDeviceLink
-        disconnect(socket, &QAbstractSocket::disconnected, socket, &QObject::deleteLater);
         bool isDeviceTrusted = KdeConnectConfig::instance().trustedDevices().contains(deviceInfo.id);
         if (!isDeviceTrusted && m_links.size() > MAX_UNPAIRED_CONNECTIONS) {
             qCWarning(KDECONNECT_CORE) << "Too many unpaired devices to remember them all. Ignoring" << deviceInfo.id;
@@ -669,6 +666,9 @@ void LanLinkProvider::addLink(QSslSocket *socket, const DeviceInfo &deviceInfo)
             socket->deleteLater();
             return;
         }
+        deviceLink = new LanDeviceLink(deviceInfo, this, socket);
+        // Socket disconnection will now be handled by LanDeviceLink
+        disconnect(socket, &QAbstractSocket::disconnected, socket, &QObject::deleteLater);
         m_links[deviceInfo.id] = deviceLink;
     }
     Q_EMIT onConnectionReceived(deviceLink);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.