Skip to content

Commit

Permalink
remove read-only workaround for dicts, only check if empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Okxa committed Mar 20, 2023
1 parent 70ca2bc commit e8cf74f
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions addons/dictionary_inspector/elements/dict_property_editor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,6 @@ func toggle_property_editable(container):
children[3].queue_free()
children[5].queue_free()

# workaround for dicts apparently sometimes being readonly to EditorPlugins
# basically just reassign the collection back and forth
func workaround_dict_read_only(dict, key, value):
var coll = {}
coll.merge(dict)
coll[key] = value
return coll

func update_variant(key, value, is_rename = false):
if is_rename:
if (typeof(value) != typeof(key) || value != key):
Expand All @@ -92,9 +84,6 @@ func update_variant(key, value, is_rename = false):
keys_by_index = stored_collection.keys()

else:
if stored_collection.is_read_only():
stored_collection = workaround_dict_read_only(stored_collection, key, value)
else:
stored_collection[key] = value

emit_signal("value_changed", stored_collection)
Expand All @@ -107,8 +96,8 @@ func _on_add_button_pressed():
var new_key = get_default_for_type(last_type_k, true)
var new_value = get_default_for_type(last_type_v)

if stored_collection.is_read_only():
stored_collection = workaround_dict_read_only(stored_collection, new_key, new_value)
if stored_collection.is_empty():
stored_collection = { new_key: new_value }
else:
stored_collection[new_key] = new_value
keys_by_index = stored_collection.keys()
Expand Down

0 comments on commit e8cf74f

Please sign in to comment.