mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-11 11:08:41 +00:00
revert r30531, which causes a crash when copying an inset.
Basically, insets in cut stack do not have a buffer, and therefore cannot acess to buffer parameters. What is annoying here is that acceptChanges requires this buffer params only to be able to read a font in moveItem, in order to read the buffer language, and I doubt this is really needed... Another change in this patch is that Inset::getLayout now returns a plainLayout when the inset does not have a buffer_. This fixes a remaining crash where dEPM reads isFreeSpacing() for an inset in the clipboard, but this looks like a fragile situation. And it will not do the right thing when doing depm in a freespacing inset. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30605 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
5d904d95e7
commit
c3be74085f
@ -362,7 +362,8 @@ Change const & Paragraph::lookupChange(pos_type pos) const
|
||||
}
|
||||
|
||||
|
||||
void Paragraph::acceptChanges(pos_type start, pos_type end)
|
||||
void Paragraph::acceptChanges(BufferParams const & bparams, pos_type start,
|
||||
pos_type end)
|
||||
{
|
||||
LASSERT(start >= 0 && start <= size(), /**/);
|
||||
LASSERT(end > start && end <= size() + 1, /**/);
|
||||
@ -372,14 +373,14 @@ void Paragraph::acceptChanges(pos_type start, pos_type end)
|
||||
case Change::UNCHANGED:
|
||||
// accept changes in nested inset
|
||||
if (Inset * inset = getInset(pos))
|
||||
inset->acceptChanges();
|
||||
inset->acceptChanges(bparams);
|
||||
break;
|
||||
|
||||
case Change::INSERTED:
|
||||
d->changes_.set(Change(Change::UNCHANGED), pos);
|
||||
// also accept changes in nested inset
|
||||
if (Inset * inset = getInset(pos))
|
||||
inset->acceptChanges();
|
||||
inset->acceptChanges(bparams);
|
||||
break;
|
||||
|
||||
case Change::DELETED:
|
||||
@ -397,7 +398,8 @@ void Paragraph::acceptChanges(pos_type start, pos_type end)
|
||||
}
|
||||
|
||||
|
||||
void Paragraph::rejectChanges(pos_type start, pos_type end)
|
||||
void Paragraph::rejectChanges(BufferParams const & bparams,
|
||||
pos_type start, pos_type end)
|
||||
{
|
||||
LASSERT(start >= 0 && start <= size(), /**/);
|
||||
LASSERT(end > start && end <= size() + 1, /**/);
|
||||
@ -407,7 +409,7 @@ void Paragraph::rejectChanges(pos_type start, pos_type end)
|
||||
case Change::UNCHANGED:
|
||||
// reject changes in nested inset
|
||||
if (Inset * inset = getInset(pos))
|
||||
inset->rejectChanges();
|
||||
inset->rejectChanges(bparams);
|
||||
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(pos_type start, pos_type end);
|
||||
void acceptChanges(BufferParams const & bparams, pos_type start, pos_type end);
|
||||
|
||||
/// reject changes within the given range
|
||||
void rejectChanges(pos_type start, pos_type end);
|
||||
void rejectChanges(BufferParams const & bparams, 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(left, right);
|
||||
pars_[pit].acceptChanges(cur.buffer()->params(), left, right);
|
||||
} else {
|
||||
pars_[pit].rejectChanges(left, right);
|
||||
pars_[pit].rejectChanges(cur.buffer()->params(), 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(0, pars_[pit].size());
|
||||
pars_[pit].rejectChanges(bparams, 0, pars_[pit].size());
|
||||
}
|
||||
|
||||
// next, reject imaginary end-of-par characters
|
||||
|
@ -461,6 +461,8 @@ 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,6 +27,7 @@ namespace lyx {
|
||||
|
||||
class BiblioInfo;
|
||||
class Buffer;
|
||||
class BufferParams;
|
||||
class BufferView;
|
||||
class Change;
|
||||
class CompletionList;
|
||||
@ -486,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() {};
|
||||
virtual void acceptChanges(BufferParams const &) {};
|
||||
/// reject the changes within the inset
|
||||
virtual void rejectChanges() {};
|
||||
virtual void rejectChanges(BufferParams const &) {};
|
||||
|
||||
///
|
||||
virtual Dimension const dimension(BufferView const &) const;
|
||||
|
@ -5152,17 +5152,17 @@ void InsetTabular::setChange(Change const & change)
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::acceptChanges()
|
||||
void InsetTabular::acceptChanges(BufferParams const & bparams)
|
||||
{
|
||||
for (idx_type idx = 0; idx < nargs(); ++idx)
|
||||
cell(idx)->acceptChanges();
|
||||
cell(idx)->acceptChanges(bparams);
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::rejectChanges()
|
||||
void InsetTabular::rejectChanges(BufferParams const & bparams)
|
||||
{
|
||||
for (idx_type idx = 0; idx < nargs(); ++idx)
|
||||
cell(idx)->rejectChanges();
|
||||
cell(idx)->rejectChanges(bparams);
|
||||
}
|
||||
|
||||
|
||||
|
@ -48,6 +48,7 @@
|
||||
namespace lyx {
|
||||
|
||||
class Buffer;
|
||||
class BufferParams;
|
||||
class BufferView;
|
||||
class CompletionList;
|
||||
class CursorSlice;
|
||||
@ -802,9 +803,9 @@ public:
|
||||
/// set the change for the entire inset
|
||||
void setChange(Change const & change);
|
||||
/// accept the changes within the inset
|
||||
void acceptChanges();
|
||||
void acceptChanges(BufferParams const & bparams);
|
||||
/// reject the changes within the inset
|
||||
void rejectChanges();
|
||||
void rejectChanges(BufferParams const & bparams);
|
||||
|
||||
// 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()
|
||||
void InsetText::acceptChanges(BufferParams const & bparams)
|
||||
{
|
||||
text_.acceptChanges(buffer().params());
|
||||
text_.acceptChanges(bparams);
|
||||
}
|
||||
|
||||
|
||||
void InsetText::rejectChanges()
|
||||
void InsetText::rejectChanges(BufferParams const & bparams)
|
||||
{
|
||||
text_.rejectChanges(buffer().params());
|
||||
text_.rejectChanges(bparams);
|
||||
}
|
||||
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
namespace lyx {
|
||||
|
||||
class BufferParams;
|
||||
class CompletionList;
|
||||
class CursorSlice;
|
||||
class Dimension;
|
||||
@ -115,9 +116,9 @@ public:
|
||||
/// set the change for the entire inset
|
||||
void setChange(Change const & change);
|
||||
/// accept the changes within the inset
|
||||
void acceptChanges();
|
||||
void acceptChanges(BufferParams const & bparams);
|
||||
/// reject the changes within the inset
|
||||
void rejectChanges();
|
||||
void rejectChanges(BufferParams const & bparams);
|
||||
|
||||
/// 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(0, pars[pit].size());
|
||||
pars[pit].acceptChanges(bparams, 0, pars[pit].size());
|
||||
}
|
||||
|
||||
// next, accept imaginary end-of-par characters
|
||||
|
Loading…
Reference in New Issue
Block a user