Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(linux): call gtk_init to fix tauri-apps/tauri#11312 #1036

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changes/explicit_gtk_init.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"tao": patch
---

Explicitly call `gtk::init()` as `gtk::Application::new` does not call it reliably.
If `gtk::init()` is not called, 'GTK may only be used from the main thread' error can occur later.
`gtk::init()` checks if already initialized and does nothing if so.
2 changes: 2 additions & 0 deletions src/platform_impl/linux/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ impl<T: 'static> EventLoop<T> {
}

fn new_gtk(app_id: Option<&str>) -> Result<EventLoop<T>, Box<dyn Error>> {
// This should be done by gtk::Application::new, but does not work properly
gtk::init()?;
let context = MainContext::default();
let app = gtk::Application::new(app_id, gio::ApplicationFlags::empty());
let app_ = app.clone();
Expand Down
Loading