Skip to content

Fix index tracking in AddTemporaryProfile() if existingProfile != null#110

Merged
RisaDev merged 1 commit into
Aether-Tools:mainfrom
Drovolon:tempprofile-delete-fix
May 17, 2026
Merged

Fix index tracking in AddTemporaryProfile() if existingProfile != null#110
RisaDev merged 1 commit into
Aether-Tools:mainfrom
Drovolon:tempprofile-delete-fix

Conversation

@Drovolon
Copy link
Copy Markdown
Contributor

Every profile in Profiles has an .Index that points back to its position in Profiles. DeleteProfile() requires that the .Index match the position (Profiles[profiles.Index] == profile).

AddTemporaryProfile() set .Index = Profiles.Count on the new temporary profile, but it did so before deleting any existing profile. This led to the .Index being off by one, so subsequent DeleteProfile() calls would return false.

Reproduction steps:

  1. Enable debug logging and debug mode for C+
  2. In the IPC tester, copy current profile into memory
  3. SetTemporaryProfileOnCharacter from memory
  4. DeleteTemporaryProfileOnCharacter -> observe the "Removed temporary profile" log line
  5. SetTemporaryProfileOnCharacter from memory
  6. (Again) SetTemporaryProfileOnCharacter from memory
  7. DeleteTemporaryProfileOnCharacter -> observe no "Removed temporary profile" log

Every profile in `Profiles` has an `.Index` that points back to its
position in `Profiles`. DeleteProfile() requires that the .Index match
the position (`Profiles[profiles.Index] == profile`).

AddTemporaryProfile() set .Index = Profiles.Count on the new temporary
profile, but it did so *before* deleting any existing profile. This led
to the .Index being off by one, so subsequent DeleteProfile() calls
would `return false`.

Reproduction steps:

1. Enable debug logging and debug mode for C+
1. In the IPC tester, copy current profile into memory
1. SetTemporaryProfileOnCharacter from memory
1. DeleteTemporaryProfileOnCharacter -> observe the "Removed temporary
   profile" log line
1. SetTemporaryProfileOnCharacter from memory
1. (Again) SetTemporaryProfileOnCharacter from memory
1. DeleteTemporaryProfileOnCharacter -> observe no "Removed temporary
   profile" log
@RisaDev
Copy link
Copy Markdown
Member

RisaDev commented May 17, 2026

Good catch, thanks!

@RisaDev RisaDev merged commit 904c318 into Aether-Tools:main May 17, 2026
1 check passed
@Drovolon Drovolon deleted the tempprofile-delete-fix branch May 17, 2026 20:19
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