Commit 390f8af9 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

Fix several memory problems (Thanks Morten)

2000-02-02  Jody Goldberg <jgoldberg@home.com>

	* src/cell.c (cell_set_text) : Fix thinko.  We are assigning to the
	  entered_text so we should unref that.  Always print the assigning
	  empty warning.

	* src/str.c (string_unref_ptr) : Delete unused function.

	* src/clipboard.c (do_clipboard_paste_cell_region) : Use the correct
	  clear flags for sheet_clear_region.
	(x_selection_handler) : Ditto.

	* src/workbook.c (workbook_expr_relocate) : We need to unref the new
	  expression because the cell refs it itself.

	* src/format.c (format_remove_decimal) : Correctly remove the last
	  decimal. bug 5836.
parent ed708582
2000-02-02 Jody Goldberg <jgoldberg@home.com>
* src/cell.c (cell_set_text) : Fix thinko. We are assigning to the
entered_text so we should unref that. Always print the assigning
empty warning.
* src/str.c (string_unref_ptr) : Delete unused function.
* src/clipboard.c (do_clipboard_paste_cell_region) : Use the correct
clear flags for sheet_clear_region.
(x_selection_handler) : Ditto.
* src/workbook.c (workbook_expr_relocate) : We need to unref the new
expression because the cell refs it itself.
* ./src/format.c (format_remove_decimal) : Correctly remove the last
decimal. bug 5836.
2000-02-02 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/dialogs/dialog-solver.c, src/dialogs/solver.glade:
......
2000-02-02 Jody Goldberg <jgoldberg@home.com>
* src/cell.c (cell_set_text) : Fix thinko. We are assigning to the
entered_text so we should unref that. Always print the assigning
empty warning.
* src/str.c (string_unref_ptr) : Delete unused function.
* src/clipboard.c (do_clipboard_paste_cell_region) : Use the correct
clear flags for sheet_clear_region.
(x_selection_handler) : Ditto.
* src/workbook.c (workbook_expr_relocate) : We need to unref the new
expression because the cell refs it itself.
* ./src/format.c (format_remove_decimal) : Correctly remove the last
decimal. bug 5836.
2000-02-02 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/dialogs/dialog-solver.c, src/dialogs/solver.glade:
......
......@@ -560,24 +560,18 @@ cell_set_text (Cell *cell, const char *text)
return;
}
if (*text == 0){
static int warn_shown;
if (*text == 0)
g_warning ("Cell value being set to empty string");
if (!warn_shown){
g_warning (
"Cell value being set to empty string");
warn_shown = 1;
}
}
cell_queue_redraw (cell);
cell_set_text_simple (cell, text);
/* Store the real entered text */
if (cell->text != NULL) {
string_unref (cell->text);
cell->entered_text = string_get (text);
if (cell->entered_text != NULL) {
String *tmp = string_get (text);
string_unref (cell->entered_text);
cell->entered_text = tmp;
}
cell_content_changed (cell);
......
......@@ -136,7 +136,7 @@ do_clipboard_paste_cell_region (CommandContext *context,
dest_col, dest_row,
dest_col + paste_width - 1,
dest_row + paste_height - 1,
TRUE);
CLEAR_VALUES|CLEAR_COMMENTS);
/* If no operations are defined, we clear the area */
if (!(paste_flags & PASTE_OPER_MASK))
......@@ -424,7 +424,8 @@ x_selection_handler (GtkWidget *widget, GtkSelectionData *selection_data, guint
sheet_clear_region (workbook_command_context_gui (sheet->workbook),
sheet,
a->start.col, a->start.row,
a->end.col, a->end.row, FALSE);
a->end.col, a->end.row,
CLEAR_VALUES|CLEAR_COMMENTS);
}
g_return_if_fail (clipboard != NULL);
......
......@@ -806,6 +806,7 @@ find_decimal_char (const char *str)
char *
format_remove_decimal (const char *format_string)
{
int offset = 1;
char *ret, *t, *p;
if (!lc)
......@@ -833,9 +834,11 @@ format_remove_decimal (const char *format_string)
*/
if ((p[1] == '0' || p[1] == '#') && (p[2] == '0' || p[2] == '#'))
++p;
else
offset = 2;
for (t = p; *t; ++t)
*t = *(t+1);
*t = *(t+offset);
return ret;
}
......
......@@ -66,26 +66,6 @@ string_unref (String *string)
}
}
/*
* Decrements the reference count on *string, and if
* it reaches zero, it also clears the value pointed
* by string_ptr
*/
void
string_unref_ptr (String **string_ptr)
{
g_return_if_fail (string_ptr != NULL);
g_return_if_fail (*string_ptr != NULL);
g_return_if_fail ((*string_ptr)->ref_count > 0);
if (--((*string_ptr)->ref_count) == 0){
g_hash_table_remove (string_hash_table, (*string_ptr)->str);
g_free ((*string_ptr)->str);
g_free (*string_ptr);
*string_ptr = NULL;
}
}
void
string_init (void)
{
......
......@@ -14,6 +14,5 @@ String *string_lookup (const char *s);
String *string_get (const char *s);
String *string_ref (String *);
void string_unref (String *);
void string_unref_ptr (String **);
#endif /* GNUMERIC_STRING_H */
......@@ -2862,6 +2862,7 @@ workbook_expr_relocate (Workbook *wb, ExprRelocateInfo const *info)
}
cell_set_formula_tree (cell, newtree);
expr_tree_unref (newtree);
}
}
......
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