1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

gg: handle bad image index

This commit is contained in:
Alexander Medvednikov 2020-08-18 01:08:58 +02:00
parent c599a4c7de
commit 40d91cc23b
2 changed files with 10 additions and 5 deletions

View File

@ -108,6 +108,10 @@ pub fn (mut img Image) init_sokol_image() &Image {
}
pub fn (ctx &Context) draw_image(x, y, width, height f32, img_ &Image) {
if img_.id >= ctx.image_cache.len {
eprintln('gg: draw_image() bad img id $img_.id (img cache len = $ctx.image_cache.len)')
return
}
img := ctx.image_cache[img_.id] // fetch the image from cache
if !img.simg_ok {
return

View File

@ -7,12 +7,13 @@ enum CloseTagType {
[ref_only]
pub struct Tag {
mut:
name string = ''
attributes map[string]string // attributes will be like map[name]value
last_attribute string = ''
content string = ''
pub mut:
name string
content string
children []&Tag
mut:
attributes map[string]string // attributes will be like map[name]value
last_attribute string
parent &Tag = C.NULL
position_in_parent int = 0
closed bool = false