mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
SeStringEvaluator: Throw if not on main thread
This commit is contained in:
parent
84f5dad0a3
commit
f209ac087a
2 changed files with 4 additions and 7 deletions
|
|
@ -1682,11 +1682,7 @@ internal class SeStringEvaluator : IServiceType, ISeStringEvaluator
|
|||
if (rtm is null)
|
||||
return false;
|
||||
|
||||
if (!ThreadSafety.IsMainThread)
|
||||
{
|
||||
Log.Error("Global parameters may only be used from the main thread.");
|
||||
return false;
|
||||
}
|
||||
ThreadSafety.AssertMainThread("Global parameters may only be used from the main thread.");
|
||||
|
||||
ref var gp = ref rtm->TextModule.MacroDecoder.GlobalParameters;
|
||||
if (parameterIndex >= gp.MySize)
|
||||
|
|
|
|||
|
|
@ -18,13 +18,14 @@ public static class ThreadSafety
|
|||
/// <summary>
|
||||
/// Throws an exception when the current thread is not the main thread.
|
||||
/// </summary>
|
||||
/// <param name="message">The message to be passed into the exception, if one is to be thrown.</param>
|
||||
/// <exception cref="InvalidOperationException">Thrown when the current thread is not the main thread.</exception>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void AssertMainThread()
|
||||
public static void AssertMainThread(string? message = null)
|
||||
{
|
||||
if (!threadStaticIsMainThread)
|
||||
{
|
||||
throw new InvalidOperationException("Not on main thread!");
|
||||
throw new InvalidOperationException(message ?? "Not on main thread!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue