Allow multiple instances of osu! when running under debug (#5436)

Allow multiple instances of osu! when running under debug

Co-authored-by: Dan Balasescu <1329837+smoogipoo@users.noreply.github.com>
This commit is contained in:
Dean Herbert 2019-07-23 20:34:45 +09:00 committed by GitHub
commit 233ba71d2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 20 deletions

View File

@ -28,6 +28,8 @@ namespace osu.Desktop
host.ExceptionThrown += handleException; host.ExceptionThrown += handleException;
if (!host.IsPrimaryInstance) if (!host.IsPrimaryInstance)
{
if (args.Length > 0 && args[0].Contains('.')) // easy way to check for a file import in args
{ {
var importer = new ArchiveImportIPCChannel(host); var importer = new ArchiveImportIPCChannel(host);
// Restore the cwd so relative paths given at the command line work correctly // Restore the cwd so relative paths given at the command line work correctly
@ -39,9 +41,15 @@ namespace osu.Desktop
if (!importer.ImportAsync(Path.GetFullPath(file)).Wait(3000)) if (!importer.ImportAsync(Path.GetFullPath(file)).Wait(3000))
throw new TimeoutException(@"IPC took too long to send"); throw new TimeoutException(@"IPC took too long to send");
} }
return 0;
} }
else
{ // we want to allow multiple instances to be started when in debug.
if (!DebugUtils.IsDebugBuild)
return 0;
}
switch (args.FirstOrDefault() ?? string.Empty) switch (args.FirstOrDefault() ?? string.Empty)
{ {
default: default:
@ -52,7 +60,6 @@ namespace osu.Desktop
host.Run(new TournamentGame()); host.Run(new TournamentGame());
break; break;
} }
}
return 0; return 0;
} }

View File

@ -20,6 +20,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Development;
using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Input; using osu.Framework.Input;
@ -153,7 +154,7 @@ namespace osu.Game
{ {
this.frameworkConfig = frameworkConfig; this.frameworkConfig = frameworkConfig;
if (!Host.IsPrimaryInstance) if (!Host.IsPrimaryInstance && !DebugUtils.IsDebugBuild)
{ {
Logger.Log(@"osu! does not support multiple running instances.", LoggingTarget.Runtime, LogLevel.Error); Logger.Log(@"osu! does not support multiple running instances.", LoggingTarget.Runtime, LogLevel.Error);
Environment.Exit(0); Environment.Exit(0);