Skip to content

fix(taskswitch): fix window visibility issues and race condition in T…#1026

Open
zorowk wants to merge 1 commit into
linuxdeepin:masterfrom
zorowk:fix_366737
Open

fix(taskswitch): fix window visibility issues and race condition in T…#1026
zorowk wants to merge 1 commit into
linuxdeepin:masterfrom
zorowk:fix_366737

Conversation

@zorowk

@zorowk zorowk commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Log:

  1. Ensure workspace opacity is restored when TaskSwitcher exits, even with zero windows, to prevent permanent window transparency.
  2. Fix race condition in prejudgment() by removing premature 'switchOn=false' which caused object destruction before cleanup.
  3. Fix syntax error in refHeight property of TaskWindowPreview.

PMS: BUG-366737
Influence: Fixes workspace window display anomalies and task switching reliability.

Summary by Sourcery

Fix TaskSwitcher window visibility handling and prevent race conditions during task switching cleanup.

Bug Fixes:

  • Restore workspace window opacity when exiting the task switcher, including when no windows are present.
  • Prevent a prejudgment race condition that could destroy objects before task switching cleanup completes.
  • Correct the refHeight property expression in TaskWindowPreview to avoid a syntax-related evaluation issue.
  • Guard task switch animations and visibility logic against empty switch view states to avoid erroneous behavior.

…askSwitcher

Log:
1. Ensure workspace opacity is restored when TaskSwitcher exits, even
   with zero windows, to prevent permanent window transparency.
2. Fix race condition in prejudgment() by removing premature 'switchOn=false'
   which caused object destruction before cleanup.
3. Fix syntax error in refHeight property of TaskWindowPreview.

PMS: BUG-366737
Influence: Fixes workspace window display anomalies and task switching reliability.
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: zorowk

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

@sourcery-ai

sourcery-ai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR fixes TaskSwitcher window visibility glitches, a race condition during task switch completion, and a small syntax issue in TaskWindowPreview, primarily by tightening conditions around visibility/animation, deferring cleanup until animations are done, and explicitly restoring surface opacity/positions.

Sequence diagram for TaskSwitcher prejudgment and visibility/animation handling

sequenceDiagram
    actor User
    participant TaskSwitcher_root as TaskSwitcher_root
    participant previewWindows as previewWindows
    participant switchView as switchView

    User ->> TaskSwitcher_root: prejudgment()
    TaskSwitcher_root ->> previewWindows: read finishedAnimations
    TaskSwitcher_root ->> previewWindows: read totalAnimations
    alt [previewWindows.finishedAnimations !== previewWindows.totalAnimations]
        TaskSwitcher_root ->> TaskSwitcher_root: prejudgment()
    else [previewWindows.finishedAnimations === previewWindows.totalAnimations]
        TaskSwitcher_root ->> TaskSwitcher_root: showTask(false)
        TaskSwitcher_root ->> switchView: read count
        alt [root.enableAnimation && switchView.count > 0 && switchView.count <= 18]
            TaskSwitcher_root ->> previewWindows: set reverse = false
            TaskSwitcher_root ->> previewWindows: set model = root.model
        else [!root.enableAnimation || switchView.count === 0 || switchView.count > 18]
            TaskSwitcher_root ->> previewWindows: set model = null
        end
    end

    Note over TaskSwitcher_root,previewWindows: root.switchOn is no longer set to false inside prejudgment(),
    Note over TaskSwitcher_root,previewWindows: preventing premature destruction before cleanup
Loading

File-Level Changes

Change Details Files
Ensure window surfaces are correctly reset (position and opacity) when exiting TaskSwitcher, even when there are zero or few windows.
  • In the preview hide path, reorder initialization so surface.y is set before surface.opacity to 0.0, keeping the animation setup consistent.
  • When restoring windows after TaskSwitcher, explicitly set surface.opacity back to 1.0 along with restoring x/y positions.
  • Guard animation setup so it only runs when there is at least one window (switchView.count > 0) and at most 18, avoiding unnecessary or invalid animation in empty states.
  • Prevent showTask(false) from hiding the root when there are zero windows unless the call is for a visible state (visible && switchView.count === 0).
src/core/qml/TaskSwitcher.qml
Fix race condition and control flow around prejudgment() and animation completion.
  • Remove premature 'root.switchOn = false' in prejudgment(), so the TaskSwitcher is not torn down before finish logic and cleanup complete.
  • Ensure prejudgment() is invoked when preview animations haven’t all finished (finishedAnimations !== totalAnimations) by explicitly calling it within that conditional block.
src/core/qml/TaskSwitcher.qml
Fix property expression syntax in TaskWindowPreview to avoid QML parsing issues.
  • Normalize the refHeight property expression by fixing spacing in the multiplication, ensuring it parses correctly and matches intended layout computation.
src/core/qml/TaskWindowPreview.qml

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

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

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:

  • In showTask(visible), changing the early return condition to only trigger when visible && switchView.count === 0 means showTask(false) can now run with switchView.count === 0, which may make switchView.currentItem undefined later in the function; consider guarding uses of currentItem (or restoring an early return) when there are no items.
  • The new call to prejudgment() when finishedAnimations !== totalAnimations changes the previous behavior of simply returning; it might be worth double-checking that prejudgment() is safe to call mid-animation and cannot be invoked twice for the same cycle (e.g., via both animation completion and this early path).
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `showTask(visible)`, changing the early return condition to only trigger when `visible && switchView.count === 0` means `showTask(false)` can now run with `switchView.count === 0`, which may make `switchView.currentItem` undefined later in the function; consider guarding uses of `currentItem` (or restoring an early return) when there are no items.
- The new call to `prejudgment()` when `finishedAnimations !== totalAnimations` changes the previous behavior of simply returning; it might be worth double-checking that `prejudgment()` is safe to call mid-animation and cannot be invoked twice for the same cycle (e.g., via both animation completion and this early path).

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.

2 participants