Some small fixes/improvements.

This commit is contained in:
Ottermandias 2023-05-27 13:56:43 +02:00
parent 96aaefd3e2
commit f938531e21
6 changed files with 13 additions and 16 deletions

View file

@ -1,5 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Dalamud; using Dalamud;
using Dalamud.Logging; using Dalamud.Logging;

View file

@ -3,7 +3,6 @@ using OtterGui.Classes;
using Penumbra.Meta.Manipulations; using Penumbra.Meta.Manipulations;
using Penumbra.Mods; using Penumbra.Mods;
using System; using System;
using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;

View file

@ -325,17 +325,12 @@ public class CollectionCacheManager : IDisposable
/// </summary> /// </summary>
public void CreateNecessaryCaches() public void CreateNecessaryCaches()
{ {
var tasks = _active.SpecialAssignments.Select(p => p.Value) Parallel.ForEach(_active.SpecialAssignments.Select(p => p.Value)
.Concat(_active.Individuals.Select(p => p.Collection)) .Concat(_active.Individuals.Select(p => p.Collection))
.Prepend(_active.Current) .Prepend(_active.Current)
.Prepend(_active.Default) .Prepend(_active.Default)
.Prepend(_active.Interface) .Prepend(_active.Interface)
.Where(CreateCache) .Where(CreateCache), CalculateEffectiveFileListInternal);
.Select(c => Task.Run(() => CalculateEffectiveFileListInternal(c)))
.ToArray();
Penumbra.Log.Debug($"Creating {tasks.Length} necessary caches.");
Task.WaitAll(tasks);
} }
private void OnModDiscoveryStarted() private void OnModDiscoveryStarted()
@ -349,10 +344,7 @@ public class CollectionCacheManager : IDisposable
} }
private void OnModDiscoveryFinished() private void OnModDiscoveryFinished()
{ => Parallel.ForEach(Active, CalculateEffectiveFileListInternal);
var tasks = Active.Select(c => Task.Run(() => CalculateEffectiveFileListInternal(c))).ToArray();
Task.WaitAll(tasks);
}
/// <summary> /// <summary>
/// Update forced files only on framework. /// Update forced files only on framework.

View file

@ -51,11 +51,13 @@ public class CommandHandler : IDisposable
_collectionEditor = collectionEditor; _collectionEditor = collectionEditor;
framework.RunOnFrameworkThread(() => framework.RunOnFrameworkThread(() =>
{ {
_commandManager.RemoveHandler(CommandName);
_commandManager.AddHandler(CommandName, new CommandInfo(OnCommand) _commandManager.AddHandler(CommandName, new CommandInfo(OnCommand)
{ {
HelpMessage = "Without arguments, toggles the main window. Use /penumbra help to get further command help.", HelpMessage = "Without arguments, toggles the main window. Use /penumbra help to get further command help.",
ShowInHelp = true, ShowInHelp = true,
}); });
Penumbra.Log.Information($"Registered {CommandName} with Dalamud.");
}); });
} }

View file

@ -140,7 +140,10 @@ public unsafe partial class CharacterUtility : IDisposable
/// <summary> Return all relevant resources to the default resource. </summary> /// <summary> Return all relevant resources to the default resource. </summary>
public void ResetAll() public void ResetAll()
{ {
if (!Ready)
return;
foreach (var list in _lists) foreach (var list in _lists)
list.Dispose(); list.Dispose();

View file

@ -1,3 +1,4 @@
using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -86,8 +87,9 @@ public class Penumbra : IDalamudPlugin
if (_characterUtility.Ready) if (_characterUtility.Ready)
_residentResources.Reload(); _residentResources.Reload();
} }
catch catch(Exception ex)
{ {
Log.Error($"Error constructing Penumbra, Disposing again:\n{ex}");
Dispose(); Dispose();
throw; throw;
} }