[LyX/master] Set explicitly outer font when inserting text inset.
Jean-Marc Lasgouttes
lasgouttes at lyx.org
Thu Mar 25 10:24:03 UTC 2021
commit efbc37926fb98fbffdc8e93091412861c6276116
Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
Date: Thu Mar 25 10:52:21 2021 +0100
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.
---
src/Text3.cpp | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/Text3.cpp b/src/Text3.cpp
index 26d6d71..22253f2 100644
--- a/src/Text3.cpp
+++ b/src/Text3.cpp
@@ -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.
More information about the lyx-cvs
mailing list