From ca43eb3016ef5ebe5cbdfe9bea2fbbb6410eeede Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Wed, 25 Aug 2021 13:56:01 +0200 Subject: [PATCH] =?UTF-8?q?particle/dynlist:=20don=E2=80=99t=20adjust=20sp?= =?UTF-8?q?acing=20if=20all=20sub-items=20are=20zero-width?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit That is, if all sub-items are zero-width, make sure *we* return a zero width, instead of a negative width. --- particles/dynlist.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/particles/dynlist.c b/particles/dynlist.c index 8c6319c..5b64dbe 100644 --- a/particles/dynlist.c +++ b/particles/dynlist.c @@ -1,6 +1,7 @@ #include "dynlist.h" #include +#include #define LOG_MODULE "dynlist" #include "../log.h" @@ -36,15 +37,24 @@ dynlist_begin_expose(struct exposable *exposable) const struct private *e = exposable->private; exposable->width = 0; + bool have_at_least_one = false; for (size_t i = 0; i < e->count; i++) { struct exposable *ee = e->exposables[i]; e->widths[i] = ee->begin_expose(ee); - exposable->width += e->left_spacing + e->widths[i] + e->right_spacing; + assert(e->widths[i] >= 0); + + if (e->widths[i] > 0) { + exposable->width += e->left_spacing + e->widths[i] + e->right_spacing; + have_at_least_one = true; + } } - exposable->width -= e->left_spacing + e->right_spacing; + if (have_at_least_one) + exposable->width -= e->left_spacing + e->right_spacing; + else + assert(exposable->width == 0); return exposable->width; }