util/root: Log source location of call without root

This commit is contained in:
Sophie Herold 2025-12-09 14:55:14 +01:00
parent 70adf7597b
commit 3e69dc4c6f
2 changed files with 5 additions and 2 deletions

View file

@ -0,0 +1 @@
Track the location in source code of errors trying to get the root window.

View file

@ -20,13 +20,15 @@ use gtk::prelude::*;
use crate::widgets::{LpEditWindow, LpWindow}; use crate::widgets::{LpEditWindow, LpWindow};
pub trait ParentWindow: WidgetExt { pub trait ParentWindow: WidgetExt {
#[track_caller]
fn window(&self) -> LpWindow { fn window(&self) -> LpWindow {
let result = self.root().and_downcast(); let result = self.root().and_downcast();
if result.is_none() { if result.is_none() {
log::error!( log::error!(
"Couldn't find LpWindow for {self:?}. mapped={}", "Couldn't find LpWindow for {self:?}. mapped={}. caller={}",
self.is_mapped() self.is_mapped(),
std::panic::Location::caller(),
); );
} }