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

Editor shortcuts are reset on each start #53372

Closed
KoBeWi opened this issue Oct 3, 2021 · 4 comments · Fixed by #53753
Closed

Editor shortcuts are reset on each start #53372

KoBeWi opened this issue Oct 3, 2021 · 4 comments · Fixed by #53753

Comments

@KoBeWi
Copy link
Member

KoBeWi commented Oct 3, 2021

Godot version

66ab3ce

System information

W10

Issue description

When you open editor, all editor shortcuts are default.

Steps to reproduce

  1. Open editor settings
  2. Mess with shortcuts
  3. Close editor
  4. Open again
  5. Your fancy custom shortcuts are gone

Minimal reproduction project

No response

@KoBeWi
Copy link
Member Author

KoBeWi commented Oct 7, 2021

The issue is gone without a trace. How mysterious 😒

@KoBeWi KoBeWi closed this as completed Oct 7, 2021
@KoBeWi
Copy link
Member Author

KoBeWi commented Oct 13, 2021

Reopening, something is definitely wrong here:
jdH3BJRy5T
I can't save this shortcut. Whatever I define, it doesn't appear in editor_settings.tres. Interestingly, the step with revert arrow IS saved, so the editor explicitly saves empty shortcut (even if it's the same as default) and when I revert, it reverts to the shortcut I previously tried to assign and it doesn't get saved. This might randomly happen with any other shortcut. Default value gets messed up and your shortcut won't be saved.

Might be related #53373
Also most likely caused by #51273
CC @EricEzaM

@KoBeWi KoBeWi reopened this Oct 13, 2021
@EricEzaM
Copy link
Contributor

EricEzaM commented Oct 13, 2021

@KoBeWi Yep it is a bug, thanks.

I think #51273 did cause the issue. In that code, the "original" for each shortcut was set as below when it is registered in editor settings. As you can see, the events AND the original (used for change checks and saving) references the same object. So when an event was added to the events array, it was also added to the "original". This is why saving and the revert button were messed up.

sc->set_events(events);
sc->set_meta("original", events);

I think this should be enough to fix it.

sc->set_events(events);
sc->set_meta("original", events.duplicate(true));

@EricEzaM
Copy link
Contributor

This also affected the undo-redo capability of the editor shortcuts. Passing around & storing pointers, man...

When testing the changes above in editor_settings.cpp, there were still issues:

  1. Set Shortcut (revert icon would appear)
  2. Revert
  3. Set shortcut again to same value
  4. Revert icon would not longer be there. Clearing the value would show the revert button, but it would be reverted back to the shortcut you pressed, which is not the actual default.

It appears the last culprit is in settings_config_dialog.cpp, where we get the shortcut events and add them as a meta value on the tree item. This is all passed by reference, which of course means that by the time you get to creating the undo_redo action, the shortcut events are already updated since it is the same memory. I'm not sure how this was affecting the value of the "original" array, but fixing this also fixed the issue described in the above steps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants