From: Mikko Rasa Date: Sun, 7 Feb 2021 13:33:20 +0000 (+0200) Subject: Ensure that mapped memory is unmapped in Texture2D::AsyncLoader X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=da1e3f68e73cc0b6fb23e9dbae410cf9af3428a2;p=libs%2Fgl.git Ensure that mapped memory is unmapped in Texture2D::AsyncLoader --- 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;