# HG changeset patch # User Kai Habel # Date 1289423038 -3600 # Node ID e0db3f9e926799b4f7adf8611756902d8f650273 # Parent 64e7538db12a44ccf93b5210bb00f2bcb358bd88 Add more checks for uimeu diff -r 64e7538db12a -r e0db3f9e9267 src/ChangeLog --- a/src/ChangeLog Wed Nov 10 04:07:14 2010 -0500 +++ b/src/ChangeLog Wed Nov 10 22:03:58 2010 +0100 @@ -1,3 +1,10 @@ +2010-11-10 Kai Habel + + * fltk-backend.cc (update_accelerator), (update_callback), (update_enable), + (update_foregroundcolor), (update_visible): Check if find_item + was succesful. (update_seperator): Make sure we don't write + beyond limits of menubar structure. + 2010-11-10 John W. Eaton Bug #31491. diff -r 64e7538db12a -r e0db3f9e9267 src/DLD-FUNCTIONS/fltk_backend.cc --- a/src/DLD-FUNCTIONS/fltk_backend.cc Wed Nov 10 04:07:14 2010 -0500 +++ b/src/DLD-FUNCTIONS/fltk_backend.cc Wed Nov 10 22:03:58 2010 +0100 @@ -377,11 +377,14 @@ if (!fltk_label.empty ()) { Fl_Menu_Item* item = const_cast(menubar->find_item (fltk_label.c_str ())); - std::string acc = uimenup.get_accelerator (); - if (acc.length () > 0) + if (item != NULL) { - int key = FL_CTRL + acc[0]; - item->shortcut (key); + std::string acc = uimenup.get_accelerator (); + if (acc.length () > 0) + { + int key = FL_CTRL + acc[0]; + item->shortcut (key); + } } } } @@ -392,11 +395,14 @@ if (!fltk_label.empty ()) { Fl_Menu_Item* item = const_cast(menubar->find_item (fltk_label.c_str ())); - if (!uimenup.get_callback ().is_empty ()) - item->callback(static_cast(script_cb), //callback - static_cast(&uimenup)); //callback data - else - item->callback(NULL, static_cast(0)); + if (item != NULL) + { + if (!uimenup.get_callback ().is_empty ()) + item->callback(static_cast(script_cb), //callback + static_cast(&uimenup)); //callback data + else + item->callback(NULL, static_cast(0)); + } } } @@ -406,10 +412,13 @@ if (!fltk_label.empty ()) { Fl_Menu_Item* item = const_cast(menubar->find_item (fltk_label.c_str ())); - if (uimenup.is_enable ()) - item->activate (); - else - item->deactivate (); + if (item != NULL) + { + if (uimenup.is_enable ()) + item->activate (); + else + item->deactivate (); + } } } @@ -419,10 +428,13 @@ if (!fltk_label.empty ()) { Fl_Menu_Item* item = const_cast(menubar->find_item (fltk_label.c_str ())); - Matrix rgb = uimenup.get_foregroundcolor_rgb (); - item->labelcolor(fl_rgb_color(static_cast(floor (rgb(0)*255)), - static_cast(floor (rgb(1)*255)), - static_cast(floor (rgb(2)*255)))); + if (item != NULL) + { + Matrix rgb = uimenup.get_foregroundcolor_rgb (); + item->labelcolor(fl_rgb_color(static_cast(floor (rgb(0)*255)), + static_cast(floor (rgb(1)*255)), + static_cast(floor (rgb(2)*255)))); + } } } @@ -445,13 +457,16 @@ break; } - if (uimenup.is_separator ()) + if ((idx >= 0) && (idx < menubar->size ())) { - if (idx >= 0 && !(itemflags & FL_SUBMENU)) - menubar->mode (idx, itemflags | FL_MENU_DIVIDER); + if (uimenup.is_separator ()) + { + if (idx >= 0 && !(itemflags & FL_SUBMENU)) + menubar->mode (idx, itemflags | FL_MENU_DIVIDER); + } + else + menubar->mode (idx, itemflags & (~FL_MENU_DIVIDER)); } - else - menubar->mode (idx, itemflags & (~FL_MENU_DIVIDER)); } } @@ -461,10 +476,13 @@ if (!fltk_label.empty ()) { Fl_Menu_Item* item = const_cast(menubar->find_item (fltk_label.c_str ())); - if (uimenup.is_visible ()) - item->show (); - else - item->hide (); + if (item != NULL) + { + if (uimenup.is_visible ()) + item->show (); + else + item->hide (); + } } }