Re: [evolution-patches] 41498: display elipses for overflowing text cells



Hmm, there was actually a problem with this patch, although you might
know by now anyway.  I get memory corruption when i open the meeting
editor in the calendar.

The version below of the code in e-cell-text.c:build_layout() seems to
stop it crashing at least.

Without the line->length > 1 test, g_utf8_prev_char can go beyond the
start of the text (how the text could be 1 char and over 1 line long
sounds like a bug, but this situation occured).

And the other check is that it doesn't try to go beyond the start of the
line as well (e.g. a line full of .'s).

FWIW this algorithm seems to do pretty funky and unexpected
elipsification, sometimes cutting off less of words as the table is made
wider.


	while (pango_layout_get_line_count (layout) > 1) {
		PangoLayoutLine *line = pango_layout_get_line (layout, 0);
		gchar *line_text;
		gchar *last_char;
		gchar *new_text;

		if (line->length <= 1)
			break;

		line_text = g_strdup (pango_layout_get_text (layout));
		last_char = g_utf8_prev_char (line_text + line->length - 1);
		while (last_char > line_text && *last_char == '.')
			last_char = g_utf8_prev_char (last_char);
		*last_char = '\0';
		new_text = g_strconcat (line_text, " ...", NULL);
		pango_layout_set_text (layout, new_text, g_utf8_strlen (new_text,
-1));
		g_free (line_text);
		g_free (new_text);
	}


On Fri, 2003-04-18 at 05:23, Mike Kestner wrote:
> Updating this patch a bit.  Needed a few additional fixes in e-cell-text
> to be able to enter edit mode on a cell without crashing.
> 
> Mike




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]