I get crashes in ParIterator::operator++() after trying the patch below. It seems p.it gets broken so the ++it fails badly.
Dekel, any ideas ? What am I doing wrong ? thanks john Index: CutAndPaste.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/CutAndPaste.C,v retrieving revision 1.37 diff -u -r1.37 CutAndPaste.C --- CutAndPaste.C 2001/11/27 10:34:11 1.37 +++ CutAndPaste.C 2001/11/29 05:38:46 @@ -10,6 +10,7 @@ #include <config.h> #include "CutAndPaste.h" +#include "iterators.h" #include "BufferView.h" #include "buffer.h" #include "paragraph.h" @@ -325,24 +327,28 @@ int CutAndPaste::SwitchLayoutsBetweenClasses(LyXTextClassList::size_type c1, LyXTextClassList::size_type c2, - Paragraph * par) + Buffer * b) { int ret = 0; - if (!par || c1 == c2) + + if (c1 == c2) { return ret; + } - while (par) { - string const name = textclasslist.NameOfLayout(c1, - par->layout); - int lay = 0; + ParIterator end = b->par_iterator_end(); + for (ParIterator it = b->par_iterator_begin(); + it != end; ++it) { + Paragraph * par = *it; + string const name = + textclasslist.NameOfLayout(c1, par->layout); + pair<bool, LyXTextClass::LayoutList::size_type> pp = textclasslist.NumberOfLayout(c2, name); + int lay = 0; if (pp.first) { lay = pp.second; - } else { // layout not found - // use default layout "Standard" (0) - lay = 0; } + par->layout = lay; if (name != textclasslist.NameOfLayout(c2, par->layout)) { @@ -356,7 +362,6 @@ InsetError * new_inset = new InsetError(s); par->insertInset(0, new_inset); } - par = par->next(); } return ret; }