Skip to content

Commit

Permalink
Proper v1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
hellzerg committed Nov 20, 2021
1 parent f62dc29 commit 308520e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
12 changes: 9 additions & 3 deletions Mint/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,6 @@ private void CheckForUpdate()
// DOWNLOAD NEW VERSION
client.DownloadFile(NewDownloadLink(latestVersion), tempFile);

// ALLOW MINT TO EXIT
_allowExit = true;

// DELETE PREVIOUS BACK-UP
if (System.IO.File.Exists(archiveFile))
{
Expand All @@ -338,6 +335,15 @@ private void CheckForUpdate()
// PATCH
System.IO.File.Move(tempFile, appFile);

// BYPASS SINGLE-INSTANCE MECHANISM
_allowExit = true;
if (Program.MUTEX != null)
{
Program.MUTEX.ReleaseMutex();
Program.MUTEX.Dispose();
Program.MUTEX = null;
}

Application.Restart();
}
catch (Exception ex)
Expand Down
5 changes: 3 additions & 2 deletions Mint/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ internal static float GetCurrentVersion()
const string _jsonAssembly = @"Mint.Newtonsoft.Json.dll";

const string _mutexGuid = "{DEADMOON-0EFC7B9A-D7FC-437F-B4B3-0118C643FE19-MINT}";
internal static Mutex MUTEX;
static bool _notRunning;

[STAThread]
Expand All @@ -36,7 +37,7 @@ static void Main()
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

using (Mutex m = new Mutex(true, _mutexGuid, out _notRunning))
using (MUTEX = new Mutex(true, _mutexGuid, out _notRunning))
{
if (_notRunning)
{
Expand All @@ -49,7 +50,7 @@ static void Main()
else
{
MessageBox.Show("Mint is already running in the background!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
Application.Exit();
Environment.Exit(0);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4
1.5

0 comments on commit 308520e

Please sign in to comment.