fix: use safeConnect for aboutToBeInvalidated#605
Merged
zccrs merged 1 commit intolinuxdeepin:masterfrom Oct 24, 2025
Merged
Conversation
The WSurface's `aboutToBeInvalidated` signal connection was incorrectly using `QObject::connect` instead of `safeConnect`. This could lead to issues when the WSurface object is modified using `setSurface`, as the previous object's `aboutToBeInvalidated` signal would not be disconnected, potentially causing a crash or unexpected behavior. This change replaces the regular `QObject::connect` with `safeConnect` to ensure proper disconnection and avoid potential issues when the surface is replaced. Influence: 1. Test replacing a WSurface multiple times with different WSurface objects using `setSurface`. 2. Verify that the `releaseResources` function is only called when the current WSurface is truly invalidated and not prematurely. 3. Observe application behavior under heavy WSurface replacement scenarios to ensure stability and prevent crashes. fix: 使用 safeConnect 连接 aboutToBeInvalidated 信号 WSurface 的 `aboutToBeInvalidated` 信号连接错误地使用了 `QObject::connect` 而不是 `safeConnect`。当使用 `setSurface` 修改 WSurface 对象时,这可能导致问题,因为前一个对象的 `aboutToBeInvalidated` 信号不会断开,可能导致崩溃或意外行为。此更改将常规的 `QObject::connect` 替换为 `safeConnect`,以确保正确断开连接并避免在表面替换时出现潜在问题。 Influence: 1. 使用 `setSurface` 多次用不同的 WSurface 对象替换 WSurface。 2. 验证 `releaseResources` 函数仅在当前 WSurface 真正失效时才被调用,而 不是过早调用。 3. 观察在大量 WSurface 替换场景下的应用程序行为,以确保稳定并防止崩溃。
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis patch updates the WSurfaceItem initialization to use the safeConnect helper for the aboutToBeInvalidated signal instead of QObject::connect, ensuring that previous signal connections are properly disconnected when the surface is replaced and avoiding potential crashes. Sequence diagram for safe signal connection during WSurface replacementsequenceDiagram
participant WSurfaceItem
participant WSurface
participant "releaseResources()"
WSurfaceItem->>WSurface: setSurface(newSurface)
WSurface->>WSurfaceItem: aboutToBeInvalidated
WSurfaceItem->>"releaseResources()": Call only for current WSurface
Note over WSurfaceItem,WSurface: safeConnect ensures old signals are disconnected
Class diagram for updated signal connection in WSurfaceItemPrivateclassDiagram
class WSurface {
+aboutToBeInvalidated
+hasSubsurfaceChanged
+safeConnect()
}
class WSurfaceItem {
+releaseResources()
+onSurfaceCommit()
}
class WSurfaceItemPrivate {
+initForSurface()
}
WSurfaceItemPrivate -- WSurfaceItem : q
WSurfaceItemPrivate -- WSurface : surface
WSurfaceItemPrivate : initForSurface() uses safeConnect for aboutToBeInvalidated
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
wineee
approved these changes
Oct 24, 2025
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: wineee, zccrs 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 |
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.
The WSurface's
aboutToBeInvalidatedsignal connection was incorrectly usingQObject::connectinstead ofsafeConnect. This could lead to issues when the WSurface object is modified usingsetSurface, as the previous object'saboutToBeInvalidatedsignal would not be disconnected, potentially causing a crash or unexpected behavior. This change replaces the regularQObject::connectwithsafeConnectto ensure proper disconnection and avoid potential issues when the surface is replaced.Influence:
setSurface.releaseResourcesfunction is only called when the current WSurface is truly invalidated and not prematurely.fix: 使用 safeConnect 连接 aboutToBeInvalidated 信号
WSurface 的
aboutToBeInvalidated信号连接错误地使用了QObject::connect而不是safeConnect。当使用setSurface修改 WSurface 对象时,这可能导致问题,因为前一个对象的aboutToBeInvalidated信号不会断开,可能导致崩溃或意外行为。此更改将常规的QObject::connect替换为
safeConnect,以确保正确断开连接并避免在表面替换时出现潜在问题。Influence:
setSurface多次用不同的 WSurface 对象替换 WSurface。releaseResources函数仅在当前 WSurface 真正失效时才被调用,而 不是过早调用。Summary by Sourcery
Bug Fixes: