godot icon indicating copy to clipboard operation
godot copied to clipboard

FileDialog does not emit files_selected signal when the dialog is canceled

Open Extner32 opened this issue 1 year ago • 1 comments

Tested versions

  • Reproducible in Godot v4.2.2.stable.official [15073afe3]

System information

Godot v4.2.2.stable - Windows 10.0.22631 - GLES3 (Compatibility) - AMD Radeon(TM) Vega 8 Graphics (Advanced Micro Devices, Inc.; 31.0.14057.5006) - AMD Ryzen 5 3500U with Radeon Vega Mobile Gfx (8 Threads)

Issue description

When a file dialog to select multiple files with is opened (I don't know if it the other ones have the same issue), the files_selected signal is not emit when the user presses the cancel button or closes the dialog (if it is in a separate window). This can be a problem for async functions using await (await $FileDialog.files_selected) because it will keep waiting for the signal to be called. I think it would probably be best if the signal returned an empty array if cancel is pressed or the window is closed.

It is possible to work around it by doing something like this:

func _on_file_dialog_canceled():
	$FileDialog.emit_signal("files_selected", [])

Steps to reproduce

  • start the project
  • use the file dialog to open a file
  • see that the array of selected files is printed to the output
  • restart the project
  • now click cancel or close the window
  • nothing gets printed, not even an empty array because the signal never gets emitted

Minimal reproduction project (MRP)

MRP.zip

Extner32 avatar Sep 30 '24 18:09 Extner32

Pressing "Cancel" emit canceled signal not *_selected.

bruvzg avatar Sep 30 '24 18:09 bruvzg

Ok, you could work around it like that. I'll close the issue.

Extner32 avatar Oct 06 '24 09:10 Extner32