From 243ebbef5a1cff140ce6baa45091a78f2f343f67 Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Fri, 7 Jun 2024 12:34:58 +0100 Subject: [PATCH] Warn if launching multiple instances (#606) --- Bloxstrap/App.xaml.cs | 15 +++++++++++++++ .../UI/Elements/ContextMenu/MenuContainer.xaml.cs | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Bloxstrap/App.xaml.cs b/Bloxstrap/App.xaml.cs index f235dd4..7e443a8 100644 --- a/Bloxstrap/App.xaml.cs +++ b/Bloxstrap/App.xaml.cs @@ -209,6 +209,21 @@ namespace Bloxstrap if (!IsFirstRun) ShouldSaveConfigs = true; + + if (Mutex.TryOpenExisting("ROBLOX_singletonMutex", out var _)) + { + var result = Frontend.ShowMessageBox( + "Roblox is currently running, and launching another instance will close it. Are you sure you want to continue launching?", + MessageBoxImage.Warning, + MessageBoxButton.YesNo + ); + + if (result != MessageBoxResult.Yes) + { + StartupFinished(); + return; + } + } // start bootstrapper and show the bootstrapper modal if we're not running silently Logger.WriteLine(LOG_IDENT, "Initializing bootstrapper"); diff --git a/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml.cs b/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml.cs index 3ccc390..67b8bb6 100644 --- a/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml.cs +++ b/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml.cs @@ -112,7 +112,7 @@ namespace Bloxstrap.UI.Elements.ContextMenu private void LogTracerMenuItem_Click(object sender, RoutedEventArgs e) { - Utilities.ShellExecute(_activityWatcher?.LogLocation); + Utilities.ShellExecute(_activityWatcher?.LogLocation!); } private void CloseRobloxMenuItem_Click(object sender, RoutedEventArgs e)