[LyX/master] Add a risk hedge for timing of initialization
Koji Yokota
yokota at lyx.org
Sun May 10 13:13:20 UTC 2026
commit 015d40fb9720447e60ef98d3e39d8a2d4415c45a
Author: Koji Yokota <yokota at lyx.org>
Date: Sun May 10 22:10:45 2026 +0900
Add a risk hedge for timing of initialization
---
src/TextMetrics.cpp | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index 04827030e5..c7ee6769d5 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -578,6 +578,10 @@ bool TextMetrics::redoParagraph(pit_type const pit, bool const align_rows)
pm.dim().des -= pm.rows().front().ascent();
// Tell the input method about pm
+ // Note that initial value of im_ is a nullptr, since TextMetrics is
+ // constructed in the initialization of BufferView before GuiInputMethod
+ // is constructed. Don't call this function too early.
+ LBUFERR(im_ != nullptr);
im_->setParagraphMetrics(pm);
changed |= old_dim.height() != pm.dim().height();
@@ -859,6 +863,10 @@ Row TextMetrics::tokenizeParagraph(pit_type const pit) const
if (ic_it.inTexted() && ic_it.text() == text_ && ic_it.pit() == pit)
ic_pos = ic_it.pos();
+ // Note that initial value of im_ is a nullptr, since TextMetrics is
+ // constructed in the initialization of BufferView before GuiInputMethod
+ // is constructed. Don't call this function too early.
+ LBUFERR(im_ != nullptr);
docstring & preedit = im_->preeditString();
// Now we iterate through until we reach the right margin
More information about the lyx-cvs
mailing list