Skip to content

fix: fix control center plugin loading and page display logic#3142

Open
caixr23 wants to merge 1 commit intolinuxdeepin:masterfrom
caixr23:but-showpage
Open

fix: fix control center plugin loading and page display logic#3142
caixr23 wants to merge 1 commit intolinuxdeepin:masterfrom
caixr23:but-showpage

Conversation

@caixr23
Copy link
Copy Markdown
Contributor

@caixr23 caixr23 commented Apr 1, 2026

  1. Changed PluginManager::addObject signal connection from Qt::QueuedConnection to direct connection to ensure immediate object addition
  2. Modified tryShow() condition to check m_showTimer instead of m_activeObject for determining when to clear show parameters
  3. Added fallback to show root page when no active object exists after clearing show parameters
  4. Reordered emit sequence in addMainObject() to ensure addObject signals are emitted before the final updatePluginStatus signal

Log: Fixed control center page display issues when loading plugins

Influence:

  1. Test control center startup with various plugin configurations
  2. Verify page navigation works correctly after plugin loading
  3. Test D-Bus show requests with different URL parameters
  4. Ensure plugin objects are properly added and displayed
  5. Verify root page displays correctly when no specific page is requested

fix: 修复控制中心插件加载和页面显示逻辑

  1. 将 PluginManager::addObject 信号连接从 Qt::QueuedConnection 改为直接 连接,确保对象立即添加
  2. 修改 tryShow() 条件,使用 m_showTimer 代替 m_activeObject 来判断何时 清除显示参数
  3. 添加在清除显示参数后没有活动对象时回退显示根页面的逻辑
  4. 重新排序 addMainObject() 中的信号发射顺序,确保 addObject 信号在最终 的 updatePluginStatus 信号之前发射

Log: 修复控制中心在加载插件时的页面显示问题

Influence:

  1. 测试控制中心在不同插件配置下的启动情况
  2. 验证插件加载后的页面导航功能是否正常
  3. 测试使用不同URL参数的D-Bus显示请求
  4. 确保插件对象被正确添加和显示
  5. 验证当没有特定页面请求时根页面是否正确显示

Summary by Sourcery

Fix control center page display behavior around plugin loading and show routing.

Bug Fixes:

  • Ensure plugin objects are added to the control center immediately when emitted by PluginManager.
  • Prevent stale show parameters from blocking display and fall back to the root page when no target page is available.
  • Resolve timing/order issues by emitting plugin addObject signals before final plugin status updates.

1. Changed PluginManager::addObject signal connection from
Qt::QueuedConnection to direct connection to ensure immediate object
addition
2. Modified tryShow() condition to check m_showTimer instead of
m_activeObject for determining when to clear show parameters
3. Added fallback to show root page when no active object exists after
clearing show parameters
4. Reordered emit sequence in addMainObject() to ensure addObject
signals are emitted before the final updatePluginStatus signal

Log: Fixed control center page display issues when loading plugins

Influence:
1. Test control center startup with various plugin configurations
2. Verify page navigation works correctly after plugin loading
3. Test D-Bus show requests with different URL parameters
4. Ensure plugin objects are properly added and displayed
5. Verify root page displays correctly when no specific page is
requested

fix: 修复控制中心插件加载和页面显示逻辑

1. 将 PluginManager::addObject 信号连接从 Qt::QueuedConnection 改为直接
连接,确保对象立即添加
2. 修改 tryShow() 条件,使用 m_showTimer 代替 m_activeObject 来判断何时
清除显示参数
3. 添加在清除显示参数后没有活动对象时回退显示根页面的逻辑
4. 重新排序 addMainObject() 中的信号发射顺序,确保 addObject 信号在最终
的 updatePluginStatus 信号之前发射

Log: 修复控制中心在加载插件时的页面显示问题

Influence:
1. 测试控制中心在不同插件配置下的启动情况
2. 验证插件加载后的页面导航功能是否正常
3. 测试使用不同URL参数的D-Bus显示请求
4. 确保插件对象被正确添加和显示
5. 验证当没有特定页面请求时根页面是否正确显示
@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: caixr23

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

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Apr 1, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts control center plugin loading and page display timing by making plugin object additions immediate, refining when show parameters are cleared, adding a root-page fallback when no active object is available, and reordering plugin status signals to better reflect object availability.

Sequence diagram for updated plugin loading and page display

