Commit f1aebf73 authored by Michael Meeks's avatar Michael Meeks
Browse files

Fix ref-counting buglet ( saves memory ),

Kill the last Style *,
parent 0f8c4327
No preview for this file type
No preview for this file type
......@@ -1028,8 +1028,10 @@ ms_excel_get_style_from_xf (ExcelSheet *sheet, guint16 xfidx)
g_return_val_if_fail (xf != NULL, NULL);
if (xf->mstyle != NULL)
if (xf->mstyle != NULL) {
mstyle_ref (xf->mstyle);
return xf->mstyle;
}
mstyle = mstyle_new ();
mstyle_set_align_v (mstyle, xf->valign);
......
......@@ -41,13 +41,17 @@ item_edit_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
{
GtkWidget *canvas = GTK_WIDGET (item->canvas);
ItemEdit *item_edit = ITEM_EDIT (item);
StyleFont *style_font;
GdkFont *font;
ColRowInfo *ci;
int xd, yd, wd, hd, dx, dy;
char *text;
int cursor_pos, text_len, first_part_len, total_len;
font = style_font_gdk_font (item_edit->style->font);
style_font = mstyle_get_font (item_edit->mstyle,
item_edit->sheet->last_zoom_factor_used);
font = style_font_gdk_font (style_font);
text = gtk_entry_get_text (GTK_ENTRY (item_edit->editor));
text_len = strlen (text);
......@@ -95,6 +99,7 @@ item_edit_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
dx + first_part_len,
dy + hd - font->descent,
text + cursor_pos, text_len - cursor_pos);
style_font_unref (style_font);
}
static double
......@@ -143,17 +148,10 @@ item_edit_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int
gnome_canvas_group_child_bounds (
GNOME_CANVAS_GROUP (item->parent), item);
if (item_edit->style)
style_unref (item_edit->style);
{
MStyle *mstyle;
mstyle = sheet_style_compute (item_edit->sheet,
item_edit->col, item_edit->row);
item_edit->style = style_new_mstyle (mstyle, MSTYLE_ELEMENT_MAX,
item_edit->sheet->last_zoom_factor_used);
mstyle_unref (mstyle);
}
if (item_edit->mstyle)
mstyle_unref (item_edit->mstyle);
item_edit->mstyle = sheet_style_compute (item_edit->sheet,
item_edit->col, item_edit->row);
}
/*
......@@ -175,6 +173,8 @@ item_edit_init (ItemEdit *item_edit)
item_edit->sheet = 0;
item_edit->col = -1;
item_edit->row = -1;
item_edit->mstyle = NULL;
}
static void
......@@ -201,7 +201,7 @@ item_edit_destroy (GtkObject *o)
int x, y, w, h;
/* Repaint the area where we had edited */
style_destroy (item_edit->style);
mstyle_unref (item_edit->mstyle);
item_edit_get_pixel_coords (item_edit, &x, &y, &w, &h);
gnome_canvas_request_redraw (GNOME_CANVAS_ITEM (item_edit)->canvas, x, y, x+w, y+h);
......@@ -215,7 +215,7 @@ item_edit_destroy (GtkObject *o)
static int
entry_event (GtkEntry *entry, GdkEvent *event, ItemEdit *item_edit)
{
switch (event->type){
switch (event->type) {
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
case GDK_BUTTON_PRESS:
......
......@@ -24,7 +24,7 @@ typedef struct {
int col, row, col_span;
int pixel_span;
Style *style;
MStyle *mstyle;
} ItemEdit;
GtkType item_edit_get_type (void);
......
......@@ -340,7 +340,6 @@ sheet_style_attach (Sheet *sheet, Range range,
sr = g_new (StyleRegion, 1);
sr->range = range;
sr->style = mstyle;
mstyle_ref (mstyle);
STYLE_LIST (sheet) = g_list_prepend (STYLE_LIST (sheet), sr);
......
......@@ -685,7 +685,7 @@ xml_write_style (parse_xml_context_t *ctxt,
xml_set_color_value (cur, "Fore", mstyle_get_color (style, MSTYLE_COLOR_FORE));
}
if (mstyle_is_element_set (style, MSTYLE_COLOR_BACK)) {
if (!style_is_default_fore (mstyle_get_color (style, MSTYLE_COLOR_BACK)))
if (!style_is_default_back (mstyle_get_color (style, MSTYLE_COLOR_BACK)))
xml_set_color_value (cur, "Back", mstyle_get_color (style, MSTYLE_COLOR_BACK));
}
if (mstyle_is_element_set (style, MSTYLE_FORMAT))
......
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