From 3a87c9b94800a49abed80a989adb18477602d3da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 15 Mar 2016 09:49:17 +0100 Subject: [PATCH] Properly reset image bindings on destruction. --- src/Magnum/AbstractTexture.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Magnum/AbstractTexture.cpp b/src/Magnum/AbstractTexture.cpp index aacee0e13..c31a5e160 100644 --- a/src/Magnum/AbstractTexture.cpp +++ b/src/Magnum/AbstractTexture.cpp @@ -240,6 +240,12 @@ AbstractTexture::~AbstractTexture() { if(binding.second == _id) binding = {}; } + /* Remove all image bindings */ + for(auto& binding: Context::current().state().texture->imageBindings) { + /* MSVC 2015 needs the parentheses around */ + if(std::get<0>(binding) == _id) binding = {}; + } + glDeleteTextures(1, &_id); }