mirror of
https://github.com/JosefNemec/Playnite.git
synced 2026-01-09 06:11:22 +08:00
Playnite detecting other Playnite apps incorrectly as Playnite itself already running
This commit is contained in:
parent
bef7cf9597
commit
05441d38f9
@ -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");
|
||||||
|
|||||||
@ -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");
|
||||||
|
|||||||
@ -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();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user