Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Fixed

- [SIL.LCModel] Multi-string (AUni) alternatives in writing systems the cache has not seen yet are no longer dropped on load; the writing system is created on demand, as for string runs, so the result no longer depends on activation order (LT-22834)
- [SIL.LCModel] BaseStyleInfo now loads default font features (ktptFontVariations) from style rules, fixing font features set as style defaults being dropped on reload (LT-22351)
- [SIL.LCModel] BaseStyleInfo no longer clobbers ws-specific font overrides inherited from a based-on style with the default font info's merely-inherited values; only explicitly-set default properties are propagated to ws overrides (LT-22351)
- [SIL.LCModel] BulletInfo now decodes all properties of an encoded bullet font info instead of stopping at the first string property, fixing bullet font features (ktptFontVariations) being lost when a bullet font name was also set (LT-22351)
Expand Down
15 changes: 13 additions & 2 deletions src/SIL.LCModel/DomainImpl/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -929,10 +929,21 @@ internal static int ReadMultiUnicodeAlternative(XElement aUniNode, ILgWritingSys
var wsVal = aUniNode.Attribute("ws");
if (wsVal == null || String.IsNullOrEmpty(wsVal.Value))
return 0;
var wsHvo = wsf.GetWsFromStr(wsVal.Value);
// Like the runs of an AStr (see TsStringSerializer.GetWsForId), create the writing
// system on demand: GetWsFromStr returns 0 for one the cache has not seen yet, which
// dropped the alternative and made the result depend on activation order (LT-22834).
int wsHvo;
try
{
wsHvo = wsf.get_Engine(wsVal.Value).Handle;
}
catch (Exception)
{
// An identifier that cannot be made into a writing system is still dropped.
wsHvo = 0;
}
// Throwing out a string without a ws is probably better than crashing
// and preventing a db from being opened.
// This code currently accepts this data, only storing en__IPA and fr strings.
// <Form>
// <AUni ws="en" />
// <AUni ws="en__IPA">problematic</AUni>
Expand Down
21 changes: 21 additions & 0 deletions tests/SIL.LCModel.Tests/DomainImpl/StringsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,27 @@ public void AppendAlternativesTest()
Assert.AreEqual("Saltillo Mejico", Cache.LangProject.FieldWorkLocation.get_String(spanish.Handle).Text);
}

/// <summary>
/// LT-22834: an AUni alternative in a writing system the cache has not seen yet must be
/// kept (created on demand, as AStr runs are), not dropped.
/// </summary>
[Test]
public void ReadMultiUnicodeAlternative_UnknownWritingSystem_IsKept()
{
const string wsId = "qaa-x-lt22834";
var wsManager = Cache.ServiceLocator.WritingSystemManager;
Assert.AreEqual(0, wsManager.GetWsFromStr(wsId), "precondition: ws must be unknown");
var node = System.Xml.Linq.XElement.Parse("<AUni ws=\"" + wsId + "\">kept</AUni>");

ITsString tss;
var ws = MultiUnicodeAccessor.ReadMultiUnicodeAlternative(node, Cache.WritingSystemFactory, out tss);

Assert.AreNotEqual(0, ws, "alternative in an unknown writing system was dropped");
Assert.AreEqual(ws, wsManager.GetWsFromStr(wsId));
Assert.AreEqual("kept", tss.Text);
Assert.AreEqual(ws, tss.get_WritingSystemAt(0));
}

[Test]
public void ToXml_WorksAsExpected()
{
Expand Down
Loading