Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dictionary values saved for instanced scene only when different from parent #29222

Closed
wants to merge 2 commits into from

Conversation

pouleyKetchoupp
Copy link
Contributor

This change makes dictionary comparison operators to check for differences in data, following the same logic as for arrays.

It allows dictionary export variables in instanced scenes to be compared to parents, so they are saved only when the data has been modified for the instance.

Fixes #29221

core/variant_op.cpp Outdated Show resolved Hide resolved
@pouleyKetchoupp pouleyKetchoupp force-pushed the fix-dict-save branch 2 times, most recently from d34a595 to 6eea702 Compare May 29, 2019 10:41
@akien-mga akien-mga requested a review from hpvb May 29, 2019 11:18
@akien-mga akien-mga requested a review from reduz June 19, 2019 10:09
@akien-mga
Copy link
Member

akien-mga commented Jun 19, 2019

Some comments from @reduz:

3:19 <reduz> Akien: idea is good, but it's not the most efficient way to do it
13:24 <Akien> reduz: any idea on what could be a more efficient implementation?
13:24 <reduz> i don't know, should think about it, the other problem is that doing this also means one need to check for cyclical inclusions so it's not that simple
13:25 <reduz> may be better to ask TMM or someone else for help on this
13:28 <reduz> it may be possible to do it also without asking for a list of items
13:28 <reduz> by just fixing Dictionary operator==

@pouleyKetchoupp
Copy link
Contributor Author

I don't mind spending more time to implement this fix in a better way, but if you want to give it to someone who knows the engine better it's fine too :)

Things I would like to clarify:

  • Cyclical inclusions: what is this problem exactly? Are we talking about the specific issue of comparing dictionaries, or more generally comparing export variables between instanced scenes and parents?
  • More efficient implementation: yes, it's possible to get rid of the allocation/copy of the list of keys/values by having the comparison logic in Dictionary rather than in Variant.
    Actually, the hash and duplicate functions in Dictionary could also get the same optimization.
  • Fix == operator: isn't it dangerous in term of functionality or performance to change this operator's behavior to a deep comparison? I would rather make a separate function like bool compare_values(const Dictionary &p_dictionary) to be safe.

@Xrayez
Copy link
Contributor

Xrayez commented Jul 21, 2019

This change makes dictionary comparison operators to check for differences in data, following the same logic as for arrays.

If this reflects the same logic as in Array, perhaps it could be merged then? This actually solves one of the recent issues described in above PR: #30715.

@pouleyKetchoupp
Copy link
Contributor Author

I've just pushed a fix for a regression I've spotted.

When modifying inputs for one of the default actions in project settings, it wasn't saved into the project file because no change was detected when comparing dictionaries.

It was due to arrays of events in the input map data being shared between the current settings and the initial settings it was comparing to. So now that deep comparison is done for dictionaries, I had to change project_settings_editor to make new copies of arrays of events when changing some values inside.

@QbieShay
Copy link
Contributor

Hi, I tested the PR but it doesn't seem to solve the issue for me. Can somebody else test too?

@aaronfranke
Copy link
Member

@pouleyKetchoupp Is this still desired? If so, it needs to be rebased on the latest master branch.

@pouleyKetchoupp
Copy link
Contributor Author

Closing in favor of #35816 which addresses the concerns raised on irc about this PR (#29222 (comment))

@aaronfranke aaronfranke added archived and removed cherrypick:3.1 cherrypick:3.x Considered for cherry-picking into a future 3.x release for pr meeting labels Jul 1, 2020
@pouleyKetchoupp pouleyKetchoupp deleted the fix-dict-save branch July 1, 2020 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dictionary values in instanced scene are not updated from parent
6 participants