app/vectors/gimpstroke.c app/vectors/gimpvectors-preview.c

2003-08-22  Simon Budig  <simon@gimp.org>

	* app/vectors/gimpstroke.c
	* app/vectors/gimpvectors-preview.c
	* app/tools/gimptransformtool.c
	* app/tools/gimpvectortool.c: Added missing checking for NULL
	return values. Hopefully this fixes the crashes others are
	observing.
This commit is contained in:
Simon Budig 2003-08-22 13:00:25 +00:00 committed by Simon Budig
parent 9d31a9db10
commit d368e27e5a
5 changed files with 60 additions and 33 deletions

View file

@ -1,3 +1,12 @@
2003-08-22 Simon Budig <simon@gimp.org>
* app/vectors/gimpstroke.c
* app/vectors/gimpvectors-preview.c
* app/tools/gimptransformtool.c
* app/tools/gimpvectortool.c: Added missing checking for NULL
return values. Hopefully this fixes the crashes others are
observing.
2003-08-22 Simon Budig <simon@gimp.org>
* app/vectors/gimpbezierstroke.c: fixed crash when deleting

View file

@ -764,22 +764,25 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool)
coords = gimp_stroke_interpolate (stroke, 1.0, &closed);
for (i = 0; i < coords->len; i++)
if (coords)
{
GimpCoords *curr = &g_array_index (coords, GimpCoords, i);
for (i = 0; i < coords->len; i++)
{
GimpCoords *curr = &g_array_index (coords, GimpCoords, i);
gimp_matrix3_transform_point (&matrix,
curr->x, curr->y,
&curr->x, &curr->y);
gimp_matrix3_transform_point (&matrix,
curr->x, curr->y,
&curr->x, &curr->y);
}
if (coords->len)
gimp_draw_tool_draw_strokes (draw_tool,
&g_array_index (coords,
GimpCoords, 0),
coords->len, FALSE, FALSE);
g_array_free (coords, TRUE);
}
if (coords->len)
gimp_draw_tool_draw_strokes (draw_tool,
&g_array_index (coords,
GimpCoords, 0),
coords->len, FALSE, FALSE);
g_array_free (coords, TRUE);
}
}
}

View file

@ -982,19 +982,22 @@ gimp_vector_tool_draw (GimpDrawTool *draw_tool)
/* the lines to the control handles */
coords = gimp_stroke_get_draw_lines (cur_stroke);
if (coords->len % 2 == 0)
if (coords)
{
gint i;
if (coords->len % 2 == 0)
{
gint i;
for (i = 0; i < coords->len; i += 2)
gimp_draw_tool_draw_strokes (draw_tool,
&g_array_index (coords,
GimpCoords, i),
2, FALSE, FALSE);
for (i = 0; i < coords->len; i += 2)
gimp_draw_tool_draw_strokes (draw_tool,
&g_array_index (coords,
GimpCoords, i),
2, FALSE, FALSE);
}
g_array_free (coords, TRUE);
}
g_array_free (coords, TRUE);
/* the stroke itself */
coords = gimp_stroke_interpolate (cur_stroke, 1.0, &closed);

View file

@ -1000,7 +1000,8 @@ static GArray *
gimp_stroke_real_get_draw_lines (const GimpStroke *stroke)
{
GList *list;
GArray *ret_lines = g_array_new (FALSE, FALSE, sizeof (GimpCoords));
GArray *ret_lines = NULL;
gint count = 0;
for (list = stroke->anchors; list; list = g_list_next (list))
{
@ -1012,16 +1013,24 @@ gimp_stroke_real_get_draw_lines (const GimpStroke *stroke)
{
GimpAnchor *next = list->next->data;
if (count == 0)
ret_lines = g_array_new (FALSE, FALSE, sizeof (GimpCoords));
ret_lines = g_array_append_val (ret_lines, anchor->position);
ret_lines = g_array_append_val (ret_lines, next->position);
count += 1;
}
if (list->prev)
{
GimpAnchor *prev = list->prev->data;
if (count == 0)
ret_lines = g_array_new (FALSE, FALSE, sizeof (GimpCoords));
ret_lines = g_array_append_val (ret_lines, anchor->position);
ret_lines = g_array_append_val (ret_lines, prev->position);
count += 1;
}
}
}

View file

@ -67,21 +67,24 @@ gimp_vectors_get_new_preview (GimpViewable *viewable,
coords = gimp_stroke_interpolate (cur_stroke, 0.5, &closed);
for (i = 0; i < coords->len; i++)
if (coords)
{
GimpCoords point;
gint x, y;
for (i = 0; i < coords->len; i++)
{
GimpCoords point;
gint x, y;
point = g_array_index (coords, GimpCoords, i);
point = g_array_index (coords, GimpCoords, i);
x = ROUND (point.x * xscale);
y = ROUND (point.y * yscale);
x = ROUND (point.x * xscale);
y = ROUND (point.y * yscale);
if (x >= 0 && y >= 0 && x < width && y < height)
data[y * width + x] = 0;
if (x >= 0 && y >= 0 && x < width && y < height)
data[y * width + x] = 0;
}
g_array_free (coords, TRUE);
}
g_array_free (coords, TRUE);
}
return temp_buf;