Ensure MapCache disposes cleanly.
This prevents the map loading thread writing to disposed objects which can have unintended side effects.
This commit is contained in:
@@ -249,8 +249,21 @@ namespace OpenRA
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (previewLoaderThread == null)
|
||||
{
|
||||
sheetBuilder.Dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
// We need to let the loader thread exit before we can dispose our sheet builder.
|
||||
// Ideally we should dispose our resources before returning, but we don't to block waiting on the loader thread to exit.
|
||||
// Instead, we'll queue disposal to be run once it has exited.
|
||||
ThreadPool.QueueUserWorkItem(_ =>
|
||||
{
|
||||
previewLoaderThread.Join();
|
||||
Game.RunAfterTick(sheetBuilder.Dispose);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user