The attached patch (against trunk) fixes the bug for me. It just does what the FIXME said needed doing anyway. If this does the job for others, then someone can commit. I won't have time until late tonight.

It seems clear that there's more to be done to clean this stuff up, but perhaps this will free 1.6.2.

Richard

Index: CutAndPaste.cpp
===================================================================
--- CutAndPaste.cpp     (revision 28704)
+++ CutAndPaste.cpp     (working copy)
@@ -221,7 +221,10 @@
 
        InsetIterator const i_end = inset_iterator_end(in);
        for (InsetIterator it = inset_iterator_begin(in); it != i_end; ++it) {
-       // Insets store buffer references so need updating.
+               // Insets store buffer references so need updating.
+               // FIXME This code can probably be deleted. The insets will get 
copied
+               // when they are pasted, at which point their buffer_ members 
will get 
+               // set back to zero.
                it->setBuffer(const_cast<Buffer &>(buffer));
 
                switch (it->lyxCode()) {
@@ -297,16 +300,19 @@
                // merge the first par of the insertion with the current par
                mergeParagraph(buffer.params(), pars, pit);
        }
-       //FIXME: We should call setBuffer() on each inserted paragraph.
-       // instead, we call setBuffer() for the main inset at the beginning
-       // of updateLabels()
 
+       // Store the new cursor position.
        pit_type last_paste = pit + insertion.size() - 1;
-
-       // Store the new cursor position.
+       pit_type startpit = pit;
        pit = last_paste;
        pos = pars[last_paste].size();
 
+       // Set paragraph buffers. It's important to do this right away
+       // before something calls Inset::buffer() and causes a crash.
+       for (pit_type p = startpit; p <= pit; ++p)
+               pars[p].setBuffer(const_cast<Buffer &>(buffer));
+
+
        // Join (conditionally) last pasted paragraph with next one, i.e.,
        // the tail of the spliced document paragraph
        if (!empty && last_paste + 1 != pit_type(pars.size())) {

Reply via email to