Skip to content

fix: DSL connection deletion signal processing error#376

Merged
caixr23 merged 1 commit intolinuxdeepin:masterfrom
caixr23:master
Jul 7, 2025
Merged

fix: DSL connection deletion signal processing error#376
caixr23 merged 1 commit intolinuxdeepin:masterfrom
caixr23:master

Conversation

@caixr23
Copy link
Copy Markdown
Contributor

@caixr23 caixr23 commented Jul 7, 2025

DSL connection deletion signal processing error

pms: BUG-308553

Summary by Sourcery

Fix errors in DSL connection signal handling and improve property safety in QML.

Bug Fixes:

  • Emit DSL connection removal correctly via itemRemoved instead of erroneously creating and adding items.
  • Prevent redundant itemAdded signals when adding PPPoE connections in DSLController_NM.

Enhancements:

  • Add null checks for QML PageAppProxy properties proxyEnable and config to avoid undefined access.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Jul 7, 2025

Reviewer's Guide

This PR corrects DSL connection signal handling by replacing incorrect addition signals with removal signals, consolidates DSL item addition emissions within the controller, and improves QML null-safety for proxy properties, along with general whitespace and formatting cleanups.

Sequence diagram for corrected DSL connection removal signal

sequenceDiagram
    participant DSLController_NM
    participant NetManagerThreadPrivate
    participant QML_UI

    DSLController_NM->>NetManagerThreadPrivate: Q_EMIT itemRemoved(connection->path())
    NetManagerThreadPrivate->>QML_UI: (UI updates to reflect removal)
Loading

Class diagram for updated DSL connection signal handling

classDiagram
    class DSLController_NM {
        +void connectionAppeared(WiredDevice::Ptr, QList<Connection::Ptr>)
        +DSLItem* addPppoeConnection(WiredDevice::Ptr, Connection::Ptr)
        +signal itemAdded(QList<DSLItem*>)
    }
    class NetManagerThreadPrivate {
        +void onDSLRemoved(QList<DSLItem*>)
        +signal itemRemoved(QString)
    }
    DSLController_NM --|> NetManagerThreadPrivate : emits signals to
Loading

File-Level Changes

Change Details Files
Fix DSL connection deletion signal handling
  • Removed creation and addition of NetConnectionItemPrivate in onDSLRemoved
  • Replaced itemAdded emission with itemRemoved(path)
net-view/operation/private/netmanagerthreadprivate.cpp
Unify DSL itemAdded emission logic
  • Removed conditional Q_EMIT itemAdded in connectionAppeared
  • Moved Q_EMIT itemAdded into addPppoeConnection implementation
src/impl/networkmanager/dslcontrollernm.cpp
Add null-safety checks in QML proxy properties
  • Guard proxyEnable with existence of item
  • Default config to empty object when item is null
dcc-network/qml/PageAppProxy.qml
Clean up whitespace and formatting
  • Condensed multi-line DBus connection call into single line
  • Removed extra blank lines and trailing spaces around IPv6 handling code
  • Standardized inline comment spacing
net-view/operation/private/netmanagerthreadprivate.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
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 @caixr23 - I've reviewed your changes - here's some feedback:

  • Verify that onDSLRemoved’s new single-parameter signal provides enough context to clean up the original NetConnectionItemPrivate instance instead of only emitting its path—otherwise stale objects may linger.
  • Ensure that moving the itemAdded emit into addPppoeConnection (and removing the conditional emit in connectionAppeared) doesn’t result in missing or duplicated DSL itemAdded signals in edge cases.
  • Consider separating the whitespace-only reformatting from the functional fixes into its own commit to make the actual logic changes easier to review.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Verify that onDSLRemoved’s new single-parameter signal provides enough context to clean up the original NetConnectionItemPrivate instance instead of only emitting its path—otherwise stale objects may linger.
- Ensure that moving the itemAdded emit into addPppoeConnection (and removing the conditional emit in connectionAppeared) doesn’t result in missing or duplicated DSL itemAdded signals in edge cases.
- Consider separating the whitespace-only reformatting from the functional fixes into its own commit to make the actual logic changes easier to review.

## Individual Comments

### Comment 1
<location> `src/impl/networkmanager/dslcontrollernm.cpp:189` </location>
<code_context>
         return item1->connection()->id() < item2->connection()->id();
     });
-
+    Q_EMIT itemAdded({item});
     return item;
 }
</code_context>

<issue_to_address>
Emitting 'itemAdded' unconditionally may emit null items.

Previously, 'itemAdded' was only emitted for non-null DSLItems. Now, emitting unconditionally could add null or invalid items. Please restore the null check or ensure 'item' is always valid before emitting.
</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.

return item1->connection()->id() < item2->connection()->id();
});

Q_EMIT itemAdded({item});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): Emitting 'itemAdded' unconditionally may emit null items.

Previously, 'itemAdded' was only emitted for non-null DSLItems. Now, emitting unconditionally could add null or invalid items. Please restore the null check or ensure 'item' is always valid before emitting.

DSL connection deletion signal processing error

pms: BUG-308553
@deepin-ci-robot
Copy link
Copy Markdown

deepin pr auto review

代码审查意见:

  1. PageAppProxy.qml文件中,修改了proxyEnable属性的赋值逻辑,增加了对item是否为null的检查。这是一个好的实践,可以避免潜在的空指针异常。

  2. proxyEnable属性中,使用了逻辑与运算符&&来检查item是否为null,这是一个正确的做法。

  3. config属性中,使用了三元运算符? :来处理itemnull的情况,如果itemnull,则config被赋值为空对象{}。这是一个合理的处理方式,可以避免潜在的空指针异常。

  4. netmanagerthreadprivate.cpp文件中,对QDBusConnection::systemBus().connect的调用进行了简化,去掉了多余的空格。这是一个小的代码风格改进,不影响功能。

  5. doGetConnectInfodoSetConnectInfo函数中,处理IPv6 DNS设置的部分代码被重复了。建议将这部分代码提取到一个单独的函数中,以减少代码重复和提高代码的可维护性。

  6. onDSLRemoved函数中,移除了对NetConnectionItemPrivate的创建和更新逻辑,直接通过Q_EMIT itemRemoved发送信号。这是一个好的实践,可以简化代码并提高性能。

  7. dslcontrollernm.cpp文件中,addPppoeConnection函数中,将m_dslItems << item的调用移到了函数的最后,并在函数末尾发送了itemAdded信号。这是一个好的实践,可以确保item被正确地添加到m_dslItems列表中,并且只有在item被成功创建后才会发送itemAdded信号。

  8. dslcontrollernm.cpp文件中,addPppoeConnection函数中,移除了对DSLItem的指针检查,直接将item添加到m_dslItems列表中。这是一个合理的做法,因为DSLItem的创建逻辑已经确保了item不为null

总体来说,代码的修改是合理的,没有发现明显的语法或逻辑错误。但是,建议进行进一步的代码重构,以减少代码重复和提高代码的可维护性。

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: caixr23, robertkill

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

@caixr23 caixr23 merged commit fb52a7c into linuxdeepin:master Jul 7, 2025
15 of 17 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