fix: don't try to reload pluginmaster when it already is being reloaded

This commit is contained in:
goat 2020-06-08 21:22:07 +02:00
parent 07a0b3903f
commit 9752ac493d
3 changed files with 27 additions and 22 deletions

View file

@ -77,7 +77,7 @@ namespace Dalamud.Interface
ImGui.Text(Loc.Localize("DalamudSettingsChannel", "General Chat Channel")); ImGui.Text(Loc.Localize("DalamudSettingsChannel", "General Chat Channel"));
ImGui.Combo("##XlChatTypeCombo", ref this.dalamudMessagesChatType, this.chatTypes, ImGui.Combo("##XlChatTypeCombo", ref this.dalamudMessagesChatType, this.chatTypes,
this.chatTypes.Length); this.chatTypes.Length);
ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsChannelHint", "Select the chat channel that is to be used for general XIVLauncher messages.")); ImGui.TextColored(this.hintTextColor, Loc.Localize("DalamudSettingsChannelHint", "Select the chat channel that is to be used for general Dalamud messages."));
ImGui.Dummy(new Vector2(5f, 5f)); ImGui.Dummy(new Vector2(5f, 5f));

View file

@ -42,7 +42,8 @@ namespace Dalamud.Plugin
this.dalamud = dalamud; this.dalamud = dalamud;
this.gameVersion = gameVersion; this.gameVersion = gameVersion;
this.dalamud.PluginRepository.ReloadPluginMaster(); if (this.dalamud.PluginRepository.State != PluginRepository.InitializationState.InProgress)
this.dalamud.PluginRepository.ReloadPluginMasterAsync();
} }
public bool Draw() { public bool Draw() {

View file

@ -34,15 +34,14 @@ namespace Dalamud.Plugin
this.dalamud = dalamud; this.dalamud = dalamud;
this.pluginDirectory = pluginDirectory; this.pluginDirectory = pluginDirectory;
State = InitializationState.InProgress; ReloadPluginMasterAsync();
Task.Run(ReloadPluginMaster).ContinueWith(t => {
if (t.IsFaulted)
State = InitializationState.Fail;
});
} }
public void ReloadPluginMaster() public void ReloadPluginMasterAsync()
{ {
Task.Run(() => {
State = InitializationState.InProgress;
try try
{ {
using var client = new WebClient(); using var client = new WebClient();
@ -53,10 +52,15 @@ namespace Dalamud.Plugin
State = InitializationState.Success; State = InitializationState.Success;
} }
catch(Exception ex) { catch (Exception ex)
{
Log.Error(ex, "Could not download PluginMaster"); Log.Error(ex, "Could not download PluginMaster");
State = InitializationState.Fail; State = InitializationState.Fail;
} }
}).ContinueWith(t => {
if (t.IsFaulted)
State = InitializationState.Fail;
});
} }
public bool InstallPlugin(PluginDefinition definition, bool enableAfterInstall = true) { public bool InstallPlugin(PluginDefinition definition, bool enableAfterInstall = true) {