image: Check realized before using surface
This avoids crashes in early calls to scaling()
This commit is contained in:
parent
3c73c06241
commit
e387d8dc66
1 changed files with 7 additions and 3 deletions
|
|
@ -276,9 +276,13 @@ impl LpImage {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn scaling(&self) -> f64 {
|
pub fn scaling(&self) -> f64 {
|
||||||
self.native()
|
if self.is_realized() {
|
||||||
.map(|x| x.surface().scale())
|
self.native()
|
||||||
.unwrap_or_else(|| self.scale_factor() as f64)
|
.map(|x| x.surface().scale())
|
||||||
|
.unwrap_or_else(|| self.scale_factor() as f64)
|
||||||
|
} else {
|
||||||
|
1.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Monitor size in physical pixels
|
/// Monitor size in physical pixels
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue