]> git.tdb.fi Git - libs/gl.git/commitdiff
Make it an error to try to refresh a Bufferable without a buffer
authorMikko Rasa <tdb@tdb.fi>
Fri, 29 Oct 2021 09:11:37 +0000 (12:11 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 29 Oct 2021 09:18:21 +0000 (12:18 +0300)
source/core/bufferable.cpp
source/core/bufferable.h

index 8f967df7a89967cf0d83ece6778d6a6ed3640539..24c0f2789f4bae1bf256237587509ff40c408e68 100644 (file)
@@ -1,6 +1,7 @@
 #include <stdexcept>
 #include "buffer.h"
 #include "bufferable.h"
+#include "error.h"
 
 using namespace std;
 
@@ -106,6 +107,9 @@ void Bufferable::update_offset()
 
 void Bufferable::upload_data(char *target) const
 {
+       if(!buffer)
+               throw invalid_operation("Bufferable::upload_data");
+
        unsigned data_size = get_data_size();
        if(location_dirty)
        {
index c7e26aefc0b8526b1a1ee330b3f38b15875fdb44..b1d991fca5218cfd4a0cd1e7ee554d2920a02463 100644 (file)
@@ -53,7 +53,7 @@ public:
        unsigned get_required_buffer_size() const;
 
        /** Uploads new data into the buffer if necessary. */
-       void refresh() const { if(buffer && dirty) upload_data(0); }
+       void refresh() const { if(dirty) upload_data(0); }
 
        /** Returns an object which can be used to upload data to the buffer using
        mapped memory. */