To resolve the issue I came up with the following, but am wondering if it is correct, or what exactly the problem was:
- Code: Select all
// Request that all existing browser windows close.
void CloseAllBrowsers(bool force_close) {
//there is a single browser right now - if i call CloseBrowser(true) instead, we get a crash later - an internal process is ongoing
mBrowser->GetHost()->TryCloseBrowser();
while (!mBrowser->HasOneRef()) { //wait for the internal process to finish
CefDoMessageLoopWork();
}
mBrowser = NULL; //destroy browser
//from here we proceed to CefShutdown
}
void OnAfterCreated(CefRefPtr<CefBrowser> browser) override {
CEF_REQUIRE_UI_THREAD();
mBrowser = browser;
}
bool DoClose(CefRefPtr<CefBrowser> browser) {
CEF_REQUIRE_UI_THREAD();
return false;
}
virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) override {
CEF_REQUIRE_UI_THREAD();
}
Am I doing something wrong, or is this correct?