Skip to content

fix: fix notification settings opening via direct D-Bus call#1530

Merged
18202781743 merged 1 commit intolinuxdeepin:masterfrom
wjyrich:fix-bug-353895
Mar 25, 2026
Merged

fix: fix notification settings opening via direct D-Bus call#1530
18202781743 merged 1 commit intolinuxdeepin:masterfrom
wjyrich:fix-bug-353895

Conversation

@wjyrich
Copy link
Contributor

@wjyrich wjyrich commented Mar 25, 2026

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

Summary by Sourcery

Handle opening of notification settings via an asynchronous D-Bus method call to avoid blocking the UI.

Bug Fixes:

  • Prevent UI lag when opening notification settings from the notification center.

Enhancements:

  • Switch notification settings opening to a direct, asynchronous D-Bus call instead of using the controlCenterInterface helper.

@sourcery-ai
Copy link

sourcery-ai bot commented Mar 25, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Switches opening of notification settings from a synchronous D‑Bus helper call to a manually constructed, asynchronous D‑Bus method call to avoid UI blocking when launching the settings page from the notification center.

Sequence diagram for asynchronously opening notification settings via D-Bus

sequenceDiagram
    actor User
    participant NotificationCenter
    participant NotifyAccessor
    participant QDBusConnection_sessionBus as QDBusConnection_sessionBus
    participant ControlCenter1 as org_deepin_dde_ControlCenter1

    User ->> NotificationCenter: clickNotificationSettingsButton()
    NotificationCenter ->> NotifyAccessor: openNotificationSetting()
    NotifyAccessor ->> NotifyAccessor: create QDBusMessage(ShowPage)
    NotifyAccessor ->> QDBusConnection_sessionBus: asyncCall(msg "notification")
    QDBusConnection_sessionBus -->> ControlCenter1: ShowPage("notification")
    ControlCenter1 -->> QDBusConnection_sessionBus: process request (no reply awaited)
    Note over User,NotificationCenter: UI remains responsive while settings open
Loading

Class diagram for NotifyAccessor using asynchronous D-Bus call

classDiagram
    class NotifyAccessor {
        +bool applicationPin(QString appId) const
        +void openNotificationSetting()
        +void onNotificationStateChanged(qint64 id, int processedType)
    }

    class QDBusMessage {
        +static QDBusMessage createMethodCall(QString service, QString path, QString interface, QString method)
        +QDBusMessage operator_left_shift(QString arg)
    }

    class QDBusConnection {
        +static QDBusConnection sessionBus()
        +void asyncCall(QDBusMessage msg)
    }

    NotifyAccessor ..> QDBusMessage : constructs
    NotifyAccessor ..> QDBusConnection : uses sessionBus_asyncCall
Loading

File-Level Changes

Change Details Files
Change notification settings launcher to use an explicit asynchronous D-Bus method call instead of the controlCenterInterface() synchronous helper.
  • Replace controlCenterInterface().call("ShowPage", "notification") and QDBusReply-based error handling with explicit construction of a QDBusMessage using createMethodCall for org.deepin.dde.ControlCenter1.ShowPage.
  • Append the "notification" page argument directly to the constructed QDBusMessage before sending.
  • Dispatch the D-Bus call via QDBusConnection::sessionBus().asyncCall(msg) so the UI is not blocked waiting for a reply.
panels/notification/center/notifyaccessor.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • The new async D-Bus call drops all error handling; consider at least adding minimal failure logging via a QDBusPendingCallWatcher or another mechanism so that failures to open the settings are still observable.
  • Instead of hardcoding the service, path, and interface here, you could reuse or extend the existing controlCenterInterface helper with asyncCall to avoid duplicating those strings and keep call sites consistent.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new async D-Bus call drops all error handling; consider at least adding minimal failure logging via a QDBusPendingCallWatcher or another mechanism so that failures to open the settings are still observable.
- Instead of hardcoding the service, path, and interface here, you could reuse or extend the existing controlCenterInterface helper with asyncCall to avoid duplicating those strings and keep call sites consistent.

## Individual Comments

### Comment 1
<location path="panels/notification/center/notifyaccessor.cpp" line_range="222-227" />
<code_context>
-        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";
+    QDBusConnection::sessionBus().asyncCall(msg);
 }

</code_context>
<issue_to_address>
**issue (bug_risk):** Async call drops error handling and logging compared to the previous sync implementation.

Previously, the sync `controlCenterInterface().call("ShowPage", "notification")` logged DBus errors and bailed out on failure. The new `asyncCall` is fire‑and‑forget, so failures (service unavailable, method not found, etc.) are now silent. If that feedback is still needed, consider `QDBusPendingCall`/`QDBusPendingCallWatcher` or another way to at least log failures, or add a comment making it explicit that errors are intentionally ignored.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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
@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, wjyrich

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@18202781743 18202781743 merged commit 0d5d499 into linuxdeepin:master Mar 25, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants