Skip to content

Offer to restart TV Rename when the theme is changed - #1089

Merged
SirSparkles merged 3 commits into
TV-Rename:masterfrom
kadeschs:theme-restart
Nov 24, 2026
Merged

SirSparkles merged 3 commits into
TV-Rename:masterfrom
kadeschs:theme-restart

Conversation

@kadeschs

@kadeschs kadeschs commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Changing the theme needs a restart, and until now that meant closing TV Rename, finding it again and starting it back up. Now, after picking a new theme and clicking OK in Preferences, TV Rename asks "Restart now" or "Later". Restart now saves the settings and starts TV Rename again on the new theme, with the same settings folder, missing folder options and /hide or /unattended. One off command line tasks such as /scan or /doall are not repeated, and the startup scan and update popup are skipped on the restart.

  • No question when the chosen theme is the one already showing (for example switching back before restarting)
  • If a scan is still running, the question says restarting will stop it, and Later is the default button
  • While files are being copied or moved there is no Restart now, just a note to restart once they finish
  • If there are scan results, the question says they will be cleared
  • ThemeableMessageBox gets an overload for its own button wording and which button is the default

A new theme only shows after a restart, so after OK in Preferences TV Rename now asks
Restart now or Later. Restart now saves the settings and starts TV Rename again with the
same settings folder (one off command line tasks are not repeated).

- No question when the chosen theme is the one already showing
- A running scan is only stopped if the user agrees, and Later is then the default
- No restart while files are being copied or moved
- ThemeableMessageBox can use its own wording for the Yes and No buttons
@SirSparkles

Copy link
Copy Markdown
Collaborator

Have a look at TVSettings.Instance.RunOnStartUp() as we may want to inhibit the settings define scan on startup (as well as the CLI one) when we doa pseudo-startup / restart

Comment thread TVRename/App/Program.cs Outdated
using Process old = Process.GetProcessById(processId);
if (!old.WaitForExit(TimeSpan.FromSeconds(60)))
{
Logger.Warn("The previous copy of TV Rename is still running after a restart");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What else should we do if the old one has not closed within 60 seconds. Terminate this version?

We have 2 methods of identifying whether an old version is running no:

  1. This Registry /. Process Id method
  2. the Mutex that we use to pass parameters to already running versions: See singleInstanceService.IsFirstInstance()

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it now closes itself. If the old copy is still running after 60 seconds, the new copy logs a warning and exits without sending it anything, leaving the old copy alone in case it is still saving.

On the two methods: the old copy closes the mutex in Main's finally, but the single instance semaphore and the port 19191 listener stay until the process ends. So the mutex can look free while IsFirstInstance() still sees the old copy, and the new one could exit with "An instance is already running". Waiting on the process covers all three. The process id is passed in an environment variable (nothing in the registry), and since ids get reused, the new copy only waits on a process that started before it.

The copy started by Restart now skips the Scan on Startup setting and the update available popup
(the Update Available button still shows). The command line scans were already not passed on.
If the old copy is still running after 60 seconds the new copy closes without passing it anything,
and a reused process id is not mistaken for the old copy. /hide and /unattended are kept on
restart, as they are how TV Rename was run rather than one off tasks.
@kadeschs

Copy link
Copy Markdown
Collaborator Author

Good catch: with Scan on Startup on, it would have run the scan and its actions straight after a theme change. Fixed in the latest commit. The restarted copy skips the startup scan and logs "Startup Scan not run as TV Rename has just restarted". I left RunOnStartUp() alone, as Preferences reads it for the checkbox and would save it unticked. The update popup is skipped after a restart too (the Update Available button still shows).

Command line scans were already not repeated, as only /userfilepath, /createmissing, /ignoremissing and /norenamecheck are passed on. I've added /hide and /unattended, since they're how TV Rename was run rather than one off tasks.

Tested with Scan on Startup and the update popup on, for a normal restart, /unattended and /hide (brought up with /focus): each first copy scanned, and each restarted copy kept its arguments, didn't scan and showed no popup. Also tested the old copy already gone (starts straight away) and one that never closes (waits 60 seconds, logs the warning, closes).

@SirSparkles
SirSparkles merged commit 2cc4f34 into TV-Rename:master Nov 24, 2026
4 checks passed
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