Skip to content

Commit

Permalink
Merge branch 'release/9.1' into LT-21963
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeOliver28 authored Dec 16, 2024
2 parents ad68e2d + a41e13c commit 92b2452
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
ghostListField="LexDb.AllExampleTranslationTargets"
field="CmTranslation.Type" bulkEdit="atomicFlatListItem" bulkDelete="false" list="LangProject.TranslationTags"/>
<column layout="StemNameForEntry" label="Stem Name" visibility="dialog"/>
<column layout="AllomorphStemNames" displayWs="best analysis" multipara="true" label="Allomorph Stem Names" sortmethod="MorphSortKey"
<column layout="AllomorphStemNames" displayWs="best analysis" multipara="true" label="Stem Name (Allomorph)" sortmethod="MorphSortKey"
ghostListField="LexDb.AllPossibleAllomorphs" visibility="dialog"/>
<!-- removed as per LT-9899
<column layout="InflectionClassForEntry" label="Inflection Classes (Entry)" visibility="dialog"/>
Expand Down
16 changes: 14 additions & 2 deletions Src/Common/Controls/DetailControls/DataTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,11 @@ public void PropChanged(int hvo, int tag, int ivMin, int cvIns, int cvDel)
// return;
if (m_monitoredProps.Contains(Tuple.Create(hvo, tag)))
{
RefreshList(false);
OnFocusFirstPossibleSlice(null);
// If we call RefreshList now, it causes a crash in the invoker
// because some slice data structures that are being used by the invoker
// get disposed by RefreshList (LT-21980, LT-22011). So we postpone calling
// RefreshList until the work is done.
this.BeginInvoke(new Action(PostponedRefreshList));
}
// Note, in LinguaLinks import we don't have an action handler when we hit this.
else if (m_cache.DomainDataByFlid.GetActionHandler() != null && m_cache.DomainDataByFlid.GetActionHandler().IsUndoOrRedoInProgress)
Expand All @@ -581,6 +584,15 @@ public void PropChanged(int hvo, int tag, int ivMin, int cvIns, int cvDel)
}
}

private void PostponedRefreshList()
{
if (!IsDisposed)
{
RefreshList(false);
OnFocusFirstPossibleSlice(null);
}
}

/// <summary></summary>
public Mediator Mediator
{
Expand Down
29 changes: 0 additions & 29 deletions Src/Common/Controls/DetailControls/MSAReferenceComboBoxSlice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ public override Mediator Mediator
m_MSAPopupTreeManager = new MSAPopupTreeManager(m_tree, m_cache, list,
m_tree.WritingSystemCode, true, m_mediator, m_propertyTable,
m_propertyTable.GetValue<Form>("window"));
m_MSAPopupTreeManager.BeforeChange += m_MSAPopupTreeManager_BeforeChange;
m_MSAPopupTreeManager.AfterChange += m_MSAPopupTreeManager_AfterChange;
m_MSAPopupTreeManager.AfterSelect += m_MSAPopupTreeManager_AfterSelect;
m_MSAPopupTreeManager.Sense = m_obj as ILexSense;
m_MSAPopupTreeManager.PersistenceProvider = m_persistProvider;
Expand Down Expand Up @@ -225,33 +223,6 @@ protected override void UpdateDisplayFromDatabase()
// What do we need to do here, if anything?
}

public void m_MSAPopupTreeManager_BeforeChange(object sender, TreeViewEventArgs e)
{
if (!ContainingDataTree.DoNotRefresh)
{
// Postpone refreshing the screen until m_MSAPopupTreeManager_AfterChange (LT-21980).
ContainingDataTree.DoNotRefresh = true;
m_forceRefresh = true;
}
}

public void m_MSAPopupTreeManager_AfterChange(object sender, TreeViewEventArgs e)
{
if (m_forceRefresh)
{
m_forceRefresh = false;
// We can't call RefreshDataTree directly,
// since that will cause Windows to crash accessing a disposed object.
// So, we queue it on the UI thread instead.
this.BeginInvoke(new Action(RefreshDataTree));
}
}

public void RefreshDataTree()
{
ContainingDataTree.DoNotRefresh = false;
}

private void m_MSAPopupTreeManager_AfterSelect(object sender, TreeViewEventArgs e)
{
// unless we get a mouse click or simulated mouse click (e.g. by ENTER or TAB),
Expand Down
5 changes: 4 additions & 1 deletion Src/LexText/Interlinear/BIRDInterlinearImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,8 @@ private static IAnalysis CreateWordAnalysisStack(LcmCache cache, Word word)

foreach (var wordItem in word.Items)
{
if (wordItem.Value == null)
continue;
ITsString wordForm = null;
switch (wordItem.type)
{
Expand Down Expand Up @@ -758,7 +760,8 @@ private static IAnalysis CreateWordAnalysisStack(LcmCache cache, Word word)
}
else
{
Debug.Assert(analysis != null, "What else could this do?");
// There was an invalid analysis in the file. We can't do anything with it.
return null;
}

// Fill in morphemes, lex. entries, lex. gloss, and lex.gram.info
Expand Down
71 changes: 71 additions & 0 deletions Src/LexText/Interlinear/ITextDllTests/BIRDFormatImportTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,77 @@ public void UglyEmptyDataShouldNotCrash()
}
}

