Skip to content

Commit 53e9b59

Browse files
committed
Don't update domain color in custom theme to fix crash
1 parent 043d563 commit 53e9b59

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/widgets/window.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ impl Window {
294294
"notify::url",
295295
false,
296296
clone!(@weak self as this => @default-panic, move |_| {
297-
this.set_special_color_from_hash();
297+
this.update_domain_color();
298298
let bar = this.active_url_bar();
299299
if bar.focus_child().is_none() {
300300
bar.set_text(&this.url());
@@ -325,7 +325,7 @@ impl Window {
325325

326326
adw::StyleManager::default().connect_dark_notify(
327327
clone!(@weak self as this => @default-panic, move |_| {
328-
this.set_special_color_from_hash();
328+
this.update_domain_color()
329329
}),
330330
);
331331

@@ -572,7 +572,7 @@ impl Window {
572572
fn inner_tab(&self, tab: &adw::TabPage) -> Tab {
573573
tab.child().downcast().unwrap()
574574
}
575-
fn set_special_color_from_hash(&self) {
575+
fn try_update_domain_color(&self) -> anyhow::Result<()> {
576576
let imp = self.imp();
577577
let url = imp.url.borrow();
578578
let url = if let Ok(domain) = Url::parse(&url) {
@@ -617,9 +617,18 @@ impl Window {
617617
imp.style_provider
618618
.borrow()
619619
.load_from_data(stylesheet.as_bytes());
620-
// FIXME: Should add a method on `Tab`...
621-
self.current_tab()
622-
.set_link_color(&self.style_context().lookup_color("accent_color").unwrap());
620+
621+
let accent_color = &self
622+
.style_context()
623+
.lookup_color("accent_color")
624+
.context("looking up accent_color")?;
625+
self.current_tab().set_link_color(accent_color);
626+
Ok(())
627+
}
628+
fn update_domain_color(&self) {
629+
if let Err(e) = self.try_update_domain_color() {
630+
warn!("Error setting custom domain color: {}", e);
631+
}
623632
}
624633

625634
fn is_small_screen(&self) -> bool {

0 commit comments

Comments
 (0)