Fix warning

This commit is contained in:
2025-10-30 22:13:38 +01:00
parent d891dceb28
commit b4108c7803
40 changed files with 378 additions and 193 deletions

View File

@@ -4,10 +4,8 @@ using System.Linq;
using System.Threading.Tasks;
using Dalamud.Bindings.ImGui;
using Dalamud.Interface.Colors;
using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
using Dalamud.Plugin.Services;
using MareSynchronos.MareConfiguration;
using MareSynchronos.PlayerData.Pairs;
using MareSynchronos.Services.Mediator;
@@ -25,7 +23,6 @@ public class AutoDetectUi : WindowMediatorSubscriberBase
{
private readonly MareConfigService _configService;
private readonly DalamudUtilService _dalamud;
private readonly IObjectTable _objectTable;
private readonly AutoDetectRequestService _requestService;
private readonly NearbyPendingService _pendingService;
private readonly PairManager _pairManager;
@@ -33,14 +30,13 @@ public class AutoDetectUi : WindowMediatorSubscriberBase
private readonly HashSet<string> _acceptInFlight = new(StringComparer.Ordinal);
public AutoDetectUi(ILogger<AutoDetectUi> logger, MareMediator mediator,
MareConfigService configService, DalamudUtilService dalamudUtilService, IObjectTable objectTable,
MareConfigService configService, DalamudUtilService dalamudUtilService,
AutoDetectRequestService requestService, NearbyPendingService pendingService, PairManager pairManager,
PerformanceCollectorService performanceCollectorService)
: base(logger, mediator, "AutoDetect", performanceCollectorService)
{
_configService = configService;
_dalamud = dalamudUtilService;
_objectTable = objectTable;
_requestService = requestService;
_pendingService = pendingService;
_pairManager = pairManager;

View File

@@ -544,7 +544,8 @@ internal sealed partial class CharaDataHubUi
{
if (_uiSharedService.IconTextButton(FontAwesomeIcon.ArrowCircleDown, "Download your Online Character Data from Server"))
{
_ = _charaDataManager.GetAllData(_disposalCts.Token);
var cts = EnsureFreshCts(ref _disposalCts);
_ = _charaDataManager.GetAllData(cts.Token);
}
}
if (_charaDataManager.DataGetTimeoutTask != null && !_charaDataManager.DataGetTimeoutTask.IsCompleted)
@@ -654,7 +655,8 @@ internal sealed partial class CharaDataHubUi
{
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Plus, "New Character Data Entry"))
{
_charaDataManager.CreateCharaDataEntry(_closalCts.Token);
var cts = EnsureFreshCts(ref _closalCts);
_charaDataManager.CreateCharaDataEntry(cts.Token);
_selectNewEntry = true;
}
}
@@ -848,4 +850,4 @@ internal sealed partial class CharaDataHubUi
}
}
}
}
}

View File

@@ -204,7 +204,8 @@ internal partial class CharaDataHubUi
{
if (_uiSharedService.IconTextButton(FontAwesomeIcon.ArrowCircleDown, "Update Data Shared With You"))
{
_ = _charaDataManager.GetAllSharedData(_disposalCts.Token).ContinueWith(u => UpdateFilteredItems());
var cts = EnsureFreshCts(ref _disposalCts);
_ = _charaDataManager.GetAllSharedData(cts.Token).ContinueWith(u => UpdateFilteredItems());
}
}
if (_charaDataManager.GetSharedWithYouTimeoutTask != null && !_charaDataManager.GetSharedWithYouTimeoutTask.IsCompleted)

View File

