dont try free the widget's pixmap until it is no longer in use

This commit is contained in:
Dana Jansens 2003-01-20 19:28:57 +00:00
parent 24e20d5ed6
commit 68a6fce53b
7 changed files with 16 additions and 11 deletions

View file

@ -67,7 +67,7 @@ void FocusLabel::renderForeground(void)
}
display->renderControl(_screen)->
drawString(_surface, *ft, x, 0, *text_color, t);
drawString(*_surface, *ft, x, 0, *text_color, t);
}
}

View file

@ -61,7 +61,7 @@ void Label::renderForeground(void)
}
display->renderControl(_screen)->
drawString(_surface, *ft, x, 0, *style()->getTextUnfocus(), t);
drawString(*_surface, *ft, x, 0, *style()->getTextUnfocus(), t);
}
}

View file

@ -13,7 +13,7 @@ int main(int argc, char **argv)
otk::AppWidget foo(&app);
foo.resize(600, 500);
otk::RenderColor color(0, 0xff, 0x20, 0x20);
otk::RenderColor color(0, 0, 0xff, 0xff);
otk::RenderTexture tex(false,
otk::RenderTexture::Flat,
false,

View file

@ -39,7 +39,6 @@ void Surface::setPixmap(const RenderColor &color)
void Surface::setPixmap(XImage *image)
{
printf("SET PIXMAP\n");
assert(image->width == _size.x());
assert(image->height == _size.y());

View file

@ -132,5 +132,7 @@ void TrueRenderControl::drawBackground(Surface& sf,
delete [] im->data;
im->data = NULL;
XDestroyImage(im);}
XDestroyImage(im);
}
}

View file

@ -25,7 +25,7 @@ Widget::Widget(Widget *parent, Direction direction)
_stretchable_horz(false), _texture(0), _bg_pixmap(0), _bg_pixel(0),
_bcolor(0), _bwidth(0), _rect(0, 0, 1, 1), _screen(parent->screen()),
_fixed_width(false), _fixed_height(false),
_surface(parent->screen(), _rect.size()),
_surface(0),
_event_dispatcher(parent->eventDispatcher())
{
assert(parent);
@ -46,7 +46,7 @@ Widget::Widget(EventDispatcher *event_dispatcher, Style *style,
_stretchable_vert(false), _stretchable_horz(false), _texture(0),
_bg_pixmap(0), _bg_pixel(0), _bcolor(0), _bwidth(0), _rect(0, 0, 1, 1),
_screen(style->getScreen()), _fixed_width(false), _fixed_height(false),
_surface(style->getScreen(), _rect.size()),
_surface(0),
_event_dispatcher(event_dispatcher)
{
assert(event_dispatcher);
@ -261,12 +261,16 @@ void Widget::render(void)
if (!_texture) return;
printf("RENDER\n");
_surface = Surface(_screen, _rect.size());
display->renderControl(_screen)->drawBackground(_surface, *_texture);
Surface *s = _surface; // save the current surface
_surface = new Surface(_screen, _rect.size());
display->renderControl(_screen)->drawBackground(*_surface, *_texture);
renderForeground();
XSetWindowBackgroundPixmap(**display, _window, _surface.pixmap());
XSetWindowBackgroundPixmap(**display, _window, _surface->pixmap());
delete s; // delete the old surface *after* its pixmap isn't in use anymore
}
void Widget::adjust(void)

View file

@ -167,7 +167,7 @@ protected:
bool _fixed_width;
bool _fixed_height;
Surface _surface;
Surface *_surface;
EventDispatcher *_event_dispatcher;
};