URI: 
       Fixed deadlock in palette switcher. - icy_draw - icy_draw is the successor to mystic draw. fork / mirror
  HTML git clone https://git.drkhsh.at/icy_draw.git
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit de427af032a0b4c6f652ad52229ce027db256cb4
   DIR parent c5e7c874fb1772758659faae0d90f94763230715
  HTML Author: Mike Krüger <mkrueger@posteo.de>
       Date:   Thu,  7 Sep 2023 20:39:35 +0200
       
       Fixed deadlock in palette switcher.
       
       Diffstat:
         M src/ui/dialogs/export_file_dialog/… |      10 ++++++----
         M src/ui/main_window.rs               |       6 +++---
         M src/ui/messages.rs                  |      13 ++++++-------
       
       3 files changed, 15 insertions(+), 14 deletions(-)
       ---
   DIR diff --git a/src/ui/dialogs/export_file_dialog/mod.rs b/src/ui/dialogs/export_file_dialog/mod.rs
       @@ -7,7 +7,7 @@ use egui_modal::Modal;
        use i18n_embed_fl::fl;
        use icy_engine::{Rectangle, SaveOptions, TextPane};
        
       -use crate::{AnsiEditor, ModalDialog, TerminalResult, Message};
       +use crate::{AnsiEditor, Message, ModalDialog, TerminalResult};
        
        mod ansi;
        mod artworx;
       @@ -155,12 +155,14 @@ impl ModalDialog for ExportFileDialog {
                                            err
                                        ))));
                                    }
       -                        },
       +                        }
                                None => {
       -                            return Ok(Some(Message::ShowError("Failed to save image".to_string())));
       +                            return Ok(Some(Message::ShowError(
       +                                "Failed to save image".to_string(),
       +                            )));
                                }
                            }
       -                        
       +
                            return Ok(None);
                        }
                    }
   DIR diff --git a/src/ui/main_window.rs b/src/ui/main_window.rs
       @@ -437,13 +437,12 @@ impl eframe::App for MainWindow {
                    })
                    .show_animated(ctx, self.left_panel, |ui| {
                        ui.add_space(8.0);
       -
       +                let mut msg = None;
                        let mut palette: usize = self.palette_mode;
                        if let Some(doc) = self.get_active_document() {
                            if let Some(editor) = doc.lock().unwrap().get_ansi_editor() {
                                ui.vertical_centered(|ui| {
       -                            let msg = crate::palette_switcher(ctx, ui, editor);
       -                            self.handle_message(msg);
       +                            msg = crate::palette_switcher(ctx, ui, editor);
                                });
                                ui.add_space(8.0);
                                ui.horizontal(|ui| {
       @@ -475,6 +474,7 @@ impl eframe::App for MainWindow {
                            }
                        }
                        self.palette_mode = palette;
       +                self.handle_message(msg);
        
                        crate::add_tool_switcher(ctx, ui, self);
                        if let Some(tool) = self
   DIR diff --git a/src/ui/messages.rs b/src/ui/messages.rs
       @@ -671,7 +671,6 @@ impl MainWindow {
                            let caret = bv.get_caret_mut();
                            caret.set_foreground(bg);
                            caret.set_background(fg);
       -
                            None
                        });
                    }
       @@ -688,12 +687,12 @@ impl MainWindow {
        
                    Message::ToggleColor => {
                        self.run_editor_command(0, |_, editor, _| {
       -                    let bv = &mut editor.buffer_view.lock();
       -                    let caret = bv.get_caret_mut();
       -                    let fg = caret.get_attribute().get_foreground();
       -                    let bg = caret.get_attribute().get_background();
       -                    caret.set_foreground(bg);
       -                    caret.set_background(fg);
       +                    let mut attr = editor.buffer_view.lock().get_caret().get_attribute();
       +                    let fg = attr.get_foreground();
       +                    let bg = attr.get_background();
       +                    attr.set_foreground(bg);
       +                    attr.set_background(fg);
       +                    editor.buffer_view.lock().get_caret_mut().set_attr(attr);
                            None
                        });
                    }