- Code: Select all
bool CHWindow::OnDoClose(CefRefPtr<CefBrowser> browser)
{
CEF_REQUIRE_UI_THREAD();
if (m_active_tab.m_browser_view && m_active_tab.m_browser_view->GetBrowser()->IsSame(browser))
m_active_tab = CHTab();
for (auto it = m_tabs.begin(); it != m_tabs.end(); ++it) {
auto& tab = *it;
if (tab.m_browser_view->GetBrowser()->IsSame(browser)) {
tab.m_panel->RemoveAllChildViews();
m_bottom_panel->RemoveChildView(tab.m_panel);
m_browser_panel->RemoveChildView(tab.m_browser_view);
m_tabs.erase(it);
auto browser_view = CefBrowserView::GetForBrowser(browser);
break;
}
}
if (!TSTERMINATE && !m_active_tab.m_browser_view && !m_tabs.empty())
SetActiveTab(*m_tabs.rbegin());
return true;
}
When I remove the last reference to the CefBrowserView in the m_tabs.erase(it) line, I see in the destructor that there is one more active reference to the CefBrowserView somewhere else. Because of this, the view object is not deleted. The browser itself stores it and returns it correctly in the next line of code.
Calling CloseBrowser(false) has no effect because the window_destroyed_ flag is false and the function does nothing. This is a bug.