mirror of
https://github.com/Zenithsiz/dcb.git
synced 2026-02-04 00:21:57 +00:00
Fixed panic on PreviewPanel::drop.
This commit is contained in:
parent
a3aa4bc1fc
commit
dbbb888f7f
@ -88,6 +88,7 @@ impl epi::App for FileEditor {
|
||||
egui::menu::menu(ui, "File", |ui| {
|
||||
// On open, ask the user and open the file
|
||||
if ui.button("Open").clicked() {
|
||||
// Ask the user for the file
|
||||
let cur_dir_path = std::env::current_dir().expect("Unable to get current directory path");
|
||||
*file_path = FileDialog::new()
|
||||
.set_location(&cur_dir_path)
|
||||
@ -174,6 +175,12 @@ impl epi::App for FileEditor {
|
||||
}
|
||||
|
||||
fn on_exit(&mut self) {
|
||||
// Forget all images we have
|
||||
// TODO: Somehow get a frame here to drop them?
|
||||
if let Some(preview_panel) = &mut self.preview_panel {
|
||||
preview_panel.forget_textures();
|
||||
}
|
||||
|
||||
// Flush the file if we have it
|
||||
if let Some(loaded_game) = &mut self.loaded_game {
|
||||
match loaded_game.game_file_mut().cdrom().flush() {
|
||||
|
||||
@ -105,6 +105,19 @@ impl PreviewPanel {
|
||||
}
|
||||
}
|
||||
|
||||
/// Forgets all textures in this panel without freeing them
|
||||
pub fn forget_textures(&mut self) {
|
||||
match self {
|
||||
PreviewPanel::Tim { pallettes, .. } => {
|
||||
pallettes.drain(..);
|
||||
},
|
||||
PreviewPanel::Tis { images } => {
|
||||
images.drain(..);
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
/// Displays this panel
|
||||
pub fn display(&self, ctx: &egui::CtxRef) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| match self {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user