[Bf-blender-cvs] [c167e8ba18d] master: Cleanup: Use new BLI_rct utilities to ensure valid rectangles

Julian Eisel noreply at git.blender.org
Tue Jan 14 19:09:20 CET 2020


Commit: c167e8ba18d5457135dce8d654fa8eda30c20786
Author: Julian Eisel
Date:   Tue Jan 14 19:04:27 2020 +0100
Branches: master
https://developer.blender.org/rBc167e8ba18d5457135dce8d654fa8eda30c20786

Cleanup: Use new BLI_rct utilities to ensure valid rectangles

Technically this does a slight change to the check in wm_window.c: The
assert now also allows zero width/height rectangles.

===================================================================

M	source/blender/blenlib/intern/rct.c
M	source/blender/editors/screen/area.c
M	source/blender/windowmanager/intern/wm_window.c

===================================================================

diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c
index 5fb33072231..8fab4ed8e6a 100644
--- a/source/blender/blenlib/intern/rct.c
+++ b/source/blender/blenlib/intern/rct.c
@@ -439,42 +439,22 @@ void BLI_rcti_union(rcti *rct1, const rcti *rct2)
 
 void BLI_rctf_init(rctf *rect, float xmin, float xmax, float ymin, float ymax)
 {
-  if (xmin <= xmax) {
-    rect->xmin = xmin;
-    rect->xmax = xmax;
-  }
-  else {
-    rect->xmax = xmin;
-    rect->xmin = xmax;
-  }
-  if (ymin <= ymax) {
-    rect->ymin = ymin;
-    rect->ymax = ymax;
-  }
-  else {
-    rect->ymax = ymin;
-    rect->ymin = ymax;
-  }
+  rect->xmin = xmin;
+  rect->xmax = xmax;
+  rect->ymin = ymin;
+  rect->ymax = ymax;
+
+  BLI_rctf_sanitize(rect);
 }
 
 void BLI_rcti_init(rcti *rect, int xmin, int xmax, int ymin, int ymax)
 {
-  if (xmin <= xmax) {
-    rect->xmin = xmin;
-    rect->xmax = xmax;
-  }
-  else {
-    rect->xmax = xmin;
-    rect->xmin = xmax;
-  }
-  if (ymin <= ymax) {
-    rect->ymin = ymin;
-    rect->ymax = ymax;
-  }
-  else {
-    rect->ymax = ymin;
-    rect->ymin = ymax;
-  }
+  rect->xmin = xmin;
+  rect->xmax = xmax;
+  rect->ymin = ymin;
+  rect->ymax = ymax;
+
+  BLI_rcti_sanitize(rect);
 }
 
 /**
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 29626fb6a8f..3c5400bd021 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -1438,9 +1438,8 @@ static void region_rect_recursive(
       }
 
       /* Fix any negative dimensions. This can happen when a quad split 3d view gets to small. (see
-       * T72200). BLI_rcti_init() sanitizes, making sure min values are <= max values. */
-      BLI_rcti_init(
-          &ar->winrct, ar->winrct.xmin, ar->winrct.xmax, ar->winrct.ymin, ar->winrct.ymax);
+       * T72200). */
+      BLI_rcti_sanitize(&ar->winrct);
 
       quad++;
     }
@@ -2902,7 +2901,7 @@ void ED_region_info_draw(ARegion *ar,
                          float fill_color[4],
                          const bool full_redraw)
 {
-  ED_region_info_draw_multiline(ar, (const char * [2]){text, NULL}, fill_color, full_redraw);
+  ED_region_info_draw_multiline(ar, (const char *[2]){text, NULL}, fill_color, full_redraw);
 }
 
 #define MAX_METADATA_STR 1024
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index a711b35e2c9..e7b6d65a3f9 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -2191,8 +2191,8 @@ void WM_window_screen_rect_calc(const wmWindow *win, rcti *r_rect)
     }
   }
 
-  BLI_assert(screen_rect.xmin < screen_rect.xmax);
-  BLI_assert(screen_rect.ymin < screen_rect.ymax);
+  BLI_assert(BLI_rcti_is_valid(&screen_rect));
+
   *r_rect = screen_rect;
 }



More information about the Bf-blender-cvs mailing list