mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-21 17:51:03 +00:00
Try to make sure that math insets have a properly set buffer_ member
Set the buffer of contents that is added to a MathData object through MathData::insert() (both versions) MathData::push_back() asArray() Also in math macros, initialize look_ with the relevant buffer. This reduces the number of insets hat do not have a proper buffer. See #13050 for discussion of this issue.
This commit is contained in:
parent
358efd120a
commit
f3c5ff9cb7
@ -394,7 +394,7 @@ void InsetNameWrapper::draw(PainterInfo & pi, int x, int y) const
|
||||
|
||||
|
||||
InsetMathMacroTemplate::InsetMathMacroTemplate(Buffer * buf)
|
||||
: InsetMathNest(buf, 3), numargs_(0), argsInLook_(0), optionals_(0),
|
||||
: InsetMathNest(buf, 3), look_(buf), numargs_(0), argsInLook_(0), optionals_(0),
|
||||
type_(MacroTypeNewcommand), redefinition_(false), lookOutdated_(true),
|
||||
premetrics_(false), labelBoxAscent_(0), labelBoxDescent_(0)
|
||||
{
|
||||
@ -405,8 +405,8 @@ InsetMathMacroTemplate::InsetMathMacroTemplate(Buffer * buf)
|
||||
InsetMathMacroTemplate::InsetMathMacroTemplate(Buffer * buf, docstring const & name, int numargs,
|
||||
int optionals, MacroType type, vector<MathData> const & optionalValues,
|
||||
MathData const & def, MathData const & display)
|
||||
: InsetMathNest(buf, optionals + 3), numargs_(numargs), argsInLook_(numargs),
|
||||
optionals_(optionals), optionalValues_(optionalValues),
|
||||
: InsetMathNest(buf, optionals + 3), look_(buf), numargs_(numargs),
|
||||
argsInLook_(numargs), optionals_(optionals), optionalValues_(optionalValues),
|
||||
type_(type), redefinition_(false), lookOutdated_(true),
|
||||
premetrics_(false), labelBoxAscent_(0), labelBoxDescent_(0)
|
||||
{
|
||||
@ -536,6 +536,8 @@ void InsetMathMacroTemplate::createLook(int args) const
|
||||
look_.push_back(MathAtom(
|
||||
new InsetDisplayLabelBox(buffer_, MathAtom(
|
||||
new InsetMathWrapper(&cell(displayIdx()))), _("LyX"), *this)));
|
||||
|
||||
look_.setContentsBuffer();
|
||||
}
|
||||
|
||||
|
||||
|
@ -52,11 +52,18 @@ MathData::MathData(Buffer * buf, const_iterator from, const_iterator to)
|
||||
{}
|
||||
|
||||
|
||||
void MathData::setContentsBuffer()
|
||||
{
|
||||
if (buffer_)
|
||||
for (MathAtom & at : *this)
|
||||
at.nucleus()->setBuffer(*buffer_);
|
||||
}
|
||||
|
||||
|
||||
void MathData::setBuffer(Buffer & b)
|
||||
{
|
||||
buffer_ = &b;
|
||||
for (MathAtom & at : *this)
|
||||
at.nucleus()->setBuffer(b);
|
||||
setContentsBuffer();
|
||||
}
|
||||
|
||||
|
||||
@ -78,6 +85,8 @@ void MathData::insert(size_type pos, MathAtom const & t)
|
||||
{
|
||||
LBUFERR(pos <= size());
|
||||
base_type::insert(begin() + pos, t);
|
||||
if (buffer_)
|
||||
operator[](pos)->setBuffer(*buffer_);
|
||||
}
|
||||
|
||||
|
||||
@ -85,6 +94,17 @@ void MathData::insert(size_type pos, MathData const & ar)
|
||||
{
|
||||
LBUFERR(pos <= size());
|
||||
base_type::insert(begin() + pos, ar.begin(), ar.end());
|
||||
if (buffer_)
|
||||
for (size_type i = 0 ; i < ar.size() ; ++i)
|
||||
operator[](pos + i)->setBuffer(*buffer_);
|
||||
}
|
||||
|
||||
|
||||
void MathData::push_back(MathAtom const & t)
|
||||
{
|
||||
base_type::push_back(t);
|
||||
if (buffer_)
|
||||
back()->setBuffer(*buffer_);
|
||||
}
|
||||
|
||||
|
||||
|
@ -59,7 +59,6 @@ public:
|
||||
using base_type::clear;
|
||||
using base_type::begin;
|
||||
using base_type::end;
|
||||
using base_type::push_back;
|
||||
using base_type::pop_back;
|
||||
using base_type::back;
|
||||
using base_type::front;
|
||||
@ -85,6 +84,8 @@ public:
|
||||
void insert(size_type pos, MathAtom const & at);
|
||||
/// inserts multiple atoms at position pos
|
||||
void insert(size_type pos, MathData const & ar);
|
||||
/// inserts single atom at end
|
||||
void push_back(MathAtom const & at);
|
||||
|
||||
/// erase range from pos1 to pos2
|
||||
void erase(iterator pos1, iterator pos2);
|
||||
@ -187,8 +188,10 @@ public:
|
||||
void updateMacros(Cursor * cur, MacroContext const & mc, UpdateType, int nesting);
|
||||
///
|
||||
void updateBuffer(ParIterator const &, UpdateType, bool const deleted = false);
|
||||
///
|
||||
/// Change associated buffer for this object and its contents
|
||||
void setBuffer(Buffer & b);
|
||||
/// Update assiociated buffer for the contents of the object
|
||||
void setContentsBuffer();
|
||||
|
||||
protected:
|
||||
/// cached values for super/subscript placement
|
||||
|
@ -1102,6 +1102,9 @@ void asArray(docstring const & str, MathData & ar, Parse::flags pf)
|
||||
bool macro = pf & Parse::MACRODEF;
|
||||
if ((str.size() == 1 && quiet) || (!mathed_parse_cell(ar, str, pf) && quiet && !macro))
|
||||
mathed_parse_cell(ar, str, pf | Parse::VERBATIM);
|
||||
|
||||
// set the buffer of the MathData contents
|
||||
ar.setContentsBuffer();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user