mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 11:16:55 +00:00
un-revert r30531, after Richard told me how to avoid the crash. Now, before
accepting changes in a clipboard copy (CutAndPaste.cpp), we set the buffer of insets (and we reset them later). Doing this makes sense because we know this is the only operation on these out-of-document paragraphs that will require access to a buffer. Also, this commit gets rid of one explicit test against ERT_CODE and LISTING_CODE. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30623 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
0dd2067a8f
commit
408b96bb92
@ -456,20 +456,33 @@ void copySelectionHelper(Buffer const & buf, ParagraphList const & pars,
|
||||
ParagraphList::iterator it_end = copy_pars.end();
|
||||
|
||||
for (; it != it_end; it++) {
|
||||
// ERT paragraphs have the Language latex_language.
|
||||
// This is invalid outside of ERT, so we need to change it
|
||||
// to the buffer language.
|
||||
if (it->ownerCode() == ERT_CODE || it->ownerCode() == LISTINGS_CODE)
|
||||
it->changeLanguage(buf.params(), latex_language, buf.language());
|
||||
|
||||
it->setInsetOwner(0);
|
||||
// Since we have a copy of the paragraphs, the insets
|
||||
// do not have a proper buffer reference. It makes
|
||||
// sense to add them temporarily, because the
|
||||
// operations below depend on that (acceptChanges included).
|
||||
it->setBuffer(const_cast<Buffer &>(buf));
|
||||
// PassThru paragraphs have the Language
|
||||
// latex_language. This is invalid for others, so we
|
||||
// need to change it to the buffer language.
|
||||
if (it->inInset().getLayout().isPassThru())
|
||||
it->changeLanguage(buf.params(),
|
||||
latex_language, buf.language());
|
||||
}
|
||||
|
||||
// do not copy text (also nested in insets) which is marked as deleted,
|
||||
// unless the whole selection was deleted
|
||||
// do not copy text (also nested in insets) which is marked as
|
||||
// deleted, unless the whole selection was deleted
|
||||
if (!isFullyDeleted(copy_pars))
|
||||
acceptChanges(copy_pars, buf.params());
|
||||
|
||||
|
||||
// do some final cleanup now, to make sure that the paragraphs
|
||||
// are not linked to something else.
|
||||
it = copy_pars.begin();
|
||||
for (; it != it_end; it++) {
|
||||
it->setBuffer(*static_cast<Buffer *>(0));
|
||||
it->setInsetOwner(0);
|
||||
}
|
||||
|
||||
DocumentClass * d = const_cast<DocumentClass *>(dc);
|
||||
cutstack.push(make_pair(copy_pars, d));
|
||||
}
|
||||
|
@ -362,8 +362,7 @@ Change const & Paragraph::lookupChange(pos_type pos) const
|
||||
}
|
||||
|
||||
|
||||
void Paragraph::acceptChanges(BufferParams const & bparams, pos_type start,
|
||||
pos_type end)
|
||||
void Paragraph::acceptChanges(pos_type start, pos_type end)
|
||||
{
|
||||
LASSERT(start >= 0 && start <= size(), /**/);
|
||||
LASSERT(end > start && end <= size() + 1, /**/);
|
||||
@ -373,14 +372,14 @@ void Paragraph::acceptChanges(BufferParams const & bparams, pos_type start,
|
||||
case Change::UNCHANGED:
|
||||
// accept changes in nested inset
|
||||
if (Inset * inset = getInset(pos))
|
||||
inset->acceptChanges(bparams);
|
||||
inset->acceptChanges();
|
||||
break;
|
||||
|
||||
case Change::INSERTED:
|
||||
d->changes_.set(Change(Change::UNCHANGED), pos);
|
||||
// also accept changes in nested inset
|
||||
if (Inset * inset = getInset(pos))
|
||||
inset->acceptChanges(bparams);
|
||||
inset->acceptChanges();
|
||||
break;
|
||||
|
||||
case Change::DELETED:
|
||||
@ -398,8 +397,7 @@ void Paragraph::acceptChanges(BufferParams const & bparams, pos_type start,
|
||||
}
|
||||
|
||||
|
||||
void Paragraph::rejectChanges(BufferParams const & bparams,
|
||||
pos_type start, pos_type end)
|
||||
void Paragraph::rejectChanges(pos_type start, pos_type end)
|
||||
{
|
||||
LASSERT(start >= 0 && start <= size(), /**/);
|
||||
LASSERT(end > start && end <= size() + 1, /**/);
|
||||
@ -409,7 +407,7 @@ void Paragraph::rejectChanges(BufferParams const & bparams,
|
||||
case Change::UNCHANGED:
|
||||
// reject changes in nested inset
|
||||
if (Inset * inset = getInset(pos))
|
||||
inset->rejectChanges(bparams);
|
||||
inset->rejectChanges();
|
||||
break;
|
||||
|
||||
case Change::INSERTED:
|
||||
|
@ -229,10 +229,10 @@ public:
|
||||
void setChange(pos_type pos, Change const & change);
|
||||
|
||||
/// accept changes within the given range
|
||||
void acceptChanges(BufferParams const & bparams, pos_type start, pos_type end);
|
||||
void acceptChanges(pos_type start, pos_type end);
|
||||
|
||||
/// reject changes within the given range
|
||||
void rejectChanges(BufferParams const & bparams, pos_type start, pos_type end);
|
||||
void rejectChanges(pos_type start, pos_type end);
|
||||
|
||||
/// Paragraphs can contain "manual labels", for example, Description
|
||||
/// environment. The text for this user-editable label is stored in
|
||||
|
@ -840,9 +840,9 @@ void Text::acceptOrRejectChanges(Cursor & cur, ChangeOp op)
|
||||
pos_type right = (pit == endPit ? endPos : parSize);
|
||||
|
||||
if (op == ACCEPT) {
|
||||
pars_[pit].acceptChanges(cur.buffer()->params(), left, right);
|
||||
pars_[pit].acceptChanges(left, right);
|
||||
} else {
|
||||
pars_[pit].rejectChanges(cur.buffer()->params(), left, right);
|
||||
pars_[pit].rejectChanges(left, right);
|
||||
}
|
||||
}
|
||||
|
||||
@ -919,7 +919,7 @@ void Text::rejectChanges(BufferParams const & bparams)
|
||||
// (do not consider end-of-par)
|
||||
for (pit_type pit = 0; pit < pars_size; ++pit) {
|
||||
if (!pars_[pit].empty()) // prevent assertion failure
|
||||
pars_[pit].rejectChanges(bparams, 0, pars_[pit].size());
|
||||
pars_[pit].rejectChanges(0, pars_[pit].size());
|
||||
}
|
||||
|
||||
// next, reject imaginary end-of-par characters
|
||||
|
@ -461,8 +461,6 @@ bool Inset::covers(BufferView const & bv, int x, int y) const
|
||||
|
||||
InsetLayout const & Inset::getLayout() const
|
||||
{
|
||||
if (!buffer_)
|
||||
return DocumentClass::plainInsetLayout();
|
||||
return buffer().params().documentClass().insetLayout(name());
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,6 @@ namespace lyx {
|
||||
|
||||
class BiblioInfo;
|
||||
class Buffer;
|
||||
class BufferParams;
|
||||
class BufferView;
|
||||
class Change;
|
||||
class CompletionList;
|
||||
@ -97,8 +96,9 @@ public:
|
||||
virtual ~Inset() {}
|
||||
|
||||
/// change associated Buffer
|
||||
/// FIXME this should go.
|
||||
virtual void setBuffer(Buffer & buffer);
|
||||
/// remove the buffer reference
|
||||
void resetBuffer() { setBuffer( *static_cast<Buffer *>(0)); }
|
||||
/// retrieve associated Buffer
|
||||
virtual Buffer & buffer();
|
||||
virtual Buffer const & buffer() const;
|
||||
@ -487,9 +487,9 @@ public:
|
||||
/// set the change for the entire inset
|
||||
virtual void setChange(Change const &) {}
|
||||
/// accept the changes within the inset
|
||||
virtual void acceptChanges(BufferParams const &) {};
|
||||
virtual void acceptChanges() {};
|
||||
/// reject the changes within the inset
|
||||
virtual void rejectChanges(BufferParams const &) {};
|
||||
virtual void rejectChanges() {};
|
||||
|
||||
///
|
||||
virtual Dimension const dimension(BufferView const &) const;
|
||||
|
@ -5152,17 +5152,17 @@ void InsetTabular::setChange(Change const & change)
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::acceptChanges(BufferParams const & bparams)
|
||||
void InsetTabular::acceptChanges()
|
||||
{
|
||||
for (idx_type idx = 0; idx < nargs(); ++idx)
|
||||
cell(idx)->acceptChanges(bparams);
|
||||
cell(idx)->acceptChanges();
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::rejectChanges(BufferParams const & bparams)
|
||||
void InsetTabular::rejectChanges()
|
||||
{
|
||||
for (idx_type idx = 0; idx < nargs(); ++idx)
|
||||
cell(idx)->rejectChanges(bparams);
|
||||
cell(idx)->rejectChanges();
|
||||
}
|
||||
|
||||
|
||||
|
@ -48,7 +48,6 @@
|
||||
namespace lyx {
|
||||
|
||||
class Buffer;
|
||||
class BufferParams;
|
||||
class BufferView;
|
||||
class CompletionList;
|
||||
class CursorSlice;
|
||||
@ -803,9 +802,9 @@ public:
|
||||
/// set the change for the entire inset
|
||||
void setChange(Change const & change);
|
||||
/// accept the changes within the inset
|
||||
void acceptChanges(BufferParams const & bparams);
|
||||
void acceptChanges();
|
||||
/// reject the changes within the inset
|
||||
void rejectChanges(BufferParams const & bparams);
|
||||
void rejectChanges();
|
||||
|
||||
// this should return true if we have a "normal" cell, otherwise false.
|
||||
// "normal" means without width set!
|
||||
|
@ -355,15 +355,15 @@ void InsetText::setChange(Change const & change)
|
||||
}
|
||||
|
||||
|
||||
void InsetText::acceptChanges(BufferParams const & bparams)
|
||||
void InsetText::acceptChanges()
|
||||
{
|
||||
text_.acceptChanges(bparams);
|
||||
text_.acceptChanges(buffer().params());
|
||||
}
|
||||
|
||||
|
||||
void InsetText::rejectChanges(BufferParams const & bparams)
|
||||
void InsetText::rejectChanges()
|
||||
{
|
||||
text_.rejectChanges(bparams);
|
||||
text_.rejectChanges(buffer().params());
|
||||
}
|
||||
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
namespace lyx {
|
||||
|
||||
class BufferParams;
|
||||
class CompletionList;
|
||||
class CursorSlice;
|
||||
class Dimension;
|
||||
@ -116,9 +115,9 @@ public:
|
||||
/// set the change for the entire inset
|
||||
void setChange(Change const & change);
|
||||
/// accept the changes within the inset
|
||||
void acceptChanges(BufferParams const & bparams);
|
||||
void acceptChanges();
|
||||
/// reject the changes within the inset
|
||||
void rejectChanges(BufferParams const & bparams);
|
||||
void rejectChanges();
|
||||
|
||||
/// append text onto the existing text
|
||||
void appendParagraphs(ParagraphList &);
|
||||
|
@ -354,7 +354,7 @@ void acceptChanges(ParagraphList & pars, BufferParams const & bparams)
|
||||
// (do not consider end-of-par)
|
||||
for (pit_type pit = 0; pit < pars_size; ++pit) {
|
||||
if (!pars[pit].empty()) // prevent assertion failure
|
||||
pars[pit].acceptChanges(bparams, 0, pars[pit].size());
|
||||
pars[pit].acceptChanges(0, pars[pit].size());
|
||||
}
|
||||
|
||||
// next, accept imaginary end-of-par characters
|
||||
|
Loading…
Reference in New Issue
Block a user