Playnite detecting other Playnite apps incorrectly as Playnite itself already running

This commit is contained in:
Josef Nemec 2025-12-25 18:48:16 +01:00
parent bef7cf9597
commit 05441d38f9
No known key found for this signature in database
3 changed files with 12 additions and 6 deletions

View File

@ -77,7 +77,7 @@ namespace Playnite.DesktopApp
} }
SplashScreen splash = null; SplashScreen splash = null;
var procCount = Process.GetProcesses().Where(a => a.ProcessName.StartsWith("Playnite.")).Count(); var procCount = Process.GetProcesses().Where(a => PlayniteApplication.IsProcessPlayniteProcess(a)).Count();
if (cmdLine.Start.IsNullOrEmpty() && !cmdLine.HideSplashScreen && procCount == 1) if (cmdLine.Start.IsNullOrEmpty() && !cmdLine.HideSplashScreen && procCount == 1)
{ {
splash = new SplashScreen("SplashScreen.png"); splash = new SplashScreen("SplashScreen.png");

View File

@ -77,7 +77,7 @@ namespace Playnite.FullscreenApp
} }
SplashScreen splash = null; SplashScreen splash = null;
var procCount = Process.GetProcesses().Where(a => a.ProcessName.StartsWith("Playnite.")).Count(); var procCount = Process.GetProcesses().Where(a => PlayniteApplication.IsProcessPlayniteProcess(a)).Count();
if (cmdLine.Start.IsNullOrEmpty() && !cmdLine.HideSplashScreen && procCount == 1) if (cmdLine.Start.IsNullOrEmpty() && !cmdLine.HideSplashScreen && procCount == 1)
{ {
splash = new SplashScreen("SplashScreen.png"); splash = new SplashScreen("SplashScreen.png");

View File

@ -921,7 +921,8 @@ namespace Playnite
} }
else else
{ {
var existingProcess = Process.GetProcesses().First(a => a.ProcessName.StartsWith("Playnite.") && a.Id != curProcess.Id); var existingProcess = Process.GetProcesses().
First(a => IsProcessPlayniteProcess(a) && a.Id != curProcess.Id);
if (existingProcess.ProcessName == curProcess.ProcessName) if (existingProcess.ProcessName == curProcess.ProcessName)
{ {
client.InvokeCommand(CmdlineCommand.Focus, string.Empty); client.InvokeCommand(CmdlineCommand.Focus, string.Empty);
@ -946,7 +947,7 @@ namespace Playnite
} }
else else
{ {
var processes = Process.GetProcesses().Where(a => a.ProcessName.StartsWith("Playnite.")).ToList(); var processes = Process.GetProcesses().Where(a => IsProcessPlayniteProcess(a)).ToList();
// In case multiple processes end up in this branch, // In case multiple processes end up in this branch,
// the process with highest process id gets to live. // the process with highest process id gets to live.
if (processes.Count > 1 && processes.Max(a => a.Id) != curProcess.Id) if (processes.Count > 1 && processes.Max(a => a.Id) != curProcess.Id)
@ -1630,13 +1631,13 @@ namespace Playnite
private void WaitForOtherInstacesToExit(bool throwOnTimetout) private void WaitForOtherInstacesToExit(bool throwOnTimetout)
{ {
if (Process.GetProcesses().Where(a => a.ProcessName.StartsWith("Playnite.")).Count() > 1) if (Process.GetProcesses().Where(a => IsProcessPlayniteProcess(a)).Count() > 1)
{ {
logger.Info("Multiple Playnite instances detected, waiting for them to close."); logger.Info("Multiple Playnite instances detected, waiting for them to close.");
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
{ {
Thread.Sleep(500); Thread.Sleep(500);
if (Process.GetProcesses().Where(a => a.ProcessName.StartsWith("Playnite.")).Count() == 1) if (Process.GetProcesses().Where(a => IsProcessPlayniteProcess(a)).Count() == 1)
{ {
break; break;
} }
@ -1655,6 +1656,11 @@ namespace Playnite
} }
} }
public static bool IsProcessPlayniteProcess(Process process)
{
return process.ProcessName.StartsWith("Playnite.DesktopApp") || process.ProcessName.StartsWith("Playnite.FullscreenApp");
}
public abstract PlayniteAPI GetApiInstance(ExtensionManifest pluginOwner); public abstract PlayniteAPI GetApiInstance(ExtensionManifest pluginOwner);
public abstract PlayniteAPI GetApiInstance(); public abstract PlayniteAPI GetApiInstance();
} }