diff options
Diffstat (limited to 'otk/surface.cc')
| -rw-r--r-- | otk/surface.cc | 14 |
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()); |
