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

Save Dialog locks up when selecting an Existing File and clicking the Save button. (Windows 10) #164

Open
Munjen opened this issue Dec 6, 2023 · 5 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@Munjen
Copy link

Munjen commented Dec 6, 2023

Hello! I posted this issue to the slint repository but now after testing with Linux it seems more likely that the problem is in the RFD crate.
I'm using the rfd crate to create a Save Dialog for my slint application on Windows 10.
The Save Dialog works perfectly except when I select an existing file and click the save button (on the save dialog).
The Save Dialog stays open and both the Slint UI and the Save Dialog lock up refusing to respond to buttons and controls.
Nothing can stop the process except 'kill terminal' in VSCode.

A simple test project with just the rfd crate ...and Save Dialog works fine.
The overwrite file message box opens and the Save Dialog closes if user responds to 'Overwrite existing file?' with 'Yes' as expected!

I put the rfd code inside a closure that runs when a slint save button is pressed
I'm not 100% sure if this is some bug in slint, rfd or am I doing something incorrectly?

Today I tried compiling on Linux Mint 21.2, Cinnamon v5.8.4, Linux Kernel: 5.15.0-88-generic.
On Linux everything works fine, No issues at all! I will post this issue to RFD git as well because now it seems more likely that the problem is coming from the rfd crate.

main_window.on_save_pressed(move |x, y| {
        let file = match save_dialog() {
            Some(s) => s,
            None => return,
        };

       //... doing stuff with the returned string...
       //... doing stuff with x, y parameters...
       //... doing stuff with a weak pointer to main_window...
});

use rfd::FileDialog;
fn save_dialog() -> Option<String> {
    let file = FileDialog::new()
        .set_file_name("Output.exr")
        .add_filter("Open EXR", &["exr"])
        .set_title("Save As 32bit EXR")
        .save_file();

    match file {
        Some(f) => Some(f.into_os_string().into_string().unwrap()),
        None => None,
    }
}
@Munjen
Copy link
Author

Munjen commented Dec 15, 2023

With my limited skills I tried to run in debug mode with VSCode and the farthest I can trace it are these two functions:
rfd-0.12.1\src\backend\win_cid\utils.rs --> init_com function on line 28. calls
rfd-0.12.1\src\backend\win_cid\file_dialog.rs --> line 106: impl FileSaveDialogImpl for FileDialog --> line 111: dialog.show()?;

The dialog opens on line 111 and becomes interactive. But after pressing save to overwrite an existing file everything freezes. Probably it is some unsafe interface with windows API or something causing the problem?

@PolyMeilex PolyMeilex added bug Something isn't working help wanted Extra attention is needed labels Dec 15, 2023
@Sandvoxel
Copy link

Ill add that this is also a issue on windows 11. It seems almost random when it decides to do it as I have gotten it to work only to relaunch and have it not work.

@Sandvoxel
Copy link

Sandvoxel commented Mar 8, 2024

@Munjen I did some experimentation an it seems like this bug was introduced on 0.13.0 as 0.12.1 dose not have the issue

@PolyMeilex
Copy link
Owner

There was no windows backend changes bettwen those versions: 0.12.1...0.13.0 😄

The only thing that could affect anything windows related is the cargo lock changes, but I don't see anything obvious in there.

@Sandvoxel
Copy link

There was no windows backend changes bettwen those versions: 0.12.1...0.13.0 😄

The only thing that could affect anything windows related is the cargo lock changes, but I don't see anything obvious in there.

My mistake I just went back and tested again and it seems to go back to 0.11.4 (Just where I happened to stop). Unsure what is causing the lockup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants