From b46d315e072211b91cd14a6208515ffed10d4392 Mon Sep 17 00:00:00 2001 From: Ricardo Cruz Date: Thu, 5 Aug 2004 14:09:12 +0000 Subject: [PATCH] When there is no entries in a menu, there is a crash. This delays the crash until an event is triggered. Select a level from Contrib Levels for testing. I dunno what changes Tobias made to menu, but I don't think that ugly checking for horizontal lines was in there. SVN-Revision: 1707 --- lib/gui/menu.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/gui/menu.cpp b/lib/gui/menu.cpp index b23ff784b..28e6efff7 100644 --- a/lib/gui/menu.cpp +++ b/lib/gui/menu.cpp @@ -457,17 +457,23 @@ Menu::action() } } - MenuItem& new_item = item[active_item]; - if(new_item.kind == MN_DEACTIVE - || new_item.kind == MN_LABEL - || new_item.kind == MN_HL) + if(active_item > 0 && active_item < (int)item.size()) { + // FIXME: wtf?! having a hack to avoid horizontal lines... + // Elegant solution would be to check for horizontal lines, right + // when it was asked to move menu up and down + MenuItem& new_item = item[active_item]; + if(new_item.kind == MN_DEACTIVE || + new_item.kind == MN_LABEL || + new_item.kind == MN_HL) + { // Skip the horzontal line item if (menuaction != MENU_ACTION_UP && menuaction != MENU_ACTION_DOWN) menuaction = MENU_ACTION_DOWN; if (item.size() > 1) action(); + } } menuaction = MENU_ACTION_NONE; -- 2.11.0