From 555facb9c737be20cd923abc15875af0281a8927 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Tue, 11 Feb 2003 22:38:29 +0000 Subject: free the surfaces' pixeldata after rendering it --- otk/surface.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'otk/surface.cc') diff --git a/otk/surface.cc b/otk/surface.cc index 3f5624d7..9fff018c 100644 --- a/otk/surface.cc +++ b/otk/surface.cc @@ -26,14 +26,23 @@ Surface::Surface(int screen, const Size &size) Surface::~Surface() { destroyObjects(); - delete [] _pixel_data; + freePixelData(); +} + +void Surface::freePixelData() +{ + if (_pixel_data) { + delete [] _pixel_data; + _pixel_data = 0; + } } void Surface::setPixmap(const RenderColor &color) { + assert(_pixel_data); if (_pixmap == None) createObjects(); - + XFillRectangle(**display, _pixmap, color.gc(), 0, 0, _size.width(), _size.height()); @@ -49,6 +58,7 @@ void Surface::setPixmap(const RenderColor &color) void Surface::setPixmap(XImage *image) { + assert(_pixel_data); assert(image->width == _size.width()); assert(image->height == _size.height()); -- cgit v1.2.3