mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Better error message for FontHandle
This commit is contained in:
parent
3ba395bd70
commit
0343897113
1 changed files with 8 additions and 6 deletions
|
|
@ -24,7 +24,6 @@ internal abstract class FontHandle : IFontHandle
|
|||
private static readonly ConditionalWeakTable<LocalPlugin, object> NonMainThreadFontAccessWarning = new();
|
||||
private static long nextNonMainThreadFontAccessWarningCheck;
|
||||
|
||||
private readonly InterfaceManager interfaceManager;
|
||||
private readonly List<IDisposable> pushedFonts = new(8);
|
||||
|
||||
private IFontHandleManager? manager;
|
||||
|
|
@ -36,7 +35,6 @@ internal abstract class FontHandle : IFontHandle
|
|||
/// <param name="manager">An instance of <see cref="IFontHandleManager"/>.</param>
|
||||
protected FontHandle(IFontHandleManager manager)
|
||||
{
|
||||
this.interfaceManager = Service<InterfaceManager>.Get();
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
|
|
@ -58,7 +56,11 @@ internal abstract class FontHandle : IFontHandle
|
|||
/// Gets the associated <see cref="IFontHandleManager"/>.
|
||||
/// </summary>
|
||||
/// <exception cref="ObjectDisposedException">When the object has already been disposed.</exception>
|
||||
protected IFontHandleManager Manager => this.manager ?? throw new ObjectDisposedException(this.GetType().Name);
|
||||
protected IFontHandleManager Manager =>
|
||||
this.manager
|
||||
?? throw new ObjectDisposedException(
|
||||
this.GetType().Name,
|
||||
"Did you write `using (fontHandle)` instead of `using (fontHandle.Push())`?");
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
|
|
@ -122,7 +124,7 @@ internal abstract class FontHandle : IFontHandle
|
|||
}
|
||||
}
|
||||
|
||||
this.interfaceManager.EnqueueDeferredDispose(locked);
|
||||
Service<InterfaceManager>.Get().EnqueueDeferredDispose(locked);
|
||||
return locked.ImFont;
|
||||
}
|
||||
|
||||
|
|
@ -196,7 +198,7 @@ internal abstract class FontHandle : IFontHandle
|
|||
ThreadSafety.AssertMainThread();
|
||||
|
||||
// Warn if the client is not properly managing the pushed font stack.
|
||||
var cumulativePresentCalls = this.interfaceManager.CumulativePresentCalls;
|
||||
var cumulativePresentCalls = Service<InterfaceManager>.Get().CumulativePresentCalls;
|
||||
if (this.lastCumulativePresentCalls != cumulativePresentCalls)
|
||||
{
|
||||
this.lastCumulativePresentCalls = cumulativePresentCalls;
|
||||
|
|
@ -213,7 +215,7 @@ internal abstract class FontHandle : IFontHandle
|
|||
if (this.TryLock(out _) is { } locked)
|
||||
{
|
||||
font = locked.ImFont;
|
||||
this.interfaceManager.EnqueueDeferredDispose(locked);
|
||||
Service<InterfaceManager>.Get().EnqueueDeferredDispose(locked);
|
||||
}
|
||||
|
||||
var rented = SimplePushedFont.Rent(this.pushedFonts, font);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue