From 9deb1508a04c80d0c39d9e1f69b11c7e43366911 Mon Sep 17 00:00:00 2001 From: Michael Webster Date: Mon, 17 Jun 2024 19:52:19 -0400 Subject: [PATCH] layout editor: Don't allow duplicate uuids when saving the layout. Nemo will complain if it's asked to add actions/menus with non- unique names. --- action-layout-editor/nemo_action_layout_editor.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/action-layout-editor/nemo_action_layout_editor.py b/action-layout-editor/nemo_action_layout_editor.py index 72f6b35cd..bb94692e5 100644 --- a/action-layout-editor/nemo_action_layout_editor.py +++ b/action-layout-editor/nemo_action_layout_editor.py @@ -438,15 +438,24 @@ def get_disabled(model, path, iter, data=None): self.nemo_plugin_settings.set_strv("disabled-actions", disabled) def serialize_model(self, parent, model): + used_uuids = {} result = [] iter = model.iter_children(parent) while iter: row_type = model.get_value(iter, ROW_TYPE) row = model.get_value(iter, ROW_OBJ) + raw_uuid = model.get_value(iter, ROW_UUID) + + uuid = raw_uuid + if raw_uuid in used_uuids: + uuid = raw_uuid + str(used_uuids[raw_uuid]) + used_uuids[raw_uuid] += 1 + else: + used_uuids[raw_uuid] = 0 item = { - 'uuid': model.get_value(iter, ROW_UUID), + 'uuid': uuid, 'type': row_type, 'user-label': row.get_custom_label(), 'user-icon': row.get_custom_icon()