Skip to content

Commit

Permalink
Fixes LT-21934: FLEx freezes when clicking "Close" if parser is runni…
Browse files Browse the repository at this point in the history
…ng (#205)

Co-authored-by: Jake Oliver <[email protected]>
  • Loading branch information
jtmaxwell3 and JakeOliver28 authored Nov 14, 2024
1 parent 3e559e7 commit b012a3f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 17 deletions.
3 changes: 0 additions & 3 deletions Src/LexText/ParserCore/ParseFiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,6 @@ private bool UpdateWordforms(object parameter)
if (work.CheckParser)
{
// This was just a test. Don't update data.
string testform = work.Wordform.Form.BestVernacularAlternative.Text;
using (new TaskReport(String.Format(ParserCoreStrings.ksTestX, testform), m_taskUpdateHandler))
{ }
FireWordformUpdated(work.Wordform, work.Priority, work.ParseResult, work.CheckParser);
continue;
}
Expand Down
18 changes: 9 additions & 9 deletions Src/LexText/ParserCore/ParserCoreStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Src/LexText/ParserCore/ParserCoreStrings.resx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Expand Down Expand Up @@ -186,8 +186,8 @@
<data name="ksUnknownNaturalClass" xml:space="preserve">
<value>Unknown Natural Class!</value>
</data>
<data name="ksTestX" xml:space="preserve">
<value>Tested {0}</value>
<data name="ksParsingX" xml:space="preserve">
<value>Parsing {0}</value>
</data>
<data name="ksMaxElementsInRule" xml:space="preserve">
<value>A rule can't have more than one element in its left-hand side or its right-hand side.</value>
Expand Down
12 changes: 10 additions & 2 deletions Src/LexText/ParserCore/ParserWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,12 @@ public bool UpdateWordform(IWfiWordform wordform, ParserPriority priority, bool
CheckNeedsUpdate();
var normalizer = CustomIcu.GetIcuNormalizer(FwNormalizationMode.knmNFD);
var word = normalizer.Normalize(form.Text.Replace(' ', '.'));
ParseResult result = null;
var stopWatch = System.Diagnostics.Stopwatch.StartNew();
ParseResult result = m_parser.ParseWord(word);
using (var task = new TaskReport(String.Format(ParserCoreStrings.ksParsingX, word), m_taskUpdateHandler))
{
result = m_parser.ParseWord(word);
}
stopWatch.Stop();
result.ParseTime = stopWatch.ElapsedMilliseconds;

Expand All @@ -160,8 +164,12 @@ public bool UpdateWordform(IWfiWordform wordform, ParserPriority priority, bool
if (m_cache.ServiceLocator.GetInstance<IWfiWordformRepository>().TryGetObject(text, out lcWordform))
{
var lcWord = normalizer.Normalize(sLower.Replace(' ', '.'));
ParseResult lcResult = null;
stopWatch.Start();
var lcResult = m_parser.ParseWord(lcWord);
using (var task = new TaskReport(String.Format(ParserCoreStrings.ksParsingX, word), m_taskUpdateHandler))
{
lcResult = m_parser.ParseWord(lcWord);
}
stopWatch.Stop();
lcResult.ParseTime = stopWatch.ElapsedMilliseconds;
if (lcResult.Analyses.Count > 0 && lcResult.ErrorMessage == null)
Expand Down
2 changes: 2 additions & 0 deletions Src/XCore/xWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1929,6 +1929,8 @@ public bool OnCloseWindow(object sender)
{
CheckDisposed();

if (Mediator != null)
Mediator.SendMessage("StopParser", null);
this.Close();

return true;
Expand Down

0 comments on commit b012a3f

Please sign in to comment.