[gimp] app: some random code cleanup



commit 069996d75fd515b48955fc6c32f89c483540d49e
Author: Michael Natterer <mitch gimp org>
Date:   Mon Jun 2 20:17:39 2014 +0200

    app: some random code cleanup

 app/core/gimpboundary.c          |    9 +++++++--
 app/core/gimpscanconvert.c       |    9 +++++----
 app/tools/gimpregionselecttool.c |   33 ++++++++++++++++-----------------
 3 files changed, 28 insertions(+), 23 deletions(-)
---
diff --git a/app/core/gimpboundary.c b/app/core/gimpboundary.c
index ff370a8..51becef 100644
--- a/app/core/gimpboundary.c
+++ b/app/core/gimpboundary.c
@@ -132,7 +132,7 @@ static void       simplify_subdivide  (const GimpBoundSeg  *segs,
 
 /**
  * gimp_boundary_find:
- * @maskPR:    any PixelRegion
+ * @buffer:    a #GeglBuffer
  * @format:    a #Babl float format representing the component to analyze
  * @type:      type of bounds
  * @x1:        left side of bounds
@@ -225,7 +225,9 @@ gimp_boundary_sort (const GimpBoundSeg *segs,
   if (num_segs == 0)
     return NULL;
 
-  /* prepare arrays with GimpBoundSeg pointers sorted by xy1 and xy2 accordingly */
+  /* prepare arrays with GimpBoundSeg pointers sorted by xy1 and xy2
+   * accordingly
+   */
   segs_ptrs_by_xy1 = g_new (const GimpBoundSeg *, num_segs);
   segs_ptrs_by_xy2 = g_new (const GimpBoundSeg *, num_segs);
 
@@ -387,6 +389,9 @@ gimp_boundary_offset (GimpBoundSeg *segs,
 {
   gint i;
 
+  g_return_if_fail ((segs == NULL && num_segs == 0) ||
+                    (segs != NULL && num_segs >  0));
+
   for (i = 0; i < num_segs; i++)
     {
       /* dont offset sorting sentinels */
diff --git a/app/core/gimpscanconvert.c b/app/core/gimpscanconvert.c
index 833ed29..0c7df76 100644
--- a/app/core/gimpscanconvert.c
+++ b/app/core/gimpscanconvert.c
@@ -247,10 +247,11 @@ gimp_scan_convert_stroke (GimpScanConvert *sc,
                           GArray          *dash_info)
 {
   sc->do_stroke = TRUE;
-  sc->width = width;
-  sc->join  = join;
-  sc->cap   = cap;
-  sc->miter = miter;
+  sc->width     = width;
+  sc->join      = join;
+  sc->cap       = cap;
+  sc->miter     = miter;
+
   if (sc->dash_info)
     {
       g_array_free (sc->dash_info, TRUE);
diff --git a/app/tools/gimpregionselecttool.c b/app/tools/gimpregionselecttool.c
index 3dca9fa..bd4caf8 100644
--- a/app/tools/gimpregionselecttool.c
+++ b/app/tools/gimpregionselecttool.c
@@ -343,7 +343,7 @@ gimp_region_select_tool_calculate (GimpRegionSelectTool *region_sel,
                                    gint                 *n_segs)
 {
   GimpDisplayShell *shell = gimp_display_get_shell (display);
-  GimpBoundSeg     *segs;
+  GimpBoundSeg     *segs  = NULL;
 
   gimp_display_shell_set_override_cursor (shell, GDK_WATCH);
 
@@ -354,26 +354,25 @@ gimp_region_select_tool_calculate (GimpRegionSelectTool *region_sel,
     GIMP_REGION_SELECT_TOOL_GET_CLASS (region_sel)->get_mask (region_sel,
                                                               display);
 
-  if (! region_sel->region_mask)
+  if (region_sel->region_mask)
+    {
+      /*  calculate and allocate a new segment array which represents
+       *  the boundary of the contiguous region
+       */
+      segs = gimp_boundary_find (region_sel->region_mask, NULL,
+                                 babl_format ("Y float"),
+                                 GIMP_BOUNDARY_WITHIN_BOUNDS,
+                                 0, 0,
+                                 gegl_buffer_get_width  (region_sel->region_mask),
+                                 gegl_buffer_get_height (region_sel->region_mask),
+                                 GIMP_BOUNDARY_HALF_WAY,
+                                 n_segs);
+    }
+  else
     {
-      gimp_display_shell_unset_override_cursor (shell);
-
       *n_segs = 0;
-      return NULL;
     }
 
-  /*  calculate and allocate a new segment array which represents the
-   *  boundary of the contiguous region
-   */
-  segs = gimp_boundary_find (region_sel->region_mask, NULL,
-                             babl_format ("Y float"),
-                             GIMP_BOUNDARY_WITHIN_BOUNDS,
-                             0, 0,
-                             gegl_buffer_get_width  (region_sel->region_mask),
-                             gegl_buffer_get_height (region_sel->region_mask),
-                             GIMP_BOUNDARY_HALF_WAY,
-                             n_segs);
-
   gimp_display_shell_unset_override_cursor (shell);
 
   return segs;


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