|
@@ -6,6 +6,8 @@ using Microsoft.Extensions.DependencyInjection;
|
|
using PixiEditor.Extensions;
|
|
using PixiEditor.Extensions;
|
|
using PixiEditor.Extensions.Common.Localization;
|
|
using PixiEditor.Extensions.Common.Localization;
|
|
using PixiEditor.Models.AppExtensions;
|
|
using PixiEditor.Models.AppExtensions;
|
|
|
|
+using PixiEditor.Helpers.UI;
|
|
|
|
+using PixiEditor.Localization;
|
|
using PixiEditor.Models.Controllers;
|
|
using PixiEditor.Models.Controllers;
|
|
using PixiEditor.Models.DataHolders;
|
|
using PixiEditor.Models.DataHolders;
|
|
using PixiEditor.Models.Dialogs;
|
|
using PixiEditor.Models.Dialogs;
|
|
@@ -46,10 +48,12 @@ internal partial class App : Application
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ #if !STEAM
|
|
if (!HandleNewInstance())
|
|
if (!HandleNewInstance())
|
|
{
|
|
{
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ #endif
|
|
|
|
|
|
AddNativeAssets();
|
|
AddNativeAssets();
|
|
|
|
|
|
@@ -90,6 +94,9 @@ internal partial class App : Application
|
|
|
|
|
|
GC.KeepAlive(_mutex);
|
|
GC.KeepAlive(_mutex);
|
|
|
|
|
|
|
|
+ if (Current?.Dispatcher == null)
|
|
|
|
+ return true;
|
|
|
|
+
|
|
if (isOwned)
|
|
if (isOwned)
|
|
{
|
|
{
|
|
var thread = new Thread(
|
|
var thread = new Thread(
|
|
@@ -107,7 +114,7 @@ internal partial class App : Application
|
|
List<string> args = new List<string>();
|
|
List<string> args = new List<string>();
|
|
if (File.Exists(passedArgsFile))
|
|
if (File.Exists(passedArgsFile))
|
|
{
|
|
{
|
|
- args = File.ReadAllText(passedArgsFile).Split(' ').ToList();
|
|
|
|
|
|
+ args = CommandLineHelpers.SplitCommandLine(File.ReadAllText(passedArgsFile)).ToList();
|
|
File.Delete(passedArgsFile);
|
|
File.Delete(passedArgsFile);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -128,7 +135,7 @@ internal partial class App : Application
|
|
}
|
|
}
|
|
|
|
|
|
// Notify other instance so it could bring itself to foreground.
|
|
// Notify other instance so it could bring itself to foreground.
|
|
- File.WriteAllText(passedArgsFile, string.Join(' ', Environment.GetCommandLineArgs()));
|
|
|
|
|
|
+ File.WriteAllText(passedArgsFile, string.Join(' ', WrapSpaces(Environment.GetCommandLineArgs())));
|
|
_eventWaitHandle.Set();
|
|
_eventWaitHandle.Set();
|
|
|
|
|
|
// Terminate this instance.
|
|
// Terminate this instance.
|
|
@@ -136,6 +143,25 @@ internal partial class App : Application
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private string?[] WrapSpaces(string[] args)
|
|
|
|
+ {
|
|
|
|
+ string?[] wrappedArgs = new string?[args.Length];
|
|
|
|
+ for (int i = 0; i < args.Length; i++)
|
|
|
|
+ {
|
|
|
|
+ string arg = args[i];
|
|
|
|
+ if (arg.Contains(' '))
|
|
|
|
+ {
|
|
|
|
+ wrappedArgs[i] = $"\"{arg}\"";
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ wrappedArgs[i] = arg;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return wrappedArgs;
|
|
|
|
+ }
|
|
|
|
+
|
|
protected override void OnSessionEnding(SessionEndingCancelEventArgs e)
|
|
protected override void OnSessionEnding(SessionEndingCancelEventArgs e)
|
|
{
|
|
{
|
|
base.OnSessionEnding(e);
|
|
base.OnSessionEnding(e);
|