Blame SOURCES/0017-filereceiver-Fix-crash-when-sending-device-is-null.patch

03fe1d
From a967936a34b2f17e002f9d69dae3e74b0ef20799 Mon Sep 17 00:00:00 2001
03fe1d
From: David Rosca <nowrep@gmail.com>
03fe1d
Date: Mon, 12 Jan 2015 14:19:42 +0100
03fe1d
Subject: [PATCH 17/20] filereceiver: Fix crash when sending device is null
03fe1d
03fe1d
BUG: 342581
03fe1d
---
03fe1d
 src/daemon/kded/filereceiver/receivefilejob.cpp | 19 +++++++++++++++----
03fe1d
 1 file changed, 15 insertions(+), 4 deletions(-)
03fe1d
03fe1d
diff --git a/src/daemon/kded/filereceiver/receivefilejob.cpp b/src/daemon/kded/filereceiver/receivefilejob.cpp
03fe1d
index daf6c57..1de755a 100644
03fe1d
--- a/src/daemon/kded/filereceiver/receivefilejob.cpp
03fe1d
+++ b/src/daemon/kded/filereceiver/receivefilejob.cpp
03fe1d
@@ -85,20 +85,31 @@ void ReceiveFileJob::init()
03fe1d
             SLOT(transferPropertiesChanged(QString,QVariantMap,QStringList)));
03fe1d
 
03fe1d
     m_session = new org::bluez::obex::Session1("org.bluez.obex", m_transfer->session().path(), QDBusConnection::sessionBus(), this);
03fe1d
-    kDebug(dblue()) << m_session->destination();
03fe1d
 
03fe1d
-    Device* device = Manager::self()->usableAdapter()->deviceForAddress(m_session->destination());
03fe1d
-    kDebug(dblue()) << device;
03fe1d
+    kDebug(dblue()) << "Source:" << m_session->source();
03fe1d
+    kDebug(dblue()) << "Destination:" << m_session->destination();
03fe1d
+
03fe1d
+    Device *device = 0;
03fe1d
+    bool isDeviceTrusted = false;
03fe1d
+
03fe1d
+    Q_FOREACH (Adapter *adapter, Manager::self()->adapters()) {
03fe1d
+        if (adapter->address() == m_session->source()) {
03fe1d
+            device = adapter->deviceForAddress(m_session->destination());
03fe1d
+            break;
03fe1d
+        }
03fe1d
+    }
03fe1d
 
03fe1d
     m_deviceName = m_session->destination();
03fe1d
+
03fe1d
     if (device) {
03fe1d
         kDebug(dblue()) << device->name();
03fe1d
         m_deviceName = device->name();
03fe1d
+        isDeviceTrusted = device->isTrusted();
03fe1d
     }
03fe1d
 
03fe1d
     FileReceiverSettings::self()->readConfig();
03fe1d
     kDebug(dblue()) << "Auto Accept: " << FileReceiverSettings::self()->autoAccept();
03fe1d
-    if (FileReceiverSettings::self()->autoAccept() == 1 && device->isTrusted()) {
03fe1d
+    if (FileReceiverSettings::self()->autoAccept() == 1 && isDeviceTrusted) {
03fe1d
         slotAccept();
03fe1d
         return;
03fe1d
     } else if (FileReceiverSettings::self()->autoAccept() == 2) {
03fe1d
-- 
03fe1d
2.1.0
03fe1d