From 2c0a13825776ca1bd97f5011c821c577305009a9 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Thu, 10 Sep 2015 21:51:08 +0200 Subject: [PATCH] Check PendingReady return values Apparently you can get a valid accountset without a valid filter, which then crashes BUG: 352532 --- telepathy-cm/kdeconnecttelepathyprotocolfactory.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/telepathy-cm/kdeconnecttelepathyprotocolfactory.cpp b/telepathy-cm/kdeconnecttelepathyprotocolfactory.cpp index d8d199662..c5d694fda 100644 --- a/telepathy-cm/kdeconnecttelepathyprotocolfactory.cpp +++ b/telepathy-cm/kdeconnecttelepathyprotocolfactory.cpp @@ -44,7 +44,11 @@ ConnectProtocolPtr KDEConnectTelepathyProtocolFactory::interface() { //maybe this should be per device.. with a device ID as a parameter, but lets keep it connect for now Tp::AccountManagerPtr am = Tp::AccountManager::create(QDBusConnection::sessionBus()); - QObject::connect(am->becomeReady(), &Tp::PendingOperation::finished, [am]() { + Tp::PendingReady *pr = am->becomeReady(); + QObject::connect(pr, &Tp::PendingOperation::finished, [pr,am]() { + if (pr->isError()) { + return; + } Tp::AccountSetPtr accounts = am->accountsByProtocol("kdeconnect"); if (!accounts) { return; @@ -52,7 +56,7 @@ ConnectProtocolPtr KDEConnectTelepathyProtocolFactory::interface() { if (accounts->accounts().isEmpty()) { Tp::PendingAccount* pa = am->createAccount("kdeconnect", "kdeconnect", "kdeconnect", QVariantMap(), QVariantMap()); QObject::connect(pa, &Tp::PendingOperation::finished, pa, [pa](){ - if (!pa->account()) { + if (pa->isError() || !pa->account()) { return; } pa->account()->setEnabled(true);