Skip to content

Commit 69b6c0a

Browse files
authored
Fix LT-22110: Intermittent crash in Segment.get_AnalysesRS (#325)
1 parent 27a891c commit 69b6c0a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/SIL.LCModel/DomainServices/AnalysisGuessServices.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ private IDictionary<IAnalysis, Dictionary<IAnalysis, PriorityCount>> GetAnalysis
402402
var segs = new HashSet<ISegment>();
403403
foreach (ISegment seg in wordform.OccurrencesInTexts)
404404
{
405+
if (!seg.IsValidObject) continue;
405406
if (segs.Contains(seg)) continue;
406407
segs.Add(seg);
407408
for (int i = 0; i < seg.AnalysesRS.Count; i++)
@@ -462,6 +463,7 @@ private Dictionary<IAnalysis, Dictionary<IAnalysis, PriorityCount>> GetGlossCoun
462463
return counts;
463464
foreach (ISegment seg in analysis.Wordform.OccurrencesInTexts)
464465
{
466+
if (!seg.IsValidObject) continue;
465467
if (segs.Contains(seg)) continue;
466468
segs.Add(seg);
467469
for (int i = 0; i < seg.AnalysesRS.Count; i++)
@@ -732,6 +734,8 @@ private IWfiWordform GetLowercaseWordform(AnalysisOccurrence occurrence, int ws,
732734
return null;
733735
if (onlyIndexZeroLowercaseMatching && occurrence.Index != 0)
734736
return null;
737+
if (occurrence.Segment == null || !occurrence.Segment.IsValidObject)
738+
return null;
735739
ITsString tssWfBaseline = occurrence.BaselineText;
736740
var cf = new CaseFunctions(Cache.ServiceLocator.WritingSystemManager.Get(ws));
737741
string sLower = cf.ToLower(tssWfBaseline.Text);

src/SIL.LCModel/DomainServices/AnalysisOccurrence.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public virtual IAnalysis Analysis
5656
{
5757
get
5858
{
59-
if (Segment?.AnalysesRS != null && Index < Segment.AnalysesRS.Count)
59+
if (Segment != null && Segment.IsValidObject && Segment.AnalysesRS != null && Index < Segment.AnalysesRS.Count)
6060
return Segment.AnalysesRS[Index];
6161
return null;
6262
}

0 commit comments

Comments
 (0)