Windows: Fix DCHECKs during shutdown with multi-threaded message loop mode (issue #2362)

This commit is contained in:
Marshall Greenblatt
2018-09-06 17:32:01 +02:00
parent 869efa155f
commit 0401e6b912
3 changed files with 41 additions and 4 deletions

View File

@@ -13,6 +13,7 @@
#include "libcef/renderer/content_renderer_client.h"
#include "libcef/utility/content_utility_client.h"
#include "base/at_exit.h"
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
@@ -281,6 +282,14 @@ class CefUIThread : public base::Thread {
browser_runner_->Shutdown();
browser_runner_.reset(NULL);
// Release MessagePump resources registered with the AtExitManager.
base::MessageLoop* ml = const_cast<base::MessageLoop*>(message_loop());
base::MessageLoopCurrent::UnbindFromCurrentThreadInternal(ml);
ml->ReleasePump();
// Run exit callbacks on the UI thread to avoid sequence check failures.
base::AtExitManager::ProcessCallbacksNow();
#if defined(OS_WIN)
// Closes the COM library on the current thread. CoInitialize must
// be balanced by a corresponding call to CoUninitialize.
@@ -635,13 +644,14 @@ void CefMainDelegate::ShutdownBrowser() {
browser_runner_->Shutdown();
browser_runner_.reset(NULL);
}
message_loop_.reset();
if (ui_thread_.get()) {
// Blocks until the thread has stopped.
ui_thread_->Stop();
ui_thread_.reset();
}
message_loop_.reset();
}
void CefMainDelegate::InitializeResourceBundle() {