Skip to content

fix: Gradia-like capture causes treeland crashed#827

Open
LFRon wants to merge 1 commit intolinuxdeepin:masterfrom
LFRon:gradia-fix
Open

fix: Gradia-like capture causes treeland crashed#827
LFRon wants to merge 1 commit intolinuxdeepin:masterfrom
LFRon:gradia-fix

Conversation

@LFRon
Copy link
Copy Markdown
Contributor

@LFRon LFRon commented Apr 13, 2026

When using Gradia (or any screenshot tool via xdg-desktop-portal) to capture, there is no mask surface. m_canvas is only set in componentComplete() when captureManager()->maskShellSurface() and captureManager()->maskSurfaceWrapper() both exist. Without a mask, m_canvas remains nullptr. When the capture finishSelect signal fires, doneSelection() unconditionally dereferences m_canvas->surfaceItem(), causing a null pointer crash (this=0x0).

Fix: Added a null guard before accessing m_canvas->surfaceItem():

if (m_canvas && m_canvas->surfaceItem())
    m_canvas->surfaceItem()->setSubsurfacesVisible(false);

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.

Sorry @LFRon, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot
Copy link
Copy Markdown

Hi @LFRon. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@LFRon
Copy link
Copy Markdown
Contributor Author

LFRon commented Apr 13, 2026

拿Claude-Opus 4.6的修复效果:

gradia-screenshot

PS: Gradia是通过Flatpak安装的

@zccrs
Copy link
Copy Markdown
Member

zccrs commented Apr 13, 2026

https://github.com/linuxdeepin/treeland/actions/runs/24324090261/job/71015816742?pr=827

看看这个ci的报错,应该是需要更新copyright的时间

…t to 2026

When using Gradia (or any screenshot tool via xdg-desktop-portal) to capture, there is no mask surface. `m_canvas` is only set in `componentComplete()` when `captureManager()->maskShellSurface()` and `captureManager()->maskSurfaceWrapper()` both exist. Without a mask, `m_canvas` remains `nullptr`. When the capture `finishSelect` signal fires, `doneSelection()` unconditionally dereferences `m_canvas->surfaceItem()`, causing a null pointer crash (`this=0x0`).

__Fix__: Added a null guard before accessing `m_canvas->surfaceItem()`:

```cpp
if (m_canvas && m_canvas->surfaceItem())
    m_canvas->surfaceItem()->setSubsurfacesVisible(false);
```
@LFRon
Copy link
Copy Markdown
Contributor Author

LFRon commented Apr 15, 2026

https://github.com/linuxdeepin/treeland/actions/runs/24324090261/job/71015816742?pr=827

看看这个ci的报错,应该是需要更新copyright的时间

大佬,我现在改成这样正确嘛(

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: LFRon, wineee

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

@wineee wineee requested a review from zccrs April 15, 2026 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants