Skip to content

fix: Fix interface not displaying in real-time after inserting wired …#517

Open
ut003640 wants to merge 1 commit intolinuxdeepin:masterfrom
ut003640:tmp1
Open

fix: Fix interface not displaying in real-time after inserting wired …#517
ut003640 wants to merge 1 commit intolinuxdeepin:masterfrom
ut003640:tmp1

Conversation

@ut003640
Copy link
Contributor

@ut003640 ut003640 commented Mar 5, 2026

…network card

After inserting a wired network card, the managed and interfaceFlag properties initially have values of false and None. When using the NetworkManager::findNetworkInterface method to search, the newly created Device object has not yet assigned values to the interfaceFlag and managed properties, so the system considers the device to be in an unmanaged state and does not display it to the user. The fix involves waiting for the newly created device object's property assignment to complete before proceeding.

Log: Fix interface not responding after inserting network card
PMS: BUG-351709

fix: 修复插入有线网卡后界面没有实时显示

在插入有线网卡后,managed和interfaceFlag属性初始值为false和None,在通过NetworkManager::findNetworkInterface方法来查找时,新生成的Device对象还没有将interfaceFlag和managed属性赋值,所以系统认为该设备是未管理状态,不会显示给用户;修改为等新创建的设备对象属性赋值完成后就可以解决问题

Log: 修复插入网卡后界面无反应

Summary by Sourcery

Bug Fixes:

  • Prevent newly inserted wired network interfaces from being treated as unmanaged and hidden by deferring device creation/removal until after interface flag and managed property updates are delivered.

…network card

After inserting a wired network card, the managed and interfaceFlag properties initially have values of false and None. When using the NetworkManager::findNetworkInterface method to search, the newly created Device object has not yet assigned values to the interfaceFlag and managed properties, so the system considers the device to be in an unmanaged state and does not display it to the user. The fix involves waiting for the newly created device object's property assignment to complete before proceeding.

Log: Fix interface not responding after inserting network card
PMS: BUG-351709

fix: 修复插入有线网卡后界面没有实时显示

在插入有线网卡后,managed和interfaceFlag属性初始值为false和None,在通过NetworkManager::findNetworkInterface方法来查找时,新生成的Device对象还没有将interfaceFlag和managed属性赋值,所以系统认为该设备是未管理状态,不会显示给用户;修改为等新创建的设备对象属性赋值完成后就可以解决问题

Log: 修复插入网卡后界面无反应
@sourcery-ai
Copy link

sourcery-ai bot commented Mar 5, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts signal connections for new network devices so that interface/managed state updates are processed asynchronously via queued connections, ensuring the UI reflects newly inserted wired NICs once their properties are fully initialized.

Sequence diagram for queued updates when a wired network device is added

sequenceDiagram
    actor User
    participant Kernel
    participant NetworkManager
    participant NetworkManagerProcesser
    participant Device
    participant UI

    User ->> Kernel: Insert wired NIC
    Kernel ->> NetworkManager: Notify new device
    NetworkManager ->> NetworkManagerProcesser: onDeviceAdded(uni)
    activate NetworkManagerProcesser
    NetworkManagerProcesser ->> Device: connect(interfaceFlagsChanged, createOrRemoveDevice, QueuedConnection)
    NetworkManagerProcesser ->> Device: connect(managedChanged, createOrRemoveDevice, QueuedConnection)
    deactivate NetworkManagerProcesser

    Note over Device,NetworkManager: Device properties are initially default

    Device ->> Device: Initialize managed and interfaceFlags
    Device -->> NetworkManagerProcesser: interfaceFlagsChanged (queued)
    Device -->> NetworkManagerProcesser: managedChanged (queued)

    activate NetworkManagerProcesser
    NetworkManagerProcesser ->> NetworkManagerProcesser: createOrRemoveDevice(uni)
    NetworkManagerProcesser ->> Device: read managed(), interfaceFlags(), type()
    NetworkManagerProcesser ->> UI: Create or update visible network interface
    deactivate NetworkManagerProcesser

    UI ->> User: Show new wired NIC as managed and up
Loading

Class diagram for updated NetworkManagerProcesser device handling

classDiagram
    class NetworkManagerProcesser {
        +onDeviceAdded(uni : QString) void
        +createOrRemoveDevice(uni : QString) void
    }

    class Device {
        +interfaceFlagsChanged()
        +managedChanged()
        +managed() bool
        +interfaceFlags() int
        +type() DeviceType
    }

    class NetworkManager {
    }

    NetworkManagerProcesser ..> Device : uses
    NetworkManager o-- Device : creates

    class QtConnection {
        +connectionType : QtConnectionType
        +QueuedConnection
    }

    NetworkManagerProcesser ..> QtConnection : uses QueuedConnection for signals
Loading

File-Level Changes

Change Details Files
Process device interface flag and managed property changes via queued signal-slot connections so the device is (re-)created only after its properties are fully initialized.
  • Update the interfaceFlagsChanged connection to use Qt::QueuedConnection so createOrRemoveDevice runs asynchronously after the event loop processes pending updates.
  • Update the managedChanged connection to use Qt::QueuedConnection for the same reason, avoiding checks against partially initialized Device objects when a NIC is inserted.
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

@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:

  • The lambdas for interfaceFlagsChanged and managedChanged capture this but use currentDevice.get() as the context object; with Qt::QueuedConnection this can invoke the lambda after NetworkManagerProcesser is destroyed, so consider using this as the context object (or a QPointer/explicit lifetime check) to avoid potential use-after-free.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The lambdas for `interfaceFlagsChanged` and `managedChanged` capture `this` but use `currentDevice.get()` as the context object; with `Qt::QueuedConnection` this can invoke the lambda after `NetworkManagerProcesser` is destroyed, so consider using `this` as the context object (or a `QPointer`/explicit lifetime check) to avoid potential use-after-free.

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.

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.

1 participant