From 6bdc785273bcbd9ecd8c6860e418b91f8d33af7c Mon Sep 17 00:00:00 2001 From: Haselnussbomber Date: Fri, 24 Oct 2025 02:29:43 +0200 Subject: [PATCH] Use new Lock objects --- Dalamud/Game/Gui/ContextMenu/ContextMenu.cs | 3 ++- Dalamud/Hooking/Internal/HookManager.cs | 3 ++- Dalamud/Interface/ImGuiFileDialog/FileDialog.Files.cs | 3 ++- .../Interface/Internal/Windows/Data/Widgets/TexWidget.cs | 4 ++-- .../ManagedFontAtlas/Internals/DelegateFontHandle.cs | 3 ++- .../Internals/FontAtlasFactory.Implementation.cs | 6 +++--- .../ManagedFontAtlas/Internals/GamePrebakedFontHandle.cs | 4 +++- .../SharedImmediateTextures/SharedImmediateTexture.cs | 2 +- Dalamud/Storage/ReliableFileStorage.cs | 6 ++++-- 9 files changed, 21 insertions(+), 13 deletions(-) diff --git a/Dalamud/Game/Gui/ContextMenu/ContextMenu.cs b/Dalamud/Game/Gui/ContextMenu/ContextMenu.cs index 7512f4160..f877dd81d 100644 --- a/Dalamud/Game/Gui/ContextMenu/ContextMenu.cs +++ b/Dalamud/Game/Gui/ContextMenu/ContextMenu.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using System.Threading; using Dalamud.Game.Text; using Dalamud.Game.Text.SeStringHandling; @@ -57,7 +58,7 @@ internal sealed unsafe class ContextMenu : IInternalDisposableService, IContextM private Dictionary> MenuItems { get; } = []; - private object MenuItemsLock { get; } = new(); + private Lock MenuItemsLock { get; } = new(); private AgentInterface* SelectedAgent { get; set; } diff --git a/Dalamud/Hooking/Internal/HookManager.cs b/Dalamud/Hooking/Internal/HookManager.cs index 8f5dba583..a61cdd0ea 100644 --- a/Dalamud/Hooking/Internal/HookManager.cs +++ b/Dalamud/Hooking/Internal/HookManager.cs @@ -2,6 +2,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; +using System.Threading; using Dalamud.Logging.Internal; using Dalamud.Memory; @@ -30,7 +31,7 @@ internal class HookManager : IInternalDisposableService /// /// Gets sync root object for hook enabling/disabling. /// - internal static object HookEnableSyncRoot { get; } = new(); + internal static Lock HookEnableSyncRoot { get; } = new(); /// /// Gets a static list of tracked and registered hooks. diff --git a/Dalamud/Interface/ImGuiFileDialog/FileDialog.Files.cs b/Dalamud/Interface/ImGuiFileDialog/FileDialog.Files.cs index e5b7fc15e..1bad08f08 100644 --- a/Dalamud/Interface/ImGuiFileDialog/FileDialog.Files.cs +++ b/Dalamud/Interface/ImGuiFileDialog/FileDialog.Files.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Threading; using Dalamud.Utility; @@ -11,7 +12,7 @@ namespace Dalamud.Interface.ImGuiFileDialog; /// public partial class FileDialog { - private readonly object filesLock = new(); + private readonly Lock filesLock = new(); private readonly DriveListLoader driveListLoader = new(); diff --git a/Dalamud/Interface/Internal/Windows/Data/Widgets/TexWidget.cs b/Dalamud/Interface/Internal/Windows/Data/Widgets/TexWidget.cs index 52fa0e822..349e724f0 100644 --- a/Dalamud/Interface/Internal/Windows/Data/Widgets/TexWidget.cs +++ b/Dalamud/Interface/Internal/Windows/Data/Widgets/TexWidget.cs @@ -137,9 +137,9 @@ internal class TexWidget : IDataWindowWidget conf.QueueSave(); } - var allBlames = this.textureManager.BlameTracker; - lock (allBlames) + lock (this.textureManager.BlameTracker) { + var allBlames = this.textureManager.BlameTracker; ImGui.PushID("blames"u8); var sizeSum = allBlames.Sum(static x => Math.Max(0, x.RawSpecs.EstimatedBytes)); if (ImGui.CollapsingHeader( diff --git a/Dalamud/Interface/ManagedFontAtlas/Internals/DelegateFontHandle.cs b/Dalamud/Interface/ManagedFontAtlas/Internals/DelegateFontHandle.cs index f2c91d264..7ebe509d0 100644 --- a/Dalamud/Interface/ManagedFontAtlas/Internals/DelegateFontHandle.cs +++ b/Dalamud/Interface/ManagedFontAtlas/Internals/DelegateFontHandle.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Linq; +using System.Threading; using Dalamud.Bindings.ImGui; using Dalamud.Interface.Utility; @@ -35,7 +36,7 @@ internal sealed class DelegateFontHandle : FontHandle internal sealed class HandleManager : IFontHandleManager { private readonly HashSet handles = new(); - private readonly object syncRoot = new(); + private readonly Lock syncRoot = new(); /// /// Initializes a new instance of the class. diff --git a/Dalamud/Interface/ManagedFontAtlas/Internals/FontAtlasFactory.Implementation.cs b/Dalamud/Interface/ManagedFontAtlas/Internals/FontAtlasFactory.Implementation.cs index 430f26127..d1fc47447 100644 --- a/Dalamud/Interface/ManagedFontAtlas/Internals/FontAtlasFactory.Implementation.cs +++ b/Dalamud/Interface/ManagedFontAtlas/Internals/FontAtlasFactory.Implementation.cs @@ -1,4 +1,4 @@ -// #define VeryVerboseLog +// #define VeryVerboseLog using System.Collections.Generic; using System.Diagnostics; @@ -41,7 +41,7 @@ internal sealed partial class FontAtlasFactory /// /// If set, disables concurrent font build operation. /// - private static readonly object? NoConcurrentBuildOperationLock = null; // new(); + private static readonly Lock? NoConcurrentBuildOperationLock = null; // new(); private static readonly ModuleLog Log = new(nameof(FontAtlasFactory)); @@ -254,7 +254,7 @@ internal sealed partial class FontAtlasFactory private readonly GamePrebakedFontHandle.HandleManager gameFontHandleManager; private readonly IFontHandleManager[] fontHandleManagers; - private readonly object syncRoot = new(); + private readonly Lock syncRoot = new(); private Task buildTask = EmptyTask; private FontAtlasBuiltData? builtData; diff --git a/Dalamud/Interface/ManagedFontAtlas/Internals/GamePrebakedFontHandle.cs b/Dalamud/Interface/ManagedFontAtlas/Internals/GamePrebakedFontHandle.cs index f6904db7c..96edf6759 100644 --- a/Dalamud/Interface/ManagedFontAtlas/Internals/GamePrebakedFontHandle.cs +++ b/Dalamud/Interface/ManagedFontAtlas/Internals/GamePrebakedFontHandle.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Reactive.Disposables; +using System.Threading; using Dalamud.Bindings.ImGui; using Dalamud.Game.Text; @@ -12,6 +13,7 @@ using Dalamud.Interface.Internal; using Dalamud.Interface.Textures.TextureWraps; using Dalamud.Interface.Utility; using Dalamud.Utility; + using Lumina.Data.Files; using Vector4 = System.Numerics.Vector4; @@ -103,7 +105,7 @@ internal class GamePrebakedFontHandle : FontHandle { private readonly Dictionary gameFontsRc = new(); private readonly HashSet handles = new(); - private readonly object syncRoot = new(); + private readonly Lock syncRoot = new(); /// /// Initializes a new instance of the class. diff --git a/Dalamud/Interface/Textures/Internal/SharedImmediateTextures/SharedImmediateTexture.cs b/Dalamud/Interface/Textures/Internal/SharedImmediateTextures/SharedImmediateTexture.cs index 5f9925ed3..341cd6062 100644 --- a/Dalamud/Interface/Textures/Internal/SharedImmediateTextures/SharedImmediateTexture.cs +++ b/Dalamud/Interface/Textures/Internal/SharedImmediateTextures/SharedImmediateTexture.cs @@ -23,7 +23,7 @@ internal abstract class SharedImmediateTexture private static long instanceCounter; - private readonly object reviveLock = new(); + private readonly Lock reviveLock = new(); private readonly List ownerPlugins = new(); private bool resourceReleased; diff --git a/Dalamud/Storage/ReliableFileStorage.cs b/Dalamud/Storage/ReliableFileStorage.cs index d9f8526c3..0a62ad35d 100644 --- a/Dalamud/Storage/ReliableFileStorage.cs +++ b/Dalamud/Storage/ReliableFileStorage.cs @@ -1,9 +1,11 @@ -using System.IO; +using System.IO; using System.Text; +using System.Threading; using System.Threading.Tasks; using Dalamud.Logging.Internal; using Dalamud.Utility; + using SQLite; namespace Dalamud.Storage; @@ -27,7 +29,7 @@ internal class ReliableFileStorage : IInternalDisposableService { private static readonly ModuleLog Log = new("VFS"); - private readonly object syncRoot = new(); + private readonly Lock syncRoot = new(); private SQLiteConnection? db;