From 24330408e97d11665a9359208ce1f1697a68c621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20V=C3=A1zquez?= Date: Wed, 20 Jan 2016 23:01:03 +0100 Subject: [PATCH] Introduce a delay and a two-step close windows procedure to allow to receive and execute the order to close the machine when Kitematic closes on Windows. --- src/browser.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/browser.js b/src/browser.js index 0ffca63efc..037b737ac2 100644 --- a/src/browser.js +++ b/src/browser.js @@ -7,10 +7,12 @@ import os from 'os'; import path from 'path'; import child_process from 'child_process'; +let Promise = require('bluebird'); process.env.NODE_PATH = path.join(__dirname, 'node_modules'); process.env.RESOURCES_PATH = path.join(__dirname, '/../resources'); process.env.PATH = '/usr/local/bin:' + process.env.PATH; +var exiting = false; var size = {}, settingsjson = {}; try { @@ -46,9 +48,15 @@ app.on('ready', function () { }); if (os.platform() === 'win32') { - mainWindow.on('close', function () { + mainWindow.on('close', function (e) { mainWindow.webContents.send('application:quitting'); - return true; + if(!exiting){ + Promise.delay(1000).then(function(){ + mainWindow.close(); + }); + exiting = true; + e.preventDefault(); + } }); app.on('window-all-closed', function () {