Skip to content

Commit

Permalink
Fix LT-20509: Can't delete words with undefined phonemes
Browse files Browse the repository at this point in the history
  • Loading branch information
jtmaxwell3 committed Sep 20, 2024
1 parent 33c3fdc commit 921a4a0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Src/FdoUi/WfiWordformUi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
// This software is licensed under the LGPL, version 2.1 or later
// (http://www.gnu.org/licenses/lgpl-2.1.html)

using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Windows.Forms;

using SIL.LCModel;
using SIL.LCModel.Infrastructure;

namespace SIL.FieldWorks.FdoUi
{
Expand Down Expand Up @@ -76,6 +79,19 @@ protected override bool IsAcceptableContextToJump(string toolCurrent, string too

public override bool CanDelete(out string cannotDeleteMsg)
{
// Delete problem annotations of the word form.
// These aren't used within FieldWorks, and they block deletion.
NonUndoableUnitOfWorkHelper.Do(m_cache.ActionHandlerAccessor, () =>
{
ICmBaseAnnotationRepository repository = base.Object.Cache.ServiceLocator.GetInstance<ICmBaseAnnotationRepository>();
IEnumerable<ICmBaseAnnotation> problemAnnotations =
from ann in repository.AllInstances()
where ann.BeginObjectRA == base.Object && ann.SourceRA is ICmAgent
select ann;
foreach (ICmBaseAnnotation problem in problemAnnotations)
m_cache.DomainDataByFlid.DeleteObj(problem.Hvo);
});

if (base.CanDelete(out cannotDeleteMsg))
return true;
cannotDeleteMsg = FdoUiStrings.ksCannotDeleteWordform;
Expand Down

0 comments on commit 921a4a0

Please sign in to comment.