summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornanahi <130121847+na-na-hi@users.noreply.github.com>2024-03-20 21:08:03 -0400
committerKacper Michajłow <kasper93@gmail.com>2024-03-21 03:11:19 +0100
commit520849dd48e34e68be09b5f4849fea1d5212fb44 (patch)
treed5e1bac0b4aab2f1d2327e3dcbaa2dcb8c57db7b
parenta5dbf340942d8844e694cd812d33a6f93d9309c4 (diff)
downloadmpv-520849dd48e34e68be09b5f4849fea1d5212fb44.tar.bz2
mpv-520849dd48e34e68be09b5f4849fea1d5212fb44.tar.xz
input: remove max active section limit
585d8c6856e8eaf77c518ad4679e8c66660fc440 increased max active section limit from 5 to 50 but this obviously doesn't properly fix the problem. Input still breaks if more than 25 scripts are loaded, or if some scripts define lots of input sections. Remove the limit completely by using a dynamic array for active sections. Fixes: https://github.com/mpv-player/mpv/issues/13707
-rw-r--r--input/input.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/input/input.c b/input/input.c
index f3b61f332d..9d14ce3b84 100644
--- a/input/input.c
+++ b/input/input.c
@@ -79,8 +79,6 @@ struct cmd_bind_section {
#define MP_MAX_SOURCES 10
-#define MAX_ACTIVE_SECTIONS 50
-
struct active_section {
char *name;
int flags;
@@ -142,7 +140,7 @@ struct input_ctx {
int num_sections;
// List currently active command sections
- struct active_section active_sections[MAX_ACTIVE_SECTIONS];
+ struct active_section *active_sections;
int num_active_sections;
unsigned int mouse_event_counter;
@@ -1017,20 +1015,16 @@ void mp_input_enable_section(struct input_ctx *ictx, char *name, int flags)
MP_TRACE(ictx, "enable section '%s'\n", name);
- if (ictx->num_active_sections < MAX_ACTIVE_SECTIONS) {
- int top = ictx->num_active_sections;
- if (!(flags & MP_INPUT_ON_TOP)) {
- // insert before the first top entry
- for (top = 0; top < ictx->num_active_sections; top++) {
- if (ictx->active_sections[top].flags & MP_INPUT_ON_TOP)
- break;
- }
- for (int n = ictx->num_active_sections; n > top; n--)
- ictx->active_sections[n] = ictx->active_sections[n - 1];
+ int top = ictx->num_active_sections;
+ if (!(flags & MP_INPUT_ON_TOP)) {
+ // insert before the first top entry
+ for (top = 0; top < ictx->num_active_sections; top++) {
+ if (ictx->active_sections[top].flags & MP_INPUT_ON_TOP)
+ break;
}
- ictx->active_sections[top] = (struct active_section){name, flags};
- ictx->num_active_sections++;
}
+ MP_TARRAY_INSERT_AT(ictx, ictx->active_sections, ictx->num_active_sections,
+ top, (struct active_section){name, flags});
MP_TRACE(ictx, "active section stack:\n");
for (int n = 0; n < ictx->num_active_sections; n++) {
@@ -1327,6 +1321,7 @@ struct input_ctx *mp_input_init(struct mpv_global *global,
.opts_cache = m_config_cache_alloc(ictx, global, &input_config),
.wakeup_cb = wakeup_cb,
.wakeup_ctx = wakeup_ctx,
+ .active_sections = talloc_array(ictx, struct active_section, 0),
};
ictx->opts = ictx->opts_cache->opts;