Skip to content

Commit

Permalink
fix(linux): crash on set size APIs (#802)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog authored Oct 16, 2023
1 parent 71d744c commit d471ea7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changes/fix-set-size-linux.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tao": patch:bug
---

Fixes set size APIs crashing on Linux.
16 changes: 8 additions & 8 deletions src/platform_impl/linux/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,11 +385,11 @@ impl Window {
.to_physical(self.scale_factor.load(Ordering::Acquire) as f64)
}

fn set_size_constraints(&self) {
if let Err(e) = self.window_requests_tx.send((
self.window_id,
WindowRequest::SizeConstraints(*self.inner_size_constraints.borrow()),
)) {
fn set_size_constraints(&self, constraints: WindowSizeConstraints) {
if let Err(e) = self
.window_requests_tx
.send((self.window_id, WindowRequest::SizeConstraints(constraints)))
{
log::warn!("Fail to send size constraint request: {}", e);
}
}
Expand All @@ -398,19 +398,19 @@ impl Window {
let mut size_constraints = self.inner_size_constraints.borrow_mut();
size_constraints.min_width = size.map(|s| s.width());
size_constraints.min_height = size.map(|s| s.height());
self.set_size_constraints()
self.set_size_constraints(*size_constraints)
}

pub fn set_max_inner_size(&self, size: Option<Size>) {
let mut size_constraints = self.inner_size_constraints.borrow_mut();
size_constraints.max_width = size.map(|s| s.width());
size_constraints.max_height = size.map(|s| s.height());
self.set_size_constraints()
self.set_size_constraints(*size_constraints)
}

pub fn set_inner_size_constraints(&self, constraints: WindowSizeConstraints) {
*self.inner_size_constraints.borrow_mut() = constraints;
self.set_size_constraints()
self.set_size_constraints(constraints)
}

pub fn set_title(&self, title: &str) {
Expand Down

0 comments on commit d471ea7

Please sign in to comment.