Commit 2a9a3045 authored by Morten Welinder's avatar Morten Welinder

The tough got going.

parent 0f4bc852
1999-05-06 Morten Welinder <terra@diku.dk>
* src/eval.c (cell_queue_recalc): Don't re-queue cell.
(cell_queue_recalc_list): Don't re-queue cells. (Because it is
wasteful and because unqueue then won't work right.)
* src/fn-lookup.c (gnumeric_column): Fix leak.
(gnumeric_row): Fix leak.
(gnumeric_choose): Fix leak.
(lookup_similar): Fix leaks.
* src/xml-io.c (xml_probe): Fix leak.
(xmlGetValue): Fix *HUGE* leak.
(readXmlStyle): Fix leaks.
(readXmlSheet): Fix leaks.
(createXmlSheet): Fix leak.
(readXmlCell): Move the freeze, just in case.
* src/fn-lookup.c (gnumeric_choose): Remove (incorrect) arg check.
* src/cell.c (cell_copy): Properly handle render_color member.
Clear the CELL_QUEUED_FOR_RECALC flag.
(cell_destroy): Add code to make it painfully clear when members
of freed cells are accessed.
1999-05-06 Michael Meeks <michael@imaginator.com>
* src/cell.h: Added deep freeze prototypes.
......
1999-05-06 Morten Welinder <terra@diku.dk>
* src/eval.c (cell_queue_recalc): Don't re-queue cell.
(cell_queue_recalc_list): Don't re-queue cells. (Because it is
wasteful and because unqueue then won't work right.)
* src/fn-lookup.c (gnumeric_column): Fix leak.
(gnumeric_row): Fix leak.
(gnumeric_choose): Fix leak.
(lookup_similar): Fix leaks.
* src/xml-io.c (xml_probe): Fix leak.
(xmlGetValue): Fix *HUGE* leak.
(readXmlStyle): Fix leaks.
(readXmlSheet): Fix leaks.
(createXmlSheet): Fix leak.
(readXmlCell): Move the freeze, just in case.
* src/fn-lookup.c (gnumeric_choose): Remove (incorrect) arg check.
* src/cell.c (cell_copy): Properly handle render_color member.
Clear the CELL_QUEUED_FOR_RECALC flag.
(cell_destroy): Add code to make it painfully clear when members
of freed cells are accessed.
1999-05-06 Michael Meeks <michael@imaginator.com>
* src/cell.h: Added deep freeze prototypes.
......
1999-05-06 Morten Welinder <terra@diku.dk>
* src/eval.c (cell_queue_recalc): Don't re-queue cell.
(cell_queue_recalc_list): Don't re-queue cells. (Because it is
wasteful and because unqueue then won't work right.)
* src/fn-lookup.c (gnumeric_column): Fix leak.
(gnumeric_row): Fix leak.
(gnumeric_choose): Fix leak.
(lookup_similar): Fix leaks.
* src/xml-io.c (xml_probe): Fix leak.
(xmlGetValue): Fix *HUGE* leak.
(readXmlStyle): Fix leaks.
(readXmlSheet): Fix leaks.
(createXmlSheet): Fix leak.
(readXmlCell): Move the freeze, just in case.
* src/fn-lookup.c (gnumeric_choose): Remove (incorrect) arg check.
* src/cell.c (cell_copy): Properly handle render_color member.
Clear the CELL_QUEUED_FOR_RECALC flag.
(cell_destroy): Add code to make it painfully clear when members
of freed cells are accessed.
1999-05-06 Michael Meeks <michael@imaginator.com>
* src/cell.h: Added deep freeze prototypes.
......
1999-05-06 Morten Welinder <terra@diku.dk>
* src/eval.c (cell_queue_recalc): Don't re-queue cell.
(cell_queue_recalc_list): Don't re-queue cells. (Because it is
wasteful and because unqueue then won't work right.)
* src/fn-lookup.c (gnumeric_column): Fix leak.
(gnumeric_row): Fix leak.
(gnumeric_choose): Fix leak.
(lookup_similar): Fix leaks.
* src/xml-io.c (xml_probe): Fix leak.
(xmlGetValue): Fix *HUGE* leak.
(readXmlStyle): Fix leaks.
(readXmlSheet): Fix leaks.
(createXmlSheet): Fix leak.
(readXmlCell): Move the freeze, just in case.
* src/fn-lookup.c (gnumeric_choose): Remove (incorrect) arg check.
* src/cell.c (cell_copy): Properly handle render_color member.
Clear the CELL_QUEUED_FOR_RECALC flag.
(cell_destroy): Add code to make it painfully clear when members
of freed cells are accessed.
1999-05-06 Michael Meeks <michael@imaginator.com>
* src/cell.h: Added deep freeze prototypes.
......
......@@ -35,8 +35,6 @@ gnumeric_choose (Sheet *sheet, GList *expr_node_list, int eval_col, int eval_row
Value *v;
GList *l=expr_node_list;
g_return_val_if_fail (l, NULL);
argc = g_list_length(l);
if (argc<1 || !l->data) {
*error_string = _("#ARG!");
......@@ -47,6 +45,7 @@ gnumeric_choose (Sheet *sheet, GList *expr_node_list, int eval_col, int eval_row
if (v->type != VALUE_INTEGER &&
v->type != VALUE_FLOAT) {
*error_string = _("#VALUE!");
value_release (v);
return NULL;
}
index = value_get_as_int(v);
......@@ -121,11 +120,16 @@ lookup_similar (const Value *data, const Value *templ, const Value *next_largest
char *c = value_string (next_largest);
int cmp = strcasecmp (a,c);
g_free (c);
if (cmp >= 0)
if (cmp >= 0) {
g_free (a);
g_free (b);
return -1;
}
else
}
} else {
g_free (a);
g_free (b);
return -1;
}
}
}
else
......@@ -320,12 +324,15 @@ gnumeric_column (Sheet *sheet, GList *expr_node_list, int eval_col, int eval_row
switch (v->type){
case VALUE_CELLRANGE:
*error_string = _("Arrays not yet supported");
value_release (v);
return NULL;
case VALUE_ARRAY:
*error_string = _("Unimplemented");
value_release (v);
return NULL;
default:
*error_string = _("#VALUE!");
value_release (v);
return NULL;
}
}
......@@ -419,12 +426,15 @@ gnumeric_row (Sheet *sheet, GList *expr_node_list, int eval_col, int eval_row, c
switch (v->type){
case VALUE_CELLRANGE:
*error_string = _("Arrays not yet supported");
value_release (v);
return NULL;
case VALUE_ARRAY:
*error_string = _("Unimplemented");
value_release (v);
return NULL;
default:
*error_string = _("#VALUE!");
value_release (v);
return NULL;
}
}
......
......@@ -38,6 +38,7 @@ cell_modified (Cell *cell)
sheet->modified = TRUE;
}
void
cell_set_formula (Cell *cell, const char *text)
{
......@@ -537,7 +538,6 @@ cell_render_value (Cell *cell)
g_free (str);
}
/*
* Sets the value for a cell:
*
......@@ -815,16 +815,23 @@ cell_copy (const Cell *cell)
new_cell->col = NULL;
new_cell->row = NULL;
new_cell->sheet = NULL;
new_cell->flags &= ~CELL_QUEUED_FOR_RECALC;
/* now copy propertly the rest */
/* now copy properly the rest */
if (new_cell->parsed_node)
expr_tree_ref (new_cell->parsed_node);
string_ref (new_cell->text);
expr_tree_ref (new_cell->parsed_node);
if (new_cell->text)
string_ref (new_cell->text);
if (new_cell->entered_text)
string_ref (new_cell->entered_text);
new_cell->style = style_duplicate (new_cell->style);
if (new_cell->style)
new_cell->style = style_duplicate (new_cell->style);
if (new_cell->render_color)
style_color_ref (new_cell->render_color);
/*
* The cell->value can be NULL if the cell contains
......@@ -833,9 +840,10 @@ cell_copy (const Cell *cell)
if (new_cell->value)
new_cell->value = value_duplicate (new_cell->value);
new_cell->comment = NULL;
if (cell->comment)
if (cell->comment) {
new_cell->comment = NULL;
cell_set_comment (new_cell, cell->comment->comment->str);
}
return new_cell;
}
......@@ -845,26 +853,38 @@ cell_destroy (Cell *cell)
{
g_return_if_fail (cell != NULL);
if (cell_hash_queue && g_hash_table_lookup (cell_hash_queue, cell)) {
g_warning ("FIXME: Deleting cell %s which was queued for redraw",
cell_name (cell->col->pos, cell->row->pos));
g_hash_table_remove (cell_hash_queue, cell);
}
cell_modified (cell);
if (cell->parsed_node){
if (cell->parsed_node)
expr_tree_unref (cell->parsed_node);
}
cell->parsed_node = (void *)0xdeadbeef;
if (cell->render_color)
style_color_unref (cell->render_color);
cell->render_color = (void *)0xdeadbeef;
cell_comment_destroy (cell);
if (cell->text)
string_unref (cell->text);
cell->text = (void *)0xdeadbeef;
if (cell->entered_text)
string_unref (cell->entered_text);
cell->entered_text = (void *)0xdeadbeef;
style_destroy (cell->style);
cell->style = (void *)0xdeadbeef;
if (cell->value)
value_release (cell->value);
cell->value = (void *)0xdeadbeef;
g_free (cell);
}
......@@ -932,7 +952,7 @@ cell_queue_redraw (Cell *cell)
queue_cell (cell);
return;
}
sheet_redraw_cell_region (cell->sheet,
cell->col->pos, cell->row->pos,
cell->col->pos, cell->row->pos);
......
......@@ -372,6 +372,9 @@ cell_queue_recalc (Cell *cell)
g_return_if_fail (cell != NULL);
if (cell->flags & CELL_QUEUED_FOR_RECALC)
return;
wb = ((Sheet *)cell->sheet)->workbook;
wb->eval_queue = g_list_prepend (wb->eval_queue, cell);
cell->flags |= CELL_QUEUED_FOR_RECALC;
......@@ -405,20 +408,27 @@ cell_queue_recalc_list (GList *list)
{
Workbook *wb;
Cell *first_cell;
GList *list0 = list;
if (!list)
return;
first_cell = list->data;
wb = ((Sheet *)(first_cell->sheet))->workbook;
wb->eval_queue = g_list_concat (wb->eval_queue, list);
while (list) {
Cell *cell = list->data;
cell->flags |= CELL_QUEUED_FOR_RECALC;
list = list->next;
if (cell->flags & CELL_QUEUED_FOR_RECALC)
continue;
wb->eval_queue = g_list_prepend (wb->eval_queue, cell);
cell->flags |= CELL_QUEUED_FOR_RECALC;
}
g_list_free (list0);
}
static Cell *
......
......@@ -372,6 +372,9 @@ cell_queue_recalc (Cell *cell)
g_return_if_fail (cell != NULL);
if (cell->flags & CELL_QUEUED_FOR_RECALC)
return;
wb = ((Sheet *)cell->sheet)->workbook;
wb->eval_queue = g_list_prepend (wb->eval_queue, cell);
cell->flags |= CELL_QUEUED_FOR_RECALC;
......@@ -405,20 +408,27 @@ cell_queue_recalc_list (GList *list)
{
Workbook *wb;
Cell *first_cell;
GList *list0 = list;
if (!list)
return;
first_cell = list->data;
wb = ((Sheet *)(first_cell->sheet))->workbook;
wb->eval_queue = g_list_concat (wb->eval_queue, list);
while (list) {
Cell *cell = list->data;
cell->flags |= CELL_QUEUED_FOR_RECALC;
list = list->next;
if (cell->flags & CELL_QUEUED_FOR_RECALC)
continue;
wb->eval_queue = g_list_prepend (wb->eval_queue, cell);
cell->flags |= CELL_QUEUED_FOR_RECALC;
}
g_list_free (list0);
}
static Cell *
......
......@@ -35,8 +35,6 @@ gnumeric_choose (Sheet *sheet, GList *expr_node_list, int eval_col, int eval_row
Value *v;
GList *l=expr_node_list;
g_return_val_if_fail (l, NULL);
argc = g_list_length(l);
if (argc<1 || !l->data) {
*error_string = _("#ARG!");
......@@ -47,6 +45,7 @@ gnumeric_choose (Sheet *sheet, GList *expr_node_list, int eval_col, int eval_row
if (v->type != VALUE_INTEGER &&
v->type != VALUE_FLOAT) {
*error_string = _("#VALUE!");
value_release (v);
return NULL;
}
index = value_get_as_int(v);
......@@ -121,11 +120,16 @@ lookup_similar (const Value *data, const Value *templ, const Value *next_largest
char *c = value_string (next_largest);
int cmp = strcasecmp (a,c);
g_free (c);
if (cmp >= 0)
if (cmp >= 0) {
g_free (a);
g_free (b);
return -1;
}
else
}
} else {
g_free (a);
g_free (b);
return -1;
}
}
}
else
......@@ -320,12 +324,15 @@ gnumeric_column (Sheet *sheet, GList *expr_node_list, int eval_col, int eval_row
switch (v->type){
case VALUE_CELLRANGE:
*error_string = _("Arrays not yet supported");
value_release (v);
return NULL;
case VALUE_ARRAY:
*error_string = _("Unimplemented");
value_release (v);
return NULL;
default:
*error_string = _("#VALUE!");
value_release (v);
return NULL;
}
}
......@@ -419,12 +426,15 @@ gnumeric_row (Sheet *sheet, GList *expr_node_list, int eval_col, int eval_row, c
switch (v->type){
case VALUE_CELLRANGE:
*error_string = _("Arrays not yet supported");
value_release (v);
return NULL;
case VALUE_ARRAY:
*error_string = _("Unimplemented");
value_release (v);
return NULL;
default:
*error_string = _("#VALUE!");
value_release (v);
return NULL;
}
}
......
......@@ -35,8 +35,6 @@ gnumeric_choose (Sheet *sheet, GList *expr_node_list, int eval_col, int eval_row
Value *v;
GList *l=expr_node_list;
g_return_val_if_fail (l, NULL);
argc = g_list_length(l);
if (argc<1 || !l->data) {
*error_string = _("#ARG!");
......@@ -47,6 +45,7 @@ gnumeric_choose (Sheet *sheet, GList *expr_node_list, int eval_col, int eval_row
if (v->type != VALUE_INTEGER &&
v->type != VALUE_FLOAT) {
*error_string = _("#VALUE!");
value_release (v);
return NULL;
}
index = value_get_as_int(v);
......@@ -121,11 +120,16 @@ lookup_similar (const Value *data, const Value *templ, const Value *next_largest
char *c = value_string (next_largest);
int cmp = strcasecmp (a,c);
g_free (c);
if (cmp >= 0)
if (cmp >= 0) {
g_free (a);
g_free (b);
return -1;
}
else
}
} else {
g_free (a);
g_free (b);
return -1;
}
}
}
else
......@@ -320,12 +324,15 @@ gnumeric_column (Sheet *sheet, GList *expr_node_list, int eval_col, int eval_row
switch (v->type){
case VALUE_CELLRANGE:
*error_string = _("Arrays not yet supported");
value_release (v);
return NULL;
case VALUE_ARRAY:
*error_string = _("Unimplemented");
value_release (v);
return NULL;
default:
*error_string = _("#VALUE!");
value_release (v);
return NULL;
}
}
......@@ -419,12 +426,15 @@ gnumeric_row (Sheet *sheet, GList *expr_node_list, int eval_col, int eval_row, c
switch (v->type){
case VALUE_CELLRANGE:
*error_string = _("Arrays not yet supported");
value_release (v);
return NULL;
case VALUE_ARRAY:
*error_string = _("Unimplemented");
value_release (v);
return NULL;
default:
*error_string = _("#VALUE!");
value_release (v);
return NULL;
}
}
......
......@@ -56,7 +56,7 @@ xmlGetValue (xmlNodePtr node, const char *name)
ret = (char *) xmlGetProp (node, name);
if (ret != NULL)
return strdup (ret);
return ret;
child = node->childs;
while (child != NULL) {
......@@ -886,7 +886,7 @@ static Style *
readXmlStyle (parseXmlContextPtr ctxt, xmlNodePtr tree, Style * ret)
{
xmlNodePtr child;
const char *prop;
char *prop;
int val;
StyleColor *c;
......@@ -932,15 +932,16 @@ readXmlStyle (parseXmlContextPtr ctxt, xmlNodePtr tree, Style * ret)
prop = xmlGetValue (tree, "Format");
if (prop != NULL){
if (ret->format == NULL){
ret->format = style_format_new ((char *) prop);
ret->format = style_format_new ((const char *) prop);
ret->valid_flags |= STYLE_FORMAT;
}
free (prop);
}
child = tree->childs;
while (child != NULL){
if (!strcmp (child->name, "Font")){
const char *v;
char *v;
v = xmlGetValue (child, "NAME");
if (v){
......@@ -957,6 +958,7 @@ readXmlStyle (parseXmlContextPtr ctxt, xmlNodePtr tree, Style * ret)
g_hash_table_insert (ctxt->nameTable, g_strdup (v), ret->font);
ret->valid_flags |= STYLE_FONT;
}
free (v);
} else {
StyleFont *font;
......@@ -1234,8 +1236,6 @@ readXmlCell (parseXmlContextPtr ctxt, xmlNodePtr tree)
int row = 0, col = 0;
char *content = NULL;
cell_deep_freeze_redraws ();
if (strcmp (tree->name, "Cell")){
fprintf (stderr,
"readXmlCell: invalid element type %s, 'Cell' expected`\n",
......@@ -1245,6 +1245,8 @@ readXmlCell (parseXmlContextPtr ctxt, xmlNodePtr tree)
xmlGetIntValue (tree, "Col", &col);
xmlGetIntValue (tree, "Row", &row);
cell_deep_freeze_redraws ();
ret = sheet_cell_get (ctxt->sheet, col, row);
if (ret == NULL)
ret = sheet_cell_new (ctxt->sheet, col, row);
......@@ -1402,7 +1404,7 @@ readXmlSheet (parseXmlContextPtr ctxt, xmlNodePtr tree)
xmlNodePtr cells;
xmlNodePtr objects;
Sheet *ret = NULL;
const char *val;
char *val;
if (strcmp (tree->name, "Sheet")){
fprintf (stderr,
......@@ -1421,6 +1423,7 @@ readXmlSheet (parseXmlContextPtr ctxt, xmlNodePtr tree)
ret = workbook_sheet_lookup (ctxt->wb, (const char *) val);
if (ret == NULL)
ret = sheet_new (ctxt->wb, (const char *) val);
free (val);
}
if (ret == NULL)
......@@ -1539,7 +1542,7 @@ writeXmlWorkbook (parseXmlContextPtr ctxt, Workbook *wb)
static void
createXmlSheet (parseXmlContextPtr ctxt, xmlNodePtr tree)
{
const char *val;
char *val;
xmlNodePtr child;
if (strcmp (tree->name, "Sheet")){
......@@ -1553,8 +1556,9 @@ createXmlSheet (parseXmlContextPtr ctxt, xmlNodePtr tree)
if (val != NULL){
Sheet *sheet;
sheet = sheet_new (ctxt->wb, (char *) val);
sheet = sheet_new (ctxt->wb, (const char *) val);
workbook_attach_sheet (ctxt->wb, sheet);
free (val);
}
return;
}
......@@ -1626,13 +1630,15 @@ xml_probe (const char *filename)
{
xmlDocPtr res;
xmlNsPtr gmr;
res = xmlParseFile (filename);
if (res == NULL)
return FALSE;
if (res->root == NULL)
if (res->root == NULL) {
xmlFreeDoc (res);
return FALSE;
}
gmr = xmlSearchNsByHref (res, res->root, "http://www.gnome.org/gnumeric/");
if (res->root->name == NULL || strcmp (res->root->name, "Workbook") || (gmr == NULL)){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment