diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/interface/interface_align.c | 16 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 7 |
2 files changed, 20 insertions, 3 deletions
diff --git a/source/blender/editors/interface/interface_align.c b/source/blender/editors/interface/interface_align.c index 59436276277..8edae5d8740 100644 --- a/source/blender/editors/interface/interface_align.c +++ b/source/blender/editors/interface/interface_align.c @@ -31,6 +31,8 @@ #include "interface_intern.h" +#include "MEM_guardedalloc.h" + #ifdef USE_UIBUT_SPATIAL_ALIGN /** @@ -416,7 +418,16 @@ void ui_block_align_calc(uiBlock *block, const ARegion *region) return; } - butal_array = alloca(sizeof(*butal_array) * (size_t)num_buttons); + /* Note that this is typically less than ~20, and almost always under ~100. + * Even so, we can't ensure this value won't exceed available stack memory. + * Fallback to allocation instead of using #alloca, see: T78636. */ + ButAlign butal_array_buf[256]; + if (num_buttons <= ARRAY_SIZE(butal_array_buf)) { + butal_array = butal_array_buf; + } + else { + butal_array = MEM_mallocN(sizeof(*butal_array) * num_buttons, __func__); + } memset(butal_array, 0, sizeof(*butal_array) * (size_t)num_buttons); /* Second loop: we initialize our ButAlign data for each button. */ @@ -515,6 +526,9 @@ void ui_block_align_calc(uiBlock *block, const ARegion *region) } } } + if (butal_array_buf != butal_array) { + MEM_freeN(butal_array); + } } # undef SIDE_TO_UI_BUT_ALIGN diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 858b48ba9fa..f027a62cbfd 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -947,8 +947,11 @@ static uiBut *ui_item_with_label(uiLayout *layout, const bool use_prop_sep = ((layout->item.flag & UI_ITEM_PROP_SEP) != 0); #endif - /* Always align item with label since text is already given enough space not to overlap. */ - sub = uiLayoutRow(layout, true); + /* Previously 'align' was enabled to make sure the label is spaced closely to the button. + * Set the space to zero instead as aligning a large number of labels can end up aligning + * thousands of buttons when displaying key-map search (a heavy operation), see: T78636. */ + sub = uiLayoutRow(layout, false); + sub->space = 0; UI_block_layout_set_current(block, sub); #ifdef UI_PROP_DECORATE |