On Mon, Feb 18, 2002 at 07:46:14PM +0200, Martin Vermeer wrote: > > Paste of figure float causes crash > > Open file "failX.lyx"; select and copy the figure > float; open a new file and paste the figure -> crash > > > > Latest CVS: > > Bug exists for all insets with *captions*, table, algorithm, ... > Remove the caption (or make it "standard" style) -> no crash. > > I believe the problem is in text2.C around/after line 884. Somehow this code > responds poorly if the paragraph in question is a caption. It makes no > difference if it is the first paragraph within a float, or a later one. > > The real bug may be somewhere else. The caption handling in text.C/text2.C is > messy :-( > > Martin Okay, here is the long story on Bug 221.
The problem is that the source document for the float to be copied is a different textclass than the (newly created) target document. Remember that every textclass has its own set of layouts, and even its own numbering. Thus is can happen, that layout "Caption" in textclass "scrreprt" (the source doc one) has number 41(*), while in textclass "article" the same layout "Caption" has number 31. [(*) Those numbers are for me, but I have tinkered with my layout files. You may see different numbers.] Now it appears that if you "cut" a text from one document containing layouts, these go into the select buffer with their hardwired layout numbers. When you then try to paste this text into a document the class of which doesn't even have 41 layouts, ... BOOM! If you want to see this for yourself, enter the line lyxerr << "getLayout()" << row->par()->getLayout() << endl; into text.C (LyXText::rightMargin) at line 860, and try out the crash recipe for this bug. Also try inserting a new figure float with caption into the new doc, to see the difference in layout number. If you're still not convinced, change the source document's class to "article" and then do the crash recipe. No crash. Remedy: Make cut & paste keep track of the layouts by name rather than by number, or convert the numbers. (Easier said than done!) Martin
msg33165/pgp00000.pgp
Description: PGP signature