Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Commit

Permalink
Acquire the default MainContext when initializing GTK
Browse files Browse the repository at this point in the history
It is required for GTK to be able to own the default main context on the
thread that initialized it, among other things to run its main loop on
that.

Make this more explicit by already acquiring it here during
initialization. This also ensures that other API that checks that this
very thread owns the main context works out of the box.
  • Loading branch information
sdroege committed Feb 10, 2019
1 parent 39bf01a commit 330c85f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/rt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ pub fn init() -> Result<(), glib::BoolError> {
}
unsafe {
if pre_init() && from_glib(ffi::gtk_init_check(ptr::null_mut(), ptr::null_mut())) {
if !glib::MainContext::default().acquire() {
return Err(glib_bool_error!("Failed to acquire default main context"));
}

set_initialized();
Ok(())
}
Expand Down

0 comments on commit 330c85f

Please sign in to comment.