Only update the loading screen from the main thread

Fixes the crash experienced by pchote. It's a hack but it's easy
to get rid of and it will have to do for now, until the messy
LoadScreen gets fixed.
This commit is contained in:
Pavlos Touboulidis
2014-05-13 17:56:27 +03:00
parent a845947e0f
commit ca44be7b2e
4 changed files with 22 additions and 25 deletions

View File

@@ -42,6 +42,7 @@ namespace OpenRA
LoadScreen.Display();
WidgetLoader = new WidgetLoader(this);
RulesetCache = new RulesetCache(this);
RulesetCache.LoadingProgress += HandleLoadingProgress;
MapCache = new MapCache(this);
// HACK: Mount only local folders so we have a half-working environment for the asset installer
@@ -50,6 +51,16 @@ namespace OpenRA
GlobalFileSystem.Mount(dir);
defaultRules = Exts.Lazy(() => RulesetCache.LoadDefaultRules());
initialThreadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
}
// HACK: Only update the loading screen if we're in the main thread.
int initialThreadId;
void HandleLoadingProgress(object sender, EventArgs e)
{
if (LoadScreen != null && System.Threading.Thread.CurrentThread.ManagedThreadId == initialThreadId)
LoadScreen.Display();
}
public void InitializeLoaders()