Skip to content

Commit

Permalink
fix(GUI): disallow reloading the app in macOS using Cmd+R (#1219)
Browse files Browse the repository at this point in the history
Users can currently force the browser window to reload by using Cmd+R in
macOS. The `will-navigate` event handler in this same file is supposed
to protect us from this case, however it's not fired at all just in
macOS for some reason.

As a solution, we attach dummy keyboard shortcut handlers for Cmd+R,
Ctrl+R, and F5, to override the normal browser window behaviour.

The reason behind disallowing reloads is that a reload during a critical
operation such as writing, validation, elevating, unmounting, drive
scanning, etc will cause undefined behaviour, resulting in nonsense
errors that we can't solve coming to TrackJS.

See: electron/electron#8841
Fixes: #1210
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
  • Loading branch information
Juan Cruz Viotti committed Mar 26, 2017
1 parent 68d50ba commit 180802b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/gui/etcher.js
Expand Up @@ -17,6 +17,7 @@
'use strict';

const electron = require('electron');
const _ = require('lodash');
const path = require('path');
let mainWindow = null;

Expand Down Expand Up @@ -69,6 +70,15 @@ electron.app.on('ready', () => {
mode: 'detach'
});
});

// Disable refreshing the browser window
// This is supposed to be handled by the `will-navigate`
// event, however there seems to be an issue where such
// event is not fired in macOS
// See: https://github.com/electron/electron/issues/8841
electron.globalShortcut.register('CmdOrCtrl+R', _.noop);
electron.globalShortcut.register('F5', _.noop);

});

mainWindow.on('blur', () => {
Expand Down

0 comments on commit 180802b

Please sign in to comment.