ui/winui/table.cpp

changeset 13
5a8762fcfecc
parent 3
f154867f54dc
child 18
af411868ab9b
--- a/ui/winui/table.cpp	Tue Jan 30 11:58:11 2024 +0100
+++ b/ui/winui/table.cpp	Tue Jan 30 13:31:25 2024 +0100
@@ -410,12 +410,17 @@
 			// depending on the type, we create different cell controls
 			UiModelType type = model->types[col];
 			switch (type) {
+				case UI_STRING_FREE:
 				case UI_STRING: {
 					TextBlock cell = TextBlock();
 					cell.Padding(cellpadding);
 					cell.VerticalAlignment(VerticalAlignment::Stretch);
-					textblock_set_str(cell, (char*)getvalue(elm, model_col));
+					char *val = (char*)getvalue(elm, model_col);
+					textblock_set_str(cell, val);
 					cellBorder.Child(cell);
+					if (type == UI_STRING_FREE && val) {
+						free(val);
+					}
 
 					break;
 				}
@@ -438,6 +443,7 @@
 					}
 					break;
 				}
+				case UI_ICON_TEXT_FREE:
 				case UI_ICON_TEXT: {
 					StackPanel cellPanel = StackPanel();
 					cellPanel.Spacing(2);
@@ -455,6 +461,9 @@
 					textblock_set_str(cell, str);
 					cellPanel.Children().Append(cell);
 					cellBorder.Child(cellPanel);
+					if (type == UI_ICON_TEXT_FREE && str) {
+						free(str);
+					}
 					break;
 				}
 			}

mercurial