Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes LT-21934: FLEx freezes when clicking "Close" if parser is running #205

Merged
merged 2 commits into from
Nov 14, 2024
Merged
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
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
Loading