Skip to content

Fix crash and wrong project removed when removing several projects - #65

Merged
Ravbug merged 1 commit into
Ravbug:masterfrom
ManeFunction:bugfix/project-remove-crash
Nov 3, 2026
Merged

Ravbug merged 1 commit into
Ravbug:masterfrom
ManeFunction:bugfix/project-remove-crash

Conversation

@ManeFunction

Copy link
Copy Markdown
Contributor

Summary

Removing more than one project in the same session could crash the app or remove the wrong project.

Cause

Each row in the projects list stores its project's index in projects. OnRemoveProject erased the entry, which moves every later project down one slot, but it didn't update the indices stored in the other rows. After the first removal, those rows pointed one slot too far:

  • If a row's stored index was now past the end, the next removal called projects.erase() out of range. That's undefined behaviour and crashed with EXC_BAD_ACCESS in OnRemoveProject (seen in a macOS crash report).
  • Otherwise it quietly removed the wrong project and saved that change to disk.
  • Open, Reveal and Open With could also act on the wrong project after a removal.

The bug came in when sorting was added (#38), which started storing the index in each row.

Fix

After the project is removed, subtract 1 from every remaining row's stored index that is above the removed one.

Testing

  1. Add three or more projects.
  2. Remove the first project in the list, then the last one.
  3. Check that the app doesn't crash, the right projects are removed, and opening the remaining projects opens the right ones.

@Ravbug
Ravbug merged commit 386ce30 into Ravbug:master Nov 3, 2026
4 checks passed
@ManeFunction
ManeFunction deleted the bugfix/project-remove-crash branch November 3, 2026 09:20
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