fixed undefined uninitialized memory behavior
This commit is contained in:
parent
fd5a380a0d
commit
8d4b3dca55
12
demo/demo.c
12
demo/demo.c
@ -244,9 +244,12 @@ widget_panel(struct gui_panel_layout *panel, struct state *demo)
|
||||
gui_panel_combo(panel, items, LEN(items), &demo->sel_item, 30, &demo->sel_act, gui_vec2(0,0));
|
||||
{
|
||||
/* progressbar combobox */
|
||||
gui_int sum;
|
||||
gui_char buffer[64];
|
||||
struct gui_panel_layout combo;
|
||||
gui_int sum = (gui_int)(demo->combo_prog[0] + demo->combo_prog[1]);
|
||||
memset(&combo, 0, sizeof(combo));
|
||||
|
||||
sum = (gui_int)(demo->combo_prog[0] + demo->combo_prog[1]);
|
||||
sum += (gui_int)(demo->combo_prog[2] + demo->combo_prog[3]);
|
||||
sprintf(buffer, "%d", sum);
|
||||
gui_panel_combo_begin(panel, &combo, buffer, &demo->prog_act, gui_vec2(0,0));
|
||||
@ -263,6 +266,7 @@ widget_panel(struct gui_panel_layout *panel, struct state *demo)
|
||||
/* color slider progressbar */
|
||||
gui_char buffer[32];
|
||||
struct gui_panel_layout combo;
|
||||
memset(&combo, 0, sizeof(combo));
|
||||
sprintf(buffer, "#%02x%02x%02x%02x", demo->combo_color.r, demo->combo_color.g,
|
||||
demo->combo_color.b, demo->combo_color.a);
|
||||
gui_panel_combo_begin(panel, &combo, buffer, &demo->col_act, gui_vec2(0,0));
|
||||
@ -283,9 +287,11 @@ widget_panel(struct gui_panel_layout *panel, struct state *demo)
|
||||
}
|
||||
{
|
||||
/* checkbox combobox */
|
||||
struct gui_panel_layout combo;
|
||||
gui_int sum;
|
||||
gui_char buffer[64];
|
||||
gui_int sum = demo->combo_sel[0] + demo->combo_sel[1];
|
||||
struct gui_panel_layout combo;
|
||||
memset(&combo, 0, sizeof(combo));
|
||||
sum = demo->combo_sel[0] + demo->combo_sel[1];
|
||||
sum += demo->combo_sel[2] + demo->combo_sel[3];
|
||||
sprintf(buffer, "%d", sum);
|
||||
gui_panel_combo_begin(panel, &combo, buffer, &demo->box_act, gui_vec2(0,0));
|
||||
|
7
gui.c
7
gui.c
@ -5566,6 +5566,7 @@ gui_panel_combo_begin(struct gui_panel_layout *parent, struct gui_panel_layout *
|
||||
if (!parent->valid || !gui_panel_widget(&header, parent))
|
||||
goto failed;
|
||||
|
||||
gui_zero(combo, sizeof(*combo));
|
||||
in = (parent->flags & GUI_PANEL_ROM) ? 0 : parent->input;
|
||||
is_active = *active;
|
||||
out = parent->buffer;
|
||||
@ -5680,8 +5681,9 @@ gui_panel_combo(struct gui_panel_layout *layout, const char **entries,
|
||||
if (!layout || !layout->valid || !entries || !current || !active) return;
|
||||
if (!count) return;
|
||||
|
||||
gui_zero(&combo, sizeof(combo));
|
||||
gui_panel_combo_begin(layout, &combo, entries[*current], active, scrollbar);
|
||||
gui_panel_row_dynamic(&combo, row_height, 1);
|
||||
gui_panel_row_dynamic(&combo, (gui_float)row_height, 1);
|
||||
for (i = 0; i < count; ++i) {
|
||||
if (i == *current) continue;
|
||||
if (gui_panel_button_fitting(&combo, entries[i], GUI_TEXT_LEFT, GUI_BUTTON_DEFAULT)) {
|
||||
@ -5718,6 +5720,7 @@ gui_panel_menu_begin(struct gui_panel_layout *parent, struct gui_panel_layout *m
|
||||
is_active = *active;
|
||||
in = parent->input;
|
||||
config = parent->config;
|
||||
gui_zero(menu, sizeof(*menu));
|
||||
{
|
||||
struct gui_button button;
|
||||
gui_panel_button(&button, &header, parent);
|
||||
@ -5792,7 +5795,7 @@ gui_panel_menu(struct gui_panel_layout *layout, const char *title,
|
||||
if (!count) return -1;
|
||||
|
||||
gui_panel_menu_begin(layout, &menu, title, width, active, scrollbar);
|
||||
gui_panel_row_dynamic(&menu, row_height, 1);
|
||||
gui_panel_row_dynamic(&menu, (gui_float)row_height, 1);
|
||||
for (i = 0; i < count; ++i) {
|
||||
if (gui_panel_button_fitting(&menu, entries[i], GUI_TEXT_CENTERED, GUI_BUTTON_DEFAULT)) {
|
||||
gui_panel_combo_close(&menu);
|
||||
|
Loading…
Reference in New Issue
Block a user