From a937e93fd610d4c6f4f89532f562ee698535c9be Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 12 Dec 2013 01:15:29 +0100 Subject: input: fix bogus section disabling, add debugging output The code to remove a section from the active section array wasn't correct (it should have tried to copy the elements in reverse), so just replace it with a macro that does the intended thing. Add some debug output to print the section stack. --- mpvcore/input/input.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/mpvcore/input/input.c b/mpvcore/input/input.c index 8b31352f72..dbda34ed40 100644 --- a/mpvcore/input/input.c +++ b/mpvcore/input/input.c @@ -2190,9 +2190,8 @@ void mp_input_disable_section(struct input_ctx *ictx, char *name) for (int i = ictx->num_active_sections - 1; i >= 0; i--) { struct active_section *as = &ictx->active_sections[i]; if (strcmp(as->name, name) == 0) { - for (int x = i; i < ictx->num_active_sections - 1; i++) - ictx->active_sections[x] = ictx->active_sections[x + 1]; - ictx->num_active_sections--; + MP_TARRAY_REMOVE_AT(ictx->active_sections, + ictx->num_active_sections, i); } } input_unlock(ictx); @@ -2205,10 +2204,19 @@ void mp_input_enable_section(struct input_ctx *ictx, char *name, int flags) mp_input_disable_section(ictx, name); + MP_VERBOSE(ictx, "enable section '%s'\n", name); + if (ictx->num_active_sections < MAX_ACTIVE_SECTIONS) { ictx->active_sections[ictx->num_active_sections++] = (struct active_section) {name, flags}; } + + MP_DBG(ictx, "active section stack:\n"); + for (int n = 0; n < ictx->num_active_sections; n++) { + MP_DBG(ictx, " %s %d\n", ictx->active_sections[n].name, + ictx->active_sections[n].flags); + } + input_unlock(ictx); } -- cgit v1.2.3