Skip to content

Commit

Permalink
Merge pull request #22975 from brave/sko/split-view-crash
Browse files Browse the repository at this point in the history
Don't observe SplitViewBrowserData repeatedly
  • Loading branch information
sangwoo108 authored Apr 9, 2024
2 parents 7953e91 + a68fe53 commit 3ef4970
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions browser/ui/views/tabs/brave_tab_container.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "chrome/browser/ui/layout_constants.h"
#include "chrome/browser/ui/tabs/tab_style.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/views/tabs/tab_container.h"
#include "chrome/browser/ui/views/tabs/tab_drag_controller.h"
#include "chrome/grit/theme_resources.h"
#include "third_party/skia/include/core/SkColor.h"
Expand Down Expand Up @@ -100,11 +101,19 @@ base::OnceClosure BraveTabContainer::LockLayout() {
}

void BraveTabContainer::AddedToWidget() {
TabContainerImpl::AddedToWidget();

if (base::FeatureList::IsEnabled(tabs::features::kBraveSplitView)) {
auto* split_view_data = SplitViewBrowserData::FromBrowser(
const_cast<Browser*>(tab_slot_controller_->GetBrowser()));
CHECK(split_view_data);
split_view_data_observation_.Observe(split_view_data);
if (!split_view_data) {
// Can be null if browser isn't normal type browser.
return;
}

if (!split_view_data_observation_.IsObserving()) {
split_view_data_observation_.Observe(split_view_data);
}
}
}

Expand Down

0 comments on commit 3ef4970

Please sign in to comment.