Removed possible dead table memory bug for windows
Tables inside windows get removed if a windows is not longer in use inside `nk_free_window`. But I noticed that they are only removed if they were not used the last frame, because of a copy & paste bug. I removed the additional check and every table should now rightfully be marked as free. I don't know if this bug actually caused any problems, since I checked memory consumption and there were no symptoms of wrong behavior before.
This commit is contained in:
parent
4dc10b0753
commit
c51d0694ac
46
nuklear.h
46
nuklear.h
@ -1335,7 +1335,7 @@ NK_API struct nk_font* nk_font_atlas_add_compressed_base85(struct nk_font_atlas*
|
|||||||
const char *data, float height,
|
const char *data, float height,
|
||||||
const struct nk_font_config *config);
|
const struct nk_font_config *config);
|
||||||
NK_API const void* nk_font_atlas_bake(struct nk_font_atlas*, int *width, int *height,
|
NK_API const void* nk_font_atlas_bake(struct nk_font_atlas*, int *width, int *height,
|
||||||
enum nk_font_atlas_format);
|
enum nk_font_atlas_format);
|
||||||
NK_API void nk_font_atlas_end(struct nk_font_atlas*, nk_handle tex,
|
NK_API void nk_font_atlas_end(struct nk_font_atlas*, nk_handle tex,
|
||||||
struct nk_draw_null_texture*);
|
struct nk_draw_null_texture*);
|
||||||
NK_API void nk_font_atlas_clear(struct nk_font_atlas*);
|
NK_API void nk_font_atlas_clear(struct nk_font_atlas*);
|
||||||
@ -14805,12 +14805,10 @@ nk_free_window(struct nk_context *ctx, struct nk_window *win)
|
|||||||
while (it) {
|
while (it) {
|
||||||
/*free window state tables */
|
/*free window state tables */
|
||||||
n = it->next;
|
n = it->next;
|
||||||
if (it->seq != ctx->seq) {
|
nk_remove_table(win, it);
|
||||||
nk_remove_table(win, it);
|
nk_free_table(ctx, it);
|
||||||
nk_free_table(ctx, it);
|
if (it == win->tables)
|
||||||
if (it == win->tables)
|
win->tables = n;
|
||||||
win->tables = n;
|
|
||||||
}
|
|
||||||
it = n;
|
it = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17842,7 +17840,6 @@ nk_color_picker(struct nk_context *ctx, struct nk_color color,
|
|||||||
NK_API int
|
NK_API int
|
||||||
nk_chart_begin(struct nk_context *ctx, const enum nk_chart_type type,
|
nk_chart_begin(struct nk_context *ctx, const enum nk_chart_type type,
|
||||||
int count, float min_value, float max_value)
|
int count, float min_value, float max_value)
|
||||||
|
|
||||||
{
|
{
|
||||||
struct nk_window *win;
|
struct nk_window *win;
|
||||||
struct nk_chart *chart;
|
struct nk_chart *chart;
|
||||||
@ -17876,17 +17873,14 @@ nk_chart_begin(struct nk_context *ctx, const enum nk_chart_type type,
|
|||||||
chart->h = bounds.h - 2 * style->padding.y;
|
chart->h = bounds.h - 2 * style->padding.y;
|
||||||
chart->w = NK_MAX(chart->w, 2 * style->padding.x);
|
chart->w = NK_MAX(chart->w, 2 * style->padding.x);
|
||||||
chart->h = NK_MAX(chart->h, 2 * style->padding.y);
|
chart->h = NK_MAX(chart->h, 2 * style->padding.y);
|
||||||
nk_zero(&chart->slots[0], sizeof(chart->slots[0]) * NK_CHART_MAX_SLOT);
|
|
||||||
chart->slot = 0;
|
|
||||||
|
|
||||||
/* add first slot into chart */
|
/* add first slot into chart */
|
||||||
{struct nk_chart_slot *slot = &chart->slots[chart->slot];
|
{struct nk_chart_slot *slot = &chart->slots[chart->slot++];
|
||||||
slot->type = type;
|
slot->type = type;
|
||||||
slot->count = count;
|
slot->count = count;
|
||||||
slot->min = NK_MIN(min_value, max_value);
|
slot->min = NK_MIN(min_value, max_value);
|
||||||
slot->max = NK_MAX(min_value, max_value);
|
slot->max = NK_MAX(min_value, max_value);
|
||||||
slot->range = slot->max - slot->min;
|
slot->range = slot->max - slot->min;}
|
||||||
chart->slot++;}
|
|
||||||
|
|
||||||
/* draw chart background */
|
/* draw chart background */
|
||||||
background = &style->background;
|
background = &style->background;
|
||||||
@ -17913,13 +17907,12 @@ nk_chart_add_slot(struct nk_context *ctx, const enum nk_chart_type type,
|
|||||||
|
|
||||||
/* add another slot into the graph */
|
/* add another slot into the graph */
|
||||||
{struct nk_chart *chart = &ctx->current->layout->chart;
|
{struct nk_chart *chart = &ctx->current->layout->chart;
|
||||||
struct nk_chart_slot *slot = &chart->slots[chart->slot];
|
struct nk_chart_slot *slot = &chart->slots[chart->slot++];
|
||||||
slot->type = type;
|
slot->type = type;
|
||||||
slot->count = count;
|
slot->count = count;
|
||||||
slot->min = NK_MIN(min_value, max_value);
|
slot->min = NK_MIN(min_value, max_value);
|
||||||
slot->max = NK_MAX(min_value, max_value);
|
slot->max = NK_MAX(min_value, max_value);
|
||||||
slot->range = slot->max - slot->min;
|
slot->range = slot->max - slot->min;}
|
||||||
chart->slot++;}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NK_INTERN nk_flags
|
NK_INTERN nk_flags
|
||||||
@ -18019,7 +18012,7 @@ nk_chart_push_column(const struct nk_context *ctx, struct nk_window *win,
|
|||||||
item.w = (chart->w - padding) / (float)(chart->slots[slot].count);
|
item.w = (chart->w - padding) / (float)(chart->slots[slot].count);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* calculate bounds of the current bar chart entry */
|
/* calculate bounds of current bar chart entry */
|
||||||
style = &ctx->style.chart;
|
style = &ctx->style.chart;
|
||||||
color = style->color;
|
color = style->color;
|
||||||
item.h = chart->h * NK_ABS((value/chart->slots[slot].range));
|
item.h = chart->h * NK_ABS((value/chart->slots[slot].range));
|
||||||
@ -18055,9 +18048,9 @@ nk_chart_push_slot(struct nk_context *ctx, float value, int slot)
|
|||||||
NK_ASSERT(ctx);
|
NK_ASSERT(ctx);
|
||||||
NK_ASSERT(ctx->current);
|
NK_ASSERT(ctx->current);
|
||||||
NK_ASSERT(slot >= 0 && slot < NK_CHART_MAX_SLOT);
|
NK_ASSERT(slot >= 0 && slot < NK_CHART_MAX_SLOT);
|
||||||
NK_ASSERT (ctx->current->layout->chart.slot > slot);
|
NK_ASSERT(slot < ctx->current->layout->chart.slot);
|
||||||
if (!ctx || !ctx->current || slot >= NK_CHART_MAX_SLOT)
|
if (!ctx || !ctx->current || slot >= NK_CHART_MAX_SLOT) return nk_false;
|
||||||
return nk_false;
|
if (slot >= ctx->current->layout->chart.slot) return nk_false;
|
||||||
|
|
||||||
win = ctx->current;
|
win = ctx->current;
|
||||||
if (win->layout->chart.slot < slot) return nk_false;
|
if (win->layout->chart.slot < slot) return nk_false;
|
||||||
@ -18091,11 +18084,7 @@ nk_chart_end(struct nk_context *ctx)
|
|||||||
|
|
||||||
win = ctx->current;
|
win = ctx->current;
|
||||||
chart = &win->layout->chart;
|
chart = &win->layout->chart;
|
||||||
nk_zero(&chart->slots[0], sizeof(chart->slots[0]) * NK_CHART_MAX_SLOT);
|
memset(chart, 0, sizeof(*chart));
|
||||||
chart->x = 0;
|
|
||||||
chart->y = 0;
|
|
||||||
chart->w = 0;
|
|
||||||
chart->h = 0;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18137,8 +18126,9 @@ nk_plot_function(struct nk_context *ctx, enum nk_chart_type type, void *userdata
|
|||||||
|
|
||||||
max_value = min_value = value_getter(userdata, offset);
|
max_value = min_value = value_getter(userdata, offset);
|
||||||
for (i = 0; i < count; ++i) {
|
for (i = 0; i < count; ++i) {
|
||||||
min_value = NK_MIN(value_getter(userdata, i + offset), min_value);
|
float value = value_getter(userdata, i + offset);
|
||||||
max_value = NK_MAX(value_getter(userdata, i + offset), max_value);
|
min_value = NK_MIN(value, min_value);
|
||||||
|
max_value = NK_MAX(value, max_value);
|
||||||
}
|
}
|
||||||
nk_chart_begin(ctx, type, count, min_value, max_value);
|
nk_chart_begin(ctx, type, count, min_value, max_value);
|
||||||
for (i = 0; i < count; ++i)
|
for (i = 0; i < count; ++i)
|
||||||
@ -18474,7 +18464,7 @@ nk_tooltip_begin(struct nk_context *ctx, struct nk_panel *layout, float width)
|
|||||||
bounds.y = (in->mouse.pos.y + 1) - win->layout->clip.y;
|
bounds.y = (in->mouse.pos.y + 1) - win->layout->clip.y;
|
||||||
|
|
||||||
ret = nk_popup_begin(ctx, layout, NK_POPUP_DYNAMIC,
|
ret = nk_popup_begin(ctx, layout, NK_POPUP_DYNAMIC,
|
||||||
"__##Tooltip##__", NK_WINDOW_NO_SCROLLBAR|NK_WINDOW_TOOLTIP, bounds);
|
"__##Tooltip##__", NK_WINDOW_NO_SCROLLBAR|NK_WINDOW_TOOLTIP|NK_WINDOW_BORDER, bounds);
|
||||||
if (ret) win->layout->flags &= ~(nk_flags)NK_WINDOW_ROM;
|
if (ret) win->layout->flags &= ~(nk_flags)NK_WINDOW_ROM;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user