Listen to 'finish-launching' event in constructor.

Otherwise @handleEvents would never be called...
This commit is contained in:
Cheng Zhao
2013-05-30 21:30:46 +08:00
parent 3c02b28c11
commit 69b8b7989a

View File

@@ -16,15 +16,33 @@ class AtomApplication
resourcePath: null
pathsToOpen: null
version: null
pidToKillWhenClosed: null
launched: false
socketPath: '/tmp/atom.sock'
constructor: ({@resourcePath, @pathsToOpen, @version, test, @pidToKillWhenClosed}) ->
constructor: ({@resourcePath, @pathsToOpen, @version, test, pidToKillWhenClosed}) ->
@pidsToOpenWindows = {}
@pathsToOpen ?= []
@windows = []
app.on 'finish-launching', =>
@launched = true
@sendArgumentsToExistingProcess pidToKillWhenClosed, (success) =>
app.terminate() if success # An Atom already exists, kill this process
@listenForArgumentsFromNewProcess()
@setupNodePath()
@setupJavaScriptArguments()
@buildApplicationMenu()
@handleEvents()
if test
@runSpecs(true)
else if @pathsToOpen.length > 0
@openPaths(@pathsToOpen, pidToKillWhenClosed)
else
# Always open a editor window if this is the first instance of Atom.
@openPath(null)
removeWindow: (window) ->
@windows.splice @windows.indexOf(window), 1
@@ -137,25 +155,6 @@ class AtomApplication
# happens when user double clicks a file in Finder to open it.
@pathsToOpen.push filePath
app.on 'finish-launching', =>
@launched = true
@sendArgumentsToExistingProcess @pidToKillWhenClosed, (success) =>
app.terminate() if success # An Atom already exists, kill this process
@listenForArgumentsFromNewProcess()
@setupNodePath()
@setupJavaScriptArguments()
@buildApplicationMenu()
@handleEvents()
if test
@runSpecs(true)
else if @pathsToOpen.length > 0
@openPaths(@pathsToOpen, pidToKillWhenClosed)
else
# Always open a editor window if this is the first instance of Atom.
@openPath(null)
ipc.on 'close-without-confirm', (processId, routingId) ->
window = BrowserWindow.fromProcessIdAndRoutingId processId, routingId
window.removeAllListeners 'close'