From 265a733807d886fcc00059b2cd45a07966953057 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Tue, 15 Oct 2024 15:43:02 -0400 Subject: [PATCH] views: Fix dangling raw_ptr on CefToolbarViewView destruction --- libcef/browser/chrome/views/chrome_browser_view.cc | 7 +++++++ libcef/browser/chrome/views/chrome_browser_view.h | 1 + 2 files changed, 8 insertions(+) diff --git a/libcef/browser/chrome/views/chrome_browser_view.cc b/libcef/browser/chrome/views/chrome_browser_view.cc index b6a3b5889..96a9b44eb 100644 --- a/libcef/browser/chrome/views/chrome_browser_view.cc +++ b/libcef/browser/chrome/views/chrome_browser_view.cc @@ -11,6 +11,13 @@ ChromeBrowserView::ChromeBrowserView(CefBrowserViewImpl* cef_browser_view) : ParentClass(cef_browser_view->delegate()), cef_browser_view_(cef_browser_view) {} +ChromeBrowserView::~ChromeBrowserView() { + if (cef_toolbar_) { + WillDestroyToolbar(); + cef_toolbar_ = nullptr; + } +} + void ChromeBrowserView::InitBrowser(std::unique_ptr browser) { DCHECK(!web_view_); diff --git a/libcef/browser/chrome/views/chrome_browser_view.h b/libcef/browser/chrome/views/chrome_browser_view.h index 36899d2ba..404d61d80 100644 --- a/libcef/browser/chrome/views/chrome_browser_view.h +++ b/libcef/browser/chrome/views/chrome_browser_view.h @@ -30,6 +30,7 @@ class ChromeBrowserView // |cef_browser_view| is non-nullptr and will outlive this object. explicit ChromeBrowserView(CefBrowserViewImpl* cef_browser_view); + ~ChromeBrowserView() override; ChromeBrowserView(const ChromeBrowserView&) = delete; ChromeBrowserView& operator=(const ChromeBrowserView&) = delete;