[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498

Maximiliano Curia maxy at moszumanska.debian.org
Fri Oct 14 14:26:47 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=046d01c

The following commit has been merged in the master branch:
commit 046d01c16df7d27e9cec4071d0950418c1d3f887
Author: Albert Vaca <albertvaka at gmail.com>
Date:   Fri Aug 16 05:35:00 2013 +0200

    Emit connectionLost *after* connectionReceived
    
    To prevent destroying and recreating the same device again
---
 daemon/linkproviders/broadcasttcplinkprovider.cpp | 30 +++++++++++++----------
 1 file changed, 17 insertions(+), 13 deletions(-)

diff --git a/daemon/linkproviders/broadcasttcplinkprovider.cpp b/daemon/linkproviders/broadcasttcplinkprovider.cpp
index bbfd274..45a0e73 100644
--- a/daemon/linkproviders/broadcasttcplinkprovider.cpp
+++ b/daemon/linkproviders/broadcasttcplinkprovider.cpp
@@ -88,14 +88,6 @@ void BroadcastTcpLinkProvider::newUdpConnection()
                 return;
             }
 
-            const QString& id = np->get<QString>("deviceId");
-            if (links.contains(id)) {
-                //Delete old link if we already know it, probably it is down if this happens.
-                qDebug() << "Destroying old link";
-                delete links[id];
-                links.remove(id);
-            }
-
             int tcpPort = np->get<int>("tcpPort",port);
 
             qDebug() << "Received Udp presentation from" << sender << "asking for a tcp connection on port " << tcpPort;
@@ -107,6 +99,7 @@ void BroadcastTcpLinkProvider::newUdpConnection()
             connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(connectError()));
             socket->connectToHost(sender, tcpPort);
 
+
         } else {
 
             delete np;
@@ -147,6 +140,9 @@ void BroadcastTcpLinkProvider::connected()
 
     connect(dl,SIGNAL(destroyed(QObject*)),this,SLOT(deviceLinkDestroyed(QObject*)));
 
+    QMap< QString, DeviceLink* >::iterator oldLinkIterator = links.find(id);
+    DeviceLink* oldLink = (oldLinkIterator == links.end())? 0 : oldLinkIterator.value();
+
     links[id] = dl;
 
     NetworkPackage np2("");
@@ -165,6 +161,11 @@ void BroadcastTcpLinkProvider::connected()
         delete dl;
     }
 
+    if (oldLink) {
+        Q_EMIT onConnectionLost(oldLink);
+        delete oldLink;
+    }
+
     receivedIdentityPackages.remove(socket);
     delete np;
 
@@ -208,11 +209,9 @@ void BroadcastTcpLinkProvider::dataReceived()
 
         connect(dl,SIGNAL(destroyed(QObject*)),this,SLOT(deviceLinkDestroyed(QObject*)));
 
-        if (links.contains(id)) {
-            //Delete old link if we already know it, probably it is down if this happens.
-            qDebug() << "Destroying old link";
-            delete links[id];
-        }
+        QMap< QString, DeviceLink* >::iterator oldLinkIterator = links.find(id);
+        DeviceLink* oldLink = (oldLinkIterator == links.end())? 0 : oldLinkIterator.value();
+
         links[id] = dl;
 
         //qDebug() << "BroadcastTcpLinkProvider creating link to device" << id << "(" << socket->peerAddress() << ")";
@@ -221,6 +220,11 @@ void BroadcastTcpLinkProvider::dataReceived()
 
         Q_EMIT onConnectionReceived(np, dl);
 
+        if (oldLink) {
+            Q_EMIT onConnectionLost(oldLink);
+            delete oldLink;
+        }
+        
         disconnect(socket,SIGNAL(readyRead()),this,SLOT(dataReceived()));
 
     } else {

-- 
kdeconnect packaging



More information about the pkg-kde-commits mailing list