mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Listen to 'finish-launching' event in constructor.
Otherwise @handleEvents would never be called...
This commit is contained in:
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user