From 69c6314a325f9dfd7f027d8d4445e7ee7de06934 Mon Sep 17 00:00:00 2001 From: Prashanth Nethi Date: Tue, 9 Dec 2014 19:40:10 +0530 Subject: [PATCH 1/2] Fix for crash on quit w.r.t any web worker still running during quit. ( [CEF 2171] Crash on quit. #7683 ) This fixes the crash with web workers still running while quitting the main Brackets app. CefQuitMessageLoop() needs to be called for the CEF message loop to quit gracefully. This change involves removing handling of WM_DESTROY and doing the same in ClientHandler::OnBeforeClose(). --- appshell/cef_main_window.cpp | 10 +--------- appshell/cef_main_window.h | 1 - appshell/client_handler.cpp | 9 +++++++++ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/appshell/cef_main_window.cpp b/appshell/cef_main_window.cpp index afc9beb29..1909b55c8 100644 --- a/appshell/cef_main_window.cpp +++ b/appshell/cef_main_window.cpp @@ -220,13 +220,6 @@ BOOL cef_main_window::HandleGetMinMaxInfo(LPMINMAXINFO mmi) return TRUE; } -// WM_DESTROY handler -BOOL cef_main_window::HandleDestroy() -{ - ::PostQuitMessage(0); - return TRUE; -} - // WM_CLOSE handler BOOL cef_main_window::HandleClose() { @@ -505,8 +498,7 @@ LRESULT cef_main_window::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) return 0L; break; case WM_DESTROY: - if (HandleDestroy()) - return 0L; + return 0L; // Do not handle the destroy here. break; case WM_CLOSE: if (HandleClose()) diff --git a/appshell/cef_main_window.h b/appshell/cef_main_window.h index 2f441d8fa..a23f798c0 100644 --- a/appshell/cef_main_window.h +++ b/appshell/cef_main_window.h @@ -52,7 +52,6 @@ class cef_main_window : public cef_host_window BOOL HandleEraseBackground(HDC hdc); BOOL HandleCreate(); BOOL HandleSetFocus(HWND hLosingFocus); - BOOL HandleDestroy(); BOOL HandleClose(); BOOL HandleInitMenuPopup(HMENU hMenuPopup); BOOL HandleCommand(UINT commandId); diff --git a/appshell/client_handler.cpp b/appshell/client_handler.cpp index 417d5b78d..f299411f4 100644 --- a/appshell/client_handler.cpp +++ b/appshell/client_handler.cpp @@ -188,7 +188,16 @@ void ClientHandler::OnBeforeClose(CefRefPtr browser) { } if (m_quitting) { + // Changed the logic to call CefQuitMesaageLoop() + // for windows as it was crashing with 2171 CEF. +#if defined(OS_WIN) + if(HasWindows()) + DispatchCloseToNextBrowser(); + else + CefQuitMessageLoop(); +#else DispatchCloseToNextBrowser(); +#endif } } From 5476e40698a8be52c4f8dfcbb08e98987390bafb Mon Sep 17 00:00:00 2001 From: RaymondLim Date: Tue, 9 Dec 2014 14:30:23 -0800 Subject: [PATCH 2/2] Don't limit `CefQuitMessageLoop()` call to Windows only. CefClient test app calls it on other platforms and we should do the same thing on quit. --- appshell/client_handler.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/appshell/client_handler.cpp b/appshell/client_handler.cpp index f299411f4..71542f98d 100644 --- a/appshell/client_handler.cpp +++ b/appshell/client_handler.cpp @@ -188,16 +188,12 @@ void ClientHandler::OnBeforeClose(CefRefPtr browser) { } if (m_quitting) { - // Changed the logic to call CefQuitMesaageLoop() - // for windows as it was crashing with 2171 CEF. -#if defined(OS_WIN) - if(HasWindows()) + // Changed the logic to call CefQuitMesaageLoop() + // for windows as it was crashing with 2171 CEF. + if (HasWindows()) DispatchCloseToNextBrowser(); else CefQuitMessageLoop(); -#else - DispatchCloseToNextBrowser(); -#endif } }