summaryrefslogtreecommitdiffhomepage
path: root/gui/src
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2022-07-13 11:55:40 +0200
committerOskar Nyberg <oskar@mullvad.net>2022-07-15 10:01:22 +0200
commitc52c18fe7f2ede658e0d55e498a43cae0be1b5ec (patch)
tree87e4d555f1967fed5b77a90cd898c19fa520a62c /gui/src
parent3254a8145c643d3f80506efefebeeb8cabb8b90b (diff)
downloadmullvadvpn-c52c18fe7f2ede658e0d55e498a43cae0be1b5ec.tar.xz
mullvadvpn-c52c18fe7f2ede658e0d55e498a43cae0be1b5ec.zip
Quit without disconnecting when renderer process is killed or crashes
Diffstat (limited to 'gui/src')
-rw-r--r--gui/src/main/index.ts16
1 files changed, 10 insertions, 6 deletions
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts
index b8a8a9ca28..07a0b711fe 100644
--- a/gui/src/main/index.ts
+++ b/gui/src/main/index.ts
@@ -260,7 +260,7 @@ class ApplicationMain {
private macOsScrollbarVisibility?: MacOsScrollbarVisibility;
- private quitWithoutDisconnect = false;
+ private stayConnectedOnQuit = false;
private changelog?: IChangelog;
private forceShowChanges = process.argv.includes(Options.showChanges);
@@ -283,8 +283,7 @@ class ApplicationMain {
// This ensures that only a single instance is running at the same time, but also exits if
// there's no already running instance when the quit without disconnect flag is supplied.
if (!app.requestSingleInstanceLock() || process.argv.includes(Options.quitWithoutDisconnect)) {
- this.quitWithoutDisconnect = true;
- app.quit();
+ this.quitWithoutDisconnect();
return;
}
@@ -318,6 +317,7 @@ class ApplicationMain {
log.error(
`Render process exited with exit code ${details.exitCode} due to ${details.reason}`,
);
+ this.quitWithoutDisconnect();
});
app.on('child-process-gone', (_event, details) => {
log.error(
@@ -336,8 +336,7 @@ class ApplicationMain {
app.on('second-instance', (_event, argv, _workingDirectory) => {
if (argv.includes(Options.quitWithoutDisconnect)) {
// Quit if another instance is started with the quit without disconnect flag.
- this.quitWithoutDisconnect = true;
- app.quit();
+ this.quitWithoutDisconnect();
} else if (this.windowController) {
// If no action was provided to the new instance the window is opened.
this.windowController.show();
@@ -402,6 +401,11 @@ class ApplicationMain {
}
};
+ private quitWithoutDisconnect() {
+ this.stayConnectedOnQuit = true;
+ app.quit();
+ }
+
// This is a last try to disconnect and quit gracefully if the app quits without having received
// the before-quit event.
private onQuit = async () => {
@@ -439,7 +443,7 @@ class ApplicationMain {
};
private async prepareToQuit() {
- if (this.quitWithoutDisconnect) {
+ if (this.stayConnectedOnQuit) {
log.info('Not disconnecting tunnel on quit');
} else {
if (this.connectedToDaemon) {