From 22e9ea5b141fa0793f247fff020bb668289f708d Mon Sep 17 00:00:00 2001 From: Yuki Hattori Date: Tue, 1 Nov 2016 02:10:44 +0900 Subject: [PATCH 1/2] Fix #104: Avoid app termination unexpectedly on Linux - Wrap triggers of internal command with setTimeout - Set cancelId as "Cancel" command --- coffee/classes/mds_window.coffee | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/coffee/classes/mds_window.coffee b/coffee/classes/mds_window.coffee index a72912b..82c5dd2 100644 --- a/coffee/classes/mds_window.coffee +++ b/coffee/classes/mds_window.coffee @@ -85,10 +85,18 @@ module.exports = class MdsWindow title: 'Marp' message: 'Are you sure?' detail: "#{@getShortPath()} has been modified. Do you want to save the changes?" + cancelId: 2 , (result) => switch result - when 0 then @trigger 'save', 'forceClose' - when 1 then @trigger 'forceClose' + when 0 + # Wrap by setTimeout to avoid app termination unexpectedly on Linux. + setTimeout => + @trigger 'save', 'forceClose' + , 0 + when 1 + setTimeout => + @trigger 'forceClose' + , 0 else MdsWindow.appWillQuit = false From b6e9b3f06392e2f578abeb8b95333a13bfeb695e Mon Sep 17 00:00:00 2001 From: Yuki Hattori Date: Tue, 1 Nov 2016 21:18:29 +0900 Subject: [PATCH 2/2] Improve code of setTimeout as one line --- coffee/classes/mds_window.coffee | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/coffee/classes/mds_window.coffee b/coffee/classes/mds_window.coffee index 82c5dd2..5cb40b1 100644 --- a/coffee/classes/mds_window.coffee +++ b/coffee/classes/mds_window.coffee @@ -87,16 +87,10 @@ module.exports = class MdsWindow detail: "#{@getShortPath()} has been modified. Do you want to save the changes?" cancelId: 2 , (result) => + # Wrap by setTimeout to avoid app termination unexpectedly on Linux. switch result - when 0 - # Wrap by setTimeout to avoid app termination unexpectedly on Linux. - setTimeout => - @trigger 'save', 'forceClose' - , 0 - when 1 - setTimeout => - @trigger 'forceClose' - , 0 + when 0 then setTimeout (=> @trigger 'save', 'forceClose'), 0 + when 1 then setTimeout (=> @trigger 'forceClose'), 0 else MdsWindow.appWillQuit = false