Skip to content

Commit

Permalink
[DanglingPtr] Fix WebUIBubbleManagerImpl dangling patch (#26465)
Browse files Browse the repository at this point in the history
A patch was added to `WebUIBubbleManagerImpl` when enabling the dangling
pointer detector on Linux, as a temporary measure. This change corrects
the the underlying issue requiring this pointer to be marked as
dangling.

This particular dangling pointer occurred because the toolbar view was
being passed as the achor for this browser data bubbles, the toolbar
gets destroyed prior to these browser data bubbles being disposed. This
PR adds checks during in the `BraveBrowserView` dtor, to make sure there
are no dangling references to the toolbar view by the time the
termination is cleaning up browser data.

Resolves brave/brave-browser#42196
  • Loading branch information
cdesouza-chromium authored Nov 11, 2024
1 parent e35a934 commit ec97acd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
12 changes: 12 additions & 0 deletions browser/ui/views/frame/brave_browser_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,18 @@ void BraveBrowserView::UpdateSearchTabsButtonState() {

BraveBrowserView::~BraveBrowserView() {
tab_cycling_event_handler_.reset();
// Removes the bubble from the browser, as it uses the `ToolbarView` as an
// archor, and that leaves a dangling reference once the `TopContainerView` is
// destroyed before all `SupportsUserData` is cleared.
if (brave_shields::CookieListOptInBubbleHost::FromBrowser(browser_.get())) {
brave_shields::CookieListOptInBubbleHost::RemoveFromBrowser(browser_.get());
}

// Same as above.
if (brave_rewards::TipPanelBubbleHost::FromBrowser(browser_.get())) {
brave_rewards::TipPanelBubbleHost::RemoveFromBrowser(browser_.get());
}

DCHECK(!tab_cycling_event_handler_);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/chrome/browser/ui/views/bubble/webui_bubble_manager.h b/chrome/browser/ui/views/bubble/webui_bubble_manager.h
index edd7d37a12e182cc663db4e565b8a9edb12e0c70..043ec6578181c02b4bad4d59769287cee6f91907 100644
index edd7d37a12e182cc663db4e565b8a9edb12e0c70..e90187359fc82f33135212fb627ac07d495076d0 100644
--- a/chrome/browser/ui/views/bubble/webui_bubble_manager.h
+++ b/chrome/browser/ui/views/bubble/webui_bubble_manager.h
@@ -165,11 +165,13 @@ class WebUIBubbleManagerImpl : public WebUIBubbleManager {
@@ -165,9 +165,11 @@ class WebUIBubbleManagerImpl : public WebUIBubbleManager {

private:
// WebUIBubbleManager:
Expand All @@ -12,8 +12,5 @@ index edd7d37a12e182cc663db4e565b8a9edb12e0c70..043ec6578181c02b4bad4d59769287ce
views::BubbleBorder::Arrow arrow) override;
+ private:

- const raw_ptr<views::View> anchor_view_;
+ const raw_ptr<views::View, DanglingUntriaged> anchor_view_;
const raw_ptr<views::View> anchor_view_;
const raw_ptr<Profile, DanglingUntriaged> profile_;
const GURL webui_url_;
const int task_manager_string_id_;

0 comments on commit ec97acd

Please sign in to comment.