From 38e7bc50fb3d5fa7452db1693d2366ed6734e981 Mon Sep 17 00:00:00 2001 From: zhangyuanyuan1 Date: Thu, 13 Oct 2022 11:41:56 +0800 Subject: [PATCH] =?UTF-8?q?dbus=20reply=20=E5=90=88=E6=B3=95=E6=80=A7?= =?UTF-8?q?=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/proxy/proxy.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/plugins/proxy/proxy.cpp b/plugins/proxy/proxy.cpp index 22b13213..65205898 100644 --- a/plugins/proxy/proxy.cpp +++ b/plugins/proxy/proxy.cpp @@ -848,7 +848,12 @@ bool Proxy::getAppProxyState() //获取应用代理开启状态 qDebug() << "call QDBusInterface getProxyStateDbus"; QDBusReply reply = m_appProxyDbus->call("getProxyStateDbus"); + + if (!reply.isValid()) { + return -1; + } state = reply; + return state; } @@ -881,6 +886,12 @@ QStringList Proxy::getAppProxyConf() //获取应用代理配置信息 qDebug() << "call QDBusInterface getProxyConfig"; QDBusReply reply = dbusInterface.call("getProxyConfig"); + + if (!reply.isValid()) { + qWarning ()<< "Return empty app proxy information, getProxyConfig reply is invalid"; + return info; + } + info = reply.value(); if (info.isEmpty()) { @@ -911,18 +922,25 @@ QMap Proxy::getAppListProxy() QMap appList; appList.clear(); - QDBusInterface *dbusInterface = new QDBusInterface("org.ukui.SettingsDaemon", + QDBusInterface dbusInterface("org.ukui.SettingsDaemon", "/org/ukui/SettingsDaemon/AppProxy", "org.ukui.SettingsDaemon.AppProxy", QDBusConnection::sessionBus()); - if(!dbusInterface->isValid()) { + if(!dbusInterface.isValid()) { qWarning ()<< "init AppProxy dbus error"; + return appList; } //获取可以配置应用代理的应用信息 qDebug() << "call QDBusInterface getAppProxy"; - QDBusReply> reply = dbusInterface->call("getAppProxy"); + QDBusReply> reply = dbusInterface.call("getAppProxy"); + + if (!reply.isValid()) { + qWarning ()<< "Return empty app list, getAppProxy reply is invalid"; + return appList; + } + appList = reply.value(); if (appList.isEmpty()) { qWarning() << "getAppProxy reply appList is empty";