d-gamedev-team / dimgui

dimgui is a D port of the imgui OpenGL GUI library.
zlib License
48 stars 13 forks source link

Never use negative-sized scissor. #3

Closed kiith-sa closed 10 years ago

kiith-sa commented 10 years ago

As the size of a scissor rectangle used in ScrollArea is defined as (width - something, height - something), the rectangle would have negative size if e.g. the scissor area size is proportional to window size and the window gets resized to a small size. This would result in a segfault (at least on AMD Catalyst/Linux).

E.g. when a user plays around with window width/height the program (even dimgui examples) would crash.

I worked around this by forcing the scissor area to be at least 1x1 pixels large.

ghost commented 10 years ago

I'd even inject a cast(int) for both parameters to max. IIRC max works unexpectedly if one of the arguments is unsigned. I think it ends up casting a signed number to unsigned, leading to massively huge numbers.

kiith-sa commented 10 years ago

Both parameters to the max calls are ints (1, width, SCROLL_AREA_PADDING, height, AREA_HEADER are all ints) - I don't see a need to add a cast.

ghost commented 10 years ago

Thanks again for the work.