From 9ee78cb9e0bcdb8deeb338473c7424f4bccf8c73 Mon Sep 17 00:00:00 2001 From: Prashanth Nethi Date: Mon, 1 Dec 2014 14:52:14 +0530 Subject: [PATCH 1/2] Fix for [CEF 2171] Crash on quit(https://github.com/adobe/brackets/issues/7683) This is to fix the crash on quit(Issue#7683) after integrating CEF 2171. On Destruction, callback_map_ was getting destroyed in the ClientApp::~ClientApp(). However while removing all the elements, it was trying to destroy some stale objects which were already deleted. So to fix this, we are now explicitly clearing the map in ClientApp::OnContextReleased() which gets triggered by CEF, just before releasing V8 context --- appshell/client_app.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/appshell/client_app.cpp b/appshell/client_app.cpp index d79c4c05f..870b421ab 100644 --- a/appshell/client_app.cpp +++ b/appshell/client_app.cpp @@ -238,6 +238,26 @@ void ClientApp::OnContextReleased(CefRefPtr browser, RenderDelegateSet::iterator it = render_delegates_.begin(); for (; it != render_delegates_.end(); ++it) (*it)->OnContextReleased(this, browser, frame, context); + + // This is to fix the crash on quit(Issue#7683) after + // integrating CEF 2171. + + // On Destruction, callback_map_ was getting destroyed + // in the ClientApp::~ClientApp(). However while removing + // all the elements, it was trying to destroy some stale + // objects which were already deleted. So to fix this, we + // are now explicitly clearing the map here. + + if (!callback_map_.empty()) { + CallbackMap::iterator it = callback_map_.begin(); + for (; it != callback_map_.end();) { + if (it->second.first->IsSame(context)) + callback_map_.erase(it++); + else + ++it; + } + } + } //Simple stack class to ensure calls to Enter and Exit are balanced From afd6ca55347250b7c7b391cd22006be39cd30aec Mon Sep 17 00:00:00 2001 From: Prashanth Nethi Date: Tue, 2 Dec 2014 12:02:23 +0530 Subject: [PATCH 2/2] Continuation of Fix for [CEF 2171] Crash on quit(https://github.com/adobe/brackets/issues/7683) This change involves some code changes got from code review comments from (https://github.com/adobe/brackets-shell/pull/487) pull request. --- appshell/client_app.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/appshell/client_app.cpp b/appshell/client_app.cpp index 870b421ab..b67ff4c34 100644 --- a/appshell/client_app.cpp +++ b/appshell/client_app.cpp @@ -239,8 +239,8 @@ void ClientApp::OnContextReleased(CefRefPtr browser, for (; it != render_delegates_.end(); ++it) (*it)->OnContextReleased(this, browser, frame, context); - // This is to fix the crash on quit(Issue#7683) after - // integrating CEF 2171. + // This is to fix the crash on quit(https://github.com/adobe/brackets/issues/7683) + // after integrating CEF 2171. // On Destruction, callback_map_ was getting destroyed // in the ClientApp::~ClientApp(). However while removing @@ -248,14 +248,12 @@ void ClientApp::OnContextReleased(CefRefPtr browser, // objects which were already deleted. So to fix this, we // are now explicitly clearing the map here. - if (!callback_map_.empty()) { - CallbackMap::iterator it = callback_map_.begin(); - for (; it != callback_map_.end();) { - if (it->second.first->IsSame(context)) - callback_map_.erase(it++); - else - ++it; - } + CallbackMap::iterator iCallBack = callback_map_.begin(); + for (; iCallBack != callback_map_.end();) { + if (iCallBack->second.first->IsSame(context)) + callback_map_.erase(iCallBack++); + else + ++iCallBack; } }