[Test]
public void EmptyTxtItemUnderWordShouldNotCrash()
{
// an interlinear text example xml string
const string xml =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<document version=\"2\">" +
"<interlinear-text guid=\"6a424526-aa64-4912-b8c7-9e5ae0ab4aae\">" +
"<item type=\"title\" lang=\"en\">Test</item>" +
"<paragraphs>" +
"<paragraph guid=\"ccd62b33-c9f6-4e52-917f-00c67c3638c8\">" +
"<phrases>" +
"<phrase begin-time-offset=\"0\" end-time-offset=\"3750\" guid=\"b57a2665-402a-4ab1-af16-655c70df062f\">" +
"<item lang=\"fr\" type=\"txt\">testing paragraph without words</item>" +
"<words>" +
"<word guid=\"093fe3c6-d467-4c28-a03e-d511b94185da\">" +
"<item lang=\"fr\" type=\"txt\"/>" + // empty txt item
"</word>" +
"</words>" +
"<item lang=\"en\" type=\"gls\">In the country of a Mongol king lived three sisters.</item>" +
"</phrase>" +
"<phrase guid=\"441c1171-78a1-481b-9732-b9c558948ce5\">" +
"<item type=\"txt\" lang=\"fr\">This is a test.</item>" +
"<item type=\"segnum\" lang=\"en\">1</item>" +
"<words>" +
"<word guid=\"d161bf25-b6df-418d-b9c1-a396ff3ec5b1\">" +
"<item type=\"txt\" lang=\"fr\">This</item>" +
"</word>" +
"<word guid=\"ab9e81c7-3157-4011-a8a1-68eb1afc0be1\">" +
"<item type=\"txt\" lang=\"fr\">is</item>" +
"</word>" +
"<word guid=\"0ef6172b-07c3-4c91-b0b2-afbebca5fca0\">" +
"<item type=\"txt\" lang=\"fr\">a</item>" +
"</word>" +
"<word guid=\"48949d94-869c-45d5-9251-b68ce7d66cee\">" +
"<item type=\"txt\" lang=\"fr\">test</item>" +
"</word>" +
"<word>" +
"<item type=\"punct\" lang=\"fr\">.</item>" +
"</word>" +
"</words>" +
"<item type=\"gls\" lang=\"en\"></item>" +
"</phrase>" +
"</phrases>" +
"</paragraph>" +
"</paragraphs>" +
"<languages>" +
"<language lang=\"en\" font=\"Charis SIL\" />" +
"<language lang=\"fr\" font=\"Times New Roman\" vernacular=\"true\" />" +
"</languages>" +
"</interlinear-text>" +
"</document>";

var li = new LinguaLinksImport(Cache, null, null);
LCModel.IText text = null;
using(var stream = new MemoryStream(Encoding.ASCII.GetBytes(xml.ToCharArray())))
{
// SUT - Verify that no crash occurs importing this data: see LT-22008
Assert.DoesNotThrow(()=> li.ImportInterlinear(new DummyProgressDlg(), stream, 0, ref text));
using(var firstEntry = Cache.LanguageProject.Texts.GetEnumerator())
{
firstEntry.MoveNext();
var imported = firstEntry.Current;
Assert.That(imported.ContentsOA.ParagraphsOS.Count, Is.EqualTo(1));
Assert.That(((IStTxtPara)imported.ContentsOA.ParagraphsOS[0]).SegmentsOS.Count, Is.EqualTo(2));
// Verify that the words with non-empty txt were imported
Assert.That(((IStTxtPara)imported.ContentsOA.ParagraphsOS[0]).SegmentsOS[1].AnalysesRS.Count, Is.EqualTo(5));
}
}
}

[Test]
public void TestImportMergeFlexTextWithSegnumItem()
{
Expand Down
2 changes: 1 addition & 1 deletion Src/LexText/LexTextControls/LinkMSADlg.resx
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
<value>102, 32</value>
</data>
<data name="m_panel1.Size" type="System.Drawing.Size, System.Drawing">
<value>208, 20</value>
<value>300, 20</value>
</data>
<data name="&gt;&gt;m_panel1.Name" xml:space="preserve">
<value>m_panel1</value>
Expand Down
11 changes: 0 additions & 11 deletions Src/LexText/LexTextControls/MSAPopupTreeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ public class MSAPopupTreeManager : PopupTreeManager

#region Events

public event TreeViewEventHandler BeforeChange;
public event TreeViewEventHandler AfterChange;

#endregion Events

/// <summary>
Expand Down Expand Up @@ -422,19 +419,11 @@ private bool EditExistingMsa()
m_sense.MorphoSyntaxAnalysisRA.Hvo, true, m_sEditGramFunc);
if (dlg.ShowDialog(ParentForm) == DialogResult.OK)
{
if (BeforeChange != null)
{
BeforeChange(this, null);
}
Cache.DomainDataByFlid.BeginUndoTask(String.Format(LexTextControls.ksUndoSetX, FieldName),
String.Format(LexTextControls.ksRedoSetX, FieldName));
m_sense.SandboxMSA = dlg.SandboxMSA;
Cache.DomainDataByFlid.EndUndoTask();
LoadPopupTree(m_sense.MorphoSyntaxAnalysisRA.Hvo);
if (AfterChange != null)
{
AfterChange(this, null);
}
return true;
}
}
Expand Down
11 changes: 11 additions & 0 deletions Src/UnicodeCharEditor/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="icu.net" publicKeyToken="416fdd914afa6b66" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

0 comments on commit 92b2452

Please sign in to comment.