mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +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 readonly ConditionalWeakTable<LocalPlugin, object> NonMainThreadFontAccessWarning = new();
|
||||||
private static long nextNonMainThreadFontAccessWarningCheck;
|
private static long nextNonMainThreadFontAccessWarningCheck;
|
||||||
|
|
||||||
private readonly InterfaceManager interfaceManager;
|
|
||||||
private readonly List<IDisposable> pushedFonts = new(8);
|
private readonly List<IDisposable> pushedFonts = new(8);
|
||||||
|
|
||||||
private IFontHandleManager? manager;
|
private IFontHandleManager? manager;
|
||||||
|
|
@ -36,7 +35,6 @@ internal abstract class FontHandle : IFontHandle
|
||||||
/// <param name="manager">An instance of <see cref="IFontHandleManager"/>.</param>
|
/// <param name="manager">An instance of <see cref="IFontHandleManager"/>.</param>
|
||||||
protected FontHandle(IFontHandleManager manager)
|
protected FontHandle(IFontHandleManager manager)
|
||||||
{
|
{
|
||||||
this.interfaceManager = Service<InterfaceManager>.Get();
|
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -58,7 +56,11 @@ internal abstract class FontHandle : IFontHandle
|
||||||
/// Gets the associated <see cref="IFontHandleManager"/>.
|
/// Gets the associated <see cref="IFontHandleManager"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <exception cref="ObjectDisposedException">When the object has already been disposed.</exception>
|
/// <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/>
|
/// <inheritdoc/>
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
|
@ -122,7 +124,7 @@ internal abstract class FontHandle : IFontHandle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.interfaceManager.EnqueueDeferredDispose(locked);
|
Service<InterfaceManager>.Get().EnqueueDeferredDispose(locked);
|
||||||
return locked.ImFont;
|
return locked.ImFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -196,7 +198,7 @@ internal abstract class FontHandle : IFontHandle
|
||||||
ThreadSafety.AssertMainThread();
|
ThreadSafety.AssertMainThread();
|
||||||
|
|
||||||
// Warn if the client is not properly managing the pushed font stack.
|
// 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)
|
if (this.lastCumulativePresentCalls != cumulativePresentCalls)
|
||||||
{
|
{
|
||||||
this.lastCumulativePresentCalls = cumulativePresentCalls;
|
this.lastCumulativePresentCalls = cumulativePresentCalls;
|
||||||
|
|
@ -213,7 +215,7 @@ internal abstract class FontHandle : IFontHandle
|
||||||
if (this.TryLock(out _) is { } locked)
|
if (this.TryLock(out _) is { } locked)
|
||||||
{
|
{
|
||||||
font = locked.ImFont;
|
font = locked.ImFont;
|
||||||
this.interfaceManager.EnqueueDeferredDispose(locked);
|
Service<InterfaceManager>.Get().EnqueueDeferredDispose(locked);
|
||||||
}
|
}
|
||||||
|
|
||||||
var rented = SimplePushedFont.Rent(this.pushedFonts, font);
|
var rented = SimplePushedFont.Rent(this.pushedFonts, font);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue