From 511cb28e17a9c544b761faf9186dcb9062cd3358 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Fri, 26 Mar 2021 18:20:00 +0200 Subject: [PATCH] properties: clear SPA_DICT_FLAG_SORTED when adding/removing items This allows calling spa_dict_qsort() externally on the dict, ensuring that lookups will not break when items are added or removed. --- src/pipewire/properties.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pipewire/properties.c b/src/pipewire/properties.c index d4499543a..ec7cf847d 100644 --- a/src/pipewire/properties.c +++ b/src/pipewire/properties.c @@ -396,6 +396,7 @@ static int do_replace(struct pw_properties *properties, const char *key, char *v if (value == NULL) return 0; add_func(properties, strdup(key), copy ? strdup(value) : value); + SPA_FLAG_CLEAR(properties->dict.flags, SPA_DICT_FLAG_SORTED); } else { struct spa_dict_item *item = pw_array_get_unchecked(&impl->items, index, struct spa_dict_item); @@ -412,6 +413,7 @@ static int do_replace(struct pw_properties *properties, const char *key, char *v item->value = last->value; impl->items.size -= sizeof(struct spa_dict_item); properties->dict.n_items--; + SPA_FLAG_CLEAR(properties->dict.flags, SPA_DICT_FLAG_SORTED); } else { free((char *) item->value); item->value = copy ? strdup(value) : value;