@@ -1,4 +1,5 @@
using Dalamud.Bindings.ImGui;
using System;
using Dalamud.Bindings.ImGui;
using Dalamud.Interface;
using Dalamud.Interface.Colors;
using Dalamud.Interface.ImGuiFileDialog;
@@ -30,9 +31,9 @@ internal sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
private readonly CharaDataGposeTogetherManager _charaDataGposeTogetherManager;
private readonly ServerConfigurationManager _serverConfigurationManager;
private readonly UiSharedService _uiSharedService;
private CancellationTokenSource _closalCts = new();
private CancellationTokenSource? _closalCts = new();
private bool _disableUI = false;
private CancellationTokenSource _disposalCts = new();
private CancellationTokenSource? _disposalCts = new();
private string _exportDescription = string.Empty;
private string _filterCodeNote = string.Empty;
private string _filterDescription = string.Empty;
@@ -123,7 +124,14 @@ internal sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
return;
}
_closalCts.Cancel();
try
{
_closalCts?.Cancel();
}
catch (ObjectDisposedException)
{
}
EnsureFreshCts(ref _closalCts);
SelectedDtoId = string.Empty;
_filteredDict = null;
_sharedWithYouOwnerFilter = string.Empty;
@@ -135,15 +143,15 @@ internal sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
public override void OnOpen()
{
_closalCts = _closalCts.CancelRecreate();
EnsureFreshCts(ref _closalCts);
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
_closalCts.CancelDispose();
_disposalCts.CancelDispose();
CancelAndDispose(ref _closalCts);
CancelAndDispose(ref _disposalCts);
}
base.Dispose(disposing);
@@ -689,7 +697,8 @@ internal sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
{
if (_uiSharedService.IconTextButton(FontAwesomeIcon.ArrowCircleDown, "Download your Character Data"))
{
_ = _charaDataManager.GetAllData(_disposalCts.Token);
var cts = EnsureFreshCts(ref _disposalCts);
_ = _charaDataManager.GetAllData(cts.Token);
}
}
if (_charaDataManager.DataGetTimeoutTask != null && !_charaDataManager.DataGetTimeoutTask.IsCompleted)
@@ -1104,4 +1113,26 @@ internal sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
drawAction();
if (_disableUI) ImGui.BeginDisabled();
}
}
private static CancellationTokenSource EnsureFreshCts(ref CancellationTokenSource? cts)
{
CancelAndDispose(ref cts);
cts = new CancellationTokenSource();
return cts;
}
private static void CancelAndDispose(ref CancellationTokenSource? cts)
{
if (cts == null) return;
try
{
cts.Cancel();
}
catch (ObjectDisposedException)
{
}
cts.Dispose();
cts = null;
}
}

View File

@@ -34,8 +34,8 @@ namespace MareSynchronos.UI;
public class CompactUi : WindowMediatorSubscriberBase
{
public float TransferPartHeight;
public float WindowContentWidth;
public float TransferPartHeight { get; internal set; }
public float WindowContentWidth { get; private set; }
private readonly ApiController _apiController;
private readonly MareConfigService _configService;
private readonly ConcurrentDictionary<GameObjectHandler, Dictionary<string, FileDownloadStatus>> _currentDownloads = new();
@@ -127,7 +127,7 @@ public class CompactUi : WindowMediatorSubscriberBase
_dataAnalysisUi = dataAnalysisUi;
var tagHandler = new TagHandler(_serverManager);
_groupPanel = new(this, uiShared, _pairManager, chatService, uidDisplayHandler, _configService, _serverManager, _charaDataManager, _autoDetectRequestService);
_groupPanel = new(this, uiShared, _pairManager, chatService, uidDisplayHandler, _serverManager, _charaDataManager, _autoDetectRequestService);
_selectGroupForPairUi = new(tagHandler, uidDisplayHandler, _uiSharedService);
_selectPairsForGroupUi = new(tagHandler, uidDisplayHandler);
_pairGroupsUi = new(configService, tagHandler, uidDisplayHandler, apiController, _selectPairsForGroupUi, _uiSharedService);

View File

@@ -30,7 +30,6 @@ internal sealed class GroupPanel
private readonly CompactUi _mainUi;
private readonly PairManager _pairManager;
private readonly ChatService _chatService;
private readonly MareConfigService _mareConfig;
private readonly ServerConfigurationManager _serverConfigurationManager;
private readonly CharaDataManager _charaDataManager;
private readonly AutoDetectRequestService _autoDetectRequestService;
@@ -75,7 +74,7 @@ internal sealed class GroupPanel
private string _syncShellToJoin = string.Empty;
public GroupPanel(CompactUi mainUi, UiSharedService uiShared, PairManager pairManager, ChatService chatServivce,
UidDisplayHandler uidDisplayHandler, MareConfigService mareConfig, ServerConfigurationManager serverConfigurationManager,
UidDisplayHandler uidDisplayHandler, ServerConfigurationManager serverConfigurationManager,
CharaDataManager charaDataManager, AutoDetectRequestService autoDetectRequestService)
{
_mainUi = mainUi;
@@ -83,7 +82,6 @@ internal sealed class GroupPanel
_pairManager = pairManager;
_chatService = chatServivce;
_uidDisplayHandler = uidDisplayHandler;
_mareConfig = mareConfig;
_serverConfigurationManager = serverConfigurationManager;
_charaDataManager = charaDataManager;
_autoDetectRequestService = autoDetectRequestService;

View File

@@ -249,9 +249,4 @@ public class PairGroupsUi
}
}
private void ToggleTagOpen(string tag)
{
bool open = !_tagHandler.IsTagOpen(tag);
_tagHandler.SetTagOpen(tag, open);
}
}

View File

@@ -9,6 +9,7 @@ using MareSynchronos.Services.Mediator;
using MareSynchronos.Utils;
using Microsoft.Extensions.Logging;
using System.Numerics;
using System;
namespace MareSynchronos.UI;
@@ -20,7 +21,7 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
private readonly UiSharedService _uiSharedService;
private readonly Dictionary<string, string[]> _texturesToConvert = new(StringComparer.Ordinal);
private Dictionary<ObjectKind, Dictionary<string, CharacterAnalyzer.FileDataEntry>>? _cachedAnalysis;
private CancellationTokenSource _conversionCancellationTokenSource = new();
private CancellationTokenSource? _conversionCancellationTokenSource = new();
private string _conversionCurrentFileName = string.Empty;
private int _conversionCurrentFileProgress = 0;
private Task? _conversionTask;
@@ -74,7 +75,7 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
UiSharedService.TextWrapped("Current file: " + _conversionCurrentFileName);
if (_uiSharedService.IconTextButton(FontAwesomeIcon.StopCircle, "Cancel conversion"))
{
_conversionCancellationTokenSource.Cancel();
TryCancel(_conversionCancellationTokenSource);
}
UiSharedService.SetScaledWindowSize(500);
ImGui.EndPopup();
@@ -294,8 +295,8 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
, ImGuiColors.DalamudYellow);
if (_texturesToConvert.Count > 0 && _uiSharedService.IconTextButton(FontAwesomeIcon.PlayCircle, "Start conversion of " + _texturesToConvert.Count + " texture(s)"))
{
_conversionCancellationTokenSource = _conversionCancellationTokenSource.CancelRecreate();
_conversionTask = _ipcManager.Penumbra.ConvertTextureFiles(_logger, _texturesToConvert, _conversionProgress, _conversionCancellationTokenSource.Token);
var conversionCts = EnsureFreshCts(ref _conversionCancellationTokenSource);
_conversionTask = _ipcManager.Penumbra.ConvertTextureFiles(_logger, _texturesToConvert, _conversionProgress, conversionCts.Token);
}
}
}
@@ -354,8 +355,13 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
protected override void Dispose(bool disposing)
{
if (disposing)
{
CancelAndDispose(ref _conversionCancellationTokenSource);
_conversionProgress.ProgressChanged -= ConversionProgress_ProgressChanged;
}
base.Dispose(disposing);
_conversionProgress.ProgressChanged -= ConversionProgress_ProgressChanged;
}
private void ConversionProgress_ProgressChanged(object? sender, (string, int) e)
@@ -489,4 +495,31 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
}
}
}
}
private static CancellationTokenSource EnsureFreshCts(ref CancellationTokenSource? cts)
{
CancelAndDispose(ref cts);
cts = new CancellationTokenSource();
return cts;
}
private static void CancelAndDispose(ref CancellationTokenSource? cts)
{
if (cts == null) return;
TryCancel(cts);
cts.Dispose();
cts = null;
}
private static void TryCancel(CancellationTokenSource? cts)
{
if (cts == null) return;
try
{
cts.Cancel();
}
catch (ObjectDisposedException)
{
}
}
}

View File

@@ -22,7 +22,6 @@ public class EditProfileUi : WindowMediatorSubscriberBase
private readonly FileDialogManager _fileDialogManager;
private readonly MareProfileManager _mareProfileManager;
private readonly UiSharedService _uiSharedService;
private readonly ServerConfigurationManager _serverConfigurationManager;
private bool _adjustedForScollBarsLocalProfile = false;
private bool _adjustedForScollBarsOnlineProfile = false;
private string _descriptionText = string.Empty;
@@ -34,7 +33,6 @@ public class EditProfileUi : WindowMediatorSubscriberBase
public EditProfileUi(ILogger<EditProfileUi> logger, MareMediator mediator,
ApiController apiController, UiSharedService uiSharedService, FileDialogManager fileDialogManager,
ServerConfigurationManager serverConfigurationManager,
MareProfileManager mareProfileManager, PerformanceCollectorService performanceCollectorService)
: base(logger, mediator, "Umbra Edit Profile###UmbraSyncEditProfileUI", performanceCollectorService)
{
@@ -47,7 +45,6 @@ public class EditProfileUi : WindowMediatorSubscriberBase
_apiController = apiController;
_uiSharedService = uiSharedService;
_fileDialogManager = fileDialogManager;
_serverConfigurationManager = serverConfigurationManager;
_mareProfileManager = mareProfileManager;
Mediator.Subscribe<GposeStartMessage>(this, (_) => { _wasOpen = IsOpen; IsOpen = false; });

View File

@@ -16,25 +16,22 @@ namespace MareSynchronos.UI;
public class PopoutProfileUi : WindowMediatorSubscriberBase
{
private readonly MareProfileManager _mareProfileManager;
private readonly PairManager _pairManager;
private readonly ServerConfigurationManager _serverManager;
private readonly UiSharedService _uiSharedService;
private Vector2 _lastMainPos = Vector2.Zero;
private Vector2 _lastMainSize = Vector2.Zero;
private byte[] _lastProfilePicture = [];
private byte[] _lastSupporterPicture = [];
private Pair? _pair;
private IDalamudTextureWrap? _supporterTextureWrap;
private IDalamudTextureWrap? _textureWrap;
public PopoutProfileUi(ILogger<PopoutProfileUi> logger, MareMediator mediator, UiSharedService uiSharedService,
ServerConfigurationManager serverManager, MareConfigService mareConfigService,
MareProfileManager mareProfileManager, PairManager pairManager, PerformanceCollectorService performanceCollectorService) : base(logger, mediator, "###UmbraSyncPopoutProfileUI", performanceCollectorService)
MareProfileManager mareProfileManager, PerformanceCollectorService performanceCollectorService) : base(logger, mediator, "###UmbraSyncPopoutProfileUI", performanceCollectorService)
{
_uiSharedService = uiSharedService;
_serverManager = serverManager;
_mareProfileManager = mareProfileManager;
_pairManager = pairManager;
Flags = ImGuiWindowFlags.NoDecoration;
Mediator.Subscribe<ProfilePopoutToggle>(this, (msg) =>
@@ -42,7 +39,6 @@ public class PopoutProfileUi : WindowMediatorSubscriberBase
IsOpen = msg.Pair != null;
_pair = msg.Pair;
_lastProfilePicture = [];
_lastSupporterPicture = [];
_textureWrap?.Dispose();
_textureWrap = null;
_supporterTextureWrap?.Dispose();
@@ -182,4 +178,4 @@ public class PopoutProfileUi : WindowMediatorSubscriberBase
_logger.LogWarning(ex, "Error during draw tooltip");
}
}
}
}

View File

@@ -16,7 +16,6 @@ namespace MareSynchronos.UI;
public class StandaloneProfileUi : WindowMediatorSubscriberBase
{
private readonly MareProfileManager _mareProfileManager;
private readonly PairManager _pairManager;
private readonly ServerConfigurationManager _serverManager;
private readonly UiSharedService _uiSharedService;
private bool _adjustedForScrollBars = false;
@@ -24,7 +23,7 @@ public class StandaloneProfileUi : WindowMediatorSubscriberBase
private IDalamudTextureWrap? _textureWrap;
public StandaloneProfileUi(ILogger<StandaloneProfileUi> logger, MareMediator mediator, UiSharedService uiBuilder,
ServerConfigurationManager serverManager, MareProfileManager mareProfileManager, PairManager pairManager, Pair pair,
ServerConfigurationManager serverManager, MareProfileManager mareProfileManager, Pair pair,
PerformanceCollectorService performanceCollector)
: base(logger, mediator, "Profile of " + pair.UserData.AliasOrUID + "##UmbraSyncStandaloneProfileUI" + pair.UserData.AliasOrUID, performanceCollector)
{
@@ -32,7 +31,6 @@ public class StandaloneProfileUi : WindowMediatorSubscriberBase
_serverManager = serverManager;
_mareProfileManager = mareProfileManager;
Pair = pair;
_pairManager = pairManager;
Flags = ImGuiWindowFlags.NoResize | ImGuiWindowFlags.AlwaysAutoResize;
var spacing = ImGui.GetStyle().ItemSpacing;
@@ -164,4 +162,4 @@ public class StandaloneProfileUi : WindowMediatorSubscriberBase
{
Mediator.Publish(new RemoveWindowMessage(this));
}
}
}

View File

@@ -29,7 +29,7 @@ public sealed class TypingIndicatorOverlay : WindowMediatorSubscriberBase
private static readonly TimeSpan TypingDisplayDelay = TimeSpan.FromMilliseconds(500);
private static readonly TimeSpan TypingDisplayFade = TypingDisplayTime;
private readonly ILogger<TypingIndicatorOverlay> _logger;
private readonly ILogger<TypingIndicatorOverlay> _typedLogger;
private readonly MareConfigService _configService;
private readonly IGameGui _gameGui;
private readonly ITextureProvider _textureProvider;
@@ -47,7 +47,7 @@ public sealed class TypingIndicatorOverlay : WindowMediatorSubscriberBase
TypingIndicatorStateService typingStateService, ApiController apiController)
: base(logger, mediator, nameof(TypingIndicatorOverlay), performanceCollectorService)
{
_logger = logger;
_typedLogger = logger;
_configService = configService;
_gameGui = gameGui;
_textureProvider = textureProvider;
@@ -216,7 +216,7 @@ public sealed class TypingIndicatorOverlay : WindowMediatorSubscriberBase
if (objectId != uint.MaxValue && objectId != 0 && TryDrawNameplateBubble(drawList, iconWrap, objectId))
{
_logger.LogTrace("TypingIndicator: drew nameplate bubble for {uid} (objectId={objectId})", uid, objectId);
_typedLogger.LogTrace("TypingIndicator: drew nameplate bubble for {uid} (objectId={objectId})", uid, objectId);
continue;
}
@@ -228,20 +228,20 @@ public sealed class TypingIndicatorOverlay : WindowMediatorSubscriberBase
if (pair == null)
{
_logger.LogTrace("TypingIndicator: no pair found for {uid}, attempting fallback", uid);
_typedLogger.LogTrace("TypingIndicator: no pair found for {uid}, attempting fallback", uid);
}
_logger.LogTrace("TypingIndicator: fallback draw for {uid} (objectId={objectId}, name={name}, ident={ident})",
_typedLogger.LogTrace("TypingIndicator: fallback draw for {uid} (objectId={objectId}, name={name}, ident={ident})",
uid, objectId, pairName, pairIdent);
if (hasWorldPosition)
{
DrawWorldFallbackIcon(drawList, iconWrap, worldPos);
_logger.LogTrace("TypingIndicator: fallback world draw for {uid} at {pos}", uid, worldPos);
_typedLogger.LogTrace("TypingIndicator: fallback world draw for {uid} at {pos}", uid, worldPos);
}
else
{
_logger.LogTrace("TypingIndicator: could not resolve position for {uid}", uid);
_typedLogger.LogTrace("TypingIndicator: could not resolve position for {uid}", uid);
}
}
}
@@ -393,7 +393,7 @@ public sealed class TypingIndicatorOverlay : WindowMediatorSubscriberBase
{
if (TryGetWorldPosition(objectId, out position))
{
_logger.LogTrace("TypingIndicator: resolved by objectId {objectId}", objectId);
_typedLogger.LogTrace("TypingIndicator: resolved by objectId {objectId}", objectId);
return true;
}
@@ -402,7 +402,7 @@ public sealed class TypingIndicatorOverlay : WindowMediatorSubscriberBase
var name = pair.PlayerName;
if (!string.IsNullOrEmpty(name) && TryGetWorldPositionByName(name!, out position))
{
_logger.LogTrace("TypingIndicator: resolved by pair name {name}", name);
_typedLogger.LogTrace("TypingIndicator: resolved by pair name {name}", name);
return true;
}
@@ -412,7 +412,7 @@ public sealed class TypingIndicatorOverlay : WindowMediatorSubscriberBase
var cached = _dalamudUtil.FindPlayerByNameHash(ident);
if (!string.IsNullOrEmpty(cached.Name) && TryGetWorldPositionByName(cached.Name, out position))
{
_logger.LogTrace("TypingIndicator: resolved by cached name {name}", cached.Name);
_typedLogger.LogTrace("TypingIndicator: resolved by cached name {name}", cached.Name);
return true;
}
@@ -422,7 +422,7 @@ public sealed class TypingIndicatorOverlay : WindowMediatorSubscriberBase
if (objRef != null)
{
position = objRef.Position;
_logger.LogTrace("TypingIndicator: resolved by cached address {addr}", cached.Address);
_typedLogger.LogTrace("TypingIndicator: resolved by cached address {addr}", cached.Address);
return true;
}
}
@@ -432,7 +432,7 @@ public sealed class TypingIndicatorOverlay : WindowMediatorSubscriberBase
var alias = userData.AliasOrUID;
if (!string.IsNullOrEmpty(alias) && TryGetWorldPositionByName(alias, out position))
{
_logger.LogTrace("TypingIndicator: resolved by user alias {alias}", alias);
_typedLogger.LogTrace("TypingIndicator: resolved by user alias {alias}", alias);
return true;
}