From 56d47fc61c7ad2a0a14131a7797b6c2d3432d6b8 Mon Sep 17 00:00:00 2001 From: Louis Pontoise Date: Wed, 20 Jan 2021 00:19:01 +0900 Subject: [PATCH] fix: restarting the app would sometimes fail to start again --- src/ui/App.swift | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/ui/App.swift b/src/ui/App.swift index 60784234..2949d4d7 100644 --- a/src/ui/App.swift +++ b/src/ui/App.swift @@ -102,13 +102,10 @@ class App: AppCenterApplication, NSApplicationDelegate { } func restart() { - let url = URL(fileURLWithPath: Bundle.main.resourcePath!) - let path = url.deletingLastPathComponent().deletingLastPathComponent().absoluteString - let task = Process() - task.launchPath = "/usr/bin/open" - task.arguments = [path] - task.launch() - exit(0) + // we use -n to open a new instance, to avoid calling applicationShouldHandleReopen + // we use Bundle.main.bundlePath in case of multiple AltTab versions on the machine + Process.launchedProcess(launchPath: "/usr/bin/open", arguments: ["-n", Bundle.main.bundlePath]) + App.shared.terminate(self) } func hideUi() {