Skip to content

Commit

Permalink
fix: prevent av window deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-is-cute committed Sep 8, 2023
1 parent c979227 commit 0a43f0c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DownloadTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ await this.Plugin.Framework.RunOnFrameworkThread(() => {
// probably antivirus (ioexception is being used by other process or
// access denied)
if (ex.IsAntiVirus()) {
await this.Plugin.PluginUi.AddIfNotPresentAsync(new AntiVirusWindow(this.Plugin));
this.Plugin.PluginUi.OpenAntiVirusWarning();
} else {
ErrorHelper.Handle(ex, $"Error downloading version {this.Version}");
}
Expand Down
10 changes: 3 additions & 7 deletions Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public Plugin() {
var showWarning = await DependencyHelper.CheckDependencies(this);
if (showWarning) {
this.IntegrityFailed = true;
this.PluginUi?.AddIfNotPresent(new AntiVirusWindow(this));
this.PluginUi?.OpenAntiVirusWarning();
}
return showWarning;
Expand Down Expand Up @@ -159,12 +159,8 @@ public Plugin() {
this.LinkPayloads = new LinkPayloads(this);
this.CommandHandler = new CommandHandler(this);

if (startWithAvWarning) {
this.PluginUi.AddIfNotPresent(new AntiVirusWindow(this));
}

if (checkTask is { Status: TaskStatus.RanToCompletion, Result: true }) {
this.PluginUi.AddIfNotPresent(new AntiVirusWindow(this));
if (startWithAvWarning || checkTask is { Status: TaskStatus.RanToCompletion, Result: true }) {
this.PluginUi.OpenAntiVirusWarning();
}

Task.Run(async () => await this.State.UpdatePackages());
Expand Down
4 changes: 4 additions & 0 deletions Ui/PluginUi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ private void OpenConfig() {
this.Visible = true;
}

internal void OpenAntiVirusWarning() {
Task.Run(async () => await this.AddIfNotPresentAsync(new AntiVirusWindow(this.Plugin)));
}

internal bool ShouldForceOpen(Tab tab) {
var should = this.ForceOpen == tab;
if (should) {
Expand Down

0 comments on commit 0a43f0c

Please sign in to comment.