From 990a402f7a0aca92877e96329c04968e85a85353 Mon Sep 17 00:00:00 2001 From: John Maxwell Date: Thu, 5 Mar 2026 09:24:40 -0800 Subject: [PATCH 1/2] Fix LT-22295: Crash when switching to Texts and Words --- .../Interlinear/InterlinDocForAnalysis.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Src/LexText/Interlinear/InterlinDocForAnalysis.cs b/Src/LexText/Interlinear/InterlinDocForAnalysis.cs index 4fd652fce0..d906293630 100644 --- a/Src/LexText/Interlinear/InterlinDocForAnalysis.cs +++ b/Src/LexText/Interlinear/InterlinDocForAnalysis.cs @@ -294,8 +294,18 @@ public virtual void TriggerAnalysisSelected(AnalysisOccurrence target, bool fSav RecordGuessIfNotKnown(target); InstallFocusBox(); RootBox.DestroySelection(); - FocusBox.SelectOccurrence(target); - SetFocusBoxSizeForVc(); + try + { + // Don't let the FocusBox be disposed in VwDrawRootBufferedClass.Create() + // when the selected word has a different RTL from the text (LT-22295). + SuppressChanges = true; + FocusBox.SelectOccurrence(target); + SetFocusBoxSizeForVc(); + } + finally + { + SuppressChanges = false; + } SelectedOccurrence = target; if (fShow) @@ -1835,7 +1845,7 @@ internal FocusBoxController FocusBox { get { - if ((ExistingFocusBox == null && ForEditing) || hasRightToLeftChanged) + if ((ExistingFocusBox == null && ForEditing) || hasRightToLeftChanged && !SuppressChanges) { CreateFocusBox(); previousRightToLeft = Vc.RightToLeft; @@ -1975,6 +1985,8 @@ public override bool WantInitialSelection get { return false; } } + public bool SuppressChanges = false; + protected override void OnMouseDown(MouseEventArgs e) { // The base method does this too, but some paths in this method don't go through the base! From 677cb7a4508a37cf9104bc7f864a08617df8c2a5 Mon Sep 17 00:00:00 2001 From: John Maxwell Date: Tue, 17 Mar 2026 13:02:25 -0700 Subject: [PATCH 2/2] Respond to Hasso's comments --- Src/LexText/Interlinear/InterlinDocForAnalysis.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Src/LexText/Interlinear/InterlinDocForAnalysis.cs b/Src/LexText/Interlinear/InterlinDocForAnalysis.cs index d906293630..3e8c11fa93 100644 --- a/Src/LexText/Interlinear/InterlinDocForAnalysis.cs +++ b/Src/LexText/Interlinear/InterlinDocForAnalysis.cs @@ -296,7 +296,7 @@ public virtual void TriggerAnalysisSelected(AnalysisOccurrence target, bool fSav RootBox.DestroySelection(); try { - // Don't let the FocusBox be disposed in VwDrawRootBufferedClass.Create() + // Suppress changing the FocusBox when called from VwDrawRootBufferedClass.Create() // when the selected word has a different RTL from the text (LT-22295). SuppressChanges = true; FocusBox.SelectOccurrence(target); @@ -1985,7 +1985,7 @@ public override bool WantInitialSelection get { return false; } } - public bool SuppressChanges = false; + private bool SuppressChanges = false; protected override void OnMouseDown(MouseEventArgs e) {