Skip to content

Commit

Permalink
fix icon loading
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Sep 11, 2023
1 parent 3cafe9a commit 0829e83
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions core/tauri-codegen/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,15 +470,20 @@ fn ico_icon<P: AsRef<Path>>(
let width = entry.width();
let height = entry.height();

let out_path = out_dir.join(path.file_name().unwrap());
let icon_file_name = path.file_name().unwrap();
let out_path = out_dir.join(icon_file_name);
write_if_changed(&out_path, &rgba).map_err(|error| EmbeddedAssetsError::AssetWrite {
path: path.to_owned(),
error,
})?;

let out_path = out_path.display().to_string();

let icon = quote!(Some(#root::Icon::Rgba { rgba: include_bytes!(#out_path).to_vec(), width: #width, height: #height }));
let icon_file_name = icon_file_name.to_str().unwrap();
let icon = quote!(Some(
#root::Icon::Rgba {
rgba: include_bytes!(concat!(std::env!("OUT_DIR"), "/", #icon_file_name)).to_vec(),
width: #width,
height: #height
}));
Ok(icon)
}

Expand Down Expand Up @@ -528,16 +533,17 @@ fn png_icon<P: AsRef<Path>>(
let width = reader.info().width;
let height = reader.info().height;

let out_path = out_dir.join(path.file_name().unwrap());
let icon_file_name = path.file_name().unwrap();
let out_path = out_dir.join(icon_file_name);
write_if_changed(&out_path, &buffer).map_err(|error| EmbeddedAssetsError::AssetWrite {
path: path.to_owned(),
error,
})?;

let icon_path = path.file_name().unwrap().to_str().unwrap().to_string();
let icon_file_name = icon_file_name.to_str().unwrap();
let icon = quote!(Some(
#root::Icon::Rgba {
rgba: include_bytes!(#icon_path).to_vec(),
rgba: include_bytes!(concat!(std::env!("OUT_DIR"), "/", #icon_file_name)).to_vec(),
width: #width,
height: #height,
}
Expand Down

0 comments on commit 0829e83

Please sign in to comment.