Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

Commit

Permalink
fixed several memory bugs, version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
maoserr committed Aug 5, 2010
1 parent 4977748 commit 52cf225
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -8,7 +8,7 @@ set(PRO_NAME "RedshiftGUI")
# Project version
set(RSG_VERSION_MAJOR 0)
set(RSG_VERSION_MINOR 2)
set(RSG_VERSION_PATCH 0)
set(RSG_VERSION_PATCH 1)
set(RSG_VERSION
"${RSG_VERSION_MAJOR}.${RSG_VERSION_MINOR}.${RSG_VERSION_PATCH}")
# Project information
Expand Down
16 changes: 8 additions & 8 deletions src/gamma.c
Expand Up @@ -116,8 +116,8 @@ int gamma_find_temp(float ratio){
curr_ratio = (float)blackbody_color[i*3]/(float)blackbody_color[i*3+2];
if( curr_ratio <= ratio ){
// Interpolate color based on ratio
int color = (ratio-curr_ratio)/(prev_ratio-curr_ratio)*100
+i*100+1000;
int color = (int)((ratio-curr_ratio)/(prev_ratio-curr_ratio)*100
+i*100+1000);
LOG(LOGVERBOSE,_("Current col:%d"),color);
return color;
}
Expand Down Expand Up @@ -225,9 +225,9 @@ int gamma_calc_temp(double elevation, int temp_day, int temp_night)
int i;
int size;
pair *map = opt_get_map(&size);
float prevelev=map[size-1].elev+360;
double prevelev=map[size-1].elev+360;
int prevtemp=map[size-1].temp;
float currelev;
double currelev;
int currtemp;
for( i = 0; i<size+1; ++i ){
if( i==size ){
Expand All @@ -239,17 +239,17 @@ int gamma_calc_temp(double elevation, int temp_day, int temp_night)
}
if( (elevation<=prevelev)
&& (elevation>=currelev) ){
float ratio;
float temp_perc;
double ratio;
double temp_perc;
/* Found target elevation */
LOG(LOGVERBOSE,_("Found target elevation "
"between %f and %f"),prevelev,currelev);
ratio = (elevation-currelev)
/(prevelev-currelev);
temp_perc= ratio*(prevtemp-currtemp)
+currtemp;
temp = (0.01*temp_perc)*(temp_day-temp_night)
+temp_night;
temp = (int)((0.01*temp_perc)*(temp_day-temp_night)
+temp_night);
LOG(LOGVERBOSE,_("Target temp %d (ratio %f,%f)"),
temp,ratio,temp_perc);
return temp;
Expand Down
6 changes: 5 additions & 1 deletion src/gui/iupgui.c
Expand Up @@ -110,17 +110,20 @@ int gui_about(Ihandle *ih){
"This program uses IUP and libcURL\n"
"Licensed under the GPL license"),NULL);
btn_home = IupButton(_("Homepage"),NULL);
IupSetfAttribute(btn_home,"MINSIZE","%dx%d",60,24);
IupSetCallback(btn_home,"ACTION",(Icallback)_btn_home);

btn_bug = IupButton(_("Bug report"),NULL);
IupSetfAttribute(btn_bug,"MINSIZE","%dx%d",60,24);
IupSetCallback(btn_bug,"ACTION",(Icallback)_btn_bug);

btn_close = IupButton(_("Close"),NULL);
IupSetfAttribute(btn_close,"MINSIZE","%dx%d",60,24);
IupSetCallback(btn_close,"ACTION",(Icallback)_btn_close);

hbox_buttons = IupHbox(btn_home,btn_bug,IupFill(),btn_close,NULL);
vbox_top = IupSetAtt(NULL,IupVbox(hbox_title,txt_area,NULL),
"MARGIN","5x5");
"MARGIN","5x5",NULL);

vbox_all = IupVbox(
IupSetAtt(NULL,IupFrame(vbox_top),
Expand All @@ -131,6 +134,7 @@ int gui_about(Ihandle *ih){
dialog = IupDialog(vbox_all);
IupSetAttribute(dialog,"TITLE",_("About Dialog"));
IupSetAttribute(dialog,"SIZE","250x150");
IupSetAttributeHandle(dialog,"ICON",himg_redshift);
IupPopup(dialog,IUP_CENTER,IUP_CENTER);
IupDestroy(dialog);
return IUP_DEFAULT;
Expand Down
1 change: 1 addition & 0 deletions src/gui/iupgui_main.c
Expand Up @@ -254,6 +254,7 @@ static Ihandle *_main_create_sun(void){
IupSetfAttribute(lbl_sun,"CY","%d",0);
// Preview
btn_preview = IupButton(_("Preview"),NULL);
IupSetfAttribute(btn_preview,"MINSIZE","%dx%d",60,24);
IupSetCallback(btn_preview,"ACTION",(Icallback)_main_preview);
vbox_sun = IupCbox(
lbl_backsun,
Expand Down
5 changes: 3 additions & 2 deletions src/gui/iupgui_settings.c
Expand Up @@ -231,7 +231,7 @@ static Ihandle *_settings_create_elev(void){

// Assume a size of 20 char per line
#define LINE_SIZE 20
txt_val = (char*)malloc(size*sizeof(char)*LINE_SIZE);
txt_val = (char*)malloc(size*sizeof(char)*LINE_SIZE+1);

for( i=0; i<size; ++i ){
// Use up LINE_SIZE of buffer, with NULL terminator being overwritten on
Expand Down Expand Up @@ -333,7 +333,8 @@ int guisettings_show(Ihandle *ih){
_settings_create();
IupPopup(dialog_settings,IUP_CENTER,IUP_CENTER);
IupDestroy(dialog_settings);
free(txt_val);
if( txt_val )
free(txt_val);
dialog_settings = NULL;
txt_val = NULL;
guigamma_check(ih);
Expand Down
2 changes: 1 addition & 1 deletion src/options.c
Expand Up @@ -277,7 +277,7 @@ int opt_parse_map(char *map){
char *currsep,*currend;
int cnt=0;
int i;
int prevelev=SOLAR_MAX_ANGLE;
double prevelev=SOLAR_MAX_ANGLE;
pair *curr_map;
while( (currstr=strchr(currstr,',')) ){
if( (currstr=strchr(currstr,';')) )
Expand Down

0 comments on commit 52cf225

Please sign in to comment.