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

Fix DynamicFont breaking mouse grab in inspector spinners #40701

Closed
wants to merge 1 commit into from

Conversation

opl-
Copy link
Contributor

@opl- opl- commented Jul 25, 2020

This was caused by DynamicFont not specifying which property was edited, resulting in the whole inspector being recreated

Fixes #25046

Edit: Valuable lessons about code formatting and the tools associated have been learned.

@opl- opl- force-pushed the fix/25046 branch 2 times, most recently from 7b32780 to 79b59b6 Compare July 25, 2020 17:24
@pouleyKetchoupp pouleyKetchoupp added this to the 4.0 milestone Jul 25, 2020
Comment on lines 795 to 799
#define SET_SPACING_VALUE(NAME) \
spacing_##NAME = p_value; \
emit_changed(); \
_change_notify("extra_spacing_" #NAME);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this trivial case, the define is probably not needed. It only saves a few lines of code and the code would be more easily readable without it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was a bit on the fence about this myself. The main reason for this was that seemingly _change_notify was always called before emit_changed, but looking at other resources it's not a requirement.

I'll push the change after testing it to make sure. It seems current master broke GDScript's tool which I'm relying on for testing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even it emit_changed() should be kept first, it's ok to have it duplicated in the four branches.

Copy link
Contributor Author

@opl- opl- Jul 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it and rebased the branch to an older commit from master as #40598 doesn't yet have support for tool which is rather useful for testing here.

Edit: Apparently in my confusion I forgot to actually stage the relevant change. I also noticed that according to the PR tool works, but has been replaced with an @tool annotation. Will correctly fix this in a bit.

@pouleyKetchoupp
Copy link
Contributor

This fix would work, although we might also want to properly fix the more general unwanted behavior with spinners (probably outside of this PR's scope).
See #25046 (comment)

@@ -677,7 +677,7 @@ DynamicFontAtSize::~DynamicFontAtSize() {

/////////////////////////

void DynamicFont::_reload_cache() {
void DynamicFont::_reload_cache(const char *p_triggering_property) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any specific reason for const char * over const String &?

Copy link
Contributor Author

@opl- opl- Jul 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lack of my knowledge about project conventions. Also, _change_notify takes in const char *, so I reused the type.

This was caused by DynamicFont not specifying which property was edited, resulting in the whole inspector property tree being recreated.

Fixes godotengine#25046
@opl- opl- requested a review from akien-mga August 3, 2020 12:32
@aaronfranke
Copy link
Member

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

@opl-
Copy link
Contributor Author

opl- commented Mar 1, 2021

@aaronfranke It seems that this is still an issue on master, but since #45879 the property change detection system works differently, so I'd have to look into it again and create an entirely new PR.

Meanwhile, this fix is still relevant to the 3.2 branch so we could just change the target branch for this PR.

@Calinou
Copy link
Member

Calinou commented Mar 20, 2021

This pull request should be reopened against the 3.x branch (I'm not sure if we can change the base branch cleanly).

@opl-
Copy link
Contributor Author

opl- commented Mar 21, 2021

The Edit button next to the title shows a dropdown that allows changing the target branch. We could try to see if it works. If it doesn't, at least we learned something and I'll open a new PR.

@Calinou Calinou changed the base branch from master to 3.x March 21, 2021 10:42
@Calinou Calinou requested review from a team as code owners March 21, 2021 10:42
@Calinou Calinou requested review from a team as code owners March 21, 2021 10:42
@Calinou Calinou removed request for a team and akien-mga March 21, 2021 10:43
@Calinou Calinou changed the base branch from 3.x to master March 21, 2021 10:44
@Calinou
Copy link
Member

Calinou commented Mar 21, 2021

@opl- It looks like it's not working, so I had to revert it. Please open a new pull request against the 3.x branch.

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.

The pointer skips away by dragging over an integer value in the Inspector
5 participants