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:
parent
6b78cb3b0a
commit
8aa9d550b2
@ -22,8 +22,11 @@ static long get_number(const char *ln) {
|
||||
int i = 1;
|
||||
|
||||
for(char *p = strtok(s, " "); p; p = strtok(NULL, " "), i++) {
|
||||
if(i == 2)
|
||||
return atol(p);
|
||||
if(i == 2) {
|
||||
long ret = atol(p);
|
||||
free(s);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
free(s);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -7,11 +7,15 @@
|
||||
class TaskButton : public Fl_Button {
|
||||
private:
|
||||
/* window ID this button handles */
|
||||
Window xid;
|
||||
Atom net_wm_icon;
|
||||
Window xid;
|
||||
bool image_alloc;
|
||||
Atom net_wm_icon;
|
||||
|
||||
void clear_image(void);
|
||||
|
||||
public:
|
||||
TaskButton(int X, int Y, int W, int H, const char *l = 0);
|
||||
~TaskButton();
|
||||
|
||||
void draw(void);
|
||||
void display_menu(void);
|
||||
|
Loading…
Reference in New Issue
Block a user