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:
@@ -22,8 +22,11 @@ static long get_number(const char *ln) {
|
|||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
for(char *p = strtok(s, " "); p; p = strtok(NULL, " "), i++) {
|
for(char *p = strtok(s, " "); p; p = strtok(NULL, " "), i++) {
|
||||||
if(i == 2)
|
if(i == 2) {
|
||||||
return atol(p);
|
long ret = atol(p);
|
||||||
|
free(s);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(s);
|
free(s);
|
||||||
|
@@ -84,7 +84,7 @@ static void maximize_cb(Fl_Widget*, void *b) {
|
|||||||
redraw_whole_panel(bb);
|
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);
|
box(FL_UP_BOX);
|
||||||
align(FL_ALIGN_INSIDE | FL_ALIGN_LEFT | FL_ALIGN_CLIP);
|
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);
|
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) {
|
void TaskButton::draw(void) {
|
||||||
Fl_Color col = value() ? selection_color() : color();
|
Fl_Color col = value() ? selection_color() : color();
|
||||||
draw_box(value() ? (down_box() ? down_box() : fl_down(box())) : box(), col);
|
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;
|
img = scaled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clear_image();
|
||||||
image(img);
|
image(img);
|
||||||
|
image_alloc = true;
|
||||||
}
|
}
|
||||||
|
@@ -7,11 +7,15 @@
|
|||||||
class TaskButton : public Fl_Button {
|
class TaskButton : public Fl_Button {
|
||||||
private:
|
private:
|
||||||
/* window ID this button handles */
|
/* window ID this button handles */
|
||||||
Window xid;
|
Window xid;
|
||||||
Atom net_wm_icon;
|
bool image_alloc;
|
||||||
|
Atom net_wm_icon;
|
||||||
|
|
||||||
|
void clear_image(void);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TaskButton(int X, int Y, int W, int H, const char *l = 0);
|
TaskButton(int X, int Y, int W, int H, const char *l = 0);
|
||||||
|
~TaskButton();
|
||||||
|
|
||||||
void draw(void);
|
void draw(void);
|
||||||
void display_menu(void);
|
void display_menu(void);
|
||||||
|
Reference in New Issue
Block a user