Fixed a memory leak.

This commit is contained in:
David Capello 2008-02-10 12:33:03 +00:00
parent b797cd91b7
commit a9ec8b61f0

View File

@ -1,5 +1,5 @@
/* ASE - Allegro Sprite Editor /* ASE - Allegro Sprite Editor
* Copyright (C) 2001-2005, 2007, 2008 David A. Capello * Copyright (C) 2001-2008 David A. Capello
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -155,20 +155,12 @@ static bool color_bar_msg_proc (JWidget widget, JMessage msg)
switch (msg->type) { switch (msg->type) {
case JM_DESTROY:
jfree (color_bar);
break;
case JM_REQSIZE:
msg->reqsize.w = msg->reqsize.h = 16;
return TRUE;
case JM_OPEN: { case JM_OPEN: {
int ncolor = get_config_int ("ColorBar", "NColors", color_bar->ncolor); int ncolor = get_config_int ("ColorBar", "NColors", color_bar->ncolor);
char buf[256], def[256]; char buf[256], def[256];
int c, beg, end; int c, beg, end;
color_bar->ncolor = MID (1, ncolor, COLOR_BAR_COLORS); color_bar->ncolor = MID(1, ncolor, COLOR_BAR_COLORS);
get_info (widget, &beg, &end); get_info (widget, &beg, &end);
@ -188,7 +180,7 @@ static bool color_bar_msg_proc (JWidget widget, JMessage msg)
break; break;
} }
case JM_CLOSE: { case JM_DESTROY: {
char buf[256]; char buf[256];
int c; int c;
@ -201,9 +193,17 @@ static bool color_bar_msg_proc (JWidget widget, JMessage msg)
set_config_string("ColorBar", buf, color_bar->color[c]); set_config_string("ColorBar", buf, color_bar->color[c]);
jfree(color_bar->color[c]); jfree(color_bar->color[c]);
} }
for (; c<COLOR_BAR_COLORS; c++)
jfree(color_bar->color[c]);
jfree(color_bar);
break; break;
} }
case JM_REQSIZE:
msg->reqsize.w = msg->reqsize.h = 16;
return TRUE;
case JM_DRAW: { case JM_DRAW: {
int imgtype = app_get_current_image_type(); int imgtype = app_get_current_image_type();
int x1, y1, x2, y2; int x1, y1, x2, y2;