mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Set explicitly outer font when inserting text inset.
Now it is possible to set this font directly instead of relying on
metrics() side effects. Do that to avoid crashes due to bad
interactions.
This implements the new scheme that was mentionned in 5a58ca65
.
Fixes bug #12204.
This commit is contained in:
parent
950a53db3b
commit
efbc37926f
@ -313,6 +313,14 @@ static bool doInsertInset(Cursor & cur, Text * text,
|
||||
}
|
||||
text->insertInset(cur, inset);
|
||||
|
||||
InsetText * inset_text = inset->asInsetText();
|
||||
if (inset_text) {
|
||||
Font const & font = inset->inheritFont()
|
||||
? cur.bv().textMetrics(text).displayFont(cur.pit(), cur.pos())
|
||||
: buffer.params().getFont();
|
||||
inset_text->setOuterFont(cur.bv(), font.fontInfo());
|
||||
}
|
||||
|
||||
if (edit)
|
||||
inset->edit(cur, true);
|
||||
|
||||
@ -323,7 +331,6 @@ static bool doInsertInset(Cursor & cur, Text * text,
|
||||
cur.buffer()->errors("Paste");
|
||||
cur.clearSelection(); // bug 393
|
||||
cur.finishUndo();
|
||||
InsetText * inset_text = inset->asInsetText();
|
||||
if (inset_text) {
|
||||
inset_text->fixParagraphsFont();
|
||||
cur.pos() = 0;
|
||||
@ -2083,12 +2090,6 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
// inside it.
|
||||
doInsertInset(cur, this, cmd, true, true);
|
||||
cur.posForward();
|
||||
/* The font of the inset is computed in metrics(), and this is
|
||||
* used to compute the height of the caret (because the font
|
||||
* is stored in TextMetrics::font_). When we insert, we have
|
||||
* to make sure that metrics are computed so that the caret
|
||||
* height is correct. Arguably, this is hackish.*/
|
||||
bv->processUpdateFlags(Update::SinglePar);
|
||||
cur.setCurrentFont();
|
||||
// Some insets are numbered, others are shown in the outline pane so
|
||||
// let's update the labels and the toc backend.
|
||||
|
Loading…
Reference in New Issue
Block a user