Skip to content

Commit 3a8a491

Browse files
committed
Fix nwjs#6766: Opening DevTools causes Crash when DevTools are open already
The extension function's lifecyle is handled correctly now. It's also referenced in extensions/browser/extension_function_dispatcher.cc
1 parent f399d06 commit 3a8a491

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/api/nw_window_api.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ NwCurrentWindowInternalCloseFunction::Run() {
154154
}
155155

156156
void NwCurrentWindowInternalShowDevToolsInternalFunction::OnOpened() {
157-
Release();
158157
Respond(NoArguments());
158+
Release();
159159
}
160160

161161
ExtensionFunction::ResponseAction
@@ -167,12 +167,12 @@ NwCurrentWindowInternalShowDevToolsInternalFunction::Run() {
167167
DevToolsWindow::OpenDevToolsWindow(web_contents);
168168
DevToolsWindow* devtools_window =
169169
DevToolsWindow::FindDevToolsWindow(agent.get());
170-
if (devtools_window)
171-
devtools_window->SetLoadCompletedCallback(base::Bind(&NwCurrentWindowInternalShowDevToolsInternalFunction::OnOpened, this));
172-
else
170+
if (devtools_window) {
171+
AddRef();
172+
devtools_window->SetLoadCompletedCallback(base::Bind(&NwCurrentWindowInternalShowDevToolsInternalFunction::OnOpened, base::Unretained(this)));
173+
} else
173174
return RespondNow(NoArguments());
174175

175-
AddRef();
176176
return RespondLater();
177177
}
178178

0 commit comments

Comments
 (0)