From 49a63f04ef790d22fa7c44fbc8ad818ca1e046ab Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" Date: Wed, 10 Nov 2021 08:47:19 -0500 Subject: [PATCH] asserts to prevent things from overflowing --- minigui.d | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/minigui.d b/minigui.d index 330cb80..4e90c45 100644 --- a/minigui.d +++ b/minigui.d @@ -7607,7 +7607,9 @@ class TableView : Widget { if(remaining < 0) remaining = 0; + int percentTotal; foreach(i, ref column; columns) { + percentTotal += column.widthPercent; auto c = column.width + (remaining * column.widthPercent) / 100; column.calculatedWidth = c; version(win32_widgets) @@ -7615,6 +7617,10 @@ class TableView : Widget { SendMessage(hwnd, LVM_SETCOLUMNWIDTH, i, c); // LVSCW_AUTOSIZE or LVSCW_AUTOSIZE_USEHEADER are amazing omg } + assert(percentTotal >= 0, "The total percents in your column definitions were negative. They must add up to something between 0 and 100."); + assert(percentTotal <= 100, "The total percents in your column definitions exceeded 100. They must add up to no more than 100 (can be less though)."); + + } override void registerMovement() {