diff options
Diffstat (limited to 'plugingui')
-rw-r--r-- | plugingui/pixelbuffer.cc | 8 | ||||
-rw-r--r-- | plugingui/pixelbuffer.h | 18 |
2 files changed, 16 insertions, 10 deletions
diff --git a/plugingui/pixelbuffer.cc b/plugingui/pixelbuffer.cc index 906e4d6..5d032b4 100644 --- a/plugingui/pixelbuffer.cc +++ b/plugingui/pixelbuffer.cc @@ -69,7 +69,8 @@ void PixelBuffer::setPixel(size_t x, size_t y, } PixelBufferAlpha::PixelBufferAlpha(size_t width, size_t height) - : buf(nullptr) + : managed(true) + , buf(nullptr) , x(0) , y(0) { @@ -78,7 +79,10 @@ PixelBufferAlpha::PixelBufferAlpha(size_t width, size_t height) PixelBufferAlpha::~PixelBufferAlpha() { - free(buf); + if(managed) + { + free(buf); + } } void PixelBufferAlpha::realloc(size_t width, size_t height) diff --git a/plugingui/pixelbuffer.h b/plugingui/pixelbuffer.h index 8e7618d..762aaa6 100644 --- a/plugingui/pixelbuffer.h +++ b/plugingui/pixelbuffer.h @@ -45,13 +45,14 @@ public: unsigned char blue, unsigned char alpha); - unsigned char* buf; - size_t width; - size_t height; + unsigned char* buf{nullptr}; + size_t width{0}; + size_t height{0}; }; class PixelBufferAlpha { public: + PixelBufferAlpha() = default; PixelBufferAlpha(size_t width, size_t height); ~PixelBufferAlpha(); @@ -77,11 +78,12 @@ public: unsigned char* blue, unsigned char* alpha); - unsigned char* buf; - size_t width; - size_t height; - size_t x; - size_t y; + bool managed{false}; + unsigned char* buf{nullptr}; + size_t width{0}; + size_t height{0}; + size_t x{0}; + size_t y{0}; }; } // GUI:: |