ThreadPool: Crash fixes

This commit is contained in:
Joshua Granick
2024-05-21 13:45:57 -07:00
parent 5381f96061
commit 2dad602c0d

View File

@@ -183,7 +183,14 @@ class ThreadPool extends WorkOutput
{
super(mode);
if (Application.current != null && Application.current.window != null)
{
__workPerFrame = workLoad / Application.current.window.frameRate;
}
else
{
__workPerFrame = workLoad / 60;
}
this.minThreads = minThreads;
this.maxThreads = maxThreads;
@@ -335,7 +342,7 @@ class ThreadPool extends WorkOutput
completed = false;
canceled = false;
if (!Application.current.onUpdate.has(__update))
if (Application.current != null && !Application.current.onUpdate.has(__update))
{
Application.current.onUpdate.add(__update);
}
@@ -570,7 +577,7 @@ class ThreadPool extends WorkOutput
activeJob = null;
}
if (completed)
if (completed && Application.current != null)
{
Application.current.onUpdate.remove(__update);
}