File dialog freeze when use in JNI
SudoDios opened this issue · comments
Sudo Dios commented
Hi.
I using this on jni.
but when i choose file or cancel it, dialog is freeze.
this is my jni fn :
#[allow(non_snake_case)]
#[no_mangle]
pub extern "system" fn Java_my_package_openFilePicker<'local>(env: JNIEnv<'local>, _class: JClass<'local>) -> jstring {
let path = std::env::current_dir().unwrap();
let res = rfd::FileDialog::new()
.add_filter("image", &["jpg", "png"])
.set_directory(&path)
.pick_file();
let result = if res != None {
res.unwrap().into_os_string().into_string().unwrap()
} else {
"".to_string()
};
env.new_string(result).unwrap().into_raw()
}