Skip to content

Commit a2c95b9

Browse files
authored
Remove the limitation to a single dropped file (#3030)
### What There is a limitation to handling no more than a single dropped file over the viewer dating back from #2 😮, with a bug in error handling to boot (error was shown only for 3+ files). This PR removes that limitation, as it seems to... just work. <img width="1747" alt="image" src="https://github.com/rerun-io/rerun/assets/49431240/ef435608-d505-4dec-b713-8675df8927ce"> ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md) * [x] I've included a screenshot or gif (if applicable) * [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/3030) (if applicable) - [PR Build Summary](https://build.rerun.io/pr/3030) - [Docs preview](https://rerun.io/preview/pr%3Aantoine%2Fmulti-dropped-files/docs) - [Examples preview](https://rerun.io/preview/pr%3Aantoine%2Fmulti-dropped-files/examples)
1 parent d932084 commit a2c95b9

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

crates/re_viewer/src/app.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -814,21 +814,12 @@ impl App {
814814
fn handle_dropping_files(&mut self, store_hub: &mut StoreHub, egui_ctx: &egui::Context) {
815815
preview_files_being_dropped(egui_ctx);
816816

817-
// Collect dropped files:
818-
if egui_ctx.input(|i| i.raw.dropped_files.len()) > 2 {
819-
rfd::MessageDialog::new()
820-
.set_level(rfd::MessageLevel::Error)
821-
.set_description("Can only load one file at a time")
822-
.show();
823-
}
824-
if let Some(file) = egui_ctx.input(|i| i.raw.dropped_files.first().cloned()) {
817+
let dropped_files = egui_ctx.input_mut(|i| std::mem::take(&mut i.raw.dropped_files));
818+
for file in dropped_files {
825819
if let Some(bytes) = &file.bytes {
826820
let mut bytes: &[u8] = &(*bytes)[..];
827821
if let Some(rrd) = crate::loading::load_file_contents(&file.name, &mut bytes) {
828822
self.on_rrd_loaded(store_hub, rrd);
829-
830-
#[allow(clippy::needless_return)] // false positive on wasm32
831-
return;
832823
}
833824
}
834825

0 commit comments

Comments
 (0)