From 7e9bc84c0675a36fcaa60dcab7dfe80ee35e23e0 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sun, 2 Apr 2017 23:58:27 +0200 Subject: [PATCH] Minor safety check --- UI/TextureUtil.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/UI/TextureUtil.h b/UI/TextureUtil.h index 01e2bda11d..71b87feb5a 100644 --- a/UI/TextureUtil.h +++ b/UI/TextureUtil.h @@ -14,7 +14,7 @@ enum ImageFileType { class ManagedTexture : public GfxResourceHolder { public: - ManagedTexture(Draw::DrawContext *draw) : draw_(draw), texture_(nullptr) { + ManagedTexture(Draw::DrawContext *draw) : draw_(draw) { if (g_Config.iGPUBackend == (int)GPUBackend::OPENGL) register_gl_resource_holder(this, "managed_texture", 0); } @@ -25,7 +25,8 @@ public: unregister_gl_resource_holder(this); } void GLLost() override { - texture_->Release(); + if (texture_) + texture_->Release(); texture_ = nullptr; } void GLRestore() override { @@ -49,7 +50,7 @@ public: int Height() const { return texture_->Height(); } private: - Draw::Texture *texture_; + Draw::Texture *texture_ = nullptr; Draw::DrawContext *draw_; std::string filename_; // Textures that are loaded from files can reload themselves automatically. };