mirror of
https://github.com/edeproject/ede.git
synced 2023-08-10 21:13:03 +03:00
Prevent some memory leaks
This commit is contained in:
@ -84,7 +84,7 @@ static void maximize_cb(Fl_Widget*, void *b) {
|
||||
redraw_whole_panel(bb);
|
||||
}
|
||||
|
||||
TaskButton::TaskButton(int X, int Y, int W, int H, const char *l) : Fl_Button(X, Y, W, H, l), xid(0) {
|
||||
TaskButton::TaskButton(int X, int Y, int W, int H, const char *l) : Fl_Button(X, Y, W, H, l), xid(0), image_alloc(false) {
|
||||
box(FL_UP_BOX);
|
||||
align(FL_ALIGN_INSIDE | FL_ALIGN_LEFT | FL_ALIGN_CLIP);
|
||||
|
||||
@ -97,6 +97,18 @@ TaskButton::TaskButton(int X, int Y, int W, int H, const char *l) : Fl_Button(X,
|
||||
image(image_window);
|
||||
}
|
||||
|
||||
TaskButton::~TaskButton() {
|
||||
clear_image();
|
||||
}
|
||||
|
||||
void TaskButton::clear_image(void) {
|
||||
if(image_alloc && image())
|
||||
delete image();
|
||||
|
||||
image(NULL);
|
||||
image_alloc = false;
|
||||
}
|
||||
|
||||
void TaskButton::draw(void) {
|
||||
Fl_Color col = value() ? selection_color() : color();
|
||||
draw_box(value() ? (down_box() ? down_box() : fl_down(box())) : box(), col);
|
||||
@ -240,5 +252,7 @@ void TaskButton::update_image_from_xid(void) {
|
||||
img = scaled;
|
||||
}
|
||||
|
||||
clear_image();
|
||||
image(img);
|
||||
image_alloc = true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user