From 5a3966187c59c8763b7109d252875939e70cc151 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 29 Oct 2021 12:11:37 +0300 Subject: [PATCH] Make it an error to try to refresh a Bufferable without a buffer --- source/core/bufferable.cpp | 4 ++++ source/core/bufferable.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/source/core/bufferable.cpp b/source/core/bufferable.cpp index 8f967df7..24c0f278 100644 --- a/source/core/bufferable.cpp +++ b/source/core/bufferable.cpp @@ -1,6 +1,7 @@ #include #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) { diff --git a/source/core/bufferable.h b/source/core/bufferable.h index c7e26aef..b1d991fc 100644 --- a/source/core/bufferable.h +++ b/source/core/bufferable.h @@ -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. */ -- 2.45.2