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:
Vadim Zeitlin 2023-09-01 20:56:55 +02:00
parent 61cb46cbed
commit ec33980a5f

View file

@ -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;
}