Here is a patch which corrects the heap corruption I was having.

Attached is a demo file for the bug. Bug is known to appear with xforms 
up to 0.88.3 -higher patches not tested before 0.89, which does not 
corrupt heap.

To replicate bug, load up lots-of-figures.lyx, go to Navigate menu. When 
you close the menu, LyX is terminated with a segmentation fault.

The problem is that xfroms 0.88 can't cope with popup menus larger than 
80 items. The TOC code breaks up long menus into chained sub-menus, but 
the floats menus didn't. This triggered the bug.

The attached bug changes the float menu to also be chained into 
sub-menus when there are lots of figures.

There is also a pre-existing BUG in the Figures and Tables float menus - 
when you select an item from these menus, the cursor is not moved. I do 
not know how to fix this, and it was pre-existing before my patch.

Ben.

#LyX 1.1 created this file. For more info see http://www.lyx.org/
\lyxformat 218
\textclass article
\language english
\inputencoding auto
\fontscheme default
\graphics default
\paperfontsize default
\spacing single 
\papersize Default
\paperpackage a4
\use_geometry 0
\use_amsmath 0
\paperorientation portrait
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\defskip medskip
\quotes_language english
\quotes_times 2
\papercolumns 1
\papersides 1
\paperpagestyle default

\layout Section

This is a heading...
\layout Standard

\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\begin_float fig 
\layout Caption

Blah.
\end_float 
\the_end
--- lyx-devel-orig/src/frontends/xforms/ChangeLog       Thu Dec  6 10:58:32 2001
+++ lyx-devel/src/frontends/xforms/ChangeLog    Tue Dec 11 14:50:17 2001
@@ -1,3 +1,8 @@
+2001-12-11  Ben Stanley <[EMAIL PROTECTED]>
+
+       * Menubar_pimpl.C: Fixed a crashing bug when document
+               has more than 80 floats and using xforms 0.88
+
 2001-12-05  John Levon  <[EMAIL PROTECTED]>
 
        * FormParagraph.C: set combo box correctly for VSpace::LENGTH
--- lyx-devel-orig/src/frontends/xforms/Menubar_pimpl.C Thu Dec  6 10:58:32 2001
+++ lyx-devel/src/frontends/xforms/Menubar_pimpl.C      Tue Dec 11 13:18:05 2001
@@ -337,10 +337,21 @@
                if (cit->first == "TOC") continue;
 
                // All the rest is for floats
-               int menu2 = get_new_submenu(smn, win);
+               int menu_first_sub = get_new_submenu(smn, win);
+               int menu_current = menu_first_sub;
                Buffer::SingleList::const_iterator ccit = cit->second.begin();
                Buffer::SingleList::const_iterator eend = cit->second.end();
+               size_type count = 0;
                for (; ccit != eend; ++ccit) {
+                       ++count;
+                       if (count > max_number_of_items) {
+                               int menu_tmp = get_new_submenu(smn, win);
+                               string label = _("More");
+                               label += "...%m";
+                               fl_addtopup(menu_current, label.c_str(), menu_tmp);
+                               count = 1;
+                               menu_current = menu_tmp;
+                       }
                        int const action =
                                lyxaction
                                .getPseudoAction(LFUN_GOTO_PARAGRAPH,
@@ -348,10 +359,10 @@
                        string label = fixlabel(ccit->str);
                        label = limit_string_length(label);
                        label += "%x" + tostr(action + action_offset);
-                       fl_addtopup(menu2, label.c_str());
+                       fl_addtopup(menu_current, label.c_str());
                }
                string const m = floatList[cit->first]->second.name() + "%m";
-               fl_addtopup(menu, m.c_str(), menu2);
+               fl_addtopup(menu, m.c_str(), menu_first_sub);
        }
        
        

Reply via email to