Hi,

One could easily make the gtk frontend crash with a failed assertion in
MenuBackend::Getmenu.  The problem occurred when viewing a document with
figures in it: the "Figures" submenu item didn't have a submenuname_
field, but GMenubar::submenuDisabled always tries to get submenus by
name from the backend.

Attached patch fixes the crash for me, but since I don't fully
understand the menu system I'd appreciate if anyone could tell me if
it's dangerous/bad.

John
Index: GMenubar.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/frontends/gtk/GMenubar.C,v
retrieving revision 1.15
diff -u -3 -p -r1.15 GMenubar.C
--- GMenubar.C	2004/10/02 23:21:36	1.15
+++ GMenubar.C	2004/10/03 11:45:20
@@ -124,9 +124,9 @@ void GMenubar::openByName(string const &
 
 bool GMenubar::submenuDisabled(MenuItem const * item)
 {
-	Menu & from = menubackend.getMenu(item->submenuname());
+	Menu * from = item->submenu();
 	Menu to;
-	menubackend.expand(from, to, view_);
+	menubackend.expand(*from, to, view_);
 	Menu::const_iterator i = to.begin();
 	Menu::const_iterator end = to.end();
 	for (; i != end; ++i) {
@@ -158,7 +158,10 @@ void GMenubar::onSubMenuActivate(MenuIte
 	ClearMenu(gmenu);
 	LyxMenu * lyxmenu = static_cast<LyxMenu*>(gmenu);
 	lyxmenu->clearBackMenu();
-	Menu * fmenu = &menubackend.getMenu(item->submenuname());
+	Menu * fmenu = item->submenuname().empty() ?
+		item->submenu() :
+		&menubackend.getMenu(item->submenuname());
+	
 	menubackend.expand(*fmenu, lyxmenu->getBackMenu(), view_);
 	Menu::const_iterator i = lyxmenu->getBackMenu().begin();
 	Menu::const_iterator end = lyxmenu->getBackMenu().end();

Reply via email to