From ed5585966b457a2574e36fe20badcf3ef948a38a Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Mon, 13 May 2013 11:21:53 +0200 Subject: [PATCH] Remove the 'running' booleans quit and optional Reason for this 'cleanup' is the strange "optional = false" lines at the end of the "case md_item" and "case md_subitem". Then, it is nicer to directly use the value of the switch to be the running variable and to use this to determine whether an item is optional and whether we should quit. --- src/frontends/qt4/Menus.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/frontends/qt4/Menus.cpp b/src/frontends/qt4/Menus.cpp index 652bce1d4e..d4a687b960 100644 --- a/src/frontends/qt4/Menus.cpp +++ b/src/frontends/qt4/Menus.cpp @@ -517,14 +517,10 @@ void MenuDefinition::read(Lexer & lex) lex.pushTable(menutags); lex.setContext("MenuDefinition::read: "); - bool quit = false; - bool optional = false; - - while (lex.isOK() && !quit) { - switch (lex.lex()) { + int md_type = 0; + while (lex.isOK() && md_type != md_endmenu) { + switch (md_type = lex.lex()) { case md_optitem: - optional = true; - // fallback to md_item case md_item: { lex.next(true); docstring const name = translateIfPossible(lex.getDocString()); @@ -534,8 +530,8 @@ void MenuDefinition::read(Lexer & lex) FuncRequest::Origin origin = FuncRequest::MENU; if (name_.startsWith("context-toc-")) origin = FuncRequest::TOC; + bool const optional = (md_type == md_optitem); add(MenuItem(MenuItem::Command, toqstr(name), func, QString(), optional, origin)); - optional = false; break; } @@ -656,21 +652,18 @@ void MenuDefinition::read(Lexer & lex) break; case md_optsubmenu: - optional = true; - // fallback to md_submenu case md_submenu: { lex.next(true); docstring const mlabel = translateIfPossible(lex.getDocString()); lex.next(true); docstring const mname = lex.getDocString(); + bool const optional = (md_type == md_optsubmenu); add(MenuItem(MenuItem::Submenu, toqstr(mlabel), toqstr(mname), QString(), optional)); - optional = false; break; } case md_endmenu: - quit = true; break; default: