mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 13:20:05 -04:00
Enable clippy::iter_over_hash_type lint (#7421)
This helped discover a few things that _might_ have been buggy.
This commit is contained in:
@@ -15,10 +15,11 @@ use winit::{
|
||||
window::{Window, WindowId},
|
||||
};
|
||||
|
||||
use ahash::{HashMap, HashSet, HashSetExt as _};
|
||||
use ahash::HashMap;
|
||||
use egui::{
|
||||
DeferredViewportUiCallback, FullOutput, ImmediateViewport, ViewportBuilder, ViewportClass,
|
||||
ViewportId, ViewportIdMap, ViewportIdPair, ViewportIdSet, ViewportInfo, ViewportOutput,
|
||||
DeferredViewportUiCallback, FullOutput, ImmediateViewport, OrderedViewportIdMap,
|
||||
ViewportBuilder, ViewportClass, ViewportId, ViewportIdPair, ViewportIdSet, ViewportInfo,
|
||||
ViewportOutput,
|
||||
};
|
||||
#[cfg(feature = "accesskit")]
|
||||
use egui_winit::accesskit_winit;
|
||||
@@ -72,7 +73,7 @@ pub struct SharedState {
|
||||
focused_viewport: Option<ViewportId>,
|
||||
}
|
||||
|
||||
pub type Viewports = ViewportIdMap<Viewport>;
|
||||
pub type Viewports = egui::OrderedViewportIdMap<Viewport>;
|
||||
|
||||
pub struct Viewport {
|
||||
ids: ViewportIdPair,
|
||||
@@ -80,7 +81,7 @@ pub struct Viewport {
|
||||
builder: ViewportBuilder,
|
||||
deferred_commands: Vec<egui::viewport::ViewportCommand>,
|
||||
info: ViewportInfo,
|
||||
actions_requested: HashSet<ActionRequested>,
|
||||
actions_requested: Vec<ActionRequested>,
|
||||
|
||||
/// `None` for sync viewports.
|
||||
viewport_ui_cb: Option<Arc<DeferredViewportUiCallback>>,
|
||||
@@ -679,7 +680,7 @@ impl WgpuWinitRunning<'_> {
|
||||
screenshot_commands,
|
||||
);
|
||||
|
||||
for action in viewport.actions_requested.drain() {
|
||||
for action in viewport.actions_requested.drain(..) {
|
||||
match action {
|
||||
ActionRequested::Screenshot { .. } => {
|
||||
// already handled above
|
||||
@@ -1034,10 +1035,10 @@ fn render_immediate_viewport(
|
||||
}
|
||||
|
||||
pub(crate) fn remove_viewports_not_in(
|
||||
viewports: &mut ViewportIdMap<Viewport>,
|
||||
viewports: &mut Viewports,
|
||||
painter: &mut egui_wgpu::winit::Painter,
|
||||
viewport_from_window: &mut HashMap<WindowId, ViewportId>,
|
||||
viewport_output: &ViewportIdMap<ViewportOutput>,
|
||||
viewport_output: &OrderedViewportIdMap<ViewportOutput>,
|
||||
) {
|
||||
let active_viewports_ids: ViewportIdSet = viewport_output.keys().copied().collect();
|
||||
|
||||
@@ -1050,8 +1051,8 @@ pub(crate) fn remove_viewports_not_in(
|
||||
/// Add new viewports, and update existing ones:
|
||||
fn handle_viewport_output(
|
||||
egui_ctx: &egui::Context,
|
||||
viewport_output: &ViewportIdMap<ViewportOutput>,
|
||||
viewports: &mut ViewportIdMap<Viewport>,
|
||||
viewport_output: &OrderedViewportIdMap<ViewportOutput>,
|
||||
viewports: &mut Viewports,
|
||||
painter: &mut egui_wgpu::winit::Painter,
|
||||
viewport_from_window: &mut HashMap<WindowId, ViewportId>,
|
||||
) {
|
||||
@@ -1111,6 +1112,8 @@ fn initialize_or_update_viewport<'a>(
|
||||
viewport_ui_cb: Option<Arc<dyn Fn(&egui::Context) + Send + Sync>>,
|
||||
painter: &mut egui_wgpu::winit::Painter,
|
||||
) -> &'a mut Viewport {
|
||||
use std::collections::btree_map::Entry;
|
||||
|
||||
profiling::function_scope!();
|
||||
|
||||
if builder.icon.is_none() {
|
||||
@@ -1121,7 +1124,7 @@ fn initialize_or_update_viewport<'a>(
|
||||
}
|
||||
|
||||
match viewports.entry(ids.this) {
|
||||
std::collections::hash_map::Entry::Vacant(entry) => {
|
||||
Entry::Vacant(entry) => {
|
||||
// New viewport:
|
||||
log::debug!("Creating new viewport {:?} ({:?})", ids.this, builder.title);
|
||||
entry.insert(Viewport {
|
||||
@@ -1130,14 +1133,14 @@ fn initialize_or_update_viewport<'a>(
|
||||
builder,
|
||||
deferred_commands: vec![],
|
||||
info: Default::default(),
|
||||
actions_requested: HashSet::new(),
|
||||
actions_requested: Vec::new(),
|
||||
viewport_ui_cb,
|
||||
window: None,
|
||||
egui_winit: None,
|
||||
})
|
||||
}
|
||||
|
||||
std::collections::hash_map::Entry::Occupied(mut entry) => {
|
||||
Entry::Occupied(mut entry) => {
|
||||
// Patch an existing viewport:
|
||||
let viewport = entry.get_mut();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user