Skip to content

Commit

Permalink
Fixed icy_draw crash.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrueger committed Dec 23, 2024
1 parent dafc051 commit 79a0286
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions crates/icy_draw/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ fn main() {
eprintln!("Failed to create log file");
}

unsafe { SETTINGS.character_sets = CharacterSets::default(); }
if let Ok(settings_file) = Settings::get_settings_file() {
if settings_file.exists() {
match Settings::load(&settings_file) {
Expand Down
10 changes: 8 additions & 2 deletions crates/icy_draw/src/ui/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,17 @@ impl KeyBindings {
}
}

#[derive(Default, Clone, Serialize, Deserialize, Debug)]
#[derive(Clone, Serialize, Deserialize, Debug)]
pub struct CharacterSets {
pub character_sets: Vec<CharSetMapping>,
}

impl Default for CharacterSets {
fn default() -> Self {
Self { character_sets: vec![CharSetMapping::default()] }
}
}

impl CharacterSets {
pub fn get_character_sets_file() -> TerminalResult<PathBuf> {
if let Some(proj_dirs) = ProjectDirs::from("com", "GitHub", "icy_draw") {
Expand Down Expand Up @@ -281,7 +287,7 @@ impl Settings {

// Read the JSON contents of the file as an instance of `User`.
let mut result: Settings = serde_json::from_reader(reader)?;

result.character_sets = CharacterSets::default();
if let Ok(settings_file) = CharacterSets::get_character_sets_file() {
if settings_file.exists() {
if let Ok(character_sets) = CharacterSets::load(&settings_file) {
Expand Down

0 comments on commit 79a0286

Please sign in to comment.