{
rowinfo_.insert(rowinfo_.begin() + row + 1, RowInfo());
cells_.insert
- (cells_.begin() + (row + 1) * ncols(), ncols(), MathData());
+ (cells_.begin() + (row + 1) * ncols(), ncols(), MathData(buffer_));
cellinfo_.insert
(cellinfo_.begin() + (row + 1) * ncols(), ncols(), CellInfo());
}
void InsetMathGrid::copyRow(row_type row)
{
addRow(row);
- for (col_type col = 0; col < ncols(); ++col)
+ for (col_type col = 0; col < ncols(); ++col) {
cells_[(row + 1) * ncols() + col] = cells_[row * ncols() + col];
+ // copying the cell does not set the buffer
+ cells_[(row + 1) * ncols() + col].setBuffer(*buffer_);
+ }
}
= cellinfo_[row * nc + col];
}
swap(cells_, new_cells);
+ // copying cells loses the buffer reference
+ setBuffer(*buffer_);
swap(cellinfo_, new_cellinfo);
ColInfo inf;
void InsetMathGrid::copyCol(col_type col)
{
addCol(col+1);
- for (row_type row = 0; row < nrows(); ++row)
+ for (row_type row = 0; row < nrows(); ++row) {
cells_[row * ncols() + col + 1] = cells_[row * ncols() + col];
+ // copying the cell does not set the buffer
+ cells_[row * ncols() + col + 1].setBuffer(*buffer_);
+ }
}
void InsetMathNest::setBuffer(Buffer & buffer)
{
InsetMath::setBuffer(buffer);
- for (idx_type i = 0, n = nargs(); i != n; ++i) {
- MathData & data = cell(i);
- for (size_t j = 0; j != data.size(); ++j)
- data[j].nucleus()->setBuffer(buffer);
- }
+ for (MathData & data : cells_)
+ data.setBuffer(buffer);
}
{}
+void MathData::setBuffer(Buffer & b)
+{
+ buffer_ = &b;
+ for (MathAtom & at : *this)
+ at.nucleus()->setBuffer(b);
+}
+
+
MathAtom & MathData::operator[](pos_type pos)
{
LBUFERR(pos < size());
///
void updateBuffer(ParIterator const &, UpdateType);
///
- void setBuffer(Buffer & b) { buffer_ = &b; }
+ void setBuffer(Buffer & b);
protected:
/// cached values for super/subscript placement