From 37962f006a0090562e4d22787f4007ac1946793d Mon Sep 17 00:00:00 2001 From: John Maxwell Date: Tue, 12 May 2026 10:05:57 -0700 Subject: [PATCH] Fix LT-22508: text not enabled; text deletion issues --- .../InterlinearTextsRecordClerk.cs | 4 --- Src/xWorks/ConcDecorator.cs | 31 +++++++++++++------ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/Src/LexText/Interlinear/InterlinearTextsRecordClerk.cs b/Src/LexText/Interlinear/InterlinearTextsRecordClerk.cs index e6a0a6fb6d..47b37f5c25 100644 --- a/Src/LexText/Interlinear/InterlinearTextsRecordClerk.cs +++ b/Src/LexText/Interlinear/InterlinearTextsRecordClerk.cs @@ -308,10 +308,6 @@ public override void PropChanged(int hvo, int tag, int ivMin, int cvIns, int cvD { m_langProjectTextsFlid = Cache.MetaDataCacheAccessor.GetFieldId("LangProject", "Texts", true); } - if (tag == m_langProjectTextsFlid && (cvIns > 0 || cvDel > 0)) - { - InterestingTextsDecorator.ClearInterestingTextsList(m_propertyTable); - } } internal abstract class CreateAndInsertStText : RecordList.ICreateAndInsert diff --git a/Src/xWorks/ConcDecorator.cs b/Src/xWorks/ConcDecorator.cs index cbd6780afa..6825d9845b 100644 --- a/Src/xWorks/ConcDecorator.cs +++ b/Src/xWorks/ConcDecorator.cs @@ -4,7 +4,6 @@ using SIL.FieldWorks.Common.Controls; using SIL.FieldWorks.Common.FwUtils; -using static SIL.FieldWorks.Common.FwUtils.FwUtils; using SIL.LCModel; using SIL.LCModel.Application; using SIL.LCModel.Core.Cellar; @@ -18,6 +17,7 @@ using System.Linq; using System.Xml; using XCore; +using static SIL.FieldWorks.Common.FwUtils.FwUtils; namespace SIL.FieldWorks.XWorks { @@ -98,6 +98,10 @@ public override void RemoveNotification(IVwNotifyChange nchng) // If a clerk were to be disposed some other time when another clerk was still using the ITL, // this would be a bad thing to do. base.RemoveNotification(m_interestingTexts); + // Clear the cache in case we are not shutting down the main window. + // This avoids problems in LT-22508 caused by stale cache data. + InterestingTextsDecorator.ClearInterestingTextsList(PropTable); + m_interestingTexts = null; } } @@ -124,7 +128,7 @@ private int[] GetAnalysisOccurrences(int hvo) public IEnumerable InterestingTexts { - get { return m_interestingTexts.InterestingTexts; } + get { return InterestingTextsList.InterestingTexts; } } public override void PropChanged(int hvo, int tag, int ivMin, int cvIns, int cvDel) @@ -315,10 +319,8 @@ int[] GetSenseOccurrences(int hvo) private bool BelongsToInterestingText(ISegment seg) { - if (m_interestingTexts == null) - return true; // no filtering IStText text = seg.Paragraph != null ? seg.Paragraph.Owner as IStText : null; - return (text != null && m_interestingTexts.IsInterestingText(text)); + return (text != null && InterestingTextsList.IsInterestingText(text)); } @@ -327,9 +329,7 @@ private bool BelongsToInterestingText(ISegment seg) /// public bool IsInterestingText(IStText text) { - if (m_interestingTexts == null) - return true; - return m_interestingTexts.IsInterestingText(text); + return InterestingTextsList.IsInterestingText(text); } public override int[] VecProp(int hvo, int tag) @@ -552,8 +552,19 @@ public void SetMediator(Mediator mediator, PropertyTable propertyTable) { Mediator = mediator; PropTable = propertyTable; - m_interestingTexts = InterestingTextsDecorator.GetInterestingTextList(mediator, PropTable, m_services); - m_interestingTexts.InterestingTextsChanged += m_interestingTexts_InterestingTextsChanged; + } + + private InterestingTextList InterestingTextsList + { + get + { + if (m_interestingTexts == null) + { + m_interestingTexts = InterestingTextsDecorator.GetInterestingTextList(Mediator, PropTable, m_services); + m_interestingTexts.InterestingTextsChanged += m_interestingTexts_InterestingTextsChanged; + } + return m_interestingTexts; + } } void m_interestingTexts_InterestingTextsChanged(object sender, InterestingTextsChangedArgs e)