]> git.tdb.fi Git - libs/gl.git/commitdiff
Ensure that mapped memory is unmapped in Texture2D::AsyncLoader
authorMikko Rasa <tdb@tdb.fi>
Sun, 7 Feb 2021 13:33:20 +0000 (15:33 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 7 Feb 2021 13:33:20 +0000 (15:33 +0200)
source/texture2d.cpp

index 311a3e4569704c92b99703c4a0473f508778c9e1..1e8e3db8fefe659a8b46390719e14177c29e5315 100644 (file)
@@ -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;