[gimp] Bug 155733 - need to check return values of gimp_drawable_mask_bounds()
- From: Sven Neumann <neo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 155733 - need to check return values of gimp_drawable_mask_bounds()
- Date: Wed, 8 Sep 2010 19:49:21 +0000 (UTC)
commit c5658da09c946c485c19c4ca6f8ff40cf05642f9
Author: Lloyd Konneker <bootch nc rr com>
Date: Wed Sep 8 08:09:30 2010 -0400
Bug 155733 - need to check return values of gimp_drawable_mask_bounds()
Fix one of many plugins: gimpressionist
Checks for intersecting selection before opening a dialog, and
finding none, returns an error string. Without the patch, the plugin
dialog has a black preview, when user chooses OK assertions fail, and
the plugin has no effect, but doesn't crash.
plug-ins/gimpressionist/gimp.c | 43 +++++++++++++++++++++++++++++----------
1 files changed, 32 insertions(+), 11 deletions(-)
---
diff --git a/plug-ins/gimpressionist/gimp.c b/plug-ins/gimpressionist/gimp.c
index 1221da6..4467127 100644
--- a/plug-ins/gimpressionist/gimp.c
+++ b/plug-ins/gimpressionist/gimp.c
@@ -114,7 +114,7 @@ run (const gchar *name,
gint *nreturn_vals,
GimpParam **return_vals)
{
- static GimpParam values[1];
+ static GimpParam values[2];
GimpRunMode run_mode;
GimpPDBStatusType status;
gboolean with_specified_preset;
@@ -148,6 +148,29 @@ run (const gchar *name,
random_generator = g_rand_new ();
+ /*
+ * Check precondition before we open a dialog: Is there a selection
+ * that intersects, OR is there no selection (use entire drawable.)
+ */
+ {
+ gint x1, y1, width, height; /* Not used. */
+
+ if (! gimp_drawable_mask_intersect (drawable->drawable_id,
+ &x1, &y1, &width, &height))
+ {
+ values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
+ *nreturn_vals = 2;
+ values[1].type = GIMP_PDB_STRING;
+ values[1].data.d_string = _("The selection does not intersect "
+ "the active layer or mask.");
+
+ gimp_drawable_detach (drawable);
+
+ return;
+ }
+ }
+
+
switch (run_mode)
{
/*
@@ -233,17 +256,16 @@ grabarea (void)
{
GimpPixelRgn src_rgn;
ppm_t *p;
- gint x1, y1, x2, y2;
+ gint x1, y1;
gint x, y;
gint width, height;
gint row, col;
gint rowstride;
gpointer pr;
- gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
-
- width = x2 - x1;
- height = y2 - y1;
+ if (! gimp_drawable_mask_intersect (drawable->drawable_id,
+ &x1, &y1, &width, &height))
+ return;
ppm_new (&infile, width, height);
p = &infile;
@@ -350,7 +372,7 @@ gimpressionist_main (void)
{
GimpPixelRgn dest_rgn;
ppm_t *p;
- gint x1, y1, x2, y2;
+ gint x1, y1;
gint x, y;
gint width, height;
gint row, col;
@@ -360,10 +382,9 @@ gimpressionist_main (void)
glong total;
gpointer pr;
- gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
-
- width = x2 - x1;
- height = y2 - y1;
+ if (! gimp_drawable_mask_intersect (drawable->drawable_id,
+ &x1, &y1, &width, &height))
+ return;
total = width * height;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]