Skip to content

Commit

Permalink
rewrote the interface locking safety
Browse files Browse the repository at this point in the history
  • Loading branch information
ircluzar committed Aug 6, 2024
1 parent e42b347 commit cd1d795
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions Source/Frontend/UI/UICore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,18 +188,17 @@ public static void UpdateFormFocusStatus(bool? forceSet = null)

public static void LockInterface(bool focusCoreForm = true, bool blockMainForm = false)
{
if (interfaceLocked || lockPending)
{
return;
}

lockPending = true;
lock (lockObject)
{
if (interfaceLocked)
return;

interfaceLocked = true;

//Kill hotkeys while locked
SetHotkeyTimer(false);

interfaceLocked = true;

var cf = S.GET<CoreForm>();
cf.LockSideBar();

Expand All @@ -224,21 +223,16 @@ public static void LockInterface(bool focusCoreForm = true, bool blockMainForm =
cf.Focus();
}
}
lockPending = false;
}

public static void UnlockInterface()
{
if (lockPending)
{
lockPending = false;
}

lock (lockObject)
{
interfaceLocked = false;
S.GET<CoreForm>().UnlockSideBar();
if (!interfaceLocked)
return;

S.GET<CoreForm>().UnlockSideBar();
S.GET<ConnectionStatusForm>().pnBlockedButtons.Hide();

CanvasForm.mainForm.UnblockView();
Expand All @@ -251,6 +245,8 @@ public static void UnlockInterface()

//Resume hotkeys
SetHotkeyTimer(true);

interfaceLocked = false;
}
}

Expand Down Expand Up @@ -302,8 +298,7 @@ internal static void UnblockView(this IBlockable ib)
}

internal static volatile bool isClosing = false;
private static bool interfaceLocked;
private static bool lockPending;
public static volatile bool interfaceLocked = false;
private static object lockObject = new object();

internal static object InputLock = new object();
Expand Down

0 comments on commit cd1d795

Please sign in to comment.