diff --git a/Src/LexText/LexTextControls/PhonologicalFeaturePopupTreeManager.cs b/Src/LexText/LexTextControls/PhonologicalFeaturePopupTreeManager.cs index 53e5efef59..7c2fd3cbc4 100644 --- a/Src/LexText/LexTextControls/PhonologicalFeaturePopupTreeManager.cs +++ b/Src/LexText/LexTextControls/PhonologicalFeaturePopupTreeManager.cs @@ -221,9 +221,12 @@ protected override void Dispose(bool disposing) { Cache.DomainDataByFlid.BeginUndoTask(LexTextControls.ksUndoInsertPhonologicalFeature, LexTextControls.ksRedoInsertPhonologicalFeature); - foreach (var cmBaseAnnotation in m_annotations) + foreach (var cmBaseAnnotation in m_annotations.ToList()) { - cmBaseAnnotation.Delete(); + if (cmBaseAnnotation.IsValidObject) + cmBaseAnnotation.Delete(); + else + m_annotations.Remove(cmBaseAnnotation); } Cache.DomainDataByFlid.EndUndoTask(); }