Skip to content

Commit

Permalink
Remove the limitation to a single dropped file (#3030)
Browse files Browse the repository at this point in the history
### 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)
  • Loading branch information
abey79 authored Aug 17, 2023
1 parent d932084 commit a2c95b9
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions crates/re_viewer/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -814,21 +814,12 @@ impl App {
fn handle_dropping_files(&mut self, store_hub: &mut StoreHub, egui_ctx: &egui::Context) {
preview_files_being_dropped(egui_ctx);

// Collect dropped files:
if egui_ctx.input(|i| i.raw.dropped_files.len()) > 2 {
rfd::MessageDialog::new()
.set_level(rfd::MessageLevel::Error)
.set_description("Can only load one file at a time")
.show();
}
if let Some(file) = egui_ctx.input(|i| i.raw.dropped_files.first().cloned()) {
let dropped_files = egui_ctx.input_mut(|i| std::mem::take(&mut i.raw.dropped_files));
for file in dropped_files {
if let Some(bytes) = &file.bytes {
let mut bytes: &[u8] = &(*bytes)[..];
if let Some(rrd) = crate::loading::load_file_contents(&file.name, &mut bytes) {
self.on_rrd_loaded(store_hub, rrd);

#[allow(clippy::needless_return)] // false positive on wasm32
return;
}
}

Expand Down

0 comments on commit a2c95b9

Please sign in to comment.