Forbid using dialog module before app is ready
This commit is contained in:
parent
7ff0e0214e
commit
058046304d
1 changed files with 7 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
||||||
binding = process.atomBinding 'dialog'
|
binding = process.atomBinding 'dialog'
|
||||||
v8Util = process.atomBinding 'v8_util'
|
v8Util = process.atomBinding 'v8_util'
|
||||||
|
app = require 'app'
|
||||||
BrowserWindow = require 'browser-window'
|
BrowserWindow = require 'browser-window'
|
||||||
|
|
||||||
fileDialogProperties =
|
fileDialogProperties =
|
||||||
|
@ -22,8 +23,12 @@ parseArgs = (window, options, callback) ->
|
||||||
options = null
|
options = null
|
||||||
[window, options, callback]
|
[window, options, callback]
|
||||||
|
|
||||||
|
checkAppInitialized = ->
|
||||||
|
throw new Error('dialog module can only be used after app is ready') unless app.isReady()
|
||||||
|
|
||||||
module.exports =
|
module.exports =
|
||||||
showOpenDialog: (args...) ->
|
showOpenDialog: (args...) ->
|
||||||
|
checkAppInitialized()
|
||||||
[window, options, callback] = parseArgs args...
|
[window, options, callback] = parseArgs args...
|
||||||
|
|
||||||
options ?= title: 'Open', properties: ['openFile']
|
options ?= title: 'Open', properties: ['openFile']
|
||||||
|
@ -52,6 +57,7 @@ module.exports =
|
||||||
wrappedCallback
|
wrappedCallback
|
||||||
|
|
||||||
showSaveDialog: (args...) ->
|
showSaveDialog: (args...) ->
|
||||||
|
checkAppInitialized()
|
||||||
[window, options, callback] = parseArgs args...
|
[window, options, callback] = parseArgs args...
|
||||||
|
|
||||||
options ?= title: 'Save'
|
options ?= title: 'Save'
|
||||||
|
@ -72,6 +78,7 @@ module.exports =
|
||||||
wrappedCallback
|
wrappedCallback
|
||||||
|
|
||||||
showMessageBox: (args...) ->
|
showMessageBox: (args...) ->
|
||||||
|
checkAppInitialized()
|
||||||
[window, options, callback] = parseArgs args...
|
[window, options, callback] = parseArgs args...
|
||||||
|
|
||||||
options ?= type: 'none'
|
options ?= type: 'none'
|
||||||
|
|
Loading…
Reference in a new issue