Skip to content

Commit

Permalink
Generate RT_GROUP_ICON id before ICON ids
Browse files Browse the repository at this point in the history
This ensures the group icon always has a consistent ID that can be used by the application to find the icon, even when the ico file itself contains a different number of resolution variations.
  • Loading branch information
tmm1 committed Nov 4, 2017
1 parent d9adecf commit 73fc896
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions icon.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ func addIcon(coff *coff.Coff, fname string, newID <-chan uint16) error {
Type: 1, // magic num.
Count: uint16(len(icons)),
}}
gid := <-newID
for _, icon := range icons {
id := <-newID
r := io.NewSectionReader(f, int64(icon.ImageOffset), int64(icon.BytesInRes))
coff.AddResource(rtIcon, id, r)
group.Entries = append(group.Entries, gRPICONDIRENTRY{IconDirEntryCommon: icon.IconDirEntryCommon, ID: id})
}
id := <-newID
coff.AddResource(rtGroupIcon, id, group)
coff.AddResource(rtGroupIcon, gid, group)
}

return nil
Expand Down

0 comments on commit 73fc896

Please sign in to comment.