From a5456a54a0001493b9bee712a476e81a4cac324b Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Thu, 16 Feb 2023 22:09:29 +0100 Subject: [PATCH] DI: Cleanup --- Pal.Client/DependencyInjectionContext.cs | 5 ++++- Pal.Client/Plugin.cs | 9 ++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Pal.Client/DependencyInjectionContext.cs b/Pal.Client/DependencyInjectionContext.cs index 7d4bbb1..c7aa306 100644 --- a/Pal.Client/DependencyInjectionContext.cs +++ b/Pal.Client/DependencyInjectionContext.cs @@ -171,10 +171,13 @@ namespace Pal.Client PluginLog.Information("Async init complete"); } + catch (ObjectDisposedException) + { + } catch (Exception e) { PluginLog.Error(e, "Async load failed"); - chatGui.PrintError($"Async loading failed: {e}"); + chatGui.PrintError($"Async loading failed: {e.GetType()}: {e.Message}"); } }); } diff --git a/Pal.Client/Plugin.cs b/Pal.Client/Plugin.cs index 74cb8f4..f30ff6b 100644 --- a/Pal.Client/Plugin.cs +++ b/Pal.Client/Plugin.cs @@ -23,17 +23,20 @@ namespace Pal.Client private readonly DalamudPluginInterface _pluginInterface; private readonly IPalacePalConfiguration _configuration; private readonly RenderAdapter _renderAdapter; + private readonly WindowSystem _windowSystem; public Plugin( IServiceProvider serviceProvider, DalamudPluginInterface pluginInterface, IPalacePalConfiguration configuration, - RenderAdapter renderAdapter) + RenderAdapter renderAdapter, + WindowSystem windowSystem) { _serviceProvider = serviceProvider; _pluginInterface = pluginInterface; _configuration = configuration; _renderAdapter = renderAdapter; + _windowSystem = windowSystem; LanguageChanged(pluginInterface.UiLanguage); @@ -63,14 +66,14 @@ namespace Pal.Client private void LanguageChanged(string languageCode) { Localization.Culture = new CultureInfo(languageCode); - _serviceProvider.GetRequiredService().Windows.OfType() + _windowSystem.Windows.OfType() .Each(w => w.LanguageChanged()); } private void Draw() { _renderAdapter.DrawLayers(); - _serviceProvider.GetRequiredService().Draw(); + _windowSystem.Draw(); } } }