Replace gtk3 with gtk4#319
Conversation
|
GTK does not support multithreading, so those changes seem to be untested, and will most likely simply panic on threading assertions at runtime. |
|
Hi @PolyMeilex , how to test GTK4 with multithreading ? I run examples with GTK4 feature and they seemed okay. |
|
My guess is that simply opening the async dialog more than once during the same process lifetime should do the trick, and cause the process to blow up in one way or another. So either open 2 dialogs, or open one and the next one once the first one is done. |
|
Modified async example to open 2 dialogs in sequence Yes it crashed with GTK. I'll try to fix the async code. fn main() {
// Spawn dialog on main thread
let task1 = rfd::AsyncFileDialog::new().pick_file();
let task2 = rfd::AsyncFileDialog::new().pick_file();
// Await somewhere else
execute(async {
let file = task1.await;
if let Some(file) = file {
// If you are on native platform you can just get the path
#[cfg(not(target_arch = "wasm32"))]
println!("{:?}", file.path());
// If you care about wasm support you just read() the file
file.read().await;
}
let file = task2.await;
if let Some(file) = file {
// If you are on native platform you can just get the path
#[cfg(not(target_arch = "wasm32"))]
println!("{:?}", file.path());
// If you care about wasm support you just read() the file
file.read().await;
}
});
std::thread::park();
}
use std::future::Future;
#[cfg(not(target_arch = "wasm32"))]
fn execute<F: Future<Output = ()> + Send + 'static>(f: F) {
// this is stupid... use any executor of your choice instead
std::thread::spawn(move || futures::executor::block_on(f));
}
#[cfg(target_arch = "wasm32")]
fn execute<F: Future<Output = ()> + 'static>(f: F) {
wasm_bindgen_futures::spawn_local(f);
} |
e3a89e9 to
4f47bd2
Compare
|
Hi @PolyMeilex , I think the GTK multithreading issue is fixed. And updated async test to check this. |
Fixed following message: Gtk-Message: 15:22:02.779: GtkDialog mapped without a transient parent. This is discouraged.
Now the async test can check API in multithreading.
4f47bd2 to
1e9c03f
Compare
Fixed #227