Make sure webContents is created when opening devtools.
Fixes atom/atom#2270.
This commit is contained in:
parent
754abbd39c
commit
972bb2e9fb
3 changed files with 12 additions and 16 deletions
|
@ -362,7 +362,7 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
|||
.SetMethod("flashFrame", &Window::FlashFrame)
|
||||
.SetMethod("setKiosk", &Window::SetKiosk)
|
||||
.SetMethod("isKiosk", &Window::IsKiosk)
|
||||
.SetMethod("openDevTools", &Window::OpenDevTools)
|
||||
.SetMethod("_openDevTools", &Window::OpenDevTools)
|
||||
.SetMethod("closeDevTools", &Window::CloseDevTools)
|
||||
.SetMethod("isDevToolsOpened", &Window::IsDevToolsOpened)
|
||||
.SetMethod("inspectElement", &Window::InspectElement)
|
||||
|
|
|
@ -18,17 +18,6 @@ BrowserWindow::_init = ->
|
|||
@webContents = @getWebContents()
|
||||
@webContents.once 'destroyed', => @webContents = null
|
||||
|
||||
# Define getter for devToolsWebContents.
|
||||
devToolsWebContents = null
|
||||
@__defineGetter__ 'devToolsWebContents', ->
|
||||
if @isDevToolsOpened()
|
||||
# Get a new devToolsWebContents if previous one has been destroyed, it
|
||||
# could happen when the devtools has been closed and then reopened.
|
||||
devToolsWebContents = null unless devToolsWebContents?.isAlive()
|
||||
devToolsWebContents ?= @getDevToolsWebContents()
|
||||
else
|
||||
devToolsWebContents = null
|
||||
|
||||
# Remember the window.
|
||||
id = BrowserWindow.windows.add this
|
||||
|
||||
|
@ -37,10 +26,12 @@ BrowserWindow::_init = ->
|
|||
@once 'closed', ->
|
||||
BrowserWindow.windows.remove id if BrowserWindow.windows.has id
|
||||
|
||||
# Tell the rpc server that a render view has been deleted and we need to
|
||||
# release all objects owned by it.
|
||||
@webContents.on 'render-view-deleted', (event, processId, routingId) ->
|
||||
process.emit 'ATOM_BROWSER_RELEASE_RENDER_VIEW', "#{processId}-#{routingId}"
|
||||
BrowserWindow::openDevTools = ->
|
||||
@_openDevTools()
|
||||
|
||||
# Force devToolsWebContents to be created.
|
||||
@devToolsWebContents = @getDevToolsWebContents()
|
||||
@devToolsWebContents.once 'destroyed', => @devToolsWebContents = null
|
||||
|
||||
BrowserWindow::toggleDevTools = ->
|
||||
if @isDevToolsOpened() then @closeDevTools() else @openDevTools()
|
||||
|
|
|
@ -15,6 +15,11 @@ module.exports.wrap = (webContents) ->
|
|||
webContents.getId = -> "#{@getProcessId()}-#{@getRoutingId()}"
|
||||
webContents.equal = (other) -> @getId() is other.getId()
|
||||
|
||||
# Tell the rpc server that a render view has been deleted and we need to
|
||||
# release all objects owned by it.
|
||||
webContents.on 'render-view-deleted', (event, processId, routingId) ->
|
||||
process.emit 'ATOM_BROWSER_RELEASE_RENDER_VIEW', "#{processId}-#{routingId}"
|
||||
|
||||
# Dispatch IPC messages to the ipc module.
|
||||
webContents.on 'ipc-message', (event, channel, args...) =>
|
||||
Object.defineProperty event, 'sender', value: webContents
|
||||
|
|
Loading…
Reference in a new issue