[gimp] Bug 565001 - Text-Tool crashes when edit a 2.4.2 version xcf
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 565001 - Text-Tool crashes when edit a 2.4.2 version xcf
- Date: Sun, 21 Feb 2010 13:34:10 +0000 (UTC)
commit 41a277f040f1b6b00b500bdd9d8fdff86a98267a
Author: Michael Natterer <mitch gimp org>
Date: Sun Feb 21 14:33:33 2010 +0100
Bug 565001 - Text-Tool crashes when edit a 2.4.2 version xcf
Convert the rectangle size from pixels to units before setting it as
box-width and box-height on the text object.
app/tools/gimptexttool.c | 50 ++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 46 insertions(+), 4 deletions(-)
---
diff --git a/app/tools/gimptexttool.c b/app/tools/gimptexttool.c
index 042c847..fb835d8 100644
--- a/app/tools/gimptexttool.c
+++ b/app/tools/gimptexttool.c
@@ -38,6 +38,7 @@
#include "core/gimplayer-floating-sel.h"
#include "core/gimpmarshal.h"
#include "core/gimptoolinfo.h"
+#include "core/gimpunit.h"
#include "text/gimptext.h"
#include "text/gimptext-vectors.h"
@@ -865,6 +866,27 @@ gimp_text_tool_frame_item (GimpTextTool *text_tool)
text_tool->handle_rectangle_change_complete = TRUE;
}
+static gdouble
+pixels_to_units (Gimp *gimp,
+ gdouble pixels,
+ GimpUnit unit,
+ gdouble resolution)
+{
+ gdouble factor;
+
+ switch (unit)
+ {
+ case GIMP_UNIT_PIXEL:
+ return pixels;
+
+ default:
+ factor = _gimp_unit_get_factor (gimp, unit);
+
+ return pixels * factor / resolution;
+ break;
+ }
+}
+
static gboolean
gimp_text_tool_rectangle_change_complete (GimpRectangleTool *rect_tool)
{
@@ -900,10 +922,20 @@ gimp_text_tool_rectangle_change_complete (GimpRectangleTool *rect_tool)
(x2 - x1) != gimp_item_get_width (item) ||
(y2 - y1) != gimp_item_get_height (item))
{
+ gdouble xres, yres;
+
+ gimp_image_get_resolution (text_tool->image, &xres, &yres);
+
g_object_set (text_tool->proxy,
"box-mode", GIMP_TEXT_BOX_FIXED,
- "box-width", (gdouble) (x2 - x1),
- "box-height", (gdouble) (y2 - y1),
+ "box-width", pixels_to_units (text_tool->image->gimp,
+ x2 - x1,
+ text_tool->proxy->unit,
+ xres),
+ "box-height", pixels_to_units (text_tool->image->gimp,
+ y2 - y1,
+ text_tool->proxy->unit,
+ yres),
NULL);
gimp_image_undo_group_start (text_tool->image, GIMP_UNDO_GROUP_TEXT,
@@ -1312,10 +1344,20 @@ gimp_text_tool_create_layer (GimpTextTool *text_tool,
if (text_tool->text_box_fixed)
{
+ gdouble xres, yres;
+
+ gimp_image_get_resolution (image, &xres, &yres);
+
g_object_set (text_tool->proxy,
"box-mode", GIMP_TEXT_BOX_FIXED,
- "box-width", (gdouble) (x2 - x1),
- "box-height", (gdouble) (y2 - y1),
+ "box-width", pixels_to_units (image->gimp,
+ x2 - x1,
+ text_tool->proxy->unit,
+ xres),
+ "box-height", pixels_to_units (image->gimp,
+ y2 - y1,
+ text_tool->proxy->unit,
+ yres),
NULL);
}
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]