Skip to content

Commit

Permalink
Fix CLI cleanup (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
gyk4j authored Feb 19, 2024
1 parent 317f389 commit 20f0950
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions WreckCli/Controller/CliController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ public override void Run(CorrectionMode mode, FileSystemInfo fsi)

CliWorker pw = new CliWorker(task, fsi);
pw.AddPropertyChangeListener(propertyChangeListener);

// HACK: Worker must save the reference before Execute as this is single-threaded.
// Saving the Worker after Execute is useless as
// PropertyChangeListener PropertyChange() will be triggered to do
// cleanup immediately within Execute before the reference to the
// worker is saved, which will cause controller.Done() call to be
// skipped.
Worker = pw; // Need to save to Worker for cleanup later.
pw.Execute();
}

Expand All @@ -98,6 +106,12 @@ public void PropertyChange(PropertyChangeEvent evt)
LOG.InfoFormat(
"State = {0}",
Enum.GetName(typeof(CliWorker.StateValue), state));

if(CliWorker.StateValue.Done.Equals(state))
{
if(controller.Worker != null && controller.Worker.IsDone())
controller.Done();
}
}
else if (R.Strings.PropertyProgress.Equals(evt.PropertyName))
{
Expand Down
2 changes: 1 addition & 1 deletion WreckCli/WreckCli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<AppDesignerFolder>Properties</AppDesignerFolder>
<SourceAnalysisOverrideSettingsFile>C:\Users\USER\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile>
<StartArguments>"C:\Users\Public"</StartArguments>
<StartArguments>"C:\temp\Public"</StartArguments>
<StartupObject>Wreck.Program</StartupObject>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
Expand Down

0 comments on commit 20f0950

Please sign in to comment.