From da1e3f68e73cc0b6fb23e9dbae410cf9af3428a2 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 7 Feb 2021 15:33:20 +0200 Subject: [PATCH] Ensure that mapped memory is unmapped in Texture2D::AsyncLoader --- source/texture2d.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/texture2d.cpp b/source/texture2d.cpp index 311a3e45..1e8e3db8 100644 --- a/source/texture2d.cpp +++ b/source/texture2d.cpp @@ -26,6 +26,7 @@ private: public: AsyncLoader(Texture2D &, IO::Seekable &); + ~AsyncLoader(); virtual bool needs_sync() const; virtual bool process(); @@ -249,6 +250,12 @@ Texture2D::AsyncLoader::AsyncLoader(Texture2D &t, IO::Seekable &i): phase(0) { } +Texture2D::AsyncLoader::~AsyncLoader() +{ + if(mapped_address) + pixel_buffer.unmap(); +} + bool Texture2D::AsyncLoader::needs_sync() const { return phase%2; @@ -276,6 +283,7 @@ bool Texture2D::AsyncLoader::process() else if(phase==3) { Bind _bind_buf(pixel_buffer, PIXEL_UNPACK_BUFFER); + mapped_address = 0; if(!pixel_buffer.unmap()) { phase = 1; -- 2.43.0