refactor: restructure treeland codebase for better maintainability#542
refactor: restructure treeland codebase for better maintainability#542zzxyb wants to merge 1 commit intolinuxdeepin:masterfrom
Conversation
simplify the processing flow of wl_client_destroy. Fixes: linuxdeepin#449 Log:
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: zzxyb The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideRefactor client destruction flow by embedding the wl_listener in WClientPrivate, removing the separate WlClientDestroyListener class, using wl_client_set_user_data for client lookup, and consolidating cleanup in a single callback. Sequence diagram for updated client destruction processsequenceDiagram
participant wl_client
participant WClient
participant WClientPrivate
participant WSocket
wl_client->>WClientPrivate: Trigger destroyListenerCallback
WClientPrivate->>WClient: WClient::get(handle) via wl_client_get_user_data
WClient->>WSocket: removeClient(handle)
WClientPrivate->>WClientPrivate: wl_list_remove(&destroyListener.link)
WClientPrivate-->>WClient: Cleanup complete
Class diagram for refactored WClient destruction flowclassDiagram
class WClientPrivate {
+wl_listener destroyListener
+wl_client* handle
+WSocket* socket
+QSharedPointer<Credentials> credentials
+int pidFD
+~WClientPrivate()
+static void destroyListenerCallback(wl_listener*, void*)
}
class WClient {
+WClient(wl_client*, WSocket*)
+WSocket* socket() const
+static WClient* get(const wl_client*)
+void freeze()
}
WClientPrivate <|-- WClient
WClient "1" -- "1" WSocket
WClientPrivate "1" -- "1" wl_listener
WClientPrivate ..> "1" Credentials : uses
%% Removed class
class WlClientDestroyListener {
-wl_listener destroy
-QPointer<WClient> client
+~WlClientDestroyListener()
+static WlClientDestroyListener* get(const wl_client*)
+static void handle_destroy(wl_listener*, void*)
}
%% Indicate removal
WlClientDestroyListener : REMOVED
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `waylib/src/server/kernel/wsocket.cpp:210` </location>
<code_context>
- Q_ASSERT(listener);
- delete listener;
- }
+ if (destroyListener.link.next && destroyListener.link.prev)
+ wl_list_remove(&destroyListener.link);
+ }
</code_context>
<issue_to_address>
Checking both next and prev pointers before wl_list_remove may not be sufficient for all list states.
Relying on non-null next and prev pointers may not reliably indicate list membership. Use a more reliable approach to check if the node is part of a list before removing it.
Suggested implementation:
```cpp
// Use a reliable flag to track list membership
static bool destroyListenerInList = true;
if (destroyListenerInList) {
wl_list_remove(&destroyListener.link);
destroyListenerInList = false;
}
```
If `destroyListenerInList` is not already managed elsewhere, you should:
1. Set `destroyListenerInList = true` when the listener is added to the list.
2. Set `destroyListenerInList = false` immediately after removal.
3. If multiple listeners are involved, consider making this a member variable of the listener object rather than a static variable.
Alternatively, if your codebase already has a utility or convention for tracking list membership, use that instead.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
标记错了issue的链接? |
| auto listener = new WlClientDestroyListener(qq); | ||
| wl_client_add_destroy_listener(handle, &listener->destroy); | ||
| destroyListener.notify = destroyListenerCallback; | ||
| wl_client_add_destroy_listener(handle, &destroyListener); |
There was a problem hiding this comment.
从这个改动看,并没有解决时序问题呀
| Q_ASSERT(ok); | ||
| } | ||
|
|
||
| delete self; |
|
TAG Bot New tag: 0.7.1 |
|
TAG Bot New tag: 0.7.2 |
|
TAG Bot New tag: 0.7.3 |
|
TAG Bot New tag: 0.7.6 |
|
TAG Bot New tag: 0.7.7 |
|
TAG Bot New tag: 0.7.8 |
|
TAG Bot New tag: 0.8.0 |
|
TAG Bot New tag: 0.8.1 |
|
TAG Bot New tag: 0.8.2 |
|
TAG Bot New tag: 0.8.3 |
simplify the processing flow of wl_client_destroy.
Fixes: #449
Log:
Summary by Sourcery
Refactor client destruction flow by removing the standalone WlClientDestroyListener class and embedding the destroy listener directly within WClientPrivate, using wl_client set/get user data and a static callback for cleanup.
Enhancements: