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 @export_category interfering with property tooltips #76147

Closed

Conversation

emr4378
Copy link

@emr4378 emr4378 commented Apr 16, 2023

Fixes #64432
Don't assume the category name can be used as the doc_name. Just leave it blank so it can be properly determined later on just before looking up cached doc info.

Fixes (not) #63997
update_tree() populates description-related caches, but nothing was ever clearing them out so they'd forever hold onto the first description seen.

@YuriSizov
Copy link
Contributor

cc @anvilfolk

@anvilfolk
Copy link
Contributor

Oh, very interesting! I can't take a deeper look right now, but the idea behind the first fix sounds really cool!!!

I'm not super sure on the second one. When is EditorInspector::_clear() called? If it's very often, I believe it might basically invalidate the use of the cache, right? There's another PR that might address this, I believe: #71843, and I think that #70217 is related to #63997 as well!

@emr4378
Copy link
Author

emr4378 commented Apr 19, 2023

AFAICT EditorInspector::_clear() is only called in EditorInspector::edit() (so whenever the node selection changes) and at the start of EditorInspector::update_tree(). I put the doc cache clearing there since that's where other caches were being reset.

But I think you're right and it's invalidating the benefit of these particular caches. I'll dig around to find better spot(s) to clear them out.

EDIT: Landed on clearing them when the node to inspect changes (edit()) and/or when the script itself changes (_edit_request_change()).

@emr4378 emr4378 force-pushed the exported-var-description-fixes branch from 211a6e5 to c88deee Compare April 19, 2023 07:01
@anvilfolk
Copy link
Contributor

anvilfolk commented Apr 21, 2023

Gave this a tiny little bit more thought - sorry it's taking a while, life has been hectic lately :)

So I suspect that #71843 is the better solution to #63997, of which I think #70217 is partially a duplicate. Instead of clearing the cache completely, it simply stops caching doc information that comes from GDScripts. This means that the cache works fully with the static documentation like @Globals and native classes. It's never cleared at any point, so it's always available and doesn't need to be re-cached.

GDScript stuff is then always obtained from EditorHelp/DocTools directly when it's needed, so it's never outdated.

I haven't gotten around to testing the other fix in this PR, since that part of the code can be pretty subtle! But I love the simplicity of it 🥳 How much testing have you managed to do on it? Would you be able to check that e.g. resource docstrings still work? And can we be 100% certain that doc_name is always being set before being used? :)

I'll try to get some more testing done myself, time is just hard to come by atm! :)

@anvilfolk
Copy link
Contributor

So I really want to test this but it's too much of a bother right now with having to restart the entire project every time you change docstrings so they update properly. #71843 fixes this but hasn't been accepted yet - I will come back to this once that's merged :)

@akien-mga
Copy link
Member

#71843 fixes this but hasn't been accepted yet - I will come back to this once that's merged :)

It was merged ;)

@akien-mga akien-mga modified the milestones: 4.1, 4.2 Jun 19, 2023
@akien-mga akien-mga added the cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release label Jun 19, 2023
@akien-mga akien-mga requested review from a team, KoBeWi and YuriSizov June 19, 2023 13:04
@anvilfolk
Copy link
Contributor

I see what you did there ;)

I will try to find some time to re-review this one sometime this week hopefully if I manage to catch up on class reading materials :)

@Calinou
Copy link
Member

Calinou commented Jun 19, 2023

The caching issue should be resolved in master, see #63997 (comment).

@anvilfolk
Copy link
Contributor

Correct! At this point the only outstanding issue should be the category issue, which I will attempt to test :) It's a single-line fix :)

@KoBeWi
Copy link
Member

KoBeWi commented Jun 20, 2023

The cache changes should be removed

I looked into what doc_name line tries to do. Seems like it's supposed to use category name as type to fetch the property description. It obviously breaks with custom categories.
It was added by #64246, but removing this line does not reintroduce the original issue, so this change is ok.

Copy link
Contributor

@anvilfolk anvilfolk left a comment

Choose a reason for hiding this comment

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

As long as the cache lines are removed, as @KoBeWi said, this fixes the issue.

The PR description is correct: there's no reason that a custom category should attempt to set doc_name, which is used to index where documentation can be found. That should be set once, when the script's own category is evaluated.

I couldn't find any regressions when using zero, one or multiple categories, or with the remaining categories, e.g. Node.

@emr4378, can you make these changes? :)

editor/editor_inspector.cpp Outdated Show resolved Hide resolved
editor/editor_inspector.cpp Outdated Show resolved Hide resolved
@YuriSizov
Copy link
Contributor

Looks like there is unaddressed feedback in the discussion above. @emr4378 Are you still interested in contributing? This needs a rebase too.

@anvilfolk
Copy link
Contributor

I'd say if someone with privileges for it wanted to amend this commit leaving only the removal of the doc_name = p.name; line, this would be good to merge. Sounds like the OP might be inactive at the moment, but could still be credited for fixing that bug :)

@akien-mga akien-mga changed the title Fixed issues with @export var tooltip descriptions Fix @export_category interfering with property tooltips Sep 30, 2023
@akien-mga akien-mga force-pushed the exported-var-description-fixes branch from c88deee to 992d678 Compare September 30, 2023 20:00
Don't assume the category name can be used as the `doc_name`. Just leave it
blank so it can be properly determined later on just before looking up cached
doc info.

Fixes godotengine#64432.
@akien-mga akien-mga force-pushed the exported-var-description-fixes branch from 992d678 to d3cdcd1 Compare September 30, 2023 20:01
@akien-mga
Copy link
Member

I updated this PR myself as advised by @anvilfolk, as OP seems to be inactive.

Should be ready to merge now.

@YuriSizov
Copy link
Contributor

YuriSizov commented Sep 30, 2023

Should be ready to merge now.

I wanted to wait for #82051 to be merged to make sure this still behaves as expected afterwards. It's probably fine, but the code related to all these class and doc names is not straightforward so I wanted to be sure.

@akien-mga
Copy link
Member

So I wanted to confirm the bug again to test the fix, and the bug seems already fixed since 4.2-dev5. Weird.

@akien-mga
Copy link
Member

@dalexeev Is this one line change still worth doing for good measure, or would risk introducing other issues?

@dalexeev
Copy link
Member

dalexeev commented Oct 2, 2023

I haven't tested this yet, but I suspect the change may break tooltips for native classes. I'll reply later.

@dalexeev
Copy link
Member

dalexeev commented Oct 2, 2023

I tested it. The code doesn't look correct to me, doc_name changes only for scripts, not for native classes. This breaks class descriptions and context menu "Open Documentation".

Before:

After:

@dalexeev
Copy link
Member

dalexeev commented Oct 2, 2023

Thanks for the contribution nonetheless!

@dalexeev dalexeev closed this Oct 2, 2023
@dalexeev dalexeev added archived and removed cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release labels Oct 2, 2023
@dalexeev dalexeev removed this from the 4.2 milestone Oct 2, 2023
@anvilfolk
Copy link
Contributor

Oh, damn, great catch @dalexeev, I had focused on testing GDScript classes! Glad you came along ❤️

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.

GDScript 2.0: @export_category interferes with the property inspector tooltip
7 participants