Skip to content

Commit

Permalink
layout editor: Don't allow duplicate uuids when saving the layout.
Browse files Browse the repository at this point in the history
Nemo will complain if it's asked to add actions/menus with non-
unique names.
  • Loading branch information
mtwebster committed Jun 17, 2024
1 parent f67bfd3 commit 9deb150
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion action-layout-editor/nemo_action_layout_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 9deb150

Please sign in to comment.