Skip to content

Fix title bar showing *Untitled on startup with no file to reopen#11578

Merged
niksedk merged 1 commit into
SubtitleEdit:mainfrom
mjuhasz:fix/title-bar-asterisk-on-startup
Jun 13, 2026
Merged

Fix title bar showing *Untitled on startup with no file to reopen#11578
niksedk merged 1 commit into
SubtitleEdit:mainfrom
mjuhasz:fix/title-bar-asterisk-on-startup

Conversation

@mjuhasz

@mjuhasz mjuhasz commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Summary

When launching the app with no recent file to reopen, the title bar incorrectly showed *Untitled — the asterisk that normally indicates unsaved changes — even though nothing had been modified.

Screenshot 2026-06-13 at 9 35 29 AM

Root Cause

_changeSubtitleHash was field-initialized to -1, but GetFastHash() never returns -1 (it computes a hash seeded from 17). The slow timer fires UpdateTitleStatus() shortly after startup and sees _changeSubtitleHash (-1) != GetFastHash(), treating the clean initial state as modified.

_changeSubtitleHash only gets a real value inside ResetSubtitle(), which is called when opening a file or clicking File > New — never during a cold start with no file.

Fix

Seed both _changeSubtitleHash and _changeSubtitleHashOriginal from the actual initial state in the constructor, immediately after SelectedEncoding is set (the encoding is an input to the hash).

SelectedEncoding = Encodings.FirstOrDefault(...) ?? Encodings[0];
_changeSubtitleHash = GetFastHash();
_changeSubtitleHashOriginal = GetFastHashOriginal();

Testing

  1. Launch the app with no recent file (or clear recent files first).
  2. Verify the title bar shows Untitled - Subtitle Edit x.x with no leading *.
  3. Type in a subtitle line and verify * appears.
  4. Save and verify * disappears.

_changeSubtitleHash was initialized to -1, but GetFastHash() never
returns -1, so UpdateTitleStatus() always saw a mismatch and prepended
'*' before the user made any changes. Seed both hashes from the actual
initial state immediately after SelectedEncoding is set.
@niksedk niksedk merged commit 500ad98 into SubtitleEdit:main Jun 13, 2026
2 checks passed
@mjuhasz mjuhasz deleted the fix/title-bar-asterisk-on-startup branch June 13, 2026 19:47
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