Skip to content

Commit

Permalink
Fix IsNgrokActive crash when calling Log.Error on non-main thread
Browse files Browse the repository at this point in the history
  • Loading branch information
starfi5h committed Jun 11, 2024
1 parent 5ee3fc8 commit e68e861
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 9 additions & 0 deletions NebulaModel/Logger/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ public static void Error(string message)
LastErrorMsg = message;
if (UIFatalErrorTip.instance != null)
{
// Test if current code is executing on the main unity thread
if (BepInEx.ThreadingHelper.Instance.InvokeRequired)
{
// ShowError has Unity API and needs to call on the main thread
BepInEx.ThreadingHelper.Instance.StartSyncInvoke(() =>
UIFatalErrorTip.instance.ShowError("[Nebula Error] " + message, "")
);
return;
}
UIFatalErrorTip.instance.ShowError("[Nebula Error] " + message, "");
}
}
Expand Down
3 changes: 1 addition & 2 deletions NebulaNetwork/Ngrok/NgrokManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,8 @@ public bool IsNgrokActive()
_ngrokProcess?.Refresh();
return !_ngrokProcess?.HasExited ?? false;
}
catch (Exception e)
catch
{
Log.Error(e);
return false;
}
}
Expand Down

0 comments on commit e68e861

Please sign in to comment.