From 0a9c764dc4973cf17e982ee142b9929690b1aa73 Mon Sep 17 00:00:00 2001 From: iwubcode Date: Tue, 2 Feb 2021 23:02:41 -0600 Subject: [PATCH] VideoCommon: Join the prefetch thread before clearing to avoid a potential crash that can occur by multiple threads touching a single resource --- Source/Core/VideoCommon/HiresTextures.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Source/Core/VideoCommon/HiresTextures.cpp b/Source/Core/VideoCommon/HiresTextures.cpp index cbb2566470..d55eadf022 100644 --- a/Source/Core/VideoCommon/HiresTextures.cpp +++ b/Source/Core/VideoCommon/HiresTextures.cpp @@ -56,14 +56,7 @@ void HiresTexture::Init() void HiresTexture::Shutdown() { - if (s_prefetcher.joinable()) - { - s_textureCacheAbortLoading.Set(); - s_prefetcher.join(); - } - - s_textureMap.clear(); - s_textureCache.clear(); + Clear(); } void HiresTexture::Update() @@ -147,6 +140,11 @@ void HiresTexture::Update() void HiresTexture::Clear() { + if (s_prefetcher.joinable()) + { + s_textureCacheAbortLoading.Set(); + s_prefetcher.join(); + } s_textureMap.clear(); s_textureCache.clear(); }