mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-14 03:47:43 +01:00
fix: wait for font rebuild when initially setting up ImGui
This is to work around changed behaviour with ImGui >1.78 wherein a race condition during font rebuild together with plugin loads would cause the remote CLR thread to end
This commit is contained in:
parent
2c66ecc84e
commit
d949734fe9
2 changed files with 83 additions and 67 deletions
|
|
@ -4,6 +4,7 @@ using System.IO;
|
|||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using Dalamud.Game;
|
||||
using Dalamud.Game.Internal.DXGI;
|
||||
using Dalamud.Hooking;
|
||||
|
|
@ -42,6 +43,8 @@ namespace Dalamud.Interface
|
|||
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
|
||||
private delegate IntPtr SetCursorDelegate(IntPtr hCursor);
|
||||
|
||||
private ManualResetEvent fontBuildSignal;
|
||||
|
||||
private ISwapChainAddressResolver Address { get; }
|
||||
|
||||
private Dalamud dalamud;
|
||||
|
|
@ -68,6 +71,8 @@ namespace Dalamud.Interface
|
|||
{
|
||||
this.dalamud = dalamud;
|
||||
|
||||
this.fontBuildSignal = new ManualResetEvent(false);
|
||||
|
||||
try {
|
||||
var sigResolver = new SwapChainSigResolver();
|
||||
sigResolver.Setup(scanner);
|
||||
|
|
@ -272,6 +277,8 @@ namespace Dalamud.Interface
|
|||
|
||||
private unsafe void SetupFonts()
|
||||
{
|
||||
this.fontBuildSignal.Reset();
|
||||
|
||||
ImGui.GetIO().Fonts.Clear();
|
||||
|
||||
ImFontConfigPtr fontConfig = ImGuiNative.ImFontConfig_ImFontConfig();
|
||||
|
|
@ -317,12 +324,18 @@ namespace Dalamud.Interface
|
|||
|
||||
Log.Verbose("[FONT] Fonts built!");
|
||||
|
||||
this.fontBuildSignal.Set();
|
||||
|
||||
fontConfig.Destroy();
|
||||
japaneseRangeHandle.Free();
|
||||
gameRangeHandle.Free();
|
||||
iconRangeHandle.Free();
|
||||
}
|
||||
|
||||
public void WaitForFontRebuild() {
|
||||
this.fontBuildSignal.WaitOne();
|
||||
}
|
||||
|
||||
// This is intended to only be called as a handler attached to scene.OnNewRenderFrame
|
||||
private void RebuildFontsInternal()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue