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

Error when assigning unnamed GDScript with exported variables #75764

Closed
anvilfolk opened this issue Apr 6, 2023 · 5 comments · Fixed by #75938
Closed

Error when assigning unnamed GDScript with exported variables #75764

anvilfolk opened this issue Apr 6, 2023 · 5 comments · Fixed by #75938

Comments

@anvilfolk
Copy link
Contributor

anvilfolk commented Apr 6, 2023

Godot version

master

System information

W11

Issue description

This issue only happens in master, it does not occur in 4.0.2 so it is a recent regression.

When assigning a script without a class_name and with at least one @export variable to a node in the scene tree (and every time you save the script after), you will get an error: Class name cannot be empty.

The error appears to originate from the first line of Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p_fallback):

ERR_FAIL_COND_V_MSG(p_class.is_empty(), nullptr, "Class name cannot be empty.");

Steps to reproduce

Create a script with

extends Node

@export var x : int

Then assign it to a node in your scene. The error will occur. Remove the @export and it will no longer occur. Add it again, and it will, every time you save the file.

Minimal reproduction project

N/A

@YuriSizov
Copy link
Contributor

I guess it's a regression from #75472.

@YuriSizov YuriSizov added this to the 4.1 milestone Apr 6, 2023
@anvilfolk
Copy link
Contributor Author

I guess it's a regression from #75472.

That sounds right, from the stack trace I was looking at it seemed to specifically be related to _extension being null, so hopefully a simple check ought to fix it?

@anvilfolk
Copy link
Contributor Author

So the error is in line 2779:

https://github.com/godotengine/godot/blob/master/editor/editor_inspector.cpp#L2761-L2782

script_name is empty because script_name = EditorNode::get_editor_data().script_class_get_name(scr->get_path()); returns empty since the path doesn't lead to a name. I guess here we want to default to something like GDScript or something?

I don't know enough about this part to be helpful :)

@anvilfolk
Copy link
Contributor Author

I'm working on a fix for one :)

@capnm
Copy link
Contributor

capnm commented Apr 11, 2023

Here you get the same error even if you assign a value:

extends Node
@export var y := 1 :
	set(v):
		pass

Deselect / select the Node with the attached script:

ERROR: Class name cannot be empty.
at: get_class_icon (editor/editor_node.cpp:4471)
...

Note: Seems to be undocumented, no idea if it is still supported ...
how-to-use-godot-4-setget

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.

3 participants