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 · 9 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.

@ValentinGrim
Copy link

ValentinGrim commented Sep 26, 2024

I'm currently experiencing the same issue.

I'm using Windows 10 Enterprise 22H2 and rfd 0.15.0.

When trying to save a file on top of an existing one, nothing happens and everything freezes.

I have more information on this: when I press Alt+F4, the dialog box asking if I want to overwrite appears and the main dialog closses correctly afterward.

Details:

...
let mut dialog = rfd::FileDialog::new().add_filter("YAML", &["yml"]);
dialog = dialog.set_title("Export YAML...");
yml_path = match dialog.save_file() {
    Some(path) => path,
    None => PathBuf::new(),
};
...

Edit :
Juste pressing Alt make the overwrite dialog appears

@ValentinGrim
Copy link

I tried to debug and ended up in rustc assembly.

Here's the last place I was before ending up into assembly :
rfd-0.15.0/src/backend/win_cid/file_dialog/dialog_ffi.rs:117

The line of code that seems to be causing the issue is:
wrap_err((v.base.Show)(d, parent.unwrap_or_default()))

@adam-jw-casey
Copy link

OS: Windows 10/11
RFD Versions Affected: Tested on 0.11.0-0.15.1


This same issue occurred for us when we upgraded iced from 0.12.1 to 0.13.1.

Calling the save_file function from an iced 0.13.0+ application causes a freeze when save is clicked, without showing the "this file exists" confirmation dialog.

Things that aren't broken:

  • Older versions of iced (<0.13.0) are unaffected
  • Calling save_file before opening the iced application or after closing it works fine
  • pick_file works fine
  • Typing the name of a file that doesn't exist into the save as dialog works fine

@petr-lesny
Copy link

I am encountering the same behavior in Windows 10/11 app uslig together slint + rfd. First use of the rfd::MessageDialog (or first message box from file dialog asking for file rewrite) is not shown. It however shows immediately when pressing Alt key. After the Alt is pressed, all subsequent message boxes show perfectly.

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

6 participants