]> git.lyx.org Git - lyx.git/commitdiff
Prevent crash when trying to draw non-existent 'button_state' button on
authorAngus Leeming <leeming@lyx.org>
Fri, 4 Jun 2004 13:20:26 +0000 (13:20 +0000)
committerAngus Leeming <leeming@lyx.org>
Fri, 4 Jun 2004 13:20:26 +0000 (13:20 +0000)
an 'FL_NORMAL_COMBOX' combox.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8805 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/xforms/ChangeLog
src/frontends/xforms/combox.c

index 0c68146ba27896a20f256377a40cc0f166800e45..cee43700b305f63f70a115e8ec0a895c8ca54769 100644 (file)
@@ -1,3 +1,8 @@
+2004-06-04  Angus Leeming  <leeming@lyx.org>
+
+       * 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  <larsbj@lyx.org>
 
        * forms/Makefile.am (.fd.C): Use '-r' to test for file existence,
index 7e9b9b131c7397cd96cd8b4a34c2584cd648ddef..05e270f111c0f8e182282e5960de12578f9fdb30 100644 (file)
@@ -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);
-
-       if (ob->x != sp->button_chosen->x ||
-           ob->y != sp->button_chosen->y ||
-           xbs   != sp->button_state->x ||
-           ob->y != sp->button_state->y) {
+       int change =
+           ob->x != sp->button_chosen->x ||
+           ob->y != sp->button_chosen->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);
        }