Let a second copy yield to the instance already running

listen() was the whole of the single-instance check and it cannot be one:
a Windows named pipe takes a second server on the same name rather than
refusing it, and everywhere else removeServer() first takes the live socket
away from the instance holding it. Starting Dikte over a running Dikte then
left two whole copies up, two tray icons and all, and the newer one's
sweep() killed the whisper the older one was answering dictations with. On
a machine that sleeps instead of logging out, that is one Start Menu click
away, and it cost a real dictation before it was understood.

A QLockFile in the data directory closes the race on all three systems,
taken before the QApplication is even built, and behind it the probe is the
side-effect-free status verb: the Settings window opens as the sign of life
only when a bare second start deliberately asks for it, not as a byproduct
of a probe racing a forwarded toggle. The two Windows relaunch dances
collapse into one ipc.respawn.

The checkout installer and the packaged setup each kept an autostart the
other could not see, so a machine that tried both started two copies at
every sign-in: each autostart now removes the other's entry, the silent
every-start repair backs off from a Run value whose target still exists,
and each uninstaller deletes the shared dikte.cmd only when the shim
names its own install.

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
huseyin-emre-tigci
2026-08-22 23:09:05 +03:00
co-authored by Claude Fable 5
parent 0a70484d84
commit 6f601ab969
7 changed files with 308 additions and 17 deletions
+15 -1
View File
@@ -59,6 +59,13 @@ Name: "autostart"; Description: "Start Dikte when I sign in"
[Files]
Source: "{#Source}\*"; DestDir: "{app}"; Flags: recursesubdirs ignoreversion
[InstallDelete]
; A checkout's install.ps1 -Autostart is a shortcut in the Startup folder. The
; registry entry this setup writes replaces it, and both left in place would be
; two Diktes at every sign-in. Only under the autostart task: somebody who
; unticked the box has not asked for their checkout's entry to go.
Type: files; Name: "{userstartup}\Dikte.lnk"; Tasks: autostart
[Icons]
Name: "{autoprograms}\Dikte"; Filename: "{app}\Dikte.exe"
@@ -111,7 +118,14 @@ begin
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
Shim: AnsiString;
begin
{ Only the shim this setup wrote, which is the one naming its dikte-cli.exe.
install.ps1 writes the same file for a checkout, naming that checkout's
Python, and a shim somebody else wrote is not this uninstaller's to take. }
if CurUninstallStep = usUninstall then
DeleteFile(ShimPath());
if LoadStringFromFile(ShimPath(), Shim)
and (Pos(ExpandConstant('{app}\dikte-cli.exe'), Shim) > 0) then
DeleteFile(ShimPath());
end;