fix: Fix interface not displaying in real-time after inserting wired …#517
Open
ut003640 wants to merge 1 commit intolinuxdeepin:masterfrom
Open
fix: Fix interface not displaying in real-time after inserting wired …#517ut003640 wants to merge 1 commit intolinuxdeepin:masterfrom
ut003640 wants to merge 1 commit intolinuxdeepin:masterfrom
Conversation
…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: 修复插入网卡后界面无反应
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts 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 addedsequenceDiagram
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
Class diagram for updated NetworkManagerProcesser device handlingclassDiagram
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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The lambdas for
interfaceFlagsChangedandmanagedChangedcapturethisbut usecurrentDevice.get()as the context object; withQt::QueuedConnectionthis can invoke the lambda afterNetworkManagerProcesseris destroyed, so consider usingthisas the context object (or aQPointer/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.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…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: