Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Commit

Permalink
Ignore callbacks if the browser has been deleted.
Browse files Browse the repository at this point in the history
  • Loading branch information
gruehle committed Jul 20, 2013
1 parent 557a6f4 commit 57b1d67
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions appshell/client_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,19 @@ bool ClientApp::OnProcessMessageReceived(
CefRefPtr<CefV8Value> callbackFunction = callback_map_[callbackId].second;
CefV8ValueList arguments;
context->Enter();

for (size_t i = 1; i < messageArgs->GetSize(); i++) {
arguments.push_back(ListValueToV8Value(messageArgs, i));

// Sanity check to make sure the context is still attched to a browser.
// Async callbacks could be initiated after a browser instance has been deleted,
// which can lead to bad things. If the browser instance has been deleted, don't
// invoke this callback.
if (context->GetBrowser()) {
for (size_t i = 1; i < messageArgs->GetSize(); i++) {
arguments.push_back(ListValueToV8Value(messageArgs, i));
}

callbackFunction->ExecuteFunction(NULL, arguments);
}

callbackFunction->ExecuteFunction(NULL, arguments);
context->Exit();

callback_map_.erase(callbackId);
Expand Down

0 comments on commit 57b1d67

Please sign in to comment.