Skip to content

Commit a00f699

Browse files
Add some code that should avoid crashes seen in the wild
1 parent eb0607c commit a00f699

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/SIL.LCModel/DomainImpl/Vectors.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,12 +1329,15 @@ public virtual T this[int index]
13291329
/// </remarks>
13301330
public int IndexOf(T obj)
13311331
{
1332-
lock (SyncRoot)
1332+
if (obj != null)
13331333
{
1334-
// No need to fluff items up!
1335-
for (int i = 0; i < m_items.Count; i++)
1336-
if (m_items[i].Id == obj.Id)
1337-
return i;
1334+
lock (SyncRoot)
1335+
{
1336+
// No need to fluff items up!
1337+
for (int i = 0; i < m_items.Count; i++)
1338+
if (m_items[i].Id == obj.Id)
1339+
return i;
1340+
}
13381341
}
13391342
return -1;
13401343
}

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(Index < Segment.AnalysesRS.Count)
59+
if (Segment?.AnalysesRS != null && Index < Segment.AnalysesRS.Count)
6060
return Segment.AnalysesRS[Index];
6161
return null;
6262
}

src/SIL.LCModel/Infrastructure/Impl/RepositoryAdditions.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,7 @@ internal partial class ConstituentChartCellPartRepository
366366
/// </summary>
367367
public IEnumerable<IConstituentChartCellPart> InstancesWithChartCellColumn(ICmPossibility target)
368368
{
369-
((ICmObjectRepositoryInternal)m_cache.ServiceLocator.ObjectRepository).EnsureCompleteIncomingRefsFrom(
370-
ConstituentChartCellPartTags.kflidColumn);
371-
return ((ICmObjectInternal)target).IncomingRefsFrom(ConstituentChartCellPartTags.kflidColumn).Cast
372-
<IConstituentChartCellPart>();
369+
return AllInstances().Where(cccp => cccp.ColumnRA == target);
373370
}
374371
}
375372
#endregion

0 commit comments

Comments
 (0)