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("flashFrame", &Window::FlashFrame)
|
||||||
.SetMethod("setKiosk", &Window::SetKiosk)
|
.SetMethod("setKiosk", &Window::SetKiosk)
|
||||||
.SetMethod("isKiosk", &Window::IsKiosk)
|
.SetMethod("isKiosk", &Window::IsKiosk)
|
||||||
.SetMethod("openDevTools", &Window::OpenDevTools)
|
.SetMethod("_openDevTools", &Window::OpenDevTools)
|
||||||
.SetMethod("closeDevTools", &Window::CloseDevTools)
|
.SetMethod("closeDevTools", &Window::CloseDevTools)
|
||||||
.SetMethod("isDevToolsOpened", &Window::IsDevToolsOpened)
|
.SetMethod("isDevToolsOpened", &Window::IsDevToolsOpened)
|
||||||
.SetMethod("inspectElement", &Window::InspectElement)
|
.SetMethod("inspectElement", &Window::InspectElement)
|
||||||
|
|
|
@ -18,17 +18,6 @@ BrowserWindow::_init = ->
|
||||||
@webContents = @getWebContents()
|
@webContents = @getWebContents()
|
||||||
@webContents.once 'destroyed', => @webContents = null
|
@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.
|
# Remember the window.
|
||||||
id = BrowserWindow.windows.add this
|
id = BrowserWindow.windows.add this
|
||||||
|
|
||||||
|
@ -37,10 +26,12 @@ BrowserWindow::_init = ->
|
||||||
@once 'closed', ->
|
@once 'closed', ->
|
||||||
BrowserWindow.windows.remove id if BrowserWindow.windows.has id
|
BrowserWindow.windows.remove id if BrowserWindow.windows.has id
|
||||||
|
|
||||||
# Tell the rpc server that a render view has been deleted and we need to
|
BrowserWindow::openDevTools = ->
|
||||||
# release all objects owned by it.
|
@_openDevTools()
|
||||||
@webContents.on 'render-view-deleted', (event, processId, routingId) ->
|
|
||||||
process.emit 'ATOM_BROWSER_RELEASE_RENDER_VIEW', "#{processId}-#{routingId}"
|
# Force devToolsWebContents to be created.
|
||||||
|
@devToolsWebContents = @getDevToolsWebContents()
|
||||||
|
@devToolsWebContents.once 'destroyed', => @devToolsWebContents = null
|
||||||
|
|
||||||
BrowserWindow::toggleDevTools = ->
|
BrowserWindow::toggleDevTools = ->
|
||||||
if @isDevToolsOpened() then @closeDevTools() else @openDevTools()
|
if @isDevToolsOpened() then @closeDevTools() else @openDevTools()
|
||||||
|
|
|
@ -15,6 +15,11 @@ module.exports.wrap = (webContents) ->
|
||||||
webContents.getId = -> "#{@getProcessId()}-#{@getRoutingId()}"
|
webContents.getId = -> "#{@getProcessId()}-#{@getRoutingId()}"
|
||||||
webContents.equal = (other) -> @getId() is other.getId()
|
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.
|
# Dispatch IPC messages to the ipc module.
|
||||||
webContents.on 'ipc-message', (event, channel, args...) =>
|
webContents.on 'ipc-message', (event, channel, args...) =>
|
||||||
Object.defineProperty event, 'sender', value: webContents
|
Object.defineProperty event, 'sender', value: webContents
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue