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

Commit

Permalink
Merge pull request #282 from adobe/glenn/issue-4522
Browse files Browse the repository at this point in the history
Ignore callbacks if the browser instance has been deleted
  • Loading branch information
JeffryBooher committed Jul 22, 2013
2 parents 583ca57 + 57b1d67 commit b9bf3ac
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 b9bf3ac

Please sign in to comment.