summaryrefslogtreecommitdiff
path: root/otk/surface.cc
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2003-02-11 22:38:29 +0000
committerDana Jansens <danakj@orodu.net>2003-02-11 22:38:29 +0000
commit555facb9c737be20cd923abc15875af0281a8927 (patch)
treefed6201d3d0993cf400a0d329b3e8d92d9dd492e /otk/surface.cc
parentaceea3c0814778317be7a903f63b8363d2b1b0ef (diff)
free the surfaces' pixeldata after rendering it
Diffstat (limited to 'otk/surface.cc')
-rw-r--r--otk/surface.cc14
1 files changed, 12 insertions, 2 deletions
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());