From e51ea856150bab6fad10401614c3de1e54c89520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 21 Jul 2018 22:47:29 +0200 Subject: [PATCH] Be extra careful about never ever binding null textures when drawing backgrounds. See #11243 --- UI/MainScreen.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index cbd9bf8a2d..5d1d521aac 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -1079,17 +1079,20 @@ bool MainScreen::DrawBackgroundFor(UIContext &dc, const std::string &gamePath, f return false; } + Draw::Texture *texture = nullptr; if (ginfo->pic1.texture) { - dc.GetDrawContext()->BindTexture(0, ginfo->pic1.texture->GetTexture()); + texture = ginfo->pic1.texture->GetTexture(); } else if (ginfo->pic0.texture) { - dc.GetDrawContext()->BindTexture(0, ginfo->pic0.texture->GetTexture()); + texture = ginfo->pic0.texture->GetTexture(); } uint32_t color = whiteAlpha(ease(progress)) & 0xFFc0c0c0; - dc.Draw()->DrawTexRect(dc.GetBounds(), 0,0,1,1, color); - dc.Flush(); - dc.RebindTexture(); - + if (texture) { + dc.GetDrawContext()->BindTexture(0, texture); + dc.Draw()->DrawTexRect(dc.GetBounds(), 0, 0, 1, 1, color); + dc.Flush(); + dc.RebindTexture(); + } return true; }