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

File dialog freeze when use in JNI #169

Open
SudoDios opened this issue Jan 31, 2024 · 0 comments
Open

File dialog freeze when use in JNI #169

SudoDios opened this issue Jan 31, 2024 · 0 comments

Comments

@SudoDios
Copy link

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()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant