diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2020-01-15 15:03:51 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2020-01-15 17:05:11 +0300 |
commit | 758361556b5b9afff506e4247345b739c0f8170c (patch) | |
tree | d03600ab5b30503f5a7042fb7bbae5e6aa26e8d7 /source/blender/windowmanager/intern/wm_draw.c | |
parent | 0e94d8bbe09e1291d0b7acf60eab62297486e956 (diff) |
Fix invalid region rectangles, sanitize dynamic region size calulations
It was too easy to end up with invalid region rectangles and we were
badly protected against them, so that they were hard to catch.
In fact we still create a main region for the top-bar, which ended up
getting a region height of -1. While this doesn't seem to have caused
issues in practice, we should prevent them entirely.
So idea was that at the end of region layout resolving,
`BLI_rcti_is_valid()` should return `true` for the region rectangle.
Further changes here ensure this is true: The `RGN_FLAG_TOO_SMALL` flag
is now set whenever there is not enough space for a region or if it
would get a size of zero or less.
Note: Should the assert fail, please do not just disable it and try to
actually address the root of the issue.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_draw.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_draw.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 09b7d89fc2b..14d4e05b77a 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -581,7 +581,14 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo) /* Compute UI layouts for dynamically size regions. */ for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) { - if (ar->visible && ar->do_draw && ar->type && ar->type->layout) { + /* Dynamic region may have been flagged as too small because their size on init is 0. + * ARegion.visible is false then, as expected. The layout should still be created then, so + * the region size can be updated (it may turn out to be not too small then). */ + const bool ignore_visibility = (ar->flag & RGN_FLAG_DYNAMIC_SIZE) && + (ar->flag & RGN_FLAG_TOO_SMALL) && + !(ar->flag & RGN_FLAG_HIDDEN); + + if ((ar->visible || ignore_visibility) && ar->do_draw && ar->type && ar->type->layout) { CTX_wm_region_set(C, ar); ED_region_do_layout(C, ar); CTX_wm_region_set(C, NULL); |