lc-soft / LCUI

C library for building user interfaces
https://lcui-dev.github.io
MIT License
4.13k stars 356 forks source link

Segmentation fault on draw window with minimal size. #200

Closed vbalyasnyy closed 4 years ago

vbalyasnyy commented 4 years ago

Segmentation fault on next simple code:

int main(void)
{
    LCUI_Widget root;
    LCUI_Widget status;

    LCUI_Init();

    status = LCUIWidget_New("textview");
    root = LCUIWidget_GetRoot();
    Widget_Append(root, status);

    LCUIDisplay_SetSize(320, 239);

    return LCUI_Main();
}

Surface creates with minimal (320,240) size settings by default:

static LCUI_Surface X11Surface_New(void)
{
...
    surface->width = MIN_WIDTH;
    surface->height = MIN_HEIGHT;
...

On surface resize task with size value less than minimal, setups minimal value:

static void X11Surface_RunTask(LCUI_Surface surface, int type)
{
...
        w = MIN_WIDTH > w ? MIN_WIDTH : w;
        h = MIN_HEIGHT > h ? MIN_HEIGHT : h;
...

But if window size setup in less or equals to minimal value, surfaces struct s->ximages and s->gc do not creates:

static void X11Surface_OnResize(LCUI_Surface s, int width, int height)
{
...
    if (width == s->width && height == s->height) {
        return;
    }
...