Skip to content

fix: fix null pointer and improve DNS/IP configuration#542

Merged
caixr23 merged 1 commit intomasterfrom
coredump
Apr 8, 2026
Merged

fix: fix null pointer and improve DNS/IP configuration#542
caixr23 merged 1 commit intomasterfrom
coredump

Conversation

@caixr23
Copy link
Copy Markdown
Contributor

@caixr23 caixr23 commented Apr 8, 2026

Fixed a null pointer access issue in PageSystemProxy.qml by adding a null check before accessing the visibleToApp property. This prevents potential crashes when the ignoreHosts object is not available.

Refactored DNS, IPv4, and IPv6 configuration sections to use DccRepeater for dynamic item management instead of manual component creation and destruction. This simplifies the code structure and eliminates the need for separate arrays to track created items. Added helper functions addAddressData() and removeAddressData() to centralize data manipulation logic.

In the IPv6 validation logic, added null checks for gateway values to prevent errors when gateway fields are empty. This ensures proper validation of IPv6 configurations.

Log: Fixed system proxy page visibility issue and improved DNS/IP configuration management

Influence:

  1. Test system proxy settings to ensure the "Ignore hosts" option appears correctly
  2. Verify DNS configuration by adding and removing DNS servers
  3. Test IPv4 configuration by adding multiple IP addresses
  4. Test IPv6 configuration with empty and populated gateway fields
  5. Validate all network configuration changes are properly saved
  6. Check that UI updates correctly when modifying network settings

fix: 修复空指针问题并改进DNS/IP配置

修复了PageSystemProxy.qml中的空指针访问问题,在访问visibleToApp属性前添 加了空值检查,防止ignoreHosts对象不可用时导致程序崩溃。

重构了DNS、IPv4和IPv6配置部分,使用DccRepeater进行动态项管理,替代了手动
创建和销毁组件的方式。这简化了代码结构,并消除了单独跟踪已创建项的需要。
添加了addAddressData()和removeAddressData()辅助函数来集中数据操作逻辑。

在IPv6验证逻辑中,为网关值添加了空值检查,防止网关字段为空时出现错误。这
确保了IPv6配置的正确验证。

Log: 修复系统代理页面显示问题并改进DNS/IP配置管理

Influence:

  1. 测试系统代理设置,确保"忽略主机"选项正确显示
  2. 验证DNS配置,测试添加和删除DNS服务器
  3. 测试IPv4配置,添加多个IP地址
  4. 测试IPv6配置,包括空和已填充的网关字段
  5. 验证所有网络配置更改是否正确保存
  6. 检查修改网络设置时UI是否正确更新

Summary by Sourcery

Refine network configuration UI and stability by refactoring dynamic DNS/IP address handling and hardening proxy/connectivity logic.

Bug Fixes:

  • Prevent a potential null pointer access in the system proxy page when the ignore-hosts object is unavailable.
  • Avoid crashes in IPv6 validation by guarding gateway checks when gateway values are null or missing.
  • Preserve previous connectivity state when handling NetworkManager connectivity changes by initializing the connectivity variable with the stored value.

Enhancements:

  • Refactor DNS configuration to use DccRepeater with centralized add/remove helpers for DNS entries instead of manual item lifecycle management.
  • Refactor IPv4 address configuration to use DccRepeater and shared add/remove helpers for address rows.
  • Refactor IPv6 address configuration to use DccRepeater and shared add/remove helpers for address rows, simplifying dynamic item management.

Fixed a null pointer access issue in PageSystemProxy.qml by adding a
null check before accessing the visibleToApp property. This prevents
potential crashes when the ignoreHosts object is not available.

Refactored DNS, IPv4, and IPv6 configuration sections to use DccRepeater
for dynamic item management instead of manual component creation and
destruction. This simplifies the code structure and eliminates the
need for separate arrays to track created items. Added helper functions
addAddressData() and removeAddressData() to centralize data manipulation
logic.

In the IPv6 validation logic, added null checks for gateway values
to prevent errors when gateway fields are empty. This ensures proper
validation of IPv6 configurations.

Log: Fixed system proxy page visibility issue and improved DNS/IP
configuration management

Influence:
1. Test system proxy settings to ensure the "Ignore hosts" option
appears correctly
2. Verify DNS configuration by adding and removing DNS servers
3. Test IPv4 configuration by adding multiple IP addresses
4. Test IPv6 configuration with empty and populated gateway fields
5. Validate all network configuration changes are properly saved
6. Check that UI updates correctly when modifying network settings

fix: 修复空指针问题并改进DNS/IP配置

修复了PageSystemProxy.qml中的空指针访问问题,在访问visibleToApp属性前添
加了空值检查,防止ignoreHosts对象不可用时导致程序崩溃。

重构了DNS、IPv4和IPv6配置部分,使用DccRepeater进行动态项管理,替代了手动
创建和销毁组件的方式。这简化了代码结构,并消除了单独跟踪已创建项的需要。
添加了addAddressData()和removeAddressData()辅助函数来集中数据操作逻辑。

