From 9752ac493d92ae929d82e363e1709aa359ed50c8 Mon Sep 17 00:00:00 2001 From: goat <16760685+goaaats@users.noreply.github.com> Date: Mon, 8 Jun 2020 21:22:07 +0200 Subject: [PATCH] fix: don't try to reload pluginmaster when it already is being reloaded --- Dalamud/Interface/DalamudSettingsWindow.cs | 2 +- Dalamud/Plugin/PluginInstallerWindow.cs | 3 +- Dalamud/Plugin/PluginRepository.cs | 44 ++++++++++++---------- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/Dalamud/Interface/DalamudSettingsWindow.cs b/Dalamud/Interface/DalamudSettingsWindow.cs index 4d29acfc7..8473624f9 100644 --- a/Dalamud/Interface/DalamudSettingsWindow.cs +++ b/Dalamud/Interface/DalamudSettingsWindow.cs @@ -77,7 +77,7 @@ namespace Dalamud.Interface ImGui.Text(Loc.Localize("DalamudSettingsChannel", "General Chat Channel")); ImGui.Combo("##XlChatTypeCombo", ref this.dalamudMessagesChatType, this.chatTypes, 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)); diff --git a/Dalamud/Plugin/PluginInstallerWindow.cs b/Dalamud/Plugin/PluginInstallerWindow.cs index 5bf2ce3fb..609c5f0ee 100644 --- a/Dalamud/Plugin/PluginInstallerWindow.cs +++ b/Dalamud/Plugin/PluginInstallerWindow.cs @@ -42,7 +42,8 @@ namespace Dalamud.Plugin this.dalamud = dalamud; this.gameVersion = gameVersion; - this.dalamud.PluginRepository.ReloadPluginMaster(); + if (this.dalamud.PluginRepository.State != PluginRepository.InitializationState.InProgress) + this.dalamud.PluginRepository.ReloadPluginMasterAsync(); } public bool Draw() { diff --git a/Dalamud/Plugin/PluginRepository.cs b/Dalamud/Plugin/PluginRepository.cs index 47507ebad..c92ff898c 100644 --- a/Dalamud/Plugin/PluginRepository.cs +++ b/Dalamud/Plugin/PluginRepository.cs @@ -34,31 +34,35 @@ namespace Dalamud.Plugin this.dalamud = dalamud; this.pluginDirectory = pluginDirectory; - State = InitializationState.InProgress; - Task.Run(ReloadPluginMaster).ContinueWith(t => { + ReloadPluginMasterAsync(); + } + + public void ReloadPluginMasterAsync() + { + Task.Run(() => { + State = InitializationState.InProgress; + + try + { + using var client = new WebClient(); + + var data = client.DownloadString(PluginRepoBaseUrl + "pluginmaster.json"); + + this.PluginMaster = JsonConvert.DeserializeObject>(data); + + State = InitializationState.Success; + } + catch (Exception ex) + { + Log.Error(ex, "Could not download PluginMaster"); + State = InitializationState.Fail; + } + }).ContinueWith(t => { if (t.IsFaulted) State = InitializationState.Fail; }); } - public void ReloadPluginMaster() - { - try - { - using var client = new WebClient(); - - var data = client.DownloadString(PluginRepoBaseUrl + "pluginmaster.json"); - - this.PluginMaster = JsonConvert.DeserializeObject>(data); - - State = InitializationState.Success; - } - catch(Exception ex) { - Log.Error(ex, "Could not download PluginMaster"); - State = InitializationState.Fail; - } - } - public bool InstallPlugin(PluginDefinition definition, bool enableAfterInstall = true) { try {