sequenceDiagram
    actor User
    participant ControlCenterUI as DccManager
    participant PluginMgr as PluginManager
    participant ShowTimer as QTimer_showTimer
    participant DBusClient

    User ->> ControlCenterUI: startControlCenter()
    ControlCenterUI ->> PluginMgr: loadAllPlugins()
    PluginMgr ->> PluginMgr: addMainObject(plugin)
    PluginMgr -->> ControlCenterUI: addObject(mainObj)
    ControlCenterUI ->> ControlCenterUI: addObject(mainObj) sets m_activeObject
    PluginMgr -->> ControlCenterUI: addObject(soObj)
    ControlCenterUI ->> ControlCenterUI: addObject(soObj) maybe updates m_activeObject
    PluginMgr -->> ControlCenterUI: updatePluginStatus(plugin, MainObjEnd|PluginEnd, "add main object finished")

    PluginMgr -->> ControlCenterUI: loadAllFinished
    ControlCenterUI -->> ControlCenterUI: tryShow() (queued)

    DBusClient ->> ControlCenterUI: show(url)
    ControlCenterUI ->> ControlCenterUI: set m_showUrl, start m_showTimer

    ShowTimer ->> ControlCenterUI: timeout -> tryShow()
    alt m_showUrl is empty and m_showTimer exists
        ControlCenterUI ->> ControlCenterUI: clearShowParam()
        ControlCenterUI ->> ControlCenterUI: showPage(m_root, "")
    else m_showUrl is not empty
        ControlCenterUI ->> ControlCenterUI: find object for m_showUrl
        alt object found
            ControlCenterUI ->> ControlCenterUI: showPage(targetObj, subPage)
            ControlCenterUI ->> ControlCenterUI: clearShowParam()
            alt no m_activeObject after clear
                ControlCenterUI ->> ControlCenterUI: showPage(m_root, "")
            end
        else object not found
            ControlCenterUI ->> DBusClient: errorReply(InvalidArgs, not_found_url)
            ControlCenterUI ->> ControlCenterUI: clearShowParam()
            alt no m_activeObject after clear
                ControlCenterUI ->> ControlCenterUI: showPage(m_root, "")
            end
        end
    end
Loading

Updated class diagram for DccManager and PluginManager

classDiagram
    class DccManager {
        - PluginManager* m_plugins
        - QTimer* m_showTimer
        - QString m_showUrl
        - QObject* m_activeObject
        - QObject* m_root
        - QList~QObject*~ m_noParentObjects
        + DccManager(QObject* parent)
        + void addObject(QObject* obj)
        + void clearShowParam()
        + void tryShow()
        + void showPage(QObject* root, QString subPageId)
    }

    class PluginManager {
        + void addMainObject(PluginData* plugin)
        + void moduleLoading()
        <<signal>> void addObject(QObject* obj)
        <<signal>> void loadAllFinished()
        <<signal>> void updatePluginStatus(PluginData* plugin, int status, QString message)
    }

    class PluginData {
        + QObject* mainObj
        + QObject* soObj
    }

    DccManager --> PluginManager : uses
    PluginManager --> PluginData : manages
    PluginManager ..> DccManager : addObject signal
    PluginManager ..> DccManager : loadAllFinished signal
Loading

File-Level Changes

Change Details Files
Make plugin object additions synchronous to ensure pages can be shown as soon as plugins finish loading.
  • Change PluginManager::addObject signal connection in DccManager constructor from Qt::QueuedConnection to a direct connection so addObject is handled immediately on emission
  • Keep loadAllFinished connection queued so tryShow() still runs after plugin loading completes and queued events are processed
src/dde-control-center/dccmanager.cpp
Refine show logic to clear parameters based on timer state and provide a root-page fallback when no active object is available.
  • Update tryShow() early-exit condition to check that m_showUrl is empty and m_showTimer exists instead of testing m_activeObject, then clear show parameters and show the root page
  • After processing show requests and clearing parameters, if no active object exists, explicitly show the root page as a fallback
src/dde-control-center/dccmanager.cpp
Reorder main-object-related status and object-addition signals so that plugin status reflects that objects are available.
  • Move the final updatePluginStatus(MainObjEnd
PluginEnd, ...) emission in addMainObject() to occur after emitting addObject for mainObj and soObj, ensuring consumers see a consistent state where objects are already added when the end status is observed

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
Copy Markdown

@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 left some high level feedback:

  • In DccManager::tryShow(), the new condition m_showUrl.isEmpty() && m_showTimer will always be true after construction because m_showTimer is never null; if the intent was to guard on a pending timer-based show, consider checking m_showTimer->isActive() (or an equivalent state) instead of the pointer itself.
  • Changing the PluginManager::addObject connection from Qt::QueuedConnection to the default direct/auto connection can introduce cross-thread issues if PluginManager ever lives in a different thread from DccManager; consider either documenting the same-thread assumption or using Qt::AutoConnection with an explicit guarantee on thread affinity.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `DccManager::tryShow()`, the new condition `m_showUrl.isEmpty() && m_showTimer` will always be true after construction because `m_showTimer` is never null; if the intent was to guard on a pending timer-based show, consider checking `m_showTimer->isActive()` (or an equivalent state) instead of the pointer itself.
- Changing the `PluginManager::addObject` connection from `Qt::QueuedConnection` to the default direct/auto connection can introduce cross-thread issues if `PluginManager` ever lives in a different thread from `DccManager`; consider either documenting the same-thread assumption or using `Qt::AutoConnection` with an explicit guarantee on thread affinity.

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.

@deepin-bot
Copy link
Copy Markdown

deepin-bot bot commented Apr 3, 2026

TAG Bot

New tag: 6.1.80
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #3153

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.

2 participants