|
From: Allin C. <cot...@wf...> - 2000-06-30 18:39:43
|
More on the business of freeing a gtksheet. I checked, and the
gtk_sheet_finalize function is being called OK when a window
containing gtksheet is destroyed. But it's not doing its
intended job. It's calling DeleteRow and DeleteColumn but these
are not doing anything because the loop that does the actual
freeing ends up running "for (i=0; i<=-1; i++)". I'm appending
a patch below. It may break other things, I haven't checked it
thoroughly. This doesn't fix all the memory leaks, but most of
them.
--- gtksheet.c.orig Fri Jun 30 09:39:59 2000
+++ gtksheet.c Fri Jun 30 14:24:17 2000
@@ -3182,9 +3182,10 @@
sheet->data[row][column]->attributes = NULL;
}
sheet->data[row][column]->link = NULL;
-/*
+
+ /* the following line was commented out. ?? AC */
if(sheet->data[row][column]) g_free(sheet->data[row][column]);
-*/
+
sheet->data[row][column] = NULL;
}
@@ -7514,7 +7515,7 @@
nrows=MIN(nrows,tbl->maxrow-row+1);
- for(i=row; i<=tbl->maxrow-nrows; i++){
+ for(i=row; i<row+nrows; i++){ /* was i<=tbl->maxrow-nrows AC */
if(tbl->row[i].name){
g_free(tbl->row[i].name);
tbl->row[i].name = NULL;
@@ -7523,11 +7524,12 @@
g_free(tbl->row[i].button.label);
tbl->row[i].button.label = NULL;
}
-
+ if (i+nrows <= tbl->maxrow){ /* added condition AC */
tbl->row[i]=tbl->row[i+nrows];
tbl->row[i].is_visible=tbl->row[i+nrows].is_visible;
tbl->row[i].is_sensitive=tbl->row[i+nrows].is_sensitive;
}
+ }
if(row <= tbl->maxallocrow){
@@ -7573,7 +7575,7 @@
if(ncols <= 0) return TRUE;
- for(i=column; i<=tbl->maxcol-ncols; i++){
+ for(i=column; i<column+ncols; i++){ /* was i<=tbl->maxcol-ncols AC */
auxcol=tbl->column[i];
if(tbl->column[i].name){
g_free(tbl->column[i].name);
@@ -7583,13 +7585,14 @@
g_free(tbl->column[i].button.label);
tbl->column[i].button.label = NULL;
}
-
+ if (i+ncols <= tbl->maxcol){ /* added condition AC */
tbl->column[i]=tbl->column[i+ncols];
tbl->column[i].is_visible=tbl->column[i+ncols].is_visible;
tbl->column[i].is_sensitive=tbl->column[i+ncols].is_sensitive;
tbl->column[i].left_text_column=tbl->column[i+ncols].left_text_column;
tbl->column[i].right_text_column=tbl->column[i+ncols].right_text_column;
tbl->column[i].justification=tbl->column[i+ncols].justification;
+ }
/* tbl->column[tbl->maxcol-(i-column)]=auxcol;
*/
}
--
Allin Cottrell
Department of Economics
Wake Forest University, NC
|