在IPv6验证逻辑中,为网关值添加了空值检查,防止网关字段为空时出现错误。这
确保了IPv6配置的正确验证。

Log: 修复系统代理页面显示问题并改进DNS/IP配置管理

Influence:
1. 测试系统代理设置,确保"忽略主机"选项正确显示
2. 验证DNS配置,测试添加和删除DNS服务器
3. 测试IPv4配置,添加多个IP地址
4. 测试IPv6配置,包括空和已填充的网关字段
5. 验证所有网络配置更改是否正确保存
6. 检查修改网络设置时UI是否正确更新
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Apr 8, 2026

Reviewer's Guide

This PR fixes a null-pointer visibility issue on the system proxy page, refactors DNS/IPv4/IPv6 address editors to use DccRepeater with centralized add/remove helpers, and hardens IPv6 gateway validation and connectivity handling logic.

Sequence diagram for DNS entry add/remove using DccRepeater

sequenceDiagram
    actor User
    participant SectionDNS
    participant DnsItem as DnsEditorItem
    participant Config as DnsConfigArray

    User->>DnsItem: Click add_icon
    DnsItem->>SectionDNS: addAddressData("")
    SectionDNS->>Config: push("")
    SectionDNS->>SectionDNS: configChanged()
    SectionDNS->>SectionDNS: editClicked()

    Note over SectionDNS,Config: DccRepeater automatically reflects new config length

    User->>DnsItem: Click delete_icon
    DnsItem->>SectionDNS: removeAddressData(index)
    SectionDNS->>Config: splice(index,1)
    SectionDNS->>SectionDNS: configChanged()
    SectionDNS->>SectionDNS: editClicked()
Loading

File-Level Changes

Change Details Files
Refactor DNS editor to use DccRepeater and centralized config mutation helpers instead of manual component lifecycle management.
  • Introduce addAddressData() and removeAddressData() helpers to push/splice DNS entries, emit configChanged(), and trigger editClicked().
  • Replace a Component-based dnsItem factory plus dnsItems tracking with a DccRepeater bound to root.config.
  • Update add/delete icon handlers to call the new helpers rather than mutating config directly.
  • Remove now-unnecessary addIpItem()/removeIpItem() functions and onConfigChanged synchronization logic.
dcc-network/qml/SectionDNS.qml
Refactor IPv6 address list handling to use DccRepeater and shared addressData helpers, and harden gateway validation.
  • Guard gateway access in validation with null checks before reading .length or applying the IPv6 regexp.
  • Add addAddressData() and removeAddressData() helpers that mutate addressData, emit addressDataChanged(), and trigger editClicked().
  • Replace the Component/ipItems pattern with a DccRepeater over root.addressData and delegate-based DccObject items.
  • Route add/remove IP UI actions through the helper functions and delete legacy add/remove item functions and onAddressDataChanged sync code.
dcc-network/qml/SectionIPv6.qml
Refactor IPv4 address list handling to use DccRepeater and shared addressData helpers.
  • Add addAddressData() and removeAddressData() helpers for IPv4 addressData mutation with change notification and editClicked().
  • Replace Component/ipItems construction with a DccRepeater bound to root.addressData and delegate DccObject items.
  • Update add/remove IP button handlers to call the helpers and remove the onAddressDataChanged-driven item creation/destruction logic.
dcc-network/qml/SectionIPv4.qml
Fix system proxy "Ignore hosts" visibility null-pointer and stabilize connectivity state mapping.
  • Guard access to ignoreHosts.visibleToApp with a null check to avoid potential crashes when ignoreHosts is absent.
  • Initialize the mapped connectivity enum ctity from the member m_connectivity before the switch to ensure a well-defined value for unhandled states.
dcc-network/qml/PageSystemProxy.qml
src/impl/networkmanager/networkmanagerprocesser.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 - I've left some high level feedback:

  • In the IPv4/IPv6/DNS sections, addAddressData/removeAddressData now encapsulate list mutations and notifications; consider removing any remaining ipItems/similar tracking state or helper functions that are no longer used to avoid confusion about the source of truth.
  • In onConnectivityChanged, ctity is initialized from m_connectivity but then immediately reassigned in the switch; if the intent is to preserve the previous value for unhandled enum cases, it would be clearer to add an explicit default branch that documents this behavior rather than relying on the initial value.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the IPv4/IPv6/DNS sections, `addAddressData`/`removeAddressData` now encapsulate list mutations and notifications; consider removing any remaining `ipItems`/similar tracking state or helper functions that are no longer used to avoid confusion about the source of truth.
- In `onConnectivityChanged`, `ctity` is initialized from `m_connectivity` but then immediately reassigned in the switch; if the intent is to preserve the previous value for unhandled enum cases, it would be clearer to add an explicit `default` branch that documents this behavior rather than relying on the initial value.

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

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, 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

@caixr23 caixr23 merged commit d1ef96d into master Apr 8, 2026
28 of 31 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