Skip to content

Commit

Permalink
Merge pull request #4 from johannes-mueller/title_terminated_zero
Browse files Browse the repository at this point in the history
Fix a non zero terminated C string when setting the title.
  • Loading branch information
johannes-mueller authored Dec 7, 2020
2 parents 721826b + 03cae6a commit 1460402
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,13 @@ pub trait PuglViewTrait {
}

/// Sets the window title
fn set_window_title (&self, title: &str) -> Status {
unsafe { Status::from(p::puglSetWindowTitle(self.view(), title.as_ptr() as *const i8)) }
fn set_window_title(&self, title: &str) -> Status {
let title =
std::ffi::CString::new(title.as_bytes())
.expect("window title must not contain 0 bytes");
unsafe {
Status::from(p::puglSetWindowTitle(self.view(), title.into_raw()))
}
}

/// Realize a view by creating a corresponding system view or window.
Expand Down

0 comments on commit 1460402

Please sign in to comment.