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

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