Skip to content

Conversation

@wjyrich
Copy link
Contributor

@wjyrich wjyrich commented Jun 17, 2025

as title.

Logs:

Summary by Sourcery

Bug Fixes:

  • Initialize m_showingDesktop from KWin's showingDesktop property in setupKWinDBusConnection() to avoid uninitialized state before signal emission.

@sourcery-ai
Copy link

sourcery-ai bot commented Jun 17, 2025

Reviewer's Guide

This PR ensures that the m_showingDesktop flag used for the smart-hide feature is initialized up-front by synchronously querying KWin’s D-Bus interface, rather than waiting only for future signals.

Sequence diagram for initializing m_showingDesktop from KWin D-Bus

sequenceDiagram
    participant X11DockHelper
    participant KWin (D-Bus)
    X11DockHelper->>KWin (D-Bus): Query property "showingDesktop"
    KWin (D-Bus)-->>X11DockHelper: Return current value (bool)
    X11DockHelper->>X11DockHelper: Set m_showingDesktop = value
Loading

Class diagram for updated X11DockHelper initialization

classDiagram
    class X11DockHelper {
        - m_showingDesktop: bool
        + setupKWinDBusConnection()
    }
    class QDBusInterface
    class QDBusConnection
    X11DockHelper ..> QDBusInterface : uses
    X11DockHelper ..> QDBusConnection : uses
Loading

File-Level Changes

Change Details Files
Add D-Bus headers
  • Include
  • Include
panels/dock/x11dockhelper.cpp
Initialize m_showingDesktop in setupKWinDBusConnection
  • Removed placeholder connect comment
  • Instantiate QDBusInterface to org.kde.KWin
  • Check interface validity
  • Retrieve "showingDesktop" property and convert to bool
  • Assign value to m_showingDesktop before connecting signals
panels/dock/x11dockhelper.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 @wjyrich - I've reviewed your changes and they look great!


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.

@wjyrich wjyrich force-pushed the fix-bug-309173-1 branch from b56f1a5 to 71878a9 Compare June 17, 2025 09:37
@deepin-ci-robot
Copy link

deepin pr auto review

关键摘要:

  • setupKWinDBusConnection函数中,使用QDBusInterface替代了直接连接信号的方式,提高了代码的可读性和可维护性。
  • 添加了对QDBusInterface的有效性检查,确保只有在接口有效时才进行后续操作,增强了代码的健壮性。

是否建议立即修改:

  • 否,提交的代码没有明显的语法或逻辑错误。
  • 是,建议添加对QDBusReply的错误处理,以防止在调用kwin.property("showingDesktop")时可能出现的异常情况。
  • 是,建议在QDBusInterface的创建和使用过程中添加适当的注释,以便其他开发者更好地理解代码的意图和逻辑。

建议的修改:

void X11DockHelper::setupKWinDBusConnection()
{
    // 连接到 KWin 的 D-Bus 接口监听 showingDesktopChanged 信号
    QDBusInterface kwin("org.kde.KWin", "/KWin", "org.kde.KWin", QDBusConnection::sessionBus());
    if (kwin.isValid()) {
        // 获取 showingDesktop 属性,并处理可能的异常
        QDBusReply<QVariant> reply = kwin.property("showingDesktop");
        if (reply.isValid()) {
            m_showingDesktop = reply.value().toBool();
        } else {
            qWarning() << "Failed to get showingDesktop property from KWin";
        }

        // 连接到 showingDesktopChanged 信号
        kwin.connection().connect("org.kde.KWin", "/KWin", "org.kde.KWin", 
                                 "showingDesktopChanged", this, SLOT(onShowingDesktopChanged(bool)));
    } else {
        qWarning() << "Failed to connect to KWin D-Bus interface";
    }
}

@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

@deepin-bot
Copy link

deepin-bot bot commented Jun 19, 2025

TAG Bot

New tag: 2.0.0
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1166

@deepin-bot
Copy link

deepin-bot bot commented Jun 24, 2025

TAG Bot

New tag: 2.0.1
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1169

@wjyrich
Copy link
Contributor Author

wjyrich commented Jun 27, 2025

/forcemerge

@deepin-bot
Copy link

deepin-bot bot commented Jun 27, 2025

This pr force merged! (status: unknown)

@deepin-bot deepin-bot bot merged commit 7b87246 into linuxdeepin:master Jun 27, 2025
7 of 10 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