Skip to content

fix(taskbar): avoid stale pointer in drag payload - #5334

Open
sanyarnd wants to merge 1 commit into
Alexays:masterfrom
sanyarnd:fix/taskbar-dnd-stale-pointer
Open

sanyarnd wants to merge 1 commit into
Alexays:masterfrom
sanyarnd:fix/taskbar-dnd-stale-pointer

Conversation

@sanyarnd

@sanyarnd sanyarnd commented Sep 17, 2026

Copy link
Copy Markdown

What does this PR do?

The taskbar currently puts a raw Gtk::Button pointer into the drag payload. If the source task disappears while a drag is in progress, the drop handler can dereference a button that has already been destroyed.

This changes the payload to carry the task's Wayland ID instead. The drop handler resolves that ID against the current task list and ignores malformed payloads or tasks that are no longer present. Normal reordering and self-drops keep their existing behavior.

I also added tests for payload validation and for live, self, and stale task lookups.

Related issues

None.

Checklist

  • Code is formatted with clang-format
  • Builds locally (ninja -C build)
  • Man page updated for any new/changed user-facing option (man/) — no user-facing options changed
  • Tested against the affected module(s)

@greptile-apps

greptile-apps Bot commented Sep 17, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge; stale or malformed drag payloads are rejected before any task widget is accessed.

Summary

This PR replaces the taskbar drag payload’s raw widget pointer with a task ID and resolves drops against the current live task list.

  • Validates that drag payloads contain exactly one 32-bit task ID.
  • Safely ignores malformed payloads and tasks removed during a drag.
  • Preserves live-task reordering and self-drop behavior.
  • Adds unit coverage for payload validation and live, self, and stale lookups.
Diagram
sequenceDiagram
  participant Source as Source Task
  participant GTK as GTK Drag Context
  participant Destination as Destination Task
  participant Taskbar as Current Task List
  Source->>GTK: Store 32-bit task ID
  Note over Source: Source may disappear
  GTK->>Destination: Deliver drag payload
  Destination->>Destination: Validate payload length
  Destination->>Taskbar: Resolve source and destination IDs
  alt Both tasks are live and visible
    Taskbar->>Taskbar: Reorder source button
  else Malformed or stale payload
    Taskbar-->>Destination: Ignore drop safely
  end
Loading

Reviews (1) · Last reviewed commit: "fix(taskbar): avoid stale pointer in dra..."

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.

1 participant