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

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