]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/buffer.cpp
Check the flat qualifier from the correct member
[libs/gl.git] / source / core / buffer.cpp
index b6f2e44b9e55555bebcfa08b80bf1ffeadb4a3c5..36ac440a54426c186c16ae238c51a337312445e8 100644 (file)
@@ -58,7 +58,7 @@ void Buffer::require_size(size_t req_sz) const
 
 void *Buffer::map()
 {
-       if(!can_map() || mapped)
+       if(size==0 || !can_map() || mapped)
                throw invalid_operation("Buffer::map");
        void *result = BufferBackend::map();
        mapped = true;
@@ -67,8 +67,8 @@ void *Buffer::map()
 
 bool Buffer::unmap()
 {
-       if(!can_map() || !mapped)
-               throw invalid_operation("Buffer::map");
+       if(size==0 || !can_map() || !mapped)
+               throw invalid_operation("Buffer::unmap");
        bool result = BufferBackend::unmap();
        mapped = false;
        return result;
@@ -76,7 +76,7 @@ bool Buffer::unmap()
 
 
 Buffer::AsyncTransfer::AsyncTransfer(Buffer &b, size_t o, size_t s):
-       buffer(b),
+       buffer(&b),
        offset(o),
        size(s),
        dest_addr(0)
@@ -93,6 +93,21 @@ Buffer::AsyncTransfer::AsyncTransfer(AsyncTransfer &&other):
        other.dest_addr = 0;
 }
 
+Buffer::AsyncTransfer &Buffer::AsyncTransfer::operator=(AsyncTransfer &&other)
+{
+       if(dest_addr)
+               finalize();
+
+       buffer = other.buffer;
+       offset = other.offset;
+       size = other.size;
+       dest_addr = other.dest_addr;
+
+       other.dest_addr = 0;
+
+       return *this;
+}
+
 Buffer::AsyncTransfer::~AsyncTransfer()
 {
        if(dest_addr)