Skip to content

Commit

Permalink
move fn
Browse files Browse the repository at this point in the history
  • Loading branch information
Its-Just-Nans committed Jun 21, 2024
1 parent db4b27c commit ce512ec
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
18 changes: 17 additions & 1 deletion crates/eframe/src/web/app_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,26 @@ impl AppRunner {
);
}
}

self.handle_platform_output(platform_output);
self.textures_delta.append(textures_delta);
self.clipped_primitives = Some(self.egui_ctx.tessellate(shapes, pixels_per_point));
self.drop_files();
}

fn drop_files(&mut self) {
/// dropped_files always empty
log::debug!("Dropped files: {:?}", self.input.raw.dropped_files.len());
if !self.input.raw.dropped_files.is_empty() {
for mut dropped_file in self.input.raw.dropped_files.drain(..) {
if let Some(stream_url) = dropped_file.stream_url {
log::debug!("Revoking url {:?}", stream_url);
if *dropped_file.need_drop_url {
let _ = web_sys::Url::revoke_object_url(&stream_url);
dropped_file.need_drop_url = false.into();
}
}
}
}
}

/// Paint the results of the last call to [`Self::logic`].
Expand Down
14 changes: 0 additions & 14 deletions crates/eframe/src/web/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,12 @@ pub(crate) fn paint_and_schedule(runner_ref: &WebRunner) -> Result<(), JsValue>
// Only paint and schedule if there has been no panic
if let Some(mut runner_lock) = runner_ref.try_lock() {
paint_if_needed(&mut runner_lock);
drop_files(&mut runner_lock);
drop(runner_lock);
runner_ref.request_animation_frame()?;
}
Ok(())
}

fn drop_files(runner: &mut AppRunner) {
if !runner.input.raw.dropped_files.is_empty() {
for mut dropped_file in runner.input.raw.dropped_files.drain(..) {
if let Some(stream_url) = dropped_file.stream_url {
if *dropped_file.need_drop_url {
let _ = web_sys::Url::revoke_object_url(&stream_url);
dropped_file.need_drop_url = false.into();
}
}
}
}
}

fn paint_if_needed(runner: &mut AppRunner) {
if runner.needs_repaint.needs_repaint() {
if runner.has_outstanding_paint_data() {
Expand Down
4 changes: 1 addition & 3 deletions crates/egui_demo_app/src/wrap_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,9 +496,7 @@ impl WrapApp {

ui.label(info);
#[cfg(target_arch = "wasm32")]
if file.stream_url.is_some()
&& ui.button("Read file (output in console)").clicked()
{
if file.stream_url.is_some() {
let mut one_file = file.clone();
let func = async move {
let res = eframe::web::get_data(&mut one_file);
Expand Down

0 comments on commit ce512ec

Please sign in to comment.