From 20dd6ae4d3ce9882a9822ad3547e9288903bbe5c Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Sun, 3 Jul 2011 17:39:35 +0200 Subject: Catch and report errors during the creation of menus --- src/Screen.cc | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/Screen.cc b/src/Screen.cc index 78932ae..b9d9a71 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -1368,11 +1368,16 @@ void BScreen::rereadMenu() { l.checkstack(1); lua::stack_sentry s(l); - // XXX try/catch m_rootmenu->removeAll(); - l.loadfile(FbTk::StringUtil::expandFilename(fb->getMenuFilename()).c_str()); - l.call(0, 1); - MenuCreator::createMenu(*m_rootmenu, l, m_rootmenu->reloadHelper()); + try { + l.loadfile(FbTk::StringUtil::expandFilename(fb->getMenuFilename()).c_str()); + l.call(0, 1); + MenuCreator::createMenu(*m_rootmenu, l, m_rootmenu->reloadHelper()); + } + catch(std::runtime_error &e) { + cerr << _FB_CONSOLETEXT(Menu, RootLoad, "Loading root menu failed: ", + "Actual error message follows this string") << e.what() << endl; + } if (m_rootmenu->numberOfItems() == 0) { _FB_USES_NLS; @@ -1402,12 +1407,16 @@ void BScreen::rereadWindowMenu() { l.checkstack(1); lua::stack_sentry s(l); - - // XXX try/catch m_windowmenu->removeAll(); - l.loadfile(FbTk::StringUtil::expandFilename(windowMenuFilename()).c_str()); - l.call(0, 1); - MenuCreator::createMenu(*m_windowmenu, l, m_windowmenu->reloadHelper()); + try { + l.loadfile(FbTk::StringUtil::expandFilename(windowMenuFilename()).c_str()); + l.call(0, 1); + MenuCreator::createMenu(*m_windowmenu, l, m_windowmenu->reloadHelper()); + } + catch(std::runtime_error &e) { + cerr << _FB_CONSOLETEXT(Menu, RootLoad, "Loading window menu failed: ", + "Actual error message follows this string") << e.what() << endl; + } } void BScreen::addConfigMenu(const FbTk::FbString &label, const FbTk::RefCount &menu) { -- cgit v0.11.2