imagebox: Refuse invalid images

This makes the imagebox widget refuse images which have a zero or negative width
or height. A zero size causes problems where a division by zero results in inf
which makes various stuff fail in weird ways later on.

Additionally, cairo's "error surfaces" have a negative size. Displaying those
would cause all sorts of weird problems, too, so we better reject those.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2011-03-04 22:03:42 +01:00
parent 00273528b0
commit 01e6e2a07b
1 changed files with 8 additions and 0 deletions

View File

@ -82,6 +82,14 @@ function set_image(box, image)
image = result
end
if image then
local w = image:get_width()
local h = image:get_height()
if w <= 0 or h <= 0 then
return false
end
end
box.image = image
box:emit_signal("widget::updated")