Bug 635040 - Edit -> Stroke Path performs no action on an incomplete path

Add error reporting to gimp_drawable_stroke_vectors() and produce the
same warning as the paint core when trying to stroke a path with zero
or one points only.
This commit is contained in:
Michael Natterer
2010-11-25 11:31:40 +01:00
parent 77a5999f13
commit d46b53f63d
4 changed files with 84 additions and 59 deletions

View File

@ -39,6 +39,7 @@
#include "gimpchannel.h"
#include "gimpcontext.h"
#include "gimpdrawable-stroke.h"
#include "gimperror.h"
#include "gimpimage.h"
#include "gimppattern.h"
#include "gimpscanconvert.h"
@ -59,7 +60,8 @@ static GimpScanConvert * gimp_drawable_render_boundary (GimpDrawable *dra
gint offset_y);
static GimpScanConvert * gimp_drawable_render_vectors (GimpDrawable *drawable,
GimpVectors *vectors,
gboolean do_stroke);
gboolean do_stroke,
GError **error);
static void gimp_drawable_stroke_scan_convert (GimpDrawable *drawable,
GimpFillOptions *options,
GimpScanConvert *scan_convert,
@ -129,54 +131,68 @@ gimp_drawable_stroke_boundary (GimpDrawable *drawable,
}
}
void
gimp_drawable_fill_vectors (GimpDrawable *drawable,
GimpFillOptions *options,
GimpVectors *vectors,
gboolean push_undo)
gboolean
gimp_drawable_fill_vectors (GimpDrawable *drawable,
GimpFillOptions *options,
GimpVectors *vectors,
gboolean push_undo,
GError **error)
{
GimpScanConvert *scan_convert;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
g_return_if_fail (GIMP_IS_FILL_OPTIONS (options));
g_return_if_fail (GIMP_IS_VECTORS (vectors));
g_return_if_fail (options->style != GIMP_FILL_STYLE_PATTERN ||
gimp_context_get_pattern (GIMP_CONTEXT (options)) != NULL);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), FALSE);
g_return_val_if_fail (GIMP_IS_FILL_OPTIONS (options), FALSE);
g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE);
g_return_val_if_fail (options->style != GIMP_FILL_STYLE_PATTERN ||
gimp_context_get_pattern (GIMP_CONTEXT (options)) != NULL,
FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
scan_convert = gimp_drawable_render_vectors (drawable, vectors, FALSE);
scan_convert = gimp_drawable_render_vectors (drawable, vectors, FALSE, error);
if (scan_convert)
{
gimp_drawable_stroke_scan_convert (drawable, options,
scan_convert, FALSE, push_undo);
gimp_scan_convert_free (scan_convert);
return TRUE;
}
return FALSE;
}
void
gimp_drawable_stroke_vectors (GimpDrawable *drawable,
GimpStrokeOptions *options,
GimpVectors *vectors,
gboolean push_undo)
gboolean
gimp_drawable_stroke_vectors (GimpDrawable *drawable,
GimpStrokeOptions *options,
GimpVectors *vectors,
gboolean push_undo,
GError **error)
{
GimpScanConvert *scan_convert;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
g_return_if_fail (GIMP_IS_STROKE_OPTIONS (options));
g_return_if_fail (GIMP_IS_VECTORS (vectors));
g_return_if_fail (GIMP_FILL_OPTIONS (options)->style != GIMP_FILL_STYLE_PATTERN ||
gimp_context_get_pattern (GIMP_CONTEXT (options)) != NULL);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), FALSE);
g_return_val_if_fail (GIMP_IS_STROKE_OPTIONS (options), FALSE);
g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE);
g_return_val_if_fail (GIMP_FILL_OPTIONS (options)->style != GIMP_FILL_STYLE_PATTERN ||
gimp_context_get_pattern (GIMP_CONTEXT (options)) != NULL,
FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
scan_convert = gimp_drawable_render_vectors (drawable, vectors, TRUE);
scan_convert = gimp_drawable_render_vectors (drawable, vectors, TRUE, error);
if (scan_convert)
{
gimp_drawable_stroke_scan_convert (drawable, GIMP_FILL_OPTIONS (options),
scan_convert, TRUE, push_undo);
gimp_scan_convert_free (scan_convert);
return TRUE;
}
return FALSE;
}
@ -254,9 +270,10 @@ gimp_drawable_render_boundary (GimpDrawable *drawable,
}
static GimpScanConvert *
gimp_drawable_render_vectors (GimpDrawable *drawable,
GimpVectors *vectors,
gboolean do_stroke)
gimp_drawable_render_vectors (GimpDrawable *drawable,
GimpVectors *vectors,
gboolean do_stroke,
GError **error)
{
GimpScanConvert *scan_convert;
GimpStroke *stroke;
@ -306,6 +323,9 @@ gimp_drawable_render_vectors (GimpDrawable *drawable,
gimp_scan_convert_free (scan_convert);
g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
_("Not enough points to stroke"));
return NULL;
}

View File

@ -22,29 +22,31 @@
#define __GIMP_DRAWABLE_STROKE_H__
void gimp_drawable_fill_boundary (GimpDrawable *drawable,
GimpFillOptions *options,
const BoundSeg *bound_segs,
gint n_bound_segs,
gint offset_x,
gint offset_y,
gboolean push_undo);
void gimp_drawable_stroke_boundary (GimpDrawable *drawable,
GimpStrokeOptions *options,
const BoundSeg *bound_segs,
gint n_bound_segs,
gint offset_x,
gint offset_y,
gboolean push_undo);
void gimp_drawable_fill_boundary (GimpDrawable *drawable,
GimpFillOptions *options,
const BoundSeg *bound_segs,
gint n_bound_segs,
gint offset_x,
gint offset_y,
gboolean push_undo);
void gimp_drawable_stroke_boundary (GimpDrawable *drawable,
GimpStrokeOptions *options,
const BoundSeg *bound_segs,
gint n_bound_segs,
gint offset_x,
gint offset_y,
gboolean push_undo);
void gimp_drawable_fill_vectors (GimpDrawable *drawable,
GimpFillOptions *options,
GimpVectors *vectors,
gboolean push_undo);
void gimp_drawable_stroke_vectors (GimpDrawable *drawable,
GimpStrokeOptions *options,
GimpVectors *vectors,
gboolean push_undo);
gboolean gimp_drawable_fill_vectors (GimpDrawable *drawable,
GimpFillOptions *options,
GimpVectors *vectors,
gboolean push_undo,
GError **error);
gboolean gimp_drawable_stroke_vectors (GimpDrawable *drawable,
GimpStrokeOptions *options,
GimpVectors *vectors,
gboolean push_undo,
GError **error);
#endif /* __GIMP_DRAWABLE_STROKE_H__ */

View File

@ -1165,7 +1165,7 @@ gimp_rectangle_tool_motion (GimpTool *tool,
aspect_text = g_strdup_printf (" (%.2f:1)", w / (gdouble) h);
gimp_tool_push_status_coords (tool, display,
GIMP_CURSOR_PRECISION_PIXEL_BORDER,
gimp_tool_control_get_precision (tool->control),
_("Rectangle: "),
w, " × ", h, aspect_text);
g_free (aspect_text);
@ -2161,7 +2161,7 @@ gimp_rectangle_tool_start (GimpRectangleTool *rect_tool,
/* initialize the statusbar display */
gimp_tool_push_status_coords (tool, tool->display,
GIMP_CURSOR_PRECISION_PIXEL_BORDER,
gimp_tool_control_get_precision (tool->control),
_("Rectangle: "), 0, " × ", 0, NULL);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), tool->display);

View File

@ -29,11 +29,12 @@
#include "vectors-types.h"
#include "core/gimp.h"
#include "core/gimp-transform-utils.h"
#include "core/gimpchannel-select.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpdrawable-stroke.h"
#include "core/gimp-transform-utils.h"
#include "core/gimperror.h"
#include "core/gimpimage.h"
#include "core/gimpimage-undo-push.h"
#include "core/gimpmarshal.h"
@ -550,17 +551,19 @@ gimp_vectors_stroke (GimpItem *item,
GimpVectors *vectors = GIMP_VECTORS (item);
gboolean retval = FALSE;
/* return successfully on an empty path, there's nothing to stroke */
if (! vectors->strokes)
return TRUE;
{
g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
_("Not enough points to stroke"));
return FALSE;
}
switch (stroke_options->method)
{
case GIMP_STROKE_METHOD_LIBART:
gimp_drawable_stroke_vectors (drawable,
stroke_options,
vectors, push_undo);
retval = TRUE;
retval = gimp_drawable_stroke_vectors (drawable,
stroke_options,
vectors, push_undo, error);
break;
case GIMP_STROKE_METHOD_PAINT_CORE: