Wait until events are dispatched when closing the browser window
Otherwise our callbacks might not be called in time and some objects could still exist when CefShutdown() was called on program exit, resulting in assertion failures in debug CEF builds.
This commit is contained in:
parent
61cb46cbed
commit
ec33980a5f
1 changed files with 10 additions and 2 deletions
|
|
@ -384,11 +384,17 @@ wxWebViewChromium::~wxWebViewChromium()
|
|||
{
|
||||
wxLogTrace(TRACE_CEF, "closing browser");
|
||||
|
||||
// Preserve the original pointer.
|
||||
const auto clientHandler = m_clientHandler;
|
||||
|
||||
constexpr bool forceClose = true;
|
||||
m_clientHandler->GetBrowser()->GetHost()->CloseBrowser(forceClose);
|
||||
|
||||
m_clientHandler->Release();
|
||||
m_clientHandler = nullptr;
|
||||
// This should be set to nullptr from ClientHandler::DoClose().
|
||||
while ( m_clientHandler )
|
||||
CefDoMessageLoopWork();
|
||||
|
||||
clientHandler->Release();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -859,6 +865,8 @@ bool ClientHandler::DoClose(CefRefPtr<CefBrowser> WXUNUSED(browser))
|
|||
{
|
||||
TRACE_CEF_FUNCTION();
|
||||
|
||||
m_webview.m_clientHandler = nullptr;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue