[gimp] app: bail out in gimp_blend_tool_initialize() if there is no gradient



commit 6de9615154645fdec0af5d69051ca23011a553c1
Author: Michael Natterer <mitch gimp org>
Date:   Sun Apr 3 00:32:59 2011 +0200

    app: bail out in gimp_blend_tool_initialize() if there is no gradient

 app/tools/gimpblendtool.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/app/tools/gimpblendtool.c b/app/tools/gimpblendtool.c
index 858fa76..f1ce1c8 100644
--- a/app/tools/gimpblendtool.c
+++ b/app/tools/gimpblendtool.c
@@ -153,8 +153,9 @@ gimp_blend_tool_initialize (GimpTool     *tool,
                             GimpDisplay  *display,
                             GError      **error)
 {
-  GimpImage    *image    = gimp_display_get_image (display);
-  GimpDrawable *drawable = gimp_image_get_active_drawable (image);
+  GimpImage        *image    = gimp_display_get_image (display);
+  GimpDrawable     *drawable = gimp_image_get_active_drawable (image);
+  GimpBlendOptions *options  = GIMP_BLEND_TOOL_GET_OPTIONS (tool);
 
   if (! GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error))
     {
@@ -182,6 +183,13 @@ gimp_blend_tool_initialize (GimpTool     *tool,
       return FALSE;
     }
 
+  if (! gimp_context_get_gradient (GIMP_CONTEXT (options)))
+    {
+      g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
+                           _("No gradient available for use with this tool."));
+      return FALSE;
+    }
+
   return TRUE;
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]