From cb2bf796fa747e6df1c698757b43c344968c7691 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 7 Jun 2013 16:12:10 +0800 Subject: [PATCH] Show prompt to force closing window when window is frozen. Fixed atom/atom-shell#17. --- src/atom-application.coffee | 2 +- src/atom-window.coffee | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/atom-application.coffee b/src/atom-application.coffee index 6e22c58f0..91b275602 100644 --- a/src/atom-application.coffee +++ b/src/atom-application.coffee @@ -247,7 +247,7 @@ class AtomApplication if pidToKillWhenClosed? @pidsToOpenWindows[pidToKillWhenClosed] = openedWindow - openedWindow.browserWindow.on 'closed', => + openedWindow.browserWindow.on 'destroyed', => for pid, trackedWindow of @pidsToOpenWindows when trackedWindow is openedWindow try process.kill(pid) diff --git a/src/atom-window.coffee b/src/atom-window.coffee index 0c422f427..33913b528 100644 --- a/src/atom-window.coffee +++ b/src/atom-window.coffee @@ -1,4 +1,5 @@ BrowserWindow = require 'browser-window' +dialog = require 'dialog' ipc = require 'ipc' module.exports = @@ -21,6 +22,14 @@ class AtomWindow @browserWindow.on 'destroyed', => global.atomApplication.removeWindow(this) + @browserWindow.on 'unresponsive', => + chosen = dialog.showMessageBox + type: 'warning' + buttons: ['Close', 'Keep Waiting'] + message: 'Editor window is frozen' + detail: "The editor window becomes frozen because of JavaScript dead loop, you can force closing it or just keep waiting." + @browserWindow.destroy() if chosen is 0 + if @isSpec # Spec window's web view should always have focus @browserWindow.on 'blur', =>