@@ -6,7 +6,13 @@ use crate::{
66use egui:: { mutex:: Mutex , Align2 , DroppedFile , FontId , RichText , TextStyle } ;
77use egui_extras:: { image:: load_image_bytes, RetainedImage } ;
88
9- use std:: { cell:: RefCell , io:: Cursor , rc:: Rc } ;
9+ use std:: {
10+ cell:: RefCell ,
11+ collections:: hash_map:: DefaultHasher ,
12+ hash:: { Hash , Hasher } ,
13+ io:: Cursor ,
14+ rc:: Rc ,
15+ } ;
1016
1117#[ derive( Default ) ]
1218pub struct MetadataTool {
@@ -111,6 +117,7 @@ impl MetadataTool {
111117
112118 pub fn load_files_or_err ( & mut self , ui : & mut egui:: Ui ) {
113119 if !self . dropped_files . is_empty ( ) {
120+ let mut hasher = DefaultHasher :: new ( ) ;
114121 ui. group ( |ui| {
115122 for file in & self . dropped_files {
116123 if let Some ( bytes) = Self :: load_file_contents ( file) {
@@ -138,7 +145,12 @@ impl MetadataTool {
138145
139146 if let Ok ( raw_dmi) = dmi:: RawDmi :: load ( bytes_reader) {
140147 let new_mwin = ImageWindow {
141- id : uuid:: Uuid :: new_v4 ( ) ,
148+ id : {
149+ for chunk in & raw_dmi. chunks_idat {
150+ chunk. data . hash ( & mut hasher)
151+ }
152+ hasher. finish ( ) . to_string ( ) . into ( )
153+ } ,
142154 img : {
143155 let h = ( ui. available_height ( ) * 1.85 ) as u32 ;
144156 let w = ( ui. available_width ( ) * 1.85 ) as u32 ;
@@ -190,7 +202,7 @@ impl eframe::App for MetadataTool {
190202
191203 for mwindow in & self . windows {
192204 egui:: Window :: new ( & mwindow. metadata . file_name )
193- . id ( mwindow. id . to_string ( ) . into ( ) )
205+ . id ( mwindow. id )
194206 . open ( & mut mwindow. is_open . borrow_mut ( ) )
195207 . show ( ctx, |ui| {
196208 create_meta_viewer ( mwindow, ui, & mwindow. metadata , & tst) ;
0 commit comments