Skip to content

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

Merged
caixr23 merged 1 commit intolinuxdeepin:coredumpfrom
caixr23:coredump
Apr 7, 2026
Merged

fix: fix null pointer and improve DNS/IP configuration#541
caixr23 merged 1 commit intolinuxdeepin:coredumpfrom
caixr23:coredump

Conversation

@caixr23
Copy link
Copy Markdown
Contributor

@caixr23 caixr23 commented Apr 7, 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 behavior and stability across DNS, IPv4/IPv6, and system proxy pages.

Bug Fixes:

  • Prevent a null pointer access on the system proxy page by guarding access to the Ignore hosts visibility flag.
  • Avoid crashes in IPv6 validation by safely handling empty or missing gateway values.
  • Preserve the previous connectivity state when handling NetworkManager connectivity change events.

Enhancements:

  • Simplify DNS configuration management by driving item creation from the config model via DccRepeater and central add/remove helpers.
  • Refactor IPv4 and IPv6 address configuration to use DccRepeater with shared add/remove helpers, improving data-driven UI updates and consistency.

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 7, 2026

Reviewer's Guide

Refactors DNS, IPv4, and IPv6 QML sections to use DccRepeater and centralized add/remove helpers instead of manual component management, tightens IPv6 gateway validation with null checks, fixes a potential null pointer in the system proxy page visibility binding, and preserves connectivity state initialization in the NetworkManager processor.

Sequence diagram for adding a new DNS server entry with DccRepeater

sequenceDiagram
    actor User
    participant SectionDNS
    participant DccRepeater
    participant DNSDelegate
    participant ConfigArray as config

    User->>DNSDelegate: click add_icon MouseArea
    DNSDelegate->>SectionDNS: addAddressData("")
    SectionDNS->>ConfigArray: push("")
    SectionDNS->>SectionDNS: configChanged()
    SectionDNS->>SectionDNS: editClicked()

    Note over SectionDNS,DccRepeater: DccRepeater observes model root.config

    DccRepeater-->>DNSDelegate: create new delegate for new index
    DNSDelegate->>User: show new empty DNS input field
Loading

Sequence diagram for IPv6 gateway validation with null safety

sequenceDiagram
    participant SectionIPv6
    participant GatewayArray as gateway

    SectionIPv6->>SectionIPv6: validateIpv6()
    loop for each k in gateway
        SectionIPv6->>GatewayArray: read gateway[k]
        alt gateway[k] exists and nonempty
            SectionIPv6->>SectionIPv6: increment gatewayCount
            alt gatewayCount >= 2
                SectionIPv6->>SectionIPv6: set errorKey(k + gateway)
                SectionIPv6->>SectionIPv6: return false
            else gatewayCount < 2
                SectionIPv6->>SectionIPv6: test NetUtils.ipv6RegExp(gateway[k])
                alt invalid format
                    SectionIPv6->>SectionIPv6: set errorKey(k + gateway)
                    SectionIPv6->>SectionIPv6: set errorMsg(Invalid gateway)
                    SectionIPv6->>SectionIPv6: return false
                else valid format
                    SectionIPv6->>SectionIPv6: continue
                end
            end
        else gateway[k] null or empty
            SectionIPv6->>SectionIPv6: skip validation for this k
        end
    end
    SectionIPv6-->>SectionIPv6: return true
Loading

Flow diagram for connectivity change handling preserving previous state

flowchart TD
    A[onConnectivityChanged called with NetworkManager_Connectivity] --> B[Initialize ctity with m_connectivity]
    B --> C{conntity value}
    C -->|Full| D[ctity = dde_network_Connectivity_Full]
    C -->|Portal| E[ctity = dde_network_Connectivity_Portal]
    C -->|Limited| F[ctity = dde_network_Connectivity_Limited]
    C -->|None| G[ctity = dde_network_Connectivity_None]
    C -->|Unknown or other| H[ctity remains as previous m_connectivity]
    D --> I[emit connectivity changed with ctity]
    E --> I
    F --> I
    G --> I
    H --> I
Loading

File-Level Changes

Change Details Files
Refactor DNS configuration UI to use DccRepeater and centralized data mutation helpers.
  • Introduce addAddressData() and removeAddressData() helpers that push/splice config entries, emit configChanged(), and trigger editClicked().
  • Replace manual Component-based dnsItem creation and destruction plus dnsItems tracking array with a DccRepeater bound to root.config.
  • Wire add/remove icon clicks to the new helpers instead of directly mutating config, keeping UI and data updates centralized.
dcc-network/qml/SectionDNS.qml
Refactor IPv6 configuration UI to use DccRepeater and robust data helpers, and harden gateway validation.
  • Add null-safe checks around gateway entries before accessing .length and validating against the IPv6 regexp.
  • Introduce addAddressData() and removeAddressData() helpers for addressData, which mutate the list, emit addressDataChanged(), and call editClicked().
  • Replace the ipComponent/Component-based dynamic object management and ipItems array with a DccRepeater bound to root.addressData and update add/remove buttons to call the new helpers.
dcc-network/qml/SectionIPv6.qml
Refactor IPv4 configuration UI to use DccRepeater with centralized addressData mutation.
  • Add addAddressData() and removeAddressData() helpers for IPv4 addressData that handle list mutation, change notification, and editClicked().
  • Replace manual ipComponent-based object creation and ipItems tracking with a DccRepeater using root.addressData as its model.
  • Update add/remove mouse handlers to call the new helpers instead of directly pushing/splicing addressData and manually firing signals.
dcc-network/qml/SectionIPv4.qml
Prevent null pointer access when showing the "Ignore hosts" option on the system proxy page.
  • Guard the visibility binding for the ignore-hosts label with a null check on ignoreHosts before reading visibleToApp, avoiding crashes when the object is absent.
dcc-network/qml/PageSystemProxy.qml
Ensure connectivity change handling starts from the last known connectivity state instead of an uninitialized value.
  • Initialize local variable ctity with m_connectivity before switching on NetworkManager::Connectivity, preventing use of an uninitialized enum value if no case assigns it.
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 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.

@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 6f3fb61 into linuxdeepin:coredump Apr 7, 2026
17 of 19 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