* CutAndPaste.cpp:

- correctly set buffer on paste. This fixes a crash on pasting branches 
	   within child documents (bug 5813)

(patch by rgheck)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@28709 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2009-03-07 11:37:51 +00:00
parent 258234787e
commit 3e5a87d6d7

View File

@ -222,7 +222,10 @@ pasteSelectionHelper(Cursor & cur, ParagraphList const & parlist,
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.
// 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()) {
@ -292,16 +295,19 @@ pasteSelectionHelper(Cursor & cur, ParagraphList const & parlist,
// 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()
pit_type last_paste = pit + insertion.size() - 1;
// Store the new cursor position.
pit_type last_paste = pit + insertion.size() - 1;
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())) {