[gimp] Bug 632568 - 'gimp-drawable-transform-rotate-simple' makes GIMP crash in some cases
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 632568 - 'gimp-drawable-transform-rotate-simple' makes GIMP crash in some cases
- Date: Thu, 17 Mar 2011 23:54:37 +0000 (UTC)
commit 1c8149a553c5cc4532cffe9c7266298de502c3bf
Author: Michael Natterer <mitch gimp org>
Date: Fri Mar 18 00:51:05 2011 +0100
Bug 632568 - 'gimp-drawable-transform-rotate-simple' makes GIMP crash in some cases
Applied modified patch from Massimo that makes sure we don't use
negative width/height if source and dest regions don't overlap.
app/core/gimpdrawable-transform.c | 13 +++++++---
app/tests/test-core.c | 49 +++++++++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+), 4 deletions(-)
---
diff --git a/app/core/gimpdrawable-transform.c b/app/core/gimpdrawable-transform.c
index d0a9914..5e4af20 100644
--- a/app/core/gimpdrawable-transform.c
+++ b/app/core/gimpdrawable-transform.c
@@ -455,10 +455,15 @@ gimp_drawable_transform_tiles_rotate (GimpDrawable *drawable,
orig_height = clip_width;
break;
}
- }
- new_width = clip_width;
- new_height = clip_height;
+ new_width = clip_width;
+ new_height = clip_height;
+ }
+ else
+ {
+ new_width = 0;
+ new_height = 0;
+ }
}
else
{
@@ -472,7 +477,7 @@ gimp_drawable_transform_tiles_rotate (GimpDrawable *drawable,
new_y = 0;
}
- if (new_width == 0 && new_height == 0)
+ if (new_width < 1 || new_height < 1)
return new_tiles;
pixel_region_init (&srcPR, orig_tiles,
diff --git a/app/tests/test-core.c b/app/tests/test-core.c
index bd98df6..ea8c9ba 100644
--- a/app/tests/test-core.c
+++ b/app/tests/test-core.c
@@ -23,6 +23,7 @@
#include "widgets/gimpuimanager.h"
#include "core/gimp.h"
+#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimplayer.h"
@@ -97,6 +98,49 @@ gimp_test_image_teardown (GimpTestFixture *fixture,
}
/**
+ * rotate_non_overlapping:
+ * @fixture:
+ * @data:
+ *
+ * Super basic test that makes sure we can add a layer
+ * and call gimp_item_rotate with center at (0, -10)
+ * without triggering a failed assertion .
+ **/
+static void
+rotate_non_overlapping (GimpTestFixture *fixture,
+ gconstpointer data)
+{
+ GimpImage *image = fixture->image;
+ GimpLayer *layer;
+ GimpContext *context = gimp_context_new (gimp, "Test", NULL /*template*/);
+ gboolean result;
+
+ g_assert_cmpint (gimp_image_get_n_layers (image), ==, 0);
+
+ layer = gimp_layer_new (image,
+ GIMP_TEST_IMAGE_SIZE,
+ GIMP_TEST_IMAGE_SIZE,
+ GIMP_RGBA_IMAGE,
+ "Test Layer",
+ 1.0,
+ GIMP_NORMAL_MODE);
+
+ g_assert_cmpint (GIMP_IS_LAYER (layer), ==, TRUE);
+
+ result = gimp_image_add_layer (image,
+ layer,
+ GIMP_IMAGE_ACTIVE_PARENT,
+ 0,
+ FALSE);
+
+ gimp_item_rotate (GIMP_ITEM (layer), context, GIMP_ROTATE_90, 0., -10., TRUE);
+
+ g_assert_cmpint (result, ==, TRUE);
+ g_assert_cmpint (gimp_image_get_n_layers (image), ==, 1);
+ g_object_unref (context);
+}
+
+/**
* add_layer:
* @fixture:
* @data:
@@ -196,10 +240,15 @@ main (int argc,
/* Add tests */
ADD_IMAGE_TEST (add_layer);
ADD_IMAGE_TEST (remove_layer);
+ ADD_IMAGE_TEST (rotate_non_overlapping);
/* Run the tests */
result = g_test_run ();
+ /* Don't write files to the source dir */
+ gimp_test_utils_set_gimp2_directory ("GIMP_TESTING_ABS_TOP_BUILDDIR",
+ "app/tests/gimpdir-output");
+
/* Exit so we don't break script-fu plug-in wire */
gimp_exit (gimp, TRUE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]