diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 0c68146ba2..cee43700b3 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,8 @@ +2004-06-04 Angus Leeming + + * combox.c (combox_handle): prevent crash when trying to draw + non-existent 'button_state' button on an 'FL_NORMAL_COMBOX' combox. + 2004-06-02 Lars Gullik Bjønnes * forms/Makefile.am (.fd.C): Use '-r' to test for file existence, diff --git a/src/frontends/xforms/combox.c b/src/frontends/xforms/combox.c index 7e9b9b131c..05e270f111 100644 --- a/src/frontends/xforms/combox.c +++ b/src/frontends/xforms/combox.c @@ -377,17 +377,23 @@ combox_handle(FL_OBJECT * ob, int event, FL_Coord mx, FL_Coord my, int key, case FL_DRAWLABEL: { COMBOX_SPEC * sp = ob->spec; - FL_Coord const xbs = - ob->x + (sp->button_state->x - sp->button_chosen->x); + int change = + ob->x != sp->button_chosen->x || + ob->y != sp->button_chosen->y; - if (ob->x != sp->button_chosen->x || - ob->y != sp->button_chosen->y || - xbs != sp->button_state->x || - ob->y != sp->button_state->y) { + FL_Coord xbs = 0; + if (sp->button_state) { + xbs = ob->x + (sp->button_state->x - sp->button_chosen->x); + change = change || + xbs != sp->button_state->x || + ob->y != sp->button_state->y; + } + if (change) { fl_freeze_form(ob->form); fl_set_object_position(sp->button_chosen, ob->x, ob->y); - fl_set_object_position(sp->button_state, xbs, ob->y); + if (sp->button_state) + fl_set_object_position(sp->button_state, xbs, ob->y); fl_unfreeze_form(ob->form); }