From 2cb11c7869f193aca118bbf07e897ad694fdbd3f Mon Sep 17 00:00:00 2001 From: wjyrich Date: Wed, 25 Mar 2026 10:43:51 +0800 Subject: [PATCH] fix: fix notification settings opening via direct D-Bus call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changed the method of opening notification settings from using the controlCenterInterface() helper to directly constructing a D-Bus message and making an async call. The previous approach used a QDBusReply which would wait for a synchronous response, potentially blocking the UI. The new implementation uses QDBusMessage::createMethodCall to create the message and QDBusConnection::sessionBus().asyncCall() to send it asynchronously, improving responsiveness. Log: Fixed issue where opening notification settings could cause UI lag Influence: 1. Test clicking notification settings button in notification center 2. Verify settings window opens without delay 3. Check that other notification center functions remain unaffected 4. Test with multiple rapid clicks to ensure no blocking occurs fix: 修复通过直接 D-Bus 调用打开通知设置的问题 将打开通知设置的方法从使用 controlCenterInterface() 辅助函数改为直接构造 D-Bus 消息并进行异步调用。之前的方法使用 QDBusReply 会等待同步响应,可能 导致 UI 阻塞。新实现使用 QDBusMessage::createMethodCall 创建消息,并使用 QDBusConnection::sessionBus().asyncCall() 异步发送,提高了响应速度。 Log: 修复了打开通知设置可能导致界面卡顿的问题 Influence: 1. 测试通知中心中点击通知设置按钮 2. 验证设置窗口打开无延迟 3. 检查通知中心其他功能是否不受影响 4. 测试多次快速点击确保不会发生阻塞 PMS: BUG-353895 --- panels/notification/center/notifyaccessor.cpp | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/panels/notification/center/notifyaccessor.cpp b/panels/notification/center/notifyaccessor.cpp index e64534731..ca763d374 100644 --- a/panels/notification/center/notifyaccessor.cpp +++ b/panels/notification/center/notifyaccessor.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -26,14 +26,6 @@ namespace notifycenter { static const uint ShowNotificationTop = 7; static const QString InvalidApp {"DS-Invalid-Apps"}; static const QStringList InvalidPinnedApps {InvalidApp}; - -static QDBusInterface controlCenterInterface() -{ - return QDBusInterface("org.deepin.dde.ControlCenter1", - "/org/deepin/dde/ControlCenter1", - "org.deepin.dde.ControlCenter1"); -} - class EventFilter : public QObject { // QObject interface @@ -219,12 +211,20 @@ bool NotifyAccessor::applicationPin(const QString &appId) const void NotifyAccessor::openNotificationSetting() { qDebug(notifyLog) << "Open notification setting"; - QDBusReply reply = controlCenterInterface().call("ShowPage", - "notification"); - if (reply.error().isValid()) { - qWarning(notifyLog) << "Failed to Open notifycation setting" << reply.error().message(); - return; - } + QDBusMessage msg = QDBusMessage::createMethodCall("org.deepin.dde.ControlCenter1", + "/org/deepin/dde/ControlCenter1", + "org.deepin.dde.ControlCenter1", + "ShowPage"); + msg << "notification"; + QDBusPendingCall call = QDBusConnection::sessionBus().asyncCall(msg); + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this); + connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher *self) { + QDBusReply reply = *self; + if (!reply.isValid()) { + qWarning(notifyLog) << "Failed to open notification setting:" << reply.error().message(); + } + self->deleteLater(); + }); } void NotifyAccessor::onNotificationStateChanged(qint64 id, int processedType)