Buffers for Math Insets

Richard Kimberly Heck rikiheck at lyx.org
Sat Oct 12 23:28:33 UTC 2019

On 10/12/19 2:17 PM, Jean-Marc Lasgouttes wrote:
> Le 12/10/2019 à 17:25, Richard Kimberly Heck a écrit :
>> It's called from Cursor::push:
>> void Cursor::push(Inset & p)
>> {
>>      push_back(CursorSlice(p));
>>      p.setBuffer(*buffer());
>> }
>> So it's actually called whenever we descend into an inset as well.
> It would be nice to have a strategy for being sure that the buffer is
> set as soon as possible in every case, so that we do not have to
> resort to hacks like this (i.e. set the cursor at many different
> places so that we avoid crashes). We should audit the cases where
> insets are created without a buffer.

I believe it is almost all in mathed now. The strategy you suggest:

> A solution would be to force the presence of a Buffer parameter in
> Inset constructors. Then we would see the places where an explicit 0
> cannot be avoided, and see what we can do about it.

was, I think, suggested back when we moved to have Inset::buffer()
return a reference. But the way insets are created in mathed, if I
remember correctly, is so different that this was impractical.

Still, yes, I agree. If you want to see a real hack, see
InsetMathRef::changeTarget. I'll be doing the same thing in another
method before long.


More information about the lyx-devel